Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: sync staging → main #176

Merged
merged 10 commits into from
Feb 14, 2024
2 changes: 1 addition & 1 deletion chain-registry
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.2",
"@tailwindcss/forms": "^0.5.7",
"@tanstack/query-sync-storage-persister": "^5.18.1",
"@tanstack/react-query": "^5.18.1",
Expand Down
32 changes: 23 additions & 9 deletions src/components/TransactionDialog/TransactionDialogContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { useBroadcastedTxsStatus, useSkipClient } from "@/solve";
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";

Expand All @@ -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();

Expand All @@ -58,7 +53,10 @@ function TransactionDialogContent({ route, onClose, isAmountError, transactionCo
const srcAccount = useAccount("source");
const dstAccount = useAccount("destination");

const showLedgerWarning = isCCTPFromNobleInOperation(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);

Expand Down Expand Up @@ -253,7 +251,7 @@ function TransactionDialogContent({ route, onClose, isAmountError, transactionCo
</AlertCollapse.Content>
</AlertCollapse.Root>
)}
{showLedgerWarning && (
{showCCTPLedgerWarning && (
<AlertCollapse.Root
type="warning"
initialOpen={true}
Expand All @@ -262,7 +260,23 @@ function TransactionDialogContent({ route, onClose, isAmountError, transactionCo
<p>
<b>WARNING: </b>
ibc.fun does not support signing with Ledger when transferring over CCTP to the Ethereum ecosystem.
We&apos;re actively working on fixing this. We apologize for the inconvenience
We&apos;re actively working on fixing this with the Noble/Circle teams. We apologize for the
inconvenience
</p>
</AlertCollapse.Content>
</AlertCollapse.Root>
)}
{showEthermintLikeLedgerWarning && (
<AlertCollapse.Root
type="warning"
initialOpen={true}
>
<AlertCollapse.Content>
<p>
<b>WARNING: </b>
ibc.fun does not support signing with Ledger on Ethermint-like chains (e.g. Injective, Dymension, EVMOS,
etc...). We&apos;re actively working on fixing this with the Ledger team. We apologize for the
inconvenience.
</p>
</AlertCollapse.Content>
</AlertCollapse.Root>
Expand Down
9 changes: 9 additions & 0 deletions src/constants/ledger-warning.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const knownBrokenCCTPLedgerChainIds = [
"noble-1",
"evmos_9001-2",
"dymension_1100-1",
"injective-1",
"dimension_37-1",
];

export const knownEthermintLedgerChainIds = ["evmos_9001-2", "dymension_1100-1", "injective-1", "dimension_37-1"];
21 changes: 19 additions & 2 deletions src/hooks/useAccount.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -79,7 +96,7 @@ export function useAccount(context: TrackWalletCtx) {
},
};
}
}, [chain, context, cosmosWallet, trackedWallet, wagmiAccount]);
}, [chain, context, cosmosWallet, trackedWallet, wagmiAccount, cosmosWalletIsLedgerQuery.data]);

return account;
}
22 changes: 22 additions & 0 deletions src/utils/ledger-warning.ts
Original file line number Diff line number Diff line change
@@ -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),
)
);
};
Loading