From 9c4f9b7501759346c1eefb51e6d2084fa4a825f0 Mon Sep 17 00:00:00 2001 From: Nur Fikri Date: Wed, 14 Feb 2024 01:38:35 +0700 Subject: [PATCH 1/5] refactor: extract cctp ledger warning on specific chains from route logic --- .../TransactionDialog/TransactionDialogContent.tsx | 9 ++------- src/utils/cctp.ts | 10 ++++++++++ 2 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 src/utils/cctp.ts diff --git a/src/components/TransactionDialog/TransactionDialogContent.tsx b/src/components/TransactionDialog/TransactionDialogContent.tsx index 1363c429..f9ceb2d5 100644 --- a/src/components/TransactionDialog/TransactionDialogContent.tsx +++ b/src/components/TransactionDialog/TransactionDialogContent.tsx @@ -10,6 +10,7 @@ import { useAccount } from "@/hooks/useAccount"; import { useFinalityTimeEstimate } from "@/hooks/useFinalityTimeEstimate"; import { useWalletAddresses } from "@/hooks/useWalletAddresses"; import { useBroadcastedTxsStatus, useSkipClient } from "@/solve"; +import { isCCTPLedgerBrokenInOperation } from "@/utils/cctp"; import { getChainGasPrice } from "@/utils/chain.client"; import { isUserRejectedRequestError } from "@/utils/error"; import { getExplorerUrl } from "@/utils/explorer"; @@ -35,12 +36,6 @@ export interface BroadcastedTx { explorerLink: string; } -const isCCTPFromNobleInOperation = (route: RouteResponse) => { - return route.operations.some( - (operation) => "cctpTransfer" in operation && operation.cctpTransfer.fromChainID === "noble-1", - ); -}; - function TransactionDialogContent({ route, onClose, isAmountError, transactionCount }: Props) { const skipClient = useSkipClient(); @@ -58,7 +53,7 @@ function TransactionDialogContent({ route, onClose, isAmountError, transactionCo const srcAccount = useAccount("source"); const dstAccount = useAccount("destination"); - const showLedgerWarning = isCCTPFromNobleInOperation(route) && srcAccount?.wallet?.mode === "ledger"; + const showLedgerWarning = isCCTPLedgerBrokenInOperation(route) && srcAccount?.wallet?.mode === "ledger"; const { data: userAddresses } = useWalletAddresses(route.chainIDs); diff --git a/src/utils/cctp.ts b/src/utils/cctp.ts new file mode 100644 index 00000000..8e954736 --- /dev/null +++ b/src/utils/cctp.ts @@ -0,0 +1,10 @@ +import { RouteResponse } from "@skip-router/core"; + +const knownBrokenCCTPLedgerChainIds = ["noble-1", "evmos_9001-2", "dymension_1100-1", "injective-1", "dimension_37-1"]; + +export const isCCTPLedgerBrokenInOperation = (route: RouteResponse) => { + return route.operations.some( + (operation) => + "cctpTransfer" in operation && knownBrokenCCTPLedgerChainIds.includes(operation.cctpTransfer.fromChainID), + ); +}; From 9bfb941234f83c16a626fce7258c88ddd714f3d5 Mon Sep 17 00:00:00 2001 From: Nur Fikri Date: Wed, 14 Feb 2024 01:43:41 +0700 Subject: [PATCH 2/5] refactor: move constants to constants folder --- src/constants/cctp.ts | 7 +++++++ src/utils/cctp.ts | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 src/constants/cctp.ts diff --git a/src/constants/cctp.ts b/src/constants/cctp.ts new file mode 100644 index 00000000..246dee82 --- /dev/null +++ b/src/constants/cctp.ts @@ -0,0 +1,7 @@ +export const knownBrokenCCTPLedgerChainIds = [ + "noble-1", + "evmos_9001-2", + "dymension_1100-1", + "injective-1", + "dimension_37-1", +]; diff --git a/src/utils/cctp.ts b/src/utils/cctp.ts index 8e954736..f6eae3de 100644 --- a/src/utils/cctp.ts +++ b/src/utils/cctp.ts @@ -1,6 +1,6 @@ import { RouteResponse } from "@skip-router/core"; -const knownBrokenCCTPLedgerChainIds = ["noble-1", "evmos_9001-2", "dymension_1100-1", "injective-1", "dimension_37-1"]; +import { knownBrokenCCTPLedgerChainIds } from "@/constants/cctp"; export const isCCTPLedgerBrokenInOperation = (route: RouteResponse) => { return route.operations.some( From b24be1d6999c4454c193ba0ebf4058bf1ee85827 Mon Sep 17 00:00:00 2001 From: Nur Fikri Date: Wed, 14 Feb 2024 07:44:17 +0700 Subject: [PATCH 3/5] fix: ledger warning not showup and add ethermintlike chain --- .../TransactionDialogContent.tsx | 27 ++++++++++++++++--- src/constants/{cctp.ts => ledger-warning.ts} | 2 ++ src/hooks/useAccount.ts | 21 +++++++++++++-- src/utils/cctp.ts | 10 ------- src/utils/ledger-warning.ts | 22 +++++++++++++++ 5 files changed, 66 insertions(+), 16 deletions(-) rename src/constants/{cctp.ts => ledger-warning.ts} (54%) delete mode 100644 src/utils/cctp.ts create mode 100644 src/utils/ledger-warning.ts diff --git a/src/components/TransactionDialog/TransactionDialogContent.tsx b/src/components/TransactionDialog/TransactionDialogContent.tsx index f9ceb2d5..88fdb265 100644 --- a/src/components/TransactionDialog/TransactionDialogContent.tsx +++ b/src/components/TransactionDialog/TransactionDialogContent.tsx @@ -10,10 +10,10 @@ import { useAccount } from "@/hooks/useAccount"; import { useFinalityTimeEstimate } from "@/hooks/useFinalityTimeEstimate"; import { useWalletAddresses } from "@/hooks/useWalletAddresses"; import { useBroadcastedTxsStatus, useSkipClient } from "@/solve"; -import { isCCTPLedgerBrokenInOperation } from "@/utils/cctp"; import { getChainGasPrice } from "@/utils/chain.client"; import { isUserRejectedRequestError } from "@/utils/error"; import { getExplorerUrl } from "@/utils/explorer"; +import { isCCTPLedgerBrokenInOperation, isEthermintLedgerInOperation } from "@/utils/ledger-warning"; import { randomId } from "@/utils/random"; import { cn } from "@/utils/ui"; @@ -53,7 +53,10 @@ function TransactionDialogContent({ route, onClose, isAmountError, transactionCo const srcAccount = useAccount("source"); const dstAccount = useAccount("destination"); - const showLedgerWarning = isCCTPLedgerBrokenInOperation(route) && srcAccount?.wallet?.mode === "ledger"; + const showCCTPLedgerWarning = isCCTPLedgerBrokenInOperation(route) && srcAccount?.wallet?.isLedger; + const showEthermintLikeLedgerWarning = isEthermintLedgerInOperation(route) && srcAccount?.wallet?.isLedger; + + const showLedgerWarning = showCCTPLedgerWarning || showEthermintLikeLedgerWarning; const { data: userAddresses } = useWalletAddresses(route.chainIDs); @@ -248,7 +251,7 @@ function TransactionDialogContent({ route, onClose, isAmountError, transactionCo )} - {showLedgerWarning && ( + {showCCTPLedgerWarning && ( WARNING: ibc.fun does not support signing with Ledger when transferring over CCTP to the Ethereum ecosystem. - We're actively working on fixing this. We apologize for the inconvenience + We're actively working on fixing this with the Noble/Circle teams. We apologize for the + inconvenience +

+ +
+ )} + {showEthermintLikeLedgerWarning && ( + + +

+ WARNING: + ibc.fun does not support signing with Ledger on Ethermint-like chains (e.g. Injective, Dymension, EVMOS, + etc...). We're actively working on fixing this with the Ledger team. We apologize for the + inconvenience.

diff --git a/src/constants/cctp.ts b/src/constants/ledger-warning.ts similarity index 54% rename from src/constants/cctp.ts rename to src/constants/ledger-warning.ts index 246dee82..b050d89e 100644 --- a/src/constants/cctp.ts +++ b/src/constants/ledger-warning.ts @@ -5,3 +5,5 @@ export const knownBrokenCCTPLedgerChainIds = [ "injective-1", "dimension_37-1", ]; + +export const knownEthermintLedgerChainIds = ["evmos_9001-2", "dymension_1100-1", "injective-1", "dimension_37-1"]; diff --git a/src/hooks/useAccount.ts b/src/hooks/useAccount.ts index fde62a3a..89b6227d 100644 --- a/src/hooks/useAccount.ts +++ b/src/hooks/useAccount.ts @@ -1,10 +1,13 @@ +import { WalletClient } from "@cosmos-kit/core"; import { useManager as useCosmosManager } from "@cosmos-kit/react"; +import { useQuery } from "@tanstack/react-query"; import { useMemo } from "react"; import { useAccount as useWagmiAccount } from "wagmi"; import { EVM_WALLET_LOGOS, INJECTED_EVM_WALLET_LOGOS } from "@/constants/wagmi"; import { trackWallet, TrackWalletCtx, useTrackWallet } from "@/context/track-wallet"; import { useChainByID } from "@/hooks/useChains"; +import { isWalletClientUsingLedger } from "@/utils/wallet"; export function useAccount(context: TrackWalletCtx) { const trackedWallet = useTrackWallet(context); @@ -20,6 +23,20 @@ export function useAccount(context: TrackWalletCtx) { const wagmiAccount = useWagmiAccount(); + const getIsLedger = async (client: WalletClient, chainId: string) => { + const isLedger = await isWalletClientUsingLedger(client, chainId); + return isLedger; + }; + + const cosmosWalletIsLedgerQuery = useQuery({ + queryKey: ["cosmosWallet", cosmosWallet, chain, cosmosWallet?.client, chain?.chainID], + queryFn: () => { + if (!cosmosWallet || !chain) return; + return getIsLedger(cosmosWallet.client, chain.chainID); + }, + enabled: chain && chain.chainType === "cosmos" && !!cosmosWallet, + }); + const account = useMemo(() => { trackedWallet; if (!chain) return; @@ -34,7 +51,7 @@ export function useAccount(context: TrackWalletCtx) { walletInfo: { logo: cosmosWallet.walletInfo.logo, }, - mode: cosmosWallet.walletInfo.mode, + isLedger: !!cosmosWalletIsLedgerQuery.data, } : undefined, chainType: chain.chainType, @@ -79,7 +96,7 @@ export function useAccount(context: TrackWalletCtx) { }, }; } - }, [chain, context, cosmosWallet, trackedWallet, wagmiAccount]); + }, [chain, context, cosmosWallet, trackedWallet, wagmiAccount, cosmosWalletIsLedgerQuery.data]); return account; } diff --git a/src/utils/cctp.ts b/src/utils/cctp.ts deleted file mode 100644 index f6eae3de..00000000 --- a/src/utils/cctp.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { RouteResponse } from "@skip-router/core"; - -import { knownBrokenCCTPLedgerChainIds } from "@/constants/cctp"; - -export const isCCTPLedgerBrokenInOperation = (route: RouteResponse) => { - return route.operations.some( - (operation) => - "cctpTransfer" in operation && knownBrokenCCTPLedgerChainIds.includes(operation.cctpTransfer.fromChainID), - ); -}; diff --git a/src/utils/ledger-warning.ts b/src/utils/ledger-warning.ts new file mode 100644 index 00000000..e9d25f53 --- /dev/null +++ b/src/utils/ledger-warning.ts @@ -0,0 +1,22 @@ +import { RouteResponse } from "@skip-router/core"; + +import { knownBrokenCCTPLedgerChainIds, knownEthermintLedgerChainIds } from "@/constants/ledger-warning"; + +export const isCCTPLedgerBrokenInOperation = (route: RouteResponse) => { + return route.operations.some( + (operation) => + "cctpTransfer" in operation && knownBrokenCCTPLedgerChainIds.includes(operation.cctpTransfer.fromChainID), + ); +}; + +export const isEthermintLedgerInOperation = (route: RouteResponse) => { + return ( + route.operations.some( + (operation) => "transfer" in operation && knownEthermintLedgerChainIds.includes(operation.transfer.chainID), + ) || + route.operations.some( + (operation) => + "axelarTransfer" in operation && knownEthermintLedgerChainIds.includes(operation.axelarTransfer.fromChainID), + ) + ); +}; From 5d9b4f4dcff48beac53a72b858afb8fb9d87b10e Mon Sep 17 00:00:00 2001 From: Nur Fikri Date: Wed, 14 Feb 2024 07:53:24 +0700 Subject: [PATCH 4/5] chore(deps): bump @skip-router/core version --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 94bad844..0a7f3c1c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,7 +38,7 @@ "@radix-ui/react-scroll-area": "^1.0.5", "@radix-ui/react-tooltip": "^1.0.7", "@sentry/nextjs": "^7.99.0", - "@skip-router/core": "^1.3.0", + "@skip-router/core": "^1.3.1", "@tailwindcss/forms": "^0.5.7", "@tanstack/query-sync-storage-persister": "^5.18.1", "@tanstack/react-query": "^5.18.1", @@ -7680,9 +7680,9 @@ } }, "node_modules/@skip-router/core": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@skip-router/core/-/core-1.3.0.tgz", - "integrity": "sha512-DUKqiv+lKANn3pamabCIAA8Wv/9Mycw5DRj3VP1/j8Mhb9zmYFzcavWJIeAmLZk2A3bGN4tQIwLVI49/mMiktA==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@skip-router/core/-/core-1.3.1.tgz", + "integrity": "sha512-twdaEjtwYO0qYgfEliQXsGUORPPwCK9XepSaqxXBycme9p+I9R6zYeoEKndOHHHH6mTFD6t9W7p3VKOyuLfiYw==", "dependencies": { "@cosmjs/amino": "0.31.x", "@cosmjs/cosmwasm-stargate": "0.31.x", diff --git a/package.json b/package.json index 9f4a3a7a..cb942931 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "@radix-ui/react-scroll-area": "^1.0.5", "@radix-ui/react-tooltip": "^1.0.7", "@sentry/nextjs": "^7.99.0", - "@skip-router/core": "^1.3.0", + "@skip-router/core": "^1.3.1", "@tailwindcss/forms": "^0.5.7", "@tanstack/query-sync-storage-persister": "^5.18.1", "@tanstack/react-query": "^5.18.1", From 76341ac2aeba0aae4123e58dba16ccb9d9c649e9 Mon Sep 17 00:00:00 2001 From: bpiv400 Date: Wed, 14 Feb 2024 11:55:59 -0500 Subject: [PATCH 5/5] (chore): bumping sdk version --- chain-registry | 2 +- package-lock.json | 8 ++++---- package.json | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/chain-registry b/chain-registry index 4e2369d0..e265ffb1 160000 --- a/chain-registry +++ b/chain-registry @@ -1 +1 @@ -Subproject commit 4e2369d031a2a8b0133f583d8623ee1f921f1103 +Subproject commit e265ffb1bd05f5394cac721f1c493fe079b53295 diff --git a/package-lock.json b/package-lock.json index 0a7f3c1c..1dc5be92 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,7 +38,7 @@ "@radix-ui/react-scroll-area": "^1.0.5", "@radix-ui/react-tooltip": "^1.0.7", "@sentry/nextjs": "^7.99.0", - "@skip-router/core": "^1.3.1", + "@skip-router/core": "^1.3.2", "@tailwindcss/forms": "^0.5.7", "@tanstack/query-sync-storage-persister": "^5.18.1", "@tanstack/react-query": "^5.18.1", @@ -7680,9 +7680,9 @@ } }, "node_modules/@skip-router/core": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@skip-router/core/-/core-1.3.1.tgz", - "integrity": "sha512-twdaEjtwYO0qYgfEliQXsGUORPPwCK9XepSaqxXBycme9p+I9R6zYeoEKndOHHHH6mTFD6t9W7p3VKOyuLfiYw==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@skip-router/core/-/core-1.3.2.tgz", + "integrity": "sha512-AFfxWOH9S3C5/BSBf6TW4qPCGcwYpItfvukU41qiiEBwuYHYe+/bcbrjORCaUvCk0s5LolXo+59Qsf3T7PEDDw==", "dependencies": { "@cosmjs/amino": "0.31.x", "@cosmjs/cosmwasm-stargate": "0.31.x", diff --git a/package.json b/package.json index cb942931..42131afa 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "@radix-ui/react-scroll-area": "^1.0.5", "@radix-ui/react-tooltip": "^1.0.7", "@sentry/nextjs": "^7.99.0", - "@skip-router/core": "^1.3.1", + "@skip-router/core": "^1.3.2", "@tailwindcss/forms": "^0.5.7", "@tanstack/query-sync-storage-persister": "^5.18.1", "@tanstack/react-query": "^5.18.1",