Skip to content

Commit

Permalink
Support USDT Arbitrum<>Mantle crossing (#544)
Browse files Browse the repository at this point in the history
* pass sourceToken and targetToken to record-detail bridgeFactory

* support USDT Arbitrum<>Mantle transfer

* display Helix(Fusion) first for RING Erhereum->Darwinia

* fix helix-bridge redeem contract functionName

* config WRING on Darwinia

* display Helix(Fusion) first for RING Darwinia->Ethereum
  • Loading branch information
JayJay1024 authored Oct 24, 2023
1 parent d9cc5fc commit 7ac9210
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 17 deletions.
12 changes: 10 additions & 2 deletions packages/apps/src/bridges/helixbridge-dvmdvm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,17 @@ export class HelixBridgeDVMDVM extends BaseBridge {
}

private async burn(_: string, recipient: string, amount: bigint, options?: { totalFee: bigint }) {
if (options && this.contract && this.specVersion && this.sourceToken && this.publicClient && this.walletClient) {
if (
options &&
this.contract &&
this.specVersion &&
this.sourceToken &&
this.targetToken &&
this.publicClient &&
this.walletClient
) {
const { args, value, functionName } =
this.sourceToken.type === "native"
this.targetToken.type === "native"
? {
functionName: "burnAndRemoteUnlockNative",
args: [this.specVersion.target, this.gasLimit, recipient, amount],
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/src/bridges/helixbridge-dvmevm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ export class HelixBridgeDVMEVM extends BaseBridge {
}

private async burn(_: string, recipient: string, amount: bigint, options?: { totalFee: bigint }) {
if (options && this.contract && this.sourceToken && this.publicClient && this.walletClient) {
if (options && this.contract && this.sourceToken && this.targetToken && this.publicClient && this.walletClient) {
const { args, functionName } =
this.sourceToken.type === "native"
this.targetToken.type === "native"
? {
functionName: "burnAndRemoteUnlockNative",
args: [recipient, amount],
Expand Down
8 changes: 5 additions & 3 deletions packages/apps/src/components/record-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ export default function RecordDetail(props: Props) {
});

const bridgeClient = useMemo<BaseBridge | undefined>(() => {
const category = record?.historyRecordById?.bridge;
const sourceChain = getChainConfig(record?.historyRecordById?.fromChain);
const targetChain = getChainConfig(record?.historyRecordById?.toChain);
const category = record?.historyRecordById?.bridge;
const sourceToken = sourceChain?.tokens.find((t) => t.symbol === record?.historyRecordById?.sendToken);
const targetToken = targetChain?.tokens.find((t) => t.symbol === record?.historyRecordById?.recvToken);

if (sourceChain && targetChain && category) {
return bridgeFactory({ category, sourceChain, targetChain });
if (category) {
return bridgeFactory({ category, sourceChain, targetChain, sourceToken, targetToken });
}

return undefined;
Expand Down
9 changes: 9 additions & 0 deletions packages/apps/src/config/chains/arbitrum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,14 @@ export const arbitrumChain: ChainConfig = {
logo: "ring.svg",
cross: [{ target: { network: "ethereum", symbol: "RING" }, bridge: { category: "lnbridgev20-opposite" } }],
},
{
decimals: 18,
symbol: "USDT",
name: "USDT",
type: "erc20",
address: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
logo: "usdt.svg",
cross: [{ target: { network: "mantle", symbol: "USDT" }, bridge: { category: "lnbridgev20-default" } }],
},
],
};
19 changes: 14 additions & 5 deletions packages/apps/src/config/chains/darwinia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ export const darwiniaChain: ChainConfig = {
bridge: { category: "helix-sub2subv21(lock)" },
action: "issue",
},
{
target: { network: "ethereum", symbol: "RING" },
bridge: { category: "helix-sub2ethv2(lock)" },
action: "issue",
},
{
target: { network: "ethereum", symbol: "RING" },
bridge: { category: "lpbridge-darwinia-dvm" },
Expand All @@ -54,8 +49,22 @@ export const darwiniaChain: ChainConfig = {
index: 0,
price: 440000n,
},
{
target: { network: "ethereum", symbol: "RING" },
bridge: { category: "helix-sub2ethv2(lock)" },
action: "issue",
},
],
},
{
decimals: 18,
symbol: "WRING",
name: "WRING",
type: "erc20",
address: "0x",
logo: "ring.svg",
cross: [],
},
{
decimals: 18,
symbol: "KTON",
Expand Down
8 changes: 4 additions & 4 deletions packages/apps/src/config/chains/ethereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ export const ethereumChain: ChainConfig = {
{ target: { network: "arbitrum", symbol: "RING" }, bridge: { category: "lnbridgev20-default" } },
{
target: { network: "darwinia-dvm", symbol: "RING" },
bridge: { category: "helix-sub2ethv2(unlock)" },
bridge: { category: "lpbridge-ethereum" },
action: "redeem",
baseFee: parseUnits("3000", 18),
index: 0,
},
{
target: { network: "darwinia-dvm", symbol: "RING" },
bridge: { category: "lpbridge-ethereum" },
bridge: { category: "helix-sub2ethv2(unlock)" },
action: "redeem",
baseFee: parseUnits("3000", 18),
index: 0,
},
],
},
Expand Down
12 changes: 11 additions & 1 deletion packages/apps/src/config/chains/mantle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,15 @@ export const mantleChain: ChainConfig = {
url: "https://explorer.mantle.xyz/",
},
},
tokens: [],
tokens: [
{
decimals: 18,
symbol: "USDT",
name: "USDT",
type: "erc20",
address: "0x201EBa5CC46D216Ce6DC03F6a759e8E766e956aE",
logo: "usdt.svg",
cross: [{ target: { network: "arbitrum", symbol: "USDT" }, bridge: { category: "lnbridgev20-default" } }],
},
],
};
1 change: 1 addition & 0 deletions packages/apps/src/types/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type TokenSymbol =
| "ORING"
| "CRAB"
| "KTON"
| "WRING"
| "xWRING"
| "xWCRAB"
| "MNT";
Expand Down

0 comments on commit 7ac9210

Please sign in to comment.