diff --git a/packages/web/config/generate-cosmos-kit-wallet-list.ts b/packages/web/config/generate-cosmos-kit-wallet-list.ts index 5a2ee99017..7b47b55ab2 100644 --- a/packages/web/config/generate-cosmos-kit-wallet-list.ts +++ b/packages/web/config/generate-cosmos-kit-wallet-list.ts @@ -5,6 +5,7 @@ import path from "node:path"; import { cdcwalletExtensionInfo } from "@cosmos-kit/cdcwallet-extension"; import { Wallet as DefaultWallet } from "@cosmos-kit/core"; import { cosmostationExtensionInfo } from "@cosmos-kit/cosmostation-extension"; +import { imTokenWalletInfo } from "@cosmos-kit/imtoken-extension"; import { keplrExtensionInfo } from "@cosmos-kit/keplr-extension"; import { keplrMobileInfo } from "@cosmos-kit/keplr-mobile"; import { leapExtensionInfo } from "@cosmos-kit/leap-extension"; @@ -38,6 +39,7 @@ const CosmosKitWalletList: Wallet[] = [ cosmostationExtensionInfo, stationExtensionInfo, cdcwalletExtensionInfo, + imTokenWalletInfo, ]; function isObject(value: any): value is Record { @@ -106,7 +108,7 @@ async function generateCosmosKitWalletList() { ).join(",")}} export const CosmosKitWalletList: Record = ${getStringifiedWallet( registryObject - )} + )} `; const prettierConfig = await prettier.resolveConfig("./"); diff --git a/packages/web/config/wallet-registry.ts b/packages/web/config/wallet-registry.ts index 316f5f4f59..081fbc652a 100644 --- a/packages/web/config/wallet-registry.ts +++ b/packages/web/config/wallet-registry.ts @@ -26,7 +26,7 @@ export const CosmosWalletRegistry: CosmosRegistryWallet[] = [ import("~/integrations/keplr-walletconnect").then( (m) => m.KeplrMobileWallet ), - supportsChain: async (chainId) => { + supportsChain: async (chainId: string) => { const keplrMobileAvailableChains: MainnetChainIds[] = [ "cosmoshub-4", "osmosis-1", @@ -78,7 +78,7 @@ export const CosmosWalletRegistry: CosmosRegistryWallet[] = [ logo: "/wallets/leap.svg", lazyInstall: () => import("@cosmos-kit/leap-mobile").then((m) => m.LeapMobileWallet), - supportsChain: async (chainId) => { + supportsChain: async (chainId: string) => { const leapMobileAvailableChains: MainnetChainIds[] = [ "agoric-3", "akashnet-2", @@ -162,7 +162,7 @@ export const CosmosWalletRegistry: CosmosRegistryWallet[] = [ (m) => m.OkxwalletExtensionWallet ), windowPropertyName: "okxwallet", - async supportsChain(chainId, retryCount = 0) { + async supportsChain(chainId: string, retryCount = 0) { if (typeof window === "undefined") return true; const okxWallet = (window as any)?.okxwallet?.keplr as { @@ -262,7 +262,7 @@ export const CosmosWalletRegistry: CosmosRegistryWallet[] = [ (m) => m.CdcwalletExtensionWallet ), mobileDisabled: false, - async supportsChain(chainId) { + async supportsChain(chainId: string) { const cdcAvailableChains: MainnetChainIds[] = [ "cosmoshub-4", "osmosis-1", @@ -281,7 +281,7 @@ export const CosmosWalletRegistry: CosmosRegistryWallet[] = [ lazyInstall: () => import("@cosmos-kit/xdefi-extension").then((m) => m.XDEFIExtensionWallet), windowPropertyName: "xfi", - async supportsChain(chainId) { + async supportsChain(chainId: string) { if (typeof window === "undefined") return true; const xfiWallet = (window as any)?.xfi?.keplr as { @@ -318,7 +318,7 @@ export const CosmosWalletRegistry: CosmosRegistryWallet[] = [ (m) => m.StationExtensionWallet ), windowPropertyName: "station", - supportsChain: async (chainId) => { + supportsChain: async (chainId: string) => { if (typeof window === "undefined") return true; const stationWallet = (window as any)?.station?.keplr as { @@ -335,4 +335,20 @@ export const CosmosWalletRegistry: CosmosRegistryWallet[] = [ }, features: [], }, + { + ...CosmosKitWalletList["imToken"], + logo: "/wallets/imtoken.svg", + mobileDisabled: false, + windowPropertyName: "cosmos", + features: [], + lazyInstall: () => + import("@cosmos-kit/imtoken-extension").then((m) => m.IMTokenWallet), + async supportsChain(chainId: string) { + const cdcAvailableChains: MainnetChainIds[] = [ + "cosmoshub-4", + "osmosis-1", + ]; + return cdcAvailableChains.includes(chainId as MainnetChainIds); + }, + }, ]; diff --git a/packages/web/modals/wallet-select/use-selectable-wallets.ts b/packages/web/modals/wallet-select/use-selectable-wallets.ts index f311b80bdc..b3e94b04d2 100644 --- a/packages/web/modals/wallet-select/use-selectable-wallets.ts +++ b/packages/web/modals/wallet-select/use-selectable-wallets.ts @@ -102,6 +102,22 @@ export const useSelectableWallets = ({ .map((wallet) => ({ ...wallet, mobileDisabled: false })); } + /** + * If on mobile and `imToken` is in `window`, it means that the user enters + * the frontend from imToken's app in app browser. So, there is no need + * to use wallet connect, as it resembles the extension's usage. + */ + if ( + _window?.imToken && + _window?.cosmos?.mode === mobileWebModeName + ) { + return array + .filter( + (wallet) => wallet.name === AvailableCosmosWallets.imToken + ) + .map((wallet) => ({ ...wallet, mobileDisabled: false })); + } + /** * If on mobile and `leap` is in `window`, it means that the user enters * the frontend from Leap's app in app browser. So, there is no need diff --git a/packages/web/package.json b/packages/web/package.json index 09875ced4a..3f9541adc9 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -35,6 +35,7 @@ "@cosmos-kit/cdcwallet": "^2.13.2", "@cosmos-kit/core": "^2.13.1", "@cosmos-kit/cosmostation": "^2.11.2", + "@cosmos-kit/imtoken": "^1.0.0", "@cosmos-kit/keplr": "^2.12.2", "@cosmos-kit/leap": "^2.12.2", "@cosmos-kit/okxwallet": "^2.9.2", diff --git a/packages/web/public/wallets/imtoken.svg b/packages/web/public/wallets/imtoken.svg new file mode 100644 index 0000000000..c974f392e0 --- /dev/null +++ b/packages/web/public/wallets/imtoken.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/yarn.lock b/yarn.lock index 82124b175c..2885449a6a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2990,6 +2990,21 @@ "@cosmos-kit/cosmostation-extension" "^2.12.2" "@cosmos-kit/cosmostation-mobile" "^2.11.2" +"@cosmos-kit/imtoken-extension@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@cosmos-kit/imtoken-extension/-/imtoken-extension-1.1.0.tgz#4d1c4ea2a0bd4548969cf4fd58503321230336c4" + integrity sha512-6vNrjVqLXdFcAEFaPCM0uFQjbLMaKymbahk2YW3qN8fUGopdmfDbFuBJj6IKqKEu9uOijmfvUcmKDZIax+gurg== + dependencies: + "@chain-registry/keplr" "1.68.2" + "@cosmos-kit/core" "^2.13.1" + +"@cosmos-kit/imtoken@^1.0.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@cosmos-kit/imtoken/-/imtoken-1.1.0.tgz#962e281a783a8fd1647fb9aa437d0fcf0159db46" + integrity sha512-PRN8OzMDbT1j5Zs5HgN34laXUUStZgxMs6cDibd9yOa3BBf0LU74CQQe+ucTLhfydrD8uqXxfsq2jg7YVxAPPg== + dependencies: + "@cosmos-kit/imtoken-extension" "^1.1.0" + "@cosmos-kit/keplr-extension@^2.12.2": version "2.12.2" resolved "https://registry.yarnpkg.com/@cosmos-kit/keplr-extension/-/keplr-extension-2.12.2.tgz#d632a1e53eb821b70851ae2aba6c473b4b79dd67"