Skip to content
This repository has been archived by the owner on Apr 17, 2024. It is now read-only.

Commit

Permalink
refactor: warning Darwinia<>Ethereum
Browse files Browse the repository at this point in the history
  • Loading branch information
JayJay1024 committed Mar 15, 2024
1 parent 6597247 commit 1b89f37
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/components/transfer-action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import { Address, isAddress } from "viem";
import { useAccount, useNetwork, useSwitchNetwork } from "wagmi";

interface Props {
forceDisabled?: boolean;
recipient: Address | undefined;
transferable: bigint | undefined;
transferAmount: InputValue<bigint>;
onTransfer: () => void;
}

export default function TransferAction({ recipient, transferable, transferAmount, onTransfer }: Props) {
export default function TransferAction({ recipient, transferable, transferAmount, forceDisabled, onTransfer }: Props) {
const {
sourceAllowance,
sourceChain,
Expand Down Expand Up @@ -105,7 +106,7 @@ export default function TransferAction({ recipient, transferable, transferAmount
]);

return (
<Button busy={busy} disabled={btnDisabled} onClick={handleClick}>
<Button busy={busy} disabled={btnDisabled || forceDisabled} onClick={handleClick}>
{btnText}
</Button>
);
Expand Down
41 changes: 35 additions & 6 deletions src/components/transfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,32 @@ export default function Transfer() {
const [balanceLoading, setBalanceLoading] = useState(false);
const [indexerCategory, setIndexerCategory] = useState<BridgeCategory>();

const alert = useMemo(() => {
if (
(sourceChain?.network === "darwinia-dvm" && targetChain?.network === "ethereum") ||
(sourceChain?.network === "ethereum" && targetChain?.network === "darwinia-dvm")
) {
return (
<div className="flex flex-wrap items-center justify-center rounded-middle bg-inner p-middle text-center text-sm font-medium text-app-orange">
<span>
{`Due to the Ethereum upgrade, the Darwinia<>Ethereum bridge is temporarily unavailable. Please use the official`}
&nbsp;
</span>
<a
href="https://bridge.arbitrum.io/?destinationChain=ethereum&sourceChain=arbitrum-one"
rel="noopener noreferrer"
target="_blank"
className=" text-primary hover:underline"
>
Arbitrum bridge
</a>
<span>&nbsp;{`to route to Darwinia or Ethereum instead.`}</span>
</div>
);
}
return null;
}, [sourceChain?.network, targetChain?.network]);

const bridgeOptions = useMemo(
() => getAvailableBridges(sourceChain, targetChain, sourceToken),
[sourceChain, targetChain, sourceToken],
Expand Down Expand Up @@ -349,16 +375,19 @@ export default function Transfer() {

{/* Information */}
<Label text="Information" textClassName="font-medium">
<TransferInfo
fee={bridgeFee ? { ...bridgeFee, loading: isLoadingFee || isLoadingRelayers } : undefined}
bridge={bridgeInstance}
transferLimit={relayersData?.sortedLnBridgeRelayInfos?.transferLimit}
isLoadingTransferLimit={isLoadingRelayers}
/>
{alert ?? (
<TransferInfo
fee={bridgeFee ? { ...bridgeFee, loading: isLoadingFee || isLoadingRelayers } : undefined}
bridge={bridgeInstance}
transferLimit={relayersData?.sortedLnBridgeRelayInfos?.transferLimit}
isLoadingTransferLimit={isLoadingRelayers}
/>
)}
</Label>

{/* Action */}
<TransferAction
forceDisabled={!!alert}
transferable={transferable}
transferAmount={deferredTransferAmount}
recipient={recipient || address}
Expand Down
2 changes: 0 additions & 2 deletions src/config/chains/darwinia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export const darwiniaChain: ChainConfig = {
bridge: { category: "helix-sub2ethv2(lock)" },
action: "issue",
min: 1000000000000000000000000n,
hidden: true,
},
],
},
Expand All @@ -93,7 +92,6 @@ export const darwiniaChain: ChainConfig = {
target: { network: "ethereum", symbol: "KTON" },
bridge: { category: "helix-sub2ethv2(lock)" },
action: "issue",
hidden: true,
},
],
},
Expand Down
2 changes: 0 additions & 2 deletions src/config/chains/ethereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export const ethereumChain: ChainConfig = {
target: { network: "darwinia-dvm", symbol: "RING" },
bridge: { category: "helix-sub2ethv2(unlock)" },
action: "redeem",
hidden: true,
},
],
},
Expand All @@ -60,7 +59,6 @@ export const ethereumChain: ChainConfig = {
target: { network: "darwinia-dvm", symbol: "KTON" },
bridge: { category: "helix-sub2ethv2(unlock)" },
action: "redeem",
hidden: true,
},
],
},
Expand Down

0 comments on commit 1b89f37

Please sign in to comment.