Render Quantus addresses and chain metadata at prefix 189 #6
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of #1. Depends on the
@polkadot/networksentry in quantus/common#1.Mostly free, once the network is registered
The address path needs no structural change.
components/Address.tsxdoes:A Quantus account id is 32 bytes, so
encodeAddress/decodeAddresswork unchanged — the variable is namedpublicKeyand is really an account id, which is misleading but not wrong. Worth a comment; not worth a rename that costs a rebase.util/chains.tsbuilds the known-chain list fromselectableNetworks, andpartials/MenuSettings.tsxbuilds the prefix dropdown fromsettings.availablePrefixes. Both light up from the single@polkadot/networksentry, so the work here is verification rather than code.What actually needs deciding
settings.prefix === -1falls back to 42 (generic substrate). For this extension the sensible default is 189, so an account shows a Quantus address before any dapp has supplied metadata. Changing a default is a decision, not a fix — record it.@polkadot/react-identiconrenders from the account id, which exists and is 32 bytes, so this works. Confirm it rather than assume: a Quantus identicon and a Substrate identicon for "the same" mnemonic will differ, because the account id is a Poseidon2 hash rather than the public key, and that difference will look like a bug to anyone comparing wallets.frame-metadatais vendored unmodified from upstream, so@polkadot/typesshould decode it as-is — verify against a real runtime and record the metadata version in use.Acceptance
quantus-cliand the mobile wallet showbalances.transfer_keep_alivefrom a dapp renders with the right pallet, call and arguments in the signing popupTwo of three acceptance criteria met, and one of them was a regression I introduced
The recipient renders at prefix 189
This was the interesting one, and it got worse before it got better. Moving call decoding onto
@quantus/codec(#7) left the approval screen printing— a correct description of the value and the one form nobody reads. Upstream got SS58 for free from
toHuman(); the codec deliberately does not, because an SS58 prefix is a property of the chain a caller is talking to rather than of the metadata, and inferring one would put a plausible, wrong address in front of the person being asked to approve a transfer.So
@quantus/codecgainedsetSs58Format, off until set, andmetadataExpandpasses the one the chain's own metadata definition carries. The screen now showsqzkYEQv8tQsmniZYdame3Cku18RL5g9bGK9Pdydq5TMPdpE3y.Account ids are found by their registry path, not by length —
scale_valuecarries each value's type id as its context, so the check is on what the runtime declared. A block hash is 32 bytes too, and rendering one as an address would be a lie a reader cannot catch; there is a test thatSystem::BlockHashstays hex with a prefix set.The SS58 vector is crystal_bob taken from the chain rather than computed, which also pins the two-byte prefix form. 189 needs it, and getting that arithmetic wrong yields an address that looks right and belongs to nobody.
The call renders with the right pallet, call and arguments
decodeMethodmoved out ofExtrinsic.tsxintoutil/with tests, becauseyarn testskips.spec.tsxand as a component method it had no coverage. They pin three things that matter more than the happy path: metadata from a different spec version is refused rather than shown (it decodes a call into something plausible and wrong); a chain with no runtime renders hex; and bytes that are not a call must not throw, since an exception there lands between somebody and their funds.The default prefix is now 189
Recording it as the decision this issue asked for. Upstream falls back to 42, the generic Substrate prefix, because it is a wallet for every Substrate chain and has no reason to prefer one. This one does: every account it can hold is a Quantus account, so 42 would show a correct address in a form no Quantus tool displays — same account id, same funds, unfamiliar string. Somebody comparing the extension against
quantus-clior the mobile wallet would reasonably conclude they had created the wrong account.A chain's own
ss58Formatstill wins where one is known, and the user setting still overrides.DEFAULT_PREFIXinextension-ui/src/util/carries the reasoning.Checklist
quantus-cliand the mobile wallet show — settled by the CLI fixtures in quantus/common#3, and independently by tier 1: the seed0x0000…00resolves toqzk1Nxai…2vSn7, which is the dev-genesis account actually holding funds on Heisenberg, so the chain agrees toobalances.transfer_keep_alivefrom a dapp renders with the right pallet, call and arguments in the signing popupStill open, and honestly
@quantus/codecreads v14 and refuses anything else loudly rather than mis-reading it. The premise in this issue — that@polkadot/typeswould decode it as-is — turned out to be false, and quantus/api#1 has why.Checked against
main. Everything except identicons is met.Met:
quantus-cli: common's CLI vectors, and crystal_alice against the chain.util/decodeMethod.spec.ts).extension-chains/src/bundle.tssets the format, and the spec includes a Bob SS58 vector.util/defaultPrefix.ts.Remaining: nobody has looked at identicons. Check one in the running extension, and note whether it is the polkadot identicon of the 32-byte account id and whether that is acceptable. That is a look-and-decide, not code; close once someone has looked.