-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #341 from getsafle/intialize_keyring_newvault
Intialize keyring newvault
- Loading branch information
Showing
4 changed files
with
542 additions
and
211 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}, | ||
}; |
Oops, something went wrong.