@tomo-inc/wallet-adaptor-base 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/package.json +2 -1
  2. package/project.json +0 -8
  3. package/src/index.ts +3 -0
  4. package/src/type.ts +5 -0
  5. package/src/utils/browsers.ts +13 -0
  6. package/src/utils/chainId.ts +1 -1
  7. package/src/wallet-api/chain.ts +9 -2
  8. package/src/wallet-api/connect.ts +85 -24
  9. package/src/wallet-api/sign-in.ts +4 -1
  10. package/src/wallet-api/sign-message.ts +38 -5
  11. package/src/wallets/Wallet.ts +4 -0
  12. package/src/wallets/default/binanceWallet/binanceWallet.ts +27 -0
  13. package/src/wallets/default/bitgetWallet/bitgetWallet.ts +10 -0
  14. package/src/wallets/default/bitverseWallet/bitverseWallet.ts +3 -0
  15. package/src/wallets/default/bybitWallet/bybitWallet.ts +5 -0
  16. package/src/wallets/default/coinbaseWallet/coinbaseWallet.ts +7 -0
  17. package/src/wallets/default/foxWallet/foxWallet.ts +5 -0
  18. package/src/wallets/default/gateWallet/gateWallet.ts +6 -0
  19. package/src/wallets/default/imTokenWallet/imTokenWallet.ts +9 -0
  20. package/src/wallets/default/iopayWallet/iopayWallet.ts +6 -0
  21. package/src/wallets/default/kaiaWallet/kaiaWallet.ts +5 -0
  22. package/src/wallets/default/kaikasWallet/kaikasWallet.ts +5 -0
  23. package/src/wallets/default/krakenWallet/krakenWallet.ts +5 -0
  24. package/src/wallets/default/kresusWallet/kresusWallet.ts +3 -0
  25. package/src/wallets/default/ledgerWallet/ledgerWallet.ts +6 -0
  26. package/src/wallets/default/metaMaskWallet/metaMaskWallet.ts +17 -0
  27. package/src/wallets/default/oktoWallet/oktoWallet.ts +6 -0
  28. package/src/wallets/default/okxWallet/okxWallet.ts +11 -0
  29. package/src/wallets/default/omniWallet/omniWallet.ts +6 -0
  30. package/src/wallets/default/oneInchWallet/oneInchWallet.ts +3 -0
  31. package/src/wallets/default/paraSwapWallet/paraswapWallet.ts +5 -0
  32. package/src/wallets/default/phantomWallet/phantomWallet.ts +7 -0
  33. package/src/wallets/default/rainbowWallet/rainbowWallet.ts +10 -0
  34. package/src/wallets/default/solflareWallet/solflareWallet.ts +7 -0
  35. package/src/wallets/default/tokenPocketWallet/tokenPocketWallet.ts +6 -0
  36. package/src/wallets/default/trustWallet/trustWallet.ts +6 -0
  37. package/src/wallets/default/uniswapWallet/uniswapWallet.ts +5 -0
  38. package/src/wallets/default/valoraWallet/valoraWallet.ts +4 -0
  39. package/src/wallets/default/zealWallet/zealWallet.ts +5 -0
  40. package/src/wallets/default/zerionWallet/zerionWallet.ts +6 -0
  41. package/src/wallets/detector.ts +32 -16
  42. package/src/wallets/providers/WalletConnectProvider.ts +23 -12
  43. package/src/wallets/providers/WalletConnectSolanaProvider.ts +32 -23
  44. package/src/wallets/wallet-walletconnect.ts +18 -9
  45. package/tsup.config.ts +3 -2
  46. package/dist/index.cjs +0 -2896
  47. package/dist/index.d.cts +0 -330
  48. package/dist/index.d.ts +0 -330
  49. package/dist/index.js +0 -2813
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomo-inc/wallet-adaptor-base",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "author": "tomo.inc",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -17,6 +17,7 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@aptos-labs/ts-sdk": "^5.1.1",
20
+ "@binance/w3w-utils": "^1.1.6",
20
21
  "@solana/spl-token": "^0.4.13",
21
22
  "@solana/web3.js": "^1.98.0",
22
23
  "@wallet-standard/core": "^1.1.0",
