Skip to content

feat(tokens): add mint, burn, and info tutorials with issuer-managed token#92

Merged
thephez merged 5 commits into
mainfrom
token-tutorials
Jun 10, 2026
Merged

feat(tokens): add mint, burn, and info tutorials with issuer-managed token#92
thephez merged 5 commits into
mainfrom
token-tutorials

Conversation

@thephez

@thephez thephez commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

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

    • Added token tutorial scripts and workflow: register, info, mint, transfer, and burn.
  • Documentation

    • Added TOKEN_CONTRACT_ID to environment examples and updated README with explicit tutorial ordering and token lifecycle setup.
  • Tests

    • Added Phase 4 token integration tests driving the tutorial flow (register → info → mint → transfer → burn).

thephez and others added 3 commits June 10, 2026 10:56
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>
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7851f27f-aa45-451b-9c11-37adb9113fa3

📥 Commits

Reviewing files that changed from the base of the PR and between a9a170b and 3860296.

📒 Files selected for processing (2)
  • 3-Tokens/token-info.mjs
  • test/read-write.test.mjs

📝 Walkthrough

Walkthrough

Adds 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.

Changes

Token Lifecycle Tutorial

Layer / File(s) Summary
SDK token API type extensions
setupDashClient-core.d.mts
The ConnectedDashClientLike.tokens interface gains statuses(tokenIds), contractInfo(contractId), mint(...), and burn(...) method signatures.
Token registration script and configuration
3-Tokens/token-register.mjs
Adds token-register.mjs that builds a tutorial TokenConfiguration, constructs/publishes a DataContract with the token at a fixed position, and logs the published contract ID and token ID.
Token query and lifecycle operation scripts
3-Tokens/token-info.mjs, 3-Tokens/token-mint.mjs, 3-Tokens/token-transfer.mjs, 3-Tokens/token-burn.mjs
Adds four operation scripts: token-info queries contract info/status/supply and balances; token-mint mints a fixed amount and logs balance/supply; token-transfer transfers tokens with pre/post balance checks; token-burn burns tokens and logs remaining balance and total supply. All validate TOKEN_CONTRACT_ID and use try/catch error handling.
Environment configuration, integration tests, and documentation
.env.example, test/read-write.test.mjs, README.md, CLAUDE.md
.env.example adds TOKEN_CONTRACT_ID; test/read-write.test.mjs adds Phase 4 token tests that register a token, extract/store its contract ID for dependent tests (info/mint/transfer/burn) and include stdout assertions; README.md and CLAUDE.md document the token tutorial ordering and setup.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

"🐰 I hopped through code to register a token bright,
Minted a few, then sent one in flight.
Queried the ledger, burned one away,
Logs tell the tale of the tutorial day.
Hooray for tokens — hop, hop, hooray!"

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(tokens): add mint, burn, and info tutorials with issuer-managed token' directly and accurately describes the main changes: adding three new tutorial scripts (mint, burn, info) and implementing issuer-managed token functionality. The title is concise, specific, and reflects the primary objectives of the PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch token-tutorials

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
3-Tokens/token-info.mjs (1)

25-28: ⚡ Quick win

Unnecessary network call to fetch identity.

The script fetches the identity from the network just to obtain identity.id for the balance query. Since keyManager.identityId is 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

📥 Commits

Reviewing files that changed from the base of the PR and between 98c7e65 and a9a170b.

📒 Files selected for processing (10)
  • .env.example
  • 3-Tokens/token-burn.mjs
  • 3-Tokens/token-info.mjs
  • 3-Tokens/token-mint.mjs
  • 3-Tokens/token-register.mjs
  • 3-Tokens/token-transfer.mjs
  • CLAUDE.md
  • README.md
  • setupDashClient-core.d.mts
  • test/read-write.test.mjs

thephez and others added 2 commits June 10, 2026 13:50
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>
@thephez thephez merged commit 484d2f2 into main Jun 10, 2026
2 of 3 checks passed
@thephez thephez deleted the token-tutorials branch June 10, 2026 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant