Skip to content

Commit 389eaff

Browse files
authored
fix: APP-833 fix wallet connect (#2779)
1 parent ea98b35 commit 389eaff

File tree

22 files changed

+869
-667
lines changed

22 files changed

+869
-667
lines changed

bun.lock

Lines changed: 574 additions & 322 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web-marketplace/package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
"@cosmjs/launchpad": "^0.27.0",
1212
"@cosmjs/proto-signing": "^0.36.1",
1313
"@cosmjs/stargate": "^0.36.1",
14-
"@cosmos-kit/keplr-mobile": "^2.6.7",
15-
"@cosmos-kit/react-lite": "^2.6.7",
1614
"@emotion/cache": "^11.14.0",
1715
"@emotion/react": "^11.10.4",
1816
"@emotion/styled": "^11.10.4",
1917
"@google-cloud/translate": "^8.5.0",
2018
"@hookform/resolvers": "^5.0.1",
19+
"@interchain-kit/core": "^0.7.0",
20+
"@interchain-kit/react": "^0.7.0",
2121
"@keplr-wallet/provider": "^0.11.10",
2222
"@keplr-wallet/stores": "^0.11.10",
2323
"@lingui/core": "^5.1.2",
@@ -53,7 +53,7 @@
5353
"analytics-plugin-do-not-track": "^0.1.5",
5454
"auth0-js": "^9.18.0",
5555
"axios": "^0.21.1",
56-
"chain-registry": "^1.18.0",
56+
"chain-registry": "^2.0.125",
5757
"clientjs": "^0.1.11",
5858
"dayjs": "^1.10.7",
5959
"formik": "^2.4.6",
@@ -177,8 +177,5 @@
177177
"vite-plugin-svgr": "^3.2.0",
178178
"vite-tsconfig-paths": "^4.2.0",
179179
"vitest": "^2.0.5"
180-
},
181-
"overrides": {
182-
"@walletconnect/sign-client": "2.10.4"
183180
}
184181
}

web-marketplace/src/app/ChainWrapper.tsx

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
11
'use client';
2-
import { wallets } from '@cosmos-kit/keplr-mobile';
3-
import { ChainProvider } from '@cosmos-kit/react-lite';
4-
import { assets, chains } from 'chain-registry';
2+
import { WCCosmosWallet, WCWallet } from '@interchain-kit/core';
3+
import { ChainProvider } from '@interchain-kit/react';
4+
import { assetLists, chains } from 'chain-registry';
55

66
import {
7-
WALLET_CONNECT_RELAY_URL,
87
walletConnectClientMeta,
8+
walletConnectOption,
99
} from 'lib/wallet/wallet.constants';
1010

1111
import { LoginModalMobile } from 'components/organisms/LoginModal/components/LoginModal.Mobile';
1212

