Skip to content

Commit

Permalink
Update chain intialization and controller imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Husienvora authored and Husienvora committed Sep 6, 2024
1 parent e009f52 commit 27cfd74
Show file tree
Hide file tree
Showing 3 changed files with 257 additions and 39 deletions.
206 changes: 206 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"@getsafle/vault-bitcoin-controller": "^2.0.7",
"@getsafle/vault-bsc-controller": "^1.2.4",
"@getsafle/vault-eth-controller": "^1.4.6",
"@getsafle/vault-evm-controller": "^1.0.0",
"@getsafle/vault-mantle-controller": "^1.0.1",
"@getsafle/vault-optimism-controller": "^1.0.8",
"@getsafle/vault-polygon-controller": "^1.2.8",
Expand Down
89 changes: 50 additions & 39 deletions src/chains/index.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,62 @@
const ethereum = require("@getsafle/vault-eth-controller");
const bsc = require("@getsafle/vault-bsc-controller");
const polygon = require("@getsafle/vault-polygon-controller");
const EvmController = require("@getsafle/vault-evm-controller");
const bitcoin = require("@getsafle/vault-bitcoin-controller");
const optimism = require("@getsafle/vault-optimism-controller");
const arbitrum = require("@getsafle/vault-arbitrum-controller");
const mantle = require("@getsafle/vault-mantle-controller");
const velas = require("@getsafle/vault-velas-controller");
const avalanche = require("@getsafle/vault-avalanche-controller");
const base = require("@getsafle/vault-base-controller");
const zkEVM = require("@getsafle/vault-polygon-zkevm-controller");
const stacks = require("@getsafle/vault-stacks-controller");
const solana = require("@getsafle/vault-sol-controller");
const bevm = require("@getsafle/vault-bevm-controller");
const rootstock = require("@getsafle/vault-rootstock-controller");

//we don't have to put rpc and chain id since our vault get web3 as a argument in all methods
const evmChains = {
ethereum: "ETH",
bsc: "BSC",
polygon: "MATIC",
optimism: "OP",
arbitrum: "ARB",
mantle: "MNT",
velas: "VLX",
avalanche: "AVAX",
base: "BASE",
zkEVM: "ZKEVM",
bevm: "BTC",
rootstock: "RBTC",
ethereum: { symbol: "ETH", txType: 2 },
bsc: { symbol: "BSC", txType: 0 },
polygon: { symbol: "MATIC", txType: 2 },
optimism: { symbol: "OP", txType: 2 },
arbitrum: { symbol: "ARB", txType: 2 },
mantle: { symbol: "MNT", txType: 2 },
velas: { symbol: "VLX", txType: 0 },
avalanche: { symbol: "AVAX", txType: 2 },
base: { symbol: "BASE", txType: 2 },
zkEVM: { symbol: "ZKEVM", txType: 2 },
bevm: { symbol: "BTC", txType: 0 },
rootstock: { symbol: "RBTC", txType: 0 },
};

const nonEvmChains = {
bitcoin: "BTC",
stacks: "STX",
solana: "SOL",
};
const nonEvmChains = { bitcoin: "BTC", stacks: "STX", solana: "SOL" };

// Create an object with all EVM chains using the same controller but initialized with the appropriate txType
const evmControllers = Object.entries(evmChains).reduce(
(acc, [chain, info]) => {
acc[chain] = EvmController;
return acc;
},
{}
);

// Create an object with just the symbols for EVM chains
const evmChainSymbols = Object.entries(evmChains).reduce(
(acc, [chain, info]) => {
acc[chain] = info.symbol;
return acc;
},
{}
);

module.exports = {
ethereum,
bsc,
polygon,
...evmControllers,
bitcoin,
optimism,
arbitrum,
mantle,
velas,
avalanche,
base,
zkEVM,
stacks,
solana,
bevm,
rootstock,
evmChains,
evmChains: evmChainSymbols,
nonEvmChains,
// getEvmChainInfo: (chain) => evmChains[chain],
// addEvmChain: (chainName, chainInfo) => {
// if (evmChains[chainName]) {
// throw new Error("Chain already exists");
// }
// evmChains[chainName] = chainInfo;
// evmControllers[chainName] = EvmController

// evmChainSymbols[chainName] = chainInfo.symbol;
// },
};

0 comments on commit 27cfd74

Please sign in to comment.