Skip to content

KRON (KCC-20) Stage 0 — token display - #357

Open
leobragaz wants to merge 2 commits into
mainfrom
feat/kcc20-stage0-display
Open

leobragaz wants to merge 2 commits into
mainfrom
feat/kcc20-stage0-display

Conversation

@leobragaz

Copy link
Copy Markdown
Contributor

Scope

KRON (KCC-20) Stage 0 — read-only DISPLAY (no transfers/mint/swap). Adds @kronsdk/kron-sdk@0.18.2 and a lib/kcc20/ module that fetches KRON covenant UTXOs, decodes the 112-byte KCC20State, matches ownership (isOwnedBy), and renders KRON in the dashboard token list.

  • Amount kept bigint end-to-end; only converted by formatUnits for display.
  • Balance is node-confirmed (indexer supplies only redeem scripts; each outpoint counts only when the node returns it under the covenant's P2SH address).
  • Verified-only: metadata used only when verifyTokenListEntry resolves against the genesis tx via Kastle's own REST API; fallback renders truncated covenant_id + raw base units.
  • Hook gates to mainnet only.

Gate

compile 0, build 0, e2e 176 passed (added tests/kcc20-unit.spec.ts).

Review

VERDICT: PASS — minor non-blocking nits (two unused exported URL constants; one rows as {...}[] cast; a fetch error silently hides the KCC-20 section).

Caveat (documented in code)

KRON's name/symbol/decimals are NOT on-chain — they come from KRON's registry, gated by verifyTokenListEntry. A wrong registry could mislabel a real token; balances are unaffected (read from the node). Pinning KRON's published signing key is the future hardening.

Scope class: in-scope (display only). Left open for Leo — new covenant-token surface.

Copilot AI lite review requested due to automatic review settings September 27, 2026 00:05
@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: forbole/kastle/.coderabbit.yml

Review profile: CHILL

Plan: Advanced

Run ID: fd907da4-3835-49a8-a871-b1ba78512864

📥 Commits

Reviewing files that changed from the base of the PR and between 66755cc and f669357.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (6)
  • components/dashboard/Assets.tsx
  • components/dashboard/TokenListItem.tsx
  • lib/kcc20/index.ts
  • lib/kcc20/useKcc20Tokens.ts
  • package.json
  • tests/kcc20-unit.spec.ts

Note

.coderabbit.yml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized keys: "labels", "include_paths", "exclude_paths", "filters", "review", "pull_request", "limits", "commands", "messages"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Moderate issues remain around error handling and preventing fetches with a stale network client.

Review effort: Lite
Findings: 2 Medium severity

Open (2)
What changed in this PR

Adds read-only KRON KCC-20 balance discovery and verified token display for mainnet dashboard assets.

Changes:

  • Adds the KRON SDK dependency.
  • Implements KCC-20 decoding, ownership checks, balance aggregation, and metadata verification.
  • Adds mainnet-gated fetching, dashboard integration, and unit coverage.
File Description
tests/​kcc20-unit.spec.ts Tests ownership behavior.
package.json Adds the KRON SDK dependency.
package-lock.json Locks the KRON SDK version.
lib/​kcc20/​useKcc20Tokens.ts Provides the mainnet-only token-fetching hook.
lib/​kcc20/​index.ts Handles KCC-20 discovery, validation, aggregation, and metadata.
components/​dashboard/​TokenListItem.tsx Renders KCC-20 balances.
components/​dashboard/​Assets.tsx Integrates KCC-20 rows into the dashboard.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/kcc20/index.ts
Comment on lines +117 to +123
const { ok } = await verify.verifyTokenListEntry(
entry,
verify.kaspaRestFetchTx(restApi),
);
if (!ok) return undefined;
const { symbol, name, decimals, logoURI } = entry;
return { symbol, name, decimals, logoURI };
Comment thread lib/kcc20/useKcc20Tokens.ts Outdated
Comment on lines +15 to +18
const { data } = useSWR(
enabled ? ["kcc20Tokens", address] : null,
() => fetchKcc20Tokens(address!, rpcClient!, restApis[NetworkType.Mainnet]),
{ refreshInterval: 30_000 },
leobragaz added a commit that referenced this pull request Sep 28, 2026
…ng (#357)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
leobragaz and others added 2 commits September 28, 2026 20:18
…play only)

Mainnet only. The indexer's figures are never trusted: a balance counts
only if the node holds that outpoint at P2SH(redeem) under the token's
covenant id and the decoded state is spendable by this wallet.
Name/symbol/decimals/logo come from the KRON registry entry, used only
when kron-sdk's verifyTokenListEntry finds that covenant id on the
entry's genesis tx. Otherwise the row shows the truncated covenant id
and raw base units. Amounts stay bigint until formatUnits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ng (#357)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leobragaz
leobragaz force-pushed the feat/kcc20-stage0-display branch from f9fd462 to f669357 Compare September 28, 2026 18:18

This branch has not been deployed

No deployments
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.

2 participants