From 13da18b5652ad4e720a2d29f0c0ead87f88cf60e Mon Sep 17 00:00:00 2001 From: JayJay1024 Date: Tue, 9 Apr 2024 15:53:05 +0800 Subject: [PATCH 1/3] Adapt indexer bridge name update --- src/components/history-records.tsx | 11 ++++++----- src/config/chains/crab.ts | 4 ++-- src/config/chains/darwinia.ts | 8 ++++---- src/config/chains/ethereum.ts | 4 ++-- src/config/chains/pangolin.ts | 2 +- src/config/chains/sepolia.ts | 2 +- src/types/bridge.ts | 11 ++++++----- src/utils/bridge.ts | 9 +++------ 8 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/components/history-records.tsx b/src/components/history-records.tsx index 0549329b..b59651dd 100644 --- a/src/components/history-records.tsx +++ b/src/components/history-records.tsx @@ -41,11 +41,12 @@ export default function HistoryRecords() { "l2arbitrumbridge-ethereum", "lpbridge-darwinia-dvm", "lpbridge-ethereum", - "xtoken-crab-dvm", - "xtoken-darwinia-dvm", - "xtoken-pangolin-dvm", - "xtoken-sepolia", - "xtoken-ethereum", + "xtoken-crab-darwinia", + "xtoken-darwinia-crab", + "xtoken-darwinia-ethereum", + "xtoken-ethereum-darwinia", + "xtoken-pangolin-sepolia", + "xtoken-sepolia-pangolin", ], }, notifyOnNetworkStatusChange: true, diff --git a/src/config/chains/crab.ts b/src/config/chains/crab.ts index 062c2d21..b1b4a219 100644 --- a/src/config/chains/crab.ts +++ b/src/config/chains/crab.ts @@ -52,7 +52,7 @@ export const crabChain: ChainConfig = { cross: [ { target: { network: "darwinia-dvm", symbol: "xWCRAB" }, - bridge: { category: "xtoken-crab-dvm" }, + bridge: { category: "xtoken-crab-darwinia" }, action: "issue", }, ], @@ -69,7 +69,7 @@ export const crabChain: ChainConfig = { cross: [ { target: { network: "darwinia-dvm", symbol: "RING" }, - bridge: { category: "xtoken-crab-dvm" }, + bridge: { category: "xtoken-crab-darwinia" }, action: "redeem", }, ], diff --git a/src/config/chains/darwinia.ts b/src/config/chains/darwinia.ts index 7e564417..cc3c77d6 100644 --- a/src/config/chains/darwinia.ts +++ b/src/config/chains/darwinia.ts @@ -53,7 +53,7 @@ export const darwiniaChain: ChainConfig = { cross: [ { target: { network: "crab-dvm", symbol: "xWRING" }, - bridge: { category: "xtoken-darwinia-dvm" }, + bridge: { category: "xtoken-darwinia-crab" }, action: "issue", }, { @@ -74,7 +74,7 @@ export const darwiniaChain: ChainConfig = { }, { target: { network: "ethereum", symbol: "RING" }, - bridge: { category: "xtoken-darwinia-dvm" }, + bridge: { category: "xtoken-darwinia-ethereum" }, action: "issue", }, ], @@ -97,7 +97,7 @@ export const darwiniaChain: ChainConfig = { }, { target: { network: "ethereum", symbol: "KTON" }, - bridge: { category: "xtoken-darwinia-dvm" }, + bridge: { category: "xtoken-darwinia-ethereum" }, action: "issue", }, ], @@ -114,7 +114,7 @@ export const darwiniaChain: ChainConfig = { cross: [ { target: { network: "crab-dvm", symbol: "CRAB" }, - bridge: { category: "xtoken-darwinia-dvm" }, + bridge: { category: "xtoken-darwinia-crab" }, action: "redeem", }, ], diff --git a/src/config/chains/ethereum.ts b/src/config/chains/ethereum.ts index 9c5c756b..a13de460 100644 --- a/src/config/chains/ethereum.ts +++ b/src/config/chains/ethereum.ts @@ -52,7 +52,7 @@ export const ethereumChain: ChainConfig = { }, { target: { network: "darwinia-dvm", symbol: "RING" }, - bridge: { category: "xtoken-ethereum" }, + bridge: { category: "xtoken-ethereum-darwinia" }, action: "redeem", }, ], @@ -75,7 +75,7 @@ export const ethereumChain: ChainConfig = { }, { target: { network: "darwinia-dvm", symbol: "KTON" }, - bridge: { category: "xtoken-ethereum" }, + bridge: { category: "xtoken-ethereum-darwinia" }, action: "redeem", }, ], diff --git a/src/config/chains/pangolin.ts b/src/config/chains/pangolin.ts index 46a32bb7..aa1d52fd 100644 --- a/src/config/chains/pangolin.ts +++ b/src/config/chains/pangolin.ts @@ -47,7 +47,7 @@ export const pangolinChain: ChainConfig = { cross: [ { target: { network: "sepolia", symbol: "xPRING" }, - bridge: { category: "xtoken-pangolin-dvm" }, + bridge: { category: "xtoken-pangolin-sepolia" }, action: "issue", }, ], diff --git a/src/config/chains/sepolia.ts b/src/config/chains/sepolia.ts index 910f562f..394bc008 100644 --- a/src/config/chains/sepolia.ts +++ b/src/config/chains/sepolia.ts @@ -47,7 +47,7 @@ export const sepoliaChain: ChainConfig = { cross: [ { target: { network: "pangolin-dvm", symbol: "PRING" }, - bridge: { category: "xtoken-sepolia" }, + bridge: { category: "xtoken-sepolia-pangolin" }, action: "redeem", }, ], diff --git a/src/types/bridge.ts b/src/types/bridge.ts index 88f49f1d..88bc3b0a 100644 --- a/src/types/bridge.ts +++ b/src/types/bridge.ts @@ -14,11 +14,12 @@ export type HelixBridgeCategory = | "helix-sub2subv21(unlock)" | "helix-sub2subv21(lock)"; export type XTokenBridgeCategory = - | "xtoken-sepolia" - | "xtoken-ethereum" - | "xtoken-darwinia-dvm" - | "xtoken-crab-dvm" - | "xtoken-pangolin-dvm"; + | "xtoken-crab-darwinia" + | "xtoken-darwinia-crab" + | "xtoken-darwinia-ethereum" + | "xtoken-ethereum-darwinia" + | "xtoken-pangolin-sepolia" + | "xtoken-sepolia-pangolin"; export type BridgeCategory = L2BridgeCategory | HelixLpBridgeCategory | HelixBridgeCategory | XTokenBridgeCategory; export interface BridgeContract { diff --git a/src/utils/bridge.ts b/src/utils/bridge.ts index 671d0ba1..dcf8d925 100644 --- a/src/utils/bridge.ts +++ b/src/utils/bridge.ts @@ -9,6 +9,9 @@ import { import { BridgeConstructorArgs } from "@/types"; export function bridgeFactory(args: BridgeConstructorArgs): BaseBridge | undefined { + if (args.category.startsWith("xtoken-")) { + return new XTokenNextBridge(args); + } switch (args.category) { case "helix-sub2ethv2(lock)": case "helix-sub2ethv2(unlock)": @@ -21,12 +24,6 @@ export function bridgeFactory(args: BridgeConstructorArgs): BaseBridge | undefin return new HelixLpBridge(args); case "l2arbitrumbridge-ethereum": return new L2ArbitrumBridge(args); - case "xtoken-darwinia-dvm": - case "xtoken-crab-dvm": - case "xtoken-pangolin-dvm": - case "xtoken-sepolia": - case "xtoken-ethereum": - return new XTokenNextBridge(args); default: return; } From 9be96723a38cd784938313b846984d723f2cccdd Mon Sep 17 00:00:00 2001 From: JayJay1024 Date: Tue, 9 Apr 2024 16:25:57 +0800 Subject: [PATCH 2/3] Fix eslint with lint-staged --- .lintstagedrc.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.lintstagedrc.js b/.lintstagedrc.js index a24c0ca4..18d979e7 100644 --- a/.lintstagedrc.js +++ b/.lintstagedrc.js @@ -1,9 +1,9 @@ const path = require("path"); const buildAppsEslintCommand = (filenames) => - `npm run lint -w apps -- --fix --file ${filenames.map((f) => path.relative("packages/apps", f)).join(" --file ")}`; + `npm run lint -- --fix --file ${filenames.map((f) => path.relative("./", f)).join(" --file ")}`; module.exports = { - "packages/apps/src/**/*.{js,jsx,ts,tsx}": [buildAppsEslintCommand], + "src/**/*.{js,jsx,ts,tsx}": [buildAppsEslintCommand], "**/*.{js,jsx,ts,tsx,json}": "prettier --write", }; From f721c8ac3bb6974dbf55e12dbb94eda6cc0d1f72 Mon Sep 17 00:00:00 2001 From: JayJay1024 Date: Wed, 10 Apr 2024 10:08:44 +0800 Subject: [PATCH 3/3] Fix cross-chain category config --- src/config/chains/crab.ts | 2 +- src/config/chains/darwinia.ts | 2 +- src/config/chains/ethereum.ts | 4 ++-- src/config/chains/sepolia.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/config/chains/crab.ts b/src/config/chains/crab.ts index b1b4a219..3b9c9a5b 100644 --- a/src/config/chains/crab.ts +++ b/src/config/chains/crab.ts @@ -69,7 +69,7 @@ export const crabChain: ChainConfig = { cross: [ { target: { network: "darwinia-dvm", symbol: "RING" }, - bridge: { category: "xtoken-crab-darwinia" }, + bridge: { category: "xtoken-darwinia-crab" }, action: "redeem", }, ], diff --git a/src/config/chains/darwinia.ts b/src/config/chains/darwinia.ts index cc3c77d6..a62e6b94 100644 --- a/src/config/chains/darwinia.ts +++ b/src/config/chains/darwinia.ts @@ -114,7 +114,7 @@ export const darwiniaChain: ChainConfig = { cross: [ { target: { network: "crab-dvm", symbol: "CRAB" }, - bridge: { category: "xtoken-darwinia-crab" }, + bridge: { category: "xtoken-crab-darwinia" }, action: "redeem", }, ], diff --git a/src/config/chains/ethereum.ts b/src/config/chains/ethereum.ts index a13de460..725a3d2d 100644 --- a/src/config/chains/ethereum.ts +++ b/src/config/chains/ethereum.ts @@ -52,7 +52,7 @@ export const ethereumChain: ChainConfig = { }, { target: { network: "darwinia-dvm", symbol: "RING" }, - bridge: { category: "xtoken-ethereum-darwinia" }, + bridge: { category: "xtoken-darwinia-ethereum" }, action: "redeem", }, ], @@ -75,7 +75,7 @@ export const ethereumChain: ChainConfig = { }, { target: { network: "darwinia-dvm", symbol: "KTON" }, - bridge: { category: "xtoken-ethereum-darwinia" }, + bridge: { category: "xtoken-darwinia-ethereum" }, action: "redeem", }, ], diff --git a/src/config/chains/sepolia.ts b/src/config/chains/sepolia.ts index 394bc008..2c0fcded 100644 --- a/src/config/chains/sepolia.ts +++ b/src/config/chains/sepolia.ts @@ -47,7 +47,7 @@ export const sepoliaChain: ChainConfig = { cross: [ { target: { network: "pangolin-dvm", symbol: "PRING" }, - bridge: { category: "xtoken-sepolia-pangolin" }, + bridge: { category: "xtoken-pangolin-sepolia" }, action: "redeem", }, ],