Repository navigation
Conversation
`fromUnit` accepts both `policyId+assetName` and `policyId.assetName`, and has since it was written. `getByUnit` and `fromRecord` sliced at 56 characters unconditionally, so an asset built from a dotted unit read back as `0n` with the same string it was built from. `0n` is why this was worth finding: it reads as "this asset is not here" rather than as a parse failure, so a balance is simply wrong and nothing reports it. One `splitUnit` now serves all three. A dot cannot occur in hex, so the two spellings stay unambiguous.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One of the four fixes asked for in the closing comment on
#619 — smallest fix plus its test, nothing else.
The defect
fromUnitaccepts bothpolicyId+assetNameandpolicyId.assetName, and has since it was written.getByUnitandfromRecordsliced at 56 characters unconditionally, so an asset built from a dottedunit read back as
0nwith the same string it was built from.0nis why this was worth finding: it reads as "this asset is not here" rather than as a parsefailure, so a balance is simply wrong and nothing reports it.
The fix
One
splitUnitnow servesfromUnit,fromRecordandgetByUnit. A dot cannot occur in hex, sothe two spellings stay unambiguous.
Contents
packages/evolution/src/Assets.ts— the shared parse.packages/evolution/test/AssetsUnitSpelling.test.ts— both spellings through all three entrypoints, including the round-trip that answered
0n.Deliberately left out: the two CIP-21 ordering hunks from the original PR.
Verification
All six CI tasks run locally off
ci.ymlagainst this base (lint,type-check,test,build,check:dts,docgen): green.packages/evolution: 1920 passed, 75 skipped, 0 failed. The new test file fails on this base without the source change, so it does exercise it.devnet's suite needs Docker and was not run here.