diff --git a/src/analytics/event.ts b/src/analytics/event.ts index a14b86f457..07be2def47 100644 --- a/src/analytics/event.ts +++ b/src/analytics/event.ts @@ -299,6 +299,10 @@ export type EventProperties = { * Whether Degen Mode was used for the swap. */ degenMode: boolean; + /** + * Whether a hardware wallet was used for the swap. + */ + hardwareWallet: boolean; }; [event.commandKActionExecuted]: { id?: string; @@ -838,6 +842,10 @@ export type EventProperties = { * Whether Degen Mode was used for the swap. */ degenMode: boolean; + /** + * Whether a hardware wallet was used for the swap. + */ + hardwareWallet: boolean; }; [event.walletViewed]: undefined; [event.toggledDegenMode]: { enabled: boolean }; diff --git a/src/entries/popup/pages/swap/onSwap.tsx b/src/entries/popup/pages/swap/onSwap.tsx index 88e3b955a0..ae75d8e499 100644 --- a/src/entries/popup/pages/swap/onSwap.tsx +++ b/src/entries/popup/pages/swap/onSwap.tsx @@ -1,4 +1,5 @@ import { CrosschainQuote, Quote, QuoteError } from '@rainbow-me/swaps'; +import { Address } from 'viem'; import { analytics } from '~/analytics'; import { event } from '~/analytics/event'; @@ -10,12 +11,13 @@ import { usePopupInstanceStore } from '~/core/state/popupInstances'; import { useSwapAssetsToRefreshStore } from '~/core/state/swapAssetsToRefresh'; import { ParsedSearchAsset } from '~/core/types/assets'; import { ChainId } from '~/core/types/chains'; +import { KeychainType } from '~/core/types/keychainTypes'; import { isSameAssetInDiffChains } from '~/core/utils/assets'; import { triggerAlert } from '~/design-system/components/Alert/Alert'; import playSound from '~/entries/popup/utils/playSound'; import { RainbowError, logger } from '~/logger'; -import * as wallet from '../../handlers/wallet'; +import { executeRap, getWallet } from '../../handlers/wallet'; export const onSwap = async ({ assetToSell, @@ -45,7 +47,9 @@ export const onSwap = async ({ const chainId = isConnectedToHardhat ? ChainId.hardhat : assetToSell.chainId; const isBridge = isSameAssetInDiffChains(assetToSell, assetToBuy); - const { errorMessage, nonce } = await wallet.executeRap({ + const wallet = getWallet(q.from as Address); + + const { errorMessage, nonce } = await executeRap({ rapActionParameters: { sellAmount: q.sellAmount?.toString(), buyAmount: q.buyAmount?.toString(), @@ -94,6 +98,7 @@ export const onSwap = async ({ tradeAmountUSD: q.tradeAmountUSD, crosschain: assetToSell.chainId !== assetToBuy.chainId, degenMode, + hardwareWallet: (await wallet).type === KeychainType.HardwareWalletKeychain, }); playSound('SendSound');