diff --git a/CHANGELOG.md b/CHANGELOG.md index 34cc79f..82b935c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -628,4 +628,11 @@ ### 2.4.6 (2024-02-2) -* Updated recover vault to handle recurring addresses in logs \ No newline at end of file +* Updated recover vault to handle recurring addresses in logs + +### 2.5.0 (2024-02-15) + +##### [BREAKING Changes] Removed getAssets() method + +* Removed function `getAssets()` to get the list of assets of all the accounts associated as it is moved to an api service. +* Updated avalanche, base and zkEVM controllers. \ No newline at end of file diff --git a/README.md b/README.md index 956b50f..812b4a8 100644 --- a/README.md +++ b/README.md @@ -191,17 +191,6 @@ This method is used to get the list of all the accounts (`imported` and `generat * `encryptionKey` - The encryption key used to encrypt/decrypt the vault. -Get Assets: -This method returns the list of assets for all the addresses on all the chains passed in the array. - - `const assets = await vault.getAssets({ addresses, chains, EthRpcUrl, polygonRpcUrl, bscRpcUrl });` - -* `addresses` - The list of addresses in an array. -* `chains` - The list of chains in an array. -* `EthRpcUrl` - Ethereum RPC URL. -* `PolygonRpcUrl` - Polygon RPC URL. -* `bscRpcUrl` - BSC RPC URL. - Get Native Asset Balance: This method is used to get the native asset balance of an address present in the vault. diff --git a/package-lock.json b/package-lock.json index cd41a58..63a17fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,27 +1,26 @@ { "name": "@getsafle/safle-vault", - "version": "2.4.6", + "version": "2.5.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "2.4.6", + "version": "2.5.0", "license": "MIT", "dependencies": { - "@getsafle/asset-controller": "^1.0.10", "@getsafle/safle-identity-wallet": "^1.3.0", "@getsafle/transaction-controller": "^1.9.3", "@getsafle/vault-arbitrum-controller": "^1.0.8", - "@getsafle/vault-avalanche-controller": "^1.2.1", - "@getsafle/vault-base-controller": "^1.0.1", + "@getsafle/vault-avalanche-controller": "^1.2.2", + "@getsafle/vault-base-controller": "^1.0.2", "@getsafle/vault-bitcoin-controller": "^2.0.7", "@getsafle/vault-bsc-controller": "^1.2.4", "@getsafle/vault-eth-controller": "^1.4.6", "@getsafle/vault-mantle-controller": "^1.0.1", "@getsafle/vault-optimism-controller": "^1.0.8", "@getsafle/vault-polygon-controller": "^1.2.8", - "@getsafle/vault-polygon-zkevm-controller": "^1.0.0", + "@getsafle/vault-polygon-zkevm-controller": "^1.0.1", "@getsafle/vault-velas-controller": "^1.3.1", "bip39": "^3.0.4", "crypto-js": "^4.1.1", @@ -736,17 +735,6 @@ "ethereumjs-util": "^7.1.3" } }, - "node_modules/@ethereumjs/rlp": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@ethereumjs/rlp/-/rlp-5.0.1.tgz", - "integrity": "sha512-Ab/Hfzz+T9Zl+65Nkg+9xAmwKPLicsnQ4NW49pgvJp9ovefuic95cgOS9CbPc9izIEgsqm1UitV0uNveCvud9w==", - "bin": { - "rlp": "bin/rlp.cjs" - }, - "engines": { - "node": ">=18" - } - }, "node_modules/@ethereumjs/tx": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/@ethereumjs/tx/-/tx-3.3.2.tgz", @@ -756,48 +744,6 @@ "ethereumjs-util": "^7.1.2" } }, - "node_modules/@ethereumjs/util": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/@ethereumjs/util/-/util-9.0.1.tgz", - "integrity": "sha512-NdFFEzCc3H1sYkNnnySwLg6owdQMhjUc2jfuDyx8Xv162WSluCnnSKouKOSG3njGNEyy2I9NmF8zTRDwuqpZWA==", - "dependencies": { - "@ethereumjs/rlp": "^5.0.1", - "ethereum-cryptography": "^2.1.2" - }, - "engines": { - "node": ">=18" - }, - "peerDependencies": { - "c-kzg": "^2.1.2" - }, - "peerDependenciesMeta": { - "c-kzg": { - "optional": true - } - } - }, - "node_modules/@ethereumjs/util/node_modules/@noble/hashes": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz", - "integrity": "sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==", - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@ethereumjs/util/node_modules/ethereum-cryptography": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-2.1.2.tgz", - "integrity": "sha512-Z5Ba0T0ImZ8fqXrJbpHcbpAvIswRte2wGNR/KePnu8GbbvgJ47lMxT/ZZPG6i9Jaht4azPDop4HaM00J0J59ug==", - "dependencies": { - "@noble/curves": "1.1.0", - "@noble/hashes": "1.3.1", - "@scure/bip32": "1.3.1", - "@scure/bip39": "1.2.1" - } - }, "node_modules/@ethersproject/abi": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.7.0.tgz", @@ -1504,24 +1450,6 @@ "@ethersproject/strings": "^5.7.0" } }, - "node_modules/@getsafle/asset-controller": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/@getsafle/asset-controller/-/asset-controller-1.0.10.tgz", - "integrity": "sha512-B64hno0nSSCZc3aQOI9788SLYSPEHSc9Z7gRGTw7xhqzhy5xQsnQYcmQMAg4upOmTNf9cbTBSnr4WtUt2ur0lA==", - "dependencies": { - "@metamask/contract-metadata": "^1.24.0", - "axios": "^0.24.0", - "web3": "^1.2.1" - } - }, - "node_modules/@getsafle/asset-controller/node_modules/axios": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz", - "integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==", - "dependencies": { - "follow-redirects": "^1.14.4" - } - }, "node_modules/@getsafle/custom-token-controller": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/@getsafle/custom-token-controller/-/custom-token-controller-1.0.7.tgz", @@ -1607,12 +1535,12 @@ } }, "node_modules/@getsafle/vault-avalanche-controller": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@getsafle/vault-avalanche-controller/-/vault-avalanche-controller-1.2.1.tgz", - "integrity": "sha512-Thv9w5xJrn9LSSZvs/aCpp+AOd9GNZA4Dn/Qisx+3Zwg8QxMB2++1FgXJPs1yCudQ3JTicBgV7beivS3vNhD5A==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@getsafle/vault-avalanche-controller/-/vault-avalanche-controller-1.2.2.tgz", + "integrity": "sha512-rCen9PLk7R+fIttzq9mKL1EbnpRBZJpWkohSJV7FA3PBzRttrCUSM2/VGPgh1/bd7XV+Vx81z5/Bp4xa2D1Oyw==", "dependencies": { "@avalabs/avalanchejs": "^3.17.0", - "@ethereumjs/tx": "^5.1.0", + "@ethereumjs/tx": "^3.4.0", "avalanche": "^3.16.0", "bip39": "^3.0.4", "browser-passworder": "^2.0.3", @@ -1631,105 +1559,29 @@ } }, "node_modules/@getsafle/vault-avalanche-controller/node_modules/@ethereumjs/common": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@ethereumjs/common/-/common-4.1.0.tgz", - "integrity": "sha512-XWdQvUjlQHVwh4uGEPFKHpsic69GOsMXEhlHrggS5ju/+2zAmmlz6B25TkCCymeElC9DUp13tH5Tc25Iuvtlcg==", + "version": "2.6.5", + "resolved": "https://registry.npmjs.org/@ethereumjs/common/-/common-2.6.5.tgz", + "integrity": "sha512-lRyVQOeCDaIVtgfbowla32pzeDv2Obr8oR8Put5RdUBNRGr1VGPGQNGP6elWIpgK3YdpzqTOh4GyUGOureVeeA==", "dependencies": { - "@ethereumjs/util": "^9.0.1", - "crc": "^4.3.2" + "crc-32": "^1.2.0", + "ethereumjs-util": "^7.1.5" } }, "node_modules/@getsafle/vault-avalanche-controller/node_modules/@ethereumjs/tx": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/@ethereumjs/tx/-/tx-5.1.0.tgz", - "integrity": "sha512-VUhw2+4yXArJZRWhPjmZFrN4WUjUo0qUZUszVpW2KzsGlqCFf67kwJcH9Rca5eS0CRHjr2qHJLpvYOjNuaXVdA==", - "dependencies": { - "@ethereumjs/common": "^4.1.0", - "@ethereumjs/rlp": "^5.0.1", - "@ethereumjs/util": "^9.0.1", - "ethereum-cryptography": "^2.1.2" - }, - "engines": { - "node": ">=18" - }, - "peerDependencies": { - "c-kzg": "^2.1.2" - }, - "peerDependenciesMeta": { - "c-kzg": { - "optional": true - } - } - }, - "node_modules/@getsafle/vault-avalanche-controller/node_modules/@noble/hashes": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz", - "integrity": "sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==", - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@getsafle/vault-avalanche-controller/node_modules/buffer": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", - "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "optional": true, - "peer": true, + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/@ethereumjs/tx/-/tx-3.5.2.tgz", + "integrity": "sha512-gQDNJWKrSDGu2w7w0PzVXVBNMzb7wwdDOmOqczmhNjqFxFuIbhVJDwiGEnxFNC2/b8ifcZzY7MLcluizohRzNw==", "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.2.1" - } - }, - "node_modules/@getsafle/vault-avalanche-controller/node_modules/crc": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/crc/-/crc-4.3.2.tgz", - "integrity": "sha512-uGDHf4KLLh2zsHa8D8hIQ1H/HtFQhyHrc0uhHBcoKGol/Xnb+MPYfUMw7cvON6ze/GUESTudKayDcJC5HnJv1A==", - "engines": { - "node": ">=12" - }, - "peerDependencies": { - "buffer": ">=6.0.3" - }, - "peerDependenciesMeta": { - "buffer": { - "optional": true - } - } - }, - "node_modules/@getsafle/vault-avalanche-controller/node_modules/ethereum-cryptography": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-2.1.2.tgz", - "integrity": "sha512-Z5Ba0T0ImZ8fqXrJbpHcbpAvIswRte2wGNR/KePnu8GbbvgJ47lMxT/ZZPG6i9Jaht4azPDop4HaM00J0J59ug==", - "dependencies": { - "@noble/curves": "1.1.0", - "@noble/hashes": "1.3.1", - "@scure/bip32": "1.3.1", - "@scure/bip39": "1.2.1" + "@ethereumjs/common": "^2.6.4", + "ethereumjs-util": "^7.1.5" } }, "node_modules/@getsafle/vault-base-controller": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@getsafle/vault-base-controller/-/vault-base-controller-1.0.1.tgz", - "integrity": "sha512-YSAkmkuzVMm+9X7gi1WmnNiOWP3ViPFExDFyha+buddHuOYPehuSK0uoGqQvUQSOP0OuNZXj/zfIZavRyJ045Q==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@getsafle/vault-base-controller/-/vault-base-controller-1.0.2.tgz", + "integrity": "sha512-zOdGB7XEHa0kJSIcVife7OVysmRLkaMWwHyjsPo+OyfTQSG/ZDer3JuonPYclMxH0GgRwq8ZLpcR3k9euSJZow==", "dependencies": { - "@ethereumjs/tx": "^5.1.0", + "@ethereumjs/tx": "^3.4.0", "axios": "^1.6.2", "bip39": "^3.0.4", "browser-passworder": "^2.0.3", @@ -1745,45 +1597,21 @@ } }, "node_modules/@getsafle/vault-base-controller/node_modules/@ethereumjs/common": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@ethereumjs/common/-/common-4.1.0.tgz", - "integrity": "sha512-XWdQvUjlQHVwh4uGEPFKHpsic69GOsMXEhlHrggS5ju/+2zAmmlz6B25TkCCymeElC9DUp13tH5Tc25Iuvtlcg==", + "version": "2.6.5", + "resolved": "https://registry.npmjs.org/@ethereumjs/common/-/common-2.6.5.tgz", + "integrity": "sha512-lRyVQOeCDaIVtgfbowla32pzeDv2Obr8oR8Put5RdUBNRGr1VGPGQNGP6elWIpgK3YdpzqTOh4GyUGOureVeeA==", "dependencies": { - "@ethereumjs/util": "^9.0.1", - "crc": "^4.3.2" + "crc-32": "^1.2.0", + "ethereumjs-util": "^7.1.5" } }, "node_modules/@getsafle/vault-base-controller/node_modules/@ethereumjs/tx": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/@ethereumjs/tx/-/tx-5.1.0.tgz", - "integrity": "sha512-VUhw2+4yXArJZRWhPjmZFrN4WUjUo0qUZUszVpW2KzsGlqCFf67kwJcH9Rca5eS0CRHjr2qHJLpvYOjNuaXVdA==", + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/@ethereumjs/tx/-/tx-3.5.2.tgz", + "integrity": "sha512-gQDNJWKrSDGu2w7w0PzVXVBNMzb7wwdDOmOqczmhNjqFxFuIbhVJDwiGEnxFNC2/b8ifcZzY7MLcluizohRzNw==", "dependencies": { - "@ethereumjs/common": "^4.1.0", - "@ethereumjs/rlp": "^5.0.1", - "@ethereumjs/util": "^9.0.1", - "ethereum-cryptography": "^2.1.2" - }, - "engines": { - "node": ">=18" - }, - "peerDependencies": { - "c-kzg": "^2.1.2" - }, - "peerDependenciesMeta": { - "c-kzg": { - "optional": true - } - } - }, - "node_modules/@getsafle/vault-base-controller/node_modules/@noble/hashes": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz", - "integrity": "sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==", - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" + "@ethereumjs/common": "^2.6.4", + "ethereumjs-util": "^7.1.5" } }, "node_modules/@getsafle/vault-base-controller/node_modules/axios": { @@ -1796,58 +1624,6 @@ "proxy-from-env": "^1.1.0" } }, - "node_modules/@getsafle/vault-base-controller/node_modules/buffer": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", - "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "optional": true, - "peer": true, - "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.2.1" - } - }, - "node_modules/@getsafle/vault-base-controller/node_modules/crc": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/crc/-/crc-4.3.2.tgz", - "integrity": "sha512-uGDHf4KLLh2zsHa8D8hIQ1H/HtFQhyHrc0uhHBcoKGol/Xnb+MPYfUMw7cvON6ze/GUESTudKayDcJC5HnJv1A==", - "engines": { - "node": ">=12" - }, - "peerDependencies": { - "buffer": ">=6.0.3" - }, - "peerDependenciesMeta": { - "buffer": { - "optional": true - } - } - }, - "node_modules/@getsafle/vault-base-controller/node_modules/ethereum-cryptography": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-2.1.2.tgz", - "integrity": "sha512-Z5Ba0T0ImZ8fqXrJbpHcbpAvIswRte2wGNR/KePnu8GbbvgJ47lMxT/ZZPG6i9Jaht4azPDop4HaM00J0J59ug==", - "dependencies": { - "@noble/curves": "1.1.0", - "@noble/hashes": "1.3.1", - "@scure/bip32": "1.3.1", - "@scure/bip39": "1.2.1" - } - }, "node_modules/@getsafle/vault-bitcoin-controller": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/@getsafle/vault-bitcoin-controller/-/vault-bitcoin-controller-2.0.7.tgz", @@ -2141,12 +1917,10 @@ } }, "node_modules/@getsafle/vault-polygon-zkevm-controller": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@getsafle/vault-polygon-zkevm-controller/-/vault-polygon-zkevm-controller-1.0.0.tgz", - "integrity": "sha512-Ms9UpkVinCSjt6t8RLTMKh6xW3zRhx5EJ/BhDR0VBUk8HzI1WXP6fVXYcWdizeM3zuctyEGoxeVY8xgytgY6Dw==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@getsafle/vault-polygon-zkevm-controller/-/vault-polygon-zkevm-controller-1.0.1.tgz", + "integrity": "sha512-7tedAYQUiihzr32/eG/LkyW9mJWkDrfH1JaHshkuNl8pVen6tCeCddaogguT8CCZnHMzvEijTZ4BRcmLDXvUgg==", "dependencies": { - "@ethereumjs/common": "^4.1.0", - "@ethereumjs/tx": "^5.1.0", "axios": "^1.6.2", "bip39": "^3.0.4", "browser-passworder": "^2.0.3", @@ -2154,6 +1928,7 @@ "eth-hd-keyring": "^3.6.0", "eth-sig-util": "^3.0.1", "eth-simple-keyring": "^4.2.0", + "ethereumjs-tx": "^1.3.7", "ethereumjs-util": "^7.1.0", "hdkey": "^2.0.1", "loglevel": "^1.7.1", @@ -2161,48 +1936,6 @@ "web3": "^1.6.0" } }, - "node_modules/@getsafle/vault-polygon-zkevm-controller/node_modules/@ethereumjs/common": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@ethereumjs/common/-/common-4.1.0.tgz", - "integrity": "sha512-XWdQvUjlQHVwh4uGEPFKHpsic69GOsMXEhlHrggS5ju/+2zAmmlz6B25TkCCymeElC9DUp13tH5Tc25Iuvtlcg==", - "dependencies": { - "@ethereumjs/util": "^9.0.1", - "crc": "^4.3.2" - } - }, - "node_modules/@getsafle/vault-polygon-zkevm-controller/node_modules/@ethereumjs/tx": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/@ethereumjs/tx/-/tx-5.1.0.tgz", - "integrity": "sha512-VUhw2+4yXArJZRWhPjmZFrN4WUjUo0qUZUszVpW2KzsGlqCFf67kwJcH9Rca5eS0CRHjr2qHJLpvYOjNuaXVdA==", - "dependencies": { - "@ethereumjs/common": "^4.1.0", - "@ethereumjs/rlp": "^5.0.1", - "@ethereumjs/util": "^9.0.1", - "ethereum-cryptography": "^2.1.2" - }, - "engines": { - "node": ">=18" - }, - "peerDependencies": { - "c-kzg": "^2.1.2" - }, - "peerDependenciesMeta": { - "c-kzg": { - "optional": true - } - } - }, - "node_modules/@getsafle/vault-polygon-zkevm-controller/node_modules/@noble/hashes": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz", - "integrity": "sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==", - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, "node_modules/@getsafle/vault-polygon-zkevm-controller/node_modules/axios": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz", @@ -2213,56 +1946,28 @@ "proxy-from-env": "^1.1.0" } }, - "node_modules/@getsafle/vault-polygon-zkevm-controller/node_modules/buffer": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", - "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "optional": true, - "peer": true, + "node_modules/@getsafle/vault-polygon-zkevm-controller/node_modules/ethereumjs-tx": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/ethereumjs-tx/-/ethereumjs-tx-1.3.7.tgz", + "integrity": "sha512-wvLMxzt1RPhAQ9Yi3/HKZTn0FZYpnsmQdbKYfUUpi4j1SEIcbkd9tndVjcPrufY3V7j2IebOpC00Zp2P/Ay2kA==", + "deprecated": "New package name format for new versions: @ethereumjs/tx. Please update.", "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.2.1" - } - }, - "node_modules/@getsafle/vault-polygon-zkevm-controller/node_modules/crc": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/crc/-/crc-4.3.2.tgz", - "integrity": "sha512-uGDHf4KLLh2zsHa8D8hIQ1H/HtFQhyHrc0uhHBcoKGol/Xnb+MPYfUMw7cvON6ze/GUESTudKayDcJC5HnJv1A==", - "engines": { - "node": ">=12" - }, - "peerDependencies": { - "buffer": ">=6.0.3" - }, - "peerDependenciesMeta": { - "buffer": { - "optional": true - } + "ethereum-common": "^0.0.18", + "ethereumjs-util": "^5.0.0" } }, - "node_modules/@getsafle/vault-polygon-zkevm-controller/node_modules/ethereum-cryptography": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-2.1.2.tgz", - "integrity": "sha512-Z5Ba0T0ImZ8fqXrJbpHcbpAvIswRte2wGNR/KePnu8GbbvgJ47lMxT/ZZPG6i9Jaht4azPDop4HaM00J0J59ug==", + "node_modules/@getsafle/vault-polygon-zkevm-controller/node_modules/ethereumjs-tx/node_modules/ethereumjs-util": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.1.tgz", + "integrity": "sha512-v3kT+7zdyCm1HIqWlLNrHGqHGLpGYIhjeHxQjnDXjLT2FyGJDsd3LWMYUo7pAFRrk86CR3nUJfhC81CCoJNNGQ==", "dependencies": { - "@noble/curves": "1.1.0", - "@noble/hashes": "1.3.1", - "@scure/bip32": "1.3.1", - "@scure/bip39": "1.2.1" + "bn.js": "^4.11.0", + "create-hash": "^1.1.2", + "elliptic": "^6.5.2", + "ethereum-cryptography": "^0.1.3", + "ethjs-util": "^0.1.3", + "rlp": "^2.0.0", + "safe-buffer": "^5.1.1" } }, "node_modules/@getsafle/vault-velas-controller": { @@ -2640,36 +2345,6 @@ "@jridgewell/sourcemap-codec": "1.4.14" } }, - "node_modules/@metamask/contract-metadata": { - "version": "1.35.0", - "resolved": "https://registry.npmjs.org/@metamask/contract-metadata/-/contract-metadata-1.35.0.tgz", - "integrity": "sha512-zfZKwLFOVrQS8vTFoeoNCG9JhqmK4oyembGiGVVpUAYD9BHVZnd9WpicGoUC07ROXLEyQuAK9AJZNBtqwwzfEQ==", - "engines": { - "node": ">=12.0.0" - } - }, - "node_modules/@noble/curves": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.1.0.tgz", - "integrity": "sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA==", - "dependencies": { - "@noble/hashes": "1.3.1" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@noble/curves/node_modules/@noble/hashes": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz", - "integrity": "sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==", - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, "node_modules/@noble/hashes": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", @@ -2692,39 +2367,6 @@ } ] }, - "node_modules/@scure/base": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.3.tgz", - "integrity": "sha512-/+SgoRjLq7Xlf0CWuLHq2LUZeL/w65kfzAPG5NH9pcmBhs+nunQTn4gvdwgMTIXnt9b2C/1SeL2XiysZEyIC9Q==", - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@scure/bip32": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.3.1.tgz", - "integrity": "sha512-osvveYtyzdEVbt3OfwwXFr4P2iVBL5u1Q3q4ONBfDY/UpOuXmOlbgwc1xECEboY8wIays8Yt6onaWMUdUbfl0A==", - "dependencies": { - "@noble/curves": "~1.1.0", - "@noble/hashes": "~1.3.1", - "@scure/base": "~1.1.0" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@scure/bip39": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.2.1.tgz", - "integrity": "sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg==", - "dependencies": { - "@noble/hashes": "~1.3.0", - "@scure/base": "~1.1.0" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, "node_modules/@sinclair/typebox": { "version": "0.25.24", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.25.24.tgz", diff --git a/package.json b/package.json index 3b5d492..aada76a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "2.4.6", + "version": "2.5.0", "description": "Safle Vault is a non-custodial, flexible and highly available crypto wallet which can be used to access dapps, send/receive crypto and store identity. Vault SDK is used to manage the vault and provide methods to generate vault, add new accounts, update the state and also enable the user to perform several vault related operations.", "main": "src/index.js", "scripts": { @@ -44,19 +44,18 @@ "license": "MIT", "homepage": "https://github.com/getsafle/safle-vault#readme", "dependencies": { - "@getsafle/asset-controller": "^1.0.10", "@getsafle/safle-identity-wallet": "^1.3.0", "@getsafle/transaction-controller": "^1.9.3", "@getsafle/vault-arbitrum-controller": "^1.0.8", - "@getsafle/vault-avalanche-controller": "^1.2.1", - "@getsafle/vault-base-controller": "^1.0.1", + "@getsafle/vault-avalanche-controller": "^1.2.2", + "@getsafle/vault-base-controller": "^1.0.2", "@getsafle/vault-bitcoin-controller": "^2.0.7", "@getsafle/vault-bsc-controller": "^1.2.4", "@getsafle/vault-eth-controller": "^1.4.6", "@getsafle/vault-mantle-controller": "^1.0.1", "@getsafle/vault-optimism-controller": "^1.0.8", "@getsafle/vault-polygon-controller": "^1.2.8", - "@getsafle/vault-polygon-zkevm-controller": "^1.0.0", + "@getsafle/vault-polygon-zkevm-controller": "^1.0.1", "@getsafle/vault-velas-controller": "^1.3.1", "bip39": "^3.0.4", "crypto-js": "^4.1.1", diff --git a/src/lib/keyring.js b/src/lib/keyring.js index 75ae291..6ce7e08 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -806,16 +806,6 @@ class Keyring { return { response: accounts }; } - async getAssets({ addresses, chains, EthRpcUrl, polygonRpcUrl, bscRpcUrl }) { - if (!Array.isArray(addresses) && !Array.isArray(chains)) { - throw ERROR_MESSAGE.SHOULD_BE_AN_ARRAY; - } - - const assetsDetails = await helper.getAssetDetails({ addresses, chains, EthRpcUrl, polygonRpcUrl, bscRpcUrl }); - - return { response: assetsDetails }; - } - async getBalance(address, rpcUrl) { if (Chains.evmChains.hasOwnProperty(this.chain)) { const web3 = new Web3(new Web3.providers.HttpProvider(rpcUrl)); diff --git a/src/lib/test/keyring.test.js b/src/lib/test/keyring.test.js index c192210..d8580d7 100644 --- a/src/lib/test/keyring.test.js +++ b/src/lib/test/keyring.test.js @@ -848,155 +848,6 @@ describe('sign',()=>{ }) -describe('getAssets',()=>{ - - test('getAssets/valid' , async()=>{ - let addressArray=[] - addressArray.push(accAddress) - let result = await vault.getAssets({addresses:["0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd"],chains:["ethereum","polygon"],EthRpcUrl:ethUrl,polygonRpcUrl:polygonRpcUrl,bscRpcUrl:bscRpcUrl}) - expect(result.response).toHaveProperty('0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd') - - - }) - - test('getAssets/empty address array' , async()=>{ - let addressArray=[] - addressArray.push(accAddress) - try{ - let result = await vault.getAssets({addresses:null,chains:chains,EthRpcUrl:ethUrl,polygonRpcUrl:polygonRpcUrl,bscRpcUrl:bscRpcUrl}) - - } - catch(e){ - expect(e.message).toBe("Cannot read properties of null (reading 'length')") - } - - - }) - - test('getAssets/invalid address array' , async()=>{ - let addressArray=[] - addressArray.push(accAddress) - try{ - let result = await vault.getAssets({addresses:["afqaefwef"],chains:chains,EthRpcUrl:ethUrl,polygonRpcUrl:polygonRpcUrl,bscRpcUrl:bscRpcUrl}) - } - catch(e){ - expect(e.message).toBe("Cannot read properties of null (reading 'length')") - } - - - }) - - test('getAssets/empty chains' , async()=>{ - let addressArray=[] - addressArray.push(accAddress) - try{ - let result = await vault.getAssets({addresses:[accAddress],chains:null,EthRpcUrl:ethUrl,polygonRpcUrl:polygonRpcUrl,bscRpcUrl:bscRpcUrl}) - } - catch(e){ - expect(e.message).toBe("Cannot read properties of null (reading 'length')") - } - - - }) - test('getAssets/invalid chain type' , async()=>{ - let addressArray=[] - addressArray.push(accAddress) - try{ - let result = await vault.getAssets({addresses:[accAddress],chains:"isbsi",EthRpcUrl:ethUrl,polygonRpcUrl:polygonRpcUrl,bscRpcUrl:bscRpcUrl}) - expect(result.response).toHaveProperty(accAddress) - } - catch(e){ - expect(e.message).toBe("Cannot destructure property 'supportedChains' of 'output' as it is undefined") - } - - - - - - - }) - test('getAssets/invalid chain' , async()=>{ - let addressArray=[] - addressArray.push(accAddress) - - let result = await vault.getAssets({addresses:[accAddress],chains:["isbsi"],EthRpcUrl:ethUrl,polygonRpcUrl:polygonRpcUrl,bscRpcUrl:bscRpcUrl}) - expect(result.response).toHaveProperty(accAddress) - - - }) - test('getAssets/empty EthRpcUrl' , async()=>{ - let addressArray=[] - addressArray.push(accAddress) - - let result = await vault.getAssets({addresses:[accAddress],chains:chains,EthRpcUrl:null,polygonRpcUrl:polygonRpcUrl,bscRpcUrl:bscRpcUrl}) - expect(result.response).toHaveProperty(accAddress) - - - - - - }) - test('getAssets/invalid EthRpcUrl' , async()=>{ - let addressArray=[] - addressArray.push(accAddress) - - let result = await vault.getAssets({addresses:[accAddress],chains:chains,EthRpcUrl:"https://1.com",polygonRpcUrl:polygonRpcUrl,bscRpcUrl:bscRpcUrl}) - expect(result.response).toHaveProperty(accAddress) - - - - - - }) - - test('getAssets/empty polygonRpcUrl' , async()=>{ - let addressArray=[] - addressArray.push(accAddress) - - let result = await vault.getAssets({addresses:[accAddress],chains:chains,EthRpcUrl:ethUrl,polygonRpcUrl:null,bscRpcUrl:bscRpcUrl}) - expect(result.response).toHaveProperty(accAddress) - - - }) - test('getAssets/invalid polygonRpcUrl' , async()=>{ - let addressArray=[] - addressArray.push(accAddress) - - let result = await vault.getAssets({addresses:[accAddress],chains:chains,EthRpcUrl:ethUrl,polygonRpcUrl:"efwegr",bscRpcUrl:bscRpcUrl}) - expect(result.response).toHaveProperty(accAddress) - - - }) - test('getAssets/empty bscRpcUrl' , async()=>{ - let addressArray=[] - addressArray.push(accAddress) - - let result = await vault.getAssets({addresses:[accAddress],chains:chains,EthRpcUrl:ethUrl,polygonRpcUrl:polygonRpcUrl,bscRpcUrl:null}) - expect(result.response).toHaveProperty(accAddress) - - - }) - test('getAssets/invalid bscRpcUrl' , async()=>{ - let addressArray=[] - addressArray.push(accAddress) - - let result = await vault.getAssets({addresses:[accAddress],chains:chains,EthRpcUrl:ethUrl,polygonRpcUrl:polygonRpcUrl,bscRpcUrl:"eafrsgrs"}) - expect(result.response).toHaveProperty(accAddress) - - - }) - test('getAssets/all params empty' , async()=>{ - try{ - let result = await vault.getAssets({addresses:null,chains:null,EthRpcUrl:null,polygonRpcUrl:null,bscRpcUrl:null}) - } - catch(e){ - expect(e).toBe('Addresses and chains should be an array') - } - - - }) -}) - describe('validateMnemonic',()=>{ let signUpPhrase='ladder equip piano open silent pizza solid cannon name volcano fee valley' test('validateMnemonic/valid' , async()=>{ diff --git a/src/utils/helper.js b/src/utils/helper.js index 68eb121..234b156 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -1,7 +1,6 @@ const cryptojs = require('crypto-js'); const safleTransactionController = require('@getsafle/transaction-controller'); const Web3 = require('web3'); -const { AssetController } = require('@getsafle/asset-controller'); const Chains = require('../chains'); const ERROR_MESSAGE = require('../constants/responses'); @@ -199,61 +198,6 @@ async function getCoinInstance(chain, mnemonic) { return keyringInstance; } -async function getAssetDetails({ addresses, chains, EthRpcUrl, polygonRpcUrl, bscRpcUrl }) { - - let output = { }; - let chainAssets = []; - - for (let j = 0; j < addresses.length; j++) { - for (let i = 0; i < chains.length; i++) { - - if (chains[i] === 'ethereum') { - const assets = await getEthAssets(addresses[j], EthRpcUrl); - - chainAssets.push({ 'ethereum': { ...assets } }); - } else if (chains[i] === 'bsc') { - const assets = await getBSCAssets(addresses[j], bscRpcUrl); - - chainAssets.push({ 'bsc': { ...assets } }); - } else { - const assets = await getPolygonAssets(addresses[j], polygonRpcUrl); - - chainAssets.push({ 'polygon': { ...assets } }); - } - } - - output[addresses[j]] = { ...chainAssets }; - - chainAssets = []; - } - - return output; -} - -async function getEthAssets(address, ethRpcUrl) { - const assetController = new AssetController({ rpcURL: ethRpcUrl, chain: 'ethereum' }); - - const tokens = await assetController.detectTokens({ userAddress: address }); - - return tokens; -} - -async function getPolygonAssets(address, polygonRpcUrl) { - const assetController = new AssetController({ rpcURL: polygonRpcUrl, chain: 'polygon' }); - - const tokens = await assetController.detectTokens({ userAddress: address }); - - return tokens; -} - -async function getBSCAssets(address, bscRpcUrl) { - const assetController = new AssetController({ rpcURL: bscRpcUrl, chain: 'bsc' }); - - const tokens = await assetController.detectTokens({ userAddress: address }); - - return tokens; -} - async function cryptography(data, key, action) { let output; @@ -312,7 +256,6 @@ module.exports = { removeEmptyAccounts, getAccountsFromLogs, getCoinInstance, - getAssetDetails, cryptography, validateEncryptionKey, createWalletLabels