Skip to content

Commit

Permalink
change configuration so entire app can point to diff networks easily
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhorsey committed Dec 22, 2022
1 parent 78f9c36 commit 77c88e2
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 28 deletions.
8 changes: 8 additions & 0 deletions packages/bridge-ui/.default.env
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ VITE_TEST_ERC20_ADDRESS_MAINNET=""
VITE_MAINNET_TOKEN_VAULT_ADDRESS=""
VITE_TAIKO_TOKEN_VAULT_ADDRESS=""
VITE_TEST_ERC20_ADDRESS_MAINNET=""
VITE_MAINNET_CHAIN_ID=
VITE_TAIKO_CHAIN_ID=
VITE_MAINNET_CHAIN_NAME=
VITE_TAIKO_CHAIN_NAME=
VITE_TAIKO_HEADER_SYNC_ADDRESS=
VITE_MAINNET_HEADER_SYNC_ADDRESS=
VITE_MAINNET_BRIDGE_ADDRESS=
VITE_TAIKO_BRIDGE_ADDRESS=
13 changes: 9 additions & 4 deletions packages/bridge-ui/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
setupI18n({ withLocale: "en" });
import {
chains,
CHAIN_ID_MAINNET,
CHAIN_ID_TAIKO,
CHAIN_MAINNET,
CHAIN_TKO,
mainnet,
Expand All @@ -53,12 +55,17 @@
number,
ethers.providers.JsonRpcProvider
>();
const p = new ethers.providers.JsonRpcProvider(
import.meta.env.VITE_L1_RPC_URL
);
providerMap.set(
CHAIN_MAINNET.id,
CHAIN_ID_MAINNET,
new ethers.providers.JsonRpcProvider(import.meta.env.VITE_L1_RPC_URL)
);
providerMap.set(
CHAIN_TKO.id,
CHAIN_ID_TAIKO,
new ethers.providers.JsonRpcProvider(import.meta.env.VITE_L2_RPC_URL)
);
providers.set(providerMap);
Expand Down Expand Up @@ -122,8 +129,6 @@
return store;
});
// const relayerURL = import.meta.env.VITE_RELAYER_URL;
const storageTransactioner: Transactioner = new StorageService(
window.localStorage,
providerMap
Expand Down
42 changes: 30 additions & 12 deletions packages/bridge-ui/src/domain/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ import type { ComponentType } from "svelte";
import Eth from "../components/icons/ETH.svelte";
import Taiko from "../components/icons/TKO.svelte";

export const CHAIN_ID_MAINNET = import.meta.env
? import.meta.env.VITE_MAINNET_CHAIN_ID
: 31336;

export const CHAIN_ID_TAIKO = import.meta.env
? import.meta.env.VITE_TAIKO_CHAIN_ID
: 167001;

export type Chain = {
id: number;
name: string;
Expand All @@ -16,34 +24,44 @@ export type Chain = {
};

export const CHAIN_MAINNET = {
id: 31336,
name: "Ethereum A1",
id: CHAIN_ID_MAINNET,
name: import.meta.env
? import.meta.env.VITE_MAINNET_CHAIN_NAME
: "Ethereum A1",
rpc: "https://l1rpc.a1.taiko.xyz",
enabled: true,
icon: Eth,
bridgeAddress: "0x0237443359aB0b11EcDC41A7aF1C90226a88c70f",
headerSyncAddress: "0xa7dF1d30f6456Dc72cE18fE011896105651a1f86",
bridgeAddress: import.meta.env
? import.meta.env.VITE_MAINNET_BRIDGE_ADDRESS
: "0x3612E284D763f42f5E4CB72B1602b23DAEC3cA60",
headerSyncAddress: import.meta.env
? import.meta.env.VITE_MAINNET_HEADER_SYNC_ADDRESS
: "0x7B3AF414448ba906f02a1CA307C56c4ADFF27ce7",
explorerUrl: "https://l1explorer.a1.taiko.xyz",
};

export const CHAIN_TKO = {
id: 167001,
name: "Taiko A1",
id: CHAIN_ID_TAIKO,
name: import.meta.env ? import.meta.env.VITE_TAIKO_CHAIN_NAME : "Taiko A1",
rpc: "https://l2rpc.a1.taiko.xyz",
enabled: true,
icon: Taiko,
bridgeAddress: "0x0000777700000000000000000000000000000004",
headerSyncAddress: "0x0000777700000000000000000000000000000001",
bridgeAddress: import.meta.env
? import.meta.env.VITE_TAIKO_BRIDGE_ADDRESS
: "0x0000777700000000000000000000000000000004",
headerSyncAddress: import.meta.env
? import.meta.env.VITE_TAIKO_HEADER_SYNC_ADDRESS
: "0x0000777700000000000000000000000000000001",
explorerUrl: "https://l2explorer.a1.taiko.xyz",
};

export const chains: Record<string, Chain> = {
31336: CHAIN_MAINNET,
167001: CHAIN_TKO,
CHAIN_ID_MAINNET: CHAIN_MAINNET,
CHAIN_ID_TAIKO: CHAIN_TKO,
};

export const mainnet: WagmiChain = {
id: 31336,
id: CHAIN_ID_MAINNET,
name: "Ethereum A1",
network: "",
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
Expand All @@ -64,7 +82,7 @@ export const mainnet: WagmiChain = {
};

export const taiko: WagmiChain = {
id: 167001,
id: CHAIN_ID_TAIKO,
name: "Taiko A1",
network: "",
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
Expand Down
8 changes: 2 additions & 6 deletions packages/bridge-ui/src/erc20/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,9 @@ class ERC20Bridge implements Bridge {
chains[opts.message.destChainId.toNumber()].headerSyncAddress,
});

return await contract.processMessage(opts.message, proof, {
gasLimit: 3500000,
});
return await contract.processMessage(opts.message, proof);
} else {
return await contract.retryMessage(opts.message, false, {
gasLimit: 3500000,
});
return await contract.retryMessage(opts.message, false);
}
}
}
Expand Down
8 changes: 2 additions & 6 deletions packages/bridge-ui/src/eth/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,9 @@ class ETHBridge implements BridgeInterface {

const proof = await this.prover.GenerateProof(proofOpts);

return await contract.processMessage(opts.message, proof, {
gasLimit: opts.message.gasLimit.add(1000000),
});
return await contract.processMessage(opts.message, proof);
} else {
return await contract.retryMessage(opts.message, {
gasLimit: opts.message.gasLimit.add(1000000),
});
return await contract.retryMessage(opts.message);
}
}
}
Expand Down

0 comments on commit 77c88e2

Please sign in to comment.