13+
const desktopWalletConnect = new WCWallet(walletConnectOption, {
14+
metadata: walletConnectClientMeta,
15+
});
16+
desktopWalletConnect.setNetworkWallet('cosmos', new WCCosmosWallet());
17+
1318
export function ChainWrapper({ children }: React.PropsWithChildren) {
1419
return (
1520
<ChainProvider
16-
chains={chains.filter(chain => chain.chain_name === 'regen')}
17-
assetLists={assets.filter(chain => chain.chain_name === 'regen')}
18-
wallets={wallets}
19-
walletModal={LoginModalMobile}
20-
walletConnectOptions={{
21-
signClient: {
22-
projectId: process.env.NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID || '',
23-
relayUrl: WALLET_CONNECT_RELAY_URL,
24-
metadata: walletConnectClientMeta,
25-
},
26-
}}
21+
chains={chains.filter(chain => chain.chainName === 'regen')}
22+
assetLists={assetLists.filter(chain => chain.chainName === 'regen')}
23+
wallets={[desktopWalletConnect]}
24+
walletModal={props => <LoginModalMobile {...props} />}
2725
>
2826
{children}
2927
</ChainProvider>

web-marketplace/src/components/organisms/LoginButton/LoginButton.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { msg } from '@lingui/core/macro';
22

33
import { TranslatorType } from 'lib/i18n/i18n.types';
4+
import { WALLET_CONNECT } from 'lib/wallet/wallet.constants';
45
import { ConnectParams } from 'lib/wallet/wallet.types';
56
import { WalletType } from 'lib/wallet/walletsConfig/walletsConfig.types';
67

@@ -25,8 +26,7 @@ export const getAllWalletsUiConfig = ({
2526
onClick: () => connectToWallet({ walletType: WalletType.Keplr }),
2627
},
2728
{
28-
// eslint-disable-next-line lingui/no-unlocalized-strings
29-
name: 'WalletConnect',
29+
name: WALLET_CONNECT,
3030
description: _(msg`Keplr Mobile`),
3131
image: walletConnectKeplr,
3232
onClick: () =>

web-marketplace/src/components/organisms/LoginButton/LoginButton.constants.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { msg } from '@lingui/core/macro';
22

3-
// eslint-disable-next-line lingui/no-unlocalized-strings
4-
export const mobileWalletsName = ['WalletConnect'];
3+
import { WALLET_CONNECT } from 'lib/wallet/wallet.constants';
4+
5+
export const mobileWalletsName = [WALLET_CONNECT];
56

67
export const RESEND_TEXT = msg`Don’t see anything?`;
78
export const RESEND_SUCCES = msg`New confirmation code sent`;

web-marketplace/src/components/organisms/LoginButton/LoginButton.legacy.tsx

Lines changed: 0 additions & 97 deletions
This file was deleted.

web-marketplace/src/components/organisms/LoginButton/hooks/useConnectToWallet.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
import { useCallback } from 'react';
2-
import { WalletRepo } from '@cosmos-kit/core';
3-
import { useChain } from '@cosmos-kit/react-lite';
2+
import { useChain, useChainWallet } from '@interchain-kit/react';
43

54
import { UseStateSetter } from 'types/react/use-state';
65
import { WalletContextType } from 'lib/wallet/wallet';
7-
import { KEPLR_MOBILE } from 'lib/wallet/wallet.constants';
6+
import { WALLET_CONNECT } from 'lib/wallet/wallet.constants';
87
import { ConnectParams } from 'lib/wallet/wallet.types';
98
import { WalletType } from 'lib/wallet/walletsConfig/walletsConfig.types';
109

1110
import { LoginModalState } from 'components/organisms/LoginModal/LoginModal.types';
1211

1312
type Props = {
1413
connect?: WalletContextType['connect'];
15-
connectWalletConnect?: WalletRepo['connect'];
1614
setModalState: UseStateSetter<LoginModalState>;
1715
onModalClose: () => void;
1816
isConnectingRef?: React.MutableRefObject<boolean>;
@@ -22,11 +20,14 @@ type Response = ({ walletType }: ConnectParams) => Promise<void>;
2220

2321
export const useConnectToWallet = ({
2422
connect,
25-
connectWalletConnect,
2623
onModalClose,
2724
isConnectingRef,
2825
}: Props): Response => {
2926
const { openView } = useChain('regen');
27+
const { connect: connectWalletConnect } = useChainWallet(
28+
'regen',
29+
WALLET_CONNECT,
30+
);
3031

3132
const connectToWallet = useCallback(
3233
async ({ walletType }: ConnectParams): Promise<void> => {
@@ -35,13 +36,10 @@ export const useConnectToWallet = ({
3536
if (isConnectingRef) isConnectingRef.current = true;
3637
onModalClose();
3738
}
38-
if (
39-
connectWalletConnect &&
40-
walletType === WalletType.WalletConnectKeplr
41-
) {
39+
if (walletType === WalletType.WalletConnectKeplr) {
4240
onModalClose();
4341
openView();
44-
await connectWalletConnect(KEPLR_MOBILE, true);
42+
await connectWalletConnect();
4543
}
4644
},
4745
[connect, connectWalletConnect, isConnectingRef, onModalClose, openView],

web-marketplace/src/components/organisms/LoginButton/hooks/useLoginData.legacy.tsx

Lines changed: 0 additions & 76 deletions
This file was deleted.

web-marketplace/src/components/organisms/LoginButton/hooks/useLoginData.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useCallback, useEffect, useMemo, useState } from 'react';
2-
import { useManager } from '@cosmos-kit/react-lite';
32
import { useLingui } from '@lingui/react';
43
import { DRAFT_ID } from 'legacy-pages/Dashboard/MyProjects/MyProjects.constants';
54
import { useRouter } from 'next/navigation';
@@ -22,7 +21,7 @@ export const useLoginData = ({
2221
}) => {
2322
const { _ } = useLingui();
2423
const { wallet, connect } = useWallet();
25-
const { walletRepos } = useManager();
24+
// const { walletRepos } = useManager();
2625

2726
const [isModalOpen, setIsModalOpen] = useState(false);
2827
const [modalState, setModalState] = useState<LoginModalState>('select');
@@ -45,7 +44,6 @@ export const useLoginData = ({
4544
onModalClose,
4645
setModalState,
4746
connect,
48-
connectWalletConnect: walletRepos[0]?.connect, // only one walletRepos for regen
4947
});
5048

5149
const walletsUiConfig = useMemo(

0 commit comments

Comments
 (0)