diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b3d608162..5d1fe43c1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,48 +1,33 @@ ## Contributing -Contributions are welcome! To work on wormhole-connect locally you'll want to use `npm link` to make the changes to the SDK immediately available. +Bug fixes and enhancements are welcome! + +*Please don't open pull requests to add tokens to Connect.* Instead, use the `tokensConfig` parameter in `config` to add tokens into your deployment of Connect. ### Setup 1) Install -Run `npm i` at the root of the repo - -2) Build - -Run `npm run build` at the root fo the repo - -3) Start -Start wormhole-connect UI: -```bash -# in /wormhole-connect -npm run start # testnet ``` - -Start builder UI: -```bash -# in /builder -npm run start +npm i ``` -## Add a token - -### Fill out token config +2) Build SDK -1. Create an entry for the token in `wormhole-connect/config/.ts`. -2. Ensure the `key` value is equal to the object key for easy lookup. -3. Add decimal values for default, Ethereum, Solana and Sui if applicable (i.e. if they vary from the default value) -4. If it's a native gas token, ensure that the wrapped version is also present and linked under `wrappedAsset` +``` +cd sdk +npm run build +``` -### Add a token icon +3) Start demo app with Vite -1. Create a file under `icons/Tokens` labeled `.tsx`. -2. Create a React component and paste the svg in the return. -3. Modify the svg to comply with react (mostly this is renaming attribute names with hyphens e.g. `view-box` to `viewBox`) -4. Ensure the width and height attributes are present on the root `` element and max height and width are set (`style={{ maxHeight: '100%', maxWidth: '100%' }}`) +``` +cd ../wormhole-connect +npm run start +``` -## Setup +This should start a local server at localhost:5173. ### Pre-commit hooks diff --git a/README.md b/README.md index d8184cfa7..0dc426569 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # Wormhole Connect - -[![npm version](https://img.shields.io/npm/v/@wormhole-foundation/wormhole-connect.svg)](https://www.npmjs.com/package/@wormhole-foundation/wormhole-connect) ![CI build](https://github.com/wormhole-foundation/wormhole-connect/actions/workflows/build.yml/badge.svg) +[![Documentation](https://img.shields.io/badge/Documentation-2a67c9)](https://docs.wormhole.com/wormhole/wormhole-connect/overview) [![npm version](https://img.shields.io/npm/v/@wormhole-foundation/wormhole-connect.svg)](https://www.npmjs.com/package/@wormhole-foundation/wormhole-connect) ![CI build](https://github.com/wormhole-foundation/wormhole-connect/actions/workflows/build.yml/badge.svg) Wormhole Connect is a customizable React widget that can perform cross-chain bridging with Wormhole. @@ -15,18 +14,20 @@ Wormhole Connect is deployed live in several production apps. Here are a few: - [Pancake Swap](https://bridge.pancakeswap.finance/wormhole) -## Integration - -You can customize and integrate via our no-code solution: https://connect-in-style.wormhole.com/ +## Getting Started -### Via NPM (for React apps) +### Via NPM for React apps (Recommended) If you're using React, you can import the `` component directly into your JSX: +#### Installation + ```bash npm i @wormhole-foundation/wormhole-connect ``` +#### Using the component + ```javascript import WormholeConnect from '@wormhole-foundation/wormhole-connect'; @@ -39,369 +40,167 @@ function App() { ### Alternative: hosted version via CDN (for any website) -If you're not using React, you can still embed Connect on your website by using the hosted version. Simply copy and paste the following code into your HTML: +If you're not using React, you can still embed Connect on your website by using the hosted version. Simply copy and paste the following code into your HTML body: ```html - - - -
-``` - -Note that the `wormhole-connect` div with your config has to be present _before_ the scripts are loaded. - -## Configuration -Wormhole Connect is highly customizable via a simple `config` object passed in as a React prop: - -```jsx - + + + ``` -See `WormholeConnectConfig` in [src/config/index.ts](../wormhole-connect/src/config/index.ts) -for a full view of the supported config parameters. - -See [src/config/examples.md](../wormhole-connect/src/config/examples.md) -for working examples of different config values. +Note that the `#wormhole-connect` element has to be present _before_ the scripts are loaded. -### Environment (`env`): -| Mainnet | Testnet | -| ---------- | --------- | -| mainnet | testnet | +You can customize and integrate Connect via our no-code solution: https://connect-in-style.wormhole.com/ -
+## Configuration -### Networks (`networks`): -| Mainnet | Testnet | -| ---------- | ------------- | -| ethereum | goerli, sepolia | -| polygon | mumbai | -| bsc | bsc | -| avalanche | fuji | -| celo | avalanche | -| moonbeam | moonbasealpha | -| solana | solana | -| sui | sui | -| aptos | aptos | -| base | basegoerli, base_sepolia | -| osmosis | osmosis | -| evmos | evmos | -| kujira | kujira | -| injective | injective | -| klaytn | klaytn | -| arbitrum | arbitrumgoerli, arbitrum_sepolia | -| optimism | optimismgoerli, optimism_sepolia | +Wormhole Connect is highly customizable via two props: `config` and `theme`. Here is an example which +limits it to two chains and customizes the background color: -> Osmosis support is in beta, reach out to a Wormhole contributor for early access. +```tsx +import WormholeConnect, { + WormholeConnectConfig, WormholeConnectPartialTheme +} from '@wormhole-foundation/wormhole-connect'; -
- -### RPCs (`rpcs`): - -We recommend that you configure your own custom RPC endpoints for each used network for the best performance. The default public RPCs may be throttled or rate limited. -See [src/config/examples.md](../wormhole-connect/src/config/examples.md). - -
- -### Tokens (`tokens`): -| Mainnet | Testnet | -| ----------- | -------- | -| ETH | ETH, ETHsepolia | -| WETH | WETH, WETHsepolia | -| USDCeth | USDCeth | -| WBTC | | -| USDT | | -| DAI | | -| BUSD | | -| MATIC | MATIC | -| WMATIC | WMATIC | -| USDCpolygon | | -| BNB | BNB | -| WBNB | WBNB | -| USDCbnb | | -| AVAX | AVAX | -| WAVAX | WAVAX | -| USDCavax | USDCavax | -| FTM | FTM | -| WFTM | WFTM | -| CELO | CELO | -| GLMR | GLMR | -| WGLMR | WGLMR | -| SOL | WSOL | -| PYTH | | -| SUI | SUI | -| USDCsol | | -| APT | APT | -| ETHarbitrum | ETHarbitrum, ETHarbitrum_sepolia | -| WETHarbitrum | WETHarbitrum, WETHarbitrum_sepolia | -| USDCarbitrum | USDCarbitrum| -| ETHoptimism | ETHoptimism, ETHoptimism_sepolia | -| WETHoptimism | WETHoptimism, WETHoptimism_sepolia | -| USDCoptimism | USDCoptimism| -| ETHbase | ETHbase, ETHbase_sepolia | -| WETHbase | WETHbase, WETHbase_sepolia | -| tBTC | tBTC | -| tBTCpolygon | tBTCpolygon | -| tBTCoptimism | tBTCoptimism | -| tBTCarbitrum | tBTCarbitrum | -| tBTCbase | tBTCbase | -| tBTCsol | tBTCsol | -| WETHpolygon | | -| WETHbsc | | -| wstETH | wstETH | -| wstETHarbitrum | | -| wstETHoptimism | | -| wstETHpolygon | | -| wstETHbase | | - -
- -### Adding Tokens (`tokensConfig`) +const config: WormholeConnectConfig = { + networks: ['ethereum', 'solana'] +}; -You can add arbitrary tokens to the Connect tokens menu by providing a `tokensConfig` key. -See the "Arbitrary Token" example in [src/config/examples.md](../wormhole-connect/src/config/examples.md). +const theme: WormholeConnectPartialTheme = { + background: { + default: '#212b4a' + } +}; +function App() { + return ( + + ) +} +``` -
+If using the hosted version, provide `config` and `theme` as JSON-serialized strings on the mount point: -### Routes (`routes`) -| Mainnet | Testnet | -| -------- | ---------| -| bridge | bridge | -| relay | relay | -| cctpManual | cctpManual | -| cctpRelay | cctpRelay | -| cosmosGateway | cosmosGateway | -| tbtc | tbtc | -| ethBridge | | -| wstETHBridge | | +```html +
+``` -
+Below are some of the more commonly used config options. See +[the full Connect docs](https://docs.wormhole.com/wormhole/wormhole-connect/overview) for more complete +documentation and examples of the different config options. -### Theme (`customTheme`) +### Environment (`env`): -See [theme.ts](../wormhole-connect/src/theme.ts) for examples +Connect renders in mainnet mode by default, but you can switch it to testnet by setting `env` to `testnet`. +```ts +const config: WormholeConnectConfig = { + env: 'testnet' +} +``` -### Examples +### RPC Endpoints (`rpcs`): -(Optional) Specify supported networks/tokens and custom RPC endpoints. Your users may encounter rate limits using public RPC endpoints if you do not provide your own +We strongly recommend that you configure your own custom RPC endpoints for each network your application needs. The default public RPCs may be throttled or rate limited. -```jsx -import WormholeBridge, { - WormholeConnectConfig, -} from "@wormhole-foundation/wormhole-connect"; +```ts const config: WormholeConnectConfig = { - env: "mainnet", - networks: ["ethereum", "polygon", "solana"], - tokens: ["ETH", "WETH", "MATIC", "WMATIC"], rpcs: { - ethereum: "https://rpc.ankr.com/eth", - solana: "https://rpc.ankr.com/solana", - }, -}; - -function App() { - return ; + solana: 'https://mainnet.helius-rpc.com/?api-key=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', + ethereum: 'https://rpc.ankr.com/eth/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' + } } ``` -(Optional) Customize theme - -```jsx -import WormholeBridge, { - light, - Theme, - WormholeConnectConfig, -} from "@wormhole-foundation/wormhole-connect"; -import lightblue from "@mui/material/colors/lightBlue"; +### Custom Tokens (`tokensConfig`) -// alters the `light` theme -const customized: Theme = light; -customized.success = lightblue; -customized.background.default = "transparent"; -customized.button.action = "#81c784"; -customized.button.actionText = "#000000"; +You can add arbitrary tokens to the Connect tokens menu by providing a `tokensConfig` key. +```ts const config: WormholeConnectConfig = { - mode: "light", - customTheme: customized, -}; - -function App() { - return ; + tokensConfig: { + ... + } } ``` -(Optional) Create fully customized theme +See the "Arbitrary Token" example in [the config docs](https://github.com/wormhole-foundation/wormhole-connect/blob/development/wormhole-connect/src/config/examples.md). -```jsx -import WormholeBridge, { - Theme, - OPACITY, - WormholeConnectConfig, -} from "@wormhole-foundation/wormhole-connect"; -import lightblue from "@mui/material/colors/lightBlue"; -import grey from "@mui/material/colors/grey"; -import green from "@mui/material/colors/green"; -import orange from "@mui/material/colors/orange"; - -const customized: Theme = { - primary: grey, - secondary: grey, - divider: "#ffffff" + OPACITY[20], - background: { - default: "#232323", - }, - text: { - primary: "#ffffff", - secondary: grey[500], - }, - error: red, - info: lightblue, - success: green, - warning: orange, - button: { - primary: "#ffffff" + OPACITY[20], - primaryText: "#ffffff", - disabled: "#ffffff" + OPACITY[10], - disabledText: "#ffffff" + OPACITY[40], - action: orange[300], - actionText: "#000000", - hover: "#ffffff" + OPACITY[7], - }, - options: { - hover: "#474747", - select: "#5b5b5b", - }, - card: { - background: "#333333", - secondary: "#474747", - elevation: "none", - }, - popover: { - background: "#1b2033", - secondary: "#ffffff" + OPACITY[5], - elevation: "none", - }, - modal: { - background: "#474747", - }, -}; -const config: WormholeConnectConfig = { - mode: "dark", - customTheme: customized, -}; +Please note you have to [register a token](https://portalbridge.com/advanced-tools/#/register) with the token bridge before you can use it in Connect. -function App() { - return ; -} -``` +### Custom Theme -## Configuration Options +You can also customize Connect's color scheme by providing a `WormholeConnectTheme` as the `theme` prop. +By default, Connect renders using the `dark` theme. -### Wallet Connect Project ID - -Required in order to display Wallet Connect as a wallet option. You can get a project ID on https://cloud.walletconnect.com/. Refer to the wallet connect [documentation](https://docs.walletconnect.com/advanced/migration-from-v1.x/overview) for more information on v2. +```jsx +import WormholeConnect, { + dark, + WormholeConnectTheme, +} from "@wormhole-foundation/wormhole-connect"; -### Toggle Hamburguer Menu +// alters the `dark` theme +const customized: WormholeConnectTheme = dark; +customized.success = '#212b4a'; +customized.background.default = "navy"; +customized.button.action = "#81c784"; +customized.button.actionText = "#000000"; -By setting the `showHamburgerMenu` option to **false**, you can deactivate the hamburger menu, causing the links to be positioned at the bottom. +export default function App() { + return ; +} +``` -#### Add extra menu entry +You can change the `theme` prop to dynamically change Connect's colors, for example when your application +switches from light to dark mode. -By setting the `showHamburgerMenu` option to **false**, you can use the `menu` array to add extra links. +See the definitions of `WormholeConnectTheme` and `dark` in [theme.ts](https://github.com/wormhole-foundation/wormhole-connect/blob/development/wormhole-connect/src/theme.ts) for type definitions. -|property|description| -|--|--| -|`menu[].label`|link name to show up| -|`menu[].href`|target url or urn| -|`menu[].target`|anchor standard target, by default `_blank`| -|`menu[].order`|order where the new item should be injected| +### Choosing Networks (`networks`): -#### Sample configuration +You can provide a whitelist of networks to limit which ones Connect offers. -```json -{ - "showHamburgerMenu": false, - "menu": [ - { - "label": "Advance Tools", - "href": "https://portalbridge.com", - "target": "_self", - "order": 1 - } - ] -} -``` -### CoinGecko API Key - -If you have a CoinGecko API Plan, you can include the API key in the configuration. In case you do not have the API key, [follow this steps](https://apiguide.coingecko.com/getting-started/getting-started). - -### More Networks - -Specify a set of extra networks to be displayed on the network selection modal, each of them linking to a different page/dApp/mobile app the user will be redirected to. - -|Property|description|| -|:--|:--|:--:| -|`moreNetworks.href`| Default value for missing network hrefs | mandatory| -|`moreNetworks.target`| Default value for missing network link targets | optional, defaults to `_self` -|`moreNetworks.description` | Brief description that should be displayed as tooltip when the user hover an more network icon. Used as default for missing network descriptions | optional | -|`moreNetworks.networks[].icon` | URL data encoded icon to display | mandatory| -|`moreNetworks.networks[].href` | Network href to redirect to. If present, the values `{:sourceChain}` and `{:targetChain}` are replaced with the selected currently selected chains before redirecting | optional | -|`moreNetworks.networks[].label` | Display text | mandatory | -|`moreNetworks.networks[].name` | Unique network key | optional, defaults to a snake_case version of the label | -|`moreNetworks.networks[].description` | Description value | optional, defaults to `moreNetworks.description`| -|`moreNetworks.networks[].target` | href target value | optional, defaults to `moreNetworks.target`| -| `moreNetworks.networks[].showOpenInNewIcon` | Disable top right open in new icon | optional, defaults to **true** if target is `_blank` or **false** if target is `_self`| - -```json -{ - ... - "moreNetworks": { - "href": "https://example.com", - "target": "_blank", - "description": "brief description that should be displayed as tooltip when the user over an more network icon", - "networks": [ - { - "icon": "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='91' height='91' viewBox='0 0 91 91' fill='none'%3E%3Ccircle cx='45.5' cy='45.5' r='45.5' fill='%23E8E8EC'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M26.833 25.8333C26.2807 25.8333 25.833 26.281 25.833 26.8333V63.1666C25.833 63.7189 26.2807 64.1666 26.833 64.1666H63.1663C63.7186 64.1666 64.1663 63.7189 64.1663 63.1666V48.7333C64.1663 48.4571 63.9425 48.2333 63.6663 48.2333C63.3902 48.2333 63.1663 48.4571 63.1663 48.7333V63.1666H26.833V26.8333L41.2663 26.8333C41.5425 26.8333 41.7663 26.6094 41.7663 26.3333C41.7663 26.0571 41.5425 25.8333 41.2663 25.8333H26.833ZM64.0199 25.9797C64.0321 25.9919 64.0435 26.0046 64.0542 26.0177L64.1663 26.324L64.1663 26.3342V37.5333C64.1663 37.8094 63.9425 38.0333 63.6663 38.0333C63.3902 38.0333 63.1663 37.8094 63.1663 37.5333V27.5404L41.6199 49.0868C41.4246 49.2821 41.1081 49.2821 40.9128 49.0868C40.7175 48.8915 40.7175 48.575 40.9128 48.3797L62.4592 26.8333H52.4663C52.1902 26.8333 51.9663 26.6094 51.9663 26.3333C51.9663 26.0571 52.1902 25.8333 52.4663 25.8333H63.666H63.6663C63.6823 25.8333 63.6983 25.834 63.7143 25.8355C63.7632 25.8402 63.8116 25.8521 63.8577 25.8712C63.9167 25.8956 63.972 25.9318 64.0199 25.9797Z' fill='%230F1022'/%3E%3Cpath d='M63.1663 63.1666V64.1666H64.1663V63.1666H63.1663ZM26.833 63.1666H25.833V64.1666H26.833V63.1666ZM26.833 26.8333L26.833 25.8333L25.833 25.8333V26.8333H26.833ZM41.2663 26.8333L41.2663 25.8333H41.2663L41.2663 26.8333ZM64.0542 26.0177L64.9934 25.6742L64.9356 25.5161L64.8292 25.3857L64.0542 26.0177ZM64.0199 25.9797L64.727 25.2726L64.727 25.2726L64.0199 25.9797ZM64.1663 26.324L65.1662 26.3158L65.1648 26.1429L65.1054 25.9806L64.1663 26.324ZM64.1663 26.3342L65.1664 26.3342L65.1663 26.326L64.1663 26.3342ZM63.1663 27.5404H64.1663V25.1261L62.4592 26.8333L63.1663 27.5404ZM40.9128 49.0868L40.2057 49.7939L40.2057 49.7939L40.9128 49.0868ZM40.9128 48.3797L40.2057 47.6726L40.2057 47.6726L40.9128 48.3797ZM62.4592 26.8333L63.1663 27.5404L64.8734 25.8333H62.4592V26.8333ZM63.7143 25.8355L63.8096 24.8401L63.8095 24.8401L63.7143 25.8355ZM63.8577 25.8712L64.2401 24.9472L64.24 24.9472L63.8577 25.8712ZM26.833 26.8333V26.8333V24.8333C25.7284 24.8333 24.833 25.7287 24.833 26.8333H26.833ZM26.833 63.1666V26.8333H24.833V63.1666H26.833ZM26.833 63.1666H26.833H24.833C24.833 64.2712 25.7284 65.1666 26.833 65.1666V63.1666ZM63.1663 63.1666H26.833V65.1666H63.1663V63.1666ZM63.1663 63.1666V65.1666C64.2709 65.1666 65.1663 64.2712 65.1663 63.1666H63.1663ZM63.1663 48.7333V63.1666H65.1663V48.7333H63.1663ZM63.6663 49.2333C63.3902 49.2333 63.1663 49.0094 63.1663 48.7333H65.1663C65.1663 47.9048 64.4948 47.2333 63.6663 47.2333V49.2333ZM64.1663 48.7333C64.1663 49.0094 63.9425 49.2333 63.6663 49.2333V47.2333C62.8379 47.2333 62.1663 47.9048 62.1663 48.7333H64.1663ZM64.1663 63.1666V48.7333H62.1663V63.1666H64.1663ZM26.833 64.1666H63.1663V62.1666H26.833V64.1666ZM25.833 26.8333V63.1666H27.833V26.8333H25.833ZM41.2663 25.8333L26.833 25.8333L26.833 27.8333L41.2663 27.8333L41.2663 25.8333ZM40.7663 26.3333C40.7663 26.0571 40.9902 25.8333 41.2663 25.8333V27.8333C42.0948 27.8333 42.7663 27.1617 42.7663 26.3333H40.7663ZM41.2663 26.8333C40.9902 26.8333 40.7663 26.6094 40.7663 26.3333H42.7663C42.7663 25.5048 42.0948 24.8333 41.2663 24.8333V26.8333ZM26.833 26.8333H41.2663V24.8333H26.833V26.8333ZM64.8292 25.3857C64.7971 25.3464 64.763 25.3086 64.727 25.2726L63.3128 26.6868C63.3012 26.6752 63.2899 26.6628 63.2793 26.6497L64.8292 25.3857ZM65.1054 25.9806L64.9934 25.6742L63.1151 26.3611L63.2271 26.6675L65.1054 25.9806ZM65.1663 26.326L65.1662 26.3158L63.1663 26.3322L63.1664 26.3425L65.1663 26.326ZM65.1663 37.5333V26.3342H63.1663V37.5333H65.1663ZM63.6663 39.0333C64.4948 39.0333 65.1663 38.3617 65.1663 37.5333H63.1663C63.1663 37.2571 63.3902 37.0333 63.6663 37.0333V39.0333ZM62.1663 37.5333C62.1663 38.3617 62.8379 39.0333 63.6663 39.0333V37.0333C63.9425 37.0333 64.1663 37.2571 64.1663 37.5333H62.1663ZM62.1663 27.5404V37.5333H64.1663V27.5404H62.1663ZM42.327 49.7939L63.8734 28.2475L62.4592 26.8333L40.9128 48.3797L42.327 49.7939ZM40.2057 49.7939C40.7915 50.3797 41.7412 50.3797 42.327 49.7939L40.9128 48.3797C41.108 48.1844 41.4246 48.1844 41.6199 48.3797L40.2057 49.7939ZM40.2057 47.6726C39.6199 48.2584 39.6199 49.2081 40.2057 49.7939L41.6199 48.3797C41.8152 48.575 41.8152 48.8915 41.6199 49.0868L40.2057 47.6726ZM61.7521 26.1261L40.2057 47.6726L41.6199 49.0868L63.1663 27.5404L61.7521 26.1261ZM52.4663 27.8333H62.4592V25.8333H52.4663V27.8333ZM50.9663 26.3333C50.9663 27.1617 51.6379 27.8333 52.4663 27.8333V25.8333C52.7425 25.8333 52.9663 26.0571 52.9663 26.3333H50.9663ZM52.4663 24.8333C51.6379 24.8333 50.9663 25.5048 50.9663 26.3333H52.9663C52.9663 26.6094 52.7425 26.8333 52.4663 26.8333V24.8333ZM63.666 24.8333H52.4663V26.8333H63.666V24.8333ZM63.6663 24.8333H63.666V26.8333H63.6663V24.8333ZM63.8095 24.8401C63.7619 24.8355 63.7141 24.8333 63.6663 24.8333V26.8333C63.6505 26.8333 63.6347 26.8325 63.619 26.831L63.8095 24.8401ZM64.24 24.9472C64.1011 24.8897 63.9559 24.8541 63.8096 24.8401L63.619 26.831C63.5706 26.8264 63.5221 26.8146 63.4754 26.7952L64.24 24.9472ZM64.727 25.2726C64.5845 25.1301 64.4184 25.0209 64.2401 24.9472L63.4754 26.7952C63.4151 26.7702 63.3594 26.7334 63.3128 26.6868L64.727 25.2726Z' fill='%230F1022'/%3E%3C/svg%3E", - "name": "more", - "label": "More networks", - "href": "https://portalbridge.com/#/transfer", - "showOpenInNewIcon": false, - } - ] - } - ... +```ts +const config: WormholeConnectConfig = { + networks: ['ethereum', 'solana'] } ``` -### More Tokens +By default, it offers its full built-in list for both `mainnet` and `testnet`: -Show a special entry on the select tokens modal which redirects the user to a different page/dApp/mobile app. +| `mainnet` | `testnet` | +| ---------- | ------------- | +| ethereum | goerli, sepolia | +| polygon | mumbai | +| bsc | bsc | +| avalanche | fuji | +| celo | avalanche | +| moonbeam | moonbasealpha | +| solana | solana | +| sui | sui | +| aptos | aptos | +| base | basegoerli, base_sepolia | +| osmosis | osmosis | +| evmos | evmos | +| kujira | kujira | +| injective | injective | +| klaytn | klaytn | +| arbitrum | arbitrumgoerli, arbitrum_sepolia | +| optimism | optimismgoerli, optimism_sepolia | -|Property|description|| -|:--|:--|:--:| -|`moreTokens.label`| Display text | mandatory| -|`moreTokens.href`| URL to redirect to. If present, the values `{:sourceChain}` and `{:targetChain}` are replaced with the selected currently selected chains before redirecting | mandatory| -|`moreTokens.target`| href target | optional, defaults to `_self` +> Osmosis support is in beta, reach out to a Wormhole contributor for early access. +### Learn More -### Explorer +Please read [the full Connect documentation](https://docs.wormhole.com/wormhole/wormhole-connect/overview) to see what else is possible! -Enable explorer button to allow users to search for his transactions on a given explorer filtering by his wallet address +## Contributing -|Property|description|| -|:--|:--|:--:| -|`explorer.label`| Display text | optional, defaults to `Transactions`| -|`explorer.href`| URL of the explorer, for instance https://wormholescan.com/. If present, the values `{:address}` is replaced with the connected wallet address| mandatory| -|`explorer.target`| href target | optional, defaults to `_blank` +We welcome contributions and bug fixes. Please see [CONTRIBUTING.md](https://github.com/wormhole-foundation/wormhole-connect/blob/development/CONTRIBUTING.md) ## Disclaimer diff --git a/wormhole-connect/docs/config.md b/wormhole-connect/docs/config.md new file mode 100644 index 000000000..0045e032e --- /dev/null +++ b/wormhole-connect/docs/config.md @@ -0,0 +1,361 @@ +# Wormhole Connect - more `config` examples + +See `WormholeConnectConfig` in [src/config/index.ts](https://github.com/wormhole-foundation/wormhole-connect/blob/development/wormhole-connect/src/config/index.ts) +for a full view of the supported config parameters. + +### Examples + +(Optional) Specify supported networks/tokens and custom RPC endpoints. Your users may encounter rate limits using public RPC endpoints if you do not provide your own + +```jsx +import WormholeConnect, { + WormholeConnectConfig, +} from "@wormhole-foundation/wormhole-connect"; + +const config: WormholeConnectConfig = { + env: "mainnet", + networks: ["ethereum", "polygon", "solana"], + tokens: ["ETH", "WETH", "MATIC", "WMATIC"], + rpcs: { + ethereum: "https://rpc.ankr.com/eth", + solana: "https://rpc.ankr.com/solana", + }, +}; + +function App() { + return ; +} +``` + +Create fully customized theme + +```jsx +import WormholeConnect, { + WormholeConnectTheme, +} from "@wormhole-foundation/wormhole-connect"; +import red from "@mui/material/colors/red"; +import lightblue from "@mui/material/colors/lightBlue"; +import grey from "@mui/material/colors/grey"; +import green from "@mui/material/colors/green"; +import orange from "@mui/material/colors/orange"; + +const customTheme: WormholeConnectTheme = { + mode: 'dark', + primary: grey, + secondary: grey, + divider: 'rgba(255, 255, 255, 0.2)', + background: { + default: "#232323", + }, + text: { + primary: "#ffffff", + secondary: grey[500], + }, + error: red, + info: lightblue, + success: green, + warning: orange, + button: { + primary: 'rgba(255, 255, 255, 0.2)', + primaryText: "#ffffff", + disabled: 'rgba(255, 255, 255, 0.1)', + disabledText: 'rgba(255, 255, 255, 0.4)', + action: orange[300], + actionText: "#000000", + hover: 'rgba(255, 255, 255, 0.7)', + }, + options: { + hover: "#474747", + select: "#5b5b5b", + }, + card: { + background: "#333333", + secondary: "#474747", + elevation: "none", + }, + popover: { + background: "#1b2033", + secondary: 'rgba(255, 255, 255, 0.5)', + elevation: "none", + }, + modal: { + background: "#474747", + }, + font: { + primary: 'Impact', + header: 'Impact', + } +}; + +export default function App() { + return ; +} +``` + +## More Configuration Options + + +### Whitelisting Tokens (`tokens`): + +You can provide a whitelist of tokens under `tokens`. By default, Connect will offer its full built-in list: + +| Mainnet | Testnet | +| ----------- | -------- | +| ETH | ETH, ETHsepolia | +| WETH | WETH, WETHsepolia | +| USDCeth | USDCeth | +| WBTC | | +| USDT | | +| DAI | | +| BUSD | | +| MATIC | MATIC | +| WMATIC | WMATIC | +| USDCpolygon | | +| BNB | BNB | +| WBNB | WBNB | +| USDCbnb | | +| AVAX | AVAX | +| WAVAX | WAVAX | +| USDCavax | USDCavax | +| FTM | FTM | +| WFTM | WFTM | +| CELO | CELO | +| GLMR | GLMR | +| WGLMR | WGLMR | +| SOL | WSOL | +| PYTH | | +| SUI | SUI | +| USDCsol | | +| APT | APT | +| ETHarbitrum | ETHarbitrum, ETHarbitrum_sepolia | +| WETHarbitrum | WETHarbitrum, WETHarbitrum_sepolia | +| USDCarbitrum | USDCarbitrum| +| ETHoptimism | ETHoptimism, ETHoptimism_sepolia | +| WETHoptimism | WETHoptimism, WETHoptimism_sepolia | +| USDCoptimism | USDCoptimism| +| ETHbase | ETHbase, ETHbase_sepolia | +| WETHbase | WETHbase, WETHbase_sepolia | +| tBTC | tBTC | +| tBTCpolygon | tBTCpolygon | +| tBTCoptimism | tBTCoptimism | +| tBTCarbitrum | tBTCarbitrum | +| tBTCbase | tBTCbase | +| tBTCsol | tBTCsol | +| WETHpolygon | | +| WETHbsc | | +| wstETH | wstETH | +| wstETHarbitrum | | +| wstETHoptimism | | +| wstETHpolygon | | +| wstETHbase | | + +### Routes (`routes`) + +You can provide a whietlist of routes under `routes`. By default, Connect will offer its full built-in list: + +| Mainnet | Testnet | +| -------- | ---------| +| bridge | bridge | +| relay | relay | +| cctpManual | cctpManual | +| cctpRelay | cctpRelay | +| cosmosGateway | cosmosGateway | +| tbtc | tbtc | +| ethBridge | | +| wstETHBridge | | + + + +### Wallet Connect Project ID + +Required in order to display Wallet Connect as a wallet option. You can get a project ID on https://cloud.walletconnect.com/. Refer to the wallet connect [documentation](https://docs.walletconnect.com/advanced/migration-from-v1.x/overview) for more information on v2. + +### Toggle Hamburguer Menu + +By setting the `showHamburgerMenu` option to **false**, you can deactivate the hamburger menu, causing the links to be positioned at the bottom. + +#### Add extra menu entry + +By setting the `showHamburgerMenu` option to **false**, you can use the `menu` array to add extra links. + +|property|description| +|--|--| +|`menu[].label`|link name to show up| +|`menu[].href`|target url or urn| +|`menu[].target`|anchor standard target, by default `_blank`| +|`menu[].order`|order where the new item should be injected| + +#### Sample configuration + +```json +{ + "showHamburgerMenu": false, + "menu": [ + { + "label": "Advance Tools", + "href": "https://portalbridge.com", + "target": "_self", + "order": 1 + } + ] +} +``` + +### CoinGecko API Key + +If you have a CoinGecko API Plan, you can include the API key in the configuration. In case you do not have the API key, [follow this steps](https://apiguide.coingecko.com/getting-started/getting-started). + +### More Networks + +Specify a set of extra networks to be displayed on the network selection modal, each of them linking to a different page/dApp/mobile app the user will be redirected to. + +|Property|description|| +|:--|:--|:--:| +|`moreNetworks.href`| Default value for missing network hrefs | mandatory| +|`moreNetworks.target`| Default value for missing network link targets | optional, defaults to `_self` +|`moreNetworks.description` | Brief description that should be displayed as tooltip when the user hover an more network icon. Used as default for missing network descriptions | optional | +|`moreNetworks.networks[].icon` | URL data encoded icon to display | mandatory| +|`moreNetworks.networks[].href` | Network href to redirect to. If present, the values `{:sourceChain}` and `{:targetChain}` are replaced with the selected currently selected chains before redirecting | optional | +|`moreNetworks.networks[].label` | Display text | mandatory | +|`moreNetworks.networks[].name` | Unique network key | optional, defaults to a snake_case version of the label | +|`moreNetworks.networks[].description` | Description value | optional, defaults to `moreNetworks.description`| +|`moreNetworks.networks[].target` | href target value | optional, defaults to `moreNetworks.target`| +| `moreNetworks.networks[].showOpenInNewIcon` | Disable top right open in new icon | optional, defaults to **true** if target is `_blank` or **false** if target is `_self`| + +```json +{ + ... + "moreNetworks": { + "href": "https://example.com", + "target": "_blank", + "description": "brief description that should be displayed as tooltip when the user over an more network icon", + "networks": [ + { + "icon": "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='91' height='91' viewBox='0 0 91 91' fill='none'%3E%3Ccircle cx='45.5' cy='45.5' r='45.5' fill='%23E8E8EC'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M26.833 25.8333C26.2807 25.8333 25.833 26.281 25.833 26.8333V63.1666C25.833 63.7189 26.2807 64.1666 26.833 64.1666H63.1663C63.7186 64.1666 64.1663 63.7189 64.1663 63.1666V48.7333C64.1663 48.4571 63.9425 48.2333 63.6663 48.2333C63.3902 48.2333 63.1663 48.4571 63.1663 48.7333V63.1666H26.833V26.8333L41.2663 26.8333C41.5425 26.8333 41.7663 26.6094 41.7663 26.3333C41.7663 26.0571 41.5425 25.8333 41.2663 25.8333H26.833ZM64.0199 25.9797C64.0321 25.9919 64.0435 26.0046 64.0542 26.0177L64.1663 26.324L64.1663 26.3342V37.5333C64.1663 37.8094 63.9425 38.0333 63.6663 38.0333C63.3902 38.0333 63.1663 37.8094 63.1663 37.5333V27.5404L41.6199 49.0868C41.4246 49.2821 41.1081 49.2821 40.9128 49.0868C40.7175 48.8915 40.7175 48.575 40.9128 48.3797L62.4592 26.8333H52.4663C52.1902 26.8333 51.9663 26.6094 51.9663 26.3333C51.9663 26.0571 52.1902 25.8333 52.4663 25.8333H63.666H63.6663C63.6823 25.8333 63.6983 25.834 63.7143 25.8355C63.7632 25.8402 63.8116 25.8521 63.8577 25.8712C63.9167 25.8956 63.972 25.9318 64.0199 25.9797Z' fill='%230F1022'/%3E%3Cpath d='M63.1663 63.1666V64.1666H64.1663V63.1666H63.1663ZM26.833 63.1666H25.833V64.1666H26.833V63.1666ZM26.833 26.8333L26.833 25.8333L25.833 25.8333V26.8333H26.833ZM41.2663 26.8333L41.2663 25.8333H41.2663L41.2663 26.8333ZM64.0542 26.0177L64.9934 25.6742L64.9356 25.5161L64.8292 25.3857L64.0542 26.0177ZM64.0199 25.9797L64.727 25.2726L64.727 25.2726L64.0199 25.9797ZM64.1663 26.324L65.1662 26.3158L65.1648 26.1429L65.1054 25.9806L64.1663 26.324ZM64.1663 26.3342L65.1664 26.3342L65.1663 26.326L64.1663 26.3342ZM63.1663 27.5404H64.1663V25.1261L62.4592 26.8333L63.1663 27.5404ZM40.9128 49.0868L40.2057 49.7939L40.2057 49.7939L40.9128 49.0868ZM40.9128 48.3797L40.2057 47.6726L40.2057 47.6726L40.9128 48.3797ZM62.4592 26.8333L63.1663 27.5404L64.8734 25.8333H62.4592V26.8333ZM63.7143 25.8355L63.8096 24.8401L63.8095 24.8401L63.7143 25.8355ZM63.8577 25.8712L64.2401 24.9472L64.24 24.9472L63.8577 25.8712ZM26.833 26.8333V26.8333V24.8333C25.7284 24.8333 24.833 25.7287 24.833 26.8333H26.833ZM26.833 63.1666V26.8333H24.833V63.1666H26.833ZM26.833 63.1666H26.833H24.833C24.833 64.2712 25.7284 65.1666 26.833 65.1666V63.1666ZM63.1663 63.1666H26.833V65.1666H63.1663V63.1666ZM63.1663 63.1666V65.1666C64.2709 65.1666 65.1663 64.2712 65.1663 63.1666H63.1663ZM63.1663 48.7333V63.1666H65.1663V48.7333H63.1663ZM63.6663 49.2333C63.3902 49.2333 63.1663 49.0094 63.1663 48.7333H65.1663C65.1663 47.9048 64.4948 47.2333 63.6663 47.2333V49.2333ZM64.1663 48.7333C64.1663 49.0094 63.9425 49.2333 63.6663 49.2333V47.2333C62.8379 47.2333 62.1663 47.9048 62.1663 48.7333H64.1663ZM64.1663 63.1666V48.7333H62.1663V63.1666H64.1663ZM26.833 64.1666H63.1663V62.1666H26.833V64.1666ZM25.833 26.8333V63.1666H27.833V26.8333H25.833ZM41.2663 25.8333L26.833 25.8333L26.833 27.8333L41.2663 27.8333L41.2663 25.8333ZM40.7663 26.3333C40.7663 26.0571 40.9902 25.8333 41.2663 25.8333V27.8333C42.0948 27.8333 42.7663 27.1617 42.7663 26.3333H40.7663ZM41.2663 26.8333C40.9902 26.8333 40.7663 26.6094 40.7663 26.3333H42.7663C42.7663 25.5048 42.0948 24.8333 41.2663 24.8333V26.8333ZM26.833 26.8333H41.2663V24.8333H26.833V26.8333ZM64.8292 25.3857C64.7971 25.3464 64.763 25.3086 64.727 25.2726L63.3128 26.6868C63.3012 26.6752 63.2899 26.6628 63.2793 26.6497L64.8292 25.3857ZM65.1054 25.9806L64.9934 25.6742L63.1151 26.3611L63.2271 26.6675L65.1054 25.9806ZM65.1663 26.326L65.1662 26.3158L63.1663 26.3322L63.1664 26.3425L65.1663 26.326ZM65.1663 37.5333V26.3342H63.1663V37.5333H65.1663ZM63.6663 39.0333C64.4948 39.0333 65.1663 38.3617 65.1663 37.5333H63.1663C63.1663 37.2571 63.3902 37.0333 63.6663 37.0333V39.0333ZM62.1663 37.5333C62.1663 38.3617 62.8379 39.0333 63.6663 39.0333V37.0333C63.9425 37.0333 64.1663 37.2571 64.1663 37.5333H62.1663ZM62.1663 27.5404V37.5333H64.1663V27.5404H62.1663ZM42.327 49.7939L63.8734 28.2475L62.4592 26.8333L40.9128 48.3797L42.327 49.7939ZM40.2057 49.7939C40.7915 50.3797 41.7412 50.3797 42.327 49.7939L40.9128 48.3797C41.108 48.1844 41.4246 48.1844 41.6199 48.3797L40.2057 49.7939ZM40.2057 47.6726C39.6199 48.2584 39.6199 49.2081 40.2057 49.7939L41.6199 48.3797C41.8152 48.575 41.8152 48.8915 41.6199 49.0868L40.2057 47.6726ZM61.7521 26.1261L40.2057 47.6726L41.6199 49.0868L63.1663 27.5404L61.7521 26.1261ZM52.4663 27.8333H62.4592V25.8333H52.4663V27.8333ZM50.9663 26.3333C50.9663 27.1617 51.6379 27.8333 52.4663 27.8333V25.8333C52.7425 25.8333 52.9663 26.0571 52.9663 26.3333H50.9663ZM52.4663 24.8333C51.6379 24.8333 50.9663 25.5048 50.9663 26.3333H52.9663C52.9663 26.6094 52.7425 26.8333 52.4663 26.8333V24.8333ZM63.666 24.8333H52.4663V26.8333H63.666V24.8333ZM63.6663 24.8333H63.666V26.8333H63.6663V24.8333ZM63.8095 24.8401C63.7619 24.8355 63.7141 24.8333 63.6663 24.8333V26.8333C63.6505 26.8333 63.6347 26.8325 63.619 26.831L63.8095 24.8401ZM64.24 24.9472C64.1011 24.8897 63.9559 24.8541 63.8096 24.8401L63.619 26.831C63.5706 26.8264 63.5221 26.8146 63.4754 26.7952L64.24 24.9472ZM64.727 25.2726C64.5845 25.1301 64.4184 25.0209 64.2401 24.9472L63.4754 26.7952C63.4151 26.7702 63.3594 26.7334 63.3128 26.6868L64.727 25.2726Z' fill='%230F1022'/%3E%3C/svg%3E", + "name": "more", + "label": "More networks", + "href": "https://portalbridge.com/#/transfer", + "showOpenInNewIcon": false, + } + ] + } + ... +} +``` + +### More Tokens + +Show a special entry on the select tokens modal which redirects the user to a different page/dApp/mobile app. + +|Property|description|| +|:--|:--|:--:| +|`moreTokens.label`| Display text | mandatory| +|`moreTokens.href`| URL to redirect to. If present, the values `{:sourceChain}` and `{:targetChain}` are replaced with the selected currently selected chains before redirecting | mandatory| +|`moreTokens.target`| href target | optional, defaults to `_self` + + +### Explorer + +Enable explorer button to allow users to search for his transactions on a given explorer filtering by his wallet address + +|Property|description|| +|:--|:--|:--:| +|`explorer.label`| Display text | optional, defaults to `Transactions`| +|`explorer.href`| URL of the explorer, for instance https://wormholescan.com/. If present, the values `{:address}` is replaced with the connected wallet address| mandatory| +|`explorer.target`| href target | optional, defaults to `_blank` + + + + +## Environment + +This shows how to run Connect on mainnet. + +```json +{ + "env": "mainnet" +} +``` + +## Custom RPC Endpoint + +This shows how to change which RPC provider Connect uses for a particular network. + +```json +{ + "rpcs": { + "solana": "https://rpc.ankr.com/solana/ee827255553bb0fa9e0aaeab27e988707e60ea06ae36be0658b778072e94979e" + } +} +``` + +## Arbitrary Token + +This shows how to add an arbitrary token to your deployment of Connect. +Please note you will need to [register](https://portalbridge.com/advanced-tools/#/register) +your token with the Token Bridge to get the contract addresses necessary for it to work with Connect. + +These example config limits Connect to the Solana and Ethereum networks, +and a handful of tokens including `BSKT` which is not built in by default +and provided under the `tokensConfig` key. + +See [src/config/types.ts](https://github.com/wormhole-foundation/wormhole-connect/blob/development/wormhole-connect/src/config/types.ts) +for the type definition of `TokensConfig`. + +```json +{ + "networks": ["solana", "ethereum"], + "tokens": ["ETH", "WETH", "MATIC", "WMATIC", "BSKT"], + "tokensConfig": { + "BSKT": { + "key": "BSKT", + "symbol": "BSKT", + "nativeChain": "solana", + "tokenId": { + "chain": "solana", + "address": "6gnCPhXtLnUD76HjQuSYPENLSZdG8RvDB1pTLM5aLSJA" + }, + "coinGeckoId": "basket", + "icon": "https://assets.coingecko.com/coins/images/34661/standard/BSKT_Logo.png?1705636891", + "color": "#2894EE", + "decimals": { + "default": 5 + }, + "foreignAssets": { + "ethereum": { + "address": "0xbC0899E527007f1B8Ced694508FCb7a2b9a46F53", + "decimals": 5 + }, + "bsc": { + "address": "0xaF42A5df3C1C1427DA8FC0326bD7b030A9367e78", + "decimals": 5 + }, + "polygon": { + "address": "0x9a6a40CdF21a0AF417F1b815223FD92c85636c58", + "decimals": 5 + }, + "avalanche": { + "address": "0x6Ac048ae05E7E015accA2aA7Abd0Ec013e8E3a59", + "decimals": 5 + }, + "sui": { + "address": "0xd4d52a6bf452401c0c70a1d19ff6cec2933f22a548eae552f3e514f64f61703a::coin::COIN", + "decimals": 5 + }, + "arbitrum": { + "address": "0xa3210cd727fE6DAf8386af5623ba51A367E46263", + "decimals": 5 + }, + "base": { + "address": "0x7CCDbA6198db389cF37b714FD6573b73F3670236", + "decimals": 5 + }, + "celo": { + "address": "0x3fc50bc066aE2ee280876EeefADfdAbF6cA02894", + "decimals": 5 + } + } + } + } +} +``` diff --git a/wormhole-connect/src/WormholeConnect.tsx b/wormhole-connect/src/WormholeConnect.tsx index d79fb0279..699959663 100644 --- a/wormhole-connect/src/WormholeConnect.tsx +++ b/wormhole-connect/src/WormholeConnect.tsx @@ -8,11 +8,11 @@ import AppRouter from './AppRouter'; import { getDesignTokens, dark } from './theme'; import ErrorBoundary from './components/ErrorBoundary'; import { WormholeConnectConfig } from './config/types'; -import { CustomTheme } from 'theme'; +import { WormholeConnectPartialTheme } from 'theme'; export interface WormholeConnectProps { // theme can be updated at any time to change the colors of Connect - theme?: CustomTheme; + theme?: WormholeConnectPartialTheme; // config is only used once, when Connect first mounts, to initialize the global config config?: WormholeConnectConfig; } diff --git a/wormhole-connect/src/config/examples.md b/wormhole-connect/src/config/examples.md deleted file mode 100644 index c22204ce8..000000000 --- a/wormhole-connect/src/config/examples.md +++ /dev/null @@ -1,94 +0,0 @@ -# Wormhole Connect - `config` examples - -## Environment - -This shows how to run Connect on mainnet. - -```json -{ - "env": "mainnet" -} -``` - -## Custom RPC Endpoint - -This shows how to change which RPC provider Connect uses for a particular network. - -```json -{ - "rpcs": { - "solana": "https://rpc.ankr.com/solana/ee827255553bb0fa9e0aaeab27e988707e60ea06ae36be0658b778072e94979e" - } -} -``` - -## Arbitrary Token - -This shows how to add an arbitrary token to your deployment of Connect. -Please note you will need to [register](https://portalbridge.com/advanced-tools/#/register) -your token with the Token Bridge to get the contract addresses necessary for it to work with Connect. - -These example config limits Connect to the Solana and Ethereum networks, -and a handful of tokens including `BSKT` which is not built in by default -and provided under the `tokensConfig` key. - -See [src/config/types.ts](https://github.com/wormhole-foundation/wormhole-connect/blob/development/wormhole-connect/src/config/types.ts) -for the type definition of `TokensConfig`. - -```json -{ - "networks": ["solana", "ethereum"], - "tokens": ["ETH", "WETH", "MATIC", "WMATIC", "BSKT"], - "tokensConfig": { - "BSKT": { - "key": "BSKT", - "symbol": "BSKT", - "nativeChain": "solana", - "tokenId": { - "chain": "solana", - "address": "6gnCPhXtLnUD76HjQuSYPENLSZdG8RvDB1pTLM5aLSJA" - }, - "coinGeckoId": "basket", - "icon": "https://assets.coingecko.com/coins/images/34661/standard/BSKT_Logo.png?1705636891", - "color": "#2894EE", - "decimals": { - "default": 5 - }, - "foreignAssets": { - "ethereum": { - "address": "0xbC0899E527007f1B8Ced694508FCb7a2b9a46F53", - "decimals": 5 - }, - "bsc": { - "address": "0xaF42A5df3C1C1427DA8FC0326bD7b030A9367e78", - "decimals": 5 - }, - "polygon": { - "address": "0x9a6a40CdF21a0AF417F1b815223FD92c85636c58", - "decimals": 5 - }, - "avalanche": { - "address": "0x6Ac048ae05E7E015accA2aA7Abd0Ec013e8E3a59", - "decimals": 5 - }, - "sui": { - "address": "0xd4d52a6bf452401c0c70a1d19ff6cec2933f22a548eae552f3e514f64f61703a::coin::COIN", - "decimals": 5 - }, - "arbitrum": { - "address": "0xa3210cd727fE6DAf8386af5623ba51A367E46263", - "decimals": 5 - }, - "base": { - "address": "0x7CCDbA6198db389cF37b714FD6573b73F3670236", - "decimals": 5 - }, - "celo": { - "address": "0x3fc50bc066aE2ee280876EeefADfdAbF6cA02894", - "decimals": 5 - } - } - } - } -} -``` diff --git a/wormhole-connect/src/config/index.ts b/wormhole-connect/src/config/index.ts index 1a5a19753..35fd91d26 100644 --- a/wormhole-connect/src/config/index.ts +++ b/wormhole-connect/src/config/index.ts @@ -20,7 +20,7 @@ export function buildConfig( customConfig?.network || customConfig?.env || // TODO remove; deprecated import.meta.env.REACT_APP_CONNECT_ENV?.toLowerCase() || - 'testnet' + 'mainnet' ).toLowerCase() as Network; if (!['mainnet', 'testnet', 'devnet'].includes(network)) diff --git a/wormhole-connect/src/config/types.ts b/wormhole-connect/src/config/types.ts index c2e03cece..f5d4126c6 100644 --- a/wormhole-connect/src/config/types.ts +++ b/wormhole-connect/src/config/types.ts @@ -9,7 +9,7 @@ import { WormholeConfig, } from '@wormhole-foundation/wormhole-connect-sdk'; import { Alignment } from 'components/Header'; -import { ExtendedTheme } from 'theme'; +import { WormholeConnectPartialTheme } from 'theme'; export enum Icon { 'AVAX' = 1, @@ -89,7 +89,7 @@ export interface WormholeConnectConfig { // Legacy support: allow theme to be in this config object // This should be removed in a future version after people have switched // to providing the theme as a separate prop - customTheme?: ExtendedTheme; + customTheme?: WormholeConnectPartialTheme; mode?: 'dark' | 'light'; // UI details diff --git a/wormhole-connect/src/demo.tsx b/wormhole-connect/src/demo.tsx index dfbe30cfd..eeec842a7 100644 --- a/wormhole-connect/src/demo.tsx +++ b/wormhole-connect/src/demo.tsx @@ -7,7 +7,7 @@ export * from './theme'; // This is the demo app used for local development function DemoApp() { - return ; + return ; } const root = ReactDOM.createRoot(document.querySelector('main') as HTMLElement); diff --git a/wormhole-connect/src/index.ts b/wormhole-connect/src/index.ts index 8538442d5..97322ffd6 100644 --- a/wormhole-connect/src/index.ts +++ b/wormhole-connect/src/index.ts @@ -2,11 +2,19 @@ import WormholeConnect from './WormholeConnect'; export default WormholeConnect; export { dark, light } from './theme'; -import type { CustomTheme, ExtendedTheme } from './theme'; +import type { + WormholeConnectPartialTheme, + WormholeConnectTheme, +} from './theme'; import type { WormholeConnectConfig } from './config/types'; import type { ChainName } from '@wormhole-foundation/wormhole-connect-sdk'; -export { WormholeConnectConfig, ChainName, CustomTheme, ExtendedTheme }; +export { + WormholeConnectConfig, + ChainName, + WormholeConnectPartialTheme, + WormholeConnectTheme, +}; export { MAINNET_CHAINS, diff --git a/wormhole-connect/src/main.tsx b/wormhole-connect/src/main.tsx index 54f8e5f42..3222fbceb 100644 --- a/wormhole-connect/src/main.tsx +++ b/wormhole-connect/src/main.tsx @@ -3,7 +3,7 @@ import ReactDOM from 'react-dom/client'; import WormholeConnect from './WormholeConnect'; import ErrorBoundary from './components/ErrorBoundary'; import { WormholeConnectConfig } from 'config/types'; -import { ExtendedTheme } from './theme'; +import { WormholeConnectPartialTheme } from './theme'; export * from './theme'; // This is the entry point that runs when integrators add the Connect widget @@ -26,7 +26,7 @@ if (!container) { } let config: WormholeConnectConfig | undefined = undefined; -let theme: ExtendedTheme | undefined = undefined; +let theme: WormholeConnectPartialTheme | undefined = undefined; try { let configAttr = container.getAttribute('data-config'); diff --git a/wormhole-connect/src/theme.ts b/wormhole-connect/src/theme.ts index 0e0a1fedb..bf4bda4f4 100644 --- a/wormhole-connect/src/theme.ts +++ b/wormhole-connect/src/theme.ts @@ -23,7 +23,7 @@ export type PaletteColor = { A700: string; }; -export type CustomTheme = { +export type WormholeConnectPartialTheme = { mode?: PaletteMode; primary?: PaletteColor; secondary?: PaletteColor; @@ -71,9 +71,9 @@ export type CustomTheme = { }; }; -export type ExtendedTheme = Required; +export type WormholeConnectTheme = Required; -export const light: ExtendedTheme = { +export const light: WormholeConnectTheme = { mode: 'light', primary: { 50: '#161718', @@ -152,7 +152,7 @@ export const light: ExtendedTheme = { }; // wormhole styled theme -export const dark: ExtendedTheme = { +export const dark: WormholeConnectTheme = { mode: 'dark', primary: grey, secondary: grey, @@ -246,9 +246,9 @@ export const dark: ExtendedTheme = { }, }; -export const getDesignTokens = (customTheme: CustomTheme) => { +export const getDesignTokens = (customTheme: WormholeConnectPartialTheme) => { const baseTheme = customTheme?.mode === 'light' ? light : dark; - const theme = Object.assign(baseTheme, customTheme) as ExtendedTheme; + const theme = Object.assign(baseTheme, customTheme) as WormholeConnectTheme; return createTheme({ components: {