Repository navigation
fix(cli): derive the storage-deposit floor and token symbol from the chain - #319
Conversation
CI Summary
Release - PassedTest this PR Download artifact (GitHub CLI required): gh run download 36156873432 -n cli-release-0.0.0-pr.319 -R paritytech/dotns-sdkInstall globally: npm install -g ./parity-dotns-cli-0.0.0-pr.319.tgzVerify: dotns --helpDeploy UI — Passed
Deploy Example — Passed
Benchmark UI - Failed (0s)
Labelspkg: cli, type: docs, type: test, pkg: ui Test - Passed367 passed, 0 failed across 367 tests. |
|
For the breaking change on
Extra NIT: might be good to move |
GHkrishna
left a comment
There was a problem hiding this comment.
Apart from the nit comment below, I feel in the cli readme we are still using:
const client = createClient(getWsProvider("wss://paseo-asset-hub-next-rpc.polkadot.io"));
const ctx = createDotnsContext({
clientWrapper: new ReviveClientWrapper(client.getTypedApi(paseo)),
origin, // your SS58 address
signer, // your PolkadotSigner
environment: "paseo-v2",
});
should we be updating it to the await getChainTokenInfo(rawClient) param too??
Done in 8cec89a . |
Yes, updated in 8cec89a |
Description
The storage deposit floor on every write was a hardcoded
2_000_000_000_000nplanck: 200 tokens at 10 decimals, 100× its documented "2 PAS". It won on essentially every call, so the limit never came from the dry run. The floor is now two whole tokens of the connected chain, and the CLI reads the chain's decimals and symbol for every amount it caps or displays.computeStorageDepositLimitkeeps the rule (dry run + 20%, floored at two tokens) with the floor at2 × 10^decimalsof the connected chain.ReviveClientWrapperholdsnativeTokenDecimalsandnativeTokenSymbol;createDotnsContextreads both from it. EveryRevive.callpath passes chain metadata, including bulletin--cache, which reads it from Asset Hub.PASliteral remains inpackages/cli/src.getChainTokenInforejects unusabletokenDecimals("",nullandtrueused to become 0 or 1 decimals, a 2 or 20 planck floor) and warns when it falls back to the defaults.Why DOT / 10 as defaults: Polkadot mainnet is the production target, so the fallbacks are the Polkadot Asset Hub values. They only apply when a chain reports no token properties; Polkadot AH (DOT/10), Paseo AH and previewnet AH (PAS/10) all report their own. CLI output on testnets still shows PAS. Only SDK callers who build
new ReviveClientWrapper(client)without token info now see DOT labels; the deposit floor is unchanged.Type
Package
@parity/dotns-cliRelated Issues
paritytech/dotns#226
Fixes
Closes paritytech/dotns#226
Checklist
Code
bun run lintpassesbun run formatpassesbun run typecheckpassesDocumentation
Breaking Changes
Breaking changes:
CreateDotnsContextOptions.nativeTokenDecimalsis removed, since a second copy on the context could disagree with the wrapper. Pass token info to the wrapper instead:new ReviveClientWrapper(client, await getChainTokenInfo(rawClient)).Testing
How to test:
cd packages/cli && bun run test:unit: 367 tests pass, including the newtests/unit/client/storageDepositLimit.test.tsandtests/unit/client/chainTokenInfo.test.ts.dotns register domain ...): the configuration block showsToken: PAS (10 decimals), amounts are labelled PAS, and the call'sstorage_deposit_limitis at least 20_000_000_000 planck (two PAS).Notes
account mapbuilds its wrapper without token info. That is safe:map_accountsets no storage deposit limit.PASliterals are left for a separate change.