Skip to content

Add custom NEP-17 token by contract hash#64

Open
Jim8y wants to merge 2 commits into
neoorder:masterfrom
Jim8y:codex/custom-token-by-hash
Open

Add custom NEP-17 token by contract hash#64
Jim8y wants to merge 2 commits into
neoorder:masterfrom
Jim8y:codex/custom-token-by-hash

Conversation

@Jim8y

@Jim8y Jim8y commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

What

The token universe was a static embedded tokens.json — a NEP-17 not in that file was invisible and unaddable. This adds an Add token action (a new toolbar button on WalletPage) that opens a popup where the user pastes a contract hash; it resolves the token via the existing RpcClient.GetTokenInfo (validating it's a real NEP-17) and persists it. TokenManager.LoadTokensAsync now merges user-added tokens with the embedded list.

Notes

  • Conflict-checked: touches TokenManager.cs, WalletPage.xaml(.cs), and a new AddTokenPopupnone of these are touched by any open PR. Uses a popup (not a routed page) specifically to avoid touching AppShell.xaml.cs/MauiProgram.cs (which several PRs edit).
  • Builds clean for net10.0-android (0 errors).

Tokens were a static embedded list, so any NEP-17 not in tokens.json was invisible
and unaddable. Add an Add-token popup (wallet toolbar) that resolves a pasted
contract hash via the existing GetTokenInfo and persists it; TokenManager merges
user tokens with the embedded list. Builds for net10.0-android (0 errors).
Copilot AI review requested due to automatic review settings June 21, 2026 12:34

Copilot AI 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.

Pull request overview

Adds a user-facing “Add token” flow so wallets can track NEP-17 tokens not present in the embedded tokens.json, by resolving token metadata from chain via RpcClient.GetTokenInfo and persisting the contract hash in settings.

Changes:

  • Merge persisted user-added token hashes into the embedded token list during token loading.
  • Add an “Add token” toolbar action on WalletPage that opens a new AddTokenPopup.
  • Add new localized strings for the popup UI (EN + zh-Hans/zh-Hant) and update the generated designer.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
OneGateApp/Services/TokenManager.cs Loads and persists custom token hashes; merges custom tokens into the embedded token list.
OneGateApp/Pages/WalletPage.xaml.cs Adds popup invocation plumbing for the new toolbar action.
OneGateApp/Pages/WalletPage.xaml Adds a new toolbar button to trigger “Add token”.
OneGateApp/Controls/Popups/AddTokenPopup.xaml.cs Implements contract-hash parsing, token resolution, persistence, and error display.
OneGateApp/Controls/Popups/AddTokenPopup.xaml New popup UI for entering a contract hash and submitting/canceling.
OneGateApp/Properties/Strings.resx Adds EN strings for the new popup and action.
OneGateApp/Properties/Strings.zh-Hans.resx Adds Simplified Chinese strings for the new popup and action.
OneGateApp/Properties/Strings.zh-Hant.resx Adds Traditional Chinese strings for the new popup and action.
OneGateApp/Properties/Strings.Designer.cs Regenerates strongly-typed accessors for newly added strings.
Files not reviewed (1)
  • OneGateApp/Properties/Strings.Designer.cs: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread OneGateApp/Services/TokenManager.cs
Comment thread OneGateApp/Controls/Popups/AddTokenPopup.xaml.cs
@Jim8y

Jim8y commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

Latest review follow-up: addressed both Copilot comments in 85af6c2.

Changes:

  • LoadTokensAsync now skips a custom token only for RpcException, so transient network/JSON/storage failures are no longer silently swallowed as “token no longer resolvable”.
  • AddTokenPopup maps RpcException to TokenNotFound and maps unexpected failures to UnknownError, so transient failures are no longer shown as Token Not Found.
  • Cleaned up the nullable UInt160.TryParse warning in the same popup.

Validation:

  • git diff --check passed.
  • Conflict-marker scan passed.
  • iOS simulator build/install/Wallet → Add Token invalid-hash validation verified.
  • Android emulator build/install/Wallet → Add Token invalid-hash validation verified with empty crash log.

Screenshots:

Screenshots are GitHub release assets only and are not committed to the repository. Ready for re-review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants