Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 4, 2026

Summary

Fixes #25

NEP-245 multi-token IDs like intents.near:nep245:v2_1.omni.hot.tg:43114_111... contain multiple colons, causing AccountId parsing to fail when attempting RPC calls. The old code would strip the prefix and try to parse v2_1.omni.hot.tg:43114_... as an account ID.

Changes

  • Token registry lookup (intents_tokens.rs): Added DEFUSE_TOKENS_MAP_CELL HashMap and find_token_by_defuse_asset_id() for O(1) lookups by defuseAssetId
  • Metadata fetching (counterparty.rs): Modified ensure_ft_metadata() to detect all intents.near:* tokens and use registry instead of RPC calls
  • Tests: Added unit tests for NEP-245/NEP-141 token lookups

Test Plan

cargo test --test nep245_token_registry_test

Example

// Before: AccountId parsing error
ensure_ft_metadata("intents.near:nep245:v2_1.omni.hot.tg:137_...")
  → extract_ft_contract()"v2_1.omni.hot.tg:137_..." (still has colon!)AccountId::from_str()ERROR

// After: Registry lookup
ensure_ft_metadata("intents.near:nep245:v2_1.omni.hot.tg:137_...")
  → starts_with("intents.near:") → true
  → find_token_by_defuse_asset_id("nep245:v2_1.omni.hot.tg:137_..."){symbol: "USDC", decimals: 6, ...}

All intents tokens (NEP-141 and NEP-245) now use the token registry from data/tokens.json. Regular FT tokens continue using RPC queries unchanged.

Co-authored-by: petersalomonsen <9760441+petersalomonsen@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix NEP-245 support for cross-chain tokens Fix NEP-245 multi-token support: use token registry instead of RPC Jan 4, 2026
Copilot AI requested a review from petersalomonsen January 4, 2026 15:31
- nep245 avalanche token is USDC with 6 decimals, not ETH with 18
- nep141:wrap.near symbol is NEAR, not wNEAR
- Apply cargo fmt formatting

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@petersalomonsen petersalomonsen changed the title Fix NEP-245 multi-token support: use token registry instead of RPC fix: NEP-245 multi-token support using token registry instead of RPC Jan 5, 2026
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Collaborator

@petersalomonsen petersalomonsen left a comment

Choose a reason for hiding this comment

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

@race-of-sloths score 3

@petersalomonsen petersalomonsen marked this pull request as ready for review January 5, 2026 05:56
@petersalomonsen
Copy link
Collaborator

@akorchyn I have tested these changes manually, and it seems to work as intended

@race-of-sloths
Copy link

race-of-sloths commented Jan 5, 2026

@Copilot Thank you for your contribution! Your pull request is now a part of the Race of Sloths!
Weekly streak is on the road, smart strategy! Secure your streak with another PR!

Shows inviting banner with latest news.

Shows profile picture for the author of the PR

Current status: executed
Reviewer Score
@petersalomonsen 3

Your contribution is much appreciated with a final score of 3!
You have received 30 Sloth points for this contribution

@petersalomonsen received 25 Sloth Points for reviewing and scoring this pull request.

What is the Race of Sloths

Race of Sloths is a friendly competition where you can participate in challenges and compete with other open-source contributors within your normal workflow

For contributors:

  • Tag @race-of-sloths inside your pull requests
  • Wait for the maintainer to review and score your pull request
  • Check out your position in the Leaderboard
  • Keep weekly and monthly streaks to reach higher positions
  • Boast your contributions with a dynamic picture of your Profile

For maintainers:

  • Score pull requests that participate in the Race of Sloths and receive a reward
  • Engage contributors with fair scoring and fast responses so they keep their streaks
  • Promote the Race to the point where the Race starts promoting you
  • Grow the community of your contributors

Feel free to check our website for additional details!

Bot commands
  • For contributors
    • Include a PR: @race-of-sloths include to enter the Race with your PR
  • For maintainers:
    • Invite contributor @race-of-sloths invite to invite the contributor to participate in a race or include it, if it's already a runner.
    • Assign points: @race-of-sloths score [1/2/3/5/8/13] to award points based on your assessment.
    • Reject this PR: @race-of-sloths exclude to send this PR back to the drawing board.
    • Exclude repo: @race-of-sloths pause to stop bot activity in this repo until @race-of-sloths unpause command is called

@akorchyn akorchyn merged commit 0ffa172 into main Jan 5, 2026
1 check passed
@petersalomonsen petersalomonsen deleted the copilot/fix-nep245-cross-chain-tokens branch January 5, 2026 10:29
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.

Fix NEP-245 Multi-Token Support for Cross-Chain Tokens

4 participants