Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token refactor follow-up: config updates #3200

Open
wants to merge 6 commits into
base: development
Choose a base branch
from

Conversation

artursapek
Copy link
Collaborator

@artursapek artursapek commented Jan 16, 2025

This makes some breaking changes to the config, so that it works with the new arbitrary tokens system.

Breaking changes

Token whitelist

The token whitelist used to reference tokens by their "keys" like this:

{
  tokens: ["USDCeth", "USDCsol"]
}

Since tokens no longer have these custom keys, we now support two other means of whitelisting tokens:

  1. Integrators can easily whitelist a single token across all chains by providing its symbol
  2. Integrators can also be more granular by providing token tuples ([chain, address]).
{
  tokens: ["USDC", ["Solana", "2qEHjDLDLbuBgRYvsxhc5D6uDWAivNFZGan56P1tpump"]]
}

This config whitelists USDC coin on all chains, and Pnut the Squirrel on Solana. There is some nuance to how this works because of wrapped tokens, which is explained here.

image

Default tokens

The DefaultInputs config now has to be either the symbol or the address for the token.

{
  ui: {
    defaultInputs: {
      fromChain: 'Solana',
      fromToken: '2qEHjDLDLbuBgRYvsxhc5D6uDWAivNFZGan56P1tpump',
      toChain: 'Ethereum',
      toToken: 'USDC',
    }
  }
}

New properties

This also adds a new config option which disables the ability to paste in token addresses:

{
  ui: {
    disableArbitraryTokens: true
  }
}

This is set to true by default if an integrator provides the tokens whitelist.

@artursapek artursapek requested a review from emreboga January 16, 2025 17:59
Copy link

netlify bot commented Jan 16, 2025

Deploy Preview for wormhole-connect ready!

Name Link
🔨 Latest commit 62b973c
🔍 Latest deploy log https://app.netlify.com/sites/wormhole-connect/deploys/6793c3d53d0a8e00087f75e2
😎 Deploy Preview https://deploy-preview-3200--wormhole-connect.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 16, 2025

Deploy Preview for wormhole-connect-mainnet ready!

Name Link
🔨 Latest commit 62b973c
🔍 Latest deploy log https://app.netlify.com/sites/wormhole-connect-mainnet/deploys/6793c3d5166d570007696d7c
😎 Deploy Preview https://deploy-preview-3200--wormhole-connect-mainnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@artursapek artursapek marked this pull request as draft January 16, 2025 17:59
@artursapek artursapek changed the title Allow integrators to disable token pasting Token refactor follow-up: config updates Jan 17, 2025
@artursapek artursapek marked this pull request as ready for review January 17, 2025 16:29
if (customConfig.tokens) {
// If the integrator has provided a whitelist of tokens, we can reasonably assume they also don't want
// users pasting in arbitrary token addresses.
ui.disableArbitraryTokens = true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the integrator explicitly specifies disableArbitraryTokens = false while having whitelist tokens in the config, should that still enable arbitrary tokens?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good question... I can add support for that

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

}
}

for (const symbol of desiredSymbols) {
Copy link
Collaborator

@emreboga emreboga Jan 24, 2025

Choose a reason for hiding this comment

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

Above it says "If there is a single native token with that symbol, we simply use that", bu I can't find where that's implemented in this loop.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the foundNative flag is how that's implemented. although you're right the comment is slightly inaccurate: we don't check that there's only one native (not wrapped) token with the symbol; we simply take the first one we find. if there were two native tokens with the same symbol, it would choose one of them arbitrarily. this isn't likely to happen, but it's possible.

I suppose I could remove the break on line 223 to include all native tokens with a matching symbol?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I think that'll work.

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