Skip to content
This repository was archived by the owner on Apr 22, 2025. It is now read-only.

Commit 9e50d35

Browse files
authored
Refactor code and support HydraDX (#30)
* Refactor code and support HydraDX * Support Safe * Update icon
1 parent a83db9c commit 9e50d35

40 files changed

+997
-422
lines changed

public/images/asset/hdx.svg

Lines changed: 13 additions & 0 deletions
Loading

public/images/asset/ring.png

1.87 KB
Loading
Lines changed: 5 additions & 0 deletions
Loading

public/images/wallet/evm.png

14.7 KB
Loading

public/manifest.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "AssetHub Bridge - Darwinia",
3+
"description": "Assets cross-chain between Darwinia and AssetHub.",
4+
"icons": [{ "src": "icon.svg", "sizes": "any" }]
5+
}

src/app/layout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const inter = Inter({ subsets: ["latin"] });
1212
export const metadata: Metadata = {
1313
title: "AssetHub Bridge - Darwinia",
1414
description: "Assets cross-chain between Darwinia and AssetHub.",
15+
manifest: "/manifest.json",
1516
};
1617

1718
export default function RootLayout({ children }: { children: React.ReactNode }) {

src/components/balance-input.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ export default function BalanceInput({
5252
}, [balance, asset, placeholder]);
5353

5454
const min = useMemo(() => {
55-
if (cross && cross.fee.asset.native) {
55+
if (cross && cross.fee.asset.local.id === asset.id) {
5656
return cross.fee.amount;
5757
}
5858
return undefined;
59-
}, [cross]);
59+
}, [cross, asset.id]);
6060

6161
const handleInputChange = useCallback<ChangeEventHandler<HTMLInputElement>>(
6262
(e) => {
@@ -133,12 +133,14 @@ export default function BalanceInput({
133133
text={`* Limit: ${formatBalance(assetLimit ?? BN_ZERO, asset?.decimals ?? 0)}, supply: ${formatBalance(
134134
(assetSupply ?? BN_ZERO).add(value?.amount ?? BN_ZERO),
135135
asset?.decimals ?? 0,
136-
)}`}
136+
)}.`}
137137
/>
138138
) : requireMin ? (
139-
<InputAlert text={`* At least ${formatBalance(min ?? BN_ZERO, asset?.decimals ?? 0)} for tx fee`} />
139+
<InputAlert
140+
text={`* At least ${formatBalance(min ?? BN_ZERO, asset?.decimals ?? 0)} ${asset.symbol} for tx fee.`}
141+
/>
140142
) : insufficient ? (
141-
<InputAlert text="* Insufficient" />
143+
<InputAlert text="* Insufficient." />
142144
) : null}
143145

144146
{/* Invisible */}

src/components/connect-wallet.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,21 @@ export default function ConnectWallet({ who, kind = "component", height = "paddi
7777
[clearValue, setActiveWallet, setActiveAccount],
7878
);
7979

80-
const [supportedRainbow, supportedTalisman] = useMemo(() => {
81-
return [supported.some((id) => id === WalletID.RAINBOW), supported.some((id) => id === WalletID.TALISMAN)];
80+
const [supportedWalletEvm, supportedWalletTalisman] = useMemo(() => {
81+
return [supported.some((id) => id === WalletID.EVM), supported.some((id) => id === WalletID.TALISMAN)];
8282
}, [supported]);
8383

8484
useEffect(() => {
8585
if (!supported.some((id) => id === WalletID.TALISMAN) && activeWallet === WalletID.TALISMAN) {
8686
setActiveWallet(undefined);
8787
clearValue(undefined);
88-
} else if (!supported.some((id) => id === WalletID.RAINBOW) && activeWallet === WalletID.RAINBOW) {
88+
} else if (!supported.some((id) => id === WalletID.EVM) && activeWallet === WalletID.EVM) {
8989
setActiveWallet(undefined);
9090
clearValue(undefined);
9191
}
9292
}, [supported, activeWallet, clearValue, setActiveWallet]);
9393

94-
const walletIcon = kind === "primary" ? null : activeWallet === WalletID.RAINBOW ? "rainbow.svg" : "talisman-red.svg";
94+
const walletIcon = kind === "primary" ? null : activeWallet === WalletID.EVM ? "evm.png" : "talisman-red.svg";
9595

9696
// Major for page header
9797
if (kind === "primary" && sender?.address) {
@@ -105,7 +105,9 @@ export default function ConnectWallet({ who, kind = "component", height = "paddi
105105

106106
return (talismanAccounts.length || activeAddress) && activeWallet ? (
107107
<Button onClick={handleDisconnect} kind={kind} height={height}>
108-
{walletIcon && <Image width={16} height={16} alt="Wallet" src={`/images/wallet/${walletIcon}`} />}
108+
{walletIcon && (
109+
<Image width={16} height={16} alt="Wallet" src={`/images/wallet/${walletIcon}`} className="rounded-full" />
110+
)}
109111
<span>Disconnect</span>
110112
</Button>
111113
) : (
@@ -129,18 +131,18 @@ export default function ConnectWallet({ who, kind = "component", height = "paddi
129131
connectTalisman();
130132
setIsOpenFalse();
131133
}}
132-
disabled={!supportedTalisman}
134+
disabled={!supportedWalletTalisman}
133135
/>
134136
<Item
135137
who={who}
136-
icon="rainbow.svg"
137-
name="Rainbow"
138+
icon="evm.png"
139+
name="EVM wallets"
138140
onClick={() => {
139-
setActiveWallet(WalletID.RAINBOW);
141+
setActiveWallet(WalletID.EVM);
140142
openConnectModal?.();
141143
setIsOpenFalse();
142144
}}
143-
disabled={!supportedRainbow}
145+
disabled={!supportedWalletEvm}
144146
/>
145147
</div>
146148
</Modal>
@@ -195,7 +197,7 @@ function Item({
195197
disabled={disabled}
196198
onClick={onClick}
197199
>
198-
<Image width={20} height={20} alt="Wallet icon" src={`/images/wallet/${icon}`} />
200+
<Image width={20} height={20} alt="Wallet icon" src={`/images/wallet/${icon}`} className="rounded-full" />
199201
<span>{name}</span>
200202
</button>
201203
</Tooltip>

0 commit comments

Comments
 (0)