feat(tokens): add mint, burn, and info tutorials with issuer-managed token#92
Conversation
Add contract-register-token.mjs (fixed-supply token contract) and identity-transfer-tokens.mjs, with TOKEN_CONTRACT_ID env var, README guidance, and read-write test coverage. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Relocate token-register.mjs and token-transfer.mjs into a dedicated 3-Tokens directory, update doc URLs and the .env.example reference, and group the tests under a Phase 4: Tokens block. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…d token Rework token-register from a fixed-supply token into an issuer-managed one with manual minting and burning enabled and a separate base/max supply, so the new mint, burn, and info tutorials can demonstrate the normal token lifecycle. Add token type declarations to setupDashClient-core.d.mts, read-write tests covering info/mint/burn, and update the README and CLAUDE.md to document the token tutorials and TOKEN_CONTRACT_ID. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds a token tutorial suite: SDK typing extensions, token registration script, info/mint/transfer/burn scripts, environment example, integration tests running tutorials in sequence, and documentation updates describing tutorial ordering and setup. ChangesToken Lifecycle Tutorial
Sequence Diagram(s)sequenceDiagram
participant User
participant Register as token-register.mjs
participant Info as token-info.mjs
participant Mint as token-mint.mjs
participant Transfer as token-transfer.mjs
participant Burn as token-burn.mjs
participant SDK as Dash SDK
User->>Register: run registration
Register->>SDK: publish DataContract (token config)
SDK-->>Register: contractId / tokenId
User->>Info: query with tokenContractId
Info->>SDK: contractInfo, statuses, totalSupply, balances
SDK-->>Info: token data
User->>Mint: run mint
Mint->>SDK: tokens.mint(...)
SDK-->>Mint: updated balance, totalSupply
User->>Transfer: run transfer
Transfer->>SDK: tokens.transfer(...)
SDK-->>Transfer: updated recipient balance
User->>Burn: run burn
Burn->>SDK: tokens.burn(...)
SDK-->>Burn: updated balance, totalSupply
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
3-Tokens/token-info.mjs (1)
25-28: ⚡ Quick winUnnecessary network call to fetch identity.
The script fetches the identity from the network just to obtain
identity.idfor the balance query. SincekeyManager.identityIdis already available, you can use it directly without the extra round-trip.⚡ Proposed fix to eliminate the network fetch
- const identity = await sdk.identities.fetch(keyManager.identityId); - const identityBalances = await sdk.tokens.identityBalances(identity.id, [ - tokenId, - ]); + const identityBalances = await sdk.tokens.identityBalances( + keyManager.identityId, + [tokenId], + );🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@3-Tokens/token-info.mjs` around lines 25 - 28, The code makes an unnecessary network call via sdk.identities.fetch to obtain identity.id only to pass into sdk.tokens.identityBalances; replace that by using keyManager.identityId directly when calling sdk.tokens.identityBalances (keep tokenId as before) and remove the sdk.identities.fetch(...) call and any unused variable (identity) so the balance query uses keyManager.identityId instead.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@3-Tokens/token-info.mjs`:
- Around line 25-28: The code makes an unnecessary network call via
sdk.identities.fetch to obtain identity.id only to pass into
sdk.tokens.identityBalances; replace that by using keyManager.identityId
directly when calling sdk.tokens.identityBalances (keep tokenId as before) and
remove the sdk.identities.fetch(...) call and any unused variable (identity) so
the balance query uses keyManager.identityId instead.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 437cae30-7ec6-40c9-aeca-202df30fdd39
📒 Files selected for processing (10)
.env.example3-Tokens/token-burn.mjs3-Tokens/token-info.mjs3-Tokens/token-mint.mjs3-Tokens/token-register.mjs3-Tokens/token-transfer.mjsCLAUDE.mdREADME.mdsetupDashClient-core.d.mtstest/read-write.test.mjs
Use keyManager.identityId directly for the balance query instead of fetching the identity from the network just to read identity.id, removing an unnecessary round-trip. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Prefer extractId, then fall back to a base58-only regex so the token contract ID is never captured as the brace opening the toJSON dump. Also assert token-transfer prints its confirmation line. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Rework token-register from a fixed-supply token into an issuer-managed one with manual minting and burning enabled and a separate base/max supply, so the new mint, burn, and info tutorials can demonstrate the normal token lifecycle.
Add token type declarations to setupDashClient-core.d.mts, read-write tests covering info/mint/burn, and update the README and CLAUDE.md to document the token tutorials and TOKEN_CONTRACT_ID.
Summary by CodeRabbit
New Features
Documentation
Tests