diff --git a/package-lock.json b/package-lock.json index d08de14..8d91468 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,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", @@ -1933,6 +1934,204 @@ "proxy-from-env": "^1.1.0" } }, + "node_modules/@getsafle/vault-evm-controller": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@getsafle/vault-evm-controller/-/vault-evm-controller-1.0.0.tgz", + "integrity": "sha512-AHL1gJNEdMdvX7iBNNpKxXA3bm8YYggpGywJ9untiyBRwZiSVXuUMmCPbqe23me8Lk1nxyl0TLyDw33iq0SIoQ==", + "license": "MIT", + "dependencies": { + "@ethereumjs/common": "2.6.0", + "@ethereumjs/tx": "^3.4.0", + "axios": "^1.6.2", + "bip39": "^3.0.4", + "browser-passworder": "^2.0.3", + "crypto": "^1.0.1", + "crypto-js": "^4.2.0", + "eth-hd-keyring": "^3.6.0", + "eth-sig-util": "^3.0.1", + "eth-simple-keyring": "^4.2.0", + "ethereumjs-abi": "^0.6.8", + "ethereumjs-tx": "^2.1.2", + "ethereumjs-util": "^7.1.5", + "events": "^3.3.0", + "loglevel": "^1.7.1", + "nyc": "^17.0.0", + "obs-store": "^4.0.3", + "web3": "^1.6.0" + } + }, + "node_modules/@getsafle/vault-evm-controller/node_modules/@ethereumjs/tx": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/@ethereumjs/tx/-/tx-3.5.2.tgz", + "integrity": "sha512-gQDNJWKrSDGu2w7w0PzVXVBNMzb7wwdDOmOqczmhNjqFxFuIbhVJDwiGEnxFNC2/b8ifcZzY7MLcluizohRzNw==", + "license": "MPL-2.0", + "dependencies": { + "@ethereumjs/common": "^2.6.4", + "ethereumjs-util": "^7.1.5" + } + }, + "node_modules/@getsafle/vault-evm-controller/node_modules/@ethereumjs/tx/node_modules/@ethereumjs/common": { + "version": "2.6.5", + "resolved": "https://registry.npmjs.org/@ethereumjs/common/-/common-2.6.5.tgz", + "integrity": "sha512-lRyVQOeCDaIVtgfbowla32pzeDv2Obr8oR8Put5RdUBNRGr1VGPGQNGP6elWIpgK3YdpzqTOh4GyUGOureVeeA==", + "license": "MIT", + "dependencies": { + "crc-32": "^1.2.0", + "ethereumjs-util": "^7.1.5" + } + }, + "node_modules/@getsafle/vault-evm-controller/node_modules/axios": { + "version": "1.7.7", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", + "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/@getsafle/vault-evm-controller/node_modules/cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "license": "ISC", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "node_modules/@getsafle/vault-evm-controller/node_modules/convert-source-map": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", + "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", + "license": "MIT" + }, + "node_modules/@getsafle/vault-evm-controller/node_modules/istanbul-lib-instrument": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.3.tgz", + "integrity": "sha512-Vtgk7L/R2JHyyGW07spoFlB8/lpjiOLTjMdms6AFMraYt3BaJauod/NGrfnVG/y4Ix1JEuMRPDPEj2ua+zz1/Q==", + "license": "BSD-3-Clause", + "dependencies": { + "@babel/core": "^7.23.9", + "@babel/parser": "^7.23.9", + "@istanbuljs/schema": "^0.1.3", + "istanbul-lib-coverage": "^3.2.0", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@getsafle/vault-evm-controller/node_modules/nyc": { + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/nyc/-/nyc-17.0.0.tgz", + "integrity": "sha512-ISp44nqNCaPugLLGGfknzQwSwt10SSS5IMoPR7GLoMAyS18Iw5js8U7ga2VF9lYuMZ42gOHr3UddZw4WZltxKg==", + "license": "ISC", + "dependencies": { + "@istanbuljs/load-nyc-config": "^1.0.0", + "@istanbuljs/schema": "^0.1.2", + "caching-transform": "^4.0.0", + "convert-source-map": "^1.7.0", + "decamelize": "^1.2.0", + "find-cache-dir": "^3.2.0", + "find-up": "^4.1.0", + "foreground-child": "^2.0.0", + "get-package-type": "^0.1.0", + "glob": "^7.1.6", + "istanbul-lib-coverage": "^3.0.0", + "istanbul-lib-hook": "^3.0.0", + "istanbul-lib-instrument": "^6.0.2", + "istanbul-lib-processinfo": "^2.0.2", + "istanbul-lib-report": "^3.0.0", + "istanbul-lib-source-maps": "^4.0.0", + "istanbul-reports": "^3.0.2", + "make-dir": "^3.0.0", + "node-preload": "^0.2.1", + "p-map": "^3.0.0", + "process-on-spawn": "^1.0.0", + "resolve-from": "^5.0.0", + "rimraf": "^3.0.0", + "signal-exit": "^3.0.2", + "spawn-wrap": "^2.0.0", + "test-exclude": "^6.0.0", + "yargs": "^15.0.2" + }, + "bin": { + "nyc": "bin/nyc.js" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@getsafle/vault-evm-controller/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@getsafle/vault-evm-controller/node_modules/wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@getsafle/vault-evm-controller/node_modules/y18n": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", + "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", + "license": "ISC" + }, + "node_modules/@getsafle/vault-evm-controller/node_modules/yargs": { + "version": "15.4.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", + "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "license": "MIT", + "dependencies": { + "cliui": "^6.0.0", + "decamelize": "^1.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@getsafle/vault-evm-controller/node_modules/yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "license": "ISC", + "dependencies": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/@getsafle/vault-mantle-controller": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@getsafle/vault-mantle-controller/-/vault-mantle-controller-1.0.1.tgz", @@ -5603,6 +5802,13 @@ "node": ">= 8" } }, + "node_modules/crypto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz", + "integrity": "sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==", + "deprecated": "This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in.", + "license": "ISC" + }, "node_modules/crypto-browserify": { "version": "3.12.0", "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", diff --git a/package.json b/package.json index 34847ca..6be5a31 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/chains/index.js b/src/chains/index.js index b5db95f..ba2bccf 100644 --- a/src/chains/index.js +++ b/src/chains/index.js @@ -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; + // }, };