Skip to content

Add new parseLink and encodePayLink methods#680

Open
swansontec wants to merge 2 commits intomasterfrom
william/parse-link
Open

Add new parseLink and encodePayLink methods#680
swansontec wants to merge 2 commits intomasterfrom
william/parse-link

Conversation

@swansontec
Copy link
Contributor

@swansontec swansontec commented Sep 10, 2025

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Description

none

Note

Medium Risk
Touches core URI/link encoding pathways and plugin interfaces, so compatibility and tokenId/currencyCode mapping regressions are possible despite fallback logic and new tests.

Overview
Adds new plugin-facing link APIs: EdgeCurrencyTools.parseLink / encodePayLink and account-facing wrappers EdgeCurrencyConfig.parseLink / encodePayLink, introducing new types (EdgeParsedLink, EdgePayLink, etc.) for richer link semantics (pay request, payment protocol, private key, custom token, WalletConnect).

Keeps backward compatibility by routing EdgeCurrencyWallet.encodeUri / parseUri through the new tools when available, otherwise falling back to legacy encodeUri / parseUri and converting between formats via new uri-tools helpers (with tokenId/currencyCode bridging). Also tweaks wallet-splitting restoration to always persist unarchive/undelete state updates, and updates/adds tests & fakes accordingly.

Written by Cursor Bugbot for commit 77a0617. This will update automatically on new commits. Configure here.

displayName: currencyName,
networkLocation: {
contractAddress,
type: (token as any).type // Undocumented EVM token type
Copy link
Contributor

Choose a reason for hiding this comment

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

Where did this come from?

@swansontec swansontec force-pushed the william/parse-link branch 2 times, most recently from e4e1c70 to a4c6f67 Compare January 28, 2026 21:55
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

readonly encodePayLink: (
link: EdgePayLink,
opts: { allTokens: EdgeTokenMap }
) => Promise<string>
Copy link

Choose a reason for hiding this comment

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

New EdgeCurrencyTools methods missing optional markers

High Severity

parseLink and encodePayLink on EdgeCurrencyTools are declared as required (non-optional) properties, but the runtime code in plugin-api.ts and currency-wallet-api.ts guards them with != null checks and falls back to the deprecated parseUri/encodeUri. This means the type contract requires all currency plugin implementations to provide these new methods, breaking backward compatibility for plugins that only implement the deprecated methods. Both properties need to be optional (?) to match the intended fallback behavior.

Additional Locations (1)

Fix in Cursor Fix in Web

if (link.token != null) {
out.token = makeMetaToken(link.token)
// @ts-expect-error Undocumented "ERC20" field:
out.token.type = link.token.networkLocation.type
Copy link

Choose a reason for hiding this comment

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

Missing null check on networkLocation causes crash

Medium Severity

In linkToParsedUri, link.token.networkLocation.type is accessed without checking whether networkLocation is defined. EdgeToken.networkLocation is typed as JsonObject | undefined and is documented as being undefined for special built-in tokens like staking balances. If a plugin's parseLink returns an EdgeParsedLink with a token whose networkLocation is undefined, this line throws a TypeError at runtime. This function is called from the wallet's deprecated parseUri backward-compatibility path, so the crash surfaces to callers of an existing API.

Fix in Cursor Fix in Web

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