From c95212a575f3112c58703a86565c58a984c44909 Mon Sep 17 00:00:00 2001 From: Viktor Vasas Date: Mon, 7 Oct 2024 14:04:04 +0200 Subject: [PATCH 1/8] feat: add ew method to get extensions --- .../providers/MultiWalletProviderProxy.ts | 26 ++- .../providers/initializeInpageProvider.ts | 41 +++- src/background/providers/models.ts | 5 + .../providers/utils/getWalletExtensionType.ts | 10 + .../web3/handlers/avalanche_selectWallet.ts | 2 + src/background/services/web3/models.ts | 3 + src/pages/ApproveAction/SelectWallet.tsx | 33 +++- .../components/WalletExtensionButton.tsx | 178 +++++++++++++----- 8 files changed, 231 insertions(+), 67 deletions(-) diff --git a/src/background/providers/MultiWalletProviderProxy.ts b/src/background/providers/MultiWalletProviderProxy.ts index 7eb1ce3da..a9d86c9b3 100644 --- a/src/background/providers/MultiWalletProviderProxy.ts +++ b/src/background/providers/MultiWalletProviderProxy.ts @@ -8,6 +8,7 @@ import { getWalletExtensionType } from './utils/getWalletExtensionType'; import { Maybe } from '@avalabs/core-utils-sdk'; import EventEmitter from 'events'; import { EVMProvider } from '@avalabs/evm-module/dist/provider'; +import { EIP6963ProviderDetail } from '@avalabs/vm-module-types'; export class MultiWalletProviderProxy extends EventEmitter { #_providers: unknown[] = []; @@ -64,8 +65,10 @@ export class MultiWalletProviderProxy extends EventEmitter { }); } - public addProvider(provider) { + public addProvider(providerDetail) { + console.log('providerDetail: ', providerDetail); // the COINBASE collects here the wallets + /* if (provider.providerMap) { for (const providerProxy of provider.providerMap.values()) { if ( @@ -77,14 +80,22 @@ export class MultiWalletProviderProxy extends EventEmitter { } return; } + */ // the coinbase would add another proxy which is useless for us - if (provider.coinbaseWalletInstalls) { - return; - } - - if (!this.#_providers.includes(provider)) { - this.#_providers.push(provider); + // if (providerDetail.coinbaseWalletInstalls) { + // return; + // } + + const isProviderAdded = this.#_providers.find( + (provider) => provider.info.uuid === providerDetail.info.uuid + ); + console.log('isProviderAdded: ', isProviderAdded); + if (!isProviderAdded) { + console.log('providerDetail: ', providerDetail); + console.log('ADD -++++--_'); + this.#_providers.push(providerDetail); + console.log('this.#_providers: ', this.#_providers); } } @@ -105,6 +116,7 @@ export class MultiWalletProviderProxy extends EventEmitter { return { index: i, type, + info: p.info, }; }), ], diff --git a/src/background/providers/initializeInpageProvider.ts b/src/background/providers/initializeInpageProvider.ts index 7cc6c8355..dd4e11918 100644 --- a/src/background/providers/initializeInpageProvider.ts +++ b/src/background/providers/initializeInpageProvider.ts @@ -17,6 +17,7 @@ export function initializeProvider( maxListeners = 100, globalObject = window ): EVMProvider { + console.log('initializeProvider globalObject: ', globalObject); const chainAgnosticProvider = new Proxy( new ChainAgnosticProvider(connection), { @@ -44,10 +45,27 @@ export function initializeProvider( deleteProperty: () => true, } ); + const multiWalletProxy = createMultiWalletProxy(evmProvider); + + globalObject.addEventListener('eip6963:announceProvider', (event: any) => { + // console.log('event: ', event.detail); + multiWalletProxy.addProvider( + new Proxy( + { + info: { ...event.detail.info }, + ...event.detail.provider, + }, + { + deleteProperty: () => true, + set: () => true, + } + ) + ); + }); - setGlobalProvider(evmProvider, globalObject); + setGlobalProvider(evmProvider, globalObject, multiWalletProxy); setAvalancheGlobalProvider(evmProvider, globalObject); - setEvmproviders(evmProvider, globalObject); + // setEvmproviders(evmProvider, globalObject); announceWalletProvider(evmProvider, globalObject); announceChainAgnosticProvider(chainAgnosticProvider, globalObject); @@ -62,23 +80,28 @@ export function initializeProvider( */ function setGlobalProvider( providerInstance: EVMProvider, - globalObject = window + globalObject = window, + multiWalletProxy ): void { + // console.log('globalObject: ', globalObject); + // console.log('globalObject.ethereum: ', globalObject.ethereum); + // console.log('globalObject.phatnom: ', globalObject.phantom); try { - const multiWalletProxy = createMultiWalletProxy(providerInstance); + // const multiWalletProxy = createMultiWalletProxy(providerInstance); // if we already have a wallet lets add it - if (globalObject.ethereum) { - multiWalletProxy.addProvider(globalObject.ethereum); - } + // if (globalObject.ethereum) { + // console.log('addProvider globalObject.ethereum: ', globalObject.ethereum); + // multiWalletProxy.addProvider(globalObject.ethereum); + // } Object.defineProperty(globalObject, 'ethereum', { get: () => { return multiWalletProxy; }, // in case a wallet tries to overwrite us lets add them to the list - set: (value) => { - multiWalletProxy.addProvider(value); + set: () => { + return multiWalletProxy; }, }); diff --git a/src/background/providers/models.ts b/src/background/providers/models.ts index f338116ac..f16f8a4b6 100644 --- a/src/background/providers/models.ts +++ b/src/background/providers/models.ts @@ -24,6 +24,11 @@ export interface EIP6963ProviderDetail { provider: Eip1193Provider; } +export interface EIP6963AnnounceProviderEvent extends CustomEvent { + type: 'eip6963:announceProvider'; + detail: EIP6963ProviderDetail; +} + export enum EventNames { CORE_WALLET_ANNOUNCE_PROVIDER = 'core-wallet:announceProvider', CORE_WALLET_REQUEST_PROVIDER = 'core-wallet:requestProvider', diff --git a/src/background/providers/utils/getWalletExtensionType.ts b/src/background/providers/utils/getWalletExtensionType.ts index ee7926598..f81b26dd2 100644 --- a/src/background/providers/utils/getWalletExtensionType.ts +++ b/src/background/providers/utils/getWalletExtensionType.ts @@ -2,9 +2,19 @@ import { WalletExtensionType } from '../../services/web3/models'; // using any since we don't really know what properties other wallets define export function getWalletExtensionType(provider: any): WalletExtensionType { + console.log('provider: ', provider); if (provider.isAvalanche) { return WalletExtensionType.CORE; } + if (provider.isPhantom) { + return WalletExtensionType.PHANTOM; + } + if (provider.isKeplr) { + return WalletExtensionType.KEPLR; + } + if (provider.isZerion) { + return WalletExtensionType.ZERION; + } if (provider.isRabby) { return WalletExtensionType.RABBY; } diff --git a/src/background/services/web3/handlers/avalanche_selectWallet.ts b/src/background/services/web3/handlers/avalanche_selectWallet.ts index 891fb8188..f8f422b78 100644 --- a/src/background/services/web3/handlers/avalanche_selectWallet.ts +++ b/src/background/services/web3/handlers/avalanche_selectWallet.ts @@ -13,6 +13,7 @@ export class AvalancheSelectWalletHandler extends DAppRequestHandler { handleUnauthenticated = async (rpcCall) => { const { request } = rpcCall; const [availableExtensions] = request.params; + console.log('availableExtensions: ', availableExtensions); if (!availableExtensions || availableExtensions.length === 0) { return { @@ -26,6 +27,7 @@ export class AvalancheSelectWalletHandler extends DAppRequestHandler { ...request, displayData: { options: availableExtensions.map((o) => o.type), + info: availableExtensions.map((extension) => extension.info), }, }, `approve/select-wallet` diff --git a/src/background/services/web3/models.ts b/src/background/services/web3/models.ts index 97a308c65..e0425f5e2 100644 --- a/src/background/services/web3/models.ts +++ b/src/background/services/web3/models.ts @@ -4,4 +4,7 @@ export enum WalletExtensionType { UNKNOWN = 'UNKNOWN', RABBY = 'RABBY', COINBASE = 'COINBASE', + PHANTOM = 'PHANTOM', + ZERION = 'ZERION', + KEPLR = 'KEPLR', } diff --git a/src/pages/ApproveAction/SelectWallet.tsx b/src/pages/ApproveAction/SelectWallet.tsx index 7555b755d..f074661dd 100644 --- a/src/pages/ApproveAction/SelectWallet.tsx +++ b/src/pages/ApproveAction/SelectWallet.tsx @@ -4,13 +4,17 @@ import { useApproveAction } from '@src/hooks/useApproveAction'; import { useGetRequestId } from '@src/hooks/useGetRequestId'; import { useCallback } from 'react'; import { LoadingOverlay } from '../../components/common/LoadingOverlay'; -import { WalletExtensionButton } from '../Wallet/components/WalletExtensionButton'; +import { + NewButton, + WalletExtensionButton, +} from '../Wallet/components/WalletExtensionButton'; import { Trans } from 'react-i18next'; import { Stack, Typography, WalletIcon } from '@avalabs/core-k2-components'; export function SelectWallet() { const requestId = useGetRequestId(); const { action: request, updateAction } = useApproveAction(requestId); + console.log('request: ', request); const selectWallet = useCallback( async (index: number | string) => @@ -46,15 +50,30 @@ export function SelectWallet() { - {request.displayData.options.map((option, i) => ( - { + if (info.rdns === 'app.core.extension') { + return ( + { + selectWallet(i); + }} + info={info} + /> + ); + } + return; + })} + {request.displayData.info.length > 1 && ( + { - selectWallet(i); + // selectWallet(i); + console.log('selectWAlelt'); }} - type={option} + // info={info} + wallets={request.displayData.info} /> - ))} + )} ); diff --git a/src/pages/Wallet/components/WalletExtensionButton.tsx b/src/pages/Wallet/components/WalletExtensionButton.tsx index 475f08b22..2a68fba3f 100644 --- a/src/pages/Wallet/components/WalletExtensionButton.tsx +++ b/src/pages/Wallet/components/WalletExtensionButton.tsx @@ -1,74 +1,164 @@ import { useTranslation } from 'react-i18next'; import { Button, + ButtonGroup, + ChevronDownIcon, + ClickAwayListener, CoinbaseWalletIcon, CoreIcon, + Grow, + KeyIcon, + MenuItem, + MenuList, MetaMaskIcon, + Popper, + Stack, + styled, + Typography, WalletIcon, } from '@avalabs/core-k2-components'; import { WalletExtensionType } from '@src/background/services/web3/models'; +import { EIP6963ProviderInfo } from '@avalabs/vm-module-types'; +import { useRef, useState } from 'react'; interface WalletExtensionButtonProps { - type: WalletExtensionType; + type?: WalletExtensionType; + info?: EIP6963ProviderInfo; onClick: () => void; + wallets?: EIP6963ProviderInfo[]; } +const StyledMenuItem = styled(MenuItem)` + color: ${({ theme }) => theme.palette.text.secondary}; + &:hover { + color: ${({ theme }) => theme.palette.text.primary}; + } +`; + +const StyledButtonGroup = styled(ButtonGroup)` + border-radius: 999px; +`; + export function WalletExtensionButton({ - type, + info, onClick, }: WalletExtensionButtonProps) { + console.log('info: ', info); const { t } = useTranslation(); - const getWalletDisplayName = (walletType: WalletExtensionType) => { - switch (walletType) { - case WalletExtensionType.METAMASK: - return 'Metamask'; - case WalletExtensionType.COINBASE: - return 'Coinbase'; - case WalletExtensionType.UNKNOWN: - default: - return t('Unknown wallet'); - } - }; - - const getWalletLogo = (walletType: WalletExtensionType) => { - switch (walletType) { - case WalletExtensionType.METAMASK: - return ; - case WalletExtensionType.COINBASE: - return ; - case WalletExtensionType.UNKNOWN: - default: - return ; - } - }; - - if (type === WalletExtensionType.CORE) { - return ( - - ); - } - return ( ); } + +export function NewButton({ + info, + onClick, + wallets, +}: WalletExtensionButtonProps) { + console.log('wallets: ', wallets); + const { t } = useTranslation(); + const toggleButtonRef = useRef(); + const [isMenuOpen, setIsMenuOpen] = useState(false); + return ( + + setIsMenuOpen(false)}> + + + + + + + + ); +} From 46131f479a694be804657a1f113bda560a1a8120 Mon Sep 17 00:00:00 2001 From: Viktor Vasas Date: Mon, 14 Oct 2024 23:40:58 +0200 Subject: [PATCH 2/8] feat: add selectwallet click event --- .../providers/MultiWalletProviderProxy.ts | 40 +++-------- .../providers/initializeInpageProvider.ts | 12 ---- src/pages/ApproveAction/SelectWallet.tsx | 21 +++--- .../components/WalletExtensionButton.tsx | 67 +++++++------------ 4 files changed, 48 insertions(+), 92 deletions(-) diff --git a/src/background/providers/MultiWalletProviderProxy.ts b/src/background/providers/MultiWalletProviderProxy.ts index a9d86c9b3..70fa53bc0 100644 --- a/src/background/providers/MultiWalletProviderProxy.ts +++ b/src/background/providers/MultiWalletProviderProxy.ts @@ -8,10 +8,9 @@ import { getWalletExtensionType } from './utils/getWalletExtensionType'; import { Maybe } from '@avalabs/core-utils-sdk'; import EventEmitter from 'events'; import { EVMProvider } from '@avalabs/evm-module/dist/provider'; -import { EIP6963ProviderDetail } from '@avalabs/vm-module-types'; export class MultiWalletProviderProxy extends EventEmitter { - #_providers: unknown[] = []; + #_providers: EVMProvider[] = []; #isWalletSelected = false; #defaultProvider; @@ -66,41 +65,21 @@ export class MultiWalletProviderProxy extends EventEmitter { } public addProvider(providerDetail) { - console.log('providerDetail: ', providerDetail); - // the COINBASE collects here the wallets - /* - if (provider.providerMap) { - for (const providerProxy of provider.providerMap.values()) { - if ( - !providerProxy.isAvalanche && // we exclude Core being duplicated - !this.#_providers.includes(providerProxy) - ) { - this.#_providers.push(providerProxy); - } - } - return; - } - */ - - // the coinbase would add another proxy which is useless for us - // if (providerDetail.coinbaseWalletInstalls) { - // return; - // } - const isProviderAdded = this.#_providers.find( (provider) => provider.info.uuid === providerDetail.info.uuid ); - console.log('isProviderAdded: ', isProviderAdded); + if (!isProviderAdded) { - console.log('providerDetail: ', providerDetail); - console.log('ADD -++++--_'); this.#_providers.push(providerDetail); - console.log('this.#_providers: ', this.#_providers); } } async #toggleWalletSelection(): Promise { // no need to select a wallet when there is only one + console.log( + 'toggleWalletSelection this.#isWalletSelected: ', + this.#isWalletSelected + ); if (this.#_providers.length === 1 || this.#isWalletSelected) { return; } @@ -122,6 +101,8 @@ export class MultiWalletProviderProxy extends EventEmitter { ], }); + console.log('selectedIndex: ', selectedIndex); + if ( selectedIndex === undefined || selectedIndex === null || @@ -153,6 +134,7 @@ export class MultiWalletProviderProxy extends EventEmitter { if (this.#_providers[selectedIndex]) { this.#isWalletSelected = true; } + console.log(' this.#isWalletSelected: ', this.#isWalletSelected); // set default wallet for this connection this.#defaultProvider = @@ -278,7 +260,7 @@ export function createMultiWalletProxy(evmProvider: EVMProvider) { // intercept unknow calls that are meant to be handled by the current provider // and forward them if needed so that we don't have to implement all the custom // functions any given wallet provider might expose - get: (target, prop, receiver) => { + get: (_, prop, receiver) => { // if the proxy has the function call it if (proxyProvider[prop]) { return proxyProvider[prop]; @@ -292,7 +274,7 @@ export function createMultiWalletProxy(evmProvider: EVMProvider) { // check if the request param is an extension defined by the dApp return Reflect.get(walletProviderExtensions, prop, receiver); }, - set(obj, prop, value) { + set(_, prop, value) { Reflect.set(walletProviderExtensions, prop, value); return true; }, diff --git a/src/background/providers/initializeInpageProvider.ts b/src/background/providers/initializeInpageProvider.ts index dd4e11918..e52b2a29c 100644 --- a/src/background/providers/initializeInpageProvider.ts +++ b/src/background/providers/initializeInpageProvider.ts @@ -48,7 +48,6 @@ export function initializeProvider( const multiWalletProxy = createMultiWalletProxy(evmProvider); globalObject.addEventListener('eip6963:announceProvider', (event: any) => { - // console.log('event: ', event.detail); multiWalletProxy.addProvider( new Proxy( { @@ -65,7 +64,6 @@ export function initializeProvider( setGlobalProvider(evmProvider, globalObject, multiWalletProxy); setAvalancheGlobalProvider(evmProvider, globalObject); - // setEvmproviders(evmProvider, globalObject); announceWalletProvider(evmProvider, globalObject); announceChainAgnosticProvider(chainAgnosticProvider, globalObject); @@ -152,16 +150,6 @@ function setAvalancheGlobalProvider( globalObject.dispatchEvent(new Event('avalanche#initialized')); } -function setEvmproviders( - providerInstance: EVMProvider, - globalObject = window -): void { - globalObject.evmproviders = globalObject.evmproviders || {}; - globalObject.evmproviders.core = providerInstance; - - globalObject.dispatchEvent(new Event('evmproviders#initialized')); -} - function announceWalletProvider( providerInstance: EVMProvider, globalObject = window diff --git a/src/pages/ApproveAction/SelectWallet.tsx b/src/pages/ApproveAction/SelectWallet.tsx index f074661dd..eddbe2bd7 100644 --- a/src/pages/ApproveAction/SelectWallet.tsx +++ b/src/pages/ApproveAction/SelectWallet.tsx @@ -5,8 +5,8 @@ import { useGetRequestId } from '@src/hooks/useGetRequestId'; import { useCallback } from 'react'; import { LoadingOverlay } from '../../components/common/LoadingOverlay'; import { - NewButton, WalletExtensionButton, + CoreExtensionButton, } from '../Wallet/components/WalletExtensionButton'; import { Trans } from 'react-i18next'; import { Stack, Typography, WalletIcon } from '@avalabs/core-k2-components'; @@ -50,13 +50,15 @@ export function SelectWallet() { - {request.displayData.info.map((info, i) => { + {request.displayData.info.map((info, index) => { + console.log('index: ', index); + console.log('info: ', info); if (info.rdns === 'app.core.extension') { return ( - { - selectWallet(i); + selectWallet(index); }} info={info} /> @@ -65,12 +67,11 @@ export function SelectWallet() { return; })} {request.displayData.info.length > 1 && ( - { - // selectWallet(i); - console.log('selectWAlelt'); + { + console.log('selectWallet' + index); + selectWallet(index); }} - // info={info} wallets={request.displayData.info} /> )} diff --git a/src/pages/Wallet/components/WalletExtensionButton.tsx b/src/pages/Wallet/components/WalletExtensionButton.tsx index 2a68fba3f..c9bb56c55 100644 --- a/src/pages/Wallet/components/WalletExtensionButton.tsx +++ b/src/pages/Wallet/components/WalletExtensionButton.tsx @@ -4,18 +4,13 @@ import { ButtonGroup, ChevronDownIcon, ClickAwayListener, - CoinbaseWalletIcon, - CoreIcon, Grow, - KeyIcon, MenuItem, MenuList, - MetaMaskIcon, Popper, Stack, styled, Typography, - WalletIcon, } from '@avalabs/core-k2-components'; import { WalletExtensionType } from '@src/background/services/web3/models'; @@ -25,7 +20,7 @@ import { useRef, useState } from 'react'; interface WalletExtensionButtonProps { type?: WalletExtensionType; info?: EIP6963ProviderInfo; - onClick: () => void; + onClick: (index: number) => void; wallets?: EIP6963ProviderInfo[]; } @@ -40,7 +35,7 @@ const StyledButtonGroup = styled(ButtonGroup)` border-radius: 999px; `; -export function WalletExtensionButton({ +export function CoreExtensionButton({ info, onClick, }: WalletExtensionButtonProps) { @@ -55,30 +50,21 @@ export function WalletExtensionButton({ onClick={onClick} fullWidth > - {/* {getWalletLogo(type)} - {getWalletDisplayName(type)} */} {info?.name || t('Unknown')} ); } -export function NewButton({ - info, - onClick, +export function WalletExtensionButton({ wallets, + onClick, }: WalletExtensionButtonProps) { - console.log('wallets: ', wallets); const { t } = useTranslation(); const toggleButtonRef = useRef(); const [isMenuOpen, setIsMenuOpen] = useState(false); return ( - + setIsMenuOpen(false)}> @@ -131,27 +116,27 @@ export function NewButton({ width: '180px', }} > - {wallets.map((wallet) => { - if (wallet.rdns === 'app.core.extension') { - return; - } - return ( - console.log('StyledMenuItem onclick')} - data-testid="add-import-account" - key={wallet.name} - sx={{ py: 1 }} - > - - {wallet.name} - - ); - })} + {wallets && + wallets.map((wallet, index) => { + if (wallet.rdns === 'app.core.extension') { + return; + } + return ( + onClick(index)} + data-testid="add-import-account" + key={wallet.name} + sx={{ py: 1 }} + > + + {wallet.name} + + ); + })} )} From 86a391a2eb969ee43b9355329942281864849c28 Mon Sep 17 00:00:00 2001 From: Viktor Vasas Date: Thu, 17 Oct 2024 19:26:39 +0200 Subject: [PATCH 3/8] refactor: multiwalletproxy test, remove wallettype getter --- .../MultiWalletProviderProxy.test.ts | 174 +++++++----------- .../providers/MultiWalletProviderProxy.ts | 19 +- .../utils/getWalletExtensionType.test.ts | 32 ---- .../providers/utils/getWalletExtensionType.ts | 28 --- 4 files changed, 75 insertions(+), 178 deletions(-) delete mode 100644 src/background/providers/utils/getWalletExtensionType.test.ts delete mode 100644 src/background/providers/utils/getWalletExtensionType.ts diff --git a/src/background/providers/MultiWalletProviderProxy.test.ts b/src/background/providers/MultiWalletProviderProxy.test.ts index eee474bc3..1ba269d5d 100644 --- a/src/background/providers/MultiWalletProviderProxy.test.ts +++ b/src/background/providers/MultiWalletProviderProxy.test.ts @@ -8,10 +8,14 @@ import { EIP6963ProviderInfo } from '@avalabs/vm-module-types'; jest.mock('../utils/messaging/AutoPairingPostMessageConnection'); jest.mock('@avalabs/evm-module/dist/provider', () => ({ - EVMProvider: jest.fn().mockImplementation(() => ({ - isAvalanche: true, - isMetaMask: true, + EVMProvider: jest.fn().mockImplementation(({ info, ...rest }) => ({ + isAvalanche: info.uuid ? false : true, removeAllListeners: jest.fn(), + info: { + ...info, + uuid: info.uuid ?? 'default-uuid', + }, + ...rest, })), })); @@ -51,97 +55,84 @@ describe('src/background/providers/MultiWalletProviderProxy', () => { }); describe('addProvider', () => { - it('adds new providers from coinbase proxy', () => { + it('should add new providers', () => { const provider = new EVMProvider({ info: providerInfo }); const mwpp = new MultiWalletProviderProxy(provider); expect(mwpp.defaultProvider).toBe(provider); expect(mwpp.providers).toStrictEqual([provider]); - const mockProvider = { - providerMap: new Map([ - ['core', provider], - ['otherprovider', { isMetaMask: true }], - ['thirdprovider', { isRabby: true }], - ] as any), - }; + const provider2 = new EVMProvider({ + info: { ...providerInfo, uuid: 'uuid-2' }, + }); + const provider3 = new EVMProvider({ + info: { ...providerInfo, uuid: 'uuid-3' }, + }); - mwpp.addProvider(mockProvider); + mwpp.addProvider(provider2); + mwpp.addProvider(provider3); expect(mwpp.defaultProvider).toBe(provider); - expect(mwpp.providers).toEqual([ - mwpp, - { isMetaMask: true }, - { isRabby: true }, - ]); - expect((mwpp.providers[0] as any).isMetaMask).toBeTruthy(); + expect((mwpp.providers[0] as any).info.uuid).toBe(EVM_PROVIDER_INFO_UUID); + expect((mwpp.providers[1] as any).info.uuid).toBe('uuid-2'); + expect((mwpp.providers[2] as any).info.uuid).toBe('uuid-3'); }); - it('does not add extra coinbase proxy', () => { + it('should not add a new provider because it has been already registered', () => { const provider = new EVMProvider({ info: providerInfo }); const mwpp = new MultiWalletProviderProxy(provider); - expect(mwpp.defaultProvider).toBe(provider); - expect(mwpp.providers).toStrictEqual([provider]); - - const mockProvider = { - coinbaseWalletInstalls: {}, - }; - - mwpp.addProvider(mockProvider); - - expect(mwpp.defaultProvider).toBe(provider); - expect(mwpp.providers).toStrictEqual([provider]); - }); - - it('adds new provider', () => { - const provider = new EVMProvider({ info: providerInfo }); - const mwpp = new MultiWalletProviderProxy(provider); - - expect(mwpp.defaultProvider).toBe(provider); - expect(mwpp.providers).toStrictEqual([provider]); - - const mockProvider = { isMetaMask: true }; - - mwpp.addProvider(mockProvider); + const provider2 = new EVMProvider({ + info: { ...providerInfo, uuid: 'uuid-2' }, + }); + const provider3 = new EVMProvider({ + info: { ...providerInfo, uuid: 'uuid-2' }, + }); + mwpp.addProvider(provider2); + mwpp.addProvider(provider3); - expect(mwpp.defaultProvider).toBe(provider); - expect(mwpp.providers).toEqual([mwpp, mockProvider]); + expect(mwpp.providers.length as any).toBe(2); + expect((mwpp.providers[0] as any).info.uuid).toBe(EVM_PROVIDER_INFO_UUID); + expect((mwpp.providers[1] as any).info.uuid).toBe('uuid-2'); }); }); describe('wallet selection', () => { it('toggles wallet selection on `eth_requestAccounts` call if multiple providers', async () => { - const provider = new EVMProvider({ info: providerInfo }); - const provider2 = { isMetaMask: true, request: jest.fn() }; + const provider = new EVMProvider({ + info: providerInfo, + request: jest.fn().mockResolvedValue(1), + } as any); + const provider2 = new EVMProvider({ + info: { ...providerInfo, uuid: 'uuid-2' }, + isMetaMask: true, + request: jest.fn().mockResolvedValue(2), + } as any); + const mwpp = new MultiWalletProviderProxy(provider); mwpp.addProvider(provider2); - // user selects metamask - provider.request = jest.fn().mockResolvedValue(1); - provider2.request.mockResolvedValue(['0x000000']); - const requestAccountsCallback = jest.fn(); mwpp .request({ method: 'eth_requestAccounts' }) .then(requestAccountsCallback); expect(requestAccountsCallback).not.toHaveBeenCalled(); - expect(provider2.request).not.toHaveBeenCalled(); expect(provider.request).toHaveBeenCalledTimes(1); + expect(provider.request).toHaveBeenCalledWith({ method: 'avalanche_selectWallet', params: [ [ { index: 0, - type: 'CORE', + info: providerInfo, }, { index: 1, - type: 'METAMASK', + info: { ...providerInfo, uuid: 'uuid-2' }, }, ], ], @@ -152,10 +143,9 @@ describe('src/background/providers/MultiWalletProviderProxy', () => { expect(provider2.request).toHaveBeenCalledWith({ method: 'eth_requestAccounts', }); - await new Promise(process.nextTick); expect(requestAccountsCallback).toHaveBeenCalledTimes(1); - expect(requestAccountsCallback).toHaveBeenCalledWith(['0x000000']); + expect(requestAccountsCallback).toHaveBeenCalledWith(2); expect(mwpp.defaultProvider).toBe(provider2); }); @@ -184,7 +174,10 @@ describe('src/background/providers/MultiWalletProviderProxy', () => { it('does not toggle wallet selection if wallet is already selected', async () => { const provider = new EVMProvider({ info: providerInfo }); - const provider2 = { isMetaMask: true, request: jest.fn() }; + const provider2 = new EVMProvider({ + info: { ...providerInfo, uuid: 'uuid-2' }, + request: jest.fn(), + } as any); const mwpp = new MultiWalletProviderProxy(provider); mwpp.addProvider(provider2); @@ -209,11 +202,11 @@ describe('src/background/providers/MultiWalletProviderProxy', () => { [ { index: 0, - type: 'CORE', + info: providerInfo, }, { index: 1, - type: 'METAMASK', + info: { ...providerInfo, uuid: 'uuid-2' }, }, ], ], @@ -240,13 +233,15 @@ describe('src/background/providers/MultiWalletProviderProxy', () => { it('wallet selection works with legacy functions: enable', async () => { const provider = new EVMProvider({ info: providerInfo }); - const provider2 = { isMetaMask: true, enable: jest.fn() }; + const provider2 = new EVMProvider({ + info: { ...providerInfo, uuid: 'uuid-2' }, + enable: jest.fn().mockResolvedValue(['0x000000']), + } as any); const mwpp = new MultiWalletProviderProxy(provider); mwpp.addProvider(provider2); // user selects metamask provider.request = jest.fn().mockResolvedValue(1); - provider2.enable.mockResolvedValue(['0x000000']); const requestAccountsCallback = jest.fn(); mwpp.enable().then(requestAccountsCallback); @@ -261,11 +256,11 @@ describe('src/background/providers/MultiWalletProviderProxy', () => { [ { index: 0, - type: 'CORE', + info: providerInfo, }, { index: 1, - type: 'METAMASK', + info: { ...providerInfo, uuid: 'uuid-2' }, }, ], ], @@ -282,13 +277,15 @@ describe('src/background/providers/MultiWalletProviderProxy', () => { it('wallet selection works with legacy functions: sendAsync', async () => { const provider = new EVMProvider({ info: providerInfo }); - const provider2 = { isMetaMask: true, request: jest.fn() }; + const provider2 = new EVMProvider({ + info: { ...providerInfo, uuid: 'uuid-2' }, + request: jest.fn().mockResolvedValue(['0x000000']), + } as any); const mwpp = new MultiWalletProviderProxy(provider); mwpp.addProvider(provider2); // user selects metamask provider.request = jest.fn().mockResolvedValue(1); - provider2.request.mockResolvedValue(['0x000000']); const requestAccountsCallback = jest.fn(); mwpp.sendAsync( @@ -310,11 +307,11 @@ describe('src/background/providers/MultiWalletProviderProxy', () => { [ { index: 0, - type: 'CORE', + info: providerInfo, }, { index: 1, - type: 'METAMASK', + info: { ...providerInfo, uuid: 'uuid-2' }, }, ], ], @@ -336,13 +333,15 @@ describe('src/background/providers/MultiWalletProviderProxy', () => { it('wallet selection works with legacy functions: send with callback', async () => { const provider = new EVMProvider({ info: providerInfo }); - const provider2 = { isMetaMask: true, request: jest.fn() }; + const provider2 = new EVMProvider({ + info: { ...providerInfo, uuid: 'uuid-2' }, + request: jest.fn().mockResolvedValue(['0x000000']), + } as any); const mwpp = new MultiWalletProviderProxy(provider); mwpp.addProvider(provider2); // user selects metamask provider.request = jest.fn().mockResolvedValue(1); - provider2.request.mockResolvedValue(['0x000000']); const requestAccountsCallback = jest.fn(); mwpp.send( @@ -360,11 +359,11 @@ describe('src/background/providers/MultiWalletProviderProxy', () => { [ { index: 0, - type: 'CORE', + info: providerInfo, }, { index: 1, - type: 'METAMASK', + info: { ...providerInfo, uuid: 'uuid-2' }, }, ], ], @@ -418,40 +417,5 @@ describe('src/background/providers/MultiWalletProviderProxy', () => { expect((mwpp as any).defaultProvider).toBe(provider); }); - - it('maintains the providers list properly', () => { - const provider = new EVMProvider({ info: providerInfo }); - const mwpp = createMultiWalletProxy(provider); - const fooMock = () => 'bar'; - const bizMock = () => 'baz'; - - const mockProvider = { - providerMap: new Map([ - ['core', provider], - ['otherprovider', { isMetaMask: true, foo: fooMock }], - ['thirdprovider', { isRabby: true, biz: bizMock }], - ] as any), - }; - - mwpp.addProvider(mockProvider); - - expect((mwpp.providers[0] as any).isMetaMask).toBe(true); - expect((mwpp.providers[0] as any).isAvalanche).toBe(true); - expect((mwpp.providers[0] as any).someUndefinedProperty).toBe(undefined); - expect((mwpp.providers[0] as any)['#isWalletSelected']).toBe(undefined); - - expect(mwpp.providers[1] as any).toEqual({ - isMetaMask: true, - isAvalanche: undefined, - foo: fooMock, - }); - - expect(mwpp.providers[2] as any).toEqual({ - isMetaMask: undefined, - isAvalanche: undefined, - isRabby: true, - biz: bizMock, - }); - }); }); }); diff --git a/src/background/providers/MultiWalletProviderProxy.ts b/src/background/providers/MultiWalletProviderProxy.ts index 70fa53bc0..e3d506aca 100644 --- a/src/background/providers/MultiWalletProviderProxy.ts +++ b/src/background/providers/MultiWalletProviderProxy.ts @@ -4,7 +4,6 @@ import { JsonRpcRequestPayload, JsonRpcResponse, } from '../connections/dAppConnection/models'; -import { getWalletExtensionType } from './utils/getWalletExtensionType'; import { Maybe } from '@avalabs/core-utils-sdk'; import EventEmitter from 'events'; import { EVMProvider } from '@avalabs/evm-module/dist/provider'; @@ -65,9 +64,9 @@ export class MultiWalletProviderProxy extends EventEmitter { } public addProvider(providerDetail) { - const isProviderAdded = this.#_providers.find( - (provider) => provider.info.uuid === providerDetail.info.uuid - ); + const isProviderAdded = this.#_providers.find((provider) => { + return provider.info.uuid === providerDetail.info.uuid; + }); if (!isProviderAdded) { this.#_providers.push(providerDetail); @@ -76,10 +75,6 @@ export class MultiWalletProviderProxy extends EventEmitter { async #toggleWalletSelection(): Promise { // no need to select a wallet when there is only one - console.log( - 'toggleWalletSelection this.#isWalletSelected: ', - this.#isWalletSelected - ); if (this.#_providers.length === 1 || this.#isWalletSelected) { return; } @@ -90,17 +85,13 @@ export class MultiWalletProviderProxy extends EventEmitter { params: [ // using any since we don't really know what kind of provider they are this.#_providers.map((p: any, i) => { - const type = getWalletExtensionType(p); - return { index: i, - type, info: p.info, }; }), ], }); - console.log('selectedIndex: ', selectedIndex); if ( @@ -134,7 +125,6 @@ export class MultiWalletProviderProxy extends EventEmitter { if (this.#_providers[selectedIndex]) { this.#isWalletSelected = true; } - console.log(' this.#isWalletSelected: ', this.#isWalletSelected); // set default wallet for this connection this.#defaultProvider = @@ -150,12 +140,15 @@ export class MultiWalletProviderProxy extends EventEmitter { } const { method } = args; + console.log('method: ', method); + console.log('this.#_providers: ', this.#_providers); // trigger wallet selection flow at connect in case multiple providers are available if ( method === DAppProviderRequest.CONNECT_METHOD && this.#_providers.length > 1 ) { + console.log('waiting'); await this.#toggleWalletSelection(); } diff --git a/src/background/providers/utils/getWalletExtensionType.test.ts b/src/background/providers/utils/getWalletExtensionType.test.ts deleted file mode 100644 index 5ddd50c25..000000000 --- a/src/background/providers/utils/getWalletExtensionType.test.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { WalletExtensionType } from '@src/background/services/web3/models'; -import { getWalletExtensionType } from './getWalletExtensionType'; - -describe('src/background/providers/utils/getWalletExtensionType', () => { - it('returns CORE when isAvalanche is true', () => { - expect( - getWalletExtensionType({ isAvalanche: true, isMetaMask: true }) - ).toBe(WalletExtensionType.CORE); - }); - - it('returns RABBY when isRabby is true', () => { - expect(getWalletExtensionType({ isRabby: true, isMetaMask: true })).toBe( - WalletExtensionType.RABBY - ); - }); - - it('returns COINBASE when isCoinbaseWallet is true', () => { - expect( - getWalletExtensionType({ isCoinbaseWallet: true, isMetaMask: true }) - ).toBe(WalletExtensionType.COINBASE); - }); - - it('returns METAMASK when isMetamask is true', () => { - expect(getWalletExtensionType({ isMetaMask: true })).toBe( - WalletExtensionType.METAMASK - ); - }); - - it('returns UNKNOWN', () => { - expect(getWalletExtensionType({})).toBe(WalletExtensionType.UNKNOWN); - }); -}); diff --git a/src/background/providers/utils/getWalletExtensionType.ts b/src/background/providers/utils/getWalletExtensionType.ts deleted file mode 100644 index f81b26dd2..000000000 --- a/src/background/providers/utils/getWalletExtensionType.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { WalletExtensionType } from '../../services/web3/models'; - -// using any since we don't really know what properties other wallets define -export function getWalletExtensionType(provider: any): WalletExtensionType { - console.log('provider: ', provider); - if (provider.isAvalanche) { - return WalletExtensionType.CORE; - } - if (provider.isPhantom) { - return WalletExtensionType.PHANTOM; - } - if (provider.isKeplr) { - return WalletExtensionType.KEPLR; - } - if (provider.isZerion) { - return WalletExtensionType.ZERION; - } - if (provider.isRabby) { - return WalletExtensionType.RABBY; - } - if (provider.isCoinbaseWallet) { - return WalletExtensionType.COINBASE; - } - if (provider.isMetaMask) { - return WalletExtensionType.METAMASK; - } - return WalletExtensionType.UNKNOWN; -} From 431a5968da531a753328cd90c9cd048a5c9815b2 Mon Sep 17 00:00:00 2001 From: Viktor Vasas Date: Thu, 17 Oct 2024 19:49:44 +0200 Subject: [PATCH 4/8] feat: add logo animations --- .../components/WalletExtensionButton.tsx | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/pages/Wallet/components/WalletExtensionButton.tsx b/src/pages/Wallet/components/WalletExtensionButton.tsx index c9bb56c55..a6a2dca62 100644 --- a/src/pages/Wallet/components/WalletExtensionButton.tsx +++ b/src/pages/Wallet/components/WalletExtensionButton.tsx @@ -5,6 +5,7 @@ import { ChevronDownIcon, ClickAwayListener, Grow, + keyframes, MenuItem, MenuList, Popper, @@ -24,10 +25,38 @@ interface WalletExtensionButtonProps { wallets?: EIP6963ProviderInfo[]; } +const flip = keyframes` + from { + transform: rotateX(0deg); + } + + to { + transform: rotateX(360deg); + } +`; + const StyledMenuItem = styled(MenuItem)` + img { + transition: transform 0.3s ease-in-out; + } + color: ${({ theme }) => theme.palette.text.secondary}; + &:hover { + color: ${({ theme }) => theme.palette.text.primary}; + img { + animation: ${flip} 0.5s ease-in-out; + } + } +`; +const CoreButton = styled(Button)` + img { + transition: transform 0.3s ease-in-out; + } color: ${({ theme }) => theme.palette.text.secondary}; &:hover { color: ${({ theme }) => theme.palette.text.primary}; + img { + animation: ${flip} 0.5s ease-in-out; + } } `; @@ -39,11 +68,10 @@ export function CoreExtensionButton({ info, onClick, }: WalletExtensionButtonProps) { - console.log('info: ', info); const { t } = useTranslation(); return ( - + ); } From 4f3f1bf48b33e04369580f579811d7d0d118a507 Mon Sep 17 00:00:00 2001 From: Viktor Vasas Date: Thu, 17 Oct 2024 19:52:05 +0200 Subject: [PATCH 5/8] chore: translations --- src/background/providers/MultiWalletProviderProxy.ts | 4 ---- src/localization/locales/en/translation.json | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/background/providers/MultiWalletProviderProxy.ts b/src/background/providers/MultiWalletProviderProxy.ts index e3d506aca..ffc1a330f 100644 --- a/src/background/providers/MultiWalletProviderProxy.ts +++ b/src/background/providers/MultiWalletProviderProxy.ts @@ -92,7 +92,6 @@ export class MultiWalletProviderProxy extends EventEmitter { }), ], }); - console.log('selectedIndex: ', selectedIndex); if ( selectedIndex === undefined || @@ -140,15 +139,12 @@ export class MultiWalletProviderProxy extends EventEmitter { } const { method } = args; - console.log('method: ', method); - console.log('this.#_providers: ', this.#_providers); // trigger wallet selection flow at connect in case multiple providers are available if ( method === DAppProviderRequest.CONNECT_METHOD && this.#_providers.length > 1 ) { - console.log('waiting'); await this.#toggleWalletSelection(); } diff --git a/src/localization/locales/en/translation.json b/src/localization/locales/en/translation.json index d9b4e1e33..51028fdb0 100644 --- a/src/localization/locales/en/translation.json +++ b/src/localization/locales/en/translation.json @@ -563,6 +563,7 @@ "Operation": "Operation", "Or": "Or", "Or click Scan QR Code.": "Or click Scan QR Code.", + "Other Wallets": "Other Wallets", "Outgoing": "Outgoing", "Owner": "Owner", "Owners": "Owners", @@ -903,7 +904,6 @@ "Unknown network fee": "Unknown network fee", "Unknown sign type": "Unknown sign type", "Unknown transaction error": "Unknown transaction error", - "Unknown wallet": "Unknown wallet", "Unknown website": "Unknown website", "Unlimited": "Unlimited", "Unlock": "Unlock", From 18538ee4fcda9049dde22a82ea7bca50c8036626 Mon Sep 17 00:00:00 2001 From: Viktor Vasas Date: Fri, 18 Oct 2024 14:28:43 +0200 Subject: [PATCH 6/8] chore: remove unencessary code --- src/background/providers/initializeInpageProvider.ts | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/background/providers/initializeInpageProvider.ts b/src/background/providers/initializeInpageProvider.ts index e52b2a29c..d4b76f9d9 100644 --- a/src/background/providers/initializeInpageProvider.ts +++ b/src/background/providers/initializeInpageProvider.ts @@ -17,7 +17,6 @@ export function initializeProvider( maxListeners = 100, globalObject = window ): EVMProvider { - console.log('initializeProvider globalObject: ', globalObject); const chainAgnosticProvider = new Proxy( new ChainAgnosticProvider(connection), { @@ -81,18 +80,7 @@ function setGlobalProvider( globalObject = window, multiWalletProxy ): void { - // console.log('globalObject: ', globalObject); - // console.log('globalObject.ethereum: ', globalObject.ethereum); - // console.log('globalObject.phatnom: ', globalObject.phantom); try { - // const multiWalletProxy = createMultiWalletProxy(providerInstance); - - // if we already have a wallet lets add it - // if (globalObject.ethereum) { - // console.log('addProvider globalObject.ethereum: ', globalObject.ethereum); - // multiWalletProxy.addProvider(globalObject.ethereum); - // } - Object.defineProperty(globalObject, 'ethereum', { get: () => { return multiWalletProxy; From c1d1a23cce728c3c1b34fa96843c14e2d1fa9614 Mon Sep 17 00:00:00 2001 From: Viktor Vasas Date: Fri, 25 Oct 2024 16:05:43 +0200 Subject: [PATCH 7/8] fix: test cases --- .../initializeInpageProvider.test.ts | 65 ++++--------------- 1 file changed, 14 insertions(+), 51 deletions(-) diff --git a/src/background/providers/initializeInpageProvider.test.ts b/src/background/providers/initializeInpageProvider.test.ts index 8cf42435a..06cd47928 100644 --- a/src/background/providers/initializeInpageProvider.test.ts +++ b/src/background/providers/initializeInpageProvider.test.ts @@ -59,19 +59,6 @@ describe('src/background/providers/initializeInpageProvider', () => { expect(windowMock.ethereum).toBe(mockMultiWalletProxy); }); - it('adds other wallets to proxy when trying to set window.ethereum', () => { - initializeProvider(connectionMock, 10, windowMock); - - const provider2 = { isMetaMask: true }; - - windowMock.ethereum = provider2; - - expect(mockMultiWalletProxy.addProvider).toHaveBeenCalledTimes(1); - expect(mockMultiWalletProxy.addProvider).toHaveBeenCalledWith(provider2); - - expect(windowMock.ethereum).toBe(mockMultiWalletProxy); - }); - it('dispatches ethereum#initialized event', () => { initializeProvider(connectionMock, 10, windowMock); @@ -132,25 +119,6 @@ describe('src/background/providers/initializeInpageProvider', () => { }); }); - describe('EIP-5749', () => { - it('sets window.evmproviders if not defined and adds core', () => { - const provider = initializeProvider(connectionMock, 10, windowMock); - - expect(windowMock.evmproviders).toStrictEqual({ core: provider }); - }); - it('adds Core to window.evmproviders if already defined', () => { - windowMock.evmproviders = { - MetaMask: { isMetaMask: true }, - }; - const provider = initializeProvider(connectionMock, 10, windowMock); - - expect(windowMock.evmproviders).toStrictEqual({ - MetaMask: { isMetaMask: true }, - core: provider, - }); - }); - }); - describe('window.avalanche', () => { it('creates the window.avalanche object', () => { const provider = initializeProvider(connectionMock, 10, windowMock); @@ -183,31 +151,33 @@ describe('src/background/providers/initializeInpageProvider', () => { it('announces core provider with eip6963:announceProvider', () => { const provider = initializeProvider(connectionMock, 10, windowMock); - expect(windowMock.dispatchEvent).toHaveBeenCalledTimes(5); - expect(windowMock.dispatchEvent.mock.calls[3][0].type).toEqual( + expect(windowMock.dispatchEvent).toHaveBeenCalledTimes(4); + expect(windowMock.dispatchEvent.mock.calls[2][0].type).toEqual( 'eip6963:announceProvider' ); - expect(windowMock.dispatchEvent.mock.calls[3][0].detail).toEqual({ - info: provider.info, - provider: provider, - }); + expect(windowMock.dispatchEvent.mock.calls[2][0].detail).toStrictEqual( + expect.objectContaining({ + info: provider.info, + provider: provider, + }) + ); }); it('re-announces on eip6963:requestProvider', () => { initializeProvider(connectionMock, 10, windowMock); - expect(windowMock.dispatchEvent).toHaveBeenCalledTimes(5); + expect(windowMock.dispatchEvent).toHaveBeenCalledTimes(4); - expect(windowMock.addEventListener).toHaveBeenCalledTimes(2); + expect(windowMock.addEventListener).toHaveBeenCalledTimes(3); expect(windowMock.addEventListener).toHaveBeenCalledWith( 'eip6963:requestProvider', expect.anything() ); - windowMock.addEventListener.mock.calls[0][1](); + windowMock.addEventListener.mock.calls[1][1](); - expect(windowMock.dispatchEvent).toHaveBeenCalledTimes(6); + expect(windowMock.dispatchEvent).toHaveBeenCalledTimes(5); - expect(windowMock.dispatchEvent.mock.calls[3][0].type).toEqual( + expect(windowMock.dispatchEvent.mock.calls[2][0].type).toEqual( 'eip6963:announceProvider' ); }); @@ -216,14 +186,7 @@ describe('src/background/providers/initializeInpageProvider', () => { it('should announce chainagnostic provider with core-wallet:announceProvider', () => { initializeProvider(connectionMock, 10, windowMock); - expect(windowMock.dispatchEvent.mock.calls[4][0].type).toEqual( - 'core-wallet:announceProvider' - ); - }); - it('should re-announce on core-wallet:requestProvider', () => { - initializeProvider(connectionMock, 10, windowMock); - - expect(windowMock.dispatchEvent.mock.calls[4][0].type).toEqual( + expect(windowMock.dispatchEvent.mock.calls[3][0].type).toEqual( 'core-wallet:announceProvider' ); }); From da12ef0fabfeb7c16995e6937c046719c1d85c3b Mon Sep 17 00:00:00 2001 From: Viktor Vasas Date: Mon, 4 Nov 2024 09:43:38 +0100 Subject: [PATCH 8/8] chore: remove logs --- src/background/services/secrets/SecretsService.test.ts | 2 -- .../services/web3/handlers/avalanche_selectWallet.ts | 1 - src/pages/ApproveAction/SelectWallet.tsx | 4 ---- 3 files changed, 7 deletions(-) diff --git a/src/background/services/secrets/SecretsService.test.ts b/src/background/services/secrets/SecretsService.test.ts index 04d537fb9..8c2c09162 100644 --- a/src/background/services/secrets/SecretsService.test.ts +++ b/src/background/services/secrets/SecretsService.test.ts @@ -499,7 +499,6 @@ describe('src/background/services/secrets/SecretsService.ts', () => { const result = await secretsService.getAccountSecrets( activeAccountData ); - console.log('result: ', result); // eslint-disable-next-line @typescript-eslint/no-unused-vars const { ...rest } = secrets.wallets[0]; expect(result).toEqual({ @@ -1491,7 +1490,6 @@ describe('src/background/services/secrets/SecretsService.ts', () => { }, isMainnet ); - console.log('result: ', result); expect(result).toStrictEqual({ account: { diff --git a/src/background/services/web3/handlers/avalanche_selectWallet.ts b/src/background/services/web3/handlers/avalanche_selectWallet.ts index f8f422b78..249857bd2 100644 --- a/src/background/services/web3/handlers/avalanche_selectWallet.ts +++ b/src/background/services/web3/handlers/avalanche_selectWallet.ts @@ -13,7 +13,6 @@ export class AvalancheSelectWalletHandler extends DAppRequestHandler { handleUnauthenticated = async (rpcCall) => { const { request } = rpcCall; const [availableExtensions] = request.params; - console.log('availableExtensions: ', availableExtensions); if (!availableExtensions || availableExtensions.length === 0) { return { diff --git a/src/pages/ApproveAction/SelectWallet.tsx b/src/pages/ApproveAction/SelectWallet.tsx index eddbe2bd7..0efe0804c 100644 --- a/src/pages/ApproveAction/SelectWallet.tsx +++ b/src/pages/ApproveAction/SelectWallet.tsx @@ -14,7 +14,6 @@ import { Stack, Typography, WalletIcon } from '@avalabs/core-k2-components'; export function SelectWallet() { const requestId = useGetRequestId(); const { action: request, updateAction } = useApproveAction(requestId); - console.log('request: ', request); const selectWallet = useCallback( async (index: number | string) => @@ -51,8 +50,6 @@ export function SelectWallet() { {request.displayData.info.map((info, index) => { - console.log('index: ', index); - console.log('info: ', info); if (info.rdns === 'app.core.extension') { return ( 1 && ( { - console.log('selectWallet' + index); selectWallet(index); }} wallets={request.displayData.info}