Skip to content

Commit e767358

Browse files
authored
chore: switch to leap metamask snap (#562)
1 parent 2401575 commit e767358

File tree

11 files changed

+166
-341
lines changed

11 files changed

+166
-341
lines changed

bun.lock

Lines changed: 143 additions & 299 deletions
Large diffs are not rendered by default.

components/react/__tests__/modal.test.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
import { State } from '@cosmos-kit/core';
21
import { Web3AuthClient } from '@cosmos-kit/web3auth';
3-
import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
2+
import { cleanup, fireEvent, render, screen } from '@testing-library/react';
43
import { afterEach, beforeEach, describe, expect, jest, mock, spyOn, test } from 'bun:test';
54
import type { ChainWalletBase } from 'cosmos-kit';
65
import { WalletStatus } from 'cosmos-kit';
76
import React from 'react';
87

98
import { TailwindModal } from '@/components/react/modal';
109
import { clearAllMocks, mockModule, mockRouter } from '@/tests';
11-
import { renderWithChainProvider } from '@/tests/render';
1210

1311
describe('TailwindModal', () => {
1412
let mockWalletRepo: any;
@@ -115,7 +113,7 @@ describe('TailwindModal', () => {
115113
),
116114
React.createElement(
117115
'button',
118-
{ onClick: () => onWalletClicked('cosmos-extension-metamask') },
116+
{ onClick: () => onWalletClicked('leap-cosmos-metamask-snap') },
119117
'Metamask'
120118
),
121119
React.createElement('button', { onClick: () => onWalletClicked('Email') }, 'Email'),

components/react/modal.tsx

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -161,19 +161,10 @@ export const TailwindModal: React.FC<
161161
}, []);
162162

163163
/**
164-
* Helper to handle a metamask extension that doesn't fully register as 'NotExist'
164+
* Helper to handle extension that doesn't fully register as 'NotExist'
165165
* in the standard wallet flow. We force set the view to NotExist if we detect the error message.
166166
*/
167-
const handleMetamaskErrorCheck = (wallet: ChainWalletBase) => {
168-
if (
169-
wallet?.walletInfo.name === 'cosmos-extension-metamask' &&
170-
wallet.message?.includes("Cannot read properties of undefined (reading 'request')")
171-
) {
172-
setCurrentView(ModalView.NotExist);
173-
setSelectedWallet(wallet);
174-
return true;
175-
}
176-
167+
const handleWalletNotExists = (wallet: ChainWalletBase) => {
177168
if (wallet?.isWalletNotExist) {
178169
setCurrentView(ModalView.NotExist);
179170
setSelectedWallet(wallet);
@@ -295,7 +286,7 @@ export const TailwindModal: React.FC<
295286
// or if the wallet doesn't exist. This ensures the error message has time
296287
// to populate in the wallet's state after calling `getWallet()`.
297288
setTimeout(() => {
298-
if (handleMetamaskErrorCheck(wallet)) {
289+
if (handleWalletNotExists(wallet)) {
299290
return;
300291
}
301292

components/react/views/Connected.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ export const Connected = ({
5757
<Image
5858
height={0}
5959
width={0}
60-
src={
61-
name === 'Cosmos MetaMask Extension' ? '/metamask.svg' : getRealLogo(logo, isDarkMode)
62-
}
60+
src={name === 'Leap Cosmos MetaMask' ? '/metamask.svg' : getRealLogo(logo, isDarkMode)}
6361
alt={name}
6462
className="w-8 h-8 rounded-full mr-2"
6563
/>

components/react/views/Connecting.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ export const Connecting = ({
4545
</div>
4646
<div className="flex flex-col w-full h-full mt-4 sm:px-8 sm:py-6">
4747
<img
48-
src={
49-
name === 'Cosmos MetaMask Extension' ? '/metamask.svg' : getRealLogo(logo, isDarkMode)
50-
}
48+
src={name === 'Leap Cosmos MetaMask' ? '/metamask.svg' : getRealLogo(logo, isDarkMode)}
5149
alt={name}
5250
className="shrink-0 w-20 h-20 mx-auto aspect-1"
5351
/>

components/react/views/Error.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const Error = ({
4949
<div className="p-3 border rounded-full border-red-600 mx-auto aspect-1 shrink-0">
5050
<Image
5151
src={
52-
currentWalletName === 'Cosmos MetaMask Extension'
52+
currentWalletName === 'Leap Cosmos MetaMask'
5353
? '/metamask.svg'
5454
: getRealLogo(logo, isDarkMode)
5555
}

components/react/views/NotExist.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const NotExist = ({
3131
<ChevronLeftIcon className="w-5 h-5" aria-hidden="true" />
3232
</button>
3333
<Dialog.Title as="h3" className="text-lg font-semibold">
34-
{name === 'Cosmos MetaMask Extension' ? 'Metamask' : name}
34+
{name === 'Leap Cosmos MetaMask' ? 'Metamask' : name}
3535
</Dialog.Title>
3636
<button
3737
type="button"
@@ -43,25 +43,23 @@ export const NotExist = ({
4343
</div>
4444
<div className="flex flex-col w-full h-full py-6 mt-4 sm:px-8">
4545
<img
46-
src={
47-
name === 'Cosmos MetaMask Extension' ? '/metamask.svg' : getRealLogo(logo, isDarkMode)
48-
}
46+
src={name === 'Leap Cosmos MetaMask' ? '/metamask.svg' : getRealLogo(logo, isDarkMode)}
4947
alt={name}
5048
className="shrink-0 w-16 h-16 mx-auto aspect-1"
5149
/>
5250
<p className="mt-3 font-medium text-black dark:text-white">
53-
Install {name === 'Cosmos MetaMask Extension' ? 'Metamask' : name}
51+
Install {name === 'Leap Cosmos MetaMask' ? 'Metamask' : name}
5452
</p>
5553
<p className="mt-1 text-sm text-gray-500 dark:text-white/75">
56-
To connect your {name === 'Cosmos MetaMask Extension' ? 'Metamask' : name} wallet, install
57-
the browser extension.
54+
To connect your {name === 'Leap Cosmos MetaMask' ? 'Metamask' : name} wallet, install the
55+
browser extension.
5856
</p>
5957
<button
6058
className={`rounded-lg btn-primary btn btn-md ${name.length >= 12 ? 'w-1/2' : 'w-1/3'} mx-auto inline-flex justify-center items-center py-2.5 font-medium mt-4 text-white`}
6159
onClick={onInstall}
6260
>
6361
<ArrowDownTrayIcon className="shrink-0 w-5 h-5 mr-2 text-white" />
64-
Install {name === 'Cosmos MetaMask Extension' ? 'Metamask' : name}
62+
Install {name === 'Leap Cosmos MetaMask' ? 'Metamask' : name}
6563
</button>
6664
</div>
6765
</div>

components/react/views/WalletList.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const WalletList = ({
3333
const isDarkMode = document.documentElement.classList.contains('dark');
3434

3535
const socialOrder = ['Google', 'Twitter', 'Apple', 'Discord', 'GitHub', 'Reddit', 'Email', 'SMS'];
36-
const browserOrder = ['Leap', 'Keplr', 'Cosmostation', 'Cosmos MetaMask Extension', 'Ledger'];
36+
const browserOrder = ['Leap', 'Keplr', 'Cosmostation', 'Leap Cosmos MetaMask', 'Ledger'];
3737
let mobileOrder = ['Wallet Connect', 'Keplr Mobile'];
3838
let leapLogo;
3939
if (isLeapDappBrowser) {
@@ -94,15 +94,15 @@ export const WalletList = ({
9494
>
9595
<img
9696
src={
97-
prettyName === 'Cosmos MetaMask Extension'
97+
prettyName === 'Leap Cosmos MetaMask'
9898
? '/metamask.svg'
9999
: getRealLogo(logo?.toString() ?? '', isDarkMode)
100100
}
101101
alt={prettyName}
102102
className="w-10 h-10 rounded-xl mr-3"
103103
/>
104104
<span className="text-md flex-1 text-left">
105-
{prettyName === 'Cosmos MetaMask Extension' ? 'MetaMask' : prettyName}
105+
{prettyName === 'Leap Cosmos MetaMask' ? 'MetaMask' : prettyName}
106106
</span>
107107
{hasMobileVersion(prettyName) &&
108108
prettyName !== 'Cosmostation' &&

contexts/__tests__/web3AuthContext.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe('Web3AuthContext', () => {
3939
},
4040
}));
4141

42-
mockModule('@cosmos-kit/cosmos-extension-metamask', () => ({
42+
mockModule('@cosmos-kit/leap-metamask-cosmos-snap', () => ({
4343
wallets: [],
4444
}));
4545

contexts/web3AuthContext.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { MainWalletBase } from '@cosmos-kit/core';
2-
import { wallets as cosmosExtensionWallets } from '@cosmos-kit/cosmos-extension-metamask';
32
import {
43
SignData,
54
Web3AuthClient,
@@ -173,7 +172,6 @@ export const Web3AuthProvider = ({ children }: { children: ReactNode }) => {
173172
const wallets = [
174173
...web3AuthWallets,
175174
...cosmosWallets.for('keplr', 'cosmostation', 'leap', 'ledger'),
176-
...cosmosExtensionWallets,
177175
];
178176

179177
return (

0 commit comments

Comments
 (0)