From b870e3ef6d5130c422c4f77d7dc791396e9ba1f2 Mon Sep 17 00:00:00 2001 From: Jay Date: Wed, 6 Nov 2024 11:07:05 +0800 Subject: [PATCH] Support celo testnet (#868) * Support celo testnet * Update chain name --- apps/helixbox-app/package.json | 2 +- .../public/images/network/celo.png | Bin 0 -> 4672 bytes .../src/config/chains/celo-testnet.ts | 62 ++++++++++++++++++ apps/helixbox-app/src/config/chains/index.ts | 1 + apps/helixbox-app/src/types/chain.ts | 4 +- apps/helixbox-app/src/utils/chain.ts | 5 ++ packages/assets/images/chains/celo.png | Bin 0 -> 4672 bytes pnpm-lock.yaml | 36 +++++----- 8 files changed, 93 insertions(+), 17 deletions(-) create mode 100644 apps/helixbox-app/public/images/network/celo.png create mode 100644 apps/helixbox-app/src/config/chains/celo-testnet.ts create mode 100644 packages/assets/images/chains/celo.png diff --git a/apps/helixbox-app/package.json b/apps/helixbox-app/package.json index e2815b29..8935b060 100644 --- a/apps/helixbox-app/package.json +++ b/apps/helixbox-app/package.json @@ -20,7 +20,7 @@ "dependencies": { "@apollo/client": "^3.10.3", "@floating-ui/react": "^0.26.14", - "@helixbridge/helixconf": "1.1.18", + "@helixbridge/helixconf": "v1.2.0-beta", "@reown/appkit": "^1.0.7", "@reown/appkit-adapter-wagmi": "^1.0.7", "@sentry/react": "^8.30.0", diff --git a/apps/helixbox-app/public/images/network/celo.png b/apps/helixbox-app/public/images/network/celo.png new file mode 100644 index 0000000000000000000000000000000000000000..593988ceea430524596e96b01cf4f70cc8de6076 GIT binary patch literal 4672 zcmV-G62I+opW#Zyh50m2O44R82kg)Bs@YbTeT%KWeM&smAKXeS!*A)wOhN8 zzoe8BQd%l%2^y)QL`lL!d_*%AR)n&I2`UkMFu@qeLozX$%uL_D=lFf++}qRL(>>ii z_tnYFFS&F3zRx}1`JU%H=L&QOY7aWPVXe|l?DA1994fMkh5i z;sgmq(;dVS|AuoJDG?@7g82I8ZCdL)(aEBz4TL(zbsu>E2_X@JoU`JoWr$%%Y#egl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()+=0QkK6W2N6t5aV znB@+f|9WMN!XevR35T?U*a^b0zKU~y^lsozg&5{QVO(5Mb!Q|9{-{_mpL_x52NL0m zN+e1U26Kz2#GTZQJA`u>tSh(|wb94C;zHsC332WcCOPp`_i0EO=Llg;!XW3UMRD@x zg478T!YF>oflksf>`!ohGpE!hEt(pap#xyPU84N0ju6+SOⓈnFu@_BUh1yo)tQR zAeAujG5$D!78?Y0hQ&=FCIAnR;X#%;nctn3ZfF%9N03@@PbJU3%@aQJytZ~)Tayu4 z(AN2^bwJ02=^7AY+El(e#4{vFDMlUm!&!- { + const couples = chain.filterCouples({ symbolFrom: token.symbol }); + const category = couples.at(0)?.category ?? "Others"; + + const routes = new Set(); + for (const couple of couples) { + routes.add(`${couple.chain.code}:${couple.symbol.from}:${couple.symbol.to}`); + } + + const cross = [...routes].map((route) => { + const [toChain, fromToken, toToken] = route.split(":"); + const lnv2 = couples.find( + (c) => + c.chain.code === toChain && + c.symbol.from === fromToken && + c.symbol.to === toToken && + (c.protocol.name === "lnv2-default" || c.protocol.name === "lnv2-opposite"), + ); + return { + target: { network: toChain as Network, symbol: toToken }, + bridge: { + category: "lnbridge" as const, + lnv2Type: (lnv2?.protocol.name === "lnv2-opposite" ? "opposite" : "default") as BridgeV2Type, + disableV2: !lnv2, + }, + }; + }); + return { ...token, name: token.symbol, address: token.address as Address, category, cross }; +}); + +if (chain.couples.length && !chain.tokens.some((t) => t.type === "native")) { + tokens.push({ + ...celoAlfajores.nativeCurrency, + logo: "https://raw.githubusercontent.com/helix-bridge/helix-ui/main/packages/assets/images/tokens/eth.png", + address: "0x0000000000000000000000000000000000000000", + category: "ETH", + type: "native", + cross: [], + alias: [], + }); +} + +export const celoTestChain: ChainConfig = { + /** + * Chain + */ + ...celoAlfajores, + network: "celo-testnet", + name: "Celo Alfajores", + + /** + * Custom + */ + logo: "celo.png", + tokens, +}; diff --git a/apps/helixbox-app/src/config/chains/index.ts b/apps/helixbox-app/src/config/chains/index.ts index 4ca288aa..de2e0292 100644 --- a/apps/helixbox-app/src/config/chains/index.ts +++ b/apps/helixbox-app/src/config/chains/index.ts @@ -25,3 +25,4 @@ export * from "./zircuit"; export * from "./zircuit-sepolia"; export * from "./morph-testnet"; export * from "./morph"; +export * from "./celo-testnet"; diff --git a/apps/helixbox-app/src/types/chain.ts b/apps/helixbox-app/src/types/chain.ts index 75687a50..d7db14c7 100644 --- a/apps/helixbox-app/src/types/chain.ts +++ b/apps/helixbox-app/src/types/chain.ts @@ -35,6 +35,7 @@ export enum ChainID { AVALANCHE = 43_114, ZIRCUIT = 48900, ZIRCUIT_SEPOLIA = 48899, + CELO_TESTNET = 44787, } // According to graphql indexer @@ -65,7 +66,8 @@ export type Network = | "avalanche" | "zircuit" | "zircuit-sepolia" - | "bsc"; + | "bsc" + | "celo-testnet"; export interface ChainConfig extends Chain { /** diff --git a/apps/helixbox-app/src/utils/chain.ts b/apps/helixbox-app/src/utils/chain.ts index 0e114460..2047395b 100644 --- a/apps/helixbox-app/src/utils/chain.ts +++ b/apps/helixbox-app/src/utils/chain.ts @@ -24,6 +24,7 @@ import { zircuitSepoliaChain, zksyncChain, zksyncSepoliaChain, + celoTestChain, } from "../config/chains"; import { ChainConfig, ChainID, Network } from "../types"; import { isMainnet } from "./env"; @@ -113,6 +114,9 @@ export function getChainConfig(chainIdOrNetwork?: ChainID | Network | null): Cha case ChainID.ZIRCUIT_SEPOLIA: case "zircuit-sepolia": return zircuitSepoliaChain; + case ChainID.CELO_TESTNET: + case "celo-testnet": + return celoTestChain; default: return; } @@ -147,6 +151,7 @@ export function getChainConfigs(askAll?: boolean) { avalancheChain, zircuitChain, zircuitSepoliaChain, + celoTestChain, ].sort((a, b) => a.name.localeCompare(b.name)); if (askAll) { diff --git a/packages/assets/images/chains/celo.png b/packages/assets/images/chains/celo.png new file mode 100644 index 0000000000000000000000000000000000000000..593988ceea430524596e96b01cf4f70cc8de6076 GIT binary patch literal 4672 zcmV-G62I+opW#Zyh50m2O44R82kg)Bs@Yb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