package/project.json CHANGED
@@ -18,14 +18,6 @@
18
18
  "cwd": "packages/wallet-adaptor-base"
19
19
  }
20
20
  },
21
- "prepare": {
22
- "executor": "nx:run-commands",
23
- "dependsOn": ["build"],
24
- "options": {
25
- "command": "pnpm build",
26
- "cwd": "packages/wallet-adaptor-base"
27
- }
28
- },
29
21
  "lint": {
30
22
  "executor": "nx:run-commands",
31
23
  "options": {
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { AdaptorChainType, Connector, WalletConnectorType } from "./type";
2
+ import { isMobile } from "./utils/isMobile";
2
3
  import { uniqueConnectors } from "./utils/utils";
3
4
  import { defaultConnectors } from "./wallets/defaultConnectors";
4
5
  import { connectorDector, supportedWalletConfigTypes, walletConfigAdapter } from "./wallets/detector";
@@ -94,3 +95,5 @@ export * from "./wallet-api";
94
95
 
95
96
  // Export all wallets
96
97
  export * from "./wallets";
98
+
99
+ export { isMobile };
package/src/type.ts CHANGED
@@ -29,6 +29,10 @@ export interface WalletInfo {
29
29
  rdns?: string;
30
30
  isWalletConnect?: boolean;
31
31
  deeplink?: string;
32
+ mobile?: {
33
+ getUri?: (uri: string) => string;
34
+ getDeeplink?: (dappUrl?: string, chainId?: number) => string | Promise<string>;
35
+ };
32
36
  links: {
33
37
  homepage?: string;
34
38
  ios_install?: string;
@@ -67,6 +71,7 @@ export interface Connector {
67
71
 
68
72
  export interface ConnectParams {
69
73
  dappLink: string;
74
+ useWalletConnect?: boolean;
70
75
  }
71
76
 
72
77
  export interface SignInParams {
@@ -37,3 +37,16 @@ export function getBrowser(): BrowserType {
37
37
  if (isSafari()) return BrowserType.Safari;
38
38
  return BrowserType.Browser;
39
39
  }
40
+
41
+ // open uri in new tab or window
42
+ export function openUri(uri: string) {
43
+ if (uri.startsWith("http")) {
44
+ const link = document.createElement("a");
45
+ link.href = uri;
46
+ link.target = "_blank";
47
+ link.rel = "noreferrer noopener";
48
+ link.click();
49
+ } else {
50
+ window.location.href = uri;
51
+ }
52
+ }
@@ -1,4 +1,4 @@
1
- import { isHex, toHex, fromHex, isAddressEqual } from "viem";
1
+ import { fromHex, isAddressEqual, isHex, toHex } from "viem";
2
2
 
3
3
  export const isHexChainId = (chainIdHex: string) => {
4
4
  return isHex(chainIdHex);
@@ -1,4 +1,5 @@
1
1
  import { ChainInfo, WalletOptions } from "type";
2
+ import { toHex } from "viem";
2
3
  import { getAllTypeChainIds } from "../utils/chainId";
3
4
 
4
5
  export const switchChain = async (chainId: string | number, walletOptions: WalletOptions) => {
@@ -41,8 +42,14 @@ export const addChain = async (chainInfo: ChainInfo, walletOptions: WalletOption
41
42
  }
42
43
 
43
44
  if (chainType === "evm") {
44
- if (!chainInfo?.chainId || !chainInfo?.chainId.startsWith("0x")) {
45
- throw new Error("Chain ID must starting with 0x");
45
+ if (!chainInfo?.chainId) {
46
+ throw new Error("Chain ID is required");
47
+ }
48
+
49
+ if (!chainInfo?.chainId.startsWith("0x")) {
50
+ const chainId = Number(chainInfo.chainId);
51
+ const chainIdHex = toHex(chainId);
52
+ chainInfo.chainId = chainIdHex;
46
53
  }
47
54
  try {
48
55
  await provider.request({
@@ -1,32 +1,28 @@
1
- import { ConnectParams, WalletOptions } from "type";
2
- import { isMobile } from "../utils/isMobile";
1
+ import { ConnectParams, WalletInfo, WalletOptions } from "type";
2
+ import { openUri } from "utils/browsers";
3
+ import { isAndroid, isIOS, isMobile } from "../utils/isMobile";
4
+ import { createWalletConnectEVMProvider } from "../wallets/wallet-walletconnect";
3
5
 
4
6
  export const connect = async (
5
7
  connectParams: ConnectParams,
6
8
  walletOptions: Omit<WalletOptions, "account">,
7
- ): Promise<{ address: string; chainId?: string; network?: string }> => {
8
- //deeplink in mobile
9
- //https://link.metamask.io/dapp/app.uniswap.org
10
- if (isMobile()) {
11
- const deeplink = walletOptions?.walletInfo?.deeplink || "";
12
- if (!deeplink) {
13
- throw new Error("Deeplink not supported");
14
- }
15
- const dappLink = connectParams?.dappLink || "";
16
- if (!dappLink) {
17
- throw new Error("Dapp link is required");
18
- }
19
- const { hostname, pathname } = new URL(dappLink);
20
- const link = `${deeplink}${hostname}${pathname}`;
21
- (window as any).location.href = link;
22
- }
23
-
9
+ ): Promise<{ address: string; chainId?: string; network?: string; provider?: any }> => {
24
10
  //inject provider/walletconnect provider
25
- const { provider, chainType } = walletOptions;
11
+ const { provider, chainType, walletInfo } = walletOptions;
12
+
13
+ if (isMobile() && walletInfo?.uuid !== "walletConnect" && !provider) {
14
+ const res = (await connectMobile({
15
+ connectParams,
16
+ walletOptions,
17
+ })) as { address: string; chainId?: string; network?: string; provider?: any };
18
+ const { address, chainId, network, provider: mobileProvider } = res || {};
19
+ return { address, chainId, network, provider: mobileProvider };
20
+ }
26
21
 
27
22
  if (!provider) {
28
23
  throw new Error("Provider is required");
29
24
  }
25
+
30
26
  if (!chainType) {
31
27
  throw new Error("Chain type is required");
32
28
  }
@@ -46,14 +42,12 @@ export const connect = async (
46
42
  if (provider?.connect) {
47
43
  res = await provider.connect();
48
44
  address = res?.publicKey?.toString() || "";
49
- }
50
- if (provider?.request) {
45
+ } else if (provider?.request) {
51
46
  res = await provider.request({
52
47
  method: "connect",
53
48
  });
54
49
  address = res?.publicKey?.toString() || "";
55
- }
56
- if (provider?.["standard:connect"]) {
50
+ } else if (provider?.["standard:connect"]) {
57
51
  res = await provider["standard:connect"]?.connect();
58
52
  address = res?.accounts?.[0]?.address || "";
59
53
  }
@@ -130,3 +124,70 @@ export const disconnect = async (walletOptions: WalletOptions): Promise<boolean>
130
124
  }
131
125
  return false;
132
126
  };
127
+
128
+ export const connectMobile = async ({
129
+ connectParams,
130
+ walletOptions,
131
+ }: {
132
+ connectParams: ConnectParams;
133
+ walletOptions: Omit<WalletOptions, "account">;
134
+ }) => {
135
+ const { useWalletConnect, dappLink } = connectParams;
136
+ const { mobile, links } = walletOptions.walletInfo as WalletInfo;
137
+ const connectWithWalletConnect = () => {
138
+ return new Promise((resolve, reject) => {
139
+ // const { chainType } = walletOptions;
140
+ const { mobile, uuid } = (walletOptions.walletInfo as WalletInfo) || {};
141
+
142
+ // Wrap async operations in an IIFE
143
+ (async () => {
144
+ try {
145
+ // TODO: support other chain types
146
+ const wcInstance = createWalletConnectEVMProvider();
147
+ // for getting the provider instance
148
+ const mobileProvider = await wcInstance.getProvider();
149
+ const wcUri = wcInstance.connectUri;
150
+ const mobileUri = await mobile?.getUri?.(wcUri);
151
+
152
+ if (!mobileUri) {
153
+ resolve({ address: "", chainId: "" });
154
+ return;
155
+ }
156
+
157
+ if (uuid !== "walletConnect") openUri(mobileUri);
158
+ const res = await wcInstance.connect().catch((error: any) => {
159
+ reject(error);
160
+ });
161
+ const address = res?.[0] || "";
162
+ const chainId = await mobileProvider.request({ method: "eth_chainId" });
163
+ resolve({ address, chainId, provider: mobileProvider });
164
+ } catch (error) {
165
+ reject(error);
166
+ }
167
+ })();
168
+ });
169
+ };
170
+ if (useWalletConnect) {
171
+ return connectWithWalletConnect();
172
+ } else if (mobile?.getDeeplink) {
173
+ const deeplink = await mobile?.getDeeplink?.(dappLink);
174
+ if (deeplink) {
175
+ openUri(deeplink);
176
+ }
177
+ } else if (mobile?.getUri) {
178
+ return connectWithWalletConnect();
179
+ } else if (links.android_install || links.ios_install || links.homepage) {
180
+ if (isAndroid()) {
181
+ openUri(links.android_install || links.homepage || "");
182
+ } else if (isIOS()) {
183
+ openUri(links.ios_install || links.homepage || "");
184
+ } else {
185
+ openUri(links.homepage || "");
186
+ }
187
+ throw new Error(`${walletOptions.walletInfo?.name} not supported`);
188
+ } else {
189
+ throw new Error(`${walletOptions.walletInfo?.name} not supported`);
190
+ }
191
+ // in mobile, don't return anything, just wait for the mobile wallet to be opened
192
+ return new Promise(() => {});
193
+ };
@@ -13,7 +13,10 @@ const params = {
13
13
  };
14
14
  */
15
15
 
16
- export const signInWithWallet = async (signInData: SignInParams, walletOptions: WalletOptions): Promise<string> => {
16
+ export const signInWithWallet = async (
17
+ signInData: SignInParams,
18
+ walletOptions: WalletOptions & { isInstalled?: boolean },
19
+ ): Promise<string> => {
17
20
  const { chainType, account, provider } = walletOptions;
18
21
 
19
22
  if (!provider) {
@@ -1,4 +1,6 @@
1
- import { WalletOptions } from "type";
1
+ import { WalletInfo, WalletOptions } from "type";
2
+ import { openUri } from "utils/browsers";
3
+ import { isMobile } from "utils/isMobile";
2
4
  import { uint8arrayToHex } from "utils/utils";
3
5
 
4
6
  /*
@@ -15,10 +17,12 @@ const params = {
15
17
 
16
18
  export const signMessage = async (
17
19
  data: { message: string; nonce: string },
18
- walletOptions: WalletOptions,
20
+ walletOptions: WalletOptions & { isInstalled?: boolean },
19
21
  ): Promise<string> => {
20
- const { chainType, account, provider } = walletOptions;
22
+ const { chainType, account, provider, walletInfo, isInstalled } = walletOptions;
21
23
  const { message, nonce } = data;
24
+ const isMobileDevice = isMobile();
25
+ const isWalletConnect = walletInfo?.uuid === "walletConnect";
22
26
 
23
27
  if (!provider) {
24
28
  throw new Error("Provider is required");
@@ -28,10 +32,22 @@ export const signMessage = async (
28
32
 
29
33
  if (chainType === "evm") {
30
34
  try {
31
- const signature: string = await provider.request({
35
+ // start provider.request, this is an asynchronous operation, will wait for user confirmation
36
+ const signaturePromise = provider.request({
32
37
  method: "personal_sign",
33
38
  params: [message, address],
34
- });
39
+ }) as Promise<string>;
40
+
41
+ // if the mobile wallet application needs to be opened, open it after the signature request is started (not blocking)
42
+ // delay opening can ensure that provider.request has been started, avoid immediate jump causing subsequent code to fail to execute
43
+ if (isMobileDevice && !isWalletConnect && !isInstalled) {
44
+ handleOpenMobileWalletDelayed(walletOptions, 100).catch((error) => {
45
+ console.error("Failed to schedule mobile wallet open:", error);
46
+ });
47
+ }
48
+
49
+ // wait for the signature result
50
+ const signature: string = await signaturePromise;
35
51
  console.log("signMessage res:", chainType, provider, message, signature);
36
52
  return signature;
37
53
  } catch (error) {
@@ -128,3 +144,20 @@ function getAPTOSSignatureFromResponse(res: any): string {
128
144
  }
129
145
  return signature;
130
146
  }
147
+
148
+ // delay open mobile wallet application, avoid immediate jump causing subsequent code to fail to execute
149
+ async function handleOpenMobileWalletDelayed(walletOptions: WalletOptions, delay: number = 100): Promise<void> {
150
+ // get deeplink, determine if a longer delay is needed
151
+ const { mobile } = (walletOptions.walletInfo as WalletInfo) || {};
152
+ const dappUrl = typeof window !== "undefined" ? window.location.href : "";
153
+ const chainId = walletOptions.account?.chainId ? parseInt(walletOptions.account.chainId, 16) : undefined;
154
+ const deeplink = await mobile?.getDeeplink?.(dappUrl, chainId);
155
+ if (!deeplink) return;
156
+
157
+ // if the deeplink does not start with http, a longer delay is needed to ensure provider.request has been started
158
+ const actualDelay = deeplink && !deeplink.startsWith("http") ? Math.max(delay, 300) : delay;
159
+
160
+ setTimeout(() => {
161
+ openUri(deeplink);
162
+ }, actualDelay);
163
+ }
@@ -33,6 +33,10 @@ export type WalletConfig = {
33
33
  linux?: string;
34
34
  desktop?: string;
35
35
  };
36
+ mobile?: {
37
+ getUri?: (uri: string) => string;
38
+ getDeeplink?: (dappUrl?: string, chainId?: number) => string | Promise<string>;
39
+ };
36
40
  };
37
41
 
38
42
  export type WagmiWalletConfig = any;
@@ -1,3 +1,4 @@
1
+ import { isAndroid } from "../../../utils/isMobile";
1
2
  import type { WalletConfig } from "../../Wallet";
2
3
  import icon from "./binanceWallet.svg";
3
4
 
@@ -17,5 +18,31 @@ export const binanceWallet = (): WalletConfig => {
17
18
  qrCode: "https://www.binance.com/en/web3wallet",
18
19
  chrome: "https://chromewebstore.google.com/detail/cadiboklkpojfamcoggejbbdjcoiljjk",
19
20
  },
21
+ mobile: {
22
+ getUri: (uri: string) => {
23
+ return isAndroid() ? uri : `bnc://app.binance.com/cedefi/wc?uri=${encodeURIComponent(uri)}`;
24
+ },
25
+ getDeeplink: async (dappUrl?: string, chainId?: number): Promise<string> => {
26
+ if (!dappUrl) return "";
27
+ // Binance wallet uses @binance/w3w-utils for deep link generation
28
+ // This is a fallback implementation. For full support, use the binance utils package
29
+ try {
30
+ // Try to use binance utils if available
31
+ const binanceUtils = await import("@binance/w3w-utils").catch(() => null);
32
+ if (binanceUtils && "getDeepLink" in binanceUtils) {
33
+ const getDeepLink = binanceUtils.getDeepLink as (
34
+ url: string,
35
+ chainId?: number,
36
+ ) => { http: string; bnc: string };
37
+ const result = getDeepLink(dappUrl, chainId);
38
+ return result?.http || "";
39
+ }
40
+ } catch (e) {
41
+ // Fallback if binance utils not available
42
+ }
43
+ // Fallback: use binance deep link format
44
+ return `bnc://app.binance.com/cedefi/dapp?url=${encodeURIComponent(dappUrl)}`;
45
+ },
46
+ },
20
47
  };
21
48
  };
@@ -1,4 +1,5 @@
1
1
  import type { WalletConfig } from "../../Wallet";
2
+ import { isAndroid } from "../../../utils/isMobile";
2
3
  import icon from "./bitgetWallet.svg";
3
4
 
4
5
  export const bitgetWallet = (): WalletConfig => {
@@ -24,5 +25,14 @@ export const bitgetWallet = (): WalletConfig => {
24
25
  chrome: "https://chrome.google.com/webstore/detail/bitkeep-crypto-nft-wallet/jiidiaalihmmhddjgbnbgdfflelocpak",
25
26
  browserExtension: "https://web3.bitget.com/en/wallet-download",
26
27
  },
28
+ mobile: {
29
+ getUri: (uri: string) => {
30
+ return isAndroid() ? uri : `bitkeep://wc?uri=${encodeURIComponent(uri)}`;
31
+ },
32
+ getDeeplink: (dappUrl?: string): string => {
33
+ if (!dappUrl) return "";
34
+ return `https://bkcode.vip?action=dapp&url=${dappUrl}`;
35
+ },
36
+ },
27
37
  };
28
38
  };
@@ -12,4 +12,7 @@ export const bitverseWallet = (): WalletConfig => ({
12
12
  ios: "https://apps.apple.com/us/app/bitverse-discover-web3-wealth/id1645515614",
13
13
  qrCode: "https://www.bitverse.zone/download",
14
14
  },
15
+ mobile: {
16
+ getUri: (uri: string) => `bitverseapp://open/wallet/wc?uri=${encodeURIComponent(uri)}`,
17
+ },
15
18
  });
@@ -17,5 +17,10 @@ export const bybitWallet = (): WalletConfig => {
17
17
  mobile: "https://www.bybit.com/en/web3",
18
18
  qrCode: "https://www.bybit.com/en/web3",
19
19
  },
20
+ mobile: {
21
+ getUri: (uri: string) => {
22
+ return `bybitapp://open/route?targetUrl=by://web3/walletconnect/wc?uri=${encodeURIComponent(uri)}`;
23
+ },
24
+ },
20
25
  };
21
26
  };
@@ -19,5 +19,12 @@ export const coinbaseWallet = (): WalletConfig => {
19
19
  chrome: "https://chrome.google.com/webstore/detail/coinbase-wallet-extension/hnfanknocfeofbddgcijnmhnfnkdnaad",
20
20
  browserExtension: "https://coinbase.com/wallet",
21
21
  },
22
+ mobile: {
23
+ getDeeplink: (dappUrl?: string): string => {
24
+ if (!dappUrl) return "";
25
+ const encodedDappUrl = encodeURIComponent(dappUrl);
26
+ return `https://go.cb-w.com/dapp?cb_url=${encodedDappUrl}`;
27
+ },
28
+ },
22
29
  };
23
30
  };
@@ -13,5 +13,10 @@ export const foxWallet = (): WalletConfig => {
13
13
  ios: "https://apps.apple.com/app/foxwallet-crypto-web3/id1590983231",
14
14
  qrCode: "https://foxwallet.com/download",
15
15
  },
16
+ mobile: {
17
+ getUri: (uri: string) => {
18
+ return `foxwallet://wc?uri=${encodeURIComponent(uri)}`;
19
+ },
20
+ },
16
21
  };
17
22
  };
@@ -1,4 +1,5 @@
1
1
  import type { WalletConfig } from "../../Wallet";
2
+ import { isAndroid } from "../../../utils/isMobile";
2
3
  import icon from "./gateWallet.svg";
3
4
 
4
5
  export const gateWallet = (): WalletConfig => {
@@ -18,5 +19,10 @@ export const gateWallet = (): WalletConfig => {
18
19
  chrome: "https://chromewebstore.google.com/detail/gate-wallet/cpmkedoipcpimgecpmgpldfpohjplkpp",
19
20
  browserExtension: "https://www.gate.io/web3",
20
21
  },
22
+ mobile: {
23
+ getUri: (uri: string) => {
24
+ return isAndroid() ? uri : `gtweb3wallet://wc?uri=${encodeURIComponent(uri)}`;
25
+ },
26
+ },
21
27
  };
22
28
  };
@@ -13,4 +13,13 @@ export const imTokenWallet = (): WalletConfig => ({
13
13
  mobile: "https://token.im/download",
14
14
  qrCode: "https://token.im/download",
15
15
  },
16
+ mobile: {
17
+ getUri: (uri: string) => {
18
+ return `imtokenv2://wc?uri=${encodeURIComponent(uri)}`;
19
+ },
20
+ getDeeplink: (dappUrl?: string): string => {
21
+ if (!dappUrl) return "";
22
+ return `imtokenv2://navigate?screen=DappView&url=${dappUrl}`;
23
+ },
24
+ },
16
25
  });
@@ -1,4 +1,5 @@
1
1
  import type { WalletConfig } from "../../Wallet";
2
+ import { isAndroid } from "../../../utils/isMobile";
2
3
  import icon from "./iopayWallet.svg";
3
4
 
4
5
  export const iopayWallet = (): WalletConfig => ({
@@ -13,4 +14,9 @@ export const iopayWallet = (): WalletConfig => ({
13
14
  qrCode: "https://iopay.me/",
14
15
  browserExtension: "https://iopay.me/",
15
16
  },
17
+ mobile: {
18
+ getUri: (uri: string) => {
19
+ return isAndroid() ? uri : `iopay://wc?uri=${encodeURIComponent(uri)}`;
20
+ },
21
+ },
16
22
  });
@@ -16,5 +16,10 @@ export const kaiaWallet = (): WalletConfig => {
16
16
  android: "https://play.google.com/store/apps/details?id=io.klutch.wallet",
17
17
  mobile: "https://app.kaiawallet.io",
18
18
  },
19
+ mobile: {
20
+ getUri: (uri: string) => {
21
+ return `kaikas://walletconnect?uri=${encodeURIComponent(uri)}`;
22
+ },
23
+ },
19
24
  };
20
25
  };
@@ -16,5 +16,10 @@ export const kaikasWallet = (): WalletConfig => {
16
16
  android: "https://play.google.com/store/apps/details?id=io.klutch.wallet",
17
17
  mobile: "https://app.kaikas.io",
18
18
  },
19
+ mobile: {
20
+ getUri: (uri: string) => {
21
+ return `kaikas://walletconnect?uri=${encodeURIComponent(uri)}`;
22
+ },
23
+ },
19
24
  };
20
25
  };
@@ -12,4 +12,9 @@ export const krakenWallet = (): WalletConfig => ({
12
12
  mobile: "https://kraken.com/wallet",
13
13
  qrCode: "https://kraken.com/wallet",
14
14
  },
15
+ mobile: {
16
+ getUri: (uri: string) => {
17
+ return `krakenwallet://wc?uri=${encodeURIComponent(uri)}`;
18
+ },
19
+ },
15
20
  });
@@ -12,4 +12,7 @@ export const kresusWallet = (): WalletConfig => ({
12
12
  ios: "https://apps.apple.com/us/app/kresus-crypto-nft-superapp/id6444355152",
13
13
  qrCode: "https://kresusconnect.kresus.com/download",
14
14
  },
15
+ mobile: {
16
+ getUri: (uri: string) => `com.kresus.superapp://wc?uri=${encodeURIComponent(uri)}`,
17
+ },
15
18
  });
@@ -1,3 +1,4 @@
1
+ import { isAndroid } from "../../../utils/isMobile";
1
2
  import type { WalletConfig } from "../../Wallet";
2
3
  import icon from "./ledgerWallet.svg";
3
4
 
@@ -18,4 +19,9 @@ export const ledgerWallet = (): WalletConfig => ({
18
19
  linux: "https://www.ledger.com/ledger-live/download",
19
20
  desktop: "https://www.ledger.com/ledger-live",
20
21
  },
22
+ mobile: {
23
+ getUri: (uri: string) => {
24
+ return isAndroid() ? uri : `ledgerlive://wc?uri=${encodeURIComponent(uri)}`;
25
+ },
26
+ },
21
27
  });
@@ -1,3 +1,4 @@
1
+ import { isAndroid, isIOS } from "../../../utils/isMobile";
1
2
  import type { WalletConfig } from "../../Wallet";
2
3
  import icon from "./metaMaskWallet.svg";
3
4
 
@@ -85,5 +86,21 @@ export const metaMaskWallet = (): WalletConfig => {
85
86
  opera: "https://addons.opera.com/extensions/details/metamask-10",
86
87
  browserExtension: "https://metamask.io/download",
87
88
  },
89
+ mobile: {
90
+ getUri: (uri: string) => {
91
+ return isAndroid()
92
+ ? uri
93
+ : isIOS()
94
+ ? // currently broken in MetaMask v6.5.0 https://github.com/MetaMask/metamask-mobile/issues/6457
95
+ `metamask://wc?uri=${encodeURIComponent(uri)}`
96
+ : `https://metamask.app.link/wc?uri=${encodeURIComponent(uri)}`;
97
+ },
98
+ getDeeplink: (dappUrl?: string): string => {
99
+ if (!dappUrl) return "";
100
+ // Remove protocol from dappUrl for MetaMask deep link
101
+ const urlWithoutProtocol = dappUrl.split("://")[1] || dappUrl;
102
+ return `https://metamask.app.link/dapp/${urlWithoutProtocol}`;
103
+ },
104
+ },
88
105
  };
89
106
  };
@@ -1,4 +1,5 @@
1
1
  import type { WalletConfig } from "../../Wallet";
2
+ import { isAndroid } from "../../../utils/isMobile";
2
3
  import icon from "./oktoWallet.svg";
3
4
 
4
5
  export const oktoWallet = (): WalletConfig => ({
@@ -13,4 +14,9 @@ export const oktoWallet = (): WalletConfig => ({
13
14
  mobile: "https://okto.tech/",
14
15
  qrCode: "https://okto.tech/",
15
16
  },
17
+ mobile: {
18
+ getUri: (uri: string) => {
19
+ return isAndroid() ? uri : `okto://wc?uri=${encodeURIComponent(uri)}`;
20
+ },
21
+ },
16
22
  });
@@ -1,3 +1,4 @@
1
+ import { isAndroid } from "../../../utils/isMobile";
1
2
  import type { WalletConfig } from "../../Wallet";
2
3
  import icon from "./okxWallet.svg";
3
4
 
@@ -26,5 +27,15 @@ export const okxWallet = (): WalletConfig => {
26
27
  firefox: "https://addons.mozilla.org/firefox/addon/okexwallet/",
27
28
  browserExtension: "https://okx.com/download",
28
29
  },
30
+ mobile: {
31
+ getUri: (uri: string) => {
32
+ return isAndroid() ? uri : `okex://main/wc?uri=${encodeURIComponent(uri)}`;
33
+ },
34
+ getDeeplink: (uri?: string): string => {
35
+ const encodedDappUrl = encodeURIComponent(uri || "");
36
+ const deepLink = `okx://wallet/dapp/url?dappUrl=${encodedDappUrl}`;
37
+ return "https://www.okx.com/download?deeplink=" + encodeURIComponent(deepLink);
38
+ },
39
+ },
29
40
  };
30
41
  };
@@ -1,4 +1,5 @@
1
1
  import type { WalletConfig } from "../../Wallet";
2
+ import { isAndroid } from "../../../utils/isMobile";
2
3
  import icon from "./omniWallet.svg";
3
4
 
4
5
  export const omniWallet = (): WalletConfig => ({
@@ -13,4 +14,9 @@ export const omniWallet = (): WalletConfig => ({
13
14
  mobile: "https://omniwallet.app.link",
14
15
  qrCode: "https://omniwallet.app.link",
15
16
  },
17
+ mobile: {
18
+ getUri: (uri: string) => {
19
+ return isAndroid() ? uri : `omni://wc?uri=${encodeURIComponent(uri)}`;
20
+ },
21
+ },
16
22
  });
@@ -13,4 +13,7 @@ export const oneInchWallet = (): WalletConfig => ({
13
13
  mobile: "https://1inch.io/wallet",
14
14
  qrCode: "https://1inch.io/wallet",
15
15
  },
16
+ mobile: {
17
+ getUri: (uri: string) => `oneinch://wc?uri=${encodeURIComponent(uri)}`,
18
+ },
16
19
  });
@@ -12,4 +12,9 @@ export const paraSwapWallet = (): WalletConfig => ({
12
12
  mobile: "https://paraswap.io",
13
13
  qrCode: "https://paraswap.io",
14
14
  },
15
+ mobile: {
16
+ getUri: (uri: string) => {
17
+ return `paraswap://wc?uri=${encodeURIComponent(uri)}`;
18
+ },
19
+ },
15
20
  });