Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support celo testnet #868

Merged
merged 2 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/helixbox-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Binary file added apps/helixbox-app/public/images/network/celo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 62 additions & 0 deletions apps/helixbox-app/src/config/chains/celo-testnet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { HelixChain } from "@helixbridge/helixconf";
import { BridgeV2Type, ChainConfig, Network } from "../../types";
import { Address } from "viem";
import { celoAlfajores } from "viem/chains";

const chain = HelixChain.celoTestnet;
const tokens = chain.tokens.map((token) => {
const couples = chain.filterCouples({ symbolFrom: token.symbol });
const category = couples.at(0)?.category ?? "Others";

const routes = new Set<string>();
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,
};
1 change: 1 addition & 0 deletions apps/helixbox-app/src/config/chains/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ export * from "./zircuit";
export * from "./zircuit-sepolia";
export * from "./morph-testnet";
export * from "./morph";
export * from "./celo-testnet";
4 changes: 3 additions & 1 deletion apps/helixbox-app/src/types/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export enum ChainID {
AVALANCHE = 43_114,
ZIRCUIT = 48900,
ZIRCUIT_SEPOLIA = 48899,
CELO_TESTNET = 44787,
}

// According to graphql indexer
Expand Down Expand Up @@ -65,7 +66,8 @@ export type Network =
| "avalanche"
| "zircuit"
| "zircuit-sepolia"
| "bsc";
| "bsc"
| "celo-testnet";

export interface ChainConfig extends Chain {
/**
Expand Down
5 changes: 5 additions & 0 deletions apps/helixbox-app/src/utils/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
zircuitSepoliaChain,
zksyncChain,
zksyncSepoliaChain,
celoTestChain,
} from "../config/chains";
import { ChainConfig, ChainID, Network } from "../types";
import { isMainnet } from "./env";
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -147,6 +151,7 @@ export function getChainConfigs(askAll?: boolean) {
avalancheChain,
zircuitChain,
zircuitSepoliaChain,
celoTestChain,
].sort((a, b) => a.name.localeCompare(b.name));

if (askAll) {
Expand Down
Binary file added packages/assets/images/chains/celo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 21 additions & 15 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading