From 1bcca2353cfa857157e3a6a23559b0a2bdc1160f Mon Sep 17 00:00:00 2001 From: Brad playdon Date: Mon, 8 Sep 2025 21:44:02 +0100 Subject: [PATCH 1/2] Revert "feat: add new event type to WormholeConnectEventCore (#3754)" This reverts commit ee510bc2bda348a0455659e7f07a3104b7d0fffc. --- src/config/ui.ts | 11 ++--- src/config/utils.ts | 53 ++++++++++------------- src/store/transferInput.ts | 12 +++-- src/telemetry/types.ts | 31 +------------ src/telemetry/utils.ts | 34 --------------- src/views/v2/Bridge/AssetPicker/index.tsx | 10 ----- src/views/v3/Bridge/AssetPicker/index.tsx | 7 --- tsconfig.json | 1 + 8 files changed, 35 insertions(+), 124 deletions(-) delete mode 100644 src/telemetry/utils.ts diff --git a/src/config/ui.ts b/src/config/ui.ts index 43827f029..c71727574 100644 --- a/src/config/ui.ts +++ b/src/config/ui.ts @@ -50,14 +50,11 @@ export type Experimental = { [Experiment in Experiments]?: boolean; }; -export interface ChainTokenPair { - chain: Chain; - token?: string; -} - export interface DefaultInputs { - source?: ChainTokenPair; - destination?: ChainTokenPair; + fromChain?: Chain; + toChain?: Chain; + fromToken?: string; // Address or symbol + toToken?: string; // Address or symbol requiredChain?: Chain; preferredRouteName?: string; } diff --git a/src/config/utils.ts b/src/config/utils.ts index 227abc17e..dd9ef684e 100644 --- a/src/config/utils.ts +++ b/src/config/utils.ts @@ -135,38 +135,33 @@ export const validateDefaults = ( tokens: TokenCache, ) => { if (!defaults) return; - if (defaults.source?.chain) { - const chain = chains[defaults.source.chain]; + if (defaults.fromChain) { + const chain = chains[defaults.fromChain]; if (!chain) { error( - `Invalid chain name "${defaults.source.chain}" specified for defaultInputs.source.chain`, + `Invalid chain name "${defaults.fromChain}" specified for defaultInputs.fromChain`, ); - delete defaults.source; + delete defaults.fromChain; } } - if (defaults.destination?.chain) { - const chain = chains[defaults.destination.chain]; + if (defaults.toChain) { + const chain = chains[defaults.toChain]; if (!chain) { error( - `Invalid chain name "${defaults.destination.chain}" specified for defaultInputs.destination.chain`, + `Invalid chain name "${defaults.toChain}" specified for defaultInputs.toChain`, ); - delete defaults.destination; + delete defaults.fromChain; } } - - if (defaults.source?.token && defaults.destination?.token) { - if (defaults.source.token === defaults.destination.token) { + if (defaults.fromChain && defaults.toChain) { + if (defaults.fromChain === defaults.toChain) { error( - `Source and destination token cannot be the same, check the defaultInputs configuration`, + `Source and destination chain cannot be the same, check the defaultInputs configuration`, ); } } - if ( - defaults.source?.chain && - defaults.destination?.chain && - defaults.requiredChain - ) { + if (defaults.fromChain && defaults.toChain && defaults.requiredChain) { const requiredConfig = chains[defaults.requiredChain]; if (!requiredConfig) { error( @@ -174,8 +169,8 @@ export const validateDefaults = ( ); } if ( - defaults.destination.chain !== defaults.requiredChain && - defaults.source.chain !== defaults.requiredChain + defaults.toChain !== defaults.requiredChain && + defaults.fromChain !== defaults.requiredChain ) { error( `Source chain or destination chain must equal the required network`, @@ -183,29 +178,29 @@ export const validateDefaults = ( } } - if (defaults.source?.chain && defaults.source?.token) { + if (defaults.fromChain && defaults.fromToken) { const token = tokens.findByAddressOrSymbol( - defaults.source.chain, - defaults.source.token, + defaults.fromChain, + defaults.fromToken, ); if (!token) { error( - `Invalid token "${defaults.source?.token}" specified for defaultInputs.fromToken`, + `Invalid token "${defaults.fromToken}" specified for defaultInputs.fromToken`, ); - delete defaults.source.token; + delete defaults.fromToken; } } - if (defaults.destination?.chain && defaults.destination?.token) { + if (defaults.toChain && defaults.toToken) { const token = tokens.findByAddressOrSymbol( - defaults.destination.chain, - defaults.destination.token, + defaults.toChain, + defaults.toToken, ); if (!token) { error( - `Invalid token "${defaults.destination?.token}" specified for defaultInputs.toToken`, + `Invalid token "${defaults.toToken}" specified for defaultInputs.toToken`, ); - delete defaults.destination.token; + delete defaults.toToken; } } diff --git a/src/store/transferInput.ts b/src/store/transferInput.ts index 387ba7de3..a98240503 100644 --- a/src/store/transferInput.ts +++ b/src/store/transferInput.ts @@ -51,17 +51,15 @@ export interface TransferInputState { // This is a function because config might have changed since we last cleared this store function getInitialState(): TransferInputState { - const { source, destination } = config.ui.defaultInputs || {}; - const fromChain = source?.chain; - const fromToken = source?.token; - const toChain = destination?.chain; - const toToken = destination?.token; + const { fromChain, toChain, fromToken, toToken } = + config.ui.defaultInputs || {}; + const fromTokenTuple = - fromToken && fromChain + fromChain && fromToken ? config.tokens.findByAddressOrSymbol(fromChain, fromToken)?.tuple : undefined; const toTokenTuple = - toToken && toChain + toChain && toToken ? config.tokens.findByAddressOrSymbol(toChain, toToken)?.tuple : undefined; diff --git a/src/telemetry/types.ts b/src/telemetry/types.ts index 745c2d943..f11c5ca90 100644 --- a/src/telemetry/types.ts +++ b/src/telemetry/types.ts @@ -1,6 +1,5 @@ import type { Chain, amount as sdkAmount } from '@wormhole-foundation/sdk'; import type { WormholeConnectConfig } from 'config/types'; -import type { Token } from 'config/tokens'; import type { TransferWallet } from 'utils/wallet'; export interface LoadEvent { @@ -104,41 +103,13 @@ export interface HistoryLoadEvent { }; } -export enum UserActions { - SelectSrcToken = 'select.src.token', - SelectSrcChain = 'select.src.chain', - SelectDestToken = 'select.dest.token', - SelectDestChain = 'select.dest.chain', -} - -type UserActionValueMap = { - [UserActions.SelectSrcToken]: Token; - [UserActions.SelectDestToken]: Token; - [UserActions.SelectSrcChain]: Chain; - [UserActions.SelectDestChain]: Chain; -}; - -export type UserActionEvent = { - type: 'user.action'; - details: { - action: A; - value: UserActionValueMap[A]; - }; -}; - -// Helper type to narrow value by action -export type UserActionEvents = { - [A in UserActions]: UserActionEvent; -}[UserActions]; - export type WormholeConnectEventCore = | LoadEvent | UpdateConfigEvent | TransferEvent | TransferErrorEvent | ConnectWalletEvent - | HistoryLoadEvent - | UserActionEvent; + | HistoryLoadEvent; export interface WormholeConnectEventMeta { meta: { diff --git a/src/telemetry/utils.ts b/src/telemetry/utils.ts deleted file mode 100644 index c40f0f00f..000000000 --- a/src/telemetry/utils.ts +++ /dev/null @@ -1,34 +0,0 @@ -import config from 'config'; -import type { Chain } from '@wormhole-foundation/sdk-base'; -import type { Token } from 'config/tokens'; -import { UserActions } from './types'; - -export const handleTelemetryOnChainSelect = ( - chain: Chain, - isSource: boolean, -) => { - config.triggerEvent({ - type: 'user.action', - details: { - value: chain, - action: isSource - ? UserActions.SelectSrcChain - : UserActions.SelectDestChain, - }, - }); -}; - -export const handleTelemetryOnTokenSelect = ( - token: Token, - isSource: boolean, -) => { - config.triggerEvent({ - type: 'user.action', - details: { - value: token, - action: isSource - ? UserActions.SelectSrcToken - : UserActions.SelectDestToken, - }, - }); -}; diff --git a/src/views/v2/Bridge/AssetPicker/index.tsx b/src/views/v2/Bridge/AssetPicker/index.tsx index e03626efd..09fa5c9e2 100644 --- a/src/views/v2/Bridge/AssetPicker/index.tsx +++ b/src/views/v2/Bridge/AssetPicker/index.tsx @@ -27,10 +27,6 @@ import AssetBadge from 'components/AssetBadge'; import type { Token } from 'config/tokens'; import { useTokenList } from 'hooks/useTokenList'; import { getTokenSymbol } from 'utils'; -import { - handleTelemetryOnChainSelect, - handleTelemetryOnTokenSelect, -} from 'telemetry/utils'; type Props = { chain?: Chain | undefined; @@ -274,7 +270,6 @@ const AssetPicker = (props: Props) => { setShowSearch={setShowChainSearch} wallet={props.wallet} onChainSelect={(key) => { - handleTelemetryOnChainSelect(key, props.isSource); props.setChain(key); setSearchQuery(''); }} @@ -295,8 +290,6 @@ const AssetPicker = (props: Props) => { searchQuery={searchQuery} onSearchQueryChange={setSearchQuery} onSelectToken={(key: Token) => { - handleTelemetryOnTokenSelect(key, props.isSource); - handleTelemetryOnChainSelect(key.chain, props.isSource); props.setToken(key); setIsDrawerOpen(false); }} @@ -330,7 +323,6 @@ const AssetPicker = (props: Props) => { setShowSearch={setShowChainSearch} wallet={props.wallet} onChainSelect={(key) => { - handleTelemetryOnChainSelect(key, props.isSource); props.setChain(key); setSearchQuery(''); }} @@ -351,8 +343,6 @@ const AssetPicker = (props: Props) => { searchQuery={searchQuery} onSearchQueryChange={setSearchQuery} onSelectToken={(key: Token) => { - handleTelemetryOnTokenSelect(key, props.isSource); - handleTelemetryOnChainSelect(key.chain, props.isSource); props.setToken(key); popupState.close(); }} diff --git a/src/views/v3/Bridge/AssetPicker/index.tsx b/src/views/v3/Bridge/AssetPicker/index.tsx index 73ab1a4f1..1aa8a4474 100644 --- a/src/views/v3/Bridge/AssetPicker/index.tsx +++ b/src/views/v3/Bridge/AssetPicker/index.tsx @@ -30,10 +30,6 @@ import AssetPickerDrawer from 'views/v3/Bridge/AssetPicker/PickerBottomSheet'; import AssetPickerPopover from 'views/v3/Bridge/AssetPicker/PickerModal'; import { calculateUSDPrice, getTokenSymbol } from 'utils'; import { formatWithCommas } from 'utils/formatNumber'; -import { - handleTelemetryOnChainSelect, - handleTelemetryOnTokenSelect, -} from 'telemetry/utils'; type Props = { chain?: Chain | undefined; @@ -301,7 +297,6 @@ function AssetPicker(props: Props) { const handleChainSelect = useCallback( (chain: Chain) => { - handleTelemetryOnChainSelect(chain, props.isSource); props.setChain(chain); setSearchQuery(''); }, @@ -310,8 +305,6 @@ function AssetPicker(props: Props) { const handleTokenSelect = useCallback( (token: Token) => { - handleTelemetryOnTokenSelect(token, props.isSource); - handleTelemetryOnChainSelect(token.chain, props.isSource); if (props.isSource && props.token?.key !== token.key) { // Reset amount when source token is changed handleAmountChange(''); diff --git a/tsconfig.json b/tsconfig.json index 4a3e4af77..2947036d3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,6 +8,7 @@ ], "compilerOptions": { "baseUrl": "src", + "allowImportingTsExtensions": true, "declaration": true, "declarationMap": true, "esModuleInterop": true, From 51e4188abb6274e3112ae8882c2ab1d37c1e5616 Mon Sep 17 00:00:00 2001 From: Brad playdon Date: Tue, 9 Sep 2025 15:39:14 +0100 Subject: [PATCH 2/2] chore: bump wallet aggregator sdk --- package-lock.json | 26 +++++++------------------- package.json | 2 +- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5d38eb2cd..d5b36e2c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48,7 +48,7 @@ "@wormhole-labs/cctp-executor-route": "0.12.0", "@wormhole-labs/wallet-aggregator-aptos": "1.3.0", "@wormhole-labs/wallet-aggregator-core": "0.0.1", - "@wormhole-labs/wallet-aggregator-evm": "0.8.0", + "@wormhole-labs/wallet-aggregator-evm": "0.9.0", "@wormhole-labs/wallet-aggregator-solana": "0.0.1", "@wormhole-labs/wallet-aggregator-sui": "0.0.3", "axios": "1.11.0", @@ -106,6 +106,9 @@ "vite-plugin-node-polyfills": "^0.24.0", "vitest": "^3.2.4" }, + "engines": { + "node": ">=22.0.0" + }, "peerDependencies": { "@emotion/react": "^11.11.0", "@emotion/styled": "^11.11.0", @@ -18440,9 +18443,9 @@ } }, "node_modules/@wormhole-labs/wallet-aggregator-evm": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@wormhole-labs/wallet-aggregator-evm/-/wallet-aggregator-evm-0.8.0.tgz", - "integrity": "sha512-h/fJZOATVC0NhFB34g7sXDgYwAksk1n3UQ/zFE2S2qG08lszXFdgf4P90Aa0gm/CBIrIGdFJGSB/AZ+bghkavQ==", + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/@wormhole-labs/wallet-aggregator-evm/-/wallet-aggregator-evm-0.9.0.tgz", + "integrity": "sha512-+YUKdROYazYXsjUUkfRcY59NCRaXaKrG/p8oW/ypICBa1jjs7WUfp5a0zkA3W2XjH1tmLFeRDsFxchq5N4/3CQ==", "license": "MIT", "dependencies": { "@wagmi/connectors": "^5.8.5", @@ -27344,21 +27347,6 @@ "license": "MIT", "peer": true }, - "node_modules/meow": { - "version": "13.2.0", - "resolved": "https://registry.npmjs.org/meow/-/meow-13.2.0.tgz", - "integrity": "sha512-pxQJQzB6djGPXh08dacEloMFopsOqGVRKFPYvPOt9XDZ1HasbgDZA74CJGreSU4G3Ak7EFJGoiH2auq+yXISgA==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/merge": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/merge/-/merge-2.1.1.tgz", diff --git a/package.json b/package.json index 1b0a456fe..23fa3f6a9 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "@wormhole-labs/cctp-executor-route": "0.12.0", "@wormhole-labs/wallet-aggregator-aptos": "1.3.0", "@wormhole-labs/wallet-aggregator-core": "0.0.1", - "@wormhole-labs/wallet-aggregator-evm": "0.8.0", + "@wormhole-labs/wallet-aggregator-evm": "0.9.0", "@wormhole-labs/wallet-aggregator-solana": "0.0.1", "@wormhole-labs/wallet-aggregator-sui": "0.0.3", "axios": "1.11.0",