From 1fa2a14f65fdbeff668235c49192b7506ebeefbd Mon Sep 17 00:00:00 2001 From: SDargarh Date: Sat, 8 Jul 2023 20:47:07 +0530 Subject: [PATCH 01/98] update vault state with decryptedVault and rate limiting for pin validation --- CHANGELOG.md | 7 +- package-lock.json | 374 +------------------------------------------- package.json | 4 +- src/config/index.js | 2 +- src/lib/keyring.js | 24 +-- src/lib/vault.js | 18 ++- src/utils/helper.js | 2 +- 7 files changed, 38 insertions(+), 393 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0edbe8b..34387bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -511,4 +511,9 @@ * Updated all ethereum based controllers * Added new controllers for Mantle and Velas chain * Updated test cases according to new chain integrated -* Updated sign message for ethereum chain to filter message hash \ No newline at end of file +* Updated sign message for ethereum chain to filter message hash + +### 1.30.01 (2023-07-8) Nightly version : only for experimental use + +* Updated vault state with decryptedVault +* Updated rate limiting for pin validation, upto 10 \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index c3d3923..9abf4a4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "@getsafle/safle-vault", - "version": "1.30.0", + "version": "1.30.01", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "1.30.0", + "version": "1.30.01", "license": "MIT", "dependencies": { - "@getsafle/asset-controller": "^1.0.11", + "@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.7", @@ -1293,15 +1293,13 @@ } }, "node_modules/@getsafle/asset-controller": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@getsafle/asset-controller/-/asset-controller-1.0.11.tgz", - "integrity": "sha512-Xg37uXX4n9DSIN9GeCUaAcJaF9EpJp9Es5aMhcnVtJp22xOiSEhA2WlruWlLD/e29wjjNTBwRB8VXQgRgsbgNg==", + "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", - "dompurify": "^3.0.3", - "jsdom": "^22.0.0", - "web3": "^1.10.0" + "web3": "^1.2.1" } }, "node_modules/@getsafle/asset-controller/node_modules/axios": { @@ -2101,14 +2099,6 @@ "node": ">=14.16" } }, - "node_modules/@tootallnate/once": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz", - "integrity": "sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==", - "engines": { - "node": ">= 10" - } - }, "node_modules/@types/babel__core": { "version": "7.20.0", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.0.tgz", @@ -2259,11 +2249,6 @@ "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.0.tgz", "integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==" }, - "node_modules/abab": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.6.tgz", - "integrity": "sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA==" - }, "node_modules/abi-decoder": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/abi-decoder/-/abi-decoder-2.4.0.tgz", @@ -2295,17 +2280,6 @@ "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz", "integrity": "sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==" }, - "node_modules/agent-base": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", - "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", - "dependencies": { - "debug": "4" - }, - "engines": { - "node": ">= 6.0.0" - } - }, "node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", @@ -3367,17 +3341,6 @@ "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.1.1.tgz", "integrity": "sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw==" }, - "node_modules/cssstyle": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-3.0.0.tgz", - "integrity": "sha512-N4u2ABATi3Qplzf0hWbVCdjenim8F3ojEXpBDF5hBpjzW182MjNGLqfmQ0SkSPeQ+V86ZXgeH8aXj6kayd4jgg==", - "dependencies": { - "rrweb-cssom": "^0.6.0" - }, - "engines": { - "node": ">=14" - } - }, "node_modules/d": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", @@ -3398,19 +3361,6 @@ "node": ">=0.10" } }, - "node_modules/data-urls": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-4.0.0.tgz", - "integrity": "sha512-/mMTei/JXPqvFqQtfyTowxmJVwr2PVAeCcDxyFf6LhoOu/09TX2OX3kb2wzi4DMXcfj4OItwDOnhl5oziPnT6g==", - "dependencies": { - "abab": "^2.0.6", - "whatwg-mimetype": "^3.0.0", - "whatwg-url": "^12.0.0" - }, - "engines": { - "node": ">=14" - } - }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", @@ -3427,11 +3377,6 @@ } } }, - "node_modules/decimal.js": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz", - "integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==" - }, "node_modules/decode-uri-component": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.2.tgz", @@ -3532,22 +3477,6 @@ "resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.2.tgz", "integrity": "sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w==" }, - "node_modules/domexception": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/domexception/-/domexception-4.0.0.tgz", - "integrity": "sha512-A2is4PLG+eeSfoTMA95/s4pvAoSo2mKtiM5jlHkAVewmiO8ISFTFKZjH7UAM1Atli/OT/7JHOrJRJiMKUZKYBw==", - "dependencies": { - "webidl-conversions": "^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/dompurify": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.0.3.tgz", - "integrity": "sha512-axQ9zieHLnAnHh0sfAamKYiqXMJAVwu+LM/alQ7WDagoWessyWvMSFyW65CqF3owufNu8HBcE4cM2Vflu7YWcQ==" - }, "node_modules/drbg.js": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/drbg.js/-/drbg.js-1.0.1.tgz", @@ -3635,17 +3564,6 @@ "once": "^1.4.0" } }, - "node_modules/entities": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", - "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", - "engines": { - "node": ">=0.12" - }, - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, "node_modules/error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", @@ -4744,19 +4662,6 @@ "node": "*" } }, - "node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/form-data-encoder": { "version": "1.7.1", "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.1.tgz", @@ -5068,17 +4973,6 @@ "minimalistic-crypto-utils": "^1.0.1" } }, - "node_modules/html-encoding-sniffer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz", - "integrity": "sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA==", - "dependencies": { - "whatwg-encoding": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, "node_modules/html-escaper": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", @@ -5109,19 +5003,6 @@ "resolved": "https://registry.npmjs.org/http-https/-/http-https-1.0.0.tgz", "integrity": "sha512-o0PWwVCSp3O0wS6FvNr6xfBCHgt0m1tvPLFOCc2iFDKTRAXhB7m8klDf7ErowFH8POa6dVdGatKU5I1YYwzUyg==" }, - "node_modules/http-proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz", - "integrity": "sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==", - "dependencies": { - "@tootallnate/once": "2", - "agent-base": "6", - "debug": "4" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/http-signature": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", @@ -5148,18 +5029,6 @@ "node": ">=10.19.0" } }, - "node_modules/https-proxy-agent": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", - "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", - "dependencies": { - "agent-base": "6", - "debug": "4" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/human-signals": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", @@ -5359,11 +5228,6 @@ "node": ">=0.12.0" } }, - "node_modules/is-potential-custom-element-name": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", - "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==" - }, "node_modules/is-typed-array": { "version": "1.1.10", "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.10.tgz", @@ -6055,47 +5919,6 @@ "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", "integrity": "sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg==" }, - "node_modules/jsdom": { - "version": "22.0.0", - "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-22.0.0.tgz", - "integrity": "sha512-p5ZTEb5h+O+iU02t0GfEjAnkdYPrQSkfuTSMkMYyIoMvUNEHsbG0bHHbfXIcfTqD2UfvjQX7mmgiFsyRwGscVw==", - "dependencies": { - "abab": "^2.0.6", - "cssstyle": "^3.0.0", - "data-urls": "^4.0.0", - "decimal.js": "^10.4.3", - "domexception": "^4.0.0", - "form-data": "^4.0.0", - "html-encoding-sniffer": "^3.0.0", - "http-proxy-agent": "^5.0.0", - "https-proxy-agent": "^5.0.1", - "is-potential-custom-element-name": "^1.0.1", - "nwsapi": "^2.2.4", - "parse5": "^7.1.2", - "rrweb-cssom": "^0.6.0", - "saxes": "^6.0.0", - "symbol-tree": "^3.2.4", - "tough-cookie": "^4.1.2", - "w3c-xmlserializer": "^4.0.0", - "webidl-conversions": "^7.0.0", - "whatwg-encoding": "^2.0.0", - "whatwg-mimetype": "^3.0.0", - "whatwg-url": "^12.0.1", - "ws": "^8.13.0", - "xml-name-validator": "^4.0.0" - }, - "engines": { - "node": ">=16" - }, - "peerDependencies": { - "canvas": "^2.5.0" - }, - "peerDependenciesMeta": { - "canvas": { - "optional": true - } - } - }, "node_modules/jsesc": { "version": "2.5.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", @@ -6656,11 +6479,6 @@ "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", "integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU=" }, - "node_modules/nwsapi": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.4.tgz", - "integrity": "sha512-NHj4rzRo0tQdijE9ZqAx6kYDcoRwYwSYzCA8MY3JzfxlrvEU0jhnhJT9BhqhJs7I/dKcrDm6TyulaRqZPIhN5g==" - }, "node_modules/oauth-sign": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", @@ -6841,17 +6659,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/parse5": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.2.tgz", - "integrity": "sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==", - "dependencies": { - "entities": "^4.4.0" - }, - "funding": { - "url": "https://github.com/inikulin/parse5?sponsor=1" - } - }, "node_modules/parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -7078,11 +6885,6 @@ "node": ">=0.10.0" } }, - "node_modules/querystringify": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", - "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==" - }, "node_modules/quick-lru": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz", @@ -7214,11 +7016,6 @@ "node": ">=0.10.0" } }, - "node_modules/requires-port": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==" - }, "node_modules/resolve": { "version": "1.22.1", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", @@ -7306,11 +7103,6 @@ "rlp": "bin/rlp" } }, - "node_modules/rrweb-cssom": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/rrweb-cssom/-/rrweb-cssom-0.6.0.tgz", - "integrity": "sha512-APM0Gt1KoXBz0iIkkdB/kfvGOwC4UuJFeG/c+yV7wSc7q96cG/kJ0HiYCnzivD9SB53cLV1MlHFNfOuPaadYSw==" - }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -7352,17 +7144,6 @@ "big.js": "^3.1.3" } }, - "node_modules/saxes": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz", - "integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==", - "dependencies": { - "xmlchars": "^2.2.0" - }, - "engines": { - "node": ">=v12.22.7" - } - }, "node_modules/scrypt-js": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-3.0.1.tgz", @@ -7844,11 +7625,6 @@ "node": ">=8" } }, - "node_modules/symbol-tree": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", - "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==" - }, "node_modules/tar": { "version": "4.4.19", "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.19.tgz", @@ -7982,31 +7758,6 @@ "node": ">=0.6" } }, - "node_modules/tough-cookie": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.2.tgz", - "integrity": "sha512-G9fqXWoYFZgTc2z8Q5zaHy/vJMjm+WV0AkAeHxVCQiEB1b+dGvWzFW6QV07cY5jQ5gRkeid2qIkzkxUnmoQZUQ==", - "dependencies": { - "psl": "^1.1.33", - "punycode": "^2.1.1", - "universalify": "^0.2.0", - "url-parse": "^1.5.3" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/tr46": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-4.1.1.tgz", - "integrity": "sha512-2lv/66T7e5yNyhAAC4NaKe5nVavzuGJQVVtRYLyQ2OI8tsJ61PMLlelehb0wi2Hx6+hT/OJUWZcw8MjlSRnxvw==", - "dependencies": { - "punycode": "^2.3.0" - }, - "engines": { - "node": ">=14" - } - }, "node_modules/tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", @@ -8082,14 +7833,6 @@ "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz", "integrity": "sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og==" }, - "node_modules/universalify": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz", - "integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==", - "engines": { - "node": ">= 4.0.0" - } - }, "node_modules/unorm": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/unorm/-/unorm-1.6.0.tgz", @@ -8139,15 +7882,6 @@ "punycode": "^2.1.0" } }, - "node_modules/url-parse": { - "version": "1.5.10", - "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz", - "integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==", - "dependencies": { - "querystringify": "^2.1.1", - "requires-port": "^1.0.0" - } - }, "node_modules/url-set-query": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/url-set-query/-/url-set-query-1.0.0.tgz", @@ -8253,17 +7987,6 @@ "extsprintf": "^1.2.0" } }, - "node_modules/w3c-xmlserializer": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-4.0.0.tgz", - "integrity": "sha512-d+BFHzbiCx6zGfz0HyQ6Rg69w9k19nviJspaj4yNscGjrHu94sVP+aRm75yEbCh+r2/yR+7q6hux9LVtbuTGBw==", - "dependencies": { - "xml-name-validator": "^4.0.0" - }, - "engines": { - "node": ">=14" - } - }, "node_modules/walker": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", @@ -8656,14 +8379,6 @@ "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" }, - "node_modules/webidl-conversions": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", - "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", - "engines": { - "node": ">=12" - } - }, "node_modules/websocket": { "version": "1.0.34", "resolved": "https://registry.npmjs.org/websocket/-/websocket-1.0.34.tgz", @@ -8693,48 +8408,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, - "node_modules/whatwg-encoding": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-2.0.0.tgz", - "integrity": "sha512-p41ogyeMUrw3jWclHWTQg1k05DSVXPLcVxRTYsXUk+ZooOCZLcoYgPZ/HL/D/N+uQPOtcp1me1WhBEaX02mhWg==", - "dependencies": { - "iconv-lite": "0.6.3" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/whatwg-encoding/node_modules/iconv-lite": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", - "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/whatwg-mimetype": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-3.0.0.tgz", - "integrity": "sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q==", - "engines": { - "node": ">=12" - } - }, - "node_modules/whatwg-url": { - "version": "12.0.1", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-12.0.1.tgz", - "integrity": "sha512-Ed/LrqB8EPlGxjS+TrsXcpUond1mhccS3pchLhzSgPCnTimUCKj3IZE75pAs5m6heB2U2TMerKFUXheyHY+VDQ==", - "dependencies": { - "tr46": "^4.1.1", - "webidl-conversions": "^7.0.0" - }, - "engines": { - "node": ">=14" - } - }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -8809,26 +8482,6 @@ "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, - "node_modules/ws": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", - "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", - "engines": { - "node": ">=10.0.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": ">=5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, "node_modules/xhr": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/xhr/-/xhr-2.6.0.tgz", @@ -8862,19 +8515,6 @@ "xhr-request": "^1.1.0" } }, - "node_modules/xml-name-validator": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-4.0.0.tgz", - "integrity": "sha512-ICP2e+jsHvAj2E2lIHxa5tjXRlKDJo4IdvPvCXbXQGdzSfmSpNVyIKMvoZHjDY9DP0zV17iI85o90vRFXNccRw==", - "engines": { - "node": ">=12" - } - }, - "node_modules/xmlchars": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", - "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==" - }, "node_modules/xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", diff --git a/package.json b/package.json index b96f724..d31b102 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "1.30.0", + "version": "1.30.01", "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,7 +44,7 @@ "license": "MIT", "homepage": "https://github.com/getsafle/safle-vault#readme", "dependencies": { - "@getsafle/asset-controller": "^1.0.11", + "@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.7", diff --git a/src/config/index.js b/src/config/index.js index 06151ae..d08d8fd 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -2,5 +2,5 @@ module.exports = { DEFAULT_GAS_LIMIT: 40000, REQUEST_BLOCKED_TIMEOUT: 3600000, TOKEN_WINDOW: 30000, - TOKEN_COUNT: 5, + TOKEN_COUNT: 10, }; diff --git a/src/lib/keyring.js b/src/lib/keyring.js index eeade5b..6f389f5 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -115,13 +115,7 @@ class Keyring { } async getAccounts(encryptionKey) { - const { decryptedVault, error } = await helper.validateEncryptionKey(this.vault, JSON.stringify(encryptionKey)); - - if (error) { - return { error } - } - - this.decryptedVault = decryptedVault; + const decryptedVault = this.decryptedVault; let chain = (Chains.evmChains.hasOwnProperty(this.chain) || this.chain === 'ethereum') ? 'eth' : this.chain; @@ -376,7 +370,7 @@ class Keyring { return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; } - const { decryptedVault, error } = await helper.validateEncryptionKey(vault, JSON.stringify(encryptionKey)); + const { decryptedVault, error } = helper.validateEncryptionKey(vault, JSON.stringify(encryptionKey)); if (error) { return { error } @@ -483,7 +477,7 @@ class Keyring { const response = await this.validatePin(pin); - const { error } = await helper.validateEncryptionKey(this.vault, JSON.stringify(encryptionKey)); + const { error } = helper.validateEncryptionKey(this.vault, JSON.stringify(encryptionKey)); if (error) { return { error } @@ -629,13 +623,7 @@ class Keyring { } async getVaultDetails(encryptionKey) { - const { decryptedVault, error } = await helper.validateEncryptionKey(this.vault, JSON.stringify(encryptionKey)); - - if (error) { - return { error } - } - - this.decryptedVault = decryptedVault; + const decryptedVault = this.decryptedVault; let accounts = { evm: { } }; @@ -742,9 +730,7 @@ class Keyring { return { error: ERROR_MESSAGE.UNSUPPORTED_NON_EVM_FUNCTIONALITY } } - async updateLabel(address, encryptionKey, newLabel) { - - const { decryptedVault, error } = await helper.validateEncryptionKey(this.vault, JSON.stringify(encryptionKey)); + async updateLabel(address, encryptionKey, newLabel, chainName) { if (error) { return { error } diff --git a/src/lib/vault.js b/src/lib/vault.js index c592f7a..6534c8d 100644 --- a/src/lib/vault.js +++ b/src/lib/vault.js @@ -10,11 +10,23 @@ const ERROR_MESSAGE = require('../constants/responses'); class Vault extends Keyring { - constructor(vault) { + constructor({vault, encryptionKey}) { super(); this.chain = 'ethereum'; this.vault = vault; - this.initializeKeyringController() + this.initializeKeyringController(); + if (vault && encryptionKey) { + this.initializeDecryptedVault(vault, encryptionKey); + } + } + + initializeDecryptedVault(vault, encryptionKey) { + const { decryptedVault, error } = helper.validateEncryptionKey(vault, JSON.stringify(encryptionKey)); + if (error) { + return { error } + } + this.decryptedVault = decryptedVault; + } initializeKeyringController() { @@ -75,6 +87,8 @@ class Vault extends Keyring { const vault = await helper.cryptography(JSON.stringify(rawVault), JSON.stringify(encryptionKey), 'encryption'); + this.initializeDecryptedVault({vault, encryptionKey}); + this.vault = vault; this.logs.updateState({ diff --git a/src/utils/helper.js b/src/utils/helper.js index b3ba5e9..5649635 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -176,7 +176,7 @@ async function cryptography(data, key, action) { return output; } -async function validateEncryptionKey(data, encryptionKey, encryptor, isCustomEncryptor) { +function validateEncryptionKey(data, encryptionKey, encryptor, isCustomEncryptor) { const bytes = cryptojs.AES.decrypt(data, encryptionKey); From e149cfce883e323eb419f81b1149536e3b2c7888 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 10 Jul 2023 13:56:40 +0530 Subject: [PATCH 02/98] parameter correction --- src/lib/vault.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/vault.js b/src/lib/vault.js index 6534c8d..0e33e57 100644 --- a/src/lib/vault.js +++ b/src/lib/vault.js @@ -87,7 +87,7 @@ class Vault extends Keyring { const vault = await helper.cryptography(JSON.stringify(rawVault), JSON.stringify(encryptionKey), 'encryption'); - this.initializeDecryptedVault({vault, encryptionKey}); + this.initializeDecryptedVault(vault, encryptionKey); this.vault = vault; From 3b3c8feae827e32d4c846262edf77b0eddb757ae Mon Sep 17 00:00:00 2001 From: Subhanshu Mohan Gupta Date: Mon, 10 Jul 2023 14:12:59 +0530 Subject: [PATCH 03/98] added nightly branches --- .github/workflows/nightly-release.yml | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/nightly-release.yml diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml new file mode 100644 index 0000000..792f9cb --- /dev/null +++ b/.github/workflows/nightly-release.yml @@ -0,0 +1,34 @@ +# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created +# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages + +name: nightly Branch + +on: + push: + branches: + - nightly-release-* + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 16.16.0 + - run: npm ci + - run: npm run test + + publish-npm: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 16.16.0 + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} \ No newline at end of file From dc4c98ff1a39bbf819190e009c7cbf876ad4ac3c Mon Sep 17 00:00:00 2001 From: Subhanshu Mohan Gupta <53417895+SubhanshuMG@users.noreply.github.com> Date: Mon, 10 Jul 2023 14:30:32 +0530 Subject: [PATCH 04/98] Update nightly-release.yml --- .github/workflows/nightly-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml index 792f9cb..e4769e6 100644 --- a/.github/workflows/nightly-release.yml +++ b/.github/workflows/nightly-release.yml @@ -17,7 +17,7 @@ jobs: with: node-version: 16.16.0 - run: npm ci - - run: npm run test +# - run: npm run test publish-npm: needs: build @@ -31,4 +31,4 @@ jobs: - run: npm ci - run: npm publish --access public env: - NODE_AUTH_TOKEN: ${{secrets.npm_token}} \ No newline at end of file + NODE_AUTH_TOKEN: ${{secrets.npm_token}} From 6b46bf1db93fc59b127890250c86fbbe154cd2cb Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 17 Jul 2023 21:25:24 +0530 Subject: [PATCH 05/98] pakage dependency updates and update lable correction --- package-lock.json | 29 +++++++++++++---------------- package.json | 2 +- src/lib/keyring.js | 4 ---- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9abf4a4..ead5222 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,7 @@ "@getsafle/vault-optimism-controller": "^1.0.7", "@getsafle/vault-polygon-controller": "^1.2.7", "@getsafle/vault-velas-controller": "^1.3.0", - "bip39": "^3.1.0", + "bip39": "^3.0.4", "crypto-js": "^4.1.1", "ethers": "^5.5.3", "jest": "^29.4.3", @@ -2045,17 +2045,6 @@ "node": ">=12.0.0" } }, - "node_modules/@noble/hashes": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.0.tgz", - "integrity": "sha512-ilHEACi9DwqJB0pw7kv+Apvh50jiiSyR/cQ3y4W7lOR5mhvn/50FLUfsnfJz0BDZtl/RR16kXvptiv6q1msYZg==", - "funding": [ - { - "type": "individual", - "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", @@ -2625,13 +2614,21 @@ "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==" }, "node_modules/bip39": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/bip39/-/bip39-3.1.0.tgz", - "integrity": "sha512-c9kiwdk45Do5GL0vJMe7tS95VjCii65mYAH7DfWl3uW8AVzXKQVUm64i3hzVybBDMp9r7j9iNxR85+ul8MdN/A==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/bip39/-/bip39-3.0.4.tgz", + "integrity": "sha512-YZKQlb752TrUWqHWj7XAwCSjYEgGAk+/Aas3V7NyjQeZYsztO8JnQUaCWhcnL4T+jL8nvB8typ2jRPzTlgugNw==", "dependencies": { - "@noble/hashes": "^1.2.0" + "@types/node": "11.11.6", + "create-hash": "^1.1.0", + "pbkdf2": "^3.0.9", + "randombytes": "^2.0.1" } }, + "node_modules/bip39/node_modules/@types/node": { + "version": "11.11.6", + "resolved": "https://registry.npmjs.org/@types/node/-/node-11.11.6.tgz", + "integrity": "sha512-Exw4yUWMBXM3X+8oqzJNRqZSwUAaS4+7NdvHqQuFi/d+synz++xmX3QIf+BFqneW8N31R8Ky+sikfZUXq07ggQ==" + }, "node_modules/bip66": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/bip66/-/bip66-1.1.5.tgz", diff --git a/package.json b/package.json index d31b102..3c780ef 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "@getsafle/vault-optimism-controller": "^1.0.7", "@getsafle/vault-polygon-controller": "^1.2.7", "@getsafle/vault-velas-controller": "^1.3.0", - "bip39": "^3.1.0", + "bip39": "^3.0.4", "crypto-js": "^4.1.1", "ethers": "^5.5.3", "jest": "^29.4.3", diff --git a/src/lib/keyring.js b/src/lib/keyring.js index 6f389f5..fe9271e 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -732,10 +732,6 @@ class Keyring { async updateLabel(address, encryptionKey, newLabel, chainName) { - if (error) { - return { error } - } - if (newLabel === null || newLabel === undefined) { return { error: ERROR_MESSAGE.INCORRECT_LABEL_TYPE }; } From 14b1ab9b7cb147e99b24042481f021df6551e2fe Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 17 Jul 2023 21:29:53 +0530 Subject: [PATCH 06/98] changelog and version update --- CHANGELOG.md | 7 ++++++- package-lock.json | 2 +- package.json | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34387bf..c1ad538 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -516,4 +516,9 @@ ### 1.30.01 (2023-07-8) Nightly version : only for experimental use * Updated vault state with decryptedVault -* Updated rate limiting for pin validation, upto 10 \ No newline at end of file +* Updated rate limiting for pin validation, upto 10 + +### 1.30.0.2 (2023-07-17) Nightly version : only for experimental use + +* pakage dependency updates +* update lable correction \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index ead5222..3e2c2d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "1.30.01", + "version": "1.30.0.2", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 3c780ef..fbbe4bf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "1.30.01", + "version": "1.30.0.2", "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": { From 0fd79646c7422404c603ef164135e66d68c10597 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Tue, 18 Jul 2023 12:13:13 +0530 Subject: [PATCH 07/98] version update --- CHANGELOG.md | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1ad538..e0b8827 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -518,7 +518,7 @@ * Updated vault state with decryptedVault * Updated rate limiting for pin validation, upto 10 -### 1.30.0.2 (2023-07-17) Nightly version : only for experimental use +### 1.30.02 (2023-07-17) Nightly version : only for experimental use * pakage dependency updates * update lable correction \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 3e2c2d2..23d1cd3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getsafle/safle-vault", - "version": "1.30.0.2", + "version": "1.30.02", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "1.30.01", + "version": "1.30.02", "license": "MIT", "dependencies": { "@getsafle/asset-controller": "^1.0.10", diff --git a/package.json b/package.json index fbbe4bf..7a3e72d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "1.30.0.2", + "version": "1.30.02", "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": { From 75845a22916b7fe6e4c2fec4922c558a49004d6d Mon Sep 17 00:00:00 2001 From: SDargarh Date: Fri, 18 Aug 2023 13:16:28 +0530 Subject: [PATCH 08/98] slicing exported private key if '0x' is prefixed --- CHANGELOG.md | 6 +++++- package-lock.json | 2 +- package.json | 2 +- src/lib/keyring.js | 6 +++++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0b8827..c2d3f50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -521,4 +521,8 @@ ### 1.30.02 (2023-07-17) Nightly version : only for experimental use * pakage dependency updates -* update lable correction \ No newline at end of file +* update lable correction + +### 1.30.03 (2023-08-17) Nightly version : only for experimental use + +* Updated keyring to slice exported private key if it has '0x' prefixed to add backward campatability for imported wallets \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 23d1cd3..0de1c82 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "1.30.02", + "version": "1.30.03", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 7a3e72d..4079d96 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "1.30.02", + "version": "1.30.03", "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": { diff --git a/src/lib/keyring.js b/src/lib/keyring.js index fe9271e..02b0902 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -175,7 +175,11 @@ class Keyring { if (isImportedAddress) { const privateKey = (chain === 'eth') ? this.decryptedVault.importedWallets.evmChains.data.find(element => element.address === address).privateKey : this.decryptedVault.importedWallets[chain].data.find(element => element.address === address).privateKey; - const decryptedPrivKey = await helper.cryptography(privateKey, pin.toString(), 'decryption'); + let decryptedPrivKey = await helper.cryptography(privateKey, pin.toString(), 'decryption'); + + if (decryptedPrivKey.startsWith('0x')) { + decryptedPrivKey = decryptedPrivKey.slice(2) + } return { response: { privateKey: decryptedPrivKey, isImported : isImportedAddress}} } From 75702ebc3c52bdacd94666c38952adaa8fdadef6 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Thu, 24 Aug 2023 13:39:25 +0530 Subject: [PATCH 09/98] updated the logs for label update & delete account --- src/lib/keyring.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/keyring.js b/src/lib/keyring.js index 02b0902..d98fc87 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -469,7 +469,7 @@ class Keyring { this.vault = vault; - this.logs.getState().logs.push({ timestamp: Date.now(), action: 'delete-account', vault: this.vault, chain: this.chain }); + this.logs.getState().logs.push({ timestamp: Date.now(), action: 'delete-account', vault: this.vault, chain: this.chain, address: address }); return { response: vault }; } @@ -779,7 +779,7 @@ class Keyring { this.vault = vault; - this.logs.getState().logs.push({ timestamp: Date.now(), action: 'delete-account', vault: this.vault, chain: this.chain }); + this.logs.getState().logs.push({ timestamp: Date.now(), action: 'update-label', vault: this.vault, chain: this.chain, address: address }); return { response: vault }; } From cee23306b24debed62c007d36d98430150aa9c7b Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 28 Aug 2023 11:30:09 +0530 Subject: [PATCH 10/98] added new package version --- .gitignore | 3 ++- CHANGELOG.md | 6 +++++- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 662cfe1..8449a7b 100644 --- a/.gitignore +++ b/.gitignore @@ -54,4 +54,5 @@ test.js test2.js vault_test.js coverage -.coverage \ No newline at end of file +.coverage +safle-vault.code-workspace diff --git a/CHANGELOG.md b/CHANGELOG.md index c2d3f50..0744430 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -525,4 +525,8 @@ ### 1.30.03 (2023-08-17) Nightly version : only for experimental use -* Updated keyring to slice exported private key if it has '0x' prefixed to add backward campatability for imported wallets \ No newline at end of file +* Updated keyring to slice exported private key if it has '0x' prefixed to add backward campatability for imported wallets + +### 1.30.04 (2023-08-28) Nightly version : only for experimental use + +* Updated the logs for label update & delete account \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 0de1c82..fafeaa6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getsafle/safle-vault", - "version": "1.30.03", + "version": "1.30.04", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "1.30.02", + "version": "1.30.04", "license": "MIT", "dependencies": { "@getsafle/asset-controller": "^1.0.10", diff --git a/package.json b/package.json index 4079d96..859de41 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "1.30.03", + "version": "1.30.04", "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": { From 816bdb118ba4b02a987120c8d1f306ed8b32c74a Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 28 Aug 2023 11:36:04 +0530 Subject: [PATCH 11/98] removed unused encryption key parameter in get accounts --- src/lib/keyring.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib/keyring.js b/src/lib/keyring.js index d98fc87..29b8b26 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -114,7 +114,8 @@ class Keyring { return { response: true }; } - async getAccounts(encryptionKey) { + async getAccounts() { + const decryptedVault = this.decryptedVault; let chain = (Chains.evmChains.hasOwnProperty(this.chain) || this.chain === 'ethereum') ? 'eth' : this.chain; @@ -206,7 +207,7 @@ class Keyring { return { error: ERROR_MESSAGE.INCORRECT_PIN }; }; - const acc = await this.getAccounts(encryptionKey); + const acc = await this.getAccounts(); if (Chains.evmChains.hasOwnProperty(this.chain) || this.chain === 'ethereum') { const accounts = await this.keyringInstance.getAccounts(); @@ -303,7 +304,7 @@ class Keyring { } else{ - const accounts = await this.getAccounts(encryptionKey); + const accounts = await this.getAccounts(); if(accounts.response.filter(e => e.address === address).length < 1) { return { error: ERROR_MESSAGE.NONEXISTENT_KEYRING_ACCOUNT }; @@ -502,7 +503,7 @@ class Keyring { let isDuplicateAddress; let numOfAcc; - accounts = await this.getAccounts(encryptionKey); + accounts = await this.getAccounts(); if (accounts.error) { numOfAcc = 0; From 00e9df76914170f6fe6c24e9197dc711c1410290 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 28 Aug 2023 12:43:49 +0530 Subject: [PATCH 12/98] added validation for pin parameter in export private key --- CHANGELOG.md | 4 +++- src/lib/keyring.js | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0744430..9d0f758 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -529,4 +529,6 @@ ### 1.30.04 (2023-08-28) Nightly version : only for experimental use -* Updated the logs for label update & delete account \ No newline at end of file +* Updated the logs for label update & delete account +* Removed unused encryption key parameter in get accounts +* Added validation for pin parameter in export private key \ No newline at end of file diff --git a/src/lib/keyring.js b/src/lib/keyring.js index 29b8b26..6646183 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -154,6 +154,12 @@ class Keyring { return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; } + const response = await this.validatePin(pin); + + if (response.response == false || response.error) { + return { error: ERROR_MESSAGE.INCORRECT_PIN }; + }; + const chain = (Chains.evmChains.hasOwnProperty(this.chain) || this.chain === 'ethereum') ? 'eth' : this.chain; const importedChain = (chain === 'eth') ? 'evmChains' : chain; @@ -167,12 +173,6 @@ class Keyring { return { error: ERROR_MESSAGE.ADDRESS_NOT_PRESENT }; } - const response = await this.validatePin(pin); - - if (response.response == false || response.error) { - return { error: ERROR_MESSAGE.INCORRECT_PIN }; - }; - if (isImportedAddress) { const privateKey = (chain === 'eth') ? this.decryptedVault.importedWallets.evmChains.data.find(element => element.address === address).privateKey : this.decryptedVault.importedWallets[chain].data.find(element => element.address === address).privateKey; From 987cf2ee3b96c3526d8f124fa4a80955fd2f6244 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 28 Aug 2023 12:54:21 +0530 Subject: [PATCH 13/98] Added validation for encryption key in add account --- CHANGELOG.md | 3 ++- src/lib/keyring.js | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d0f758..f97e51e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -531,4 +531,5 @@ * Updated the logs for label update & delete account * Removed unused encryption key parameter in get accounts -* Added validation for pin parameter in export private key \ No newline at end of file +* Added validation for pin parameter in export private key +* Added validation for encryption key in add account \ No newline at end of file diff --git a/src/lib/keyring.js b/src/lib/keyring.js index 6646183..896d417 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -207,6 +207,12 @@ class Keyring { return { error: ERROR_MESSAGE.INCORRECT_PIN }; }; + const { error } = helper.validateEncryptionKey(this.vault, JSON.stringify(encryptionKey)); + + if (error) { + return { error } + } + const acc = await this.getAccounts(); if (Chains.evmChains.hasOwnProperty(this.chain) || this.chain === 'ethereum') { From e07d38b0bc1d3fd7d6eaed6f13e05ae8b7f4b2af Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 28 Aug 2023 13:00:18 +0530 Subject: [PATCH 14/98] Added validation for encryption key in sign message --- CHANGELOG.md | 2 +- src/lib/keyring.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f97e51e..4ef82c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -532,4 +532,4 @@ * Updated the logs for label update & delete account * Removed unused encryption key parameter in get accounts * Added validation for pin parameter in export private key -* Added validation for encryption key in add account \ No newline at end of file +* Added validation for encryption key in add account, sign message \ No newline at end of file diff --git a/src/lib/keyring.js b/src/lib/keyring.js index 896d417..b8dd748 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -279,6 +279,13 @@ class Keyring { if(res.response == false || res.error) { return { error: ERROR_MESSAGE.INCORRECT_PIN }; }; + + const err = helper.validateEncryptionKey(this.vault, JSON.stringify(encryptionKey)); + + if (err.error) { + return { error : err.error } + } + const { error, response } = await this.exportPrivateKey(address, pin); if (error) { From 7c5c334d552a2c4201d7c95608341e1e0fb0b500 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 28 Aug 2023 13:02:12 +0530 Subject: [PATCH 15/98] added validation for pin parameter in restore keyring state --- CHANGELOG.md | 2 +- src/lib/keyring.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ef82c7..505c4b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -531,5 +531,5 @@ * Updated the logs for label update & delete account * Removed unused encryption key parameter in get accounts -* Added validation for pin parameter in export private key +* Added validation for pin parameter in export private key, restore keyring state * Added validation for encryption key in add account, sign message \ No newline at end of file diff --git a/src/lib/keyring.js b/src/lib/keyring.js index b8dd748..5d8e9f6 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -388,6 +388,12 @@ class Keyring { return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; } + const res = await this.validatePin(pin) + + if(res.response == false || res.error) { + return { error: ERROR_MESSAGE.INCORRECT_PIN }; + }; + const { decryptedVault, error } = helper.validateEncryptionKey(vault, JSON.stringify(encryptionKey)); if (error) { From b8a29ac6481bf3cb5ec1756280e736f31d6e9b8e Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 28 Aug 2023 13:04:00 +0530 Subject: [PATCH 16/98] Added validation for encryption key in delete account --- CHANGELOG.md | 2 +- src/lib/keyring.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 505c4b3..0bec660 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -532,4 +532,4 @@ * Updated the logs for label update & delete account * Removed unused encryption key parameter in get accounts * Added validation for pin parameter in export private key, restore keyring state -* Added validation for encryption key in add account, sign message \ No newline at end of file +* Added validation for encryption key in add account, sign message, delete account \ No newline at end of file diff --git a/src/lib/keyring.js b/src/lib/keyring.js index 5d8e9f6..1624c8a 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -459,6 +459,12 @@ class Keyring { return { error: ERROR_MESSAGE.INCORRECT_PIN }; }; + const { error } = helper.validateEncryptionKey(this.vault, JSON.stringify(encryptionKey)); + + if (error) { + return { error } + } + let chain = (Chains.evmChains.hasOwnProperty(this.chain) || this.chain === 'ethereum') ? 'eth' : this.chain; const importedChain = (chain === 'eth') ? 'evmChains' : chain; From b6e0291785a9f85b15df2ba24b1cf875248d83f0 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 28 Aug 2023 13:34:46 +0530 Subject: [PATCH 17/98] Import wallet - sync the pin validation steps with other methods --- CHANGELOG.md | 3 ++- src/lib/keyring.js | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bec660..7de9c32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -532,4 +532,5 @@ * Updated the logs for label update & delete account * Removed unused encryption key parameter in get accounts * Added validation for pin parameter in export private key, restore keyring state -* Added validation for encryption key in add account, sign message, delete account \ No newline at end of file +* Added validation for encryption key in add account, sign message, delete account +* Sync the pin validation steps with other methods in import wallet \ No newline at end of file diff --git a/src/lib/keyring.js b/src/lib/keyring.js index 1624c8a..b70a651 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -507,16 +507,16 @@ class Keyring { const response = await this.validatePin(pin); + if(response.response == false || response.error) { + return { error: ERROR_MESSAGE.INCORRECT_PIN }; + }; + const { error } = helper.validateEncryptionKey(this.vault, JSON.stringify(encryptionKey)); if (error) { return { error } } - if(response.response == false || response.error) { - return { error: ERROR_MESSAGE.INCORRECT_PIN }; - }; - if (privateKey.startsWith('0x')) { privateKey = privateKey.slice(2) } From b5cca7a6fe8307000b13b99b56d0804b77182f43 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 28 Aug 2023 13:40:08 +0530 Subject: [PATCH 18/98] Added validation for encryption key in get vault details --- CHANGELOG.md | 2 +- src/lib/keyring.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7de9c32..fdf2dee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -532,5 +532,5 @@ * Updated the logs for label update & delete account * Removed unused encryption key parameter in get accounts * Added validation for pin parameter in export private key, restore keyring state -* Added validation for encryption key in add account, sign message, delete account +* Added validation for encryption key in add account, sign message, delete account, get vault details * Sync the pin validation steps with other methods in import wallet \ No newline at end of file diff --git a/src/lib/keyring.js b/src/lib/keyring.js index b70a651..3045b5b 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -653,6 +653,13 @@ class Keyring { } async getVaultDetails(encryptionKey) { + + const { error } = helper.validateEncryptionKey(this.vault, JSON.stringify(encryptionKey)); + + if (error) { + return { error } + } + const decryptedVault = this.decryptedVault; let accounts = { evm: { } }; From 00a675fdc12d94c5b56a12e55f1236e66cb07731 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 28 Aug 2023 13:45:43 +0530 Subject: [PATCH 19/98] Added validation for encryption key in update label --- CHANGELOG.md | 2 +- src/lib/keyring.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fdf2dee..d32e5fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -532,5 +532,5 @@ * Updated the logs for label update & delete account * Removed unused encryption key parameter in get accounts * Added validation for pin parameter in export private key, restore keyring state -* Added validation for encryption key in add account, sign message, delete account, get vault details +* Added validation for encryption key in add account, sign message, delete account, get vault details & update label * Sync the pin validation steps with other methods in import wallet \ No newline at end of file diff --git a/src/lib/keyring.js b/src/lib/keyring.js index 3045b5b..0497ed9 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -769,6 +769,12 @@ class Keyring { async updateLabel(address, encryptionKey, newLabel, chainName) { + const { error } = helper.validateEncryptionKey(this.vault, JSON.stringify(encryptionKey)); + + if (error) { + return { error } + } + if (newLabel === null || newLabel === undefined) { return { error: ERROR_MESSAGE.INCORRECT_LABEL_TYPE }; } From 5e8fbeae0ca727379b2f6e62ee4c84de2332cedf Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 28 Aug 2023 13:48:44 +0530 Subject: [PATCH 20/98] added validation for current pin parameter in change pin --- CHANGELOG.md | 2 +- src/lib/keyring.js | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d32e5fc..6e6dd97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -531,6 +531,6 @@ * Updated the logs for label update & delete account * Removed unused encryption key parameter in get accounts -* Added validation for pin parameter in export private key, restore keyring state +* Added validation for pin parameter in export private key, restore keyring state & current pin parameter in change pin * Added validation for encryption key in add account, sign message, delete account, get vault details & update label * Sync the pin validation steps with other methods in import wallet \ No newline at end of file diff --git a/src/lib/keyring.js b/src/lib/keyring.js index 0497ed9..44a0167 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -824,6 +824,7 @@ class Keyring { } async changePin(currentPin, newPin, encryptionKey) { + if (!Number.isInteger(currentPin) || currentPin < 0) { throw ERROR_MESSAGE.INCORRECT_PIN_TYPE } @@ -832,6 +833,18 @@ class Keyring { throw ERROR_MESSAGE.INCORRECT_PIN_TYPE } + const response = await this.validatePin(currentPin); + + if (response.response == false || response.error) { + return { error: ERROR_MESSAGE.INCORRECT_PIN }; + }; + + const err = helper.validateEncryptionKey(this.vault, JSON.stringify(encryptionKey)); + + if (err.error) { + return { error : err.error } + } + const { error, response: mnemonic }= await this.exportMnemonic(currentPin); if (error) { From c84b6dd21b6e297936f3dbb24206d74e039157cf Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 28 Aug 2023 13:52:11 +0530 Subject: [PATCH 21/98] Updated tests wrt changes in vault generation and parameter validations --- src/lib/test/keyring.test.js | 73 +++++++++++++++++++++--------------- src/lib/test/vault.test.js | 14 +++---- 2 files changed, 49 insertions(+), 38 deletions(-) diff --git a/src/lib/test/keyring.test.js b/src/lib/test/keyring.test.js index efa1314..9e1b7d4 100644 --- a/src/lib/test/keyring.test.js +++ b/src/lib/test/keyring.test.js @@ -22,7 +22,7 @@ beforeAll(async() => { result = await vault.generateVault(bufView,pin,phrase) vaultAddress=result.response - await vault.getAccounts(bufView); + await vault.getAccounts(); }); describe('exportMnemonic' , ()=>{ @@ -115,14 +115,14 @@ describe('addAccount' , ()=>{ }) - test('addAccount/empty encryption key' , async()=>{ + test('addAccount/empty encryption key' , async()=>{ try{ let result = await vault.addAccount(null,pin) } catch(e){ - expect(e.message).toBe("Cannot read properties of undefined (reading 'length')") + expect(e.message).toBe("Incorrect Encryption Key or vault string") } - + }) test('addAccount/empty pin' , async()=>{ @@ -892,6 +892,18 @@ describe('changePin',()=>{ }) + test('changePin/wrong currentpin' , async()=>{ + try{ + let result = await vault.changePin(111111,pin,bufView) + + } + catch(e){ + expect(e).toBe('Wrong pin type, format or length') + } + + + }) + test('changePin/invalid currentpin' , async()=>{ try{ let result = await vault.changePin('aefe',pin,bufView) @@ -942,19 +954,23 @@ describe('changePin',()=>{ }) test('changePin/empty encryption key' , async()=>{ - - let result = await vault.changePin(pin,pin,null) - expect(result).toHaveProperty('response') - - - + try{ + let result = await vault.changePin(pin,pin,null) + } + catch(e){ + expect(e.message).toBe("Incorrect Encryption Key or vault string") + } + }) test('changePin/invalid encryption key' , async()=>{ - + try{ let result = await vault.changePin(pin,pin,'efefe') - expect(result).toHaveProperty('response') + } + catch(e){ + expect(e.message).toBe("Incorrect Encryption Key or vault string") + } @@ -996,17 +1012,23 @@ describe('deleteAccount',()=>{ }) test('deleteAccount/empty encryption key' , async()=>{ - + try{ let result = await vault.deleteAccount(null,accAddress,pin) - expect(result.error).toBe('This address is not present in the vault') + } + catch(e){ + expect(e.message).toBe("Incorrect Encryption Key or vault string") + } }) test('deleteAccount/invalid encryption key' , async()=>{ - + try{ let result = await vault.deleteAccount(null,accAddress,pin) - expect(result.error).toBe('This address is not present in the vault') + } + catch(e){ + expect(e.message).toBe("Incorrect Encryption Key or vault string") + } }) @@ -1066,22 +1088,11 @@ describe('deleteAccount',()=>{ describe('getAccounts',()=>{ test('getAccounts/valid' , async()=>{ await vault.restoreKeyringState(vaultAddress,pin,bufView) - let result = await vault.getAccounts(bufView) + let result = await vault.getAccounts() expect(result).toHaveProperty('response') }) - test('getAccounts/empty encryption key ' , async()=>{ - - let result = await vault.getAccounts(null) - expect(result.error).toBe('Incorrect Encryption Key or vault string') - - }) - test('getAccounts/invalid encryption key ' , async()=>{ - - let result = await vault.getAccounts("aefefe") - expect(result.error).toBe('Incorrect Encryption Key or vault string') - - }) + }) @@ -1142,7 +1153,7 @@ describe('signTransaction',()=>{ } catch(e){ - expect(e.message).toBe("No keyring found for the requested account.") + expect(e.message).toBe("Cannot read properties of undefined (reading 'toLowerCase')") } @@ -1173,7 +1184,7 @@ describe('signTransaction',()=>{ } catch(e){ - expect(e.message).toBe("No keyring found for the requested account.") + expect(e.message).toBe("Cannot read properties of undefined (reading 'toLowerCase')") } diff --git a/src/lib/test/vault.test.js b/src/lib/test/vault.test.js index 061ad16..9a89324 100644 --- a/src/lib/test/vault.test.js +++ b/src/lib/test/vault.test.js @@ -12,7 +12,7 @@ describe('getSupportedChains' , ()=>{ test('getSupportedChains' , async()=>{ - let result = await new Vault().getSupportedChains() + let result = await new Vault({}).getSupportedChains() expect({ evmChains: { ethereum: 'ETH', bsc: 'BSC', polygon: 'MATIC', optimism: 'OP', arbitrum: 'ARB', mantle: 'MNT', velas: 'VLX' }, nonEvmChains: { bitcoin: 'BTC' } @@ -28,7 +28,7 @@ describe('generateMnemonic' , ()=>{ test('generateMnemonic' , async()=>{ - let result = await new Vault().generateMnemonic() + let result = await new Vault({}).generateMnemonic() Mnemonic=result expect(typeof(result)).toBe("string") @@ -58,7 +58,7 @@ describe("generateVault",()=>{ const buf = new ArrayBuffer(32); const bufView = new Uint8Array(buf); - let result = await new Vault().generateVault(bufView,null,Mnemonic) + let result = await new Vault({}).generateVault(bufView,null,Mnemonic) expect(result.error).toBe("Wrong pin type, format or length") }) @@ -66,14 +66,14 @@ describe("generateVault",()=>{ test('generateVault/empty encrption key' , async()=>{ const buf = new ArrayBuffer(32); const bufView = new Uint8Array(buf); - let result = await new Vault().generateVault(null,1111,Mnemonic) + let result = await new Vault({}).generateVault(null,1111,Mnemonic) expect(result.error).toBe('Wrong pin type, format or length') }) test('generateVault/empty encrption key' , async()=>{ const buf = new ArrayBuffer(32); const bufView = new Uint8Array(buf); - let result = await new Vault().generateVault(null,111111,Mnemonic) + let result = await new Vault({}).generateVault(null,111111,Mnemonic) expect(result.error).toBe('Please enter both encryptionKey and pin') }) @@ -82,7 +82,7 @@ describe("generateVault",()=>{ const buf = new ArrayBuffer(32); const bufView = new Uint8Array(buf); try{ - let result = await new Vault().generateVault(bufView,1111,null) + let result = await new Vault({}).generateVault(bufView,1111,null) } catch(e){ expect(e.message).toBe('Seed phrase is invalid.') @@ -95,7 +95,7 @@ describe("generateVault",()=>{ const buf = new ArrayBuffer(32); const bufView = new Uint8Array(buf); - let result = await new Vault().generateVault(null,null,null) + let result = await new Vault({}).generateVault(null,null,null) expect(result.error).toBe("Wrong pin type, format or length") From 69b7fab0e3de43c5a7b5d2c30cbc071cbae29be1 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 28 Aug 2023 14:05:32 +0530 Subject: [PATCH 22/98] updated change log --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e6dd97..f1cf0f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -533,4 +533,5 @@ * Removed unused encryption key parameter in get accounts * Added validation for pin parameter in export private key, restore keyring state & current pin parameter in change pin * Added validation for encryption key in add account, sign message, delete account, get vault details & update label -* Sync the pin validation steps with other methods in import wallet \ No newline at end of file +* Sync the pin validation steps with other methods in import wallet +* Updated tests wrt changes in vault generation and parameter validations \ No newline at end of file From 6ef7db850475ca6103cb80c2c4f6920c63420b59 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Tue, 29 Aug 2023 15:23:09 +0530 Subject: [PATCH 23/98] Implemented vault recovery using logs and updated tests --- CHANGELOG.md | 3 +- src/constants/responses/index.js | 3 +- src/lib/test/vault.test.js | 90 +++++++++++++++++++++++++++++--- src/lib/vault.js | 15 +++++- src/utils/helper.js | 57 +++++++++++++------- 5 files changed, 137 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1cf0f5..098a97d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -534,4 +534,5 @@ * Added validation for pin parameter in export private key, restore keyring state & current pin parameter in change pin * Added validation for encryption key in add account, sign message, delete account, get vault details & update label * Sync the pin validation steps with other methods in import wallet -* Updated tests wrt changes in vault generation and parameter validations \ No newline at end of file +* Updated tests wrt changes in vault generation and parameter validations +* Implemented vault recovery using logs and updated tests \ No newline at end of file diff --git a/src/constants/responses/index.js b/src/constants/responses/index.js index 8a28bc5..96cf01f 100644 --- a/src/constants/responses/index.js +++ b/src/constants/responses/index.js @@ -15,5 +15,6 @@ module.exports = { INCORRECT_CURRENT_PIN: 'The current pin passed is incorrect', INCORRECT_LABEL_TYPE: 'Label should be a valid string', REQUEST_LIMIT_EXCEEDED: 'Request limit exceeded. Please retry later', - REQUEST_BLOCKED: 'Requests to method blocked' + REQUEST_BLOCKED: 'Requests to method blocked', + INVALID_API_KEY: 'Invalid API key passed' }; diff --git a/src/lib/test/vault.test.js b/src/lib/test/vault.test.js index 9a89324..74549e6 100644 --- a/src/lib/test/vault.test.js +++ b/src/lib/test/vault.test.js @@ -8,6 +8,70 @@ let phrase="fun rough treat scan glimpse region century purpose expire video rem let pin=696969 let vault =new Vault({}) +const logs = [ + { + "action": "add-account", + "timestamp": 1000000000001, + "platform": "web", + "address": "0xF8919220F674a553F0F0F6e86481612A2bEd44EB", + "storage": [ + "mobile" + ], + "_id": "64e881b05b04774ca85aee51" + }, + { + "action": "add-account", + "timestamp": 1000000000002, + "platform": "web", + "address": "0x627437E29e7363C0F53896e84467EF6F8f9D0247", + "storage": [ + "mobile" + ], + "_id": "64e881e3bae0e048dfaefc46" + }, + { + "action": "add-account", + "timestamp": 1000000000003, + "platform": "web", + "address": "0xa1F77e4D8306000639D1d44a6013ad53b992182E", + "storage": [ + "mobile" + ], + "_id": "64ec3339a58abcbf66a9b34a" + }, + { + "action": "add-account", + "timestamp": 1000000000004, + "platform": "web", + "address": "0x9e6627384a3E6453b9EC061e4DaeD4cE0223bbdc", + "storage": [ + "mobile" + ], + "_id": "64ec333ca58abcbf66a9b354" + }, + { + "action": "add-account", + "timestamp": 1000000000005, + "platform": "mobile", + "address": "0xCccbD31ea19acE5688731148a4f63907F273BEe0", + "storage": [ + "mobile" + ], + "_id": "64e87e9e72e00ccf96bce1fc" + }, + { + "action": "delete-account", + "timestamp": 1000000000006, + "platform": "web", + "address": "0x9e6627384a3E6453b9EC061e4DaeD4cE0223bbdc", + "storage": [ + "mobile" + ], + "_id": "64ec3339a58abcbf66a9b34a" + }, + ] + + describe('getSupportedChains' , ()=>{ test('getSupportedChains' , async()=>{ @@ -105,11 +169,24 @@ describe("generateVault",()=>{ describe("recoverVault",()=>{ - test('recoverVault/valid' , async()=>{ + test('recoverVault/transaction valid' , async()=>{ let result = await vault.recoverVault(phrase,bufView,pin,'BgoGMHvB5R7iMNhZ2BoJd470aSZNEz9t2N8PBOWD') expect(result).toHaveProperty('response') }) + + test('recoverVault/logs valid' , async()=>{ + + let result = await vault.recoverVault(phrase,bufView,pin,null,'logs', logs) + expect(result).toHaveProperty('response') + }) + + test('recoverVault/logs empty logs valid' , async()=>{ + + let result = await vault.recoverVault(phrase,bufView,pin,null,'logs') + expect(result).toHaveProperty('response') + }) + test('recoverVault/empty phrase' , async()=>{ try{ let result = await vault.recoverVault(null,bufView,pin,'BgoGMHvB5R7iMNhZ2BoJd470aSZNEz9t2N8PBOWD') @@ -140,7 +217,8 @@ describe("recoverVault",()=>{ }) test('recoverVault/empty encryption key' , async()=>{ let result = await vault.recoverVault(phrase,null,pin,'BgoGMHvB5R7iMNhZ2BoJd470aSZNEz9t2N8PBOWD') - expect(result).toHaveProperty('response') + expect(result.error).toBe("Please enter both encryptionKey and pin") + }) test('recoverVault/invalid encryption key' , async()=>{ @@ -164,14 +242,10 @@ describe("recoverVault",()=>{ }) test('recoverVault/empty marshal key' , async()=>{ - try{ - let result = await vault.recoverVault(phrase,bufView,pin,null) - } - catch(e){ - expect(e.message).toBe("Cannot destructure property 'transactions' of 'response' as it is undefined.") + let result = await vault.recoverVault(phrase,bufView,pin,null) + expect(result.error).toBe("Invalid API key passed") - } }) test('recoverVault/invalid marshal key' , async()=>{ diff --git a/src/lib/vault.js b/src/lib/vault.js index 0e33e57..924c85b 100644 --- a/src/lib/vault.js +++ b/src/lib/vault.js @@ -98,14 +98,23 @@ class Vault extends Keyring { return { response: vault }; } - async recoverVault(mnemonic, encryptionKey, pin, unmarshalApiKey) { + async recoverVault(mnemonic, encryptionKey, pin, unmarshalApiKey, recoverMechanism = 'transactions', logs = {}) { + if (!Number.isInteger(pin) || pin < 0 || pin.toString().length !=6) { return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; } + + if (!encryptionKey) { + return { error : ERROR_MESSAGE.ENTER_CREDS } + } + + if(recoverMechanism === 'transactions' && !unmarshalApiKey) { + return { error: ERROR_MESSAGE.INVALID_API_KEY }; + } const vaultState = await this.keyringInstance.createNewVaultAndRestore(JSON.stringify(encryptionKey), mnemonic); - const accountsArray = await helper.removeEmptyAccounts(vaultState.keyrings[0].accounts[0], this.keyringInstance, vaultState, unmarshalApiKey); + const accountsArray = await helper.removeEmptyAccounts(vaultState.keyrings[0].accounts[0], this.keyringInstance, vaultState, unmarshalApiKey, recoverMechanism, logs); const privData = await helper.generatePrivData(mnemonic, pin); @@ -113,6 +122,8 @@ class Vault extends Keyring { const rawVault = { eth: { public: accountsArray, private: privData, numberOfAccounts } } + this.decryptedVault = rawVault + const vault = await helper.cryptography(JSON.stringify(rawVault), JSON.stringify(encryptionKey), 'encryption'); this.vault = vault; diff --git a/src/utils/helper.js b/src/utils/helper.js index 5649635..8f3e505 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -27,34 +27,53 @@ async function generatePrivData(mnemonic, pin) { return priv; } -async function removeEmptyAccounts(indexAddress, keyringInstance, vaultState, unmarshalApiKey) { + +async function removeEmptyAccounts(indexAddress, keyringInstance, vaultState, unmarshalApiKey, recoverMechanism, logs) { const keyring = keyringInstance.getKeyringsByType(vaultState.keyrings[0].type); let zeroCounter = 0; let accountsArray = []; accountsArray.push({ address: indexAddress, isDeleted: false, isImported: false, label: 'Wallet 1' }); - do { - zeroCounter = 0; - for(let i=0; i < 5; i++) { - const vaultState = await keyringInstance.addNewAccount(keyring[0]); - - const ethActivity = await getETHTransactions(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1], 'ethereum', unmarshalApiKey); - const polygonActivity = await getPolygonTransactions(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1], 'polygon', unmarshalApiKey); - const bscActivity = await getBSCTransactions(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1], 'bsc', unmarshalApiKey); - const label = this.createWalletLabels('all', i+2); - - if (!ethActivity && !polygonActivity && !bscActivity) { - accountsArray.push({ address: vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1], isDeleted: true, isImported: false, label, isExported: false }); - zeroCounter++; - } else { - accountsArray.push({ address: vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1], isDeleted: false, isImported: false, label, isExported: false }); - zeroCounter = 0; + if( recoverMechanism === 'logs'){ + for(let i=0; i < logs.length; i++){ + if (logs[i].action === 'add-account'){ + const vaultState = await keyringInstance.addNewAccount(keyring[0]); + const newAccountAddr = Web3.utils.toChecksumAddress(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1]) + const label = this.createWalletLabels('all', i+2); + if (Web3.utils.toChecksumAddress(logs[i].address) === newAccountAddr) { + accountsArray.push({ address: newAccountAddr, isDeleted: false, isImported: false, label, isExported: false }); + } + + } + if(logs[i].action === 'delete-account') { + let ind = accountsArray.findIndex((acc) => acc.address === Web3.utils.toChecksumAddress(logs[i].address)) + accountsArray[ind].isDeleted = ind ? true : accountsArray[ind].isDeleted; } } - } - while (zeroCounter < 5 ) + } else if( recoverMechanism === 'transactions'){ + do { + zeroCounter = 0; + for(let i=0; i < 5; i++) { + const vaultState = await keyringInstance.addNewAccount(keyring[0]); + + const ethActivity = await getETHTransactions(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1], 'ethereum', unmarshalApiKey); + const polygonActivity = await getPolygonTransactions(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1], 'polygon', unmarshalApiKey); + const bscActivity = await getBSCTransactions(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1], 'bsc', unmarshalApiKey); + const label = this.createWalletLabels('all', i+2); + + if (!ethActivity && !polygonActivity && !bscActivity) { + accountsArray.push({ address: vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1], isDeleted: true, isImported: false, label, isExported: false }); + zeroCounter++; + } else { + accountsArray.push({ address: vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1], isDeleted: false, isImported: false, label, isExported: false }); + zeroCounter = 0; + } + } + } + + while (zeroCounter < 5 ) return accountsArray; } From 10a2acbe15363466d4fbbccbf1b288415ed0bf87 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Tue, 29 Aug 2023 15:29:11 +0530 Subject: [PATCH 24/98] code correction --- src/utils/helper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/helper.js b/src/utils/helper.js index 8f3e505..5fa1fd9 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -74,7 +74,7 @@ async function removeEmptyAccounts(indexAddress, keyringInstance, vaultState, un } while (zeroCounter < 5 ) - + } return accountsArray; } From 63ec1c5647236adf252ead34fb648e5a5d026432 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Tue, 29 Aug 2023 15:43:09 +0530 Subject: [PATCH 25/98] log delete account index check added --- src/utils/helper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/helper.js b/src/utils/helper.js index 5fa1fd9..70825da 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -48,7 +48,7 @@ async function removeEmptyAccounts(indexAddress, keyringInstance, vaultState, un } if(logs[i].action === 'delete-account') { let ind = accountsArray.findIndex((acc) => acc.address === Web3.utils.toChecksumAddress(logs[i].address)) - accountsArray[ind].isDeleted = ind ? true : accountsArray[ind].isDeleted; + ind >= 0 ? accountsArray[ind].isDeleted = true : false; } } From 1cc1fcd4f25b40e76952c2bdf1d9399f2a42baf4 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Fri, 8 Sep 2023 14:09:32 +0530 Subject: [PATCH 26/98] Implemented account recovery and added tests --- CHANGELOG.md | 7 +- package-lock.json | 4 +- package.json | 2 +- src/lib/keyring.js | 52 +++++++ src/lib/test/keyring.test.js | 288 ++++++++++++++++++++++++----------- 5 files changed, 262 insertions(+), 91 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 098a97d..c6af68b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -535,4 +535,9 @@ * Added validation for encryption key in add account, sign message, delete account, get vault details & update label * Sync the pin validation steps with other methods in import wallet * Updated tests wrt changes in vault generation and parameter validations -* Implemented vault recovery using logs and updated tests \ No newline at end of file +* Implemented vault recovery using logs and updated tests + +### 1.30.05 (2023-09-08) Nightly version : only for experimental use + +* Implemented account recovery in case of deleted accounts, both generated and imported +* Added test cases for account recovery \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index fafeaa6..ff8bdc4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getsafle/safle-vault", - "version": "1.30.04", + "version": "1.30.05", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "1.30.04", + "version": "1.30.05", "license": "MIT", "dependencies": { "@getsafle/asset-controller": "^1.0.10", diff --git a/package.json b/package.json index 859de41..02f1f09 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "1.30.04", + "version": "1.30.05", "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": { diff --git a/src/lib/keyring.js b/src/lib/keyring.js index 44a0167..d43a257 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -500,6 +500,58 @@ class Keyring { return { response: vault }; } + async restoreAccount(encryptionKey, address, pin) { + if (!Number.isInteger(pin) || pin < 0) { + throw ERROR_MESSAGE.INCORRECT_PIN_TYPE + } + + const { response } = await this.validatePin(pin); + + if(response == false) { + return { error: ERROR_MESSAGE.INCORRECT_PIN }; + }; + + const { error } = helper.validateEncryptionKey(this.vault, JSON.stringify(encryptionKey)); + + if (error) { + return { error } + } + + let chain = (Chains.evmChains.hasOwnProperty(this.chain) || this.chain === 'ethereum') ? 'eth' : this.chain; + + const importedChain = (chain === 'eth') ? 'evmChains' : chain; + + let objIndex; + + if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) !== undefined && this.decryptedVault.importedWallets[importedChain].data.some(element => element.address === address) == true) { + + objIndex = this.decryptedVault.importedWallets[importedChain].data.findIndex((obj => + obj.address === address + )); + + this.decryptedVault.importedWallets[importedChain].data[objIndex].isDeleted = false; + } else { + + objIndex = this.decryptedVault[chain].public.findIndex((obj => + obj.address === address + )); + + if(objIndex < 0) { + return { error: ERROR_MESSAGE.ADDRESS_NOT_PRESENT }; + } + + this.decryptedVault[chain].public[objIndex].isDeleted = false; + } + + const vault = await helper.cryptography(JSON.stringify(this.decryptedVault), JSON.stringify(encryptionKey), 'encryption', this.encryptor, this.isCustomEncryptor); + + this.vault = vault; + + this.logs.getState().logs.push({ timestamp: Date.now(), action: 'restore-account', vault: this.vault, chain: this.chain, address, platform: this.platform }); + + return { response: vault }; + } + async importWallet(privateKey, pin, encryptionKey) { if (!Number.isInteger(pin) || pin < 0 || pin.toString().length !=6) { return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; diff --git a/src/lib/test/keyring.test.js b/src/lib/test/keyring.test.js index 9e1b7d4..9bbca35 100644 --- a/src/lib/test/keyring.test.js +++ b/src/lib/test/keyring.test.js @@ -13,6 +13,9 @@ let vault =new Vault({}) let vaultAddress let privateKey let accAddress +let privateKeyImp = "0x7a9633b8103fec11c9e855a6b6c8c072e9af311a69b92ab0ad8186b1fb57371f" +let impAccAddress + let chains const ethUrl = 'https://mainnet.infura.io/v3/6145d532688844c4b6db32574d90e19f'; @@ -22,7 +25,7 @@ beforeAll(async() => { result = await vault.generateVault(bufView,pin,phrase) vaultAddress=result.response - await vault.getAccounts(); + await vault.getAccounts(bufView); }); describe('exportMnemonic' , ()=>{ @@ -115,14 +118,14 @@ describe('addAccount' , ()=>{ }) - test('addAccount/empty encryption key' , async()=>{ + test('addAccount/empty encryption key' , async()=>{ try{ let result = await vault.addAccount(null,pin) } catch(e){ expect(e.message).toBe("Incorrect Encryption Key or vault string") } - + }) test('addAccount/empty pin' , async()=>{ @@ -214,6 +217,13 @@ describe('exportPrivateKey' , ()=>{ describe('importWallet' , ()=>{ + test('importWallet/valid import' , async()=>{ + let result = await vault.importWallet("0x"+privateKeyImp,pin,bufView) + impAccAddress = result.response.address + expect(result).toHaveProperty('response.address') + + }) + test('importWallet/valid address exists already' , async()=>{ let result = await vault.importWallet("0x"+privateKey,pin,bufView) @@ -291,9 +301,195 @@ describe('getActiveChains',()=>{ }) }) +describe('deleteAccount',()=>{ + test('deleteAccount/valid generated acc' , async()=>{ + + let result = await vault.deleteAccount(bufView,accAddress,pin) + expect(result).toHaveProperty('response') + + }) + + test('deleteAccount/valid imported acc' , async()=>{ + + let result = await vault.deleteAccount(bufView,impAccAddress,pin) + expect(result).toHaveProperty('response') + + }) + + + test('deleteAccount/empty encryption key' , async()=>{ + try{ + let result = await vault.deleteAccount(null,accAddress,pin) + } + catch(e){ + expect(e.message).toBe("Incorrect Encryption Key or vault string") + } + + + }) + + test('deleteAccount/invalid encryption key' , async()=>{ + try{ + let result = await vault.deleteAccount(null,accAddress,pin) + } + catch(e){ + expect(e.message).toBe("Incorrect Encryption Key or vault string") + } + + + }) + test('deleteAccount/empty address' , async()=>{ + + let result = await vault.deleteAccount(bufView,null,pin) + expect(result.error).toBe('This address is not present in the vault') + + + }) + test('deleteAccount/invalid address' , async()=>{ + + let result = await vault.deleteAccount(bufView,"rerwgtehry",pin) + expect(result.error).toBe('This address is not present in the vault') + + + }) + test('deleteAccount/empty pin' , async()=>{ + + let result = await vault.deleteAccount(bufView,accAddress,null) + expect(result.error).toBe("Wrong pin type, format or length") + + + + + + }) + test('deleteAccount/invalid pin' , async()=>{ + + let result = await vault.deleteAccount(bufView,accAddress,"efwe") + expect(result.error).toBe("Wrong pin type, format or length") + + + }) + test('deleteAccount/incorrect pin' , async()=>{ + + let result = await vault.deleteAccount(bufView,accAddress,111111) + expect(result.error).toBe("Incorrect pin") + + + }) + test('deleteAccount/all params empty' , async()=>{ + try{ + let result = await vault.deleteAccount(null,null,null) + } + catch(e){ + expect(e).toBe('Wrong pin type, format or length') + + } + + + }) +}) + + +describe('restoreAccount', ()=> { + + test('restoreAccount/valid generated acc' , async()=>{ + + let result = await vault.restoreAccount(bufView,accAddress,pin) + expect(result).toHaveProperty('response') + + }) + + test('restoreAccount/valid imported acc' , async()=>{ + + let result = await vault.restoreAccount(bufView,impAccAddress,pin) + expect(result).toHaveProperty('response') + + }) + + + test('restoreAccount/empty encryption key' , async()=>{ + try{ + let result = await vault.restoreAccount(null,accAddress,pin) + } + catch(e){ + expect(e.message).toBe("Incorrect Encryption Key or vault string") + } + + + }) + + test('restoreAccount/invalid encryption key' , async()=>{ + try{ + let result = await vault.restoreAccount(null,accAddress,pin) + } + catch(e){ + expect(e.message).toBe("Incorrect Encryption Key or vault string") + } + + + }) + test('restoreAccount/empty address' , async()=>{ + + let result = await vault.restoreAccount(bufView,null,pin) + expect(result.error).toBe('This address is not present in the vault') + + + }) + test('restoreAccount/invalid address' , async()=>{ + + let result = await vault.restoreAccount(bufView,"rerwgtehry",pin) + expect(result.error).toBe('This address is not present in the vault') + + + }) + test('restoreAccount/empty pin' , async()=>{ + + try { + let result = await vault.restoreAccount(bufView,accAddress,null) + } + catch(e){ + expect(e).toBe('Wrong pin type, format or length') + } + + + }) + test('restoreAccount/invalid pin' , async()=>{ + + try { + let result = await vault.restoreAccount(bufView,accAddress,"efwe") + } + catch(e){ + expect(e).toBe('Wrong pin type, format or length') + } + + + }) + test('restoreAccount/incorrect pin' , async()=>{ + + let result = await vault.restoreAccount(bufView,accAddress,111111) + expect(result.error).toBe("Incorrect pin") + + + }) + test('restoreAccount/all params empty' , async()=>{ + try{ + let result = await vault.restoreAccount(null,null,null) + } + catch(e){ + expect(e).toBe('Wrong pin type, format or length') + + } + + + }) +}) + + describe('restoreKeyringState',()=>{ test('restoreKeyringState/valid' , async()=>{ + + await vault.restoreKeyringState(vaultAddress,pin,bufView) expect(result).toHaveProperty('response') @@ -955,12 +1151,12 @@ describe('changePin',()=>{ test('changePin/empty encryption key' , async()=>{ try{ - let result = await vault.changePin(pin,pin,null) + let result = await vault.changePin(pin,pin,null) } catch(e){ expect(e.message).toBe("Incorrect Encryption Key or vault string") } - + }) @@ -1003,88 +1199,6 @@ describe('getLogs',()=>{ }) -describe('deleteAccount',()=>{ - test('deleteAccount/valid' , async()=>{ - - let result = await vault.deleteAccount(bufView,accAddress,pin) - expect(result.error).toBe('This address is not present in the vault') - - - }) - test('deleteAccount/empty encryption key' , async()=>{ - try{ - let result = await vault.deleteAccount(null,accAddress,pin) - } - catch(e){ - expect(e.message).toBe("Incorrect Encryption Key or vault string") - } - - - }) - - test('deleteAccount/invalid encryption key' , async()=>{ - try{ - let result = await vault.deleteAccount(null,accAddress,pin) - } - catch(e){ - expect(e.message).toBe("Incorrect Encryption Key or vault string") - } - - - }) - test('deleteAccount/empty address' , async()=>{ - - let result = await vault.deleteAccount(bufView,accAddress,pin) - expect(result.error).toBe('This address is not present in the vault') - - - }) - test('deleteAccount/invalid address' , async()=>{ - - let result = await vault.deleteAccount(bufView,"rerwgtehry",pin) - expect(result.error).toBe('This address is not present in the vault') - - - }) - test('deleteAccount/empty pin' , async()=>{ - - let result = await vault.deleteAccount(bufView,accAddress,null) - expect(result.error).toBe("Wrong pin type, format or length") - - - - - - }) - test('deleteAccount/invalid pin' , async()=>{ - - let result = await vault.deleteAccount(bufView,accAddress,"efwe") - expect(result.error).toBe("Wrong pin type, format or length") - - - }) - test('deleteAccount/incorrect pin' , async()=>{ - - let result = await vault.deleteAccount(bufView,accAddress,111111) - expect(result.error).toBe("Incorrect pin") - - - }) - test('deleteAccount/all params empty' , async()=>{ - try{ - let result = await vault.deleteAccount(null,null,null) - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - - } - - - }) -}) - - - describe('getAccounts',()=>{ test('getAccounts/valid' , async()=>{ await vault.restoreKeyringState(vaultAddress,pin,bufView) From 493c489eeb2a39db9bb6a1c59c0efe9da2a868b4 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Tue, 12 Sep 2023 17:34:59 +0530 Subject: [PATCH 27/98] "initial bitcoin integration and test" --- .gitignore | 2 ++ src/lib/keyring.js | 48 ++++++++++++++++++++++++++++----------------- src/lib/vault.js | 47 ++++++++++++++++++++++++++++++++++++++++++-- src/utils/helper.js | 36 +++++++++++++++++++++++++++++++--- 4 files changed, 110 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index 8449a7b..e57e808 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,5 @@ vault_test.js coverage .coverage safle-vault.code-workspace +vault_test.json +vault_test_bitcoin.js diff --git a/src/lib/keyring.js b/src/lib/keyring.js index d43a257..07d7e46 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -350,7 +350,8 @@ class Keyring { return { error: ERROR_MESSAGE.INCORRECT_PIN }; }; - const { error, response } = await this.exportPrivateKey(rawTx.from.toLowerCase(), pin); + const { error, response } = await this.exportPrivateKey(rawTx.from, pin); + // const { error, response } = await this.exportPrivateKey(rawTx.from.toLowerCase(), pin); if (error) { return { error }; @@ -406,10 +407,11 @@ class Keyring { const activeChains = await this.getActiveChains(); - const valuesToRemove = Object.keys(Chains.evmChains); + const evmChainList = Object.keys(Chains.evmChains); - const filteredChains = activeChains.response.filter(activeChains => !valuesToRemove.includes(activeChains.chain)); + const filteredChains = activeChains.response.filter(activeChains => !evmChainList.includes(activeChains.chain)); + //generate other chain's keyring instance and add accounts to it as per decrypted vault if (filteredChains.length > 0) { filteredChains.forEach(async (chainData) => { const { response: mnemonic } = await this.exportMnemonic(pin); @@ -431,6 +433,7 @@ class Keyring { const mnemonic = await helper.cryptography(decryptedVault.eth.private.encryptedMnemonic, pin.toString(), 'decryption'); + // clearing vault state and adding new accounts as per decrypted vault const restoredVault = await this.keyringInstance.createNewVaultAndRestore(JSON.stringify(encryptionKey), mnemonic); const numberOfAcc = this.decryptedVault.eth.numberOfAccounts; @@ -718,7 +721,7 @@ class Keyring { const activeChains = await this.getActiveChains(); - const valuesToRemove = Object.keys(Chains.evmChains); + const evmChainList = Object.keys(Chains.evmChains); accounts.evm.generatedWallets = ({ ...decryptedVault.eth.public }) @@ -728,7 +731,7 @@ class Keyring { accounts.evm.importedWallets = ({ ...decryptedVault.importedWallets.evmChains.data }); } - const filteredChains = activeChains.response.filter(activeChains => !valuesToRemove.includes(activeChains.chain)); + const filteredChains = activeChains.response.filter(activeChains => !evmChainList.includes(activeChains.chain)); let nonEvmAccs = []; @@ -738,18 +741,21 @@ class Keyring { if (containsGenerated) { nonEvmAccs = decryptedVault[chain].public.filter((address) => address.isDeleted === false); - - let result = nonEvmAccs.map(a => { return { address: a.address, label: a.label }}); - - accounts[chain] = { generatedWallets: [ ...result ] }; + + // Comment - It is filtering is-deleted and is-imported data + // let result = nonEvmAccs.map(a => { return { address: a.address, label: a.label }}); + + // accounts[chain] = { generatedWallets: [ ...result ] }; + accounts[chain] = { generatedWallets: [ ...decryptedVault[chain].public ] }; } if (containsImported) { nonEvmAccs = decryptedVault.importedWallets[chain].data.filter((address) => address.isDeleted === false); + // Comment - It is filtering is-deleted and is-imported data + // let result = nonEvmAccs.map(a => { return { address: a.address, label: a.label }}); - let result = nonEvmAccs.map(a => { return { address: a.address, label: a.label }}); - - (accounts[chain] === undefined) ? accounts[chain] = { importedWallets: [ ...result ] } : accounts[chain].importedWallets = [ ...result ]; + // (accounts[chain] === undefined) ? accounts[chain] = { importedWallets: [ ...result ] } : accounts[chain].importedWallets = [ ...result ]; + (accounts[chain] === undefined) ? accounts[chain] = { importedWallets: [ ...decryptedVault.importedWallets[chain].data ] } : accounts[chain].importedWallets = [ ...decryptedVault.importedWallets[chain].data ]; } }); @@ -791,7 +797,8 @@ class Keyring { return { error: ERROR_MESSAGE.INCORRECT_PIN }; }; - const { error, response } = await this.exportPrivateKey(address.toLowerCase(), pin); + // const { error, response } = await this.exportPrivateKey(address.toLowerCase(), pin); + const { error, response } = await this.exportPrivateKey(address, pin); if (error) { return { error }; @@ -854,12 +861,17 @@ class Keyring { return { error: ERROR_MESSAGE.ADDRESS_NOT_PRESENT }; } if (typeof this.decryptedVault[chain].public[objIndex].label === 'string' || this.decryptedVault[chain].public[objIndex].label instanceof String){ - const chains = Object.keys(Chains.evmChains); - let obj = chains.reduce(function(acc, curr) { - acc[curr] = newLabel; - return acc; - }, {}); + if(chain === 'eth') { + const chains = Object.keys(Chains.evmChains); + let obj = chains.reduce(function(acc, curr) { + acc[curr] = newLabel; + return acc; + }, {}); this.decryptedVault[chain].public[objIndex].label = obj; + } + else { + this.decryptedVault[chain].public[objIndex].label = newLabel; + } } else{ (chain === 'eth') ? this.decryptedVault[chain].public[objIndex].label[chainName] = newLabel : this.decryptedVault[chain].public[objIndex].label = newLabel; diff --git a/src/lib/vault.js b/src/lib/vault.js index 924c85b..03600a5 100644 --- a/src/lib/vault.js +++ b/src/lib/vault.js @@ -1,5 +1,6 @@ const CryptoJS = require('crypto-js'); const { KeyringController } = require('@getsafle/vault-eth-controller'); +const BitcoinKeyringController= require('@getsafle/vault-bitcoin-controller').KeyringController ; const bip39 = require('bip39'); const helper = require('../utils/helper'); @@ -49,6 +50,13 @@ class Vault extends Keyring { this.keyringInstance = keyringController; } + // initializeBitcoinKeyringController(mnemonic) { + // // const mnemonic = "example install inhale chronic quick kangaroo tonight awful vast resist best very"; + // const keyringController = new BitcoinKeyringController({mnemonic:mnemonic}); + // // this.bitcoinKeyringInstance = keyringController; + // this["bitcoin"] = keyringController; + // } + async generateMnemonic(entropy) { var mnemonic; @@ -83,7 +91,12 @@ class Vault extends Keyring { const privData = await helper.generatePrivData(mnemonic, pin); - const rawVault = { eth: { public: [ { address: accounts[0], isDeleted: false, isImported: false, label: 'Wallet 1' } ], private: privData, numberOfAccounts: 1 } } + // this.initializeBitcoinKeyringController(mnemonic); + + // const {address: addedAcc } = await this.bitcoinKeyringInstance.addAccount(); + + const rawVault = { eth: { public: [ { address: accounts[0], isDeleted: false, isImported: false, label: 'Wallet 1' } ], private: privData, numberOfAccounts: 1 },} + // bitcoin : { public: [ { address: addedAcc, isDeleted: false, isImported: false, label: 'Bitcoin Wallet 1' } ], numberOfAccounts: 1 } } const vault = await helper.cryptography(JSON.stringify(rawVault), JSON.stringify(encryptionKey), 'encryption'); @@ -91,6 +104,9 @@ class Vault extends Keyring { this.vault = vault; + console.log("decyypted vault = = ", this.decryptedVault); + console.log("this = ", this); + this.logs.updateState({ logs: [{ timestamp: Date.now(), action: 'vault-generation', vault: this.vault }], }); @@ -120,7 +136,34 @@ class Vault extends Keyring { const numberOfAccounts = accountsArray.length; - const rawVault = { eth: { public: accountsArray, private: privData, numberOfAccounts } } + let rawVault = { eth: { public: accountsArray, private: privData, numberOfAccounts } } + + + const activeChains = await this.getActiveChains(); + + const evmChainList = Object.keys(Chains.evmChains); + + const filteredChains = activeChains.response.filter(activeChains => !evmChainList.includes(activeChains.chain)); + + //generate other chain's keyring instance and get accounts from logs + if (filteredChains.length > 0) { + filteredChains.forEach(async (chainData) => { + const { response: mnemonic } = await this.exportMnemonic(pin); + + const keyringInstance = await helper.getCoinInstance(chainData.chain.toLowerCase(), mnemonic); + + const accArray = await helper.getAccountsFromLogs(keyringInstance, vaultState, recoverMechanism, logs); + const numberOfAcc = accArray.length; + + + rawVault = { chainData: { public: accountsArray, numberOfAcc } } + // for (let i = 0; i < numberOfAcc; i++) { + // await this[chainData.chain].addAccount(); + // } + }) + } + + this.decryptedVault = rawVault diff --git a/src/utils/helper.js b/src/utils/helper.js index 70825da..0c67495 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -29,15 +29,19 @@ async function generatePrivData(mnemonic, pin) { async function removeEmptyAccounts(indexAddress, keyringInstance, vaultState, unmarshalApiKey, recoverMechanism, logs) { + const keyring = keyringInstance.getKeyringsByType(vaultState.keyrings[0].type); let zeroCounter = 0; let accountsArray = []; - accountsArray.push({ address: indexAddress, isDeleted: false, isImported: false, label: 'Wallet 1' }); + + indexAddress ? accountsArray.push({ address: indexAddress, isDeleted: false, isImported: false, label: 'Wallet 1' }) : null + + // accountsArray.push({ address: indexAddress, isDeleted: false, isImported: false, label: 'Wallet 1' }); if( recoverMechanism === 'logs'){ for(let i=0; i < logs.length; i++){ - if (logs[i].action === 'add-account'){ + if (logs[i].action === 'add-account' && logs[i].chain === "ethereum"){ const vaultState = await keyringInstance.addNewAccount(keyring[0]); const newAccountAddr = Web3.utils.toChecksumAddress(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1]) const label = this.createWalletLabels('all', i+2); @@ -78,6 +82,30 @@ async function removeEmptyAccounts(indexAddress, keyringInstance, vaultState, un return accountsArray; } +async function getAccountsFromLogs(keyringInstance, vaultState, recoverMechanism, logs) { + + let accountsArray = []; + if( recoverMechanism === 'logs'){ + for(let i=0; i < logs.length; i++){ + if (logs[i].action === 'add-account' && logs[i].chain === "bitcoin"){ + const {address} = await keyringInstance.addAccount(); + // const newAccountAddr = Web3.utils.toChecksumAddress(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1]) + const label = this.createWalletLabels('all', i+2); + if (logs[i].address === address) { + accountsArray.push({ address: address, isDeleted: false, isImported: false, label, isExported: false }); + } + + } + if(logs[i].action === 'delete-account') { + let ind = accountsArray.findIndex((acc) => acc.address === logs[i].address) + ind >= 0 ? accountsArray[ind].isDeleted = true : false; + } + } + + } + return accountsArray; +} + async function getETHTransactions(address, network, unmarshalApiKey) { const transactionController = new safleTransactionController.TransactionController(); @@ -121,7 +149,8 @@ async function getCoinInstance(chain, mnemonic) { return keyringInstance; } - const keyringInstance = new Chains[chain].KeyringController({ mnemonic }); + // const keyringInstance = new Chains[chain].KeyringController({ mnemonic }); + const keyringInstance = new Chains[chain].KeyringController({mnemonic: mnemonic, network: 'TESTNET'}); return keyringInstance; } @@ -233,6 +262,7 @@ module.exports = { stringToArrayBuffer, generatePrivData, removeEmptyAccounts, + getAccountsFromLogs, getCoinInstance, getAssetDetails, cryptography, From c948429026a98488a62785cab7b0c017e776192f Mon Sep 17 00:00:00 2001 From: SDargarh Date: Tue, 12 Sep 2023 18:45:11 +0530 Subject: [PATCH 28/98] added logs for export nmemonic --- .gitignore | 2 ++ src/lib/keyring.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 8449a7b..e57e808 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,5 @@ vault_test.js coverage .coverage safle-vault.code-workspace +vault_test.json +vault_test_bitcoin.js diff --git a/src/lib/keyring.js b/src/lib/keyring.js index d43a257..294cde6 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -45,6 +45,8 @@ class Keyring { return { error: ERROR_MESSAGE.INCORRECT_PIN }; } + this.logs.getState().logs.push({ timestamp: Date.now(), action: 'export-mnemonic', vault: this.vault, chain: this.chain }); + return { response: mnemonic } } From bc0c4d8df1f1818dcfb3837ff611ccd43f5449eb Mon Sep 17 00:00:00 2001 From: SDargarh Date: Tue, 12 Sep 2023 18:55:51 +0530 Subject: [PATCH 29/98] change log update --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c6af68b..f55372e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -540,4 +540,5 @@ ### 1.30.05 (2023-09-08) Nightly version : only for experimental use * Implemented account recovery in case of deleted accounts, both generated and imported -* Added test cases for account recovery \ No newline at end of file +* Added test cases for account recovery +* Added logs for export mnemonic \ No newline at end of file From 8724e6b6e42149dc06b89de2dcd4ee887d669830 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Tue, 12 Sep 2023 19:03:01 +0530 Subject: [PATCH 30/98] Added logs for export private key --- CHANGELOG.md | 3 ++- src/lib/keyring.js | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f55372e..d4cdce3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -541,4 +541,5 @@ * Implemented account recovery in case of deleted accounts, both generated and imported * Added test cases for account recovery -* Added logs for export mnemonic \ No newline at end of file +* Added logs for export mnemonic +* Added logs for export private key(for generated and imported accounts) \ No newline at end of file diff --git a/src/lib/keyring.js b/src/lib/keyring.js index 294cde6..6441c9e 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -184,17 +184,20 @@ class Keyring { decryptedPrivKey = decryptedPrivKey.slice(2) } + this.logs.getState().logs.push({ timestamp: Date.now(), action: 'export-private-key', vault: this.vault, chain: this.chain, address: address, isImportedAddress: isImportedAddress }); return { response: { privateKey: decryptedPrivKey, isImported : isImportedAddress}} } if (chain === 'eth') { const privateKey = await this.keyringInstance.exportAccount(address) + this.logs.getState().logs.push({ timestamp: Date.now(), action: 'export-private-key', vault: this.vault, chain: this.chain, address: address, isImportedAddress: isImportedAddress }); return { response: {privateKey, isImported : isImportedAddress} } } const { privateKey } = await this[chain].exportPrivateKey(address); + this.logs.getState().logs.push({ timestamp: Date.now(), action: 'export-private-key', vault: this.vault, chain: this.chain, address: address, isImportedAddress: isImportedAddress }); return { response: {privateKey, isImported : isImportedAddress} }; } From f1221b5d8211e039e3bc14d3fe9ea758199348f6 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Tue, 12 Sep 2023 21:42:31 +0530 Subject: [PATCH 31/98] Re-encrypt the private key of imported wallets and update vault state after change pin --- CHANGELOG.md | 3 ++- src/lib/keyring.js | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4cdce3..8bbb64a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -542,4 +542,5 @@ * Implemented account recovery in case of deleted accounts, both generated and imported * Added test cases for account recovery * Added logs for export mnemonic -* Added logs for export private key(for generated and imported accounts) \ No newline at end of file +* Added logs for export private key(for generated and imported accounts) +* Re-encrypted the private key of imported wallets and updated vault state after change pin \ No newline at end of file diff --git a/src/lib/keyring.js b/src/lib/keyring.js index 6441c9e..4684aa4 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -880,6 +880,23 @@ class Keyring { return { response: vault }; } + async resetAllImportedWallets(currentPin, newPin) { + const chain = (Chains.evmChains.hasOwnProperty(this.chain) || this.chain === 'ethereum') ? 'eth' : this.chain; + const importedChain = (chain === 'eth') ? 'evmChains' : chain; + + if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) === undefined) { + return null; + } + + let data = this.decryptedVault.importedWallets[importedChain].data + for(let i = 0; i < data.length; i++) { + let decryptedPrivKey = await helper.cryptography(data[i].privateKey, currentPin.toString(), 'decryption'); + let encryptedPrivKey = await helper.cryptography(decryptedPrivKey, newPin.toString(), 'encryption'); + this.decryptedVault.importedWallets[importedChain].data[i].privateKey = encryptedPrivKey + } +} + + async changePin(currentPin, newPin, encryptionKey) { if (!Number.isInteger(currentPin) || currentPin < 0) { @@ -912,6 +929,8 @@ class Keyring { this.decryptedVault.eth.private = privData; + await this.resetAllImportedWallets(currentPin, newPin); + const vault = await helper.cryptography(JSON.stringify(this.decryptedVault), JSON.stringify(encryptionKey), 'encryption'); this.vault = vault; From 42be14c68851a7f0c6d8994fd97cd82b36aa711f Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 18 Sep 2023 15:33:36 +0530 Subject: [PATCH 32/98] gitignore update --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index e57e808..4789a3e 100644 --- a/.gitignore +++ b/.gitignore @@ -57,4 +57,3 @@ coverage .coverage safle-vault.code-workspace vault_test.json -vault_test_bitcoin.js From 636bc933f3131a0f392e0d6ea5fee95a9e27ac74 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Wed, 27 Sep 2023 17:30:56 +0530 Subject: [PATCH 33/98] Added checksum for every address comparison in vault --- CHANGELOG.md | 6 +++++- package-lock.json | 4 ++-- package.json | 2 +- src/lib/keyring.js | 30 +++++++++++++++--------------- 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bbb64a..8a5329a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -543,4 +543,8 @@ * Added test cases for account recovery * Added logs for export mnemonic * Added logs for export private key(for generated and imported accounts) -* Re-encrypted the private key of imported wallets and updated vault state after change pin \ No newline at end of file +* Re-encrypted the private key of imported wallets and updated vault state after change pin + +### 1.30.06 (2023-09-27) Nightly version : only for experimental use + +* Added checksum for every address comparison in vault \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index ff8bdc4..5d91191 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getsafle/safle-vault", - "version": "1.30.05", + "version": "1.30.06", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "1.30.05", + "version": "1.30.06", "license": "MIT", "dependencies": { "@getsafle/asset-controller": "^1.0.10", diff --git a/package.json b/package.json index 02f1f09..fa27696 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "1.30.05", + "version": "1.30.06", "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": { diff --git a/src/lib/keyring.js b/src/lib/keyring.js index 4684aa4..d30167f 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -167,16 +167,16 @@ class Keyring { let isImportedAddress; - if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) !== undefined && this.decryptedVault.importedWallets[importedChain].data.some(element => element.address === address) == true) { + if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) !== undefined && this.decryptedVault.importedWallets[importedChain].data.some(element => Web3.utils.toChecksumAddress(element.address) === Web3.utils.toChecksumAddress(address)) == true) { isImportedAddress = true; - } else if (this.decryptedVault[chain] !== undefined && this.decryptedVault[chain].public.some(element => element.address === address) == true) { + } else if (this.decryptedVault[chain] !== undefined && this.decryptedVault[chain].public.some(element => Web3.utils.toChecksumAddress(element.address) === Web3.utils.toChecksumAddress(address)) == true) { isImportedAddress = false; } else { return { error: ERROR_MESSAGE.ADDRESS_NOT_PRESENT }; } if (isImportedAddress) { - const privateKey = (chain === 'eth') ? this.decryptedVault.importedWallets.evmChains.data.find(element => element.address === address).privateKey : this.decryptedVault.importedWallets[chain].data.find(element => element.address === address).privateKey; + const privateKey = (chain === 'eth') ? this.decryptedVault.importedWallets.evmChains.data.find(element => Web3.utils.toChecksumAddress(element.address) === Web3.utils.toChecksumAddress(address)).privateKey : this.decryptedVault.importedWallets[chain].data.find(element => Web3.utils.toChecksumAddress(element.address) === Web3.utils.toChecksumAddress(address)).privateKey; let decryptedPrivKey = await helper.cryptography(privateKey, pin.toString(), 'decryption'); @@ -324,7 +324,7 @@ class Keyring { else{ const accounts = await this.getAccounts(); - if(accounts.response.filter(e => e.address === address).length < 1) { + if(accounts.response.filter(e => Web3.utils.toChecksumAddress(e.address) === Web3.utils.toChecksumAddress(address)).length < 1) { return { error: ERROR_MESSAGE.NONEXISTENT_KEYRING_ACCOUNT }; } @@ -476,17 +476,17 @@ class Keyring { let objIndex; - if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) !== undefined && this.decryptedVault.importedWallets[importedChain].data.some(element => element.address === address) == true) { + if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) !== undefined && this.decryptedVault.importedWallets[importedChain].data.some(element => Web3.utils.toChecksumAddress(element.address) === Web3.utils.toChecksumAddress(address)) == true) { objIndex = this.decryptedVault.importedWallets[importedChain].data.findIndex((obj => - obj.address === address + Web3.utils.toChecksumAddress(obj.address) === Web3.utils.toChecksumAddress(address) )); this.decryptedVault.importedWallets[importedChain].data[objIndex].isDeleted = true; } else { objIndex = this.decryptedVault[chain].public.findIndex((obj => - obj.address === address + Web3.utils.toChecksumAddress(obj.address) === Web3.utils.toChecksumAddress(address) )); if(objIndex < 0) { @@ -528,17 +528,17 @@ class Keyring { let objIndex; - if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) !== undefined && this.decryptedVault.importedWallets[importedChain].data.some(element => element.address === address) == true) { + if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) !== undefined && this.decryptedVault.importedWallets[importedChain].data.some(element => Web3.utils.toChecksumAddress(element.address) === Web3.utils.toChecksumAddress(address)) == true) { objIndex = this.decryptedVault.importedWallets[importedChain].data.findIndex((obj => - obj.address === address + Web3.utils.toChecksumAddress(obj.address) === Web3.utils.toChecksumAddress(address) )); this.decryptedVault.importedWallets[importedChain].data[objIndex].isDeleted = false; } else { objIndex = this.decryptedVault[chain].public.findIndex((obj => - obj.address === address + Web3.utils.toChecksumAddress(obj.address) === Web3.utils.toChecksumAddress(address) )); if(objIndex < 0) { @@ -601,7 +601,7 @@ class Keyring { numOfAcc = accounts.response.length; accounts.response.forEach(element => { - if (element.address === address) { + if (Web3.utils.toChecksumAddress(element.address) === Web3.utils.toChecksumAddress(address)) { isDuplicateAddress = true; } }); @@ -635,7 +635,7 @@ class Keyring { accounts.response.forEach(element => { numOfAcc = accounts.response.length; - if (element.address === address) { + if (Web3.utils.toChecksumAddress(element.address) === Web3.utils.toChecksumAddress(address)) { isDuplicateAddress = true; } }); @@ -842,17 +842,17 @@ class Keyring { let objIndex; - if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) !== undefined && this.decryptedVault.importedWallets[importedChain].data.some(element => element.address === address) == true) { + if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) !== undefined && this.decryptedVault.importedWallets[importedChain].data.some(element => Web3.utils.toChecksumAddress(element.address) === Web3.utils.toChecksumAddress(address)) == true) { objIndex = this.decryptedVault.importedWallets[importedChain].data.findIndex((obj => - obj.address === address + Web3.utils.toChecksumAddress(obj.address) === Web3.utils.toChecksumAddress(address) )); this.decryptedVault.importedWallets[importedChain].data[objIndex].label = newLabel; } else { objIndex = this.decryptedVault[chain].public.findIndex((obj => - obj.address === address + Web3.utils.toChecksumAddress(obj.address) === Web3.utils.toChecksumAddress(address) )); if(objIndex < 0) { From 32583e5e48b5c7cf134ca6a4bf6cceb994b740b6 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Wed, 27 Sep 2023 17:40:19 +0530 Subject: [PATCH 34/98] updated label creation according to logs --- src/utils/helper.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils/helper.js b/src/utils/helper.js index 70825da..65e2e16 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -34,15 +34,17 @@ async function removeEmptyAccounts(indexAddress, keyringInstance, vaultState, un let zeroCounter = 0; let accountsArray = []; accountsArray.push({ address: indexAddress, isDeleted: false, isImported: false, label: 'Wallet 1' }); + let labelCounter = 2; // as an initial wallet is already created above with label 'Wallet 1' if( recoverMechanism === 'logs'){ for(let i=0; i < logs.length; i++){ if (logs[i].action === 'add-account'){ const vaultState = await keyringInstance.addNewAccount(keyring[0]); const newAccountAddr = Web3.utils.toChecksumAddress(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1]) - const label = this.createWalletLabels('all', i+2); if (Web3.utils.toChecksumAddress(logs[i].address) === newAccountAddr) { + const label = this.createWalletLabels('all', labelCounter); accountsArray.push({ address: newAccountAddr, isDeleted: false, isImported: false, label, isExported: false }); + labelCounter++; } } From 140e8f327992277877109bcaa6a99348757389f6 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Wed, 27 Sep 2023 18:22:52 +0530 Subject: [PATCH 35/98] reverted few checksum comparison and updated tests --- CHANGELOG.md | 4 +++- src/lib/keyring.js | 28 ++++++++++++++-------------- src/lib/test/keyring.test.js | 21 ++++++++++++++------- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a5329a..863a1fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -547,4 +547,6 @@ ### 1.30.06 (2023-09-27) Nightly version : only for experimental use -* Added checksum for every address comparison in vault \ No newline at end of file +* Added checksum for address comparison in export private key +* Updated label creation according to logs +* Updated test cases according to checksum address comparison in export private key \ No newline at end of file diff --git a/src/lib/keyring.js b/src/lib/keyring.js index d30167f..d5a10ad 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -167,7 +167,7 @@ class Keyring { let isImportedAddress; - if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) !== undefined && this.decryptedVault.importedWallets[importedChain].data.some(element => Web3.utils.toChecksumAddress(element.address) === Web3.utils.toChecksumAddress(address)) == true) { + if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) !== undefined && this.decryptedVault.importedWallets[importedChain].data.some(element => element.address === address) == true) { isImportedAddress = true; } else if (this.decryptedVault[chain] !== undefined && this.decryptedVault[chain].public.some(element => Web3.utils.toChecksumAddress(element.address) === Web3.utils.toChecksumAddress(address)) == true) { isImportedAddress = false; @@ -176,7 +176,7 @@ class Keyring { } if (isImportedAddress) { - const privateKey = (chain === 'eth') ? this.decryptedVault.importedWallets.evmChains.data.find(element => Web3.utils.toChecksumAddress(element.address) === Web3.utils.toChecksumAddress(address)).privateKey : this.decryptedVault.importedWallets[chain].data.find(element => Web3.utils.toChecksumAddress(element.address) === Web3.utils.toChecksumAddress(address)).privateKey; + const privateKey = (chain === 'eth') ? this.decryptedVault.importedWallets.evmChains.data.find(element => element.address === address).privateKey : this.decryptedVault.importedWallets[chain].data.find(element => element.address === address).privateKey; let decryptedPrivKey = await helper.cryptography(privateKey, pin.toString(), 'decryption'); @@ -324,7 +324,7 @@ class Keyring { else{ const accounts = await this.getAccounts(); - if(accounts.response.filter(e => Web3.utils.toChecksumAddress(e.address) === Web3.utils.toChecksumAddress(address)).length < 1) { + if(accounts.response.filter(e => e.address === address).length < 1) { return { error: ERROR_MESSAGE.NONEXISTENT_KEYRING_ACCOUNT }; } @@ -476,17 +476,17 @@ class Keyring { let objIndex; - if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) !== undefined && this.decryptedVault.importedWallets[importedChain].data.some(element => Web3.utils.toChecksumAddress(element.address) === Web3.utils.toChecksumAddress(address)) == true) { + if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) !== undefined && this.decryptedVault.importedWallets[importedChain].data.some(element => element.address === address) == true) { objIndex = this.decryptedVault.importedWallets[importedChain].data.findIndex((obj => - Web3.utils.toChecksumAddress(obj.address) === Web3.utils.toChecksumAddress(address) + obj.address === address )); this.decryptedVault.importedWallets[importedChain].data[objIndex].isDeleted = true; } else { objIndex = this.decryptedVault[chain].public.findIndex((obj => - Web3.utils.toChecksumAddress(obj.address) === Web3.utils.toChecksumAddress(address) + obj.address === address )); if(objIndex < 0) { @@ -528,17 +528,17 @@ class Keyring { let objIndex; - if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) !== undefined && this.decryptedVault.importedWallets[importedChain].data.some(element => Web3.utils.toChecksumAddress(element.address) === Web3.utils.toChecksumAddress(address)) == true) { + if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) !== undefined && this.decryptedVault.importedWallets[importedChain].data.some(element => element.address === address) == true) { objIndex = this.decryptedVault.importedWallets[importedChain].data.findIndex((obj => - Web3.utils.toChecksumAddress(obj.address) === Web3.utils.toChecksumAddress(address) + obj.address === address )); this.decryptedVault.importedWallets[importedChain].data[objIndex].isDeleted = false; } else { objIndex = this.decryptedVault[chain].public.findIndex((obj => - Web3.utils.toChecksumAddress(obj.address) === Web3.utils.toChecksumAddress(address) + obj.address === address )); if(objIndex < 0) { @@ -601,7 +601,7 @@ class Keyring { numOfAcc = accounts.response.length; accounts.response.forEach(element => { - if (Web3.utils.toChecksumAddress(element.address) === Web3.utils.toChecksumAddress(address)) { + if (element.address === address) { isDuplicateAddress = true; } }); @@ -635,7 +635,7 @@ class Keyring { accounts.response.forEach(element => { numOfAcc = accounts.response.length; - if (Web3.utils.toChecksumAddress(element.address) === Web3.utils.toChecksumAddress(address)) { + if (element.address === address) { isDuplicateAddress = true; } }); @@ -842,17 +842,17 @@ class Keyring { let objIndex; - if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) !== undefined && this.decryptedVault.importedWallets[importedChain].data.some(element => Web3.utils.toChecksumAddress(element.address) === Web3.utils.toChecksumAddress(address)) == true) { + if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) !== undefined && this.decryptedVault.importedWallets[importedChain].data.some(element => element.address === address) == true) { objIndex = this.decryptedVault.importedWallets[importedChain].data.findIndex((obj => - Web3.utils.toChecksumAddress(obj.address) === Web3.utils.toChecksumAddress(address) + obj.address === address )); this.decryptedVault.importedWallets[importedChain].data[objIndex].label = newLabel; } else { objIndex = this.decryptedVault[chain].public.findIndex((obj => - Web3.utils.toChecksumAddress(obj.address) === Web3.utils.toChecksumAddress(address) + obj.address === address )); if(objIndex < 0) { diff --git a/src/lib/test/keyring.test.js b/src/lib/test/keyring.test.js index 9bbca35..2a7a056 100644 --- a/src/lib/test/keyring.test.js +++ b/src/lib/test/keyring.test.js @@ -180,10 +180,13 @@ describe('exportPrivateKey' , ()=>{ test('exportPrivateKey/empty accAddress' , async()=>{ - let result = await vault.exportPrivateKey(null,pin) - expect(result.error).toBe('This address is not present in the vault') - - + try{ + let result = await vault.exportPrivateKey(null,pin) + } + catch(e){ + expect(e.message).toBe('Given address "null" is not a valid Ethereum address.') + } + }) @@ -772,9 +775,13 @@ describe('sign',()=>{ test('sign/invalid address' , async()=>{ let data="hello world" - - let result = await vault.sign(data,"abc",pin,ethUrl) - expect(result.error).toBe('This address is not present in the vault') + try{ + let result = await vault.sign(data,"abc",pin,ethUrl) + } + catch(e){ + expect(e.message).toBe('Given address "null" is not a valid Ethereum address.') + } + From a9231fa0cd7b64f856ccc4036a2b3e5d11498f44 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Wed, 27 Sep 2023 18:27:01 +0530 Subject: [PATCH 36/98] sign/invalid address test case update --- src/lib/test/keyring.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/test/keyring.test.js b/src/lib/test/keyring.test.js index 2a7a056..4cf1b4f 100644 --- a/src/lib/test/keyring.test.js +++ b/src/lib/test/keyring.test.js @@ -779,7 +779,7 @@ describe('sign',()=>{ let result = await vault.sign(data,"abc",pin,ethUrl) } catch(e){ - expect(e.message).toBe('Given address "null" is not a valid Ethereum address.') + expect(e.message).toBe('Given address "abc" is not a valid Ethereum address.') } From 33eb5a2b3d774fd4dcce8957e48bda784929b3c0 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Wed, 4 Oct 2023 18:32:01 +0530 Subject: [PATCH 37/98] recover vault update for bitcoin --- package-lock.json | 8 ++++---- package.json | 2 +- src/lib/vault.js | 14 ++++++-------- src/utils/helper.js | 20 ++++++++++++-------- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5d91191..7eb52d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@getsafle/safle-identity-wallet": "^1.3.0", "@getsafle/transaction-controller": "^1.9.3", "@getsafle/vault-arbitrum-controller": "^1.0.7", - "@getsafle/vault-bitcoin-controller": "^1.2.3", + "@getsafle/vault-bitcoin-controller": "^2.0.0", "@getsafle/vault-bsc-controller": "^1.2.2", "@getsafle/vault-eth-controller": "^1.4.5", "@getsafle/vault-mantle-controller": "^1.0.0", @@ -1395,9 +1395,9 @@ } }, "node_modules/@getsafle/vault-bitcoin-controller": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/@getsafle/vault-bitcoin-controller/-/vault-bitcoin-controller-1.2.3.tgz", - "integrity": "sha512-gIqkNiJc5meLnThBCHvDirvwYwFLlGzPHPp3dN+c2kJSID6P5O/GMakuPwmDEQp4FGkCdTltu1qm9qpbmRSyjA==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@getsafle/vault-bitcoin-controller/-/vault-bitcoin-controller-2.0.0.tgz", + "integrity": "sha512-Jz6Mef3Osv5sKDoD8cFTS09y933ThbrT+STyL38zgviX/fHf57j+iYFzJ+tIByS0nK7pxJgMaQXai/nmOWvLUw==", "dependencies": { "axios": "^0.21.4", "bip39": "^2.2.0", diff --git a/package.json b/package.json index fa27696..1589678 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@getsafle/safle-identity-wallet": "^1.3.0", "@getsafle/transaction-controller": "^1.9.3", "@getsafle/vault-arbitrum-controller": "^1.0.7", - "@getsafle/vault-bitcoin-controller": "^1.2.3", + "@getsafle/vault-bitcoin-controller": "^2.0.0", "@getsafle/vault-bsc-controller": "^1.2.2", "@getsafle/vault-eth-controller": "^1.4.5", "@getsafle/vault-mantle-controller": "^1.0.0", diff --git a/src/lib/vault.js b/src/lib/vault.js index 03600a5..e946ae7 100644 --- a/src/lib/vault.js +++ b/src/lib/vault.js @@ -146,8 +146,9 @@ class Vault extends Keyring { const filteredChains = activeChains.response.filter(activeChains => !evmChainList.includes(activeChains.chain)); //generate other chain's keyring instance and get accounts from logs + let obj = {} if (filteredChains.length > 0) { - filteredChains.forEach(async (chainData) => { + for ( let chainData of filteredChains ) { const { response: mnemonic } = await this.exportMnemonic(pin); const keyringInstance = await helper.getCoinInstance(chainData.chain.toLowerCase(), mnemonic); @@ -155,16 +156,13 @@ class Vault extends Keyring { const accArray = await helper.getAccountsFromLogs(keyringInstance, vaultState, recoverMechanism, logs); const numberOfAcc = accArray.length; + rawVault[chainData.chain.toLowerCase()] = { public: accArray, numberOfAcc } + console.log("rawVault = ", rawVault); - rawVault = { chainData: { public: accountsArray, numberOfAcc } } - // for (let i = 0; i < numberOfAcc; i++) { - // await this[chainData.chain].addAccount(); - // } - }) + } + } - - this.decryptedVault = rawVault const vault = await helper.cryptography(JSON.stringify(rawVault), JSON.stringify(encryptionKey), 'encryption'); diff --git a/src/utils/helper.js b/src/utils/helper.js index 520e064..98b1e1d 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -34,10 +34,8 @@ async function removeEmptyAccounts(indexAddress, keyringInstance, vaultState, un let zeroCounter = 0; let accountsArray = []; - - indexAddress ? accountsArray.push({ address: indexAddress, isDeleted: false, isImported: false, label: 'Wallet 1' }) : null - - // accountsArray.push({ address: indexAddress, isDeleted: false, isImported: false, label: 'Wallet 1' }); + accountsArray.push({ address: indexAddress, isDeleted: false, isImported: false, label: 'Wallet 1' }); + let labelCounter = 2; // as an initial wallet is already created above with label 'Wallet 1' if( recoverMechanism === 'logs'){ for(let i=0; i < logs.length; i++){ @@ -86,14 +84,16 @@ async function removeEmptyAccounts(indexAddress, keyringInstance, vaultState, un async function getAccountsFromLogs(keyringInstance, vaultState, recoverMechanism, logs) { let accountsArray = []; + let labelCounter = 1; if( recoverMechanism === 'logs'){ for(let i=0; i < logs.length; i++){ if (logs[i].action === 'add-account' && logs[i].chain === "bitcoin"){ const {address} = await keyringInstance.addAccount(); // const newAccountAddr = Web3.utils.toChecksumAddress(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1]) - const label = this.createWalletLabels('all', i+2); if (logs[i].address === address) { + const label = this.createWalletLabels('bitcoin', labelCounter); accountsArray.push({ address: address, isDeleted: false, isImported: false, label, isExported: false }); + labelCounter ++; } } @@ -150,8 +150,8 @@ async function getCoinInstance(chain, mnemonic) { return keyringInstance; } - // const keyringInstance = new Chains[chain].KeyringController({ mnemonic }); - const keyringInstance = new Chains[chain].KeyringController({mnemonic: mnemonic, network: 'TESTNET'}); + const keyringInstance = new Chains[chain].KeyringController({ mnemonic }); + // const keyringInstance = new Chains[chain].KeyringController({mnemonic: mnemonic, network: 'TESTNET'}); return keyringInstance; } @@ -248,7 +248,11 @@ function createWalletLabels(labelObj = 'all', walletIndex = 1) { if (labelObj === 'all') { chains.forEach(chain => labels[chain] = `${chain.charAt(0).toUpperCase() + chain.substr(1).toLowerCase()} Wallet ${walletIndex}` ); - } else { + } + else if (labelObj === 'bitcoin') { + labels = `${labelObj.charAt(0).toUpperCase() + labelObj.substr(1).toLowerCase()} Wallet ${walletIndex}`; + } + else { chains.forEach(chain => { if (labels[chain] !== undefined) { labels[chain] = `${chain.charAt(0).toUpperCase() + chain.substr(1).toLowerCase()} Wallet ${walletIndex}`; From 6504518ce5a84d29ad6e135b05848b555afd2255 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Wed, 4 Oct 2023 23:57:01 +0530 Subject: [PATCH 38/98] bitcoin integration updates for imported wallets --- src/lib/keyring.js | 60 ++++++++++++++++++++++++++++++++++++---------- src/lib/vault.js | 7 ------ 2 files changed, 47 insertions(+), 20 deletions(-) diff --git a/src/lib/keyring.js b/src/lib/keyring.js index a1da6ba..00d2c3f 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -169,7 +169,8 @@ class Keyring { if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) !== undefined && this.decryptedVault.importedWallets[importedChain].data.some(element => element.address === address) == true) { isImportedAddress = true; - } else if (this.decryptedVault[chain] !== undefined && this.decryptedVault[chain].public.some(element => Web3.utils.toChecksumAddress(element.address) === Web3.utils.toChecksumAddress(address)) == true) { + // } else if (this.decryptedVault[chain] !== undefined && this.decryptedVault[chain].public.some(element => Web3.utils.toChecksumAddress(element.address) === Web3.utils.toChecksumAddress(address)) == true) { + } else if (this.decryptedVault[chain] !== undefined && this.decryptedVault[chain].public.some(element => element.address.toLowerCase() === address.toLowerCase()) == true) { isImportedAddress = false; } else { return { error: ERROR_MESSAGE.ADDRESS_NOT_PRESENT }; @@ -318,6 +319,12 @@ class Keyring { return { response: signedMessage.message }; } + if (Chains?.[this.chain]){ + const { signedMessage } = await this[this.chain].signMessage(data, address, privateKey); + return { response: signedMessage }; + + } + return { error: ERROR_MESSAGE.UNSUPPORTED_NON_EVM_FUNCTIONALITY } } @@ -384,7 +391,15 @@ class Keyring { return { response: signedTx }; } - const { signedTransaction } = await this[this.chain].signTransaction(rawTx, privateKey); + if(isImported) { + const { signedTransaction } = await this[this.chain].signTransaction(rawTx, privateKey); + return { response: signedTransaction }; + } + else{ + const { signedTransaction } = await this[this.chain].signTransaction(rawTx); + return { response: signedTransaction }; + } + return { response: signedTransaction }; } @@ -751,7 +766,7 @@ class Keyring { // let result = nonEvmAccs.map(a => { return { address: a.address, label: a.label }}); // accounts[chain] = { generatedWallets: [ ...result ] }; - accounts[chain] = { generatedWallets: [ ...decryptedVault[chain].public ] }; + accounts[chain] = { generatedWallets: { ...decryptedVault[chain].public } }; } if (containsImported) { @@ -760,7 +775,7 @@ class Keyring { // let result = nonEvmAccs.map(a => { return { address: a.address, label: a.label }}); // (accounts[chain] === undefined) ? accounts[chain] = { importedWallets: [ ...result ] } : accounts[chain].importedWallets = [ ...result ]; - (accounts[chain] === undefined) ? accounts[chain] = { importedWallets: [ ...decryptedVault.importedWallets[chain].data ] } : accounts[chain].importedWallets = [ ...decryptedVault.importedWallets[chain].data ]; + (accounts[chain] === undefined) ? accounts[chain] = { importedWallets: { ...decryptedVault.importedWallets[chain].data } } : accounts[chain].importedWallets = { ...decryptedVault.importedWallets[chain].data }; } }); @@ -786,7 +801,7 @@ class Keyring { return { response: balance }; } - const balance = await Chains[this.chain].getBalance(address, rpcUrl); + const balance = await Chains[this.chain].getBalance(address); return { response: balance }; } @@ -893,19 +908,38 @@ class Keyring { } async resetAllImportedWallets(currentPin, newPin) { - const chain = (Chains.evmChains.hasOwnProperty(this.chain) || this.chain === 'ethereum') ? 'eth' : this.chain; - const importedChain = (chain === 'eth') ? 'evmChains' : chain; - if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) === undefined) { + // const evmChainList = Object.keys(Chains.evmChains); + + // const filteredChains = activeChains.response.filter(activeChains => !evmChainList.includes(activeChains.chain)); + + + + // const chain = (Chains.evmChains.hasOwnProperty(this.chain) || this.chain === 'ethereum') ? 'eth' : this.chain; + // const importedChain = (chain === 'eth') ? 'evmChains' : chain; + + // if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) === undefined) { + // return null; + // } + + if (_.get(this.decryptedVault, `importedWallets`) === undefined) { return null; } - let data = this.decryptedVault.importedWallets[importedChain].data - for(let i = 0; i < data.length; i++) { - let decryptedPrivKey = await helper.cryptography(data[i].privateKey, currentPin.toString(), 'decryption'); - let encryptedPrivKey = await helper.cryptography(decryptedPrivKey, newPin.toString(), 'encryption'); - this.decryptedVault.importedWallets[importedChain].data[i].privateKey = encryptedPrivKey + let importedChains = Object.keys(this.decryptedVault.importedWallets) + + for (let importedChain of importedChains) + { + let data = this.decryptedVault.importedWallets[importedChain].data + for(let i = 0; i < data.length; i++) { + let decryptedPrivKey = await helper.cryptography(data[i].privateKey, currentPin.toString(), 'decryption'); + let encryptedPrivKey = await helper.cryptography(decryptedPrivKey, newPin.toString(), 'encryption'); + this.decryptedVault.importedWallets[importedChain].data[i].privateKey = encryptedPrivKey + // 'U2FsdGVkX18FMr+3tQmbjTmKwadj5fPPqrExRP8mUUXxT9chK9fkt+Dl8GtC7hJNfiazLnQEubTILDten238/cVqH6UAZduAXnrEEDmOUBBzhS/xAT7LvB17tycrGDXy' + + } } + } diff --git a/src/lib/vault.js b/src/lib/vault.js index e946ae7..0081837 100644 --- a/src/lib/vault.js +++ b/src/lib/vault.js @@ -50,13 +50,6 @@ class Vault extends Keyring { this.keyringInstance = keyringController; } - // initializeBitcoinKeyringController(mnemonic) { - // // const mnemonic = "example install inhale chronic quick kangaroo tonight awful vast resist best very"; - // const keyringController = new BitcoinKeyringController({mnemonic:mnemonic}); - // // this.bitcoinKeyringInstance = keyringController; - // this["bitcoin"] = keyringController; - // } - async generateMnemonic(entropy) { var mnemonic; From 8f1aa0140b20008d45c9fbf5144a46c38bde33bf Mon Sep 17 00:00:00 2001 From: SDargarh Date: Thu, 5 Oct 2023 13:53:51 +0530 Subject: [PATCH 39/98] Updated pin format from number to string and tests --- CHANGELOG.md | 7 +++++- package-lock.json | 4 ++-- package.json | 2 +- src/lib/keyring.js | 42 ++++++++++++++++++------------------ src/lib/test/keyring.test.js | 24 ++++++++++----------- src/lib/test/vault.test.js | 8 +++---- src/lib/vault.js | 5 +++-- src/utils/helper.js | 2 +- 8 files changed, 50 insertions(+), 44 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 863a1fd..ced2a68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -549,4 +549,9 @@ * Added checksum for address comparison in export private key * Updated label creation according to logs -* Updated test cases according to checksum address comparison in export private key \ No newline at end of file +* Updated test cases according to checksum address comparison in export private key + +### 1.30.07 (2023-10-05) Nightly version : only for experimental use + +* Updated pin format from number to string +* updated test cases according to pin format changes \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 5d91191..12f1a69 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getsafle/safle-vault", - "version": "1.30.06", + "version": "1.30.07", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "1.30.06", + "version": "1.30.07", "license": "MIT", "dependencies": { "@getsafle/asset-controller": "^1.0.10", diff --git a/package.json b/package.json index fa27696..f90ff6a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "1.30.06", + "version": "1.30.07", "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": { diff --git a/src/lib/keyring.js b/src/lib/keyring.js index d5a10ad..9f48392 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -27,7 +27,7 @@ class Keyring { } async exportMnemonic(pin) { - if (!Number.isInteger(pin) || pin < 0 || pin.toString().length !=6 ) { + if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; } @@ -37,7 +37,7 @@ class Keyring { return { error: ERROR_MESSAGE.INCORRECT_PIN }; } - const mnemonic = await helper.cryptography(this.decryptedVault.eth.private.encryptedMnemonic, pin.toString(), 'decryption'); + const mnemonic = await helper.cryptography(this.decryptedVault.eth.private.encryptedMnemonic, pin, 'decryption'); const spaceCount = mnemonic.split(" ").length - 1; @@ -67,14 +67,14 @@ class Keyring { this.timeout = Date.now() + Config.REQUEST_BLOCKED_TIMEOUT; return { error: ERROR_MESSAGE.REQUEST_LIMIT_EXCEEDED }; } else { - if (!Number.isInteger(pin) || pin < 0 || pin.toString().length !=6) { + if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; } let spaceCount; try { - const mnemonic = await helper.cryptography(this.decryptedVault.eth.private.encryptedMnemonic, pin.toString(), 'decryption'); + const mnemonic = await helper.cryptography(this.decryptedVault.eth.private.encryptedMnemonic, pin, 'decryption'); spaceCount = mnemonic.split(" ").length - 1; } catch (error) { @@ -152,7 +152,7 @@ class Keyring { } async exportPrivateKey(address, pin) { - if (!Number.isInteger(pin) || pin < 0 || pin.toString().length !=6) { + if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; } @@ -178,7 +178,7 @@ class Keyring { if (isImportedAddress) { const privateKey = (chain === 'eth') ? this.decryptedVault.importedWallets.evmChains.data.find(element => element.address === address).privateKey : this.decryptedVault.importedWallets[chain].data.find(element => element.address === address).privateKey; - let decryptedPrivKey = await helper.cryptography(privateKey, pin.toString(), 'decryption'); + let decryptedPrivKey = await helper.cryptography(privateKey, pin, 'decryption'); if (decryptedPrivKey.startsWith('0x')) { decryptedPrivKey = decryptedPrivKey.slice(2) @@ -202,7 +202,7 @@ class Keyring { } async addAccount(encryptionKey, pin) { - if (!Number.isInteger(pin) || pin < 0 || pin.toString().length !=6) { + if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; } @@ -275,7 +275,7 @@ class Keyring { } async signMessage(address, data, pin, encryptionKey, rpcUrl = '') { - if (!Number.isInteger(pin) || pin < 0 || pin.toString().length !=6) { + if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; } @@ -345,7 +345,7 @@ class Keyring { } async signTransaction(rawTx, pin, rpcUrl) { - if (!Number.isInteger(pin) || pin < 0 || pin.toString().length !=6) { + if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; } @@ -389,7 +389,7 @@ class Keyring { } async restoreKeyringState(vault, pin, encryptionKey) { - if (!Number.isInteger(pin) || pin < 0 || pin.toString().length !=6) { + if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; } @@ -434,7 +434,7 @@ class Keyring { this.logs.getState().logs.push({ timestamp: Date.now(), action: 'restore-keyring', vault: this.vault }); - const mnemonic = await helper.cryptography(decryptedVault.eth.private.encryptedMnemonic, pin.toString(), 'decryption'); + const mnemonic = await helper.cryptography(decryptedVault.eth.private.encryptedMnemonic, pin, 'decryption'); const restoredVault = await this.keyringInstance.createNewVaultAndRestore(JSON.stringify(encryptionKey), mnemonic); @@ -454,7 +454,7 @@ class Keyring { } async deleteAccount(encryptionKey, address, pin) { - if (!Number.isInteger(pin) || pin < 0 || pin.toString().length !=6) { + if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; } @@ -506,8 +506,8 @@ class Keyring { } async restoreAccount(encryptionKey, address, pin) { - if (!Number.isInteger(pin) || pin < 0) { - throw ERROR_MESSAGE.INCORRECT_PIN_TYPE + if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { + return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; } const { response } = await this.validatePin(pin); @@ -558,7 +558,7 @@ class Keyring { } async importWallet(privateKey, pin, encryptionKey) { - if (!Number.isInteger(pin) || pin < 0 || pin.toString().length !=6) { + if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; } @@ -578,7 +578,7 @@ class Keyring { privateKey = privateKey.slice(2) } - const encryptedPrivKey = await helper.cryptography(privateKey, pin.toString(), 'encryption'); + const encryptedPrivKey = await helper.cryptography(privateKey, pin, 'encryption'); let address; let accounts; @@ -786,7 +786,7 @@ class Keyring { } async sign(data, address, pin, rpcUrl) { - if (!Number.isInteger(pin) || pin < 0 || pin.toString().length !=6) { + if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; } @@ -890,8 +890,8 @@ class Keyring { let data = this.decryptedVault.importedWallets[importedChain].data for(let i = 0; i < data.length; i++) { - let decryptedPrivKey = await helper.cryptography(data[i].privateKey, currentPin.toString(), 'decryption'); - let encryptedPrivKey = await helper.cryptography(decryptedPrivKey, newPin.toString(), 'encryption'); + let decryptedPrivKey = await helper.cryptography(data[i].privateKey, currentpin, 'decryption'); + let encryptedPrivKey = await helper.cryptography(decryptedPrivKey, newpin, 'encryption'); this.decryptedVault.importedWallets[importedChain].data[i].privateKey = encryptedPrivKey } } @@ -899,11 +899,11 @@ class Keyring { async changePin(currentPin, newPin, encryptionKey) { - if (!Number.isInteger(currentPin) || currentPin < 0) { + if (typeof(currentPin) != 'string' || currentPin < 0) { throw ERROR_MESSAGE.INCORRECT_PIN_TYPE } - if (!Number.isInteger(newPin) || newPin < 0) { + if (typeof(newPin) != 'string' || newPin < 0) { throw ERROR_MESSAGE.INCORRECT_PIN_TYPE } diff --git a/src/lib/test/keyring.test.js b/src/lib/test/keyring.test.js index 4cf1b4f..185708f 100644 --- a/src/lib/test/keyring.test.js +++ b/src/lib/test/keyring.test.js @@ -7,7 +7,7 @@ let Vault = require('../vault') const Web3 = require('web3') const bufView = [48, 0, 236, 187, 187, 172, 177, 90, 255, 184, 9, 116, 142, 96, 197, 158, 87, 35, 26, 101, 187, 30, 116, 138, 50, 131, 166, 50, 51, 197, 198, 83, 238, 167, 105, 178, 182, 108, 174, 199, 124, 141, 155, 73, 21, 85, 81, 109, 78, 233, 152, 108, 242, 238, 192, 31, 147, 86, 174, 195, 55, 229, 4, 36]; let phrase="fun rough treat scan glimpse region century purpose expire video remind second" -let pin=696969 +let pin="696969" let result let vault =new Vault({}) let vaultAddress @@ -37,7 +37,7 @@ describe('exportMnemonic' , ()=>{ }) test('Valid exportMnemonic/INCORRECT_PIN' , async()=>{ - let result = await new KeyRing().exportMnemonic(111111) + let result = await new KeyRing().exportMnemonic("111111") expect(result.error).toBe('Incorrect pin') }) @@ -140,7 +140,7 @@ describe('addAccount' , ()=>{ }) test('addAccount/invalid pin' , async()=>{ - let result = await vault.addAccount(bufView,"123333") + let result = await vault.addAccount(bufView,123333) expect(result.error).toBe("Wrong pin type, format or length") @@ -148,7 +148,7 @@ describe('addAccount' , ()=>{ }) test('addAccount/incorrect pin' , async()=>{ - let result = await vault.addAccount(bufView,123333) + let result = await vault.addAccount(bufView,"123333") expect(result.error).toBe("Incorrect pin") @@ -205,7 +205,7 @@ describe('exportPrivateKey' , ()=>{ }) test('exportPrivateKey/incorrect pin' , async()=>{ - let result = await vault.exportPrivateKey(accAddress,111111) + let result = await vault.exportPrivateKey(accAddress,"111111") expect(result.error).toBe("Incorrect pin") }) @@ -256,7 +256,7 @@ describe('importWallet' , ()=>{ }) test('importWallet/incorrect pin' , async()=>{ - let result = await vault.importWallet("0x"+privateKey,111111,bufView) + let result = await vault.importWallet("0x"+privateKey,"111111",bufView) expect(result.error).toBe("Incorrect pin") @@ -374,7 +374,7 @@ describe('deleteAccount',()=>{ }) test('deleteAccount/incorrect pin' , async()=>{ - let result = await vault.deleteAccount(bufView,accAddress,111111) + let result = await vault.deleteAccount(bufView,accAddress,"111111") expect(result.error).toBe("Incorrect pin") @@ -469,7 +469,7 @@ describe('restoreAccount', ()=> { }) test('restoreAccount/incorrect pin' , async()=>{ - let result = await vault.restoreAccount(bufView,accAddress,111111) + let result = await vault.restoreAccount(bufView,accAddress,"111111") expect(result.error).toBe("Incorrect pin") @@ -745,7 +745,7 @@ describe('sign',()=>{ console.log("sign/valid--->",pin,ethUrl) await vault.restoreKeyringState(vault,pin,bufView) - let result = await vault.sign(data,"0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd",696969,ethUrl) + let result = await vault.sign(data,"0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd",pin,ethUrl) console.log("sign/valid--->",result) expect(result.response).toHaveProperty('signature') @@ -798,7 +798,7 @@ describe('sign',()=>{ let data="hello world" - let result = await vault.sign(data,"abc",111111,ethUrl) + let result = await vault.sign(data,"abc","111111",ethUrl) expect(result.error).toBe("Incorrect pin") }) @@ -1097,7 +1097,7 @@ describe('changePin',()=>{ test('changePin/wrong currentpin' , async()=>{ try{ - let result = await vault.changePin(111111,pin,bufView) + let result = await vault.changePin("111111",pin,bufView) } catch(e){ @@ -1384,7 +1384,7 @@ describe('signTransaction',()=>{ }; - let result = await vault.signTransaction("evwf",112344,polygonRpcUrl) + let result = await vault.signTransaction("evwf","112344",polygonRpcUrl) expect(result.error).toBe('Incorrect pin') diff --git a/src/lib/test/vault.test.js b/src/lib/test/vault.test.js index 74549e6..874cb54 100644 --- a/src/lib/test/vault.test.js +++ b/src/lib/test/vault.test.js @@ -5,7 +5,7 @@ const crypto = require('crypto'); let Vault = require('../vault') const bufView = [48, 0, 236, 187, 187, 172, 177, 90, 255, 184, 9, 116, 142, 96, 197, 158, 87, 35, 26, 101, 187, 30, 116, 138, 50, 131, 166, 50, 51, 197, 198, 83, 238, 167, 105, 178, 182, 108, 174, 199, 124, 141, 155, 73, 21, 85, 81, 109, 78, 233, 152, 108, 242, 238, 192, 31, 147, 86, 174, 195, 55, 229, 4, 36]; let phrase="fun rough treat scan glimpse region century purpose expire video remind second" -let pin=696969 +let pin="696969" let vault =new Vault({}) const logs = [ @@ -114,7 +114,7 @@ describe("generateVault",()=>{ test('generateVault/valid case' , async()=>{ - let result = await vault.generateVault(bufView,111111,Mnemonic) + let result = await vault.generateVault(bufView,"111111",Mnemonic) expect(result).toHaveProperty('response') }) @@ -130,14 +130,14 @@ describe("generateVault",()=>{ test('generateVault/empty encrption key' , async()=>{ const buf = new ArrayBuffer(32); const bufView = new Uint8Array(buf); - let result = await new Vault({}).generateVault(null,1111,Mnemonic) + let result = await new Vault({}).generateVault(null,"1111",Mnemonic) expect(result.error).toBe('Wrong pin type, format or length') }) test('generateVault/empty encrption key' , async()=>{ const buf = new ArrayBuffer(32); const bufView = new Uint8Array(buf); - let result = await new Vault({}).generateVault(null,111111,Mnemonic) + let result = await new Vault({}).generateVault(null,"111111",Mnemonic) expect(result.error).toBe('Please enter both encryptionKey and pin') }) diff --git a/src/lib/vault.js b/src/lib/vault.js index 924c85b..9569eb0 100644 --- a/src/lib/vault.js +++ b/src/lib/vault.js @@ -69,7 +69,8 @@ class Vault extends Keyring { } async generateVault(encryptionKey, pin, mnemonic) { - if (!Number.isInteger(pin) || pin < 0 || pin.toString().length !=6) { + + if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; } @@ -100,7 +101,7 @@ class Vault extends Keyring { async recoverVault(mnemonic, encryptionKey, pin, unmarshalApiKey, recoverMechanism = 'transactions', logs = {}) { - if (!Number.isInteger(pin) || pin < 0 || pin.toString().length !=6) { + if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; } diff --git a/src/utils/helper.js b/src/utils/helper.js index 65e2e16..f624241 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -20,7 +20,7 @@ async function stringToArrayBuffer(str) { async function generatePrivData(mnemonic, pin) { var priv = {}; - const encryptedMnemonic = cryptojs.AES.encrypt(mnemonic, pin.toString()).toString(); + const encryptedMnemonic = cryptojs.AES.encrypt(mnemonic, pin).toString(); priv.encryptedMnemonic = encryptedMnemonic; From 0df2fb01436a9812d8141477ff84f513197d3ddd Mon Sep 17 00:00:00 2001 From: SDargarh Date: Fri, 6 Oct 2023 13:09:04 +0530 Subject: [PATCH 40/98] test case update for address --- src/lib/test/keyring.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/test/keyring.test.js b/src/lib/test/keyring.test.js index 4cf1b4f..f279db5 100644 --- a/src/lib/test/keyring.test.js +++ b/src/lib/test/keyring.test.js @@ -184,7 +184,7 @@ describe('exportPrivateKey' , ()=>{ let result = await vault.exportPrivateKey(null,pin) } catch(e){ - expect(e.message).toBe('Given address "null" is not a valid Ethereum address.') + expect(e.message).toBe("Cannot read properties of null (reading 'toLowerCase')") } From d574cc19505df71d7a390ac4e1b6de06618ea83d Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 9 Oct 2023 15:58:37 +0530 Subject: [PATCH 41/98] updated bitcoin package --- package-lock.json | 8 ++++---- package.json | 2 +- src/lib/keyring.js | 14 -------------- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index 21e3475..357d170 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@getsafle/safle-identity-wallet": "^1.3.0", "@getsafle/transaction-controller": "^1.9.3", "@getsafle/vault-arbitrum-controller": "^1.0.7", - "@getsafle/vault-bitcoin-controller": "^2.0.0", + "@getsafle/vault-bitcoin-controller": "^2.0.1", "@getsafle/vault-bsc-controller": "^1.2.2", "@getsafle/vault-eth-controller": "^1.4.5", "@getsafle/vault-mantle-controller": "^1.0.0", @@ -1395,9 +1395,9 @@ } }, "node_modules/@getsafle/vault-bitcoin-controller": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@getsafle/vault-bitcoin-controller/-/vault-bitcoin-controller-2.0.0.tgz", - "integrity": "sha512-Jz6Mef3Osv5sKDoD8cFTS09y933ThbrT+STyL38zgviX/fHf57j+iYFzJ+tIByS0nK7pxJgMaQXai/nmOWvLUw==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@getsafle/vault-bitcoin-controller/-/vault-bitcoin-controller-2.0.1.tgz", + "integrity": "sha512-NAUKw5lkH+/FDxEBkbxGo2WCz6pTZWoH7UVUkSOv7dvkJKd1rR1kIFzzXU5TE9fYW0X+lpQI5DGw+c2MgkrsQg==", "dependencies": { "axios": "^0.21.4", "bip39": "^2.2.0", diff --git a/package.json b/package.json index c66ba39..8a8343d 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "@getsafle/safle-identity-wallet": "^1.3.0", "@getsafle/transaction-controller": "^1.9.3", "@getsafle/vault-arbitrum-controller": "^1.0.7", - "@getsafle/vault-bitcoin-controller": "^2.0.0", + "@getsafle/vault-bitcoin-controller": "^2.0.1", "@getsafle/vault-bsc-controller": "^1.2.2", "@getsafle/vault-eth-controller": "^1.4.5", "@getsafle/vault-mantle-controller": "^1.0.0", diff --git a/src/lib/keyring.js b/src/lib/keyring.js index 5991275..bc5d4d1 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -909,19 +909,6 @@ class Keyring { async resetAllImportedWallets(currentPin, newPin) { - // const evmChainList = Object.keys(Chains.evmChains); - - // const filteredChains = activeChains.response.filter(activeChains => !evmChainList.includes(activeChains.chain)); - - - - // const chain = (Chains.evmChains.hasOwnProperty(this.chain) || this.chain === 'ethereum') ? 'eth' : this.chain; - // const importedChain = (chain === 'eth') ? 'evmChains' : chain; - - // if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) === undefined) { - // return null; - // } - if (_.get(this.decryptedVault, `importedWallets`) === undefined) { return null; } @@ -935,7 +922,6 @@ class Keyring { let decryptedPrivKey = await helper.cryptography(data[i].privateKey, currentPin.toString(), 'decryption'); let encryptedPrivKey = await helper.cryptography(decryptedPrivKey, newPin.toString(), 'encryption'); this.decryptedVault.importedWallets[importedChain].data[i].privateKey = encryptedPrivKey - // 'U2FsdGVkX18FMr+3tQmbjTmKwadj5fPPqrExRP8mUUXxT9chK9fkt+Dl8GtC7hJNfiazLnQEubTILDten238/cVqH6UAZduAXnrEEDmOUBBzhS/xAT7LvB17tycrGDXy' } } From 2862fb082a11f6fb2319e81a1082b3db30821c28 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 9 Oct 2023 16:25:48 +0530 Subject: [PATCH 42/98] updated resetting imported walletes --- CHANGELOG.md | 6 +++++- package-lock.json | 4 ++-- package.json | 2 +- src/lib/keyring.js | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ced2a68..077f536 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -554,4 +554,8 @@ ### 1.30.07 (2023-10-05) Nightly version : only for experimental use * Updated pin format from number to string -* updated test cases according to pin format changes \ No newline at end of file +* updated test cases according to pin format changes + +### 1.30.08 (2023-10-09) Nightly version : only for experimental use + +* Updated pin while resetting imported wallets \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 12f1a69..4d568c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getsafle/safle-vault", - "version": "1.30.07", + "version": "1.30.08", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "1.30.07", + "version": "1.30.08", "license": "MIT", "dependencies": { "@getsafle/asset-controller": "^1.0.10", diff --git a/package.json b/package.json index f90ff6a..fb4f2bd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "1.30.07", + "version": "1.30.08", "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": { diff --git a/src/lib/keyring.js b/src/lib/keyring.js index 9f48392..58c7405 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -890,8 +890,8 @@ class Keyring { let data = this.decryptedVault.importedWallets[importedChain].data for(let i = 0; i < data.length; i++) { - let decryptedPrivKey = await helper.cryptography(data[i].privateKey, currentpin, 'decryption'); - let encryptedPrivKey = await helper.cryptography(decryptedPrivKey, newpin, 'encryption'); + let decryptedPrivKey = await helper.cryptography(data[i].privateKey, currentPin, 'decryption'); + let encryptedPrivKey = await helper.cryptography(decryptedPrivKey, newPin, 'encryption'); this.decryptedVault.importedWallets[importedChain].data[i].privateKey = encryptedPrivKey } } From 594f4ca765d3d6578b14a895e4f45dd1ee0a458b Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 9 Oct 2023 17:35:57 +0530 Subject: [PATCH 43/98] code cleanup and package update --- CHANGELOG.md | 6 +++++- package-lock.json | 4 ++-- package.json | 2 +- src/lib/keyring.js | 16 ++-------------- src/lib/vault.js | 5 ----- src/utils/helper.js | 2 -- 6 files changed, 10 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 077f536..f80fcb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -558,4 +558,8 @@ ### 1.30.08 (2023-10-09) Nightly version : only for experimental use -* Updated pin while resetting imported wallets \ No newline at end of file +* Updated pin while resetting imported wallets + +### 1.31.0 (2023-10-09) Nightly version : only for experimental use + +* Integrated upgraded bitcoin controller into vault \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 86b7d3f..a95ba0a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getsafle/safle-vault", - "version": "1.30.08", + "version": "1.31.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "1.30.08", + "version": "1.31.0", "license": "MIT", "dependencies": { "@getsafle/asset-controller": "^1.0.10", diff --git a/package.json b/package.json index 518e708..4c2caf6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "1.30.08", + "version": "1.31.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": { diff --git a/src/lib/keyring.js b/src/lib/keyring.js index bc5d4d1..2d5e9d8 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -169,7 +169,6 @@ class Keyring { if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) !== undefined && this.decryptedVault.importedWallets[importedChain].data.some(element => element.address === address) == true) { isImportedAddress = true; - // } else if (this.decryptedVault[chain] !== undefined && this.decryptedVault[chain].public.some(element => Web3.utils.toChecksumAddress(element.address) === Web3.utils.toChecksumAddress(address)) == true) { } else if (this.decryptedVault[chain] !== undefined && this.decryptedVault[chain].public.some(element => element.address.toLowerCase() === address.toLowerCase()) == true) { isImportedAddress = false; } else { @@ -363,7 +362,6 @@ class Keyring { }; const { error, response } = await this.exportPrivateKey(rawTx.from, pin); - // const { error, response } = await this.exportPrivateKey(rawTx.from.toLowerCase(), pin); if (error) { return { error }; @@ -761,20 +759,11 @@ class Keyring { if (containsGenerated) { nonEvmAccs = decryptedVault[chain].public.filter((address) => address.isDeleted === false); - - // Comment - It is filtering is-deleted and is-imported data - // let result = nonEvmAccs.map(a => { return { address: a.address, label: a.label }}); - - // accounts[chain] = { generatedWallets: [ ...result ] }; accounts[chain] = { generatedWallets: { ...decryptedVault[chain].public } }; } if (containsImported) { nonEvmAccs = decryptedVault.importedWallets[chain].data.filter((address) => address.isDeleted === false); - // Comment - It is filtering is-deleted and is-imported data - // let result = nonEvmAccs.map(a => { return { address: a.address, label: a.label }}); - - // (accounts[chain] === undefined) ? accounts[chain] = { importedWallets: [ ...result ] } : accounts[chain].importedWallets = [ ...result ]; (accounts[chain] === undefined) ? accounts[chain] = { importedWallets: { ...decryptedVault.importedWallets[chain].data } } : accounts[chain].importedWallets = { ...decryptedVault.importedWallets[chain].data }; } }); @@ -817,7 +806,6 @@ class Keyring { return { error: ERROR_MESSAGE.INCORRECT_PIN }; }; - // const { error, response } = await this.exportPrivateKey(address.toLowerCase(), pin); const { error, response } = await this.exportPrivateKey(address, pin); if (error) { @@ -919,8 +907,8 @@ class Keyring { { let data = this.decryptedVault.importedWallets[importedChain].data for(let i = 0; i < data.length; i++) { - let decryptedPrivKey = await helper.cryptography(data[i].privateKey, currentPin.toString(), 'decryption'); - let encryptedPrivKey = await helper.cryptography(decryptedPrivKey, newPin.toString(), 'encryption'); + let decryptedPrivKey = await helper.cryptography(data[i].privateKey, currentPin, 'decryption'); + let encryptedPrivKey = await helper.cryptography(decryptedPrivKey, newPin, 'encryption'); this.decryptedVault.importedWallets[importedChain].data[i].privateKey = encryptedPrivKey } diff --git a/src/lib/vault.js b/src/lib/vault.js index 0095878..943935a 100644 --- a/src/lib/vault.js +++ b/src/lib/vault.js @@ -85,12 +85,7 @@ class Vault extends Keyring { const privData = await helper.generatePrivData(mnemonic, pin); - // this.initializeBitcoinKeyringController(mnemonic); - - // const {address: addedAcc } = await this.bitcoinKeyringInstance.addAccount(); - const rawVault = { eth: { public: [ { address: accounts[0], isDeleted: false, isImported: false, label: 'Wallet 1' } ], private: privData, numberOfAccounts: 1 },} - // bitcoin : { public: [ { address: addedAcc, isDeleted: false, isImported: false, label: 'Bitcoin Wallet 1' } ], numberOfAccounts: 1 } } const vault = await helper.cryptography(JSON.stringify(rawVault), JSON.stringify(encryptionKey), 'encryption'); diff --git a/src/utils/helper.js b/src/utils/helper.js index 55d085d..bcc008c 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -89,7 +89,6 @@ async function getAccountsFromLogs(keyringInstance, vaultState, recoverMechanis for(let i=0; i < logs.length; i++){ if (logs[i].action === 'add-account' && logs[i].chain === "bitcoin"){ const {address} = await keyringInstance.addAccount(); - // const newAccountAddr = Web3.utils.toChecksumAddress(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1]) if (logs[i].address === address) { const label = this.createWalletLabels('bitcoin', labelCounter); accountsArray.push({ address: address, isDeleted: false, isImported: false, label, isExported: false }); @@ -151,7 +150,6 @@ async function getCoinInstance(chain, mnemonic) { } const keyringInstance = new Chains[chain].KeyringController({ mnemonic }); - // const keyringInstance = new Chains[chain].KeyringController({mnemonic: mnemonic, network: 'TESTNET'}); return keyringInstance; } From 87ac6a628025b0211be201ea43ef14a30918e6af Mon Sep 17 00:00:00 2001 From: SDargarh Date: Wed, 25 Oct 2023 16:11:38 +0530 Subject: [PATCH 44/98] Enable backward compatibility in vault recovery for evm chains for undefined chain parameter in logs --- CHANGELOG.md | 3 ++- src/lib/vault.js | 4 ---- src/utils/helper.js | 3 ++- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f80fcb1..69d83e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -562,4 +562,5 @@ ### 1.31.0 (2023-10-09) Nightly version : only for experimental use -* Integrated upgraded bitcoin controller into vault \ No newline at end of file +* Integrated upgraded bitcoin controller into vault +* Enable backward compatibility in vault recovery for evm chains for undefined chain parameter in logs \ No newline at end of file diff --git a/src/lib/vault.js b/src/lib/vault.js index 943935a..9180f42 100644 --- a/src/lib/vault.js +++ b/src/lib/vault.js @@ -93,9 +93,6 @@ class Vault extends Keyring { this.vault = vault; - console.log("decyypted vault = = ", this.decryptedVault); - console.log("this = ", this); - this.logs.updateState({ logs: [{ timestamp: Date.now(), action: 'vault-generation', vault: this.vault }], }); @@ -146,7 +143,6 @@ class Vault extends Keyring { const numberOfAcc = accArray.length; rawVault[chainData.chain.toLowerCase()] = { public: accArray, numberOfAcc } - console.log("rawVault = ", rawVault); } diff --git a/src/utils/helper.js b/src/utils/helper.js index bcc008c..27c5b11 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -36,10 +36,11 @@ async function removeEmptyAccounts(indexAddress, keyringInstance, vaultState, un let accountsArray = []; accountsArray.push({ address: indexAddress, isDeleted: false, isImported: false, label: 'Wallet 1' }); let labelCounter = 2; // as an initial wallet is already created above with label 'Wallet 1' + const chains = Object.keys(Chains.evmChains); if( recoverMechanism === 'logs'){ for(let i=0; i < logs.length; i++){ - if (logs[i].action === 'add-account' && logs[i].chain === "ethereum"){ + if (logs[i].action === 'add-account' && (chains.includes(logs[i].chain) || logs[i].chain === undefined)){ const vaultState = await keyringInstance.addNewAccount(keyring[0]); const newAccountAddr = Web3.utils.toChecksumAddress(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1]) if (Web3.utils.toChecksumAddress(logs[i].address) === newAccountAddr) { From c92f701c8f49ede7b2f959134a60e93848791bf9 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Thu, 26 Oct 2023 17:45:23 +0530 Subject: [PATCH 45/98] Generate a default wallet for every chain when generating vault --- CHANGELOG.md | 3 ++- src/lib/vault.js | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69d83e3..fd4bc3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -563,4 +563,5 @@ ### 1.31.0 (2023-10-09) Nightly version : only for experimental use * Integrated upgraded bitcoin controller into vault -* Enable backward compatibility in vault recovery for evm chains for undefined chain parameter in logs \ No newline at end of file +* Enable backward compatibility in vault recovery for evm chains for undefined chain parameter in logs +* Generate a default wallet for every chain when generating vault \ No newline at end of file diff --git a/src/lib/vault.js b/src/lib/vault.js index 9180f42..5bd8ca6 100644 --- a/src/lib/vault.js +++ b/src/lib/vault.js @@ -50,6 +50,11 @@ class Vault extends Keyring { this.keyringInstance = keyringController; } + initializeSupportedChainKeyringController(mnemonic) { + const keyringController = new BitcoinKeyringController({mnemonic:mnemonic}); + this["bitcoin"] = keyringController; + } + async generateMnemonic(entropy) { var mnemonic; @@ -85,7 +90,15 @@ class Vault extends Keyring { const privData = await helper.generatePrivData(mnemonic, pin); - const rawVault = { eth: { public: [ { address: accounts[0], isDeleted: false, isImported: false, label: 'Wallet 1' } ], private: privData, numberOfAccounts: 1 },} + const rawVault = { eth: { public: [ { address: accounts[0], isDeleted: false, isImported: false, label: 'Wallet 1' } ], private: privData, numberOfAccounts: 1 }} + + this.initializeSupportedChainKeyringController(mnemonic); + + for (const chain of Object.keys(Chains.nonEvmChains)) { + const {address: addedAcc } = await this[chain].addAccount(); + let label = `${chain.charAt(0).toUpperCase() + chain.substr(1).toLowerCase()} Wallet 1` + rawVault[chain] = { public: [ { address: addedAcc, isDeleted: false, isImported: false, label: label } ], numberOfAccounts: 1 } + } const vault = await helper.cryptography(JSON.stringify(rawVault), JSON.stringify(encryptionKey), 'encryption'); From c2e4db4a6a59971a8fa7dcc90a5201454fcd1e1c Mon Sep 17 00:00:00 2001 From: SDargarh Date: Thu, 26 Oct 2023 17:46:42 +0530 Subject: [PATCH 46/98] Add fallback for recover vault - the default address to be recovered for every chain --- CHANGELOG.md | 3 ++- src/utils/helper.js | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd4bc3f..6191c3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -564,4 +564,5 @@ * Integrated upgraded bitcoin controller into vault * Enable backward compatibility in vault recovery for evm chains for undefined chain parameter in logs -* Generate a default wallet for every chain when generating vault \ No newline at end of file +* Generate a default wallet for every chain when generating vault +* Add fallback for recover vault - the default address to be recovered for every chain \ No newline at end of file diff --git a/src/utils/helper.js b/src/utils/helper.js index 27c5b11..1302870 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -43,7 +43,7 @@ async function removeEmptyAccounts(indexAddress, keyringInstance, vaultState, un if (logs[i].action === 'add-account' && (chains.includes(logs[i].chain) || logs[i].chain === undefined)){ const vaultState = await keyringInstance.addNewAccount(keyring[0]); const newAccountAddr = Web3.utils.toChecksumAddress(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1]) - if (Web3.utils.toChecksumAddress(logs[i].address) === newAccountAddr) { + if (logs[i].address.toLowerCase() === newAccountAddr.toLowerCase()) { const label = this.createWalletLabels('all', labelCounter); accountsArray.push({ address: newAccountAddr, isDeleted: false, isImported: false, label, isExported: false }); labelCounter++; @@ -83,17 +83,25 @@ async function removeEmptyAccounts(indexAddress, keyringInstance, vaultState, un } async function getAccountsFromLogs(keyringInstance, vaultState, recoverMechanism, logs) { + + //if mech = transaction - generate one acc for bitcoin let accountsArray = []; - let labelCounter = 1; + let {address} = await keyringInstance.addAccount(); + const label = this.createWalletLabels('bitcoin', 1); + accountsArray.push({ address: address, isDeleted: false, isImported: false, label, isExported: false }); + let labelCounter = 2; + const chains = Object.keys(Chains.nonEvmChains); + if( recoverMechanism === 'logs'){ + let {address} = await keyringInstance.addAccount(); for(let i=0; i < logs.length; i++){ - if (logs[i].action === 'add-account' && logs[i].chain === "bitcoin"){ - const {address} = await keyringInstance.addAccount(); + if (logs[i].action === 'add-account' && (chains.includes(logs[i].chain) || logs[i].chain === undefined)){ if (logs[i].address === address) { const label = this.createWalletLabels('bitcoin', labelCounter); accountsArray.push({ address: address, isDeleted: false, isImported: false, label, isExported: false }); labelCounter ++; + address = (await keyringInstance.addAccount()).address; } } @@ -103,7 +111,7 @@ async function getAccountsFromLogs(keyringInstance, vaultState, recoverMechanis } } - } + } return accountsArray; } From 8aa9b8553544b03cebaa69dc5d4ee55de491cfee Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 30 Oct 2023 17:23:42 +0530 Subject: [PATCH 47/98] Updated recover vault to create default wallet address for bitcoin for preexisting vaults --- CHANGELOG.md | 3 ++- src/lib/vault.js | 22 +++++++--------------- src/utils/helper.js | 16 ++++++++-------- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6191c3e..5cb42b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -565,4 +565,5 @@ * Integrated upgraded bitcoin controller into vault * Enable backward compatibility in vault recovery for evm chains for undefined chain parameter in logs * Generate a default wallet for every chain when generating vault -* Add fallback for recover vault - the default address to be recovered for every chain \ No newline at end of file +* Add fallback for recover vault - the default address to be recovered for every chain +* Updated recover vault to create default wallet address for bitcoin for preexisting vaults \ No newline at end of file diff --git a/src/lib/vault.js b/src/lib/vault.js index 5bd8ca6..b6a0af3 100644 --- a/src/lib/vault.js +++ b/src/lib/vault.js @@ -137,28 +137,20 @@ class Vault extends Keyring { let rawVault = { eth: { public: accountsArray, private: privData, numberOfAccounts } } - - const activeChains = await this.getActiveChains(); - - const evmChainList = Object.keys(Chains.evmChains); - - const filteredChains = activeChains.response.filter(activeChains => !evmChainList.includes(activeChains.chain)); + const nonEvmChainList = Object.keys(Chains.nonEvmChains); //generate other chain's keyring instance and get accounts from logs let obj = {} - if (filteredChains.length > 0) { - for ( let chainData of filteredChains ) { - const { response: mnemonic } = await this.exportMnemonic(pin); + for ( let chainData of nonEvmChainList) { + const { response: mnemonic } = await this.exportMnemonic(pin); - const keyringInstance = await helper.getCoinInstance(chainData.chain.toLowerCase(), mnemonic); + const keyringInstance = await helper.getCoinInstance(chainData.toLowerCase(), mnemonic); - const accArray = await helper.getAccountsFromLogs(keyringInstance, vaultState, recoverMechanism, logs); - const numberOfAcc = accArray.length; + const accArray = await helper.getAccountsFromLogs(keyringInstance, vaultState, recoverMechanism, logs); + const numberOfAcc = accArray.length; - rawVault[chainData.chain.toLowerCase()] = { public: accArray, numberOfAcc } + rawVault[chainData.toLowerCase()] = { public: accArray, numberOfAcc } - } - } this.decryptedVault = rawVault diff --git a/src/utils/helper.js b/src/utils/helper.js index 1302870..920a07b 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -41,16 +41,16 @@ async function removeEmptyAccounts(indexAddress, keyringInstance, vaultState, un if( recoverMechanism === 'logs'){ for(let i=0; i < logs.length; i++){ if (logs[i].action === 'add-account' && (chains.includes(logs[i].chain) || logs[i].chain === undefined)){ - const vaultState = await keyringInstance.addNewAccount(keyring[0]); + let vaultState = await keyringInstance.addNewAccount(keyring[0]); const newAccountAddr = Web3.utils.toChecksumAddress(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1]) if (logs[i].address.toLowerCase() === newAccountAddr.toLowerCase()) { const label = this.createWalletLabels('all', labelCounter); - accountsArray.push({ address: newAccountAddr, isDeleted: false, isImported: false, label, isExported: false }); + accountsArray.push({ address: newAccountAddr.toLowerCase(), isDeleted: false, isImported: false, label, isExported: false }); labelCounter++; } } - if(logs[i].action === 'delete-account') { + if(logs[i].action === 'delete-account' && (chains.includes(logs[i].chain) || logs[i].chain === undefined)) { let ind = accountsArray.findIndex((acc) => acc.address === Web3.utils.toChecksumAddress(logs[i].address)) ind >= 0 ? accountsArray[ind].isDeleted = true : false; } @@ -96,17 +96,17 @@ async function getAccountsFromLogs(keyringInstance, vaultState, recoverMechanis if( recoverMechanism === 'logs'){ let {address} = await keyringInstance.addAccount(); for(let i=0; i < logs.length; i++){ - if (logs[i].action === 'add-account' && (chains.includes(logs[i].chain) || logs[i].chain === undefined)){ - if (logs[i].address === address) { + if (logs[i].action === 'add-account' && (chains.includes(logs[i].chain))){ + if (logs[i].address.toLowerCase() === address.toLowerCase()) { const label = this.createWalletLabels('bitcoin', labelCounter); - accountsArray.push({ address: address, isDeleted: false, isImported: false, label, isExported: false }); + accountsArray.push({ address: address.toLowerCase(), isDeleted: false, isImported: false, label, isExported: false }); labelCounter ++; address = (await keyringInstance.addAccount()).address; } } - if(logs[i].action === 'delete-account') { - let ind = accountsArray.findIndex((acc) => acc.address === logs[i].address) + if(logs[i].action === 'delete-account' && (chains.includes(logs[i].chain))) { + let ind = accountsArray.findIndex((acc) => acc.address.toLowerCase() === logs[i].address.toLowerCase()) ind >= 0 ? accountsArray[ind].isDeleted = true : false; } } From f2bd53ceb0293e3fa1331167be33ec746b5f203f Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 30 Oct 2023 17:28:49 +0530 Subject: [PATCH 48/98] updated test result for bitcoin --- CHANGELOG.md | 3 ++- src/lib/test/keyring.test.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cb42b0..9d89584 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -566,4 +566,5 @@ * Enable backward compatibility in vault recovery for evm chains for undefined chain parameter in logs * Generate a default wallet for every chain when generating vault * Add fallback for recover vault - the default address to be recovered for every chain -* Updated recover vault to create default wallet address for bitcoin for preexisting vaults \ No newline at end of file +* Updated recover vault to create default wallet address for bitcoin for preexisting vaults +* Updated test result for bitcoin \ No newline at end of file diff --git a/src/lib/test/keyring.test.js b/src/lib/test/keyring.test.js index 09845e4..686be62 100644 --- a/src/lib/test/keyring.test.js +++ b/src/lib/test/keyring.test.js @@ -291,6 +291,7 @@ describe('getActiveChains',()=>{ chains=result.response expect({ response: [ + { chain: 'bitcoin', symbol: 'BTC' }, { chain: 'ethereum', symbol: 'ETH' }, { chain: 'bsc', symbol: 'BSC' }, { chain: 'polygon', symbol: 'MATIC' }, From a74739c10f74dac77aa7e5c1b63c0c94b947f7ec Mon Sep 17 00:00:00 2001 From: SDargarh Date: Thu, 2 Nov 2023 13:16:01 +0530 Subject: [PATCH 49/98] Merging nightly release 1.31.0 into main branch --- .github/workflows/nightly-release.yml | 34 --------------------------- CHANGELOG.md | 7 +++++- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 9 insertions(+), 38 deletions(-) delete mode 100644 .github/workflows/nightly-release.yml diff --git a/.github/workflows/nightly-release.yml b/.github/workflows/nightly-release.yml deleted file mode 100644 index e4769e6..0000000 --- a/.github/workflows/nightly-release.yml +++ /dev/null @@ -1,34 +0,0 @@ -# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created -# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages - -name: nightly Branch - -on: - push: - branches: - - nightly-release-* - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: 16.16.0 - - run: npm ci -# - run: npm run test - - publish-npm: - needs: build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: 16.16.0 - registry-url: https://registry.npmjs.org/ - - run: npm ci - - run: npm publish --access public - env: - NODE_AUTH_TOKEN: ${{secrets.npm_token}} diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d89584..543ba0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -567,4 +567,9 @@ * Generate a default wallet for every chain when generating vault * Add fallback for recover vault - the default address to be recovered for every chain * Updated recover vault to create default wallet address for bitcoin for preexisting vaults -* Updated test result for bitcoin \ No newline at end of file +* Updated test result for bitcoin + +### 2.0.0 (2023-11-02) + +* Removed workflow for nightly release branch +* Merging nightly release 1.31.0 into main branch \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index a95ba0a..1b29dd1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getsafle/safle-vault", - "version": "1.31.0", + "version": "2.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "1.31.0", + "version": "2.0.0", "license": "MIT", "dependencies": { "@getsafle/asset-controller": "^1.0.10", diff --git a/package.json b/package.json index 4c2caf6..c68a096 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "1.31.0", + "version": "2.0.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": { From fef35359b9bb54a40f841735061b3a3d8c1af0d8 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Tue, 28 Nov 2023 15:15:10 +0530 Subject: [PATCH 50/98] backward compatibility in recover vault and updated restore keyring state for other chains --- .gitignore | 1 + CHANGELOG.md | 7 ++++++- package-lock.json | 4 ++-- package.json | 2 +- src/lib/keyring.js | 13 ++++++++++++- src/utils/helper.js | 29 ++++++++++++++++++++++++----- 6 files changed, 46 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index e57e808..89e6698 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,4 @@ coverage safle-vault.code-workspace vault_test.json vault_test_bitcoin.js +vault_test_recovery.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 543ba0e..a4bb29d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -572,4 +572,9 @@ ### 2.0.0 (2023-11-02) * Removed workflow for nightly release branch -* Merging nightly release 1.31.0 into main branch \ No newline at end of file +* Merging nightly release 1.31.0 into main branch + +### 2.0.1 (2023-11-02) + +* Added backward compatibility in recover vault to handle incomplete logs for older users +* Updated restore keyring state for other chains \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 1b29dd1..d76340f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getsafle/safle-vault", - "version": "2.0.0", + "version": "2.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "2.0.0", + "version": "2.0.1", "license": "MIT", "dependencies": { "@getsafle/asset-controller": "^1.0.10", diff --git a/package.json b/package.json index c68a096..76c450e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "2.0.0", + "version": "2.0.1", "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": { diff --git a/src/lib/keyring.js b/src/lib/keyring.js index 2d5e9d8..800921a 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -454,7 +454,7 @@ class Keyring { // clearing vault state and adding new accounts as per decrypted vault const restoredVault = await this.keyringInstance.createNewVaultAndRestore(JSON.stringify(encryptionKey), mnemonic); - const numberOfAcc = this.decryptedVault.eth.numberOfAccounts; + let numberOfAcc = this.decryptedVault.eth.numberOfAccounts; let decryptedkeyring = await this.keyringInstance.getKeyringsByType(restoredVault.keyrings[0].type); @@ -467,6 +467,17 @@ class Keyring { } else { decryptedkeyring[0].opts.numberOfAccounts = numberOfAcc; } + + // restoring keyring for other chains + const nonEvmChainList = Object.keys(Chains.nonEvmChains); + for ( let chainData of nonEvmChainList) { + numberOfAcc = this.decryptedVault[chainData].numberOfAcc + if(numberOfAcc >= 1) { + for(let i=0; i < numberOfAcc; i++) { + this[chainData].addAccount(); + } + } + } } async deleteAccount(encryptionKey, address, pin) { diff --git a/src/utils/helper.js b/src/utils/helper.js index 920a07b..d13afcc 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -42,7 +42,18 @@ async function removeEmptyAccounts(indexAddress, keyringInstance, vaultState, un for(let i=0; i < logs.length; i++){ if (logs[i].action === 'add-account' && (chains.includes(logs[i].chain) || logs[i].chain === undefined)){ let vaultState = await keyringInstance.addNewAccount(keyring[0]); - const newAccountAddr = Web3.utils.toChecksumAddress(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1]) + let newAccountAddr = Web3.utils.toChecksumAddress(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1]) + if (logs[i].address.toLowerCase() !== newAccountAddr.toLowerCase()) { + do { + const label = this.createWalletLabels('all', labelCounter); + accountsArray.push({ address: newAccountAddr.toLowerCase(), isDeleted: false, isImported: false, label, isExported: false }); + labelCounter++; + let vaultState = await keyringInstance.addNewAccount(keyring[0]); + newAccountAddr = Web3.utils.toChecksumAddress(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1]) + } + while(logs[i].address.toLowerCase() !== newAccountAddr.toLowerCase()) + } + if (logs[i].address.toLowerCase() === newAccountAddr.toLowerCase()) { const label = this.createWalletLabels('all', labelCounter); accountsArray.push({ address: newAccountAddr.toLowerCase(), isDeleted: false, isImported: false, label, isExported: false }); @@ -94,14 +105,23 @@ async function getAccountsFromLogs(keyringInstance, vaultState, recoverMechanis const chains = Object.keys(Chains.nonEvmChains); if( recoverMechanism === 'logs'){ - let {address} = await keyringInstance.addAccount(); for(let i=0; i < logs.length; i++){ if (logs[i].action === 'add-account' && (chains.includes(logs[i].chain))){ + let address = (await keyringInstance.addAccount()).address; + if (logs[i].address.toLowerCase() !== address.toLowerCase()) { + do { + const label = this.createWalletLabels('bitcoin', labelCounter); + accountsArray.push({ address: address.toLowerCase(), isDeleted: false, isImported: false, label, isExported: false }); + labelCounter++; + address = (await keyringInstance.addAccount()).address; + } + while(logs[i].address.toLowerCase() !== address.toLowerCase()) + } + if (logs[i].address.toLowerCase() === address.toLowerCase()) { const label = this.createWalletLabels('bitcoin', labelCounter); accountsArray.push({ address: address.toLowerCase(), isDeleted: false, isImported: false, label, isExported: false }); labelCounter ++; - address = (await keyringInstance.addAccount()).address; } } @@ -110,8 +130,7 @@ async function getAccountsFromLogs(keyringInstance, vaultState, recoverMechanis ind >= 0 ? accountsArray[ind].isDeleted = true : false; } } - - } + } return accountsArray; } From 6637b8231bbb13dd4388f1267aeccbaf9615de3f Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 4 Dec 2023 13:39:38 +0530 Subject: [PATCH 51/98] updated bitcoin package and vault integration --- CHANGELOG.md | 7 ++++++- package-lock.json | 12 ++++++------ package.json | 4 ++-- src/lib/keyring.js | 14 ++++++++------ 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4bb29d..d481bac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -577,4 +577,9 @@ ### 2.0.1 (2023-11-02) * Added backward compatibility in recover vault to handle incomplete logs for older users -* Updated restore keyring state for other chains \ No newline at end of file +* Updated restore keyring state for other chains + +### 2.0.2 (2023-12-04) + +* Response updated for no accounts found +* Added a precheck of current chain in decrypted vault while restoring keyring state \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index d76340f..8254db4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,19 +1,19 @@ { "name": "@getsafle/safle-vault", - "version": "2.0.1", + "version": "2.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "2.0.1", + "version": "2.0.2", "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.7", - "@getsafle/vault-bitcoin-controller": "^2.0.1", + "@getsafle/vault-bitcoin-controller": "^2.0.2", "@getsafle/vault-bsc-controller": "^1.2.2", "@getsafle/vault-eth-controller": "^1.4.5", "@getsafle/vault-mantle-controller": "^1.0.0", @@ -1395,9 +1395,9 @@ } }, "node_modules/@getsafle/vault-bitcoin-controller": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@getsafle/vault-bitcoin-controller/-/vault-bitcoin-controller-2.0.1.tgz", - "integrity": "sha512-NAUKw5lkH+/FDxEBkbxGo2WCz6pTZWoH7UVUkSOv7dvkJKd1rR1kIFzzXU5TE9fYW0X+lpQI5DGw+c2MgkrsQg==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@getsafle/vault-bitcoin-controller/-/vault-bitcoin-controller-2.0.2.tgz", + "integrity": "sha512-QHGykhG1J/VtyfANQsHt8sCT3yAQxTVMi+RM0WSW2b5zhZeJEMn6M2ezM3NRyNA7CaMWCcAG7DdBxgkLBicPqw==", "dependencies": { "axios": "^0.21.4", "bip39": "^2.2.0", diff --git a/package.json b/package.json index 76c450e..d46f36a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "2.0.1", + "version": "2.0.2", "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": { @@ -48,7 +48,7 @@ "@getsafle/safle-identity-wallet": "^1.3.0", "@getsafle/transaction-controller": "^1.9.3", "@getsafle/vault-arbitrum-controller": "^1.0.7", - "@getsafle/vault-bitcoin-controller": "^2.0.1", + "@getsafle/vault-bitcoin-controller": "^2.0.2", "@getsafle/vault-bsc-controller": "^1.2.2", "@getsafle/vault-eth-controller": "^1.4.5", "@getsafle/vault-mantle-controller": "^1.0.0", diff --git a/src/lib/keyring.js b/src/lib/keyring.js index 800921a..a8ef69a 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -137,7 +137,7 @@ class Keyring { } if (decryptedVault[this.chain] === undefined && _.get(decryptedVault, `importedWallets.${this.chain}`) === undefined) { - return { error: ERROR_MESSAGE.NO_ACCOUNTS_FOUND }; + return { response: accounts }; } (decryptedVault[this.chain] !== undefined) ? accounts.push(...decryptedVault[this.chain].public) : null; @@ -471,12 +471,14 @@ class Keyring { // restoring keyring for other chains const nonEvmChainList = Object.keys(Chains.nonEvmChains); for ( let chainData of nonEvmChainList) { - numberOfAcc = this.decryptedVault[chainData].numberOfAcc - if(numberOfAcc >= 1) { - for(let i=0; i < numberOfAcc; i++) { - this[chainData].addAccount(); + if(this.decryptedVault[chainData]) { + numberOfAcc = this.decryptedVault[chainData].numberOfAcc + if(numberOfAcc >= 1) { + for(let i=0; i < numberOfAcc; i++) { + this[chainData].addAccount(); + } } - } + } } } From 8382d694987d9fafca24262d26a49b1e1ab6ccd8 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 4 Dec 2023 13:42:28 +0530 Subject: [PATCH 52/98] Node version upgrade to 18.x --- .github/workflows/main.yml | 4 ++-- .github/workflows/other-branches.yml | 2 +- CHANGELOG.md | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 88af596..3889aaa 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: - node-version: 16.16.0 + node-version: 18.x - run: npm ci - run: npm run test @@ -29,7 +29,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: - node-version: 16.16.0 + node-version: 18.x registry-url: https://registry.npmjs.org/ - run: npm ci - run: npm publish --access public diff --git a/.github/workflows/other-branches.yml b/.github/workflows/other-branches.yml index f341e08..a99c519 100644 --- a/.github/workflows/other-branches.yml +++ b/.github/workflows/other-branches.yml @@ -31,7 +31,7 @@ jobs: - name: Setting up Node.js uses: actions/setup-node@v2 with: - node-version: '16.16.0' + node-version: 18.x - name: Installing dependencies run: npm ci diff --git a/CHANGELOG.md b/CHANGELOG.md index d481bac..1203346 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -582,4 +582,5 @@ ### 2.0.2 (2023-12-04) * Response updated for no accounts found -* Added a precheck of current chain in decrypted vault while restoring keyring state \ No newline at end of file +* Added a precheck of current chain in decrypted vault while restoring keyring state +* Node version upgrade to 18.x \ No newline at end of file From 618963c3d9832ce3580bdb675940b4eb73e13dc0 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 4 Dec 2023 17:55:10 +0530 Subject: [PATCH 53/98] added getFees() and it's tests, updated all controllers --- .gitignore | 1 + CHANGELOG.md | 9 ++- README.md | 8 +++ package-lock.json | 118 ++++++++++++++++++++++++----------- package.json | 18 +++--- src/lib/keyring.js | 35 +++++++++++ src/lib/test/keyring.test.js | 44 +++++++++++++ 7 files changed, 185 insertions(+), 48 deletions(-) diff --git a/.gitignore b/.gitignore index 89e6698..29e01d2 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,4 @@ safle-vault.code-workspace vault_test.json vault_test_bitcoin.js vault_test_recovery.js +test_getFees.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 1203346..1bba807 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -583,4 +583,11 @@ * Response updated for no accounts found * Added a precheck of current chain in decrypted vault while restoring keyring state -* Node version upgrade to 18.x \ No newline at end of file +* Node version upgrade to 18.x + +### 2.1.0 (2023-12-04) + +* Added getFees() method to get transaction fees +* Updated readme for getFees() method +* Added test for getFees() method +* Updated controller version of eth, polygon, bsc, optimism, arbitrum, mantle, velas, bitcoin \ No newline at end of file diff --git a/README.md b/README.md index 30f9fa6..956b50f 100644 --- a/README.md +++ b/README.md @@ -242,4 +242,12 @@ Get Logs: This method retrieves all the logs of all the vault changes. `const logs = await vault.getLogs();` + +Get Fees: +This method returns an object containing gas limit, gas price wrt the speed of transaction confirmation + + `async getFees(rawTx, rpcUrl); ` + +* `rawTx` - The rawTx object containing the transaction details, e.g from, to , value, data, chainID +* `rpcUrl` - RPC URL of the chain. \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 8254db4..014baa6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,25 +1,25 @@ { "name": "@getsafle/safle-vault", - "version": "2.0.2", + "version": "2.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "2.0.2", + "version": "2.1.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.7", - "@getsafle/vault-bitcoin-controller": "^2.0.2", - "@getsafle/vault-bsc-controller": "^1.2.2", - "@getsafle/vault-eth-controller": "^1.4.5", - "@getsafle/vault-mantle-controller": "^1.0.0", - "@getsafle/vault-optimism-controller": "^1.0.7", - "@getsafle/vault-polygon-controller": "^1.2.7", - "@getsafle/vault-velas-controller": "^1.3.0", + "@getsafle/vault-arbitrum-controller": "^1.0.8", + "@getsafle/vault-bitcoin-controller": "^2.0.3", + "@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-velas-controller": "^1.3.1", "bip39": "^3.0.4", "crypto-js": "^4.1.1", "ethers": "^5.5.3", @@ -1349,9 +1349,9 @@ } }, "node_modules/@getsafle/vault-arbitrum-controller": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/@getsafle/vault-arbitrum-controller/-/vault-arbitrum-controller-1.0.7.tgz", - "integrity": "sha512-kJgTqwzjer82WQqb9b405Fw5R9EIyW21ztI3KHcAtpU911nYIrNK/mi3tTGGhkAUya8PU3Rs2JJMR+drdMH7vA==", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@getsafle/vault-arbitrum-controller/-/vault-arbitrum-controller-1.0.8.tgz", + "integrity": "sha512-0431UTZvWf0Onc9vmpNrI5pTzJmkqhZ0HgThMAi41NcSp6TFnKR/phinZgDsDZdoviaLJ3nSrjho5IT9X5MQOQ==", "dependencies": { "bip39": "^3.0.4", "browser-passworder": "^2.0.3", @@ -1395,9 +1395,9 @@ } }, "node_modules/@getsafle/vault-bitcoin-controller": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@getsafle/vault-bitcoin-controller/-/vault-bitcoin-controller-2.0.2.tgz", - "integrity": "sha512-QHGykhG1J/VtyfANQsHt8sCT3yAQxTVMi+RM0WSW2b5zhZeJEMn6M2ezM3NRyNA7CaMWCcAG7DdBxgkLBicPqw==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@getsafle/vault-bitcoin-controller/-/vault-bitcoin-controller-2.0.3.tgz", + "integrity": "sha512-Fp1PMHqr8SXyFoNfjaejU/bRIrh3Mq5HpYpAaLBlQ5MFKS8BZUbf/7yNFqOfU4O9DZAcfIjTvwuMSdWbZ7C2Mw==", "dependencies": { "axios": "^0.21.4", "bip39": "^2.2.0", @@ -1424,9 +1424,9 @@ } }, "node_modules/@getsafle/vault-bsc-controller": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@getsafle/vault-bsc-controller/-/vault-bsc-controller-1.2.2.tgz", - "integrity": "sha512-KmKq0okKzNWaX2kEHjWymCiNLNHO1ogiV+eOtI9GF4k7732o8Esik0A81YQrsICHoEgYk+AsJ5BLrmyB4CQe3Q==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@getsafle/vault-bsc-controller/-/vault-bsc-controller-1.2.4.tgz", + "integrity": "sha512-xu05m9ESTIP4IOzhThZ+g4L1H/1rcRkoHl9o2/mWAi0v9oIMD7DLMe0ffK2WfGDrnw6aJsuMxZXV0kmkoVlKLA==", "dependencies": { "bip39": "^3.0.4", "browser-passworder": "^2.0.3", @@ -1470,20 +1470,23 @@ } }, "node_modules/@getsafle/vault-eth-controller": { - "version": "1.4.5", - "resolved": "https://registry.npmjs.org/@getsafle/vault-eth-controller/-/vault-eth-controller-1.4.5.tgz", - "integrity": "sha512-Y1vHFE9WnxWTToJtedb8rNAG58FqX4si8bWPRYQsufoWBRjo+CSCpw9hrS9VjuG3QdjJsPf3M7usfSWSyBxyHw==", + "version": "1.4.6", + "resolved": "https://registry.npmjs.org/@getsafle/vault-eth-controller/-/vault-eth-controller-1.4.6.tgz", + "integrity": "sha512-v848rXMFixeWsGaJyLHX3luV+yK9EosJ47L/gTdifXUqYesljWs+XsbRG2truJfECNtJSyMFHtJGrUYG1+/YkQ==", "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-js": "^4.2.0", "eth-hd-keyring": "^3.6.0", "eth-sig-util": "^3.0.1", "eth-simple-keyring": "^4.2.0", "ethereumjs-util": "^7.1.0", "loglevel": "^1.7.1", - "obs-store": "^4.0.3" + "obs-store": "^4.0.3", + "web3": "^1.6.0" } }, "node_modules/@getsafle/vault-eth-controller/node_modules/@ethereumjs/tx": { @@ -1504,10 +1507,20 @@ "ethereumjs-util": "^7.1.5" } }, + "node_modules/@getsafle/vault-eth-controller/node_modules/axios": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz", + "integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==", + "dependencies": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, "node_modules/@getsafle/vault-mantle-controller": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@getsafle/vault-mantle-controller/-/vault-mantle-controller-1.0.0.tgz", - "integrity": "sha512-fXiV3x6M2oOU2z+1bwz8h2tK+b+gHvvhus6UvzOrgmSJfSDkdYH7JoMuj47QI07okx4t0LuUAvfiMMwMqdSaxA==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@getsafle/vault-mantle-controller/-/vault-mantle-controller-1.0.1.tgz", + "integrity": "sha512-cba2ZUwJjBsf5mO4p23bqQPrza9XF41u6RWBzUBsULt//LKkonnlXKyirJXrsWSzicjiZHHwa6/fw8cDkZYcxw==", "dependencies": { "bip39": "^3.0.4", "browser-passworder": "^2.0.3", @@ -1551,9 +1564,9 @@ } }, "node_modules/@getsafle/vault-optimism-controller": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/@getsafle/vault-optimism-controller/-/vault-optimism-controller-1.0.7.tgz", - "integrity": "sha512-SV+RydWv8Hn3azMfjmHFkcDzu0WF9ZroxjOzh/KG8yvexF0hyK3IjNbtu87uAIIgA6bZoi+8Whx4As8AKeGyXQ==", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@getsafle/vault-optimism-controller/-/vault-optimism-controller-1.0.8.tgz", + "integrity": "sha512-haEwk4dp3AvmLTu63GosiupTu8ov7C9XFWMJtHI03hx3+p+HNfaXN+sqnU/UgKg3YkOqrdKa2KyRYP1srZnP8w==", "dependencies": { "bip39": "^3.0.4", "browser-passworder": "^2.0.3", @@ -1597,12 +1610,13 @@ } }, "node_modules/@getsafle/vault-polygon-controller": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/@getsafle/vault-polygon-controller/-/vault-polygon-controller-1.2.7.tgz", - "integrity": "sha512-BUTwC6/YlLo9KWJOcDQY9ylsrL+AIe1O6VCVfvuCZgC/BQEcCLeVlLcYEwV5W87SZQJmKwbLYUSe9CeCXhnJfg==", + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@getsafle/vault-polygon-controller/-/vault-polygon-controller-1.2.8.tgz", + "integrity": "sha512-hNich9fJXYrR2PJXFezfS2CQ1vbeHeqbDsMCTJ3+6UptD7iv/Nm251jZED9HFTiXdOlYfUUT+cub71pS0sZsFg==", "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-js": "^4.1.1", @@ -1638,6 +1652,16 @@ "ethereumjs-util": "^7.1.4" } }, + "node_modules/@getsafle/vault-polygon-controller/node_modules/axios": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz", + "integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==", + "dependencies": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, "node_modules/@getsafle/vault-polygon-controller/node_modules/ethereumjs-tx": { "version": "1.3.7", "resolved": "https://registry.npmjs.org/ethereumjs-tx/-/ethereumjs-tx-1.3.7.tgz", @@ -1663,9 +1687,9 @@ } }, "node_modules/@getsafle/vault-velas-controller": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@getsafle/vault-velas-controller/-/vault-velas-controller-1.3.0.tgz", - "integrity": "sha512-thktV8u3aklvqnzRhj61VYVSMZjlU+0DAsTiFuF3s1JyyCHp/NiY+gRf1MlJ8kiblNkOF5PuUrVcZ6M0N67j6g==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@getsafle/vault-velas-controller/-/vault-velas-controller-1.3.1.tgz", + "integrity": "sha512-r6vuUOJoaDb34rpFTNQebHCVAR0pqpq4fkqN/Rk7oN3HROETFRcyhK3Z1bUAdpof5vNOrKAcsni79L5duedEYA==", "dependencies": { "bip39": "^3.0.4", "browser-passworder": "^2.0.3", @@ -3334,9 +3358,9 @@ } }, "node_modules/crypto-js": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.1.1.tgz", - "integrity": "sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw==" + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz", + "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==" }, "node_modules/d": { "version": "1.0.1", @@ -4659,6 +4683,19 @@ "node": "*" } }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/form-data-encoder": { "version": "1.7.1", "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.1.tgz", @@ -6825,6 +6862,11 @@ "node": ">= 0.10" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "node_modules/psl": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", diff --git a/package.json b/package.json index d46f36a..a5e0745 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "2.0.2", + "version": "2.1.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": { @@ -47,14 +47,14 @@ "@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.7", - "@getsafle/vault-bitcoin-controller": "^2.0.2", - "@getsafle/vault-bsc-controller": "^1.2.2", - "@getsafle/vault-eth-controller": "^1.4.5", - "@getsafle/vault-mantle-controller": "^1.0.0", - "@getsafle/vault-optimism-controller": "^1.0.7", - "@getsafle/vault-polygon-controller": "^1.2.7", - "@getsafle/vault-velas-controller": "^1.3.0", + "@getsafle/vault-arbitrum-controller": "^1.0.8", + "@getsafle/vault-bitcoin-controller": "^2.0.3", + "@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-velas-controller": "^1.3.1", "bip39": "^3.0.4", "crypto-js": "^4.1.1", "ethers": "^5.5.3", diff --git a/src/lib/keyring.js b/src/lib/keyring.js index a8ef69a..7c97601 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -274,6 +274,41 @@ class Keyring { return { response: { vault: encryptedVault, address: newAddress }}; } + async getFees(rawTx, rpcUrl) { + let address = rawTx.from + const chain = (Chains.evmChains.hasOwnProperty(this.chain) || this.chain === 'ethereum') ? 'eth' : this.chain; + const importedChain = (chain === 'eth') ? 'evmChains' : chain; + + let isImportedAddress; + + if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) !== undefined && this.decryptedVault.importedWallets[importedChain].data.some(element => element.address === address) == true) { + isImportedAddress = true; + } else if (this.decryptedVault[chain] !== undefined && this.decryptedVault[chain].public.some(element => element.address.toLowerCase() === address.toLowerCase()) == true) { + isImportedAddress = false; + } else { + return { error: ERROR_MESSAGE.ADDRESS_NOT_PRESENT }; + } + + + if (this.chain === 'ethereum') { + const web3 = new Web3(new Web3.providers.HttpProvider(rpcUrl)); + const fees = await this.keyringInstance.getFees(rawTx, web3); + return { response: fees }; + } + + if (Chains.evmChains.hasOwnProperty(this.chain)) { + const web3 = new Web3(new Web3.providers.HttpProvider(rpcUrl)); + const keyringInstance = await helper.getCoinInstance(this.chain); + + const fees = await keyringInstance.getFees(rawTx, web3); + + return { response: fees }; + } + + const fees = await this[this.chain].getFees(rawTx); + return { response: fees }; + } + async signMessage(address, data, pin, encryptionKey, rpcUrl = '') { if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; diff --git a/src/lib/test/keyring.test.js b/src/lib/test/keyring.test.js index 686be62..d1108e9 100644 --- a/src/lib/test/keyring.test.js +++ b/src/lib/test/keyring.test.js @@ -1489,6 +1489,50 @@ describe('signTransaction',()=>{ }) +describe('get Fees', () => { + + test('get Fees, validate', async () => { + vault.changeNetwork('polygon') + let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" + const web3 = new Web3(polygonRpcUrl) + + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0", 'ether')), + chainID: 137, + }; + + let result = await vault.getFees(rawTx,polygonRpcUrl) + expect(result.response).toHaveProperty('gasLimit') + expect(result.response).toHaveProperty('fees') + + }) + + test('get fees, invalid', async () => { + vault.changeNetwork('polygon') + let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" + const web3 = new Web3(polygonRpcUrl) + + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0", 'ether')), + chainID: 137, + }; + + try { + let result = await vault.getFees(rawTx,'abc') + console.log("result = ", result); + } + catch (e) { + console.log(e.message); + expect(e.message).toBe("CONNECTION ERROR: Couldn't connect to node abc.") + } + + }) +}) + From 2b62e34f5ab61f55fd8e74318155da7ce405ba7a Mon Sep 17 00:00:00 2001 From: saurabh Date: Mon, 4 Dec 2023 18:21:08 +0530 Subject: [PATCH 54/98] integrated avalanche c-chain --- CHANGELOG.md | 6 +- package-lock.json | 1851 +++++++++++++++++++++------------- package.json | 3 +- src/chains/index.js | 4 +- src/lib/test/keyring.test.js | 3 +- src/lib/test/vault.test.js | 2 +- 6 files changed, 1178 insertions(+), 691 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bba807..6a29011 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -590,4 +590,8 @@ * Added getFees() method to get transaction fees * Updated readme for getFees() method * Added test for getFees() method -* Updated controller version of eth, polygon, bsc, optimism, arbitrum, mantle, velas, bitcoin \ No newline at end of file +* Updated controller version of eth, polygon, bsc, optimism, arbitrum, mantle, velas, bitcoin + +### 2.2.0 (2023-12-04) + +* Integrated avalanche C chain in safle vault. \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 014baa6..4b639a5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,19 @@ { "name": "@getsafle/safle-vault", - "version": "2.1.0", + "version": "2.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "2.1.0", + "version": "2.2.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-bitcoin-controller": "^2.0.3", "@getsafle/vault-bsc-controller": "^1.2.4", "@getsafle/vault-eth-controller": "^1.4.6", @@ -30,6 +31,11 @@ "web3": "^1.9.0" } }, + "node_modules/@adraffy/ens-normalize": { + "version": "1.8.9", + "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.8.9.tgz", + "integrity": "sha512-93OmGCV0vO8+JQ3FHG+gZk/MPHzzMPDRiCiFcCQNTCnHaaxsacO3ScTPGlu2wX2dOtgfalbchPcw1cOYYjHCYQ==" + }, "node_modules/@ampproject/remapping": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.0.tgz", @@ -42,6 +48,156 @@ "node": ">=6.0.0" } }, + "node_modules/@avalabs/avalanchejs": { + "version": "3.17.0", + "resolved": "https://registry.npmjs.org/@avalabs/avalanchejs/-/avalanchejs-3.17.0.tgz", + "integrity": "sha512-Fv5Vu5hwzPNN4e7ER9TFIFU9msOZa+C28BcZUVW5TnabpglOpL46hA3iihRGTDRx1Y95cra29uctPqDRnVTMpQ==", + "dependencies": { + "assert": "2.0.0", + "axios": "0.27.2", + "bech32": "2.0.0", + "bip39": "3.1.0", + "bn.js": "5.2.1", + "buffer": "6.0.3", + "create-hash": "1.2.0", + "crypto-browserify": "3.12.0", + "elliptic": "6.5.4", + "ethers": "6.0.8", + "hdkey": "2.1.0", + "isomorphic-ws": "5.0.0", + "randombytes": "^2.1.0", + "store2": "2.14.2", + "stream-browserify": "3.0.0", + "ws": "8.12.1", + "xss": "1.0.14" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@avalabs/avalanchejs/node_modules/aes-js": { + "version": "4.0.0-beta.3", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-4.0.0-beta.3.tgz", + "integrity": "sha512-/xJX0/VTPcbc5xQE2VUP91y1xN8q/rDfhEzLm+vLc3hYvb5+qHCnpJRuFcrKn63zumK/sCwYYzhG8HP78JYSTA==" + }, + "node_modules/@avalabs/avalanchejs/node_modules/axios": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", + "dependencies": { + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" + } + }, + "node_modules/@avalabs/avalanchejs/node_modules/bech32": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/bech32/-/bech32-2.0.0.tgz", + "integrity": "sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg==" + }, + "node_modules/@avalabs/avalanchejs/node_modules/bip39": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bip39/-/bip39-3.1.0.tgz", + "integrity": "sha512-c9kiwdk45Do5GL0vJMe7tS95VjCii65mYAH7DfWl3uW8AVzXKQVUm64i3hzVybBDMp9r7j9iNxR85+ul8MdN/A==", + "dependencies": { + "@noble/hashes": "^1.2.0" + } + }, + "node_modules/@avalabs/avalanchejs/node_modules/bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + }, + "node_modules/@avalabs/avalanchejs/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" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/@avalabs/avalanchejs/node_modules/ethers": { + "version": "6.0.8", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.0.8.tgz", + "integrity": "sha512-j5smdMwn4t4vEARcfUv54mTJ2NMCorYLL51wPjFInEnrRr2SF5Sl9a7Z4DXS8UO1fBJVGHnjDDrF1b7msY3f7Q==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/ethers-io/" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@adraffy/ens-normalize": "1.8.9", + "@noble/hashes": "1.1.2", + "@noble/secp256k1": "1.7.1", + "aes-js": "4.0.0-beta.3", + "tslib": "2.4.0", + "ws": "8.5.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@avalabs/avalanchejs/node_modules/ethers/node_modules/@noble/hashes": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.1.2.tgz", + "integrity": "sha512-KYRCASVTv6aeUi1tsF8/vpyR7zpfs3FUzy2Jqm+MU+LmUKhQ0y2FpfwqkCcxSg2ua4GALJd8k2R76WxwZGbQpA==", + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ] + }, + "node_modules/@avalabs/avalanchejs/node_modules/ethers/node_modules/ws": { + "version": "8.5.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.5.0.tgz", + "integrity": "sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/@avalabs/avalanchejs/node_modules/hdkey": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/hdkey/-/hdkey-2.1.0.tgz", + "integrity": "sha512-i9Wzi0Dy49bNS4tXXeGeu0vIcn86xXdPQUpEYg+SO1YiO8HtomjmmRMaRyqL0r59QfcD4PfVbSF3qmsWFwAemA==", + "dependencies": { + "bs58check": "^2.1.2", + "ripemd160": "^2.0.2", + "safe-buffer": "^5.1.1", + "secp256k1": "^4.0.0" + } + }, "node_modules/@babel/code-frame": { "version": "7.18.6", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz", @@ -578,6 +734,17 @@ "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", @@ -587,6 +754,48 @@ "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", @@ -700,9 +909,9 @@ } }, "node_modules/@ethersproject/basex": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/basex/-/basex-5.5.0.tgz", - "integrity": "sha512-ZIodwhHpVJ0Y3hUCfUucmxKsWQA5TMnavp5j/UOuDdzZWzJlRmuOjcTMIGgHCYuZmHt36BfiSyQPSRskPxbfaQ==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/basex/-/basex-5.7.0.tgz", + "integrity": "sha512-ywlh43GwZLv2Voc2gQVTKBoVQ1mti3d8HK5aMxsfu/nRDnMmNqaSJ3r3n85HBByT8OpoY96SXM1FogC533T4zw==", "funding": [ { "type": "individual", @@ -714,8 +923,8 @@ } ], "dependencies": { - "@ethersproject/bytes": "^5.5.0", - "@ethersproject/properties": "^5.5.0" + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/properties": "^5.7.0" } }, "node_modules/@ethersproject/bignumber": { @@ -780,9 +989,9 @@ } }, "node_modules/@ethersproject/contracts": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/contracts/-/contracts-5.5.0.tgz", - "integrity": "sha512-2viY7NzyvJkh+Ug17v7g3/IJC8HqZBDcOjYARZLdzRxrfGlRgmYgl6xPRKVbEzy1dWKw/iv7chDcS83pg6cLxg==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/contracts/-/contracts-5.7.0.tgz", + "integrity": "sha512-5GJbzEU3X+d33CdfPhcyS+z8MzsTrBGk/sc+G+59+tPa9yFkl6HQ9D6L0QMgNTA9q8dT0XKxxkyp883XsQvbbg==", "funding": [ { "type": "individual", @@ -794,16 +1003,16 @@ } ], "dependencies": { - "@ethersproject/abi": "^5.5.0", - "@ethersproject/abstract-provider": "^5.5.0", - "@ethersproject/abstract-signer": "^5.5.0", - "@ethersproject/address": "^5.5.0", - "@ethersproject/bignumber": "^5.5.0", - "@ethersproject/bytes": "^5.5.0", - "@ethersproject/constants": "^5.5.0", - "@ethersproject/logger": "^5.5.0", - "@ethersproject/properties": "^5.5.0", - "@ethersproject/transactions": "^5.5.0" + "@ethersproject/abi": "^5.7.0", + "@ethersproject/abstract-provider": "^5.7.0", + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/transactions": "^5.7.0" } }, "node_modules/@ethersproject/hash": { @@ -833,9 +1042,9 @@ } }, "node_modules/@ethersproject/hdnode": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/hdnode/-/hdnode-5.5.0.tgz", - "integrity": "sha512-mcSOo9zeUg1L0CoJH7zmxwUG5ggQHU1UrRf8jyTYy6HxdZV+r0PBoL1bxr+JHIPXRzS6u/UW4mEn43y0tmyF8Q==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/hdnode/-/hdnode-5.7.0.tgz", + "integrity": "sha512-OmyYo9EENBPPf4ERhR7oj6uAtUAhYGqOnIS+jE5pTXvdKBS99ikzq1E7Iv0ZQZ5V36Lqx1qZLeak0Ra16qpeOg==", "funding": [ { "type": "individual", @@ -847,24 +1056,24 @@ } ], "dependencies": { - "@ethersproject/abstract-signer": "^5.5.0", - "@ethersproject/basex": "^5.5.0", - "@ethersproject/bignumber": "^5.5.0", - "@ethersproject/bytes": "^5.5.0", - "@ethersproject/logger": "^5.5.0", - "@ethersproject/pbkdf2": "^5.5.0", - "@ethersproject/properties": "^5.5.0", - "@ethersproject/sha2": "^5.5.0", - "@ethersproject/signing-key": "^5.5.0", - "@ethersproject/strings": "^5.5.0", - "@ethersproject/transactions": "^5.5.0", - "@ethersproject/wordlists": "^5.5.0" + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/basex": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/pbkdf2": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/sha2": "^5.7.0", + "@ethersproject/signing-key": "^5.7.0", + "@ethersproject/strings": "^5.7.0", + "@ethersproject/transactions": "^5.7.0", + "@ethersproject/wordlists": "^5.7.0" } }, "node_modules/@ethersproject/json-wallets": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/json-wallets/-/json-wallets-5.5.0.tgz", - "integrity": "sha512-9lA21XQnCdcS72xlBn1jfQdj2A1VUxZzOzi9UkNdnokNKke/9Ya2xA9aIK1SC3PQyBDLt4C+dfps7ULpkvKikQ==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/json-wallets/-/json-wallets-5.7.0.tgz", + "integrity": "sha512-8oee5Xgu6+RKgJTkvEMl2wDgSPSAQ9MB/3JYjFV9jlKvcYHUXZC+cQp0njgmxdHkYWn8s6/IqIZYm0YWCjO/0g==", "funding": [ { "type": "individual", @@ -876,17 +1085,17 @@ } ], "dependencies": { - "@ethersproject/abstract-signer": "^5.5.0", - "@ethersproject/address": "^5.5.0", - "@ethersproject/bytes": "^5.5.0", - "@ethersproject/hdnode": "^5.5.0", - "@ethersproject/keccak256": "^5.5.0", - "@ethersproject/logger": "^5.5.0", - "@ethersproject/pbkdf2": "^5.5.0", - "@ethersproject/properties": "^5.5.0", - "@ethersproject/random": "^5.5.0", - "@ethersproject/strings": "^5.5.0", - "@ethersproject/transactions": "^5.5.0", + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/hdnode": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/pbkdf2": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/random": "^5.7.0", + "@ethersproject/strings": "^5.7.0", + "@ethersproject/transactions": "^5.7.0", "aes-js": "3.0.0", "scrypt-js": "3.0.1" } @@ -949,9 +1158,9 @@ } }, "node_modules/@ethersproject/pbkdf2": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/pbkdf2/-/pbkdf2-5.5.0.tgz", - "integrity": "sha512-SaDvQFvXPnz1QGpzr6/HToLifftSXGoXrbpZ6BvoZhmx4bNLHrxDe8MZisuecyOziP1aVEwzC2Hasj+86TgWVg==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/pbkdf2/-/pbkdf2-5.7.0.tgz", + "integrity": "sha512-oR/dBRZR6GTyaofd86DehG72hY6NpAjhabkhxgr3X2FpJtJuodEl2auADWBZfhDHgVCbu3/H/Ocq2uC6dpNjjw==", "funding": [ { "type": "individual", @@ -963,8 +1172,8 @@ } ], "dependencies": { - "@ethersproject/bytes": "^5.5.0", - "@ethersproject/sha2": "^5.5.0" + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/sha2": "^5.7.0" } }, "node_modules/@ethersproject/properties": { @@ -986,9 +1195,9 @@ } }, "node_modules/@ethersproject/providers": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.5.2.tgz", - "integrity": "sha512-hkbx7x/MKcRjyrO4StKXCzCpWer6s97xnm34xkfPiarhtEUVAN4TBBpamM+z66WcTt7H5B53YwbRj1n7i8pZoQ==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.7.2.tgz", + "integrity": "sha512-g34EWZ1WWAVgr4aptGlVBF8mhl3VWjv+8hoAnzStu8Ah22VHBsuGzP17eb6xDVRzw895G4W7vvx60lFFur/1Rg==", "funding": [ { "type": "individual", @@ -1000,23 +1209,24 @@ } ], "dependencies": { - "@ethersproject/abstract-provider": "^5.5.0", - "@ethersproject/abstract-signer": "^5.5.0", - "@ethersproject/address": "^5.5.0", - "@ethersproject/basex": "^5.5.0", - "@ethersproject/bignumber": "^5.5.0", - "@ethersproject/bytes": "^5.5.0", - "@ethersproject/constants": "^5.5.0", - "@ethersproject/hash": "^5.5.0", - "@ethersproject/logger": "^5.5.0", - "@ethersproject/networks": "^5.5.0", - "@ethersproject/properties": "^5.5.0", - "@ethersproject/random": "^5.5.0", - "@ethersproject/rlp": "^5.5.0", - "@ethersproject/sha2": "^5.5.0", - "@ethersproject/strings": "^5.5.0", - "@ethersproject/transactions": "^5.5.0", - "@ethersproject/web": "^5.5.0", + "@ethersproject/abstract-provider": "^5.7.0", + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/base64": "^5.7.0", + "@ethersproject/basex": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/hash": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/networks": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/random": "^5.7.0", + "@ethersproject/rlp": "^5.7.0", + "@ethersproject/sha2": "^5.7.0", + "@ethersproject/strings": "^5.7.0", + "@ethersproject/transactions": "^5.7.0", + "@ethersproject/web": "^5.7.0", "bech32": "1.1.4", "ws": "7.4.6" } @@ -1042,9 +1252,9 @@ } }, "node_modules/@ethersproject/random": { - "version": "5.5.1", - "resolved": "https://registry.npmjs.org/@ethersproject/random/-/random-5.5.1.tgz", - "integrity": "sha512-YaU2dQ7DuhL5Au7KbcQLHxcRHfgyNgvFV4sQOo0HrtW3Zkrc9ctWNz8wXQ4uCSfSDsqX2vcjhroxU5RQRV0nqA==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/random/-/random-5.7.0.tgz", + "integrity": "sha512-19WjScqRA8IIeWclFme75VMXSBvi4e6InrUNuaR4s5pTF2qNhcGdCUwdxUVGtDDqC00sDLCO93jPQoDUH4HVmQ==", "funding": [ { "type": "individual", @@ -1056,8 +1266,8 @@ } ], "dependencies": { - "@ethersproject/bytes": "^5.5.0", - "@ethersproject/logger": "^5.5.0" + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0" } }, "node_modules/@ethersproject/rlp": { @@ -1080,9 +1290,9 @@ } }, "node_modules/@ethersproject/sha2": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/sha2/-/sha2-5.5.0.tgz", - "integrity": "sha512-B5UBoglbCiHamRVPLA110J+2uqsifpZaTmid2/7W5rbtYVz6gus6/hSDieIU/6gaKIDcOj12WnOdiymEUHIAOA==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/sha2/-/sha2-5.7.0.tgz", + "integrity": "sha512-gKlH42riwb3KYp0reLsFTokByAKoJdgFCwI+CCiX/k+Jm2mbNs6oOaCjYQSlI1+XBVejwH2KrmCbMAT/GnRDQw==", "funding": [ { "type": "individual", @@ -1094,8 +1304,8 @@ } ], "dependencies": { - "@ethersproject/bytes": "^5.5.0", - "@ethersproject/logger": "^5.5.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", "hash.js": "1.1.7" } }, @@ -1128,9 +1338,9 @@ "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" }, "node_modules/@ethersproject/solidity": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/solidity/-/solidity-5.5.0.tgz", - "integrity": "sha512-9NgZs9LhGMj6aCtHXhtmFQ4AN4sth5HuFXVvAQtzmm0jpSCNOTGtrHZJAeYTh7MBjRR8brylWZxBZR9zDStXbw==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/solidity/-/solidity-5.7.0.tgz", + "integrity": "sha512-HmabMd2Dt/raavyaGukF4XxizWKhKQ24DoLtdNbBmNKUOPqwjsKQSdV9GQtj9CBEea9DlzETlVER1gYeXXBGaA==", "funding": [ { "type": "individual", @@ -1142,12 +1352,12 @@ } ], "dependencies": { - "@ethersproject/bignumber": "^5.5.0", - "@ethersproject/bytes": "^5.5.0", - "@ethersproject/keccak256": "^5.5.0", - "@ethersproject/logger": "^5.5.0", - "@ethersproject/sha2": "^5.5.0", - "@ethersproject/strings": "^5.5.0" + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/sha2": "^5.7.0", + "@ethersproject/strings": "^5.7.0" } }, "node_modules/@ethersproject/strings": { @@ -1197,9 +1407,9 @@ } }, "node_modules/@ethersproject/units": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/units/-/units-5.5.0.tgz", - "integrity": "sha512-7+DpjiZk4v6wrikj+TCyWWa9dXLNU73tSTa7n0TSJDxkYbV3Yf1eRh9ToMLlZtuctNYu9RDNNy2USq3AdqSbag==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/units/-/units-5.7.0.tgz", + "integrity": "sha512-pD3xLMy3SJu9kG5xDGI7+xhTEmGXlEqXU4OfNapmfnxLVY4EMSSRp7j1k7eezutBPH7RBN/7QPnwR7hzNlEFeg==", "funding": [ { "type": "individual", @@ -1211,15 +1421,15 @@ } ], "dependencies": { - "@ethersproject/bignumber": "^5.5.0", - "@ethersproject/constants": "^5.5.0", - "@ethersproject/logger": "^5.5.0" + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/logger": "^5.7.0" } }, "node_modules/@ethersproject/wallet": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/wallet/-/wallet-5.5.0.tgz", - "integrity": "sha512-Mlu13hIctSYaZmUOo7r2PhNSd8eaMPVXe1wxrz4w4FCE4tDYBywDH+bAR1Xz2ADyXGwqYMwstzTrtUVIsKDO0Q==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/wallet/-/wallet-5.7.0.tgz", + "integrity": "sha512-MhmXlJXEJFBFVKrDLB4ZdDzxcBxQ3rLyCkhNqVu3CDYvR97E+8r01UgrI+TI99Le+aYm/in/0vp86guJuM7FCA==", "funding": [ { "type": "individual", @@ -1231,21 +1441,21 @@ } ], "dependencies": { - "@ethersproject/abstract-provider": "^5.5.0", - "@ethersproject/abstract-signer": "^5.5.0", - "@ethersproject/address": "^5.5.0", - "@ethersproject/bignumber": "^5.5.0", - "@ethersproject/bytes": "^5.5.0", - "@ethersproject/hash": "^5.5.0", - "@ethersproject/hdnode": "^5.5.0", - "@ethersproject/json-wallets": "^5.5.0", - "@ethersproject/keccak256": "^5.5.0", - "@ethersproject/logger": "^5.5.0", - "@ethersproject/properties": "^5.5.0", - "@ethersproject/random": "^5.5.0", - "@ethersproject/signing-key": "^5.5.0", - "@ethersproject/transactions": "^5.5.0", - "@ethersproject/wordlists": "^5.5.0" + "@ethersproject/abstract-provider": "^5.7.0", + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/hash": "^5.7.0", + "@ethersproject/hdnode": "^5.7.0", + "@ethersproject/json-wallets": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/random": "^5.7.0", + "@ethersproject/signing-key": "^5.7.0", + "@ethersproject/transactions": "^5.7.0", + "@ethersproject/wordlists": "^5.7.0" } }, "node_modules/@ethersproject/web": { @@ -1271,9 +1481,9 @@ } }, "node_modules/@ethersproject/wordlists": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/wordlists/-/wordlists-5.5.0.tgz", - "integrity": "sha512-bL0UTReWDiaQJJYOC9sh/XcRu/9i2jMrzf8VLRmPKx58ckSlOJiohODkECCO50dtLZHcGU6MLXQ4OOrgBwP77Q==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/wordlists/-/wordlists-5.7.0.tgz", + "integrity": "sha512-S2TFNJNfHWVHNE6cNDjbVlZ6MgE17MIxMbMg2zv3wn+3XSJGosL1m9ZVv3GXCf/2ymSsQ+hRI5IzoMJTG6aoVA==", "funding": [ { "type": "individual", @@ -1285,11 +1495,11 @@ } ], "dependencies": { - "@ethersproject/bytes": "^5.5.0", - "@ethersproject/hash": "^5.5.0", - "@ethersproject/logger": "^5.5.0", - "@ethersproject/properties": "^5.5.0", - "@ethersproject/strings": "^5.5.0" + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/hash": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/strings": "^5.7.0" } }, "node_modules/@getsafle/asset-controller": { @@ -1394,47 +1604,20 @@ "safe-buffer": "^5.1.1" } }, - "node_modules/@getsafle/vault-bitcoin-controller": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@getsafle/vault-bitcoin-controller/-/vault-bitcoin-controller-2.0.3.tgz", - "integrity": "sha512-Fp1PMHqr8SXyFoNfjaejU/bRIrh3Mq5HpYpAaLBlQ5MFKS8BZUbf/7yNFqOfU4O9DZAcfIjTvwuMSdWbZ7C2Mw==", - "dependencies": { - "axios": "^0.21.4", - "bip39": "^2.2.0", - "bitcoinjs-lib": "^5.2.0", - "bitcoinjs-message": "^2.2.0", - "bitcore-lib": "^8.25.10", - "obs-store": "^4.0.3", - "satoshi-bitcoin": "^1.0.5" - }, - "engines": { - "node": ">= 10" - } - }, - "node_modules/@getsafle/vault-bitcoin-controller/node_modules/bip39": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/bip39/-/bip39-2.6.0.tgz", - "integrity": "sha512-RrnQRG2EgEoqO24ea+Q/fftuPUZLmrEM3qNhhGsA3PbaXaCW791LTzPuVyx/VprXQcTbPJ3K3UeTna8ZnVl2sg==", - "dependencies": { - "create-hash": "^1.1.0", - "pbkdf2": "^3.0.9", - "randombytes": "^2.0.1", - "safe-buffer": "^5.0.1", - "unorm": "^1.3.3" - } - }, - "node_modules/@getsafle/vault-bsc-controller": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/@getsafle/vault-bsc-controller/-/vault-bsc-controller-1.2.4.tgz", - "integrity": "sha512-xu05m9ESTIP4IOzhThZ+g4L1H/1rcRkoHl9o2/mWAi0v9oIMD7DLMe0ffK2WfGDrnw6aJsuMxZXV0kmkoVlKLA==", + "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==", "dependencies": { + "@avalabs/avalanchejs": "^3.17.0", + "@ethereumjs/tx": "^5.1.0", + "avalanche": "^3.16.0", "bip39": "^3.0.4", "browser-passworder": "^2.0.3", - "crypto-js": "^4.1.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-tx": "^1.3.7", "ethereumjs-util": "^7.1.0", "hdkey": "^2.0.1", "loglevel": "^1.7.1", @@ -1445,26 +1628,171 @@ "node": ">= 10" } }, - "node_modules/@getsafle/vault-bsc-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.", + "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==", "dependencies": { - "ethereum-common": "^0.0.18", - "ethereumjs-util": "^5.0.0" + "@ethereumjs/util": "^9.0.1", + "crc": "^4.3.2" } }, - "node_modules/@getsafle/vault-bsc-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==", + "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": { - "bn.js": "^4.11.0", - "create-hash": "^1.1.2", - "elliptic": "^6.5.2", - "ethereum-cryptography": "^0.1.3", - "ethjs-util": "^0.1.3", + "@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, + "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" + } + }, + "node_modules/@getsafle/vault-bitcoin-controller": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@getsafle/vault-bitcoin-controller/-/vault-bitcoin-controller-2.0.3.tgz", + "integrity": "sha512-Fp1PMHqr8SXyFoNfjaejU/bRIrh3Mq5HpYpAaLBlQ5MFKS8BZUbf/7yNFqOfU4O9DZAcfIjTvwuMSdWbZ7C2Mw==", + "dependencies": { + "axios": "^0.21.4", + "bip39": "^2.2.0", + "bitcoinjs-lib": "^5.2.0", + "bitcoinjs-message": "^2.2.0", + "bitcore-lib": "^8.25.10", + "obs-store": "^4.0.3", + "satoshi-bitcoin": "^1.0.5" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/@getsafle/vault-bitcoin-controller/node_modules/bip39": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/bip39/-/bip39-2.6.0.tgz", + "integrity": "sha512-RrnQRG2EgEoqO24ea+Q/fftuPUZLmrEM3qNhhGsA3PbaXaCW791LTzPuVyx/VprXQcTbPJ3K3UeTna8ZnVl2sg==", + "dependencies": { + "create-hash": "^1.1.0", + "pbkdf2": "^3.0.9", + "randombytes": "^2.0.1", + "safe-buffer": "^5.0.1", + "unorm": "^1.3.3" + } + }, + "node_modules/@getsafle/vault-bsc-controller": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@getsafle/vault-bsc-controller/-/vault-bsc-controller-1.2.4.tgz", + "integrity": "sha512-xu05m9ESTIP4IOzhThZ+g4L1H/1rcRkoHl9o2/mWAi0v9oIMD7DLMe0ffK2WfGDrnw6aJsuMxZXV0kmkoVlKLA==", + "dependencies": { + "bip39": "^3.0.4", + "browser-passworder": "^2.0.3", + "crypto-js": "^4.1.1", + "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", + "obs-store": "^4.0.3", + "web3": "^1.6.0" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/@getsafle/vault-bsc-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": { + "ethereum-common": "^0.0.18", + "ethereumjs-util": "^5.0.0" + } + }, + "node_modules/@getsafle/vault-bsc-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": { + "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" } @@ -2069,6 +2397,83 @@ "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", + "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/secp256k1": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/@noble/secp256k1/-/secp256k1-1.7.1.tgz", + "integrity": "sha512-hOUk6AyBFmqVrv7k5WAw/LpszxVbj9gGN4JRkIX52fdFAj1UA61KXmZDvqVEm+pOyec3+fIeZB02LYa/pWOArw==", + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ] + }, + "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", @@ -2377,6 +2782,28 @@ "safer-buffer": "~2.1.0" } }, + "node_modules/asn1.js": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz", + "integrity": "sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==", + "dependencies": { + "bn.js": "^4.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0", + "safer-buffer": "^2.1.0" + } + }, + "node_modules/assert": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/assert/-/assert-2.0.0.tgz", + "integrity": "sha512-se5Cd+js9dXJnu6Ag2JFc00t+HmHOen+8Q+L7O9zI0PqQXr20uk2J0XQqMxZEeo5U50o8Nvmmx7dZrl+Ufr35A==", + "dependencies": { + "es6-object-assign": "^1.1.0", + "is-nan": "^1.2.1", + "object-is": "^1.0.1", + "util": "^0.12.0" + } + }, "node_modules/assert-plus": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", @@ -2406,6 +2833,96 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/avalanche": { + "version": "3.16.0", + "resolved": "https://registry.npmjs.org/avalanche/-/avalanche-3.16.0.tgz", + "integrity": "sha512-Xy37+SvtUetBwdZ9Ic7nKXokPdPscdeeoa0RtXXvS/80RKRnhI3f7atKTk6XpGZ//X64s0DsT8IoM/Pn/KdZjg==", + "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.", + "dependencies": { + "assert": "2.0.0", + "axios": "0.27.2", + "bech32": "2.0.0", + "bip39": "3.0.4", + "bn.js": "5.2.1", + "buffer": "6.0.3", + "create-hash": "1.2.0", + "crypto-browserify": "3.12.0", + "elliptic": "6.5.4", + "ethers": "5.7.2", + "hdkey": "2.0.1", + "isomorphic-ws": "5.0.0", + "randombytes": "^2.1.0", + "store2": "2.14.2", + "stream-browserify": "3.0.0", + "ws": "8.8.1", + "xss": "1.0.14" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/avalanche/node_modules/axios": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", + "dependencies": { + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" + } + }, + "node_modules/avalanche/node_modules/bech32": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/bech32/-/bech32-2.0.0.tgz", + "integrity": "sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg==" + }, + "node_modules/avalanche/node_modules/bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + }, + "node_modules/avalanche/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" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/avalanche/node_modules/ws": { + "version": "8.8.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.8.1.tgz", + "integrity": "sha512-bGy2JzvzkPowEJV++hF07hAD6niYSr0JzBNo/J29WsB57A2r7Wlc1UFcTR9IzrPvuNVO4B8LGqF8qcpsVOhJCA==", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/aws-sign2": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", @@ -2853,39 +3370,98 @@ "safe-buffer": "^5.0.1" } }, - "node_modules/browserify-unibabel": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/browserify-unibabel/-/browserify-unibabel-3.0.0.tgz", - "integrity": "sha1-WmuPD3BM44jTkn30czfiWDD3Hdo=" - }, - "node_modules/browserslist": { - "version": "4.21.5", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.5.tgz", - "integrity": "sha512-tUkiguQGW7S3IhB7N+c2MV/HZPSCPAAiYBZXLsBhFB/PCy6ZKKsZrmBayHV9fdGV/ARIfJ14NkxKzRDjvp7L6w==", - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - } - ], + "node_modules/browserify-cipher": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", + "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", "dependencies": { - "caniuse-lite": "^1.0.30001449", - "electron-to-chromium": "^1.4.284", - "node-releases": "^2.0.8", - "update-browserslist-db": "^1.0.10" - }, - "bin": { - "browserslist": "cli.js" - }, - "engines": { - "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + "browserify-aes": "^1.0.4", + "browserify-des": "^1.0.0", + "evp_bytestokey": "^1.0.0" } }, - "node_modules/bs58": { + "node_modules/browserify-des": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", + "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", + "dependencies": { + "cipher-base": "^1.0.1", + "des.js": "^1.0.0", + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, + "node_modules/browserify-rsa": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.1.0.tgz", + "integrity": "sha512-AdEER0Hkspgno2aR97SAf6vi0y0k8NuOpGnVH3O99rcA5Q6sh8QxcngtHuJ6uXwnfAXNM4Gn1Gb7/MV1+Ymbog==", + "dependencies": { + "bn.js": "^5.0.0", + "randombytes": "^2.0.1" + } + }, + "node_modules/browserify-rsa/node_modules/bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + }, + "node_modules/browserify-sign": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.2.2.tgz", + "integrity": "sha512-1rudGyeYY42Dk6texmv7c4VcQ0EsvVbLwZkA+AQB7SxvXxmcD93jcHie8bzecJ+ChDlmAm2Qyu0+Ccg5uhZXCg==", + "dependencies": { + "bn.js": "^5.2.1", + "browserify-rsa": "^4.1.0", + "create-hash": "^1.2.0", + "create-hmac": "^1.1.7", + "elliptic": "^6.5.4", + "inherits": "^2.0.4", + "parse-asn1": "^5.1.6", + "readable-stream": "^3.6.2", + "safe-buffer": "^5.2.1" + }, + "engines": { + "node": ">= 4" + } + }, + "node_modules/browserify-sign/node_modules/bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + }, + "node_modules/browserify-unibabel": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/browserify-unibabel/-/browserify-unibabel-3.0.0.tgz", + "integrity": "sha1-WmuPD3BM44jTkn30czfiWDD3Hdo=" + }, + "node_modules/browserslist": { + "version": "4.21.5", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.5.tgz", + "integrity": "sha512-tUkiguQGW7S3IhB7N+c2MV/HZPSCPAAiYBZXLsBhFB/PCy6ZKKsZrmBayHV9fdGV/ARIfJ14NkxKzRDjvp7L6w==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + } + ], + "dependencies": { + "caniuse-lite": "^1.0.30001449", + "electron-to-chromium": "^1.4.284", + "node-releases": "^2.0.8", + "update-browserslist-db": "^1.0.10" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/bs58": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", "integrity": "sha1-vhYedsNU9veIrkBx9j806MTwpCo=", @@ -3227,6 +3803,11 @@ "node": ">= 0.8" } }, + "node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -3311,6 +3892,15 @@ "node": ">=0.8" } }, + "node_modules/create-ecdh": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.4.tgz", + "integrity": "sha512-mf+TCx8wWc9VpuxfP2ht0iSISLZnt0JgWlrOKZiNqyUZWnjIaCIVNQArMHnCZKfEYRg6IM7A+NeJoN8gf/Ws0A==", + "dependencies": { + "bn.js": "^4.1.0", + "elliptic": "^6.5.3" + } + }, "node_modules/create-hash": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", @@ -3357,11 +3947,37 @@ "node": ">= 8" } }, + "node_modules/crypto-browserify": { + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", + "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", + "dependencies": { + "browserify-cipher": "^1.0.0", + "browserify-sign": "^4.0.0", + "create-ecdh": "^4.0.0", + "create-hash": "^1.1.0", + "create-hmac": "^1.1.0", + "diffie-hellman": "^5.0.0", + "inherits": "^2.0.1", + "pbkdf2": "^3.0.3", + "public-encrypt": "^4.0.0", + "randombytes": "^2.0.0", + "randomfill": "^1.0.3" + }, + "engines": { + "node": "*" + } + }, "node_modules/crypto-js": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz", "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==" }, + "node_modules/cssfilter": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/cssfilter/-/cssfilter-0.0.10.tgz", + "integrity": "sha512-FAaLDaplstoRsDR8XGYH51znUN0UY7nMc6Z9/fvE8EXGwvJE9hu7W2vHwx1+bd6gCYnln9nLbzxFTrcO9YQDZw==" + }, "node_modules/d": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", @@ -3452,6 +4068,35 @@ "node": ">=10" } }, + "node_modules/define-data-property": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.1.tgz", + "integrity": "sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ==", + "dependencies": { + "get-intrinsic": "^1.2.1", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/define-properties": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", + "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==", + "dependencies": { + "define-data-property": "^1.0.1", + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -3468,6 +4113,15 @@ "node": ">= 0.8" } }, + "node_modules/des.js": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.1.0.tgz", + "integrity": "sha512-r17GxjhUCjSRy8aiJpr8/UadFIzMzJGexI3Nmz4ADi9LYSFx4gTBp80+NaX/YsXWWLhpZ7v/v/ubEc/bCNfKwg==", + "dependencies": { + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" + } + }, "node_modules/destroy": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", @@ -3493,6 +4147,16 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/diffie-hellman": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", + "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", + "dependencies": { + "bn.js": "^4.1.0", + "miller-rabin": "^4.0.0", + "randombytes": "^2.0.0" + } + }, "node_modules/dom-walk": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.2.tgz", @@ -3617,6 +4281,11 @@ "es6-symbol": "^3.1.1" } }, + "node_modules/es6-object-assign": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/es6-object-assign/-/es6-object-assign-1.1.0.tgz", + "integrity": "sha512-MEl9uirslVwqQU369iHNWZXsI8yaZYGg/D65aOgZkeyFJwHYSxilf7rQzXKI7DdDuBPrBXbfk3sl9hJhmd5AUw==" + }, "node_modules/es6-promise": { "version": "4.2.8", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", @@ -3839,487 +4508,89 @@ "@types/bn.js": "^4.11.3", "bn.js": "^4.11.0", "create-hash": "^1.1.2", - "elliptic": "^6.5.2", - "ethereum-cryptography": "^0.1.3", - "ethjs-util": "0.1.6", - "rlp": "^2.2.3" - } - }, - "node_modules/ethereumjs-common": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/ethereumjs-common/-/ethereumjs-common-1.5.2.tgz", - "integrity": "sha512-hTfZjwGX52GS2jcVO6E2sx4YuFnf0Fhp5ylo4pEPhEffNln7vS59Hr5sLnp3/QCazFLluuBZ+FZ6J5HTp0EqCA==", - "deprecated": "New package name format for new versions: @ethereumjs/common. Please update." - }, - "node_modules/ethereumjs-tx": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ethereumjs-tx/-/ethereumjs-tx-2.1.2.tgz", - "integrity": "sha512-zZEK1onCeiORb0wyCXUvg94Ve5It/K6GD1K+26KfFKodiBiS6d9lfCXlUKGBBdQ+bv7Day+JK0tj1K+BeNFRAw==", - "deprecated": "New package name format for new versions: @ethereumjs/tx. Please update.", - "dependencies": { - "ethereumjs-common": "^1.5.0", - "ethereumjs-util": "^6.0.0" - } - }, - "node_modules/ethereumjs-tx/node_modules/ethereumjs-util": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.2.1.tgz", - "integrity": "sha512-W2Ktez4L01Vexijrm5EB6w7dg4n/TgpoYU4avuT5T3Vmnw/eCRtiBrJfQYS/DCSvDIOLn2k57GcHdeBcgVxAqw==", - "dependencies": { - "@types/bn.js": "^4.11.3", - "bn.js": "^4.11.0", - "create-hash": "^1.1.2", - "elliptic": "^6.5.2", - "ethereum-cryptography": "^0.1.3", - "ethjs-util": "0.1.6", - "rlp": "^2.2.3" - } - }, - "node_modules/ethereumjs-util": { - "version": "7.1.5", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-7.1.5.tgz", - "integrity": "sha512-SDl5kKrQAudFBUe5OJM9Ac6WmMyYmXX/6sTmLZ3ffG2eY6ZIGBes3pEDxNN6V72WyOw4CPD5RomKdsa8DAAwLg==", - "dependencies": { - "@types/bn.js": "^5.1.0", - "bn.js": "^5.1.2", - "create-hash": "^1.1.2", - "ethereum-cryptography": "^0.1.3", - "rlp": "^2.2.4" - }, - "engines": { - "node": ">=10.0.0" - } - }, - "node_modules/ethereumjs-util/node_modules/@types/bn.js": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.0.tgz", - "integrity": "sha512-QSSVYj7pYFN49kW77o2s9xTCwZ8F2xLbjLLSEVh8D2F4JUhZtPAGOFLTD+ffqksBx/u4cE/KImFjyhqCjn/LIA==", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/ethereumjs-util/node_modules/bn.js": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.0.tgz", - "integrity": "sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw==" - }, - "node_modules/ethereumjs-wallet": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/ethereumjs-wallet/-/ethereumjs-wallet-1.0.1.tgz", - "integrity": "sha512-3Z5g1hG1das0JWU6cQ9HWWTY2nt9nXCcwj7eXVNAHKbo00XAZO8+NHlwdgXDWrL0SXVQMvTWN8Q/82DRH/JhPw==", - "dependencies": { - "aes-js": "^3.1.1", - "bs58check": "^2.1.2", - "ethereum-cryptography": "^0.1.3", - "ethereumjs-util": "^7.0.2", - "randombytes": "^2.0.6", - "scrypt-js": "^3.0.1", - "utf8": "^3.0.0", - "uuid": "^3.3.2" - } - }, - "node_modules/ethers": { - "version": "5.5.3", - "resolved": "https://registry.npmjs.org/ethers/-/ethers-5.5.3.tgz", - "integrity": "sha512-fTT4WT8/hTe/BLwRUtl7I5zlpF3XC3P/Xwqxc5AIP2HGlH15qpmjs0Ou78az93b1rLITzXLFxoNX63B8ZbUd7g==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/abi": "5.5.0", - "@ethersproject/abstract-provider": "5.5.1", - "@ethersproject/abstract-signer": "5.5.0", - "@ethersproject/address": "5.5.0", - "@ethersproject/base64": "5.5.0", - "@ethersproject/basex": "5.5.0", - "@ethersproject/bignumber": "5.5.0", - "@ethersproject/bytes": "5.5.0", - "@ethersproject/constants": "5.5.0", - "@ethersproject/contracts": "5.5.0", - "@ethersproject/hash": "5.5.0", - "@ethersproject/hdnode": "5.5.0", - "@ethersproject/json-wallets": "5.5.0", - "@ethersproject/keccak256": "5.5.0", - "@ethersproject/logger": "5.5.0", - "@ethersproject/networks": "5.5.2", - "@ethersproject/pbkdf2": "5.5.0", - "@ethersproject/properties": "5.5.0", - "@ethersproject/providers": "5.5.2", - "@ethersproject/random": "5.5.1", - "@ethersproject/rlp": "5.5.0", - "@ethersproject/sha2": "5.5.0", - "@ethersproject/signing-key": "5.5.0", - "@ethersproject/solidity": "5.5.0", - "@ethersproject/strings": "5.5.0", - "@ethersproject/transactions": "5.5.0", - "@ethersproject/units": "5.5.0", - "@ethersproject/wallet": "5.5.0", - "@ethersproject/web": "5.5.1", - "@ethersproject/wordlists": "5.5.0" - } - }, - "node_modules/ethers/node_modules/@ethersproject/abi": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.5.0.tgz", - "integrity": "sha512-loW7I4AohP5KycATvc0MgujU6JyCHPqHdeoo9z3Nr9xEiNioxa65ccdm1+fsoJhkuhdRtfcL8cfyGamz2AxZ5w==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/address": "^5.5.0", - "@ethersproject/bignumber": "^5.5.0", - "@ethersproject/bytes": "^5.5.0", - "@ethersproject/constants": "^5.5.0", - "@ethersproject/hash": "^5.5.0", - "@ethersproject/keccak256": "^5.5.0", - "@ethersproject/logger": "^5.5.0", - "@ethersproject/properties": "^5.5.0", - "@ethersproject/strings": "^5.5.0" - } - }, - "node_modules/ethers/node_modules/@ethersproject/abstract-provider": { - "version": "5.5.1", - "resolved": "https://registry.npmjs.org/@ethersproject/abstract-provider/-/abstract-provider-5.5.1.tgz", - "integrity": "sha512-m+MA/ful6eKbxpr99xUYeRvLkfnlqzrF8SZ46d/xFB1A7ZVknYc/sXJG0RcufF52Qn2jeFj1hhcoQ7IXjNKUqg==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bignumber": "^5.5.0", - "@ethersproject/bytes": "^5.5.0", - "@ethersproject/logger": "^5.5.0", - "@ethersproject/networks": "^5.5.0", - "@ethersproject/properties": "^5.5.0", - "@ethersproject/transactions": "^5.5.0", - "@ethersproject/web": "^5.5.0" - } - }, - "node_modules/ethers/node_modules/@ethersproject/abstract-signer": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/abstract-signer/-/abstract-signer-5.5.0.tgz", - "integrity": "sha512-lj//7r250MXVLKI7sVarXAbZXbv9P50lgmJQGr2/is82EwEb8r7HrxsmMqAjTsztMYy7ohrIhGMIml+Gx4D3mA==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/abstract-provider": "^5.5.0", - "@ethersproject/bignumber": "^5.5.0", - "@ethersproject/bytes": "^5.5.0", - "@ethersproject/logger": "^5.5.0", - "@ethersproject/properties": "^5.5.0" - } - }, - "node_modules/ethers/node_modules/@ethersproject/address": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/address/-/address-5.5.0.tgz", - "integrity": "sha512-l4Nj0eWlTUh6ro5IbPTgbpT4wRbdH5l8CQf7icF7sb/SI3Nhd9Y9HzhonTSTi6CefI0necIw7LJqQPopPLZyWw==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bignumber": "^5.5.0", - "@ethersproject/bytes": "^5.5.0", - "@ethersproject/keccak256": "^5.5.0", - "@ethersproject/logger": "^5.5.0", - "@ethersproject/rlp": "^5.5.0" - } - }, - "node_modules/ethers/node_modules/@ethersproject/base64": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/base64/-/base64-5.5.0.tgz", - "integrity": "sha512-tdayUKhU1ljrlHzEWbStXazDpsx4eg1dBXUSI6+mHlYklOXoXF6lZvw8tnD6oVaWfnMxAgRSKROg3cVKtCcppA==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bytes": "^5.5.0" - } - }, - "node_modules/ethers/node_modules/@ethersproject/bignumber": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.5.0.tgz", - "integrity": "sha512-6Xytlwvy6Rn3U3gKEc1vP7nR92frHkv6wtVr95LFR3jREXiCPzdWxKQ1cx4JGQBXxcguAwjA8murlYN2TSiEbg==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bytes": "^5.5.0", - "@ethersproject/logger": "^5.5.0", - "bn.js": "^4.11.9" - } - }, - "node_modules/ethers/node_modules/@ethersproject/bytes": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/bytes/-/bytes-5.5.0.tgz", - "integrity": "sha512-ABvc7BHWhZU9PNM/tANm/Qx4ostPGadAuQzWTr3doklZOhDlmcBqclrQe/ZXUIj3K8wC28oYeuRa+A37tX9kog==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/logger": "^5.5.0" - } - }, - "node_modules/ethers/node_modules/@ethersproject/constants": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/constants/-/constants-5.5.0.tgz", - "integrity": "sha512-2MsRRVChkvMWR+GyMGY4N1sAX9Mt3J9KykCsgUFd/1mwS0UH1qw+Bv9k1UJb3X3YJYFco9H20pjSlOIfCG5HYQ==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bignumber": "^5.5.0" - } - }, - "node_modules/ethers/node_modules/@ethersproject/hash": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/hash/-/hash-5.5.0.tgz", - "integrity": "sha512-dnGVpK1WtBjmnp3mUT0PlU2MpapnwWI0PibldQEq1408tQBAbZpPidkWoVVuNMOl/lISO3+4hXZWCL3YV7qzfg==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/abstract-signer": "^5.5.0", - "@ethersproject/address": "^5.5.0", - "@ethersproject/bignumber": "^5.5.0", - "@ethersproject/bytes": "^5.5.0", - "@ethersproject/keccak256": "^5.5.0", - "@ethersproject/logger": "^5.5.0", - "@ethersproject/properties": "^5.5.0", - "@ethersproject/strings": "^5.5.0" - } - }, - "node_modules/ethers/node_modules/@ethersproject/keccak256": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/keccak256/-/keccak256-5.5.0.tgz", - "integrity": "sha512-5VoFCTjo2rYbBe1l2f4mccaRFN/4VQEYFwwn04aJV2h7qf4ZvI2wFxUE1XOX+snbwCLRzIeikOqtAoPwMza9kg==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bytes": "^5.5.0", - "js-sha3": "0.8.0" + "elliptic": "^6.5.2", + "ethereum-cryptography": "^0.1.3", + "ethjs-util": "0.1.6", + "rlp": "^2.2.3" } }, - "node_modules/ethers/node_modules/@ethersproject/logger": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/logger/-/logger-5.5.0.tgz", - "integrity": "sha512-rIY/6WPm7T8n3qS2vuHTUBPdXHl+rGxWxW5okDfo9J4Z0+gRRZT0msvUdIJkE4/HS29GUMziwGaaKO2bWONBrg==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ] + "node_modules/ethereumjs-common": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/ethereumjs-common/-/ethereumjs-common-1.5.2.tgz", + "integrity": "sha512-hTfZjwGX52GS2jcVO6E2sx4YuFnf0Fhp5ylo4pEPhEffNln7vS59Hr5sLnp3/QCazFLluuBZ+FZ6J5HTp0EqCA==", + "deprecated": "New package name format for new versions: @ethereumjs/common. Please update." }, - "node_modules/ethers/node_modules/@ethersproject/networks": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/@ethersproject/networks/-/networks-5.5.2.tgz", - "integrity": "sha512-NEqPxbGBfy6O3x4ZTISb90SjEDkWYDUbEeIFhJly0F7sZjoQMnj5KYzMSkMkLKZ+1fGpx00EDpHQCy6PrDupkQ==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], + "node_modules/ethereumjs-tx": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ethereumjs-tx/-/ethereumjs-tx-2.1.2.tgz", + "integrity": "sha512-zZEK1onCeiORb0wyCXUvg94Ve5It/K6GD1K+26KfFKodiBiS6d9lfCXlUKGBBdQ+bv7Day+JK0tj1K+BeNFRAw==", + "deprecated": "New package name format for new versions: @ethereumjs/tx. Please update.", "dependencies": { - "@ethersproject/logger": "^5.5.0" + "ethereumjs-common": "^1.5.0", + "ethereumjs-util": "^6.0.0" } }, - "node_modules/ethers/node_modules/@ethersproject/properties": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/properties/-/properties-5.5.0.tgz", - "integrity": "sha512-l3zRQg3JkD8EL3CPjNK5g7kMx4qSwiR60/uk5IVjd3oq1MZR5qUg40CNOoEJoX5wc3DyY5bt9EbMk86C7x0DNA==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], + "node_modules/ethereumjs-tx/node_modules/ethereumjs-util": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.2.1.tgz", + "integrity": "sha512-W2Ktez4L01Vexijrm5EB6w7dg4n/TgpoYU4avuT5T3Vmnw/eCRtiBrJfQYS/DCSvDIOLn2k57GcHdeBcgVxAqw==", "dependencies": { - "@ethersproject/logger": "^5.5.0" + "@types/bn.js": "^4.11.3", + "bn.js": "^4.11.0", + "create-hash": "^1.1.2", + "elliptic": "^6.5.2", + "ethereum-cryptography": "^0.1.3", + "ethjs-util": "0.1.6", + "rlp": "^2.2.3" } }, - "node_modules/ethers/node_modules/@ethersproject/rlp": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/rlp/-/rlp-5.5.0.tgz", - "integrity": "sha512-hLv8XaQ8PTI9g2RHoQGf/WSxBfTB/NudRacbzdxmst5VHAqd1sMibWG7SENzT5Dj3yZ3kJYx+WiRYEcQTAkcYA==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], + "node_modules/ethereumjs-util": { + "version": "7.1.5", + "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-7.1.5.tgz", + "integrity": "sha512-SDl5kKrQAudFBUe5OJM9Ac6WmMyYmXX/6sTmLZ3ffG2eY6ZIGBes3pEDxNN6V72WyOw4CPD5RomKdsa8DAAwLg==", "dependencies": { - "@ethersproject/bytes": "^5.5.0", - "@ethersproject/logger": "^5.5.0" + "@types/bn.js": "^5.1.0", + "bn.js": "^5.1.2", + "create-hash": "^1.1.2", + "ethereum-cryptography": "^0.1.3", + "rlp": "^2.2.4" + }, + "engines": { + "node": ">=10.0.0" } }, - "node_modules/ethers/node_modules/@ethersproject/signing-key": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/signing-key/-/signing-key-5.5.0.tgz", - "integrity": "sha512-5VmseH7qjtNmDdZBswavhotYbWB0bOwKIlOTSlX14rKn5c11QmJwGt4GHeo7NrL/Ycl7uo9AHvEqs5xZgFBTng==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], + "node_modules/ethereumjs-util/node_modules/@types/bn.js": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.0.tgz", + "integrity": "sha512-QSSVYj7pYFN49kW77o2s9xTCwZ8F2xLbjLLSEVh8D2F4JUhZtPAGOFLTD+ffqksBx/u4cE/KImFjyhqCjn/LIA==", "dependencies": { - "@ethersproject/bytes": "^5.5.0", - "@ethersproject/logger": "^5.5.0", - "@ethersproject/properties": "^5.5.0", - "bn.js": "^4.11.9", - "elliptic": "6.5.4", - "hash.js": "1.1.7" + "@types/node": "*" } }, - "node_modules/ethers/node_modules/@ethersproject/strings": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.5.0.tgz", - "integrity": "sha512-9fy3TtF5LrX/wTrBaT8FGE6TDJyVjOvXynXJz5MT5azq+E6D92zuKNx7i29sWW2FjVOaWjAsiZ1ZWznuduTIIQ==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], + "node_modules/ethereumjs-util/node_modules/bn.js": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.0.tgz", + "integrity": "sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw==" + }, + "node_modules/ethereumjs-wallet": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ethereumjs-wallet/-/ethereumjs-wallet-1.0.1.tgz", + "integrity": "sha512-3Z5g1hG1das0JWU6cQ9HWWTY2nt9nXCcwj7eXVNAHKbo00XAZO8+NHlwdgXDWrL0SXVQMvTWN8Q/82DRH/JhPw==", "dependencies": { - "@ethersproject/bytes": "^5.5.0", - "@ethersproject/constants": "^5.5.0", - "@ethersproject/logger": "^5.5.0" + "aes-js": "^3.1.1", + "bs58check": "^2.1.2", + "ethereum-cryptography": "^0.1.3", + "ethereumjs-util": "^7.0.2", + "randombytes": "^2.0.6", + "scrypt-js": "^3.0.1", + "utf8": "^3.0.0", + "uuid": "^3.3.2" } }, - "node_modules/ethers/node_modules/@ethersproject/transactions": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/@ethersproject/transactions/-/transactions-5.5.0.tgz", - "integrity": "sha512-9RZYSKX26KfzEd/1eqvv8pLauCKzDTub0Ko4LfIgaERvRuwyaNV78mJs7cpIgZaDl6RJui4o49lHwwCM0526zA==", - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/address": "^5.5.0", - "@ethersproject/bignumber": "^5.5.0", - "@ethersproject/bytes": "^5.5.0", - "@ethersproject/constants": "^5.5.0", - "@ethersproject/keccak256": "^5.5.0", - "@ethersproject/logger": "^5.5.0", - "@ethersproject/properties": "^5.5.0", - "@ethersproject/rlp": "^5.5.0", - "@ethersproject/signing-key": "^5.5.0" - } - }, - "node_modules/ethers/node_modules/@ethersproject/web": { - "version": "5.5.1", - "resolved": "https://registry.npmjs.org/@ethersproject/web/-/web-5.5.1.tgz", - "integrity": "sha512-olvLvc1CB12sREc1ROPSHTdFCdvMh0J5GSJYiQg2D0hdD4QmJDy8QYDb1CvoqD/bF1c++aeKv2sR5uduuG9dQg==", + "node_modules/ethers": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-5.7.2.tgz", + "integrity": "sha512-wswUsmWo1aOK8rR7DIKiWSw9DbLWe6x98Jrn8wcTflTVvaXhAMaB5zGAXy0GYQEQp9iO1iSHWVyARQm11zUtyg==", "funding": [ { "type": "individual", @@ -4331,11 +4602,36 @@ } ], "dependencies": { - "@ethersproject/base64": "^5.5.0", - "@ethersproject/bytes": "^5.5.0", - "@ethersproject/logger": "^5.5.0", - "@ethersproject/properties": "^5.5.0", - "@ethersproject/strings": "^5.5.0" + "@ethersproject/abi": "5.7.0", + "@ethersproject/abstract-provider": "5.7.0", + "@ethersproject/abstract-signer": "5.7.0", + "@ethersproject/address": "5.7.0", + "@ethersproject/base64": "5.7.0", + "@ethersproject/basex": "5.7.0", + "@ethersproject/bignumber": "5.7.0", + "@ethersproject/bytes": "5.7.0", + "@ethersproject/constants": "5.7.0", + "@ethersproject/contracts": "5.7.0", + "@ethersproject/hash": "5.7.0", + "@ethersproject/hdnode": "5.7.0", + "@ethersproject/json-wallets": "5.7.0", + "@ethersproject/keccak256": "5.7.0", + "@ethersproject/logger": "5.7.0", + "@ethersproject/networks": "5.7.1", + "@ethersproject/pbkdf2": "5.7.0", + "@ethersproject/properties": "5.7.0", + "@ethersproject/providers": "5.7.2", + "@ethersproject/random": "5.7.0", + "@ethersproject/rlp": "5.7.0", + "@ethersproject/sha2": "5.7.0", + "@ethersproject/signing-key": "5.7.0", + "@ethersproject/solidity": "5.7.0", + "@ethersproject/strings": "5.7.0", + "@ethersproject/transactions": "5.7.0", + "@ethersproject/units": "5.7.0", + "@ethersproject/wallet": "5.7.0", + "@ethersproject/web": "5.7.1", + "@ethersproject/wordlists": "5.7.0" } }, "node_modules/ethjs-unit": { @@ -4762,9 +5058,12 @@ } }, "node_modules/function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, "node_modules/gensync": { "version": "1.0.0-beta.2", @@ -4783,13 +5082,14 @@ } }, "node_modules/get-intrinsic": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.0.tgz", - "integrity": "sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.2.tgz", + "integrity": "sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==", "dependencies": { - "function-bind": "^1.1.1", - "has": "^1.0.3", - "has-symbols": "^1.0.3" + "function-bind": "^1.1.2", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "hasown": "^2.0.0" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -4940,6 +5240,28 @@ "node": ">=8" } }, + "node_modules/has-property-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.1.tgz", + "integrity": "sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==", + "dependencies": { + "get-intrinsic": "^1.2.2" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz", + "integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/has-symbols": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", @@ -4987,6 +5309,17 @@ "minimalistic-assert": "^1.0.1" } }, + "node_modules/hasown": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz", + "integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/hdkey": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/hdkey/-/hdkey-2.0.1.tgz", @@ -5254,6 +5587,21 @@ "npm": ">=3" } }, + "node_modules/is-nan": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/is-nan/-/is-nan-1.3.2.tgz", + "integrity": "sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w==", + "dependencies": { + "call-bind": "^1.0.0", + "define-properties": "^1.1.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", @@ -5295,6 +5643,14 @@ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" }, + "node_modules/isomorphic-ws": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-5.0.0.tgz", + "integrity": "sha512-muId7Zzn9ywDsyXgTIafTry2sV3nySZeUDe6YedVd1Hvuuep5AsIlqK+XefWpYTyJG5e503F2xIuT2lcU6rCSw==", + "peerDependencies": { + "ws": "*" + } + }, "node_modules/isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", @@ -6199,6 +6555,18 @@ "node": ">=8.6" } }, + "node_modules/miller-rabin": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", + "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", + "dependencies": { + "bn.js": "^4.0.0", + "brorand": "^1.0.1" + }, + "bin": { + "miller-rabin": "bin/miller-rabin" + } + }, "node_modules/mime": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", @@ -6537,6 +6905,29 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/object-is": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.5.tgz", + "integrity": "sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw==", + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "engines": { + "node": ">= 0.4" + } + }, "node_modules/oboe": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/oboe/-/oboe-2.1.5.tgz", @@ -6671,6 +7062,18 @@ "node": ">=6" } }, + "node_modules/parse-asn1": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.6.tgz", + "integrity": "sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw==", + "dependencies": { + "asn1.js": "^5.2.0", + "browserify-aes": "^1.0.0", + "evp_bytestokey": "^1.0.0", + "pbkdf2": "^3.0.3", + "safe-buffer": "^5.1.1" + } + }, "node_modules/parse-headers": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/parse-headers/-/parse-headers-2.0.5.tgz", @@ -6872,6 +7275,19 @@ "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==" }, + "node_modules/public-encrypt": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", + "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", + "dependencies": { + "bn.js": "^4.1.0", + "browserify-rsa": "^4.0.0", + "create-hash": "^1.1.0", + "parse-asn1": "^5.0.0", + "randombytes": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, "node_modules/pump": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", @@ -6943,6 +7359,15 @@ "safe-buffer": "^5.1.0" } }, + "node_modules/randomfill": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", + "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", + "dependencies": { + "randombytes": "^2.0.5", + "safe-buffer": "^5.1.0" + } + }, "node_modules/range-parser": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", @@ -6971,9 +7396,9 @@ "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==" }, "node_modules/readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -7462,6 +7887,20 @@ "node": ">= 0.8" } }, + "node_modules/store2": { + "version": "2.14.2", + "resolved": "https://registry.npmjs.org/store2/-/store2-2.14.2.tgz", + "integrity": "sha512-siT1RiqlfQnGqgT/YzXVUNsom9S0H1OX+dpdGN1xkyYATo4I6sep5NmsRD/40s3IIOvlCq6akxkqG82urIZW1w==" + }, + "node_modules/stream-browserify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-3.0.0.tgz", + "integrity": "sha512-H73RAHsVBapbim0tU2JwwOiXUj+fikfiaoYAKHF3VJfA0pe2BCzkhAHBlLG6REzE+2WNZcxOXjK7lkso+9euLA==", + "dependencies": { + "inherits": "~2.0.4", + "readable-stream": "^3.5.0" + } + }, "node_modules/strict-uri-encode": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz", @@ -7797,6 +8236,11 @@ "node": ">=0.6" } }, + "node_modules/tslib": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==" + }, "node_modules/tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", @@ -8521,6 +8965,26 @@ "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, + "node_modules/ws": { + "version": "8.12.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.12.1.tgz", + "integrity": "sha512-1qo+M9Ba+xNhPB+YTWUlK6M17brTut5EXbcBaMRN5pH5dFrXz7lzz1ChFSUq3bOUl8yEvSenhHmYUNJxFzdJew==", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/xhr": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/xhr/-/xhr-2.6.0.tgz", @@ -8554,6 +9018,21 @@ "xhr-request": "^1.1.0" } }, + "node_modules/xss": { + "version": "1.0.14", + "resolved": "https://registry.npmjs.org/xss/-/xss-1.0.14.tgz", + "integrity": "sha512-og7TEJhXvn1a7kzZGQ7ETjdQVS2UfZyTlsEdDOqvQF7GoxNfY+0YLCzBy1kPdsDDx4QuNAonQPddpsn6Xl/7sw==", + "dependencies": { + "commander": "^2.20.3", + "cssfilter": "0.0.10" + }, + "bin": { + "xss": "bin/xss" + }, + "engines": { + "node": ">= 0.10.0" + } + }, "node_modules/xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", diff --git a/package.json b/package.json index a5e0745..d788624 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "2.1.0", + "version": "2.2.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": { @@ -48,6 +48,7 @@ "@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-bitcoin-controller": "^2.0.3", "@getsafle/vault-bsc-controller": "^1.2.4", "@getsafle/vault-eth-controller": "^1.4.6", diff --git a/src/chains/index.js b/src/chains/index.js index 63bca35..e8b2660 100644 --- a/src/chains/index.js +++ b/src/chains/index.js @@ -6,8 +6,9 @@ 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 evmChains = { 'ethereum': 'ETH', 'bsc': 'BSC', 'polygon': 'MATIC', 'optimism': 'OP' ,'arbitrum': 'ARB', 'mantle': 'MNT', 'velas': 'VLX' }; +const evmChains = { 'ethereum': 'ETH', 'bsc': 'BSC', 'polygon': 'MATIC', 'optimism': 'OP' ,'arbitrum': 'ARB', 'mantle': 'MNT', 'velas': 'VLX' , 'avalanche': 'AVAX'}; const nonEvmChains = { 'bitcoin': 'BTC' }; module.exports = { @@ -19,6 +20,7 @@ module.exports = { arbitrum, mantle, velas, + avalanche, evmChains, nonEvmChains, } \ No newline at end of file diff --git a/src/lib/test/keyring.test.js b/src/lib/test/keyring.test.js index d1108e9..87d7f4e 100644 --- a/src/lib/test/keyring.test.js +++ b/src/lib/test/keyring.test.js @@ -298,7 +298,8 @@ describe('getActiveChains',()=>{ { chain: 'optimism', symbol: 'OP' }, { chain: 'arbitrum', symbol: 'ARB' }, { chain: 'mantle', symbol: 'MNT' }, - { chain: 'velas', symbol: 'VLX' } + { chain: 'velas', symbol: 'VLX' }, + { chain: 'avalanche', symbol: 'AVAX' } ] }).toMatchObject(result) diff --git a/src/lib/test/vault.test.js b/src/lib/test/vault.test.js index 874cb54..279857b 100644 --- a/src/lib/test/vault.test.js +++ b/src/lib/test/vault.test.js @@ -78,7 +78,7 @@ describe('getSupportedChains' , ()=>{ let result = await new Vault({}).getSupportedChains() expect({ - evmChains: { ethereum: 'ETH', bsc: 'BSC', polygon: 'MATIC', optimism: 'OP', arbitrum: 'ARB', mantle: 'MNT', velas: 'VLX' }, + evmChains: { ethereum: 'ETH', bsc: 'BSC', polygon: 'MATIC', optimism: 'OP', arbitrum: 'ARB', mantle: 'MNT', velas: 'VLX', avalanche: 'AVAX' }, nonEvmChains: { bitcoin: 'BTC' } }).toMatchObject(result.response) }) From 2922677f720af31b2cfee8d9583c090f03c76dfe Mon Sep 17 00:00:00 2001 From: saurabh Date: Tue, 19 Dec 2023 11:55:34 +0530 Subject: [PATCH 55/98] integrated base chain --- CHANGELOG.md | 6 +- package-lock.json | 129 ++++++++++++++++++++++++++++++++++- package.json | 3 +- src/chains/index.js | 4 +- src/lib/test/keyring.test.js | 8 +-- src/lib/test/vault.test.js | 2 +- 6 files changed, 140 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a29011..0658fb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -594,4 +594,8 @@ ### 2.2.0 (2023-12-04) -* Integrated avalanche C chain in safle vault. \ No newline at end of file +* Integrated avalanche C chain in safle vault. + +### 2.3.0 (2023-12-19) + +* Integrated base chain in safle vault. \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 4b639a5..47c9a49 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getsafle/safle-vault", - "version": "2.2.0", + "version": "2.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "2.2.0", + "version": "2.3.0", "license": "MIT", "dependencies": { "@getsafle/asset-controller": "^1.0.10", @@ -14,6 +14,7 @@ "@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-bitcoin-controller": "^2.0.3", "@getsafle/vault-bsc-controller": "^1.2.4", "@getsafle/vault-eth-controller": "^1.4.6", @@ -1722,6 +1723,130 @@ "@scure/bip39": "1.2.1" } }, + "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==", + "dependencies": { + "@ethereumjs/tx": "^5.1.0", + "axios": "^1.6.2", + "bip39": "^3.0.4", + "browser-passworder": "^2.0.3", + "crypto-js": "^4.2.0", + "eth-hd-keyring": "^3.6.0", + "eth-sig-util": "^3.0.1", + "eth-simple-keyring": "^4.2.0", + "ethereumjs-util": "^7.1.0", + "hdkey": "^2.0.1", + "loglevel": "^1.7.1", + "obs-store": "^4.0.3", + "web3": "^1.6.0" + } + }, + "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==", + "dependencies": { + "@ethereumjs/util": "^9.0.1", + "crc": "^4.3.2" + } + }, + "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==", + "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/" + } + }, + "node_modules/@getsafle/vault-base-controller/node_modules/axios": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz", + "integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==", + "dependencies": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "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.3", "resolved": "https://registry.npmjs.org/@getsafle/vault-bitcoin-controller/-/vault-bitcoin-controller-2.0.3.tgz", diff --git a/package.json b/package.json index d788624..745dabd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "2.2.0", + "version": "2.3.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": { @@ -49,6 +49,7 @@ "@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-bitcoin-controller": "^2.0.3", "@getsafle/vault-bsc-controller": "^1.2.4", "@getsafle/vault-eth-controller": "^1.4.6", diff --git a/src/chains/index.js b/src/chains/index.js index e8b2660..cab7911 100644 --- a/src/chains/index.js +++ b/src/chains/index.js @@ -7,8 +7,9 @@ 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 evmChains = { 'ethereum': 'ETH', 'bsc': 'BSC', 'polygon': 'MATIC', 'optimism': 'OP' ,'arbitrum': 'ARB', 'mantle': 'MNT', 'velas': 'VLX' , 'avalanche': 'AVAX'}; +const evmChains = { 'ethereum': 'ETH', 'bsc': 'BSC', 'polygon': 'MATIC', 'optimism': 'OP' ,'arbitrum': 'ARB', 'mantle': 'MNT', 'velas': 'VLX' , 'avalanche': 'AVAX', 'base':'BASE'}; const nonEvmChains = { 'bitcoin': 'BTC' }; module.exports = { @@ -21,6 +22,7 @@ module.exports = { mantle, velas, avalanche, + base, evmChains, nonEvmChains, } \ No newline at end of file diff --git a/src/lib/test/keyring.test.js b/src/lib/test/keyring.test.js index 87d7f4e..43882ec 100644 --- a/src/lib/test/keyring.test.js +++ b/src/lib/test/keyring.test.js @@ -209,11 +209,6 @@ describe('exportPrivateKey' , ()=>{ expect(result.error).toBe("Incorrect pin") }) - - - - - }) @@ -299,7 +294,8 @@ describe('getActiveChains',()=>{ { chain: 'arbitrum', symbol: 'ARB' }, { chain: 'mantle', symbol: 'MNT' }, { chain: 'velas', symbol: 'VLX' }, - { chain: 'avalanche', symbol: 'AVAX' } + { chain: 'avalanche', symbol: 'AVAX' }, + { chain: 'base', symbol: 'BASE' } ] }).toMatchObject(result) diff --git a/src/lib/test/vault.test.js b/src/lib/test/vault.test.js index 279857b..1f659d6 100644 --- a/src/lib/test/vault.test.js +++ b/src/lib/test/vault.test.js @@ -78,7 +78,7 @@ describe('getSupportedChains' , ()=>{ let result = await new Vault({}).getSupportedChains() expect({ - evmChains: { ethereum: 'ETH', bsc: 'BSC', polygon: 'MATIC', optimism: 'OP', arbitrum: 'ARB', mantle: 'MNT', velas: 'VLX', avalanche: 'AVAX' }, + evmChains: { ethereum: 'ETH', bsc: 'BSC', polygon: 'MATIC', optimism: 'OP', arbitrum: 'ARB', mantle: 'MNT', velas: 'VLX', avalanche: 'AVAX', base:'BASE' }, nonEvmChains: { bitcoin: 'BTC' } }).toMatchObject(result.response) }) From a7b700cf441f49a914b67cbe8c6d76eefdc399fd Mon Sep 17 00:00:00 2001 From: saurabh Date: Tue, 19 Dec 2023 13:34:52 +0530 Subject: [PATCH 56/98] integrated polygon zkEVM chain --- CHANGELOG.md | 6 +- package-lock.json | 130 ++++++++++++++++++++++++++++++++++- package.json | 3 +- src/chains/index.js | 4 +- src/lib/test/keyring.test.js | 3 +- src/lib/test/vault.test.js | 2 +- 6 files changed, 141 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0658fb6..ef9225a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -598,4 +598,8 @@ ### 2.3.0 (2023-12-19) -* Integrated base chain in safle vault. \ No newline at end of file +* Integrated base chain in safle vault. + +### 2.4.0 (2023-12-19) + +* Integrated polygon zkEVM chain in safle vault. \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 47c9a49..02c9c91 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getsafle/safle-vault", - "version": "2.3.0", + "version": "2.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "2.3.0", + "version": "2.4.0", "license": "MIT", "dependencies": { "@getsafle/asset-controller": "^1.0.10", @@ -21,6 +21,7 @@ "@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-velas-controller": "^1.3.1", "bip39": "^3.0.4", "crypto-js": "^4.1.1", @@ -2139,6 +2140,131 @@ "safe-buffer": "^5.1.1" } }, + "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==", + "dependencies": { + "@ethereumjs/common": "^4.1.0", + "@ethereumjs/tx": "^5.1.0", + "axios": "^1.6.2", + "bip39": "^3.0.4", + "browser-passworder": "^2.0.3", + "crypto-js": "^4.2.0", + "eth-hd-keyring": "^3.6.0", + "eth-sig-util": "^3.0.1", + "eth-simple-keyring": "^4.2.0", + "ethereumjs-util": "^7.1.0", + "hdkey": "^2.0.1", + "loglevel": "^1.7.1", + "obs-store": "^4.0.3", + "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", + "integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==", + "dependencies": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "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, + "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 + } + } + }, + "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==", + "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-velas-controller": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/@getsafle/vault-velas-controller/-/vault-velas-controller-1.3.1.tgz", diff --git a/package.json b/package.json index 745dabd..1242d1f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "2.3.0", + "version": "2.4.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": { @@ -56,6 +56,7 @@ "@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-velas-controller": "^1.3.1", "bip39": "^3.0.4", "crypto-js": "^4.1.1", diff --git a/src/chains/index.js b/src/chains/index.js index cab7911..420171d 100644 --- a/src/chains/index.js +++ b/src/chains/index.js @@ -8,8 +8,9 @@ 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 evmChains = { 'ethereum': 'ETH', 'bsc': 'BSC', 'polygon': 'MATIC', 'optimism': 'OP' ,'arbitrum': 'ARB', 'mantle': 'MNT', 'velas': 'VLX' , 'avalanche': 'AVAX', 'base':'BASE'}; +const evmChains = { 'ethereum': 'ETH', 'bsc': 'BSC', 'polygon': 'MATIC', 'optimism': 'OP' ,'arbitrum': 'ARB', 'mantle': 'MNT', 'velas': 'VLX' , 'avalanche': 'AVAX', 'base':'BASE', 'zkEVM': 'ZKEVM'}; const nonEvmChains = { 'bitcoin': 'BTC' }; module.exports = { @@ -23,6 +24,7 @@ module.exports = { velas, avalanche, base, + zkEVM, evmChains, nonEvmChains, } \ No newline at end of file diff --git a/src/lib/test/keyring.test.js b/src/lib/test/keyring.test.js index 43882ec..c192210 100644 --- a/src/lib/test/keyring.test.js +++ b/src/lib/test/keyring.test.js @@ -295,7 +295,8 @@ describe('getActiveChains',()=>{ { chain: 'mantle', symbol: 'MNT' }, { chain: 'velas', symbol: 'VLX' }, { chain: 'avalanche', symbol: 'AVAX' }, - { chain: 'base', symbol: 'BASE' } + { chain: 'base', symbol: 'BASE' }, + { chain: 'zkEVM', symbol: 'ZKEVM' } ] }).toMatchObject(result) diff --git a/src/lib/test/vault.test.js b/src/lib/test/vault.test.js index 1f659d6..bfda6a8 100644 --- a/src/lib/test/vault.test.js +++ b/src/lib/test/vault.test.js @@ -78,7 +78,7 @@ describe('getSupportedChains' , ()=>{ let result = await new Vault({}).getSupportedChains() expect({ - evmChains: { ethereum: 'ETH', bsc: 'BSC', polygon: 'MATIC', optimism: 'OP', arbitrum: 'ARB', mantle: 'MNT', velas: 'VLX', avalanche: 'AVAX', base:'BASE' }, + evmChains: { ethereum: 'ETH', bsc: 'BSC', polygon: 'MATIC', optimism: 'OP', arbitrum: 'ARB', mantle: 'MNT', velas: 'VLX', avalanche: 'AVAX', base:'BASE', zkEVM: 'ZKEVM'}, nonEvmChains: { bitcoin: 'BTC' } }).toMatchObject(result.response) }) From 8780287e1311d3128f19eedf526308e919b7f70f Mon Sep 17 00:00:00 2001 From: SDargarh Date: Fri, 5 Jan 2024 13:51:18 +0530 Subject: [PATCH 57/98] Updated recover vault to handle disordered logs and duplicate addresses --- CHANGELOG.md | 6 +++++- package-lock.json | 4 ++-- package.json | 2 +- src/lib/vault.js | 1 - src/utils/helper.js | 16 ++++++++++++---- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef9225a..2787bdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -602,4 +602,8 @@ ### 2.4.0 (2023-12-19) -* Integrated polygon zkEVM chain in safle vault. \ No newline at end of file +* Integrated polygon zkEVM chain in safle vault. + +### 2.4.1 (2024-01-05) + +* Updated recover vault to handle disordered logs and duplicate addresses. \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 02c9c91..1f4adb1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getsafle/safle-vault", - "version": "2.4.0", + "version": "2.4.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "2.4.0", + "version": "2.4.1", "license": "MIT", "dependencies": { "@getsafle/asset-controller": "^1.0.10", diff --git a/package.json b/package.json index 1242d1f..c072186 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "2.4.0", + "version": "2.4.1", "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": { diff --git a/src/lib/vault.js b/src/lib/vault.js index b6a0af3..f31fecc 100644 --- a/src/lib/vault.js +++ b/src/lib/vault.js @@ -142,7 +142,6 @@ class Vault extends Keyring { //generate other chain's keyring instance and get accounts from logs let obj = {} for ( let chainData of nonEvmChainList) { - const { response: mnemonic } = await this.exportMnemonic(pin); const keyringInstance = await helper.getCoinInstance(chainData.toLowerCase(), mnemonic); diff --git a/src/utils/helper.js b/src/utils/helper.js index d13afcc..821c88b 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -33,8 +33,10 @@ async function removeEmptyAccounts(indexAddress, keyringInstance, vaultState, un const keyring = keyringInstance.getKeyringsByType(vaultState.keyrings[0].type); let zeroCounter = 0; + let accountCheckList = []; let accountsArray = []; accountsArray.push({ address: indexAddress, isDeleted: false, isImported: false, label: 'Wallet 1' }); + accountCheckList.push(indexAddress) let labelCounter = 2; // as an initial wallet is already created above with label 'Wallet 1' const chains = Object.keys(Chains.evmChains); @@ -43,20 +45,22 @@ async function removeEmptyAccounts(indexAddress, keyringInstance, vaultState, un if (logs[i].action === 'add-account' && (chains.includes(logs[i].chain) || logs[i].chain === undefined)){ let vaultState = await keyringInstance.addNewAccount(keyring[0]); let newAccountAddr = Web3.utils.toChecksumAddress(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1]) - if (logs[i].address.toLowerCase() !== newAccountAddr.toLowerCase()) { + if (logs[i].address.toLowerCase() !== newAccountAddr.toLowerCase() && !accountCheckList.includes(logs[i].address.toLowerCase())) { do { const label = this.createWalletLabels('all', labelCounter); accountsArray.push({ address: newAccountAddr.toLowerCase(), isDeleted: false, isImported: false, label, isExported: false }); + accountCheckList.push(newAccountAddr.toLowerCase()) labelCounter++; let vaultState = await keyringInstance.addNewAccount(keyring[0]); newAccountAddr = Web3.utils.toChecksumAddress(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1]) } - while(logs[i].address.toLowerCase() !== newAccountAddr.toLowerCase()) + while(logs[i].address.toLowerCase() !== newAccountAddr.toLowerCase() && !accountCheckList.includes(logs[i].address.toLowerCase())) } if (logs[i].address.toLowerCase() === newAccountAddr.toLowerCase()) { const label = this.createWalletLabels('all', labelCounter); accountsArray.push({ address: newAccountAddr.toLowerCase(), isDeleted: false, isImported: false, label, isExported: false }); + accountCheckList.push(newAccountAddr.toLowerCase()) labelCounter++; } @@ -98,9 +102,11 @@ async function getAccountsFromLogs(keyringInstance, vaultState, recoverMechanis //if mech = transaction - generate one acc for bitcoin let accountsArray = []; + let accountCheckList = []; let {address} = await keyringInstance.addAccount(); const label = this.createWalletLabels('bitcoin', 1); accountsArray.push({ address: address, isDeleted: false, isImported: false, label, isExported: false }); + accountCheckList.push(address) let labelCounter = 2; const chains = Object.keys(Chains.nonEvmChains); @@ -108,19 +114,21 @@ async function getAccountsFromLogs(keyringInstance, vaultState, recoverMechanis for(let i=0; i < logs.length; i++){ if (logs[i].action === 'add-account' && (chains.includes(logs[i].chain))){ let address = (await keyringInstance.addAccount()).address; - if (logs[i].address.toLowerCase() !== address.toLowerCase()) { + if (logs[i].address.toLowerCase() !== address.toLowerCase() && !accountCheckList.includes(logs[i].address.toLowerCase())) { do { const label = this.createWalletLabels('bitcoin', labelCounter); accountsArray.push({ address: address.toLowerCase(), isDeleted: false, isImported: false, label, isExported: false }); + accountCheckList.push(address.toLowerCase()) labelCounter++; address = (await keyringInstance.addAccount()).address; } - while(logs[i].address.toLowerCase() !== address.toLowerCase()) + while(logs[i].address.toLowerCase() !== address.toLowerCase() && !accountCheckList.includes(logs[i].address.toLowerCase())) } if (logs[i].address.toLowerCase() === address.toLowerCase()) { const label = this.createWalletLabels('bitcoin', labelCounter); accountsArray.push({ address: address.toLowerCase(), isDeleted: false, isImported: false, label, isExported: false }); + accountCheckList.push(address.toLowerCase()) labelCounter ++; } From 951a55871c6e39954a2841c845a9d31aabf13e14 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Tue, 9 Jan 2024 14:02:44 +0530 Subject: [PATCH 58/98] Updated bitcoin controller version --- CHANGELOG.md | 6 +++++- package-lock.json | 12 ++++++------ package.json | 4 ++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2787bdc..614c74f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -606,4 +606,8 @@ ### 2.4.1 (2024-01-05) -* Updated recover vault to handle disordered logs and duplicate addresses. \ No newline at end of file +* Updated recover vault to handle disordered logs and duplicate addresses. + +### 2.4.2 (2024-01-09) + +* Updated bitcoin controller version \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 1f4adb1..3c68b03 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getsafle/safle-vault", - "version": "2.4.1", + "version": "2.4.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "2.4.1", + "version": "2.4.2", "license": "MIT", "dependencies": { "@getsafle/asset-controller": "^1.0.10", @@ -15,7 +15,7 @@ "@getsafle/vault-arbitrum-controller": "^1.0.8", "@getsafle/vault-avalanche-controller": "^1.2.1", "@getsafle/vault-base-controller": "^1.0.1", - "@getsafle/vault-bitcoin-controller": "^2.0.3", + "@getsafle/vault-bitcoin-controller": "^2.0.4", "@getsafle/vault-bsc-controller": "^1.2.4", "@getsafle/vault-eth-controller": "^1.4.6", "@getsafle/vault-mantle-controller": "^1.0.1", @@ -1849,9 +1849,9 @@ } }, "node_modules/@getsafle/vault-bitcoin-controller": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@getsafle/vault-bitcoin-controller/-/vault-bitcoin-controller-2.0.3.tgz", - "integrity": "sha512-Fp1PMHqr8SXyFoNfjaejU/bRIrh3Mq5HpYpAaLBlQ5MFKS8BZUbf/7yNFqOfU4O9DZAcfIjTvwuMSdWbZ7C2Mw==", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@getsafle/vault-bitcoin-controller/-/vault-bitcoin-controller-2.0.4.tgz", + "integrity": "sha512-B1AmpU9qEPR2DtoZ6kJM7UMeVHhFA75DUWtuMed7y+E/baZD/zVu3Z2MAMr+FFVZAmoupBCLOn2CL0GPKwez4A==", "dependencies": { "axios": "^0.21.4", "bip39": "^2.2.0", diff --git a/package.json b/package.json index c072186..5d02445 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "2.4.1", + "version": "2.4.2", "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": { @@ -50,7 +50,7 @@ "@getsafle/vault-arbitrum-controller": "^1.0.8", "@getsafle/vault-avalanche-controller": "^1.2.1", "@getsafle/vault-base-controller": "^1.0.1", - "@getsafle/vault-bitcoin-controller": "^2.0.3", + "@getsafle/vault-bitcoin-controller": "^2.0.4", "@getsafle/vault-bsc-controller": "^1.2.4", "@getsafle/vault-eth-controller": "^1.4.6", "@getsafle/vault-mantle-controller": "^1.0.1", From ae60bf90fdb312fc62d50b86115a820d2f85d526 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Tue, 23 Jan 2024 15:31:32 +0530 Subject: [PATCH 59/98] Increased rate limit for validating pin --- CHANGELOG.md | 6 +++++- package-lock.json | 4 ++-- package.json | 2 +- src/config/index.js | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 614c74f..2395bc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -610,4 +610,8 @@ ### 2.4.2 (2024-01-09) -* Updated bitcoin controller version \ No newline at end of file +* Updated bitcoin controller version + +### 2.4.3 (2024-01-23) + +* Increased rate limit for validating pin \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 3c68b03..b0c25b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getsafle/safle-vault", - "version": "2.4.2", + "version": "2.4.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "2.4.2", + "version": "2.4.3", "license": "MIT", "dependencies": { "@getsafle/asset-controller": "^1.0.10", diff --git a/package.json b/package.json index 5d02445..6c3eb10 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "2.4.2", + "version": "2.4.3", "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": { diff --git a/src/config/index.js b/src/config/index.js index d08d8fd..1151e99 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -1,6 +1,6 @@ module.exports = { DEFAULT_GAS_LIMIT: 40000, REQUEST_BLOCKED_TIMEOUT: 3600000, - TOKEN_WINDOW: 30000, - TOKEN_COUNT: 10, + TOKEN_WINDOW: 15000, + TOKEN_COUNT: 20, }; From cf7aa65b0d03efa960b7e0603148e301463c67b9 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Tue, 23 Jan 2024 15:58:56 +0530 Subject: [PATCH 60/98] Updated bitcoin controller version --- CHANGELOG.md | 3 ++- package-lock.json | 8 ++++---- package.json | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2395bc3..d141cb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -614,4 +614,5 @@ ### 2.4.3 (2024-01-23) -* Increased rate limit for validating pin \ No newline at end of file +* Increased rate limit for validating pin +* Updated bitcoin controller version \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index b0c25b9..ad1fdae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "@getsafle/vault-arbitrum-controller": "^1.0.8", "@getsafle/vault-avalanche-controller": "^1.2.1", "@getsafle/vault-base-controller": "^1.0.1", - "@getsafle/vault-bitcoin-controller": "^2.0.4", + "@getsafle/vault-bitcoin-controller": "^2.0.5", "@getsafle/vault-bsc-controller": "^1.2.4", "@getsafle/vault-eth-controller": "^1.4.6", "@getsafle/vault-mantle-controller": "^1.0.1", @@ -1849,9 +1849,9 @@ } }, "node_modules/@getsafle/vault-bitcoin-controller": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@getsafle/vault-bitcoin-controller/-/vault-bitcoin-controller-2.0.4.tgz", - "integrity": "sha512-B1AmpU9qEPR2DtoZ6kJM7UMeVHhFA75DUWtuMed7y+E/baZD/zVu3Z2MAMr+FFVZAmoupBCLOn2CL0GPKwez4A==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@getsafle/vault-bitcoin-controller/-/vault-bitcoin-controller-2.0.5.tgz", + "integrity": "sha512-Mrm2prkya1FYHECaOV7z9z4c66BeEeRB/CQxEuJ/WDgWYmjFwZvKoaBbCt6prn70OZddwjK9bMktYzYbGaWiGQ==", "dependencies": { "axios": "^0.21.4", "bip39": "^2.2.0", diff --git a/package.json b/package.json index 6c3eb10..28fb1dd 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@getsafle/vault-arbitrum-controller": "^1.0.8", "@getsafle/vault-avalanche-controller": "^1.2.1", "@getsafle/vault-base-controller": "^1.0.1", - "@getsafle/vault-bitcoin-controller": "^2.0.4", + "@getsafle/vault-bitcoin-controller": "^2.0.5", "@getsafle/vault-bsc-controller": "^1.2.4", "@getsafle/vault-eth-controller": "^1.4.6", "@getsafle/vault-mantle-controller": "^1.0.1", From 45c2b3baec8be5eea4bccdad7f5b872b074c90e1 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Wed, 24 Jan 2024 12:05:06 +0530 Subject: [PATCH 61/98] Updated bitcoin controller version with proxy service integrated --- CHANGELOG.md | 6 +++++- package-lock.json | 12 ++++++------ package.json | 4 ++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d141cb9..cebcc5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -615,4 +615,8 @@ ### 2.4.3 (2024-01-23) * Increased rate limit for validating pin -* Updated bitcoin controller version \ No newline at end of file +* Updated bitcoin controller version + +### 2.4.4 (2024-01-24) + +* Updated bitcoin controller version with proxy service integrated \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index ad1fdae..2f3ca8b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getsafle/safle-vault", - "version": "2.4.3", + "version": "2.4.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "2.4.3", + "version": "2.4.4", "license": "MIT", "dependencies": { "@getsafle/asset-controller": "^1.0.10", @@ -15,7 +15,7 @@ "@getsafle/vault-arbitrum-controller": "^1.0.8", "@getsafle/vault-avalanche-controller": "^1.2.1", "@getsafle/vault-base-controller": "^1.0.1", - "@getsafle/vault-bitcoin-controller": "^2.0.5", + "@getsafle/vault-bitcoin-controller": "^2.0.6", "@getsafle/vault-bsc-controller": "^1.2.4", "@getsafle/vault-eth-controller": "^1.4.6", "@getsafle/vault-mantle-controller": "^1.0.1", @@ -1849,9 +1849,9 @@ } }, "node_modules/@getsafle/vault-bitcoin-controller": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@getsafle/vault-bitcoin-controller/-/vault-bitcoin-controller-2.0.5.tgz", - "integrity": "sha512-Mrm2prkya1FYHECaOV7z9z4c66BeEeRB/CQxEuJ/WDgWYmjFwZvKoaBbCt6prn70OZddwjK9bMktYzYbGaWiGQ==", + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@getsafle/vault-bitcoin-controller/-/vault-bitcoin-controller-2.0.6.tgz", + "integrity": "sha512-sZYGpvNZEDELbPTAYC5qSgRUtS7V/F5XJBBbWcHVUN/DEXoSXnr6cLnzjmKdytQDT47nK8PGhrF6Xq2mp6bleA==", "dependencies": { "axios": "^0.21.4", "bip39": "^2.2.0", diff --git a/package.json b/package.json index 28fb1dd..4151e3b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "2.4.3", + "version": "2.4.4", "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": { @@ -50,7 +50,7 @@ "@getsafle/vault-arbitrum-controller": "^1.0.8", "@getsafle/vault-avalanche-controller": "^1.2.1", "@getsafle/vault-base-controller": "^1.0.1", - "@getsafle/vault-bitcoin-controller": "^2.0.5", + "@getsafle/vault-bitcoin-controller": "^2.0.6", "@getsafle/vault-bsc-controller": "^1.2.4", "@getsafle/vault-eth-controller": "^1.4.6", "@getsafle/vault-mantle-controller": "^1.0.1", From 3927f3dd516e75875a103c9724c6b2304b7fc90e Mon Sep 17 00:00:00 2001 From: SDargarh Date: Tue, 30 Jan 2024 12:40:04 +0530 Subject: [PATCH 62/98] Updated bitcoin controller version with network param for signing --- CHANGELOG.md | 6 +++++- package-lock.json | 12 ++++++------ package.json | 4 ++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cebcc5a..00907d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -619,4 +619,8 @@ ### 2.4.4 (2024-01-24) -* Updated bitcoin controller version with proxy service integrated \ No newline at end of file +* Updated bitcoin controller version with proxy service integrated + +### 2.4.5 (2024-01-30) + +* Updated bitcoin controller version with network param for signing \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 2f3ca8b..c92db2e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getsafle/safle-vault", - "version": "2.4.4", + "version": "2.4.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "2.4.4", + "version": "2.4.5", "license": "MIT", "dependencies": { "@getsafle/asset-controller": "^1.0.10", @@ -15,7 +15,7 @@ "@getsafle/vault-arbitrum-controller": "^1.0.8", "@getsafle/vault-avalanche-controller": "^1.2.1", "@getsafle/vault-base-controller": "^1.0.1", - "@getsafle/vault-bitcoin-controller": "^2.0.6", + "@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", @@ -1849,9 +1849,9 @@ } }, "node_modules/@getsafle/vault-bitcoin-controller": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/@getsafle/vault-bitcoin-controller/-/vault-bitcoin-controller-2.0.6.tgz", - "integrity": "sha512-sZYGpvNZEDELbPTAYC5qSgRUtS7V/F5XJBBbWcHVUN/DEXoSXnr6cLnzjmKdytQDT47nK8PGhrF6Xq2mp6bleA==", + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/@getsafle/vault-bitcoin-controller/-/vault-bitcoin-controller-2.0.7.tgz", + "integrity": "sha512-OkfMoVhPqXAeH/xM2/tbVBXQrj9AOAHVXLXxyGicsjPIHWY5IKu1rmQOAMB9zGuiuhmI6yynPQPDksxLo0lvHQ==", "dependencies": { "axios": "^0.21.4", "bip39": "^2.2.0", diff --git a/package.json b/package.json index 4151e3b..fa9bd6a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "2.4.4", + "version": "2.4.5", "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": { @@ -50,7 +50,7 @@ "@getsafle/vault-arbitrum-controller": "^1.0.8", "@getsafle/vault-avalanche-controller": "^1.2.1", "@getsafle/vault-base-controller": "^1.0.1", - "@getsafle/vault-bitcoin-controller": "^2.0.6", + "@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", From 76f0d2271b386eb03d7bf16eb59372f0b7dc951e Mon Sep 17 00:00:00 2001 From: SDargarh Date: Tue, 30 Jan 2024 15:43:07 +0530 Subject: [PATCH 63/98] Updated restore keyring and vault structure in recover vault function for bitcoin --- CHANGELOG.md | 3 ++- src/lib/keyring.js | 13 ------------- src/lib/vault.js | 2 +- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00907d1..10e92e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -623,4 +623,5 @@ ### 2.4.5 (2024-01-30) -* Updated bitcoin controller version with network param for signing \ No newline at end of file +* Updated bitcoin controller version with network param for signing +* Updated restore keyring state and vault structure in recover vault function for bitcoin \ No newline at end of file diff --git a/src/lib/keyring.js b/src/lib/keyring.js index 7c97601..75ae291 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -475,7 +475,6 @@ class Keyring { const numberOfAcc = this.decryptedVault[chainData.chain.toLowerCase()].numberOfAccounts; - for (let i = 0; i < numberOfAcc; i++) { await this[chainData.chain].addAccount(); } @@ -503,18 +502,6 @@ class Keyring { decryptedkeyring[0].opts.numberOfAccounts = numberOfAcc; } - // restoring keyring for other chains - const nonEvmChainList = Object.keys(Chains.nonEvmChains); - for ( let chainData of nonEvmChainList) { - if(this.decryptedVault[chainData]) { - numberOfAcc = this.decryptedVault[chainData].numberOfAcc - if(numberOfAcc >= 1) { - for(let i=0; i < numberOfAcc; i++) { - this[chainData].addAccount(); - } - } - } - } } async deleteAccount(encryptionKey, address, pin) { diff --git a/src/lib/vault.js b/src/lib/vault.js index f31fecc..1eee836 100644 --- a/src/lib/vault.js +++ b/src/lib/vault.js @@ -148,7 +148,7 @@ class Vault extends Keyring { const accArray = await helper.getAccountsFromLogs(keyringInstance, vaultState, recoverMechanism, logs); const numberOfAcc = accArray.length; - rawVault[chainData.toLowerCase()] = { public: accArray, numberOfAcc } + rawVault[chainData.toLowerCase()] = { public: accArray, numberOfAccounts: numberOfAcc } } From 96e953699910d1b8d96937dd274596707364f671 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 5 Feb 2024 11:16:47 +0530 Subject: [PATCH 64/98] Updated recover vault to handle recurring addresses in logs --- CHANGELOG.md | 6 +++++- package-lock.json | 4 ++-- package.json | 2 +- src/utils/helper.js | 15 ++++++++++++--- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10e92e9..34cc79f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -624,4 +624,8 @@ ### 2.4.5 (2024-01-30) * Updated bitcoin controller version with network param for signing -* Updated restore keyring state and vault structure in recover vault function for bitcoin \ No newline at end of file +* Updated restore keyring state and vault structure in recover vault function for bitcoin + +### 2.4.6 (2024-02-2) + +* Updated recover vault to handle recurring addresses in logs \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index c92db2e..cd41a58 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getsafle/safle-vault", - "version": "2.4.5", + "version": "2.4.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "2.4.5", + "version": "2.4.6", "license": "MIT", "dependencies": { "@getsafle/asset-controller": "^1.0.10", diff --git a/package.json b/package.json index fa9bd6a..3b5d492 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "2.4.5", + "version": "2.4.6", "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": { diff --git a/src/utils/helper.js b/src/utils/helper.js index 821c88b..68eb121 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -40,11 +40,16 @@ async function removeEmptyAccounts(indexAddress, keyringInstance, vaultState, un let labelCounter = 2; // as an initial wallet is already created above with label 'Wallet 1' const chains = Object.keys(Chains.evmChains); + let newAccountAddr = indexAddress + if( recoverMechanism === 'logs'){ for(let i=0; i < logs.length; i++){ if (logs[i].action === 'add-account' && (chains.includes(logs[i].chain) || logs[i].chain === undefined)){ - let vaultState = await keyringInstance.addNewAccount(keyring[0]); - let newAccountAddr = Web3.utils.toChecksumAddress(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1]) + if (accountCheckList.includes(newAccountAddr)) { + vaultState = await keyringInstance.addNewAccount(keyring[0]); + newAccountAddr = Web3.utils.toChecksumAddress(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1]) + } + if (logs[i].address.toLowerCase() !== newAccountAddr.toLowerCase() && !accountCheckList.includes(logs[i].address.toLowerCase())) { do { const label = this.createWalletLabels('all', labelCounter); @@ -113,7 +118,11 @@ async function getAccountsFromLogs(keyringInstance, vaultState, recoverMechanis if( recoverMechanism === 'logs'){ for(let i=0; i < logs.length; i++){ if (logs[i].action === 'add-account' && (chains.includes(logs[i].chain))){ - let address = (await keyringInstance.addAccount()).address; + + if (accountCheckList.includes(address)) { + address = (await keyringInstance.addAccount()).address; + } + if (logs[i].address.toLowerCase() !== address.toLowerCase() && !accountCheckList.includes(logs[i].address.toLowerCase())) { do { const label = this.createWalletLabels('bitcoin', labelCounter); From da2988c1f2a9029b7869e0ce49fc35839988b193 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Thu, 8 Feb 2024 18:00:03 +0530 Subject: [PATCH 65/98] Refactored recover vault logic and account labeling --- CHANGELOG.md | 7 +- package-lock.json | 4 +- package.json | 2 +- src/lib/keyring.js | 25 +++-- src/lib/vault.js | 24 +++-- src/utils/helper.js | 231 ++++++++++++++++++++------------------------ 6 files changed, 147 insertions(+), 146 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34cc79f..a1bcf1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -628,4 +628,9 @@ ### 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.4.7 (2024-02-08) + +* Refactored recover vault logic and generalized it for evm and non evm chains +* updated labeling for evm and non evm wallet accounts \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index cd41a58..e8a2de0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getsafle/safle-vault", - "version": "2.4.6", + "version": "2.4.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "2.4.6", + "version": "2.4.7", "license": "MIT", "dependencies": { "@getsafle/asset-controller": "^1.0.10", diff --git a/package.json b/package.json index 3b5d492..88b382e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "2.4.6", + "version": "2.4.7", "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": { diff --git a/src/lib/keyring.js b/src/lib/keyring.js index 75ae291..6013292 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -221,6 +221,8 @@ class Keyring { const acc = await this.getAccounts(); if (Chains.evmChains.hasOwnProperty(this.chain) || this.chain === 'ethereum') { + + let labelPrefix = 'EVM' const accounts = await this.keyringInstance.getAccounts(); const keyring = await this.keyringInstance.getKeyringForAccount(accounts[0]); @@ -229,7 +231,7 @@ class Keyring { const newAccount = await this.keyringInstance.getAccounts(); - this.decryptedVault.eth.public.push({ address: newAccount[newAccount.length - 1], isDeleted: false, isImported: false, label: `Wallet ${acc.response.length + 1}` }) + this.decryptedVault.eth.public.push({ address: newAccount[newAccount.length - 1], isDeleted: false, isImported: false, label: `${labelPrefix} Wallet ${acc.response.length + 1}` }) this.decryptedVault.eth.numberOfAccounts++; const encryptedVault = await helper.cryptography(JSON.stringify(this.decryptedVault), JSON.stringify(encryptionKey), 'encryption'); @@ -245,6 +247,8 @@ class Keyring { let newAddress; + let labelPrefix = Chains.nonEvmChains[this.chain] + if (this[this.chain] === undefined) { const keyringInstance = await helper.getCoinInstance(this.chain, mnemonic); @@ -254,14 +258,14 @@ class Keyring { newAddress = address; - const publicData = [ { address, isDeleted: false, isImported: false, label: `${this.chain[0].toUpperCase() + this.chain.slice(1)} Wallet ${acc.response ? acc.response.length + 1 : 1}` } ]; + const publicData = [ { address, isDeleted: false, isImported: false, label: `${labelPrefix} Wallet ${acc.response ? acc.response.length + 1 : 1}` } ]; this.decryptedVault[this.chain] = { public: publicData, numberOfAccounts: 1 }; } else { const { address } = await this[this.chain].addAccount(); newAddress = address; - (this.decryptedVault[this.chain] === undefined) ? this.decryptedVault[this.chain] = { public: [ { address: newAddress, isDeleted: false, isImported: false, label: `${this.chain[0].toUpperCase() + this.chain.slice(1)} Wallet ${acc.response.length + 1}` } ], numberOfAccounts: 1 } : this.decryptedVault[this.chain].public.push({ address: newAddress, isDeleted: false, isImported: false, label: `${this.chain[0].toUpperCase() + this.chain.slice(1)} Wallet ${acc.response.length + 1}` }); + (this.decryptedVault[this.chain] === undefined) ? this.decryptedVault[this.chain] = { public: [ { address: newAddress, isDeleted: false, isImported: false, label: `${labelPrefix} Wallet ${acc.response.length + 1}` } ], numberOfAccounts: 1 } : this.decryptedVault[this.chain].public.push({ address: newAddress, isDeleted: false, isImported: false, label: `${labelPrefix} Wallet ${acc.response.length + 1}` }); this.decryptedVault[this.chain].numberOfAccounts++; } @@ -643,6 +647,8 @@ class Keyring { } if (Chains.evmChains.hasOwnProperty(this.chain) || this.chain === 'ethereum') { + + let labelPrefix = 'EVM' const keyringInstance = await helper.getCoinInstance(this.chain); @@ -663,13 +669,14 @@ class Keyring { } if (this.decryptedVault.importedWallets === undefined) { - this.decryptedVault.importedWallets = { evmChains: { data: [{ address, privateKey: encryptedPrivKey, isDeleted: false, isImported: true, label: `Wallet ${numOfAcc + 1}` }] } }; + this.decryptedVault.importedWallets = { evmChains: { data: [{ address, privateKey: encryptedPrivKey, isDeleted: false, isImported: true, label: `${labelPrefix} Wallet ${numOfAcc + 1}` }] } }; } else if (this.decryptedVault.importedWallets.evmChains === undefined) { - this.decryptedVault.importedWallets.evmChains = { data: [{ address, privateKey: encryptedPrivKey, isDeleted: false, isImported: true, label: `Wallet ${numOfAcc + 1}` }] }; + this.decryptedVault.importedWallets.evmChains = { data: [{ address, privateKey: encryptedPrivKey, isDeleted: false, isImported: true, label: `${labelPrefix} Wallet ${numOfAcc + 1}` }] }; } else { - this.decryptedVault.importedWallets.evmChains.data.push({ address, privateKey: encryptedPrivKey, isDeleted: false, isImported: true, label: `Wallet ${numOfAcc + 1}` }); + this.decryptedVault.importedWallets.evmChains.data.push({ address, privateKey: encryptedPrivKey, isDeleted: false, isImported: true, label: `${labelPrefix} Wallet ${numOfAcc + 1}` }); } } else { + let labelPrefix = Chains.nonEvmChains[this.chain] const { response: mnemonic } = await this.exportMnemonic(pin); if (this[this.chain] === undefined) { @@ -699,16 +706,16 @@ class Keyring { if (this.decryptedVault.importedWallets === undefined) { let object = {}; - const data = [ { address, isDeleted: false, isImported: true, privateKey: encryptedPrivKey, label: `${this.chain[0].toUpperCase() + this.chain.slice(1)} Wallet ${numOfAcc + 1}` } ]; + const data = [ { address, isDeleted: false, isImported: true, privateKey: encryptedPrivKey, label: `${labelPrefix} Wallet ${numOfAcc + 1}` } ]; object[this.chain] = { data }; this.decryptedVault.importedWallets = object; } else if (this.decryptedVault.importedWallets[this.chain] === undefined) { - const data = [ { address, isDeleted: false, isImported: true, privateKey: encryptedPrivKey, label: `${this.chain[0].toUpperCase() + this.chain.slice(1)} Wallet ${numOfAcc + 1}` } ]; + const data = [ { address, isDeleted: false, isImported: true, privateKey: encryptedPrivKey, label: `${labelPrefix} Wallet ${numOfAcc + 1}` } ]; this.decryptedVault.importedWallets[this.chain] = { data }; } else { - this.decryptedVault.importedWallets[this.chain].data.push({ address, isDeleted: false, isImported: true, privateKey: encryptedPrivKey, label: `${this.chain[0].toUpperCase() + this.chain.slice(1)} Wallet ${numOfAcc + 1}` }); + this.decryptedVault.importedWallets[this.chain].data.push({ address, isDeleted: false, isImported: true, privateKey: encryptedPrivKey, label: `${labelPrefix} Wallet ${numOfAcc + 1}` }); } } diff --git a/src/lib/vault.js b/src/lib/vault.js index 1eee836..ac01833 100644 --- a/src/lib/vault.js +++ b/src/lib/vault.js @@ -90,13 +90,13 @@ class Vault extends Keyring { const privData = await helper.generatePrivData(mnemonic, pin); - const rawVault = { eth: { public: [ { address: accounts[0], isDeleted: false, isImported: false, label: 'Wallet 1' } ], private: privData, numberOfAccounts: 1 }} + const rawVault = { eth: { public: [ { address: accounts[0], isDeleted: false, isImported: false, label: 'EVM Wallet 1' } ], private: privData, numberOfAccounts: 1 }} this.initializeSupportedChainKeyringController(mnemonic); for (const chain of Object.keys(Chains.nonEvmChains)) { const {address: addedAcc } = await this[chain].addAccount(); - let label = `${chain.charAt(0).toUpperCase() + chain.substr(1).toLowerCase()} Wallet 1` + let label = `${Chains.nonEvmChains[chain]} Wallet 1` rawVault[chain] = { public: [ { address: addedAcc, isDeleted: false, isImported: false, label: label } ], numberOfAccounts: 1 } } @@ -129,8 +129,14 @@ class Vault extends Keyring { const vaultState = await this.keyringInstance.createNewVaultAndRestore(JSON.stringify(encryptionKey), mnemonic); - const accountsArray = await helper.removeEmptyAccounts(vaultState.keyrings[0].accounts[0], this.keyringInstance, vaultState, unmarshalApiKey, recoverMechanism, logs); - + let accountsArray = []; + if(recoverMechanism === 'transactions') { + accountsArray = await helper.getAccountsFromTransactions(vaultState.keyrings[0].accounts[0], this.keyringInstance, vaultState, unmarshalApiKey) + } + else if (recoverMechanism === 'logs') { + accountsArray = await helper.getAccountsFromLogs('ethereum', this.keyringInstance, vaultState, logs, vaultState.keyrings[0].accounts[0]) + } + const privData = await helper.generatePrivData(mnemonic, pin); const numberOfAccounts = accountsArray.length; @@ -141,14 +147,14 @@ class Vault extends Keyring { //generate other chain's keyring instance and get accounts from logs let obj = {} - for ( let chainData of nonEvmChainList) { - - const keyringInstance = await helper.getCoinInstance(chainData.toLowerCase(), mnemonic); + for ( let chain of nonEvmChainList) { + const keyringInstance = await helper.getCoinInstance(chain.toLowerCase(), mnemonic); - const accArray = await helper.getAccountsFromLogs(keyringInstance, vaultState, recoverMechanism, logs); + let {address} = await keyringInstance.addAccount(); + const accArray = await helper.getAccountsFromLogs(chain, keyringInstance, vaultState, logs, address); const numberOfAcc = accArray.length; - rawVault[chainData.toLowerCase()] = { public: accArray, numberOfAccounts: numberOfAcc } + rawVault[chain.toLowerCase()] = { public: accArray, numberOfAccounts: numberOfAcc } } diff --git a/src/utils/helper.js b/src/utils/helper.js index 68eb121..8cd2e46 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -27,127 +27,126 @@ async function generatePrivData(mnemonic, pin) { return priv; } - -async function removeEmptyAccounts(indexAddress, keyringInstance, vaultState, unmarshalApiKey, recoverMechanism, logs) { +async function getAccountsFromTransactions(indexAddress, keyringInstance, vaultState, unmarshalApiKey) { const keyring = keyringInstance.getKeyringsByType(vaultState.keyrings[0].type); let zeroCounter = 0; - let accountCheckList = []; let accountsArray = []; - accountsArray.push({ address: indexAddress, isDeleted: false, isImported: false, label: 'Wallet 1' }); - accountCheckList.push(indexAddress) - let labelCounter = 2; // as an initial wallet is already created above with label 'Wallet 1' - const chains = Object.keys(Chains.evmChains); - - let newAccountAddr = indexAddress - - if( recoverMechanism === 'logs'){ - for(let i=0; i < logs.length; i++){ - if (logs[i].action === 'add-account' && (chains.includes(logs[i].chain) || logs[i].chain === undefined)){ - if (accountCheckList.includes(newAccountAddr)) { - vaultState = await keyringInstance.addNewAccount(keyring[0]); - newAccountAddr = Web3.utils.toChecksumAddress(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1]) - } - - if (logs[i].address.toLowerCase() !== newAccountAddr.toLowerCase() && !accountCheckList.includes(logs[i].address.toLowerCase())) { - do { - const label = this.createWalletLabels('all', labelCounter); - accountsArray.push({ address: newAccountAddr.toLowerCase(), isDeleted: false, isImported: false, label, isExported: false }); - accountCheckList.push(newAccountAddr.toLowerCase()) - labelCounter++; - let vaultState = await keyringInstance.addNewAccount(keyring[0]); - newAccountAddr = Web3.utils.toChecksumAddress(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1]) - } - while(logs[i].address.toLowerCase() !== newAccountAddr.toLowerCase() && !accountCheckList.includes(logs[i].address.toLowerCase())) - } - - if (logs[i].address.toLowerCase() === newAccountAddr.toLowerCase()) { - const label = this.createWalletLabels('all', labelCounter); - accountsArray.push({ address: newAccountAddr.toLowerCase(), isDeleted: false, isImported: false, label, isExported: false }); - accountCheckList.push(newAccountAddr.toLowerCase()) - labelCounter++; - } - - } - if(logs[i].action === 'delete-account' && (chains.includes(logs[i].chain) || logs[i].chain === undefined)) { - let ind = accountsArray.findIndex((acc) => acc.address === Web3.utils.toChecksumAddress(logs[i].address)) - ind >= 0 ? accountsArray[ind].isDeleted = true : false; + accountsArray.push({ address: indexAddress, isDeleted: false, isImported: false, label: 'EVM Wallet 1' }); + + do { + zeroCounter = 0; + for(let i=0; i < 5; i++) { + const vaultState = await keyringInstance.addNewAccount(keyring[0]); + + const ethActivity = await getETHTransactions(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1], 'ethereum', unmarshalApiKey); + const polygonActivity = await getPolygonTransactions(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1], 'polygon', unmarshalApiKey); + const bscActivity = await getBSCTransactions(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1], 'bsc', unmarshalApiKey); + const label = this.createWalletLabels('EVM', i+2); + + if (!ethActivity && !polygonActivity && !bscActivity) { + accountsArray.push({ address: vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1], isDeleted: true, isImported: false, label, isExported: false }); + zeroCounter++; + } else { + accountsArray.push({ address: vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1], isDeleted: false, isImported: false, label, isExported: false }); + zeroCounter = 0; } } + } - } else if( recoverMechanism === 'transactions'){ - do { - zeroCounter = 0; - for(let i=0; i < 5; i++) { - const vaultState = await keyringInstance.addNewAccount(keyring[0]); - - const ethActivity = await getETHTransactions(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1], 'ethereum', unmarshalApiKey); - const polygonActivity = await getPolygonTransactions(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1], 'polygon', unmarshalApiKey); - const bscActivity = await getBSCTransactions(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1], 'bsc', unmarshalApiKey); - const label = this.createWalletLabels('all', i+2); + while (zeroCounter < 5 ) + + return accountsArray; +} + +async function getAccountsFromLogs(chain, chainInstance, vaultState, logs, indexAddress) { - if (!ethActivity && !polygonActivity && !bscActivity) { - accountsArray.push({ address: vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1], isDeleted: true, isImported: false, label, isExported: false }); - zeroCounter++; - } else { - accountsArray.push({ address: vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1], isDeleted: false, isImported: false, label, isExported: false }); - zeroCounter = 0; - } - } + let accountsArray = []; + const accountCheckSet = new Set(); + const evmChains = Object.keys(Chains.evmChains); + let generatedAddress = indexAddress + let labelCounter = 1; + let keyring, labelPrifix + + if (chain === 'ethereum' || chain === undefined || evmChains.includes(chain)) { + keyring = chainInstance.getKeyringsByType(vaultState.keyrings[0].type); + labelPrifix = 'EVM'; + } else { + labelPrifix = Chains.nonEvmChains[chain]; + } + + // create account sequentially using chain specific keyring instance + const createNewAddress = async (chain, chainInstance) => { + let address + if (chain === 'ethereum' || chain === undefined) { + vaultState = await chainInstance.addNewAccount(keyring[0]) + address = (Web3.utils.toChecksumAddress(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1])).toLowerCase() } - - while (zeroCounter < 5 ) + else { + address = (await chainInstance.addAccount()).address.toLowerCase(); + } + return address; } - return accountsArray; -} -async function getAccountsFromLogs(keyringInstance, vaultState, recoverMechanism, logs) { + // create account data wrt vault structure + const createAccountObject = async (generatedAddress) => { + const label = this.createWalletLabels(labelPrifix, labelCounter++); + return { address: generatedAddress, isDeleted: false, isImported: false, label, isExported: false }; + }; + + // add the initial address in the account array + if (!indexAddress){ + return accountsArray + } + else if(!logs) { + const account = await createAccountObject(indexAddress); + accountsArray.push(account); + accountCheckSet.add(account.address.toLowerCase()); + return accountsArray + } + else { + const account = await createAccountObject(indexAddress); + accountsArray.push(account); + accountCheckSet.add(account.address.toLowerCase()); + } + + + const addAccountIfVerified = async (logAddress) => { - //if mech = transaction - generate one acc for bitcoin + if (accountCheckSet.has(generatedAddress)) { + // If the previous generated address was added in the check set, generate a new address + generatedAddress = await createNewAddress(chain, chainInstance); + } - let accountsArray = []; - let accountCheckList = []; - let {address} = await keyringInstance.addAccount(); - const label = this.createWalletLabels('bitcoin', 1); - accountsArray.push({ address: address, isDeleted: false, isImported: false, label, isExported: false }); - accountCheckList.push(address) - let labelCounter = 2; - const chains = Object.keys(Chains.nonEvmChains); - - if( recoverMechanism === 'logs'){ - for(let i=0; i < logs.length; i++){ - if (logs[i].action === 'add-account' && (chains.includes(logs[i].chain))){ - - if (accountCheckList.includes(address)) { - address = (await keyringInstance.addAccount()).address; - } - - if (logs[i].address.toLowerCase() !== address.toLowerCase() && !accountCheckList.includes(logs[i].address.toLowerCase())) { - do { - const label = this.createWalletLabels('bitcoin', labelCounter); - accountsArray.push({ address: address.toLowerCase(), isDeleted: false, isImported: false, label, isExported: false }); - accountCheckList.push(address.toLowerCase()) - labelCounter++; - address = (await keyringInstance.addAccount()).address; - } - while(logs[i].address.toLowerCase() !== address.toLowerCase() && !accountCheckList.includes(logs[i].address.toLowerCase())) - } - - if (logs[i].address.toLowerCase() === address.toLowerCase()) { - const label = this.createWalletLabels('bitcoin', labelCounter); - accountsArray.push({ address: address.toLowerCase(), isDeleted: false, isImported: false, label, isExported: false }); - accountCheckList.push(address.toLowerCase()) - labelCounter ++; + while (logAddress !== generatedAddress && !accountCheckSet.has(logAddress)) { + // Generate new addresses till the one matching the logAddress, which has not been addded to checkset yet + const account = await createAccountObject(generatedAddress); + accountsArray.push(account); + accountCheckSet.add(account.address.toLowerCase()); + generatedAddress = await createNewAddress(chain, chainInstance); + } + + if (logAddress === generatedAddress) { + // If the address matches, add it to the accounts array + const account = await createAccountObject(generatedAddress); + accountsArray.push(account); + accountCheckSet.add(account.address.toLowerCase()); + } + }; + + for (let log of logs) { + const logAddress = log?.address?.toLowerCase(); + if (log.action === 'add-account' && log?.chain === chain) { + await addAccountIfVerified(logAddress); + } else if (log.action === 'delete-account' && Chains.nonEvmChains.hasOwnProperty(log.chain)) { + const index = accountsArray.findIndex((acc) => acc.address === logAddress); + if (index !== -1) { + accountsArray[index].isDeleted = true; } - - } - if(logs[i].action === 'delete-account' && (chains.includes(logs[i].chain))) { - let ind = accountsArray.findIndex((acc) => acc.address.toLowerCase() === logs[i].address.toLowerCase()) - ind >= 0 ? accountsArray[ind].isDeleted = true : false; - } } } + return accountsArray; } @@ -284,32 +283,16 @@ function validateEncryptionKey(data, encryptionKey, encryptor, isCustomEncryptor } -function createWalletLabels(labelObj = 'all', walletIndex = 1) { - let labels = {}; - - const chains = Object.keys(Chains.evmChains); - - if (labelObj === 'all') { - chains.forEach(chain => labels[chain] = `${chain.charAt(0).toUpperCase() + chain.substr(1).toLowerCase()} Wallet ${walletIndex}` ); - } - else if (labelObj === 'bitcoin') { - labels = `${labelObj.charAt(0).toUpperCase() + labelObj.substr(1).toLowerCase()} Wallet ${walletIndex}`; - } - else { - chains.forEach(chain => { - if (labels[chain] !== undefined) { - labels[chain] = `${chain.charAt(0).toUpperCase() + chain.substr(1).toLowerCase()} Wallet ${walletIndex}`; - } - }) - } - +function createWalletLabels(labelPrefix, walletIndex = 1) { + let labels = `${labelPrefix} Wallet ${walletIndex}`; return labels; } module.exports = { stringToArrayBuffer, generatePrivData, - removeEmptyAccounts, + // removeEmptyAccounts, + getAccountsFromTransactions, getAccountsFromLogs, getCoinInstance, getAssetDetails, From e9d3a5329cf6f8a69596cc7c6157e10135f09b10 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Thu, 8 Feb 2024 18:13:53 +0530 Subject: [PATCH 66/98] check for empty logs updated --- src/utils/helper.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/helper.js b/src/utils/helper.js index 8cd2e46..3ff2f83 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -60,7 +60,7 @@ async function getAccountsFromTransactions(indexAddress, keyringInstance, vaultS return accountsArray; } -async function getAccountsFromLogs(chain, chainInstance, vaultState, logs, indexAddress) { +async function getAccountsFromLogs(chain, chainInstance, vaultState, logs = [], indexAddress) { let accountsArray = []; const accountCheckSet = new Set(); @@ -99,7 +99,7 @@ async function getAccountsFromLogs(chain, chainInstance, vaultState, logs, inde if (!indexAddress){ return accountsArray } - else if(!logs) { + else if(!logs.length) { const account = await createAccountObject(indexAddress); accountsArray.push(account); accountCheckSet.add(account.address.toLowerCase()); From 2c3f95e5098154015acf7f1121d6e7d8f23ad574 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 12 Feb 2024 22:13:55 +0530 Subject: [PATCH 67/98] Integrated restore account logs for vault recovery --- CHANGELOG.md | 3 +- src/utils/helper.js | 107 +++++++++++++++++++++----------------------- 2 files changed, 54 insertions(+), 56 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1bcf1e..6f876f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -633,4 +633,5 @@ ### 2.4.7 (2024-02-08) * Refactored recover vault logic and generalized it for evm and non evm chains -* updated labeling for evm and non evm wallet accounts \ No newline at end of file +* updated labeling for evm and non evm wallet accounts +* Integrated restore account logs for vault recovery \ No newline at end of file diff --git a/src/utils/helper.js b/src/utils/helper.js index 3ff2f83..6fbbdda 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -60,94 +60,91 @@ async function getAccountsFromTransactions(indexAddress, keyringInstance, vaultS return accountsArray; } -async function getAccountsFromLogs(chain, chainInstance, vaultState, logs = [], indexAddress) { - - let accountsArray = []; - const accountCheckSet = new Set(); - const evmChains = Object.keys(Chains.evmChains); - let generatedAddress = indexAddress + +async function getAccountsFromLogs(chain, chainInstance, vaultState, logs = [], indexAddress) { + + const accountsMap = new Map(); + let generatedAddress = indexAddress; let labelCounter = 1; - let keyring, labelPrifix - if (chain === 'ethereum' || chain === undefined || evmChains.includes(chain)) { - keyring = chainInstance.getKeyringsByType(vaultState.keyrings[0].type); - labelPrifix = 'EVM'; - } else { - labelPrifix = Chains.nonEvmChains[chain]; + if (!indexAddress) { + return []; } - // create account sequentially using chain specific keyring instance + // Create a new address based on the blockchain type const createNewAddress = async (chain, chainInstance) => { - let address + let address; if (chain === 'ethereum' || chain === undefined) { - vaultState = await chainInstance.addNewAccount(keyring[0]) - address = (Web3.utils.toChecksumAddress(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1])).toLowerCase() - } - else { + keyring = chainInstance.getKeyringsByType(vaultState.keyrings[0].type); + vaultState = await chainInstance.addNewAccount(keyring[0]); + address = (Web3.utils.toChecksumAddress(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1])).toLowerCase(); + } else { address = (await chainInstance.addAccount()).address.toLowerCase(); } return address; - } + }; - // create account data wrt vault structure + // Create an account object with a label based on the blockchain type const createAccountObject = async (generatedAddress) => { - const label = this.createWalletLabels(labelPrifix, labelCounter++); + const labelPrefix = chain === 'ethereum' || chain === undefined || Chains.evmChains[chain] ? 'EVM' : Chains.nonEvmChains[chain]; + const label = this.createWalletLabels(labelPrefix, labelCounter++); return { address: generatedAddress, isDeleted: false, isImported: false, label, isExported: false }; }; - // add the initial address in the account array + // If indexAddress is empty, return the values of the accounts map if (!indexAddress){ - return accountsArray - } - else if(!logs.length) { - const account = await createAccountObject(indexAddress); - accountsArray.push(account); - accountCheckSet.add(account.address.toLowerCase()); - return accountsArray - } - else { - const account = await createAccountObject(indexAddress); - accountsArray.push(account); - accountCheckSet.add(account.address.toLowerCase()); + return Array.from(accountsMap.values()); + } else { + // Set the indexAddress account in the accounts map + accountsMap.set(indexAddress, await createAccountObject(indexAddress)); } - + // Add account if verified based on the log address const addAccountIfVerified = async (logAddress) => { + if (accountsMap.has(logAddress)) { + let account = accountsMap.get(logAddress); + if (account.isDeleted === true) { + account.isDeleted = false; + } + } - if (accountCheckSet.has(generatedAddress)) { - // If the previous generated address was added in the check set, generate a new address + if (accountsMap.has(generatedAddress)) { generatedAddress = await createNewAddress(chain, chainInstance); } - - while (logAddress !== generatedAddress && !accountCheckSet.has(logAddress)) { - // Generate new addresses till the one matching the logAddress, which has not been addded to checkset yet - const account = await createAccountObject(generatedAddress); - accountsArray.push(account); - accountCheckSet.add(account.address.toLowerCase()); + + while (logAddress !== generatedAddress && !accountsMap.has(logAddress)) { + accountsMap.set(generatedAddress, await createAccountObject(generatedAddress)); generatedAddress = await createNewAddress(chain, chainInstance); } - + if (logAddress === generatedAddress) { - // If the address matches, add it to the accounts array - const account = await createAccountObject(generatedAddress); - accountsArray.push(account); - accountCheckSet.add(account.address.toLowerCase()); + accountsMap.set(generatedAddress, await createAccountObject(generatedAddress)); } }; + // Iterate through the logs and update the accounts map accordingly for (let log of logs) { const logAddress = log?.address?.toLowerCase(); - if (log.action === 'add-account' && log?.chain === chain) { - await addAccountIfVerified(logAddress); - } else if (log.action === 'delete-account' && Chains.nonEvmChains.hasOwnProperty(log.chain)) { - const index = accountsArray.findIndex((acc) => acc.address === logAddress); - if (index !== -1) { - accountsArray[index].isDeleted = true; + if (log?.chain === chain || (chain === 'ethereum' && log?.chain === undefined)) { + if (log.action === 'add-account') { + await addAccountIfVerified(logAddress); + } + else if(log.action === 'restore-account') { + const account = accountsMap.get(logAddress); + if (account) { + account.isDeleted = false; + } + } else if (log.action === 'delete-account') { + const account = accountsMap.get(logAddress); + if (account) { + account.isDeleted = true; } + } } } - return accountsArray; + // Return the values of the accounts map as an array + return Array.from(accountsMap.values()); } async function getETHTransactions(address, network, unmarshalApiKey) { From ed2a4e4ab79982e25fd06b2ca0fad29d6604497e Mon Sep 17 00:00:00 2001 From: SDargarh Date: Tue, 13 Feb 2024 11:00:45 +0530 Subject: [PATCH 68/98] check for empty logs updated --- src/utils/helper.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/utils/helper.js b/src/utils/helper.js index 6fbbdda..d19bfbd 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -67,10 +67,6 @@ async function getAccountsFromLogs(chain, chainInstance, vaultState, logs = [], let generatedAddress = indexAddress; let labelCounter = 1; - if (!indexAddress) { - return []; - } - // Create a new address based on the blockchain type const createNewAddress = async (chain, chainInstance) => { let address; @@ -93,11 +89,14 @@ async function getAccountsFromLogs(chain, chainInstance, vaultState, logs = [], // If indexAddress is empty, return the values of the accounts map if (!indexAddress){ - return Array.from(accountsMap.values()); + return []; } else { // Set the indexAddress account in the accounts map accountsMap.set(indexAddress, await createAccountObject(indexAddress)); } + if(!logs.length) { + return Array.from(accountsMap.values()); + } // Add account if verified based on the log address const addAccountIfVerified = async (logAddress) => { From 9ec4537ecebf132a717b7adb8d6ce39acb4ee119 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Tue, 13 Feb 2024 11:02:44 +0530 Subject: [PATCH 69/98] removed comment --- src/utils/helper.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/utils/helper.js b/src/utils/helper.js index d19bfbd..ccb0aea 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -287,7 +287,6 @@ function createWalletLabels(labelPrefix, walletIndex = 1) { module.exports = { stringToArrayBuffer, generatePrivData, - // removeEmptyAccounts, getAccountsFromTransactions, getAccountsFromLogs, getCoinInstance, From bb5ba9b7ccaa07c3f1858ca66a9743b3715e06b9 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Thu, 15 Feb 2024 16:16:36 +0530 Subject: [PATCH 70/98] updated controllers --- CHANGELOG.md | 9 +- README.md | 11 - package-lock.json | 468 ++++------------------------------- package.json | 9 +- src/lib/keyring.js | 10 - src/lib/test/keyring.test.js | 149 ----------- src/utils/helper.js | 57 ----- 7 files changed, 67 insertions(+), 646 deletions(-) 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 From d47f2747b8978514e452fc80bd35ab7b40bbb501 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Tue, 20 Feb 2024 11:54:00 +0530 Subject: [PATCH 71/98] resolve conflicts --- CHANGELOG.md | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee73d1e..0b4126c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -637,7 +637,7 @@ * 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. -### 2.4.7 (2024-02-08) +### 2.5.1 (2024-02-20) * Refactored recover vault logic and generalized it for evm and non evm chains * updated labeling for evm and non evm wallet accounts diff --git a/package-lock.json b/package-lock.json index 63a17fb..38b1cc6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getsafle/safle-vault", - "version": "2.5.0", + "version": "2.5.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "2.5.0", + "version": "2.5.1", "license": "MIT", "dependencies": { "@getsafle/safle-identity-wallet": "^1.3.0", diff --git a/package.json b/package.json index aada76a..3f7709f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "2.5.0", + "version": "2.5.1", "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": { From e68b9547a9bddca847b2544f2e14c0bf61c6feed Mon Sep 17 00:00:00 2001 From: SDargarh Date: Tue, 7 May 2024 11:22:24 +0530 Subject: [PATCH 72/98] Integrated stacks chain in safle vault --- CHANGELOG.md | 6 +- package-lock.json | 1400 +++++++++++++++++++++++++++++++++- package.json | 3 +- src/chains/index.js | 4 +- src/lib/test/keyring.test.js | 1 + src/lib/test/vault.test.js | 2 +- src/lib/vault.js | 12 +- 7 files changed, 1397 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b4126c..f57b89d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -641,4 +641,8 @@ * Refactored recover vault logic and generalized it for evm and non evm chains * updated labeling for evm and non evm wallet accounts -* Integrated restore account logs for vault recovery \ No newline at end of file +* Integrated restore account logs for vault recovery + +### 2.6.0 (2024-05-07) + +* Integrated stacks chain in safle vault \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 38b1cc6..de0b58c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getsafle/safle-vault", - "version": "2.5.1", + "version": "2.6.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "2.5.1", + "version": "2.6.0", "license": "MIT", "dependencies": { "@getsafle/safle-identity-wallet": "^1.3.0", @@ -21,6 +21,7 @@ "@getsafle/vault-optimism-controller": "^1.0.8", "@getsafle/vault-polygon-controller": "^1.2.8", "@getsafle/vault-polygon-zkevm-controller": "^1.0.1", + "@getsafle/vault-stacks-controller": "^1.0.3", "@getsafle/vault-velas-controller": "^1.3.1", "bip39": "^3.0.4", "crypto-js": "^4.1.1", @@ -1970,6 +1971,37 @@ "safe-buffer": "^5.1.1" } }, + "node_modules/@getsafle/vault-stacks-controller": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@getsafle/vault-stacks-controller/-/vault-stacks-controller-1.0.3.tgz", + "integrity": "sha512-QRnzQy5uPRL+55+TQSpfNM5OEcRDLWfkTKp5CEQGv4Dv9ln/PLQxfPVZwdnb7Zlo/05nAgdyHfdTzPB8nNQHhQ==", + "dependencies": { + "@stacks/connect": "^7.7.1", + "@stacks/network": "^6.11.3", + "@stacks/transactions": "^6.12.1", + "@stacks/wallet-sdk": "^6.12.1", + "axios": "^1.6.8", + "bn.js": "^5.2.1", + "mocha": "^8.1.3", + "nyc": "^15.1.0", + "obs-store": "^4.0.3" + } + }, + "node_modules/@getsafle/vault-stacks-controller/node_modules/axios": { + "version": "1.6.8", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz", + "integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/@getsafle/vault-stacks-controller/node_modules/bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + }, "node_modules/@getsafle/vault-velas-controller": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/@getsafle/vault-velas-controller/-/vault-velas-controller-1.3.1.tgz", @@ -2367,6 +2399,67 @@ } ] }, + "node_modules/@scure/base": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.6.tgz", + "integrity": "sha512-ok9AWwhcgYuGG3Zfhyqg+zwl+Wn5uE+dwC0NV/2qQkx4dABbb/bx96vWu8NSj+BNjjSjno+JRYRjle1jV08k3g==", + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip32": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.1.3.tgz", + "integrity": "sha512-dSH3+LCWONlSNQuF34xZrG6Xas7tp2jSSqHb/pMfXWM0vKE4JZOtK3uJfoWouUVW5IGlls75HkXmYLldZ8ySgQ==", + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], + "dependencies": { + "@noble/hashes": "~1.1.3", + "@noble/secp256k1": "~1.7.0", + "@scure/base": "~1.1.0" + } + }, + "node_modules/@scure/bip32/node_modules/@noble/hashes": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.1.5.tgz", + "integrity": "sha512-LTMZiiLc+V4v1Yi16TD6aX2gmtKszNye0pQgbaLqkvhIqP7nVsSaJsWloGQjJfJ8offaoP5GtX3yY5swbcJxxQ==", + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ] + }, + "node_modules/@scure/bip39": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.1.0.tgz", + "integrity": "sha512-pwrPOS16VeTKg98dYXQyIjJEcWfz7/1YJIwxUEPFfQPtc86Ym/1sVgQ2RLoD43AazMk2l/unK4ITySSpW2+82w==", + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], + "dependencies": { + "@noble/hashes": "~1.1.1", + "@scure/base": "~1.1.0" + } + }, + "node_modules/@scure/bip39/node_modules/@noble/hashes": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.1.5.tgz", + "integrity": "sha512-LTMZiiLc+V4v1Yi16TD6aX2gmtKszNye0pQgbaLqkvhIqP7nVsSaJsWloGQjJfJ8offaoP5GtX3yY5swbcJxxQ==", + "funding": [ + { + "type": "individual", + "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", @@ -2399,6 +2492,212 @@ "@sinonjs/commons": "^2.0.0" } }, + "node_modules/@stacks/auth": { + "version": "6.13.1", + "resolved": "https://registry.npmjs.org/@stacks/auth/-/auth-6.13.1.tgz", + "integrity": "sha512-nr5VeLIJBVI72eWYs/oQ7nrmuZxe89AlS5Lt/WxCcUDK9Z+oqQR1qsxBo86yVDlmrxoNWncHWD38LX54HsOEzA==", + "dependencies": { + "@stacks/common": "^6.13.0", + "@stacks/encryption": "^6.13.1", + "@stacks/network": "^6.13.0", + "@stacks/profile": "^6.13.1", + "cross-fetch": "^3.1.5", + "jsontokens": "^4.0.1" + } + }, + "node_modules/@stacks/common": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/@stacks/common/-/common-6.13.0.tgz", + "integrity": "sha512-wwzyihjaSdmL6NxKvDeayy3dqM0L0Q2sawmdNtzJDi0FnXuJGm5PeapJj7bEfcI9XwI7Bw5jZoC6mCn9nc5YIw==", + "dependencies": { + "@types/bn.js": "^5.1.0", + "@types/node": "^18.0.4" + } + }, + "node_modules/@stacks/common/node_modules/@types/bn.js": { + "version": "5.1.5", + "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.5.tgz", + "integrity": "sha512-V46N0zwKRF5Q00AZ6hWtN0T8gGmDUaUzLWQvHFo5yThtVwK/VCenFY3wXVbOvNfajEpsTfQM4IN9k/d6gUVX3A==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@stacks/connect": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/@stacks/connect/-/connect-7.7.1.tgz", + "integrity": "sha512-MwLRhgRLOGo0Y4IDC0qp9RUX2SZubgse1aI2TN/fz2abNIh1LgmOKUua3w17YiBEZxDD9nyQ4KW1c33bdnrOPw==", + "dependencies": { + "@stacks/auth": "^6.1.1", + "@stacks/connect-ui": "6.4.1", + "@stacks/network": "^6.1.1", + "@stacks/profile": "^6.1.1", + "@stacks/transactions": "^6.1.1", + "jsontokens": "^4.0.1" + } + }, + "node_modules/@stacks/connect-ui": { + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/@stacks/connect-ui/-/connect-ui-6.4.1.tgz", + "integrity": "sha512-Y6Fp26MUsMQq08zFSWus40rS7RNHrHj6VDJrFUqM9VsksV3wftpsRcy7psQusUvW1DS7fPza67IlM1dcN4rvSg==", + "dependencies": { + "@stencil/core": "^2.17.1" + } + }, + "node_modules/@stacks/encryption": { + "version": "6.13.1", + "resolved": "https://registry.npmjs.org/@stacks/encryption/-/encryption-6.13.1.tgz", + "integrity": "sha512-y5IFX3/nGI3fCk70gE0JwH70GpshD8RhUfvhMLcL96oNaec1cCdj1ZUiQupeicfYTHuraaVBYU9xLls4TRmypg==", + "dependencies": { + "@noble/hashes": "1.1.5", + "@noble/secp256k1": "1.7.1", + "@scure/bip39": "1.1.0", + "@stacks/common": "^6.13.0", + "@types/node": "^18.0.4", + "base64-js": "^1.5.1", + "bs58": "^5.0.0", + "ripemd160-min": "^0.0.6", + "varuint-bitcoin": "^1.1.2" + } + }, + "node_modules/@stacks/encryption/node_modules/@noble/hashes": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.1.5.tgz", + "integrity": "sha512-LTMZiiLc+V4v1Yi16TD6aX2gmtKszNye0pQgbaLqkvhIqP7nVsSaJsWloGQjJfJ8offaoP5GtX3yY5swbcJxxQ==", + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ] + }, + "node_modules/@stacks/encryption/node_modules/base-x": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/base-x/-/base-x-4.0.0.tgz", + "integrity": "sha512-FuwxlW4H5kh37X/oW59pwTzzTKRzfrrQwhmyspRM7swOEZcHtDZSCt45U6oKgtuFE+WYPblePMVIPR4RZrh/hw==" + }, + "node_modules/@stacks/encryption/node_modules/bs58": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/bs58/-/bs58-5.0.0.tgz", + "integrity": "sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ==", + "dependencies": { + "base-x": "^4.0.0" + } + }, + "node_modules/@stacks/network": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/@stacks/network/-/network-6.13.0.tgz", + "integrity": "sha512-Ss/Da4BNyPBBj1OieM981fJ7SkevKqLPkzoI1+Yo7cYR2df+0FipIN++Z4RfpJpc8ne60vgcx7nJZXQsiGhKBQ==", + "dependencies": { + "@stacks/common": "^6.13.0", + "cross-fetch": "^3.1.5" + } + }, + "node_modules/@stacks/profile": { + "version": "6.13.1", + "resolved": "https://registry.npmjs.org/@stacks/profile/-/profile-6.13.1.tgz", + "integrity": "sha512-GCDE13hwoUYZvZKTb5c0Tr74DcxIP/n4bffcYrKa5UabITPQ7JwsJIOyDoAwdtl3lu7fi9aBsKrdfHpBBUSQIQ==", + "dependencies": { + "@stacks/common": "^6.13.0", + "@stacks/network": "^6.13.0", + "@stacks/transactions": "^6.13.1", + "jsontokens": "^4.0.1", + "schema-inspector": "^2.0.2", + "zone-file": "^2.0.0-beta.3" + } + }, + "node_modules/@stacks/storage": { + "version": "6.13.1", + "resolved": "https://registry.npmjs.org/@stacks/storage/-/storage-6.13.1.tgz", + "integrity": "sha512-XnzRAETDKW7Ij3cuUNllrrnLOCwctV/XrIHgVWnD04LNL5R9apkwp9IkzaFbyJZ+XrkUBKwtdCgVYype2XgT6w==", + "dependencies": { + "@stacks/auth": "^6.13.1", + "@stacks/common": "^6.13.0", + "@stacks/encryption": "^6.13.1", + "@stacks/network": "^6.13.0", + "base64-js": "^1.5.1", + "jsontokens": "^4.0.1" + } + }, + "node_modules/@stacks/transactions": { + "version": "6.13.1", + "resolved": "https://registry.npmjs.org/@stacks/transactions/-/transactions-6.13.1.tgz", + "integrity": "sha512-PWw2I+2Fj3CaFYQIoVcqQN6E2qGHNhFv03nuR0CxMq0sx8stPgYZbdzUlnlBcJQdsFiHrw3sPeqnXDZt+Hg5YQ==", + "dependencies": { + "@noble/hashes": "1.1.5", + "@noble/secp256k1": "1.7.1", + "@stacks/common": "^6.13.0", + "@stacks/network": "^6.13.0", + "c32check": "^2.0.0", + "lodash.clonedeep": "^4.5.0" + } + }, + "node_modules/@stacks/transactions/node_modules/@noble/hashes": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.1.5.tgz", + "integrity": "sha512-LTMZiiLc+V4v1Yi16TD6aX2gmtKszNye0pQgbaLqkvhIqP7nVsSaJsWloGQjJfJ8offaoP5GtX3yY5swbcJxxQ==", + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ] + }, + "node_modules/@stacks/wallet-sdk": { + "version": "6.13.1", + "resolved": "https://registry.npmjs.org/@stacks/wallet-sdk/-/wallet-sdk-6.13.1.tgz", + "integrity": "sha512-262CYKAm1j8oVxfGUIJrHp867j9gm5NrqPM85s0TfCv2QhfLDkvme6nKgmvtL2TecAZkBa5tu8M5DQ7z92WvAQ==", + "dependencies": { + "@scure/bip32": "1.1.3", + "@scure/bip39": "1.1.0", + "@stacks/auth": "^6.13.1", + "@stacks/common": "^6.13.0", + "@stacks/encryption": "^6.13.1", + "@stacks/network": "^6.13.0", + "@stacks/profile": "^6.13.1", + "@stacks/storage": "^6.13.1", + "@stacks/transactions": "^6.13.1", + "buffer": "^6.0.3", + "c32check": "^2.0.0", + "jsontokens": "^4.0.1", + "triplesec": "^4.0.3", + "zone-file": "^2.0.0-beta.3" + } + }, + "node_modules/@stacks/wallet-sdk/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" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/@stencil/core": { + "version": "2.22.3", + "resolved": "https://registry.npmjs.org/@stencil/core/-/core-2.22.3.tgz", + "integrity": "sha512-kmVA0M/HojwsfkeHsifvHVIYe4l5tin7J5+DLgtl8h6WWfiMClND5K3ifCXXI2ETDNKiEk21p6jql3Fx9o2rng==", + "bin": { + "stencil": "bin/stencil" + }, + "engines": { + "node": ">=12.10.0", + "npm": ">=6.0.0" + } + }, "node_modules/@szmarczak/http-timer": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-5.0.1.tgz", @@ -2509,9 +2808,12 @@ } }, "node_modules/@types/node": { - "version": "14.14.37", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.37.tgz", - "integrity": "sha512-XYmBiy+ohOR4Lh5jE379fV2IU+6Jn4g5qASinhitfyO71b/sCo6MKsMLF5tc7Zf2CE8hViVQyYSobJNke8OvUw==" + "version": "18.19.31", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.31.tgz", + "integrity": "sha512-ArgCD39YpyyrtFKIqMDvjz79jto5fcI/SVUs2HwB+f0dAzq68yqOdyaSivLiLugSziTpNXLQrVb7RZFmdZzbhA==", + "dependencies": { + "undici-types": "~5.26.4" + } }, "node_modules/@types/pbkdf2": { "version": "3.1.0", @@ -2560,6 +2862,11 @@ "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.0.tgz", "integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==" }, + "node_modules/@ungap/promise-all-settled": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", + "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==" + }, "node_modules/abi-decoder": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/abi-decoder/-/abi-decoder-2.4.0.tgz", @@ -2591,6 +2898,18 @@ "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz", "integrity": "sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==" }, + "node_modules/aggregate-error": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", + "integrity": "sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==", + "dependencies": { + "clean-stack": "^2.0.0", + "indent-string": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", @@ -2606,6 +2925,14 @@ "url": "https://github.com/sponsors/epoberezkin" } }, + "node_modules/ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "engines": { + "node": ">=6" + } + }, "node_modules/ansi-escapes": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", @@ -2654,6 +2981,22 @@ "node": ">= 8" } }, + "node_modules/append-transform": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/append-transform/-/append-transform-2.0.0.tgz", + "integrity": "sha512-7yeyCEurROLQJFv5Xj4lEGTy0borxepjFv1g22oAdqFu//SrAlDl1O1Nxx15SH1RoliUml6p8dwJW9jvZughhg==", + "dependencies": { + "default-require-extensions": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/archy": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", + "integrity": "sha512-Xg+9RwCg/0p32teKdGMPTPnVXKD0w3DfHnFTficozsAgsvq2XenPJq/MYpzzQ/v8zrOyJn6Ds39VA4JIDwFfqw==" + }, "node_modules/argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -2705,6 +3048,14 @@ "node": ">=0.8" } }, + "node_modules/async": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", + "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", + "dependencies": { + "lodash": "^4.17.14" + } + }, "node_modules/async-limiter": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", @@ -2994,6 +3345,17 @@ "node": "*" } }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/bindings": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", @@ -3250,6 +3612,11 @@ "browserify-unibabel": "^3.0.0" } }, + "node_modules/browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==" + }, "node_modules/browserify-aes": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", @@ -3448,6 +3815,23 @@ "node": ">= 0.8" } }, + "node_modules/c32check": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/c32check/-/c32check-2.0.0.tgz", + "integrity": "sha512-rpwfAcS/CMqo0oCqDf3r9eeLgScRE3l/xHDCXhM3UyrfvIn7PrLq63uHh7yYbv8NzaZn5MVsVhIRpQ+5GZ5HyA==", + "dependencies": { + "@noble/hashes": "^1.1.2", + "base-x": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/c32check/node_modules/base-x": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/base-x/-/base-x-4.0.0.tgz", + "integrity": "sha512-FuwxlW4H5kh37X/oW59pwTzzTKRzfrrQwhmyspRM7swOEZcHtDZSCt45U6oKgtuFE+WYPblePMVIPR4RZrh/hw==" + }, "node_modules/cacheable-lookup": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-6.1.0.tgz", @@ -3495,6 +3879,31 @@ "node": ">=8" } }, + "node_modules/caching-transform": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/caching-transform/-/caching-transform-4.0.0.tgz", + "integrity": "sha512-kpqOvwXnjjN44D89K5ccQC+RUrsy7jB/XLlRrx0D7/2HNcTPqzsb6XgYoErwko6QsV184CA2YgS1fxDiiDZMWA==", + "dependencies": { + "hasha": "^5.0.0", + "make-dir": "^3.0.0", + "package-hash": "^4.0.0", + "write-file-atomic": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/caching-transform/node_modules/write-file-atomic": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz", + "integrity": "sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==", + "dependencies": { + "imurmurhash": "^0.1.4", + "is-typedarray": "^1.0.0", + "signal-exit": "^3.0.2", + "typedarray-to-buffer": "^3.1.5" + } + }, "node_modules/call-bind": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", @@ -3566,6 +3975,26 @@ "node": ">=10" } }, + "node_modules/chokidar": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.1.tgz", + "integrity": "sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw==", + "dependencies": { + "anymatch": "~3.1.1", + "braces": "~3.0.2", + "glob-parent": "~5.1.0", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.5.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.1" + } + }, "node_modules/chownr": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", @@ -3631,6 +4060,14 @@ "resolved": "https://registry.npmjs.org/class-is/-/class-is-1.1.0.tgz", "integrity": "sha512-rhjH9AG1fvabIDoGRVH587413LPjTZgmDF9fOFCbFJQV4yuocX1mHxxvXI4g3cGwbVY9wAYIoKlg1N79frJKQw==" }, + "node_modules/clean-stack": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", + "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==", + "engines": { + "node": ">=6" + } + }, "node_modules/cliui": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", @@ -3701,6 +4138,11 @@ "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" }, + "node_modules/commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==" + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -3907,6 +4349,14 @@ } } }, + "node_modules/decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/decode-uri-component": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.2.tgz", @@ -3953,6 +4403,20 @@ "node": ">=0.10.0" } }, + "node_modules/default-require-extensions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/default-require-extensions/-/default-require-extensions-3.0.1.tgz", + "integrity": "sha512-eXTJmRbm2TIt9MgWTsOH1wEuhew6XGZcMeGKCtLedIg/NCsg1iBePXkceTdK4Fii7pzmN9tGsZhKzZ4h7O/fxw==", + "dependencies": { + "strip-bom": "^4.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/defer-to-connect": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz", @@ -4032,6 +4496,14 @@ "node": ">=8" } }, + "node_modules/diff": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", + "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/diff-sequences": { "version": "29.4.3", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.4.3.tgz", @@ -4164,6 +4636,11 @@ "node": ">=0.10" } }, + "node_modules/es6-error": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz", + "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==" + }, "node_modules/es6-iterator": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", @@ -4602,17 +5079,6 @@ "url": "https://github.com/sindresorhus/execa?sponsor=1" } }, - "node_modules/execa/node_modules/is-stream": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", - "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/exit": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", @@ -4825,22 +5291,46 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, - "node_modules/find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "node_modules/find-cache-dir": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz", + "integrity": "sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==", "dependencies": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" + "commondir": "^1.0.1", + "make-dir": "^3.0.2", + "pkg-dir": "^4.1.0" }, "engines": { "node": ">=8" - } + }, + "funding": { + "url": "https://github.com/avajs/find-cache-dir?sponsor=1" + } + }, + "node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/flat": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", + "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", + "bin": { + "flat": "cli.js" + } }, "node_modules/follow-redirects": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", "funding": [ { "type": "individual", @@ -4864,6 +5354,18 @@ "is-callable": "^1.1.3" } }, + "node_modules/foreground-child": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz", + "integrity": "sha512-dCIq9FpEcyQyXKCkyzmlPTFNgrCzPudOe+mhvJU5zAtlBnGVy2yKxtfsxK2tQBThwq225jcvBjpw1Gr40uzZCA==", + "dependencies": { + "cross-spawn": "^7.0.0", + "signal-exit": "^3.0.2" + }, + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", @@ -4906,6 +5408,25 @@ "node": ">= 0.6" } }, + "node_modules/fromentries": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/fromentries/-/fromentries-1.3.2.tgz", + "integrity": "sha512-cHEpEQHUg0f8XdtZCc2ZAhrHzKzT0MrFUTcvx+hfxYu7rGMDc5SKoXFh+n4YigxsHXRzc6OrCshdR1bWH6HHyg==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/fs-extra": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz", @@ -5034,6 +5555,17 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/global": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/global/-/global-4.4.0.tgz", @@ -5093,6 +5625,14 @@ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==" }, + "node_modules/growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "engines": { + "node": ">=4.x" + } + }, "node_modules/har-schema": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", @@ -5202,6 +5742,29 @@ "minimalistic-assert": "^1.0.1" } }, + "node_modules/hasha": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/hasha/-/hasha-5.2.2.tgz", + "integrity": "sha512-Hrp5vIK/xr5SkeN2onO32H0MgNZ0f17HRNH39WfL0SYUNOTZ5Lz1TJ8Pajo/87dYGEFlLMm7mIc/k/s6Bvz9HQ==", + "dependencies": { + "is-stream": "^2.0.0", + "type-fest": "^0.8.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/hasha/node_modules/type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "engines": { + "node": ">=8" + } + }, "node_modules/hasown": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz", @@ -5223,6 +5786,14 @@ "secp256k1": "^4.0.0" } }, + "node_modules/he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "bin": { + "he": "bin/he" + } + }, "node_modules/hmac-drbg": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", @@ -5297,6 +5868,24 @@ "node": ">=10.17.0" } }, + "node_modules/iced-error": { + "version": "0.0.13", + "resolved": "https://registry.npmjs.org/iced-error/-/iced-error-0.0.13.tgz", + "integrity": "sha512-yEEaG8QfyyRL0SsbNNDw3rVgTyqwHFMCuV6jDvD43f/2shmdaFXkqvFLGhDlsYNSolzYHwVLM/CrXt9GygYopA==" + }, + "node_modules/iced-lock": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/iced-lock/-/iced-lock-1.1.0.tgz", + "integrity": "sha512-J9UMVitgTMYrkUil5EB9/Q4BPWiMpFH156yjDlmMoMRKs3s3PnXj/6G0UlzIOGnNi5JVNk/zVYLXVnuo+1QnqQ==", + "dependencies": { + "iced-runtime": "^1.0.0" + } + }, + "node_modules/iced-runtime": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/iced-runtime/-/iced-runtime-1.0.4.tgz", + "integrity": "sha512-rgiJXNF6ZgF2Clh/TKUlBDW3q51YPDJUXmxGQXx1b8tbZpVpTn+1RX9q1sjNkujXIIaVxZByQzPHHORg7KV51g==" + }, "node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -5372,6 +5961,14 @@ "node": ">=0.8.19" } }, + "node_modules/indent-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "engines": { + "node": ">=8" + } + }, "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -5414,6 +6011,17 @@ "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==" }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/is-callable": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", @@ -5436,6 +6044,14 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -5471,6 +6087,17 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-hex-prefixed": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-hex-prefixed/-/is-hex-prefixed-1.0.0.tgz", @@ -5503,6 +6130,25 @@ "node": ">=0.12.0" } }, + "node_modules/is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-typed-array": { "version": "1.1.10", "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.10.tgz", @@ -5526,6 +6172,14 @@ "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==" }, + "node_modules/is-windows": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -5557,6 +6211,17 @@ "node": ">=8" } }, + "node_modules/istanbul-lib-hook": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-hook/-/istanbul-lib-hook-3.0.0.tgz", + "integrity": "sha512-Pt/uge1Q9s+5VAZ+pCo16TYMWPBIl+oaNIjgLQxcX0itS6ueeaA+pEfThZpH8WxhFgCiEb8sAJY6MdUKgiIWaQ==", + "dependencies": { + "append-transform": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/istanbul-lib-instrument": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.1.tgz", @@ -5572,6 +6237,30 @@ "node": ">=8" } }, + "node_modules/istanbul-lib-processinfo": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/istanbul-lib-processinfo/-/istanbul-lib-processinfo-2.0.3.tgz", + "integrity": "sha512-NkwHbo3E00oybX6NGJi6ar0B29vxyvNwoC7eJ4G4Yq28UfY758Hgn/heV8VRFhevPED4LXfFz0DQ8z/0kw9zMg==", + "dependencies": { + "archy": "^1.0.0", + "cross-spawn": "^7.0.3", + "istanbul-lib-coverage": "^3.2.0", + "p-map": "^3.0.0", + "rimraf": "^3.0.0", + "uuid": "^8.3.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-processinfo/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/istanbul-lib-report": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", @@ -6257,6 +6946,16 @@ "graceful-fs": "^4.1.6" } }, + "node_modules/jsontokens": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/jsontokens/-/jsontokens-4.0.1.tgz", + "integrity": "sha512-+MO415LEN6M+3FGsRz4wU20g7N2JA+2j9d9+pGaNJHviG4L8N0qzavGyENw6fJqsq9CcrHOIL6iWX5yeTZ86+Q==", + "dependencies": { + "@noble/hashes": "^1.1.2", + "@noble/secp256k1": "^1.6.3", + "base64-js": "^1.5.1" + } + }, "node_modules/jsprim": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", @@ -6342,6 +7041,27 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, + "node_modules/lodash.clonedeep": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", + "integrity": "sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==" + }, + "node_modules/lodash.flattendeep": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", + "integrity": "sha512-uHaJFihxmJcEX3kT4I23ABqKKalJ/zDrDg0lsFtc1h+3uw49SIJ5beyhx5ExVRti3AvKoOJngIj7xz3oylPdWQ==" + }, + "node_modules/log-symbols": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.0.0.tgz", + "integrity": "sha512-FN8JBzLx6CzeMrB0tg6pqlGU1wCrXW+ZXGH481kfsBqer0hToTIiHdjH4Mq8xJUbvATujKCvaREGWpGUionraA==", + "dependencies": { + "chalk": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/loglevel": { "version": "1.7.1", "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.7.1.tgz", @@ -6586,11 +7306,237 @@ "node": ">=4" } }, + "node_modules/mocha": { + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-8.4.0.tgz", + "integrity": "sha512-hJaO0mwDXmZS4ghXsvPVriOhsxQ7ofcpQdm8dE+jISUOKopitvnXFQmpRR7jd2K6VBG6E26gU3IAbXXGIbu4sQ==", + "dependencies": { + "@ungap/promise-all-settled": "1.1.2", + "ansi-colors": "4.1.1", + "browser-stdout": "1.3.1", + "chokidar": "3.5.1", + "debug": "4.3.1", + "diff": "5.0.0", + "escape-string-regexp": "4.0.0", + "find-up": "5.0.0", + "glob": "7.1.6", + "growl": "1.10.5", + "he": "1.2.0", + "js-yaml": "4.0.0", + "log-symbols": "4.0.0", + "minimatch": "3.0.4", + "ms": "2.1.3", + "nanoid": "3.1.20", + "serialize-javascript": "5.0.1", + "strip-json-comments": "3.1.1", + "supports-color": "8.1.1", + "which": "2.0.2", + "wide-align": "1.1.3", + "workerpool": "6.1.0", + "yargs": "16.2.0", + "yargs-parser": "20.2.4", + "yargs-unparser": "2.0.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha" + }, + "engines": { + "node": ">= 10.12.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mochajs" + } + }, + "node_modules/mocha/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, + "node_modules/mocha/node_modules/cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "node_modules/mocha/node_modules/debug": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/mocha/node_modules/debug/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/mocha/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mocha/node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mocha/node_modules/glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/mocha/node_modules/js-yaml": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.0.0.tgz", + "integrity": "sha512-pqon0s+4ScYUvX30wxQi3PogGFAlUyH0awepWvwkj4jD4v+ova3RiYw8bmA6x2rDrEaj8i/oWKoRxpVNW+Re8Q==", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/mocha/node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mocha/node_modules/minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/mocha/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/mocha/node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mocha/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/mocha/node_modules/yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dependencies": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mocha/node_modules/yargs-parser": { + "version": "20.2.4", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", + "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", + "engines": { + "node": ">=10" + } + }, "node_modules/mock-fs": { "version": "4.14.0", "resolved": "https://registry.npmjs.org/mock-fs/-/mock-fs-4.14.0.tgz", "integrity": "sha512-qYvlv/exQ4+svI3UOvPUpLDF0OMX5euvUH0Ny4N5QyRyhNdgAgUrVH3iUINSzEPLvx0kbo/Bp28GJKIqvE7URw==" }, + "node_modules/more-entropy": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/more-entropy/-/more-entropy-0.0.7.tgz", + "integrity": "sha512-e0TxQtU1F6/ZA8WnEA2JLQwwDqBTtZFLJSW7rWgUsQou35wx1IOL0g2O7q7oGoMgIJto+jHMnNGHLfSiylHRrw==", + "dependencies": { + "iced-runtime": ">=0.0.1" + } + }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -6645,6 +7591,17 @@ "resolved": "https://registry.npmjs.org/nano-json-stream-parser/-/nano-json-stream-parser-0.1.2.tgz", "integrity": "sha512-9MqxMH/BSJC7dnLsEMPyfN5Dvoo49IsPFYMcHw3Bcfc2kN0lpHRBSzlMSVx4HGyJ7s9B31CyBTVehWJoQ8Ctew==" }, + "node_modules/nanoid": { + "version": "3.1.20", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.20.tgz", + "integrity": "sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw==", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -6721,6 +7678,17 @@ "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==" }, + "node_modules/node-preload": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/node-preload/-/node-preload-0.2.1.tgz", + "integrity": "sha512-RM5oyBy45cLEoHqCeh+MNuFAxO0vTFBLskvQbOKnEE7YTTSN4tbN8QWDIPQ6L+WvKsB/qLEGpYe2ZZ9d4W9OIQ==", + "dependencies": { + "process-on-spawn": "^1.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/node-releases": { "version": "2.0.10", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.10.tgz", @@ -6774,6 +7742,126 @@ "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", "integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU=" }, + "node_modules/nyc": { + "version": "15.1.0", + "resolved": "https://registry.npmjs.org/nyc/-/nyc-15.1.0.tgz", + "integrity": "sha512-jMW04n9SxKdKi1ZMGhvUTHBN0EICCRkHemEoE5jm6mTYcqcdas0ATzgUgejlQUHMvpnOZqGB5Xxsv9KxJW1j8A==", + "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": "^4.0.0", + "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": ">=8.9" + } + }, + "node_modules/nyc/node_modules/cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "node_modules/nyc/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==" + }, + "node_modules/nyc/node_modules/istanbul-lib-instrument": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.3.tgz", + "integrity": "sha512-BXgQl9kf4WTCPCCpmFGoJkz/+uhvm7h7PFKUYxh7qarQd3ER33vHG//qaE8eN25l07YqZPpHXU9I09l/RD5aGQ==", + "dependencies": { + "@babel/core": "^7.7.5", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-coverage": "^3.0.0", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/nyc/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==", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/nyc/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==" + }, + "node_modules/nyc/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==", + "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/nyc/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==", + "dependencies": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/oauth-sign": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", @@ -6947,6 +8035,17 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/p-map": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-3.0.0.tgz", + "integrity": "sha512-d3qXVTF/s+W+CdJ5A29wywV2n8CQQYahlgz2bFiA+4eVNJbHJodPZ+/gXwPGh0bOqA+j8S+6+ckmvLGPk1QpxQ==", + "dependencies": { + "aggregate-error": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/p-try": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", @@ -6955,6 +8054,20 @@ "node": ">=6" } }, + "node_modules/package-hash": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/package-hash/-/package-hash-4.0.0.tgz", + "integrity": "sha512-whdkPIooSu/bASggZ96BWVvZTRMOFxnyUG5PnTSGKoJE2gd5mbVNmR2Nj20QFzxYYgAXpoqC+AiXzl+UMRh7zQ==", + "dependencies": { + "graceful-fs": "^4.1.15", + "hasha": "^5.0.0", + "lodash.flattendeep": "^4.4.0", + "release-zalgo": "^1.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/parse-asn1": { "version": "5.1.6", "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.6.tgz", @@ -7134,6 +8247,25 @@ "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" }, + "node_modules/process-on-spawn": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/process-on-spawn/-/process-on-spawn-1.0.0.tgz", + "integrity": "sha512-1WsPDsUSMmZH5LeMLegqkPDrsGgsWwk1Exipy2hvB0o/F0ASzbpIctSCcZIK1ykJvtTJULEH+20WOFjMvGnCTg==", + "dependencies": { + "fromentries": "^1.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/progress": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz", + "integrity": "sha512-UdA8mJ4weIkUBO224tIarHzuHs4HuYiJvsuGT7j/SPQiUJVjYvNDBIPa0hAorduOfjGohB/qHWRa/lrrWX/mXw==", + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/prompts": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", @@ -7301,6 +8433,28 @@ "node": ">= 6" } }, + "node_modules/readdirp": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.5.0.tgz", + "integrity": "sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ==", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/release-zalgo": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/release-zalgo/-/release-zalgo-1.0.0.tgz", + "integrity": "sha512-gUAyHVHPPC5wdqX/LG4LWtRYtgjxyX78oanFNTMMyFEfOqdC54s3eE82imuWKbOeqYht2CrNf64Qb8vgmmtZGA==", + "dependencies": { + "es6-error": "^4.0.1" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/request": { "version": "2.88.2", "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", @@ -7373,6 +8527,11 @@ "node": ">=0.10.0" } }, + "node_modules/require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==" + }, "node_modules/resolve": { "version": "1.22.1", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", @@ -7440,6 +8599,20 @@ "node": ">=8" } }, + "node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/ripemd160": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", @@ -7449,6 +8622,14 @@ "inherits": "^2.0.1" } }, + "node_modules/ripemd160-min": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/ripemd160-min/-/ripemd160-min-0.0.6.tgz", + "integrity": "sha512-+GcJgQivhs6S9qvLogusiTcS9kQUfgR75whKuy5jIhuiOfQuJ8fjqxV6EGD5duH1Y/FawFUMtMhyeq3Fbnib8A==", + "engines": { + "node": ">=8" + } + }, "node_modules/rlp": { "version": "2.2.6", "resolved": "https://registry.npmjs.org/rlp/-/rlp-2.2.6.tgz", @@ -7501,6 +8682,14 @@ "big.js": "^3.1.3" } }, + "node_modules/schema-inspector": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/schema-inspector/-/schema-inspector-2.1.0.tgz", + "integrity": "sha512-3bmQVhbA01/EW8cZin4vIpqlpNU2SIy4BhKCfCgogJ3T/L76dLx3QAE+++4o+dNT33sa+SN9vOJL7iHiHFjiNg==", + "dependencies": { + "async": "~2.6.3" + } + }, "node_modules/scrypt-js": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-3.0.1.tgz", @@ -7569,6 +8758,14 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" }, + "node_modules/serialize-javascript": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-5.0.1.tgz", + "integrity": "sha512-SaaNal9imEO737H2c05Og0/8LUXG7EnsZyMa8MzkmuHoELfT6txuj0cMqRj6zfPKnmQ1yasR4PCJc8x+M4JSPA==", + "dependencies": { + "randombytes": "^2.1.0" + } + }, "node_modules/serve-static": { "version": "1.15.0", "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", @@ -7598,6 +8795,11 @@ "node": ">=6" } }, + "node_modules/set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==" + }, "node_modules/setimmediate": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", @@ -7727,6 +8929,22 @@ "source-map": "^0.6.0" } }, + "node_modules/spawn-wrap": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/spawn-wrap/-/spawn-wrap-2.0.0.tgz", + "integrity": "sha512-EeajNjfN9zMnULLwhZZQU3GWBoFNkbngTUPfaawT4RkMiviTxcX0qfhVbGey39mfctfDHkWtuecgQ8NJcyQWHg==", + "dependencies": { + "foreground-child": "^2.0.0", + "is-windows": "^1.0.2", + "make-dir": "^3.0.0", + "rimraf": "^3.0.0", + "signal-exit": "^3.0.2", + "which": "^2.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -8129,6 +9347,19 @@ "node": ">=0.6" } }, + "node_modules/triplesec": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/triplesec/-/triplesec-4.0.3.tgz", + "integrity": "sha512-fug70e1nJoCMxsXQJlETisAALohm84vl++IiTTHEqM7Lgqwz62jrlwqOC/gJEAJjO/ByN127sEcioB56HW3wIw==", + "dependencies": { + "iced-error": ">=0.0.9", + "iced-lock": "^1.0.1", + "iced-runtime": "^1.0.2", + "more-entropy": ">=0.0.7", + "progress": "~1.1.2", + "uglify-js": "^3.1.9" + } + }, "node_modules/tslib": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", @@ -8204,11 +9435,27 @@ "resolved": "https://registry.npmjs.org/typeforce/-/typeforce-1.18.0.tgz", "integrity": "sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g==" }, + "node_modules/uglify-js": { + "version": "3.17.4", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.4.tgz", + "integrity": "sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==", + "bin": { + "uglifyjs": "bin/uglifyjs" + }, + "engines": { + "node": ">=0.8.0" + } + }, "node_modules/ultron": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz", "integrity": "sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og==" }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + }, "node_modules/unorm": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/unorm/-/unorm-1.6.0.tgz", @@ -8798,6 +10045,11 @@ "node": ">= 8" } }, + "node_modules/which-module": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz", + "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==" + }, "node_modules/which-typed-array": { "version": "1.1.9", "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.9.tgz", @@ -8817,6 +10069,53 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "dependencies": { + "string-width": "^1.0.2 || 2" + } + }, + "node_modules/wide-align/node_modules/ansi-regex": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz", + "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==", + "engines": { + "node": ">=4" + } + }, + "node_modules/wide-align/node_modules/is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w==", + "engines": { + "node": ">=4" + } + }, + "node_modules/wide-align/node_modules/string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dependencies": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/wide-align/node_modules/strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha512-4XaJ2zQdCzROZDivEVIDPkcQn8LMFSa8kj8Gxb/Lnwzv9A8VctNZ+lfivC/sV3ivW8ElJTERXZoPBRrZKkNKow==", + "dependencies": { + "ansi-regex": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/wif": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/wif/-/wif-2.0.6.tgz", @@ -8825,6 +10124,11 @@ "bs58check": "<3.0.0" } }, + "node_modules/workerpool": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.1.0.tgz", + "integrity": "sha512-toV7q9rWNYha963Pl/qyeZ6wG+3nnsyvolaNUS8+R5Wtw6qJPTxIlOP1ZSvcGhEJw+l3HMMmtiNo9Gl61G4GVg==" + }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", @@ -8980,6 +10284,42 @@ "node": ">=12" } }, + "node_modules/yargs-unparser": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", + "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", + "dependencies": { + "camelcase": "^6.0.0", + "decamelize": "^4.0.0", + "flat": "^5.0.2", + "is-plain-obj": "^2.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs-unparser/node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/yargs-unparser/node_modules/decamelize": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", @@ -8990,6 +10330,14 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } + }, + "node_modules/zone-file": { + "version": "2.0.0-beta.3", + "resolved": "https://registry.npmjs.org/zone-file/-/zone-file-2.0.0-beta.3.tgz", + "integrity": "sha512-6tE3PSRcpN5lbTTLlkLez40WkNPc9vw/u1J2j6DBiy0jcVX48nCkWrx2EC+bWHqC2SLp069Xw4AdnYn/qp/W5g==", + "engines": { + "node": ">=10" + } } } } diff --git a/package.json b/package.json index 3f7709f..80495dc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "2.5.1", + "version": "2.6.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": { @@ -56,6 +56,7 @@ "@getsafle/vault-optimism-controller": "^1.0.8", "@getsafle/vault-polygon-controller": "^1.2.8", "@getsafle/vault-polygon-zkevm-controller": "^1.0.1", + "@getsafle/vault-stacks-controller": "^1.0.3", "@getsafle/vault-velas-controller": "^1.3.1", "bip39": "^3.0.4", "crypto-js": "^4.1.1", diff --git a/src/chains/index.js b/src/chains/index.js index 420171d..b1e6428 100644 --- a/src/chains/index.js +++ b/src/chains/index.js @@ -9,9 +9,10 @@ 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 evmChains = { 'ethereum': 'ETH', 'bsc': 'BSC', 'polygon': 'MATIC', 'optimism': 'OP' ,'arbitrum': 'ARB', 'mantle': 'MNT', 'velas': 'VLX' , 'avalanche': 'AVAX', 'base':'BASE', 'zkEVM': 'ZKEVM'}; -const nonEvmChains = { 'bitcoin': 'BTC' }; +const nonEvmChains = { 'bitcoin': 'BTC', 'stacks': 'STX' }; module.exports = { ethereum, @@ -25,6 +26,7 @@ module.exports = { avalanche, base, zkEVM, + stacks, evmChains, nonEvmChains, } \ No newline at end of file diff --git a/src/lib/test/keyring.test.js b/src/lib/test/keyring.test.js index d8580d7..60e4bf8 100644 --- a/src/lib/test/keyring.test.js +++ b/src/lib/test/keyring.test.js @@ -287,6 +287,7 @@ describe('getActiveChains',()=>{ expect({ response: [ { chain: 'bitcoin', symbol: 'BTC' }, + { chain: 'stacks', symbol: 'STX' }, { chain: 'ethereum', symbol: 'ETH' }, { chain: 'bsc', symbol: 'BSC' }, { chain: 'polygon', symbol: 'MATIC' }, diff --git a/src/lib/test/vault.test.js b/src/lib/test/vault.test.js index bfda6a8..c90bda7 100644 --- a/src/lib/test/vault.test.js +++ b/src/lib/test/vault.test.js @@ -79,7 +79,7 @@ describe('getSupportedChains' , ()=>{ let result = await new Vault({}).getSupportedChains() expect({ evmChains: { ethereum: 'ETH', bsc: 'BSC', polygon: 'MATIC', optimism: 'OP', arbitrum: 'ARB', mantle: 'MNT', velas: 'VLX', avalanche: 'AVAX', base:'BASE', zkEVM: 'ZKEVM'}, - nonEvmChains: { bitcoin: 'BTC' } + nonEvmChains: { bitcoin: 'BTC', stacks: 'STX' } }).toMatchObject(result.response) }) diff --git a/src/lib/vault.js b/src/lib/vault.js index ac01833..2074f39 100644 --- a/src/lib/vault.js +++ b/src/lib/vault.js @@ -1,6 +1,7 @@ const CryptoJS = require('crypto-js'); const { KeyringController } = require('@getsafle/vault-eth-controller'); const BitcoinKeyringController= require('@getsafle/vault-bitcoin-controller').KeyringController ; +const StacksKeyringController = require('@getsafle/vault-stacks-controller').KeyringController; const bip39 = require('bip39'); const helper = require('../utils/helper'); @@ -53,6 +54,9 @@ class Vault extends Keyring { initializeSupportedChainKeyringController(mnemonic) { const keyringController = new BitcoinKeyringController({mnemonic:mnemonic}); this["bitcoin"] = keyringController; + + const stacksKeyringController = new StacksKeyringController({mnemonic:mnemonic}); + this["stacks"] = stacksKeyringController; } async generateMnemonic(entropy) { @@ -95,9 +99,15 @@ class Vault extends Keyring { this.initializeSupportedChainKeyringController(mnemonic); for (const chain of Object.keys(Chains.nonEvmChains)) { - const {address: addedAcc } = await this[chain].addAccount(); + let addedAcc + if (chain === 'stacks') { + addedAcc = (await this[chain].generateWallet()).address; + } else { + addedAcc = (await this[chain].addAccount()).address; + } let label = `${Chains.nonEvmChains[chain]} Wallet 1` rawVault[chain] = { public: [ { address: addedAcc, isDeleted: false, isImported: false, label: label } ], numberOfAccounts: 1 } + } const vault = await helper.cryptography(JSON.stringify(rawVault), JSON.stringify(encryptionKey), 'encryption'); From aee6d96282c97e424e17b4761e0e9aa86b89b85b Mon Sep 17 00:00:00 2001 From: SDargarh Date: Tue, 7 May 2024 13:54:43 +0530 Subject: [PATCH 73/98] updated restoring and recovering vault --- src/lib/keyring.js | 6 +++++- src/lib/test/keyring.test.js | 2 +- src/lib/vault.js | 15 +++++++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/lib/keyring.js b/src/lib/keyring.js index 42cd72d..7e284f2 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -480,7 +480,11 @@ class Keyring { const numberOfAcc = this.decryptedVault[chainData.chain.toLowerCase()].numberOfAccounts; for (let i = 0; i < numberOfAcc; i++) { - await this[chainData.chain].addAccount(); + if(chainData.chain.toLowerCase() === 'stacks' && i === 0) { + await this[chainData.chain].generateWallet() + } else { + await this[chainData.chain].addAccount(); + } } }) } diff --git a/src/lib/test/keyring.test.js b/src/lib/test/keyring.test.js index 60e4bf8..91d97c9 100644 --- a/src/lib/test/keyring.test.js +++ b/src/lib/test/keyring.test.js @@ -19,7 +19,7 @@ let impAccAddress let chains const ethUrl = 'https://mainnet.infura.io/v3/6145d532688844c4b6db32574d90e19f'; -const polygonRpcUrl = 'https://rpc-mumbai.maticvigil.com'; +const polygonRpcUrl = 'https://polygon-testnet.public.blastapi.io'; const bscRpcUrl = 'https://rpc.ankr.com/bsc'; beforeAll(async() => { diff --git a/src/lib/vault.js b/src/lib/vault.js index 2074f39..8f4cc6c 100644 --- a/src/lib/vault.js +++ b/src/lib/vault.js @@ -159,9 +159,20 @@ class Vault extends Keyring { let obj = {} for ( let chain of nonEvmChainList) { const keyringInstance = await helper.getCoinInstance(chain.toLowerCase(), mnemonic); - - let {address} = await keyringInstance.addAccount(); + let address + if(chain === 'stacks') { + address = (await keyringInstance.generateWallet()).address; + } else { + address = (await keyringInstance.addAccount()).address; + } + const accArray = await helper.getAccountsFromLogs(chain, keyringInstance, vaultState, logs, address); + + if(chain === 'stacks') { + for( let ele of accArray) { + ele.address = ele.address.toUpperCase(); + } + } const numberOfAcc = accArray.length; rawVault[chain.toLowerCase()] = { public: accArray, numberOfAccounts: numberOfAcc } From 582ad431d9f1bef7520e248d69659ebe8d997aa5 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Thu, 9 May 2024 13:08:42 +0530 Subject: [PATCH 74/98] updated stacks controller version --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index de0b58c..3db4c70 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ "@getsafle/vault-optimism-controller": "^1.0.8", "@getsafle/vault-polygon-controller": "^1.2.8", "@getsafle/vault-polygon-zkevm-controller": "^1.0.1", - "@getsafle/vault-stacks-controller": "^1.0.3", + "@getsafle/vault-stacks-controller": "^1.0.4", "@getsafle/vault-velas-controller": "^1.3.1", "bip39": "^3.0.4", "crypto-js": "^4.1.1", @@ -1972,9 +1972,9 @@ } }, "node_modules/@getsafle/vault-stacks-controller": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@getsafle/vault-stacks-controller/-/vault-stacks-controller-1.0.3.tgz", - "integrity": "sha512-QRnzQy5uPRL+55+TQSpfNM5OEcRDLWfkTKp5CEQGv4Dv9ln/PLQxfPVZwdnb7Zlo/05nAgdyHfdTzPB8nNQHhQ==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@getsafle/vault-stacks-controller/-/vault-stacks-controller-1.0.4.tgz", + "integrity": "sha512-D0A7SHk3tD8zeV6tLy2tLl95PSxlC+av2t5wsI1BL02DPGPBnpnIqwa97PPPfbLgdcikeOmSWNUufuorg1+kmg==", "dependencies": { "@stacks/connect": "^7.7.1", "@stacks/network": "^6.11.3", diff --git a/package.json b/package.json index 80495dc..a98ffee 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "@getsafle/vault-optimism-controller": "^1.0.8", "@getsafle/vault-polygon-controller": "^1.2.8", "@getsafle/vault-polygon-zkevm-controller": "^1.0.1", - "@getsafle/vault-stacks-controller": "^1.0.3", + "@getsafle/vault-stacks-controller": "^1.0.4", "@getsafle/vault-velas-controller": "^1.3.1", "bip39": "^3.0.4", "crypto-js": "^4.1.1", From d3616940e353e36a28168a8b617f3c427e6ca60c Mon Sep 17 00:00:00 2001 From: SDargarh Date: Thu, 9 May 2024 13:21:28 +0530 Subject: [PATCH 75/98] updated stacks controller version --- CHANGELOG.md | 6 +++++- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f57b89d..69ce6de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -645,4 +645,8 @@ ### 2.6.0 (2024-05-07) -* Integrated stacks chain in safle vault \ No newline at end of file +* Integrated stacks chain in safle vault + +### 2.6.1 (2024-05-09) + +* Upgraded stacks controller version \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 3db4c70..b6c0bc5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getsafle/safle-vault", - "version": "2.6.0", + "version": "2.6.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "2.6.0", + "version": "2.6.1", "license": "MIT", "dependencies": { "@getsafle/safle-identity-wallet": "^1.3.0", diff --git a/package.json b/package.json index a98ffee..fb900d2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "2.6.0", + "version": "2.6.1", "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": { From 6092ad34cf0889c8845cb1a56dc126a64c63f18c Mon Sep 17 00:00:00 2001 From: SDargarh Date: Fri, 31 May 2024 16:36:15 +0530 Subject: [PATCH 76/98] updated add account for stacks addresses --- src/lib/keyring.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lib/keyring.js b/src/lib/keyring.js index 7e284f2..7f61c16 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -254,11 +254,15 @@ class Keyring { this[this.chain] = keyringInstance; - const { address } = await this[this.chain].addAccount(); + if(this.chain === "stacks") { + newAddress = (await this[this.chain].generateWallet()).address; + } else { + const { address } = await this[this.chain].addAccount(); - newAddress = address; + newAddress = address; + } - const publicData = [ { address, isDeleted: false, isImported: false, label: `${labelPrefix} Wallet ${acc.response ? acc.response.length + 1 : 1}` } ]; + const publicData = [ { address: newAddress, isDeleted: false, isImported: false, label: `${labelPrefix} Wallet ${acc.response ? acc.response.length + 1 : 1}` } ]; this.decryptedVault[this.chain] = { public: publicData, numberOfAccounts: 1 }; } else { const { address } = await this[this.chain].addAccount(); From dc0210a3e2788f95056f29893593b43baaac6944 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Mon, 3 Jun 2024 12:13:28 +0530 Subject: [PATCH 77/98] add account and stacks controller updated --- CHANGELOG.md | 5 +++++ package-lock.json | 12 ++++++------ package.json | 4 ++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69ce6de..98ac952 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -649,4 +649,9 @@ ### 2.6.1 (2024-05-09) +* Upgraded stacks controller version + +### 2.6.2 (2024-05-31) + +* Updated add account for stacks addresses * Upgraded stacks controller version \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index b6c0bc5..25d5b27 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getsafle/safle-vault", - "version": "2.6.1", + "version": "2.6.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "2.6.1", + "version": "2.6.2", "license": "MIT", "dependencies": { "@getsafle/safle-identity-wallet": "^1.3.0", @@ -21,7 +21,7 @@ "@getsafle/vault-optimism-controller": "^1.0.8", "@getsafle/vault-polygon-controller": "^1.2.8", "@getsafle/vault-polygon-zkevm-controller": "^1.0.1", - "@getsafle/vault-stacks-controller": "^1.0.4", + "@getsafle/vault-stacks-controller": "^1.0.5", "@getsafle/vault-velas-controller": "^1.3.1", "bip39": "^3.0.4", "crypto-js": "^4.1.1", @@ -1972,9 +1972,9 @@ } }, "node_modules/@getsafle/vault-stacks-controller": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@getsafle/vault-stacks-controller/-/vault-stacks-controller-1.0.4.tgz", - "integrity": "sha512-D0A7SHk3tD8zeV6tLy2tLl95PSxlC+av2t5wsI1BL02DPGPBnpnIqwa97PPPfbLgdcikeOmSWNUufuorg1+kmg==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@getsafle/vault-stacks-controller/-/vault-stacks-controller-1.0.5.tgz", + "integrity": "sha512-U5Wd9lLIEEZcfnKdvfmZl2bfr3cMgEXAYiuXFKLnpZJTAiA7lJbExVTAP/y1OndKRM6nH594lOah/bibINfOuQ==", "dependencies": { "@stacks/connect": "^7.7.1", "@stacks/network": "^6.11.3", diff --git a/package.json b/package.json index fb900d2..03080cb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "2.6.1", + "version": "2.6.2", "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": { @@ -56,7 +56,7 @@ "@getsafle/vault-optimism-controller": "^1.0.8", "@getsafle/vault-polygon-controller": "^1.2.8", "@getsafle/vault-polygon-zkevm-controller": "^1.0.1", - "@getsafle/vault-stacks-controller": "^1.0.4", + "@getsafle/vault-stacks-controller": "^1.0.5", "@getsafle/vault-velas-controller": "^1.3.1", "bip39": "^3.0.4", "crypto-js": "^4.1.1", From 0753b53dc932da2eaacac173f8a1a051a0748402 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Thu, 25 Jul 2024 16:52:32 +0530 Subject: [PATCH 78/98] Integrated solana chain in safle vault --- CHANGELOG.md | 6 +- package-lock.json | 1948 +++++++++++++++++++++++++++++++++++-------- package.json | 3 +- src/chains/index.js | 5 +- src/lib/vault.js | 4 + 5 files changed, 1603 insertions(+), 363 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98ac952..e3853a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -654,4 +654,8 @@ ### 2.6.2 (2024-05-31) * Updated add account for stacks addresses -* Upgraded stacks controller version \ No newline at end of file +* Upgraded stacks controller version + +### 2.7.0 (2024-07-25) + +* Integrated solana chain in safle vault \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 25d5b27..7d21b60 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getsafle/safle-vault", - "version": "2.6.2", + "version": "2.7.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "2.6.2", + "version": "2.7.0", "license": "MIT", "dependencies": { "@getsafle/safle-identity-wallet": "^1.3.0", @@ -21,6 +21,7 @@ "@getsafle/vault-optimism-controller": "^1.0.8", "@getsafle/vault-polygon-controller": "^1.2.8", "@getsafle/vault-polygon-zkevm-controller": "^1.0.1", + "@getsafle/vault-sol-controller": "^1.0.1", "@getsafle/vault-stacks-controller": "^1.0.5", "@getsafle/vault-velas-controller": "^1.3.1", "bip39": "^3.0.4", @@ -201,44 +202,45 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz", - "integrity": "sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==", + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.24.7.tgz", + "integrity": "sha512-BcYH1CVJBO9tvyIZ2jVeXgSIMvGZ2FDRvDdOIVQyuklNKSsx+eppDEBq/g47Ayw+RqNFE+URvOShmf+f/qwAlA==", "dependencies": { - "@babel/highlight": "^7.18.6" + "@babel/highlight": "^7.24.7", + "picocolors": "^1.0.0" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/compat-data": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.21.0.tgz", - "integrity": "sha512-gMuZsmsgxk/ENC3O/fRw5QY8A9/uxQbbCEypnLIiYYc/qVJtEV7ouxC3EllIIwNzMqAQee5tanFabWsUOutS7g==", + "version": "7.24.9", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.24.9.tgz", + "integrity": "sha512-e701mcfApCJqMMueQI0Fb68Amflj83+dvAvHawoBpAz+GDjCIyGHzNwnefjsWJ3xiYAqqiQFoWbspGYBdb2/ng==", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/core": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.21.0.tgz", - "integrity": "sha512-PuxUbxcW6ZYe656yL3EAhpy7qXKq0DmYsrJLpbB8XrsCP9Nm+XCg9XFMb5vIDliPD7+U/+M+QJlH17XOcB7eXA==", + "version": "7.24.9", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.24.9.tgz", + "integrity": "sha512-5e3FI4Q3M3Pbr21+5xJwCv6ZT6KmGkI0vw3Tozy5ODAQFTIWe37iT8Cr7Ice2Ntb+M3iSKCEWMB1MBgKrW3whg==", "dependencies": { "@ampproject/remapping": "^2.2.0", - "@babel/code-frame": "^7.18.6", - "@babel/generator": "^7.21.0", - "@babel/helper-compilation-targets": "^7.20.7", - "@babel/helper-module-transforms": "^7.21.0", - "@babel/helpers": "^7.21.0", - "@babel/parser": "^7.21.0", - "@babel/template": "^7.20.7", - "@babel/traverse": "^7.21.0", - "@babel/types": "^7.21.0", - "convert-source-map": "^1.7.0", + "@babel/code-frame": "^7.24.7", + "@babel/generator": "^7.24.9", + "@babel/helper-compilation-targets": "^7.24.8", + "@babel/helper-module-transforms": "^7.24.9", + "@babel/helpers": "^7.24.8", + "@babel/parser": "^7.24.8", + "@babel/template": "^7.24.7", + "@babel/traverse": "^7.24.8", + "@babel/types": "^7.24.9", + "convert-source-map": "^2.0.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", - "json5": "^2.2.2", - "semver": "^6.3.0" + "json5": "^2.2.3", + "semver": "^6.3.1" }, "engines": { "node": ">=6.9.0" @@ -248,19 +250,14 @@ "url": "https://opencollective.com/babel" } }, - "node_modules/@babel/core/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==" - }, "node_modules/@babel/generator": { - "version": "7.21.1", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.21.1.tgz", - "integrity": "sha512-1lT45bAYlQhFn/BHivJs43AiW2rg3/UbLyShGfF3C0KmHvO5fSghWd5kBJy30kpRRucGzXStvnnCFniCR2kXAA==", + "version": "7.24.10", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.24.10.tgz", + "integrity": "sha512-o9HBZL1G2129luEUlG1hB4N/nlYNWHnpwlND9eOMclRqqu1YDy2sSYVCFUZwl8I1Gxh+QSRrP2vD7EpUmFVXxg==", "dependencies": { - "@babel/types": "^7.21.0", - "@jridgewell/gen-mapping": "^0.3.2", - "@jridgewell/trace-mapping": "^0.3.17", + "@babel/types": "^7.24.9", + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.25", "jsesc": "^2.5.1" }, "engines": { @@ -268,94 +265,95 @@ } }, "node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz", - "integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==", + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", + "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==", "dependencies": { - "@jridgewell/set-array": "^1.0.1", + "@jridgewell/set-array": "^1.2.1", "@jridgewell/sourcemap-codec": "^1.4.10", - "@jridgewell/trace-mapping": "^0.3.9" + "@jridgewell/trace-mapping": "^0.3.24" }, "engines": { "node": ">=6.0.0" } }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.20.7.tgz", - "integrity": "sha512-4tGORmfQcrc+bvrjb5y3dG9Mx1IOZjsHqQVUz7XCNHO+iTmqxWnVg3KRygjGmpRLJGdQSKuvFinbIb0CnZwHAQ==", + "version": "7.24.8", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.24.8.tgz", + "integrity": "sha512-oU+UoqCHdp+nWVDkpldqIQL/i/bvAv53tRqLG/s+cOXxe66zOYLU7ar/Xs3LdmBihrUMEUhwu6dMZwbNOYDwvw==", "dependencies": { - "@babel/compat-data": "^7.20.5", - "@babel/helper-validator-option": "^7.18.6", - "browserslist": "^4.21.3", + "@babel/compat-data": "^7.24.8", + "@babel/helper-validator-option": "^7.24.8", + "browserslist": "^4.23.1", "lru-cache": "^5.1.1", - "semver": "^6.3.0" + "semver": "^6.3.1" }, "engines": { "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" } }, "node_modules/@babel/helper-environment-visitor": { - "version": "7.18.9", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz", - "integrity": "sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg==", + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.24.7.tgz", + "integrity": "sha512-DoiN84+4Gnd0ncbBOM9AZENV4a5ZiL39HYMyZJGZ/AZEykHYdJw0wW3kdcsh9/Kn+BRXHLkkklZ51ecPKmI1CQ==", + "dependencies": { + "@babel/types": "^7.24.7" + }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-function-name": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.21.0.tgz", - "integrity": "sha512-HfK1aMRanKHpxemaY2gqBmL04iAPOPRj7DxtNbiDOrJK+gdwkiNRVpCpUJYbUT+aZyemKN8brqTOxzCaG6ExRg==", + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.24.7.tgz", + "integrity": "sha512-FyoJTsj/PEUWu1/TYRiXTIHc8lbw+TDYkZuoE43opPS5TrI7MyONBE1oNvfguEXAD9yhQRrVBnXdXzSLQl9XnA==", "dependencies": { - "@babel/template": "^7.20.7", - "@babel/types": "^7.21.0" + "@babel/template": "^7.24.7", + "@babel/types": "^7.24.7" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-hoist-variables": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz", - "integrity": "sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==", + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.24.7.tgz", + "integrity": "sha512-MJJwhkoGy5c4ehfoRyrJ/owKeMl19U54h27YYftT0o2teQ3FJ3nQUf/I3LlJsX4l3qlw7WRXUmiyajvHXoTubQ==", "dependencies": { - "@babel/types": "^7.18.6" + "@babel/types": "^7.24.7" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-module-imports": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.18.6.tgz", - "integrity": "sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA==", + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.24.7.tgz", + "integrity": "sha512-8AyH3C+74cgCVVXow/myrynrAGv+nTVg5vKu2nZph9x7RcRwzmh0VFallJuFTZ9mx6u4eSdXZfcOzSqTUm0HCA==", "dependencies": { - "@babel/types": "^7.18.6" + "@babel/traverse": "^7.24.7", + "@babel/types": "^7.24.7" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-module-transforms": { - "version": "7.21.2", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.21.2.tgz", - "integrity": "sha512-79yj2AR4U/Oqq/WOV7Lx6hUjau1Zfo4cI+JLAVYeMV5XIlbOhmjEk5ulbTc9fMpmlojzZHkUUxAiK+UKn+hNQQ==", + "version": "7.24.9", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.24.9.tgz", + "integrity": "sha512-oYbh+rtFKj/HwBQkFlUzvcybzklmVdVV3UU+mN7n2t/q3yGHbuVdNxyFvSBO1tfvjyArpHNcWMAzsSPdyI46hw==", "dependencies": { - "@babel/helper-environment-visitor": "^7.18.9", - "@babel/helper-module-imports": "^7.18.6", - "@babel/helper-simple-access": "^7.20.2", - "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/helper-validator-identifier": "^7.19.1", - "@babel/template": "^7.20.7", - "@babel/traverse": "^7.21.2", - "@babel/types": "^7.21.2" + "@babel/helper-environment-visitor": "^7.24.7", + "@babel/helper-module-imports": "^7.24.7", + "@babel/helper-simple-access": "^7.24.7", + "@babel/helper-split-export-declaration": "^7.24.7", + "@babel/helper-validator-identifier": "^7.24.7" }, "engines": { "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" } }, "node_modules/@babel/helper-plugin-utils": { @@ -367,72 +365,73 @@ } }, "node_modules/@babel/helper-simple-access": { - "version": "7.20.2", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.20.2.tgz", - "integrity": "sha512-+0woI/WPq59IrqDYbVGfshjT5Dmk/nnbdpcF8SnMhhXObpTq2KNBdLFRFrkVdbDOyUmHBCxzm5FHV1rACIkIbA==", + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.24.7.tgz", + "integrity": "sha512-zBAIvbCMh5Ts+b86r/CjU+4XGYIs+R1j951gxI3KmmxBMhCg4oQMsv6ZXQ64XOm/cvzfU1FmoCyt6+owc5QMYg==", "dependencies": { - "@babel/types": "^7.20.2" + "@babel/traverse": "^7.24.7", + "@babel/types": "^7.24.7" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-split-export-declaration": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz", - "integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==", + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.24.7.tgz", + "integrity": "sha512-oy5V7pD+UvfkEATUKvIjvIAH/xCzfsFVw7ygW2SI6NClZzquT+mwdTfgfdbUiceh6iQO0CHtCPsyze/MZ2YbAA==", "dependencies": { - "@babel/types": "^7.18.6" + "@babel/types": "^7.24.7" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-string-parser": { - "version": "7.19.4", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.19.4.tgz", - "integrity": "sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw==", + "version": "7.24.8", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.24.8.tgz", + "integrity": "sha512-pO9KhhRcuUyGnJWwyEgnRJTSIZHiT+vMD0kPeD+so0l7mxkMT19g3pjY9GTnHySck/hDzq+dtW/4VgnMkippsQ==", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.19.1", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", - "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.24.7.tgz", + "integrity": "sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-option": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.21.0.tgz", - "integrity": "sha512-rmL/B8/f0mKS2baE9ZpyTcTavvEuWhTTW8amjzXNvYG4AwBsqTLikfXsEofsJEfKHf+HQVQbFOHy6o+4cnC/fQ==", + "version": "7.24.8", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.24.8.tgz", + "integrity": "sha512-xb8t9tD1MHLungh/AIoWYN+gVHaB9kwlu8gffXGSt3FFEIT7RjS+xWbc2vUD1UTZdIpKj/ab3rdqJ7ufngyi2Q==", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helpers": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.21.0.tgz", - "integrity": "sha512-XXve0CBtOW0pd7MRzzmoyuSj0e3SEzj8pgyFxnTT1NJZL38BD1MK7yYrm8yefRPIDvNNe14xR4FdbHwpInD4rA==", + "version": "7.24.8", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.24.8.tgz", + "integrity": "sha512-gV2265Nkcz7weJJfvDoAEVzC1e2OTDpkGbEsebse8koXUJUXPsCMi7sRo/+SPMuMZ9MtUPnGwITTnQnU5YjyaQ==", "dependencies": { - "@babel/template": "^7.20.7", - "@babel/traverse": "^7.21.0", - "@babel/types": "^7.21.0" + "@babel/template": "^7.24.7", + "@babel/types": "^7.24.8" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/highlight": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", - "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.24.7.tgz", + "integrity": "sha512-EStJpq4OuY8xYfhGVXngigBJRWxftKX9ksiGDnmlY3o7B/V7KIAc9X4oiK87uPJSc/vs5L869bem5fhZa8caZw==", "dependencies": { - "@babel/helper-validator-identifier": "^7.18.6", - "chalk": "^2.0.0", - "js-tokens": "^4.0.0" + "@babel/helper-validator-identifier": "^7.24.7", + "chalk": "^2.4.2", + "js-tokens": "^4.0.0", + "picocolors": "^1.0.0" }, "engines": { "node": ">=6.9.0" @@ -503,9 +502,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.21.2", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.21.2.tgz", - "integrity": "sha512-URpaIJQwEkEC2T9Kn+Ai6Xe/02iNaVCuT/PtoRz3GPVJVDpPd7mLo+VddTbhCRU9TXqW5mSrQfXZyi8kDKOVpQ==", + "version": "7.24.8", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.24.8.tgz", + "integrity": "sha512-WzfbgXOkGzZiXXCqk43kKwZjzwx4oulxZi3nq2TYL9mOjQv6kYwul9mz6ID36njuL7Xkp6nJEfok848Zj10j/w==", "bin": { "parser": "bin/babel-parser.js" }, @@ -676,33 +675,44 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/runtime": { + "version": "7.24.8", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.8.tgz", + "integrity": "sha512-5F7SDGs1T72ZczbRwbGO9lQi0NLjQxzl6i4lJxLxfW9U5UluCSyEJeniWvnhl3/euNiqQVbo8zruhsDfid0esA==", + "dependencies": { + "regenerator-runtime": "^0.14.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@babel/template": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.20.7.tgz", - "integrity": "sha512-8SegXApWe6VoNw0r9JHpSteLKTpTiLZ4rMlGIm9JQ18KiCtyQiAMEazujAHrUS5flrcqYZa75ukev3P6QmUwUw==", + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.24.7.tgz", + "integrity": "sha512-jYqfPrU9JTF0PmPy1tLYHW4Mp4KlgxJD9l2nP9fD6yT/ICi554DmrWBAEYpIelzjHf1msDP3PxJIRt/nFNfBig==", "dependencies": { - "@babel/code-frame": "^7.18.6", - "@babel/parser": "^7.20.7", - "@babel/types": "^7.20.7" + "@babel/code-frame": "^7.24.7", + "@babel/parser": "^7.24.7", + "@babel/types": "^7.24.7" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.21.2", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.21.2.tgz", - "integrity": "sha512-ts5FFU/dSUPS13tv8XiEObDu9K+iagEKME9kAbaP7r0Y9KtZJZ+NGndDvWoRAYNpeWafbpFeki3q9QoMD6gxyw==", - "dependencies": { - "@babel/code-frame": "^7.18.6", - "@babel/generator": "^7.21.1", - "@babel/helper-environment-visitor": "^7.18.9", - "@babel/helper-function-name": "^7.21.0", - "@babel/helper-hoist-variables": "^7.18.6", - "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/parser": "^7.21.2", - "@babel/types": "^7.21.2", - "debug": "^4.1.0", + "version": "7.24.8", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.24.8.tgz", + "integrity": "sha512-t0P1xxAPzEDcEPmjprAQq19NWum4K0EQPjMwZQZbHt+GiZqvjCHjj755Weq1YRPVzBI+3zSfvScfpnuIecVFJQ==", + "dependencies": { + "@babel/code-frame": "^7.24.7", + "@babel/generator": "^7.24.8", + "@babel/helper-environment-visitor": "^7.24.7", + "@babel/helper-function-name": "^7.24.7", + "@babel/helper-hoist-variables": "^7.24.7", + "@babel/helper-split-export-declaration": "^7.24.7", + "@babel/parser": "^7.24.8", + "@babel/types": "^7.24.8", + "debug": "^4.3.1", "globals": "^11.1.0" }, "engines": { @@ -710,12 +720,12 @@ } }, "node_modules/@babel/types": { - "version": "7.21.2", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.21.2.tgz", - "integrity": "sha512-3wRZSs7jiFaB8AjxiiD+VqN5DTG2iRvJGQ+qYFrs/654lg6kGTQWIOFjlBo5RaXuAZjBmP3+OQH4dmhqiiyYxw==", + "version": "7.24.9", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.24.9.tgz", + "integrity": "sha512-xm8XrMKz0IlUdocVbYJe0Z9xEgidU7msskG8BbhnTPK/HZ2z/7FP7ykqPgrUH+C+r414mNfNWam1f2vqOjqjYQ==", "dependencies": { - "@babel/helper-string-parser": "^7.19.4", - "@babel/helper-validator-identifier": "^7.19.1", + "@babel/helper-string-parser": "^7.24.8", + "@babel/helper-validator-identifier": "^7.24.7", "to-fast-properties": "^2.0.0" }, "engines": { @@ -1971,206 +1981,649 @@ "safe-buffer": "^5.1.1" } }, - "node_modules/@getsafle/vault-stacks-controller": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@getsafle/vault-stacks-controller/-/vault-stacks-controller-1.0.5.tgz", - "integrity": "sha512-U5Wd9lLIEEZcfnKdvfmZl2bfr3cMgEXAYiuXFKLnpZJTAiA7lJbExVTAP/y1OndKRM6nH594lOah/bibINfOuQ==", + "node_modules/@getsafle/vault-sol-controller": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@getsafle/vault-sol-controller/-/vault-sol-controller-1.0.1.tgz", + "integrity": "sha512-owE9Ipd/eiBtrYCB7V14bl5CbeSZr2VQ6YCt411uM0CaCN023wzBecXGYS2DxVxP1KHQHCDCyq5FcPjITXpTNA==", "dependencies": { - "@stacks/connect": "^7.7.1", - "@stacks/network": "^6.11.3", - "@stacks/transactions": "^6.12.1", - "@stacks/wallet-sdk": "^6.12.1", - "axios": "^1.6.8", - "bn.js": "^5.2.1", - "mocha": "^8.1.3", - "nyc": "^15.1.0", - "obs-store": "^4.0.3" + "@solana/spl-token": "^0.4.8", + "@solana/web3.js": "^1.95.1", + "bip39": "^3.1.0", + "bs58": "^5.0.0", + "ed25519-hd-key": "^1.3.0", + "mocha": "^10.7.0", + "nyc": "^17.0.0", + "obs-store": "^4.0.3", + "tweetnacl": "^1.0.3" } }, - "node_modules/@getsafle/vault-stacks-controller/node_modules/axios": { - "version": "1.6.8", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz", - "integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==", - "dependencies": { - "follow-redirects": "^1.15.6", - "form-data": "^4.0.0", - "proxy-from-env": "^1.1.0" + "node_modules/@getsafle/vault-sol-controller/node_modules/ansi-colors": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", + "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", + "engines": { + "node": ">=6" } }, - "node_modules/@getsafle/vault-stacks-controller/node_modules/bn.js": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", - "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + "node_modules/@getsafle/vault-sol-controller/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" }, - "node_modules/@getsafle/vault-velas-controller": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@getsafle/vault-velas-controller/-/vault-velas-controller-1.3.1.tgz", - "integrity": "sha512-r6vuUOJoaDb34rpFTNQebHCVAR0pqpq4fkqN/Rk7oN3HROETFRcyhK3Z1bUAdpof5vNOrKAcsni79L5duedEYA==", + "node_modules/@getsafle/vault-sol-controller/node_modules/base-x": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/base-x/-/base-x-4.0.0.tgz", + "integrity": "sha512-FuwxlW4H5kh37X/oW59pwTzzTKRzfrrQwhmyspRM7swOEZcHtDZSCt45U6oKgtuFE+WYPblePMVIPR4RZrh/hw==" + }, + "node_modules/@getsafle/vault-sol-controller/node_modules/bip39": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bip39/-/bip39-3.1.0.tgz", + "integrity": "sha512-c9kiwdk45Do5GL0vJMe7tS95VjCii65mYAH7DfWl3uW8AVzXKQVUm64i3hzVybBDMp9r7j9iNxR85+ul8MdN/A==", "dependencies": { - "bip39": "^3.0.4", - "browser-passworder": "^2.0.3", - "crypto-js": "^4.1.1", - "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", - "obs-store": "^4.0.3", - "web3": "^1.6.0" - }, - "engines": { - "node": ">= 10" + "@noble/hashes": "^1.2.0" } }, - "node_modules/@getsafle/vault-velas-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.", + "node_modules/@getsafle/vault-sol-controller/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dependencies": { - "ethereum-common": "^0.0.18", - "ethereumjs-util": "^5.0.0" + "balanced-match": "^1.0.0" } }, - "node_modules/@getsafle/vault-velas-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==", + "node_modules/@getsafle/vault-sol-controller/node_modules/bs58": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/bs58/-/bs58-5.0.0.tgz", + "integrity": "sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ==", "dependencies": { - "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" + "base-x": "^4.0.0" } }, - "node_modules/@istanbuljs/load-nyc-config": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", - "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", + "node_modules/@getsafle/vault-sol-controller/node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", "dependencies": { - "camelcase": "^5.3.1", - "find-up": "^4.1.0", - "get-package-type": "^0.1.0", - "js-yaml": "^3.13.1", - "resolve-from": "^5.0.0" + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" }, "engines": { - "node": ">=8" + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" } }, - "node_modules/@istanbuljs/schema": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", - "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", - "engines": { - "node": ">=8" + "node_modules/@getsafle/vault-sol-controller/node_modules/cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" } }, - "node_modules/@jest/console": { - "version": "29.4.3", - "resolved": "https://registry.npmjs.org/@jest/console/-/console-29.4.3.tgz", - "integrity": "sha512-W/o/34+wQuXlgqlPYTansOSiBnuxrTv61dEVkA6HNmpcgHLUjfaUbdqt6oVvOzaawwo9IdW9QOtMgQ1ScSZC4A==", - "dependencies": { - "@jest/types": "^29.4.3", - "@types/node": "*", - "chalk": "^4.0.0", - "jest-message-util": "^29.4.3", - "jest-util": "^29.4.3", - "slash": "^3.0.0" - }, + "node_modules/@getsafle/vault-sol-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==" + }, + "node_modules/@getsafle/vault-sol-controller/node_modules/diff": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", + "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + "node": ">=0.3.1" } }, - "node_modules/@jest/core": { - "version": "29.4.3", - "resolved": "https://registry.npmjs.org/@jest/core/-/core-29.4.3.tgz", - "integrity": "sha512-56QvBq60fS4SPZCuM7T+7scNrkGIe7Mr6PVIXUpu48ouvRaWOFqRPV91eifvFM0ay2HmfswXiGf97NGUN5KofQ==", - "dependencies": { - "@jest/console": "^29.4.3", - "@jest/reporters": "^29.4.3", - "@jest/test-result": "^29.4.3", - "@jest/transform": "^29.4.3", - "@jest/types": "^29.4.3", - "@types/node": "*", - "ansi-escapes": "^4.2.1", - "chalk": "^4.0.0", - "ci-info": "^3.2.0", - "exit": "^0.1.2", - "graceful-fs": "^4.2.9", - "jest-changed-files": "^29.4.3", - "jest-config": "^29.4.3", - "jest-haste-map": "^29.4.3", - "jest-message-util": "^29.4.3", - "jest-regex-util": "^29.4.3", - "jest-resolve": "^29.4.3", - "jest-resolve-dependencies": "^29.4.3", - "jest-runner": "^29.4.3", - "jest-runtime": "^29.4.3", - "jest-snapshot": "^29.4.3", - "jest-util": "^29.4.3", - "jest-validate": "^29.4.3", - "jest-watcher": "^29.4.3", - "micromatch": "^4.0.4", - "pretty-format": "^29.4.3", - "slash": "^3.0.0", - "strip-ansi": "^6.0.0" - }, + "node_modules/@getsafle/vault-sol-controller/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" - }, - "peerDependencies": { - "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + "node": ">=10" }, - "peerDependenciesMeta": { - "node-notifier": { - "optional": true - } + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@jest/environment": { - "version": "29.4.3", - "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-29.4.3.tgz", - "integrity": "sha512-dq5S6408IxIa+lr54zeqce+QgI+CJT4nmmA+1yzFgtcsGK8c/EyiUb9XQOgz3BMKrRDfKseeOaxj2eO8LlD3lA==", + "node_modules/@getsafle/vault-sol-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==", "dependencies": { - "@jest/fake-timers": "^29.4.3", - "@jest/types": "^29.4.3", - "@types/node": "*", - "jest-mock": "^29.4.3" + "@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": "^14.15.0 || ^16.10.0 || >=18.0.0" + "node": ">=10" } }, - "node_modules/@jest/expect": { - "version": "29.4.3", - "resolved": "https://registry.npmjs.org/@jest/expect/-/expect-29.4.3.tgz", - "integrity": "sha512-iktRU/YsxEtumI9zsPctYUk7ptpC+AVLLk1Ax3AsA4g1C+8OOnKDkIQBDHtD5hA/+VtgMd5AWI5gNlcAlt2vxQ==", + "node_modules/@getsafle/vault-sol-controller/node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dependencies": { - "expect": "^29.4.3", - "jest-snapshot": "^29.4.3" + "argparse": "^2.0.1" }, - "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + "bin": { + "js-yaml": "bin/js-yaml.js" } }, - "node_modules/@jest/expect-utils": { - "version": "29.4.3", - "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.4.3.tgz", - "integrity": "sha512-/6JWbkxHOP8EoS8jeeTd9dTfc9Uawi+43oLKHfp6zzux3U2hqOOVnV3ai4RpDYHOccL6g+5nrxpoc8DmJxtXVQ==", + "node_modules/@getsafle/vault-sol-controller/node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", "dependencies": { - "jest-get-type": "^29.4.3" + "p-locate": "^5.0.0" }, "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@jest/fake-timers": { + "node_modules/@getsafle/vault-sol-controller/node_modules/log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@getsafle/vault-sol-controller/node_modules/minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@getsafle/vault-sol-controller/node_modules/mocha": { + "version": "10.7.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.7.0.tgz", + "integrity": "sha512-v8/rBWr2VO5YkspYINnvu81inSz2y3ODJrhO175/Exzor1RcEZZkizgE2A+w/CAXXoESS8Kys5E62dOHGHzULA==", + "dependencies": { + "ansi-colors": "^4.1.3", + "browser-stdout": "^1.3.1", + "chokidar": "^3.5.3", + "debug": "^4.3.5", + "diff": "^5.2.0", + "escape-string-regexp": "^4.0.0", + "find-up": "^5.0.0", + "glob": "^8.1.0", + "he": "^1.2.0", + "js-yaml": "^4.1.0", + "log-symbols": "^4.1.0", + "minimatch": "^5.1.6", + "ms": "^2.1.3", + "serialize-javascript": "^6.0.2", + "strip-json-comments": "^3.1.1", + "supports-color": "^8.1.1", + "workerpool": "^6.5.1", + "yargs": "^16.2.0", + "yargs-parser": "^20.2.9", + "yargs-unparser": "^2.0.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha.js" + }, + "engines": { + "node": ">= 14.0.0" + } + }, + "node_modules/@getsafle/vault-sol-controller/node_modules/mocha/node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@getsafle/vault-sol-controller/node_modules/mocha/node_modules/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@getsafle/vault-sol-controller/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/@getsafle/vault-sol-controller/node_modules/nyc": { + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/nyc/-/nyc-17.0.0.tgz", + "integrity": "sha512-ISp44nqNCaPugLLGGfknzQwSwt10SSS5IMoPR7GLoMAyS18Iw5js8U7ga2VF9lYuMZ42gOHr3UddZw4WZltxKg==", + "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-sol-controller/node_modules/nyc/node_modules/cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "node_modules/@getsafle/vault-sol-controller/node_modules/nyc/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==", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@getsafle/vault-sol-controller/node_modules/nyc/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==" + }, + "node_modules/@getsafle/vault-sol-controller/node_modules/nyc/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==", + "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-sol-controller/node_modules/nyc/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==", + "dependencies": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/@getsafle/vault-sol-controller/node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@getsafle/vault-sol-controller/node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/@getsafle/vault-sol-controller/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@getsafle/vault-sol-controller/node_modules/serialize-javascript": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", + "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", + "dependencies": { + "randombytes": "^2.1.0" + } + }, + "node_modules/@getsafle/vault-sol-controller/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/@getsafle/vault-sol-controller/node_modules/workerpool": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz", + "integrity": "sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==" + }, + "node_modules/@getsafle/vault-sol-controller/node_modules/yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dependencies": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@getsafle/vault-sol-controller/node_modules/yargs-parser": { + "version": "20.2.9", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", + "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", + "engines": { + "node": ">=10" + } + }, + "node_modules/@getsafle/vault-stacks-controller": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@getsafle/vault-stacks-controller/-/vault-stacks-controller-1.0.5.tgz", + "integrity": "sha512-U5Wd9lLIEEZcfnKdvfmZl2bfr3cMgEXAYiuXFKLnpZJTAiA7lJbExVTAP/y1OndKRM6nH594lOah/bibINfOuQ==", + "dependencies": { + "@stacks/connect": "^7.7.1", + "@stacks/network": "^6.11.3", + "@stacks/transactions": "^6.12.1", + "@stacks/wallet-sdk": "^6.12.1", + "axios": "^1.6.8", + "bn.js": "^5.2.1", + "mocha": "^8.1.3", + "nyc": "^15.1.0", + "obs-store": "^4.0.3" + } + }, + "node_modules/@getsafle/vault-stacks-controller/node_modules/axios": { + "version": "1.6.8", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz", + "integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/@getsafle/vault-stacks-controller/node_modules/bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + }, + "node_modules/@getsafle/vault-velas-controller": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@getsafle/vault-velas-controller/-/vault-velas-controller-1.3.1.tgz", + "integrity": "sha512-r6vuUOJoaDb34rpFTNQebHCVAR0pqpq4fkqN/Rk7oN3HROETFRcyhK3Z1bUAdpof5vNOrKAcsni79L5duedEYA==", + "dependencies": { + "bip39": "^3.0.4", + "browser-passworder": "^2.0.3", + "crypto-js": "^4.1.1", + "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", + "obs-store": "^4.0.3", + "web3": "^1.6.0" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/@getsafle/vault-velas-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": { + "ethereum-common": "^0.0.18", + "ethereumjs-util": "^5.0.0" + } + }, + "node_modules/@getsafle/vault-velas-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": { + "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/@istanbuljs/load-nyc-config": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", + "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", + "dependencies": { + "camelcase": "^5.3.1", + "find-up": "^4.1.0", + "get-package-type": "^0.1.0", + "js-yaml": "^3.13.1", + "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "engines": { + "node": ">=8" + } + }, + "node_modules/@jest/console": { + "version": "29.4.3", + "resolved": "https://registry.npmjs.org/@jest/console/-/console-29.4.3.tgz", + "integrity": "sha512-W/o/34+wQuXlgqlPYTansOSiBnuxrTv61dEVkA6HNmpcgHLUjfaUbdqt6oVvOzaawwo9IdW9QOtMgQ1ScSZC4A==", + "dependencies": { + "@jest/types": "^29.4.3", + "@types/node": "*", + "chalk": "^4.0.0", + "jest-message-util": "^29.4.3", + "jest-util": "^29.4.3", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/core": { + "version": "29.4.3", + "resolved": "https://registry.npmjs.org/@jest/core/-/core-29.4.3.tgz", + "integrity": "sha512-56QvBq60fS4SPZCuM7T+7scNrkGIe7Mr6PVIXUpu48ouvRaWOFqRPV91eifvFM0ay2HmfswXiGf97NGUN5KofQ==", + "dependencies": { + "@jest/console": "^29.4.3", + "@jest/reporters": "^29.4.3", + "@jest/test-result": "^29.4.3", + "@jest/transform": "^29.4.3", + "@jest/types": "^29.4.3", + "@types/node": "*", + "ansi-escapes": "^4.2.1", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "exit": "^0.1.2", + "graceful-fs": "^4.2.9", + "jest-changed-files": "^29.4.3", + "jest-config": "^29.4.3", + "jest-haste-map": "^29.4.3", + "jest-message-util": "^29.4.3", + "jest-regex-util": "^29.4.3", + "jest-resolve": "^29.4.3", + "jest-resolve-dependencies": "^29.4.3", + "jest-runner": "^29.4.3", + "jest-runtime": "^29.4.3", + "jest-snapshot": "^29.4.3", + "jest-util": "^29.4.3", + "jest-validate": "^29.4.3", + "jest-watcher": "^29.4.3", + "micromatch": "^4.0.4", + "pretty-format": "^29.4.3", + "slash": "^3.0.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/@jest/environment": { + "version": "29.4.3", + "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-29.4.3.tgz", + "integrity": "sha512-dq5S6408IxIa+lr54zeqce+QgI+CJT4nmmA+1yzFgtcsGK8c/EyiUb9XQOgz3BMKrRDfKseeOaxj2eO8LlD3lA==", + "dependencies": { + "@jest/fake-timers": "^29.4.3", + "@jest/types": "^29.4.3", + "@types/node": "*", + "jest-mock": "^29.4.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/expect": { + "version": "29.4.3", + "resolved": "https://registry.npmjs.org/@jest/expect/-/expect-29.4.3.tgz", + "integrity": "sha512-iktRU/YsxEtumI9zsPctYUk7ptpC+AVLLk1Ax3AsA4g1C+8OOnKDkIQBDHtD5hA/+VtgMd5AWI5gNlcAlt2vxQ==", + "dependencies": { + "expect": "^29.4.3", + "jest-snapshot": "^29.4.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/expect-utils": { + "version": "29.4.3", + "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.4.3.tgz", + "integrity": "sha512-/6JWbkxHOP8EoS8jeeTd9dTfc9Uawi+43oLKHfp6zzux3U2hqOOVnV3ai4RpDYHOccL6g+5nrxpoc8DmJxtXVQ==", + "dependencies": { + "jest-get-type": "^29.4.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/fake-timers": { "version": "29.4.3", "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-29.4.3.tgz", "integrity": "sha512-4Hote2MGcCTWSD2gwl0dwbCpBRHhE6olYEuTj8FMowdg3oQWNKr2YuxenPQYZ7+PfqPY1k98wKDU4Z+Hvd4Tiw==", @@ -2356,9 +2809,9 @@ } }, "node_modules/@jridgewell/set-array": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", - "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", + "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", "engines": { "node": ">=6.0.0" } @@ -2369,18 +2822,29 @@ "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==" }, "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.17", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.17.tgz", - "integrity": "sha512-MCNzAp77qzKca9+W/+I0+sEpaUnZoeasnghNeVc41VZCEKaCH73Vq3BZZ/SzWIgrqE4H4ceI+p+b6C0mHf9T4g==", + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@noble/curves": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.4.2.tgz", + "integrity": "sha512-TavHr8qycMChk8UwMld0ZDRvatedkzWfH8IiaeGCfymOP5i0hSCozz9vHOL0nkwk7HRMlFnAiKpS2jrUmSybcw==", "dependencies": { - "@jridgewell/resolve-uri": "3.1.0", - "@jridgewell/sourcemap-codec": "1.4.14" + "@noble/hashes": "1.4.0" + }, + "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", - "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", + "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==", "engines": { "node": ">= 16" }, @@ -2481,15 +2945,443 @@ "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-2.0.0.tgz", "integrity": "sha512-uLa0j859mMrg2slwQYdO/AkrOfmH+X6LTVmNTS9CqexuE2IvVORIkSpJLqePAbEnKJ77aMmCwr1NUZ57120Xcg==", "dependencies": { - "type-detect": "4.0.8" + "type-detect": "4.0.8" + } + }, + "node_modules/@sinonjs/fake-timers": { + "version": "10.0.2", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.0.2.tgz", + "integrity": "sha512-SwUDyjWnah1AaNl7kxsa7cfLhlTYoiyhDAIgyh+El30YvXs/o7OLXpYH88Zdhyx9JExKrmHDJ+10bwIcY80Jmw==", + "dependencies": { + "@sinonjs/commons": "^2.0.0" + } + }, + "node_modules/@solana/buffer-layout": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@solana/buffer-layout/-/buffer-layout-4.0.1.tgz", + "integrity": "sha512-E1ImOIAD1tBZFRdjeM4/pzTiTApC0AOBGwyAMS4fwIodCWArzJ3DWdoh8cKxeFM2fElkxBh2Aqts1BPC373rHA==", + "dependencies": { + "buffer": "~6.0.3" + }, + "engines": { + "node": ">=5.10" + } + }, + "node_modules/@solana/buffer-layout-utils": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@solana/buffer-layout-utils/-/buffer-layout-utils-0.2.0.tgz", + "integrity": "sha512-szG4sxgJGktbuZYDg2FfNmkMi0DYQoVjN2h7ta1W1hPrwzarcFLBq9UpX1UjNXsNpT9dn+chgprtWGioUAr4/g==", + "dependencies": { + "@solana/buffer-layout": "^4.0.0", + "@solana/web3.js": "^1.32.0", + "bigint-buffer": "^1.1.5", + "bignumber.js": "^9.0.1" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/@solana/buffer-layout/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" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/@solana/codecs": { + "version": "2.0.0-preview.4", + "resolved": "https://registry.npmjs.org/@solana/codecs/-/codecs-2.0.0-preview.4.tgz", + "integrity": "sha512-gLMupqI4i+G4uPi2SGF/Tc1aXcviZF2ybC81x7Q/fARamNSgNOCUUoSCg9nWu1Gid6+UhA7LH80sWI8XjKaRog==", + "dependencies": { + "@solana/codecs-core": "2.0.0-preview.4", + "@solana/codecs-data-structures": "2.0.0-preview.4", + "@solana/codecs-numbers": "2.0.0-preview.4", + "@solana/codecs-strings": "2.0.0-preview.4", + "@solana/options": "2.0.0-preview.4" + }, + "peerDependencies": { + "typescript": ">=5" + } + }, + "node_modules/@solana/codecs-core": { + "version": "2.0.0-preview.4", + "resolved": "https://registry.npmjs.org/@solana/codecs-core/-/codecs-core-2.0.0-preview.4.tgz", + "integrity": "sha512-A0VVuDDA5kNKZUinOqHxJQK32aKTucaVbvn31YenGzHX1gPqq+SOnFwgaEY6pq4XEopSmaK16w938ZQS8IvCnw==", + "dependencies": { + "@solana/errors": "2.0.0-preview.4" + }, + "peerDependencies": { + "typescript": ">=5" + } + }, + "node_modules/@solana/codecs-data-structures": { + "version": "2.0.0-preview.4", + "resolved": "https://registry.npmjs.org/@solana/codecs-data-structures/-/codecs-data-structures-2.0.0-preview.4.tgz", + "integrity": "sha512-nt2k2eTeyzlI/ccutPcG36M/J8NAYfxBPI9h/nQjgJ+M+IgOKi31JV8StDDlG/1XvY0zyqugV3I0r3KAbZRJpA==", + "dependencies": { + "@solana/codecs-core": "2.0.0-preview.4", + "@solana/codecs-numbers": "2.0.0-preview.4", + "@solana/errors": "2.0.0-preview.4" + }, + "peerDependencies": { + "typescript": ">=5" + } + }, + "node_modules/@solana/codecs-numbers": { + "version": "2.0.0-preview.4", + "resolved": "https://registry.npmjs.org/@solana/codecs-numbers/-/codecs-numbers-2.0.0-preview.4.tgz", + "integrity": "sha512-Q061rLtMadsO7uxpguT+Z7G4UHnjQ6moVIxAQxR58nLxDPCC7MB1Pk106/Z7NDhDLHTcd18uO6DZ7ajHZEn2XQ==", + "dependencies": { + "@solana/codecs-core": "2.0.0-preview.4", + "@solana/errors": "2.0.0-preview.4" + }, + "peerDependencies": { + "typescript": ">=5" + } + }, + "node_modules/@solana/codecs-strings": { + "version": "2.0.0-preview.4", + "resolved": "https://registry.npmjs.org/@solana/codecs-strings/-/codecs-strings-2.0.0-preview.4.tgz", + "integrity": "sha512-YDbsQePRWm+xnrfS64losSGRg8Wb76cjK1K6qfR8LPmdwIC3787x9uW5/E4icl/k+9nwgbIRXZ65lpF+ucZUnw==", + "dependencies": { + "@solana/codecs-core": "2.0.0-preview.4", + "@solana/codecs-numbers": "2.0.0-preview.4", + "@solana/errors": "2.0.0-preview.4" + }, + "peerDependencies": { + "fastestsmallesttextencoderdecoder": "^1.0.22", + "typescript": ">=5" + } + }, + "node_modules/@solana/errors": { + "version": "2.0.0-preview.4", + "resolved": "https://registry.npmjs.org/@solana/errors/-/errors-2.0.0-preview.4.tgz", + "integrity": "sha512-kadtlbRv2LCWr8A9V22On15Us7Nn8BvqNaOB4hXsTB3O0fU40D1ru2l+cReqLcRPij4znqlRzW9Xi0m6J5DIhA==", + "dependencies": { + "chalk": "^5.3.0", + "commander": "^12.1.0" + }, + "bin": { + "errors": "bin/cli.mjs" + }, + "peerDependencies": { + "typescript": ">=5" + } + }, + "node_modules/@solana/errors/node_modules/chalk": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", + "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/@solana/errors/node_modules/commander": { + "version": "12.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz", + "integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==", + "engines": { + "node": ">=18" + } + }, + "node_modules/@solana/options": { + "version": "2.0.0-preview.4", + "resolved": "https://registry.npmjs.org/@solana/options/-/options-2.0.0-preview.4.tgz", + "integrity": "sha512-tv2O/Frxql/wSe3jbzi5nVicIWIus/BftH+5ZR+r9r3FO0/htEllZS5Q9XdbmSboHu+St87584JXeDx3xm4jaA==", + "dependencies": { + "@solana/codecs-core": "2.0.0-preview.4", + "@solana/codecs-data-structures": "2.0.0-preview.4", + "@solana/codecs-numbers": "2.0.0-preview.4", + "@solana/codecs-strings": "2.0.0-preview.4", + "@solana/errors": "2.0.0-preview.4" + }, + "peerDependencies": { + "typescript": ">=5" + } + }, + "node_modules/@solana/spl-token": { + "version": "0.4.8", + "resolved": "https://registry.npmjs.org/@solana/spl-token/-/spl-token-0.4.8.tgz", + "integrity": "sha512-RO0JD9vPRi4LsAbMUdNbDJ5/cv2z11MGhtAvFeRzT4+hAGE/FUzRi0tkkWtuCfSIU3twC6CtmAihRp/+XXjWsA==", + "dependencies": { + "@solana/buffer-layout": "^4.0.0", + "@solana/buffer-layout-utils": "^0.2.0", + "@solana/spl-token-group": "^0.0.5", + "@solana/spl-token-metadata": "^0.1.3", + "buffer": "^6.0.3" + }, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "@solana/web3.js": "^1.94.0" + } + }, + "node_modules/@solana/spl-token-group": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/@solana/spl-token-group/-/spl-token-group-0.0.5.tgz", + "integrity": "sha512-CLJnWEcdoUBpQJfx9WEbX3h6nTdNiUzswfFdkABUik7HVwSNA98u5AYvBVK2H93d9PGMOHAak2lHW9xr+zAJGQ==", + "dependencies": { + "@solana/codecs": "2.0.0-preview.4", + "@solana/spl-type-length-value": "0.1.0" + }, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "@solana/web3.js": "^1.94.0" + } + }, + "node_modules/@solana/spl-token-metadata": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/@solana/spl-token-metadata/-/spl-token-metadata-0.1.4.tgz", + "integrity": "sha512-N3gZ8DlW6NWDV28+vCCDJoTqaCZiF/jDUnk3o8GRkAFzHObiR60Bs1gXHBa8zCPdvOwiG6Z3dg5pg7+RW6XNsQ==", + "dependencies": { + "@solana/codecs": "2.0.0-preview.2", + "@solana/spl-type-length-value": "0.1.0" + }, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "@solana/web3.js": "^1.91.6" + } + }, + "node_modules/@solana/spl-token-metadata/node_modules/@solana/codecs": { + "version": "2.0.0-preview.2", + "resolved": "https://registry.npmjs.org/@solana/codecs/-/codecs-2.0.0-preview.2.tgz", + "integrity": "sha512-4HHzCD5+pOSmSB71X6w9ptweV48Zj1Vqhe732+pcAQ2cMNnN0gMPMdDq7j3YwaZDZ7yrILVV/3+HTnfT77t2yA==", + "dependencies": { + "@solana/codecs-core": "2.0.0-preview.2", + "@solana/codecs-data-structures": "2.0.0-preview.2", + "@solana/codecs-numbers": "2.0.0-preview.2", + "@solana/codecs-strings": "2.0.0-preview.2", + "@solana/options": "2.0.0-preview.2" + } + }, + "node_modules/@solana/spl-token-metadata/node_modules/@solana/codecs-core": { + "version": "2.0.0-preview.2", + "resolved": "https://registry.npmjs.org/@solana/codecs-core/-/codecs-core-2.0.0-preview.2.tgz", + "integrity": "sha512-gLhCJXieSCrAU7acUJjbXl+IbGnqovvxQLlimztPoGgfLQ1wFYu+XJswrEVQqknZYK1pgxpxH3rZ+OKFs0ndQg==", + "dependencies": { + "@solana/errors": "2.0.0-preview.2" + } + }, + "node_modules/@solana/spl-token-metadata/node_modules/@solana/codecs-data-structures": { + "version": "2.0.0-preview.2", + "resolved": "https://registry.npmjs.org/@solana/codecs-data-structures/-/codecs-data-structures-2.0.0-preview.2.tgz", + "integrity": "sha512-Xf5vIfromOZo94Q8HbR04TbgTwzigqrKII0GjYr21K7rb3nba4hUW2ir8kguY7HWFBcjHGlU5x3MevKBOLp3Zg==", + "dependencies": { + "@solana/codecs-core": "2.0.0-preview.2", + "@solana/codecs-numbers": "2.0.0-preview.2", + "@solana/errors": "2.0.0-preview.2" + } + }, + "node_modules/@solana/spl-token-metadata/node_modules/@solana/codecs-numbers": { + "version": "2.0.0-preview.2", + "resolved": "https://registry.npmjs.org/@solana/codecs-numbers/-/codecs-numbers-2.0.0-preview.2.tgz", + "integrity": "sha512-aLZnDTf43z4qOnpTcDsUVy1Ci9im1Md8thWipSWbE+WM9ojZAx528oAql+Cv8M8N+6ALKwgVRhPZkto6E59ARw==", + "dependencies": { + "@solana/codecs-core": "2.0.0-preview.2", + "@solana/errors": "2.0.0-preview.2" + } + }, + "node_modules/@solana/spl-token-metadata/node_modules/@solana/codecs-strings": { + "version": "2.0.0-preview.2", + "resolved": "https://registry.npmjs.org/@solana/codecs-strings/-/codecs-strings-2.0.0-preview.2.tgz", + "integrity": "sha512-EgBwY+lIaHHgMJIqVOGHfIfpdmmUDNoNO/GAUGeFPf+q0dF+DtwhJPEMShhzh64X2MeCZcmSO6Kinx0Bvmmz2g==", + "dependencies": { + "@solana/codecs-core": "2.0.0-preview.2", + "@solana/codecs-numbers": "2.0.0-preview.2", + "@solana/errors": "2.0.0-preview.2" + }, + "peerDependencies": { + "fastestsmallesttextencoderdecoder": "^1.0.22" + } + }, + "node_modules/@solana/spl-token-metadata/node_modules/@solana/errors": { + "version": "2.0.0-preview.2", + "resolved": "https://registry.npmjs.org/@solana/errors/-/errors-2.0.0-preview.2.tgz", + "integrity": "sha512-H2DZ1l3iYF5Rp5pPbJpmmtCauWeQXRJapkDg8epQ8BJ7cA2Ut/QEtC3CMmw/iMTcuS6uemFNLcWvlOfoQhvQuA==", + "dependencies": { + "chalk": "^5.3.0", + "commander": "^12.0.0" + }, + "bin": { + "errors": "bin/cli.js" + } + }, + "node_modules/@solana/spl-token-metadata/node_modules/@solana/options": { + "version": "2.0.0-preview.2", + "resolved": "https://registry.npmjs.org/@solana/options/-/options-2.0.0-preview.2.tgz", + "integrity": "sha512-FAHqEeH0cVsUOTzjl5OfUBw2cyT8d5Oekx4xcn5hn+NyPAfQJgM3CEThzgRD6Q/4mM5pVUnND3oK/Mt1RzSE/w==", + "dependencies": { + "@solana/codecs-core": "2.0.0-preview.2", + "@solana/codecs-numbers": "2.0.0-preview.2" + } + }, + "node_modules/@solana/spl-token-metadata/node_modules/chalk": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", + "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/@solana/spl-token-metadata/node_modules/commander": { + "version": "12.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz", + "integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==", + "engines": { + "node": ">=18" + } + }, + "node_modules/@solana/spl-token/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" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/@solana/spl-type-length-value": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@solana/spl-type-length-value/-/spl-type-length-value-0.1.0.tgz", + "integrity": "sha512-JBMGB0oR4lPttOZ5XiUGyvylwLQjt1CPJa6qQ5oM+MBCndfjz2TKKkw0eATlLLcYmq1jBVsNlJ2cD6ns2GR7lA==", + "dependencies": { + "buffer": "^6.0.3" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/@solana/spl-type-length-value/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" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/@solana/web3.js": { + "version": "1.95.1", + "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.95.1.tgz", + "integrity": "sha512-mRX/AjV6QbiOXpWcy5Rz1ZWEH2lVkwO7T0pcv9t97ACpv3/i3tPiqXwk0JIZgSR3wOSTiT26JfygnJH2ulS6dQ==", + "dependencies": { + "@babel/runtime": "^7.24.8", + "@noble/curves": "^1.4.2", + "@noble/hashes": "^1.4.0", + "@solana/buffer-layout": "^4.0.1", + "agentkeepalive": "^4.5.0", + "bigint-buffer": "^1.1.5", + "bn.js": "^5.2.1", + "borsh": "^0.7.0", + "bs58": "^4.0.1", + "buffer": "6.0.3", + "fast-stable-stringify": "^1.0.0", + "jayson": "^4.1.1", + "node-fetch": "^2.7.0", + "rpc-websockets": "^9.0.2", + "superstruct": "^2.0.2" + } + }, + "node_modules/@solana/web3.js/node_modules/bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + }, + "node_modules/@solana/web3.js/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" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" } }, - "node_modules/@sinonjs/fake-timers": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.0.2.tgz", - "integrity": "sha512-SwUDyjWnah1AaNl7kxsa7cfLhlTYoiyhDAIgyh+El30YvXs/o7OLXpYH88Zdhyx9JExKrmHDJ+10bwIcY80Jmw==", + "node_modules/@solana/web3.js/node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", "dependencies": { - "@sinonjs/commons": "^2.0.0" + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } } }, "node_modules/@stacks/auth": { @@ -2698,6 +3590,14 @@ "npm": ">=6.0.0" } }, + "node_modules/@swc/helpers": { + "version": "0.5.12", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.12.tgz", + "integrity": "sha512-KMZNXiGibsW9kvZAO1Pam2JPTDBm+KSHMMHWdsyI/1DbIZjT2A6Gy3hblVXUMEDvUAKq+e0vL0X0o54owWji7g==", + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/@szmarczak/http-timer": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-5.0.1.tgz", @@ -2765,6 +3665,14 @@ "@types/responselike": "^1.0.0" } }, + "node_modules/@types/connect": { + "version": "3.4.38", + "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz", + "integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/graceful-fs": { "version": "4.1.6", "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.6.tgz", @@ -2849,6 +3757,19 @@ "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz", "integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==" }, + "node_modules/@types/uuid": { + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz", + "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==" + }, + "node_modules/@types/ws": { + "version": "7.4.7", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.4.7.tgz", + "integrity": "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/yargs": { "version": "17.0.22", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.22.tgz", @@ -2898,6 +3819,17 @@ "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz", "integrity": "sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==" }, + "node_modules/agentkeepalive": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.5.0.tgz", + "integrity": "sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==", + "dependencies": { + "humanize-ms": "^1.2.1" + }, + "engines": { + "node": ">= 8.0.0" + } + }, "node_modules/aggregate-error": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", @@ -3337,6 +4269,18 @@ "resolved": "https://registry.npmjs.org/bigi/-/bigi-1.4.2.tgz", "integrity": "sha512-ddkU+dFIuEIW8lE7ZwdIAf2UPoM90eaprg5m3YXAVVTmKlqV/9BX4A2M8BOK2yOq6/VgZFVhK6QAxJebhlbhzw==" }, + "node_modules/bigint-buffer": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/bigint-buffer/-/bigint-buffer-1.1.5.tgz", + "integrity": "sha512-trfYco6AoZ+rKhKnxA0hgX0HAbVP/s808/EuDSe2JDzUnCp/xAsli35Orvk67UrTEcwuxZqYZDmfA2RXJgxVvA==", + "hasInstallScript": true, + "dependencies": { + "bindings": "^1.3.0" + }, + "engines": { + "node": ">= 10.0.0" + } + }, "node_modules/bignumber.js": { "version": "9.1.1", "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.1.tgz", @@ -3579,6 +4523,21 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, + "node_modules/borsh": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/borsh/-/borsh-0.7.0.tgz", + "integrity": "sha512-CLCsZGIBCFnPtkNnieW/a8wmreDmfUtjU2m9yHrzPXIlNbqVs0AQrSatSG6vdNYUqdc83tkQi2eHfF98ubzQLA==", + "dependencies": { + "bn.js": "^5.2.0", + "bs58": "^4.0.0", + "text-encoding-utf-8": "^1.0.2" + } + }, + "node_modules/borsh/node_modules/bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -3695,9 +4654,9 @@ "integrity": "sha1-WmuPD3BM44jTkn30czfiWDD3Hdo=" }, "node_modules/browserslist": { - "version": "4.21.5", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.5.tgz", - "integrity": "sha512-tUkiguQGW7S3IhB7N+c2MV/HZPSCPAAiYBZXLsBhFB/PCy6ZKKsZrmBayHV9fdGV/ARIfJ14NkxKzRDjvp7L6w==", + "version": "4.23.2", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.2.tgz", + "integrity": "sha512-qkqSyistMYdxAcw+CzbZwlBy8AGmS/eEWs+sEV5TnLRGDOL+C5M2EnH6tlZyg0YoAxGJAFKh61En9BR941GnHA==", "funding": [ { "type": "opencollective", @@ -3706,13 +4665,17 @@ { "type": "tidelift", "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" } ], "dependencies": { - "caniuse-lite": "^1.0.30001449", - "electron-to-chromium": "^1.4.284", - "node-releases": "^2.0.8", - "update-browserslist-db": "^1.0.10" + "caniuse-lite": "^1.0.30001640", + "electron-to-chromium": "^1.4.820", + "node-releases": "^2.0.14", + "update-browserslist-db": "^1.1.0" }, "bin": { "browserslist": "cli.js" @@ -3933,9 +4896,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001458", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001458.tgz", - "integrity": "sha512-lQ1VlUUq5q9ro9X+5gOEyH7i3vm+AYVT1WDCVB69XOZ17KZRhnZ9J0Sqz7wTHQaLBJccNCHq8/Ww5LlOIZbB0w==", + "version": "1.0.30001643", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001643.tgz", + "integrity": "sha512-ERgWGNleEilSrHM6iUz/zJNSQTP8Mr21wDWpdgvRwcTXGAq6jMtOUPP4dqFPTdKqZ2wKTdtB+uucZ3MRpAUSmg==", "funding": [ { "type": "opencollective", @@ -3944,6 +4907,10 @@ { "type": "tidelift", "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" } ] }, @@ -4334,9 +5301,9 @@ } }, "node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", + "integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==", "dependencies": { "ms": "2.1.2" }, @@ -4454,6 +5421,17 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/delay": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/delay/-/delay-5.0.0.tgz", + "integrity": "sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -4558,15 +5536,24 @@ "safe-buffer": "^5.0.1" } }, + "node_modules/ed25519-hd-key": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/ed25519-hd-key/-/ed25519-hd-key-1.3.0.tgz", + "integrity": "sha512-IWwAyiiuJQhgu3L8NaHb68eJxTu2pgCwxIBdgpLJdKpYZM46+AXePSVTr7fkNKaUOfOL4IrjEUaQvyVRIDP7fg==", + "dependencies": { + "create-hmac": "1.1.7", + "tweetnacl": "1.0.3" + } + }, "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/electron-to-chromium": { - "version": "1.4.313", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.313.tgz", - "integrity": "sha512-QckB9OVqr2oybjIrbMI99uF+b9+iTja5weFe0ePbqLb5BHqXOJUO1SG6kDj/1WtWPRIBr51N153AEq8m7HuIaA==" + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.1.tgz", + "integrity": "sha512-FKbOCOQ5QRB3VlIbl1LZQefWIYwszlBloaXcY2rbfpu9ioJnNh3TK03YtIDKDo3WKBi8u+YV4+Fn2CkEozgf4w==" }, "node_modules/elliptic": { "version": "6.5.4", @@ -4661,6 +5648,14 @@ "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" }, + "node_modules/es6-promisify": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", + "integrity": "sha512-C+d6UdsYDk0lMebHNR4S2NybQMMngAOnOwYBQjTOiv0MkoJMP0Myw2mgpDLBcpfCmRLxyFqYhS/CfOENq4SJhQ==", + "dependencies": { + "es6-promise": "^4.0.3" + } + }, "node_modules/es6-symbol": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", @@ -4671,9 +5666,9 @@ } }, "node_modules/escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", + "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", "engines": { "node": ">=6" } @@ -5227,6 +6222,14 @@ "node >=0.6.0" ] }, + "node_modules/eyes": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz", + "integrity": "sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ==", + "engines": { + "node": "> 0.1.90" + } + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -5237,6 +6240,17 @@ "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" }, + "node_modules/fast-stable-stringify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fast-stable-stringify/-/fast-stable-stringify-1.0.0.tgz", + "integrity": "sha512-wpYMUmFu5f00Sm0cj2pfivpmawLZ0NKdviQ4w9zJeR8JVtOpOxHmLaJuj0vxvGqMJQWyP/COUkF75/57OKyRag==" + }, + "node_modules/fastestsmallesttextencoderdecoder": { + "version": "1.0.22", + "resolved": "https://registry.npmjs.org/fastestsmallesttextencoderdecoder/-/fastestsmallesttextencoderdecoder-1.0.22.tgz", + "integrity": "sha512-Pb8d48e+oIuY4MaM64Cd7OW1gt4nxCHs7/ddPPZ/Ic3sg8yVGM7O9wDvZ7us6ScaUupzM+pfBolwtYhN1IxBIw==", + "peer": true + }, "node_modules/fb-watchman": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.2.tgz", @@ -5868,6 +6882,14 @@ "node": ">=10.17.0" } }, + "node_modules/humanize-ms": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", + "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==", + "dependencies": { + "ms": "^2.0.0" + } + }, "node_modules/iced-error": { "version": "0.0.13", "resolved": "https://registry.npmjs.org/iced-error/-/iced-error-0.0.13.tgz", @@ -6172,6 +7194,17 @@ "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==" }, + "node_modules/is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-windows": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", @@ -6299,6 +7332,72 @@ "node": ">=8" } }, + "node_modules/jayson": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/jayson/-/jayson-4.1.1.tgz", + "integrity": "sha512-5ZWm4Q/0DHPyeMfAsrwViwUS2DMVsQgWh8bEEIVTkfb3DzHZ2L3G5WUnF+AKmGjjM9r1uAv73SaqC1/U4RL45w==", + "dependencies": { + "@types/connect": "^3.4.33", + "@types/node": "^12.12.54", + "@types/ws": "^7.4.4", + "commander": "^2.20.3", + "delay": "^5.0.0", + "es6-promisify": "^5.0.0", + "eyes": "^0.1.8", + "isomorphic-ws": "^4.0.1", + "json-stringify-safe": "^5.0.1", + "JSONStream": "^1.3.5", + "uuid": "^8.3.2", + "ws": "^7.5.10" + }, + "bin": { + "jayson": "bin/jayson.js" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/jayson/node_modules/@types/node": { + "version": "12.20.55", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.55.tgz", + "integrity": "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==" + }, + "node_modules/jayson/node_modules/isomorphic-ws": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz", + "integrity": "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==", + "peerDependencies": { + "ws": "*" + } + }, + "node_modules/jayson/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/jayson/node_modules/ws": { + "version": "7.5.10", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", + "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", + "engines": { + "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/jest": { "version": "29.4.3", "resolved": "https://registry.npmjs.org/jest/-/jest-29.4.3.tgz", @@ -6946,6 +8045,29 @@ "graceful-fs": "^4.1.6" } }, + "node_modules/jsonparse": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", + "integrity": "sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==", + "engines": [ + "node >= 0.2.0" + ] + }, + "node_modules/JSONStream": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", + "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", + "dependencies": { + "jsonparse": "^1.2.0", + "through": ">=2.2.7 <3" + }, + "bin": { + "JSONStream": "bin.js" + }, + "engines": { + "node": "*" + } + }, "node_modules/jsontokens": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/jsontokens/-/jsontokens-4.0.1.tgz", @@ -7644,25 +8766,6 @@ } } }, - "node_modules/node-fetch/node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" - }, - "node_modules/node-fetch/node_modules/webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" - }, - "node_modules/node-fetch/node_modules/whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "dependencies": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - }, "node_modules/node-gyp-build": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.2.3.tgz", @@ -7690,9 +8793,9 @@ } }, "node_modules/node-releases": { - "version": "2.0.10", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.10.tgz", - "integrity": "sha512-5GFldHPXVG/YZmFzJvKK2zDSzPKhEp0+ZR5SVaoSag9fsL5YgHbUHDfnG5494ISANDcK4KwPXAx2xqVEydmd7w==" + "version": "2.0.18", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.18.tgz", + "integrity": "sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g==" }, "node_modules/normalize-path": { "version": "3.0.0", @@ -8165,9 +9268,9 @@ "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==" }, "node_modules/picocolors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.1.tgz", + "integrity": "sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==" }, "node_modules/picomatch": { "version": "2.3.1", @@ -8444,6 +9547,11 @@ "node": ">=8.10.0" } }, + "node_modules/regenerator-runtime": { + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", + "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==" + }, "node_modules/release-zalgo": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/release-zalgo/-/release-zalgo-1.0.0.tgz", @@ -8641,6 +9749,72 @@ "rlp": "bin/rlp" } }, + "node_modules/rpc-websockets": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/rpc-websockets/-/rpc-websockets-9.0.2.tgz", + "integrity": "sha512-YzggvfItxMY3Lwuax5rC18inhbjJv9Py7JXRHxTIi94JOLrqBsSsUUc5bbl5W6c11tXhdfpDPK0KzBhoGe8jjw==", + "dependencies": { + "@swc/helpers": "^0.5.11", + "@types/uuid": "^8.3.4", + "@types/ws": "^8.2.2", + "buffer": "^6.0.3", + "eventemitter3": "^5.0.1", + "uuid": "^8.3.2", + "ws": "^8.5.0" + }, + "funding": { + "type": "paypal", + "url": "https://paypal.me/kozjak" + }, + "optionalDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + } + }, + "node_modules/rpc-websockets/node_modules/@types/ws": { + "version": "8.5.11", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.11.tgz", + "integrity": "sha512-4+q7P5h3SpJxaBft0Dzpbr6lmMaqh0Jr2tbhJZ/luAwvD7ohSCniYkwz/pLxuT2h0EOa6QADgJj1Ko+TzRfZ+w==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/rpc-websockets/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" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/rpc-websockets/node_modules/eventemitter3": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", + "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==" + }, + "node_modules/rpc-websockets/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -8710,9 +9884,9 @@ } }, "node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "bin": { "semver": "bin/semver.js" } @@ -9103,6 +10277,14 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/superstruct": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-2.0.2.tgz", + "integrity": "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A==", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -9255,6 +10437,16 @@ "node": ">=8" } }, + "node_modules/text-encoding-utf-8": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz", + "integrity": "sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg==" + }, + "node_modules/through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==" + }, "node_modules/through2": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", @@ -9347,6 +10539,11 @@ "node": ">=0.6" } }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, "node_modules/triplesec": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/triplesec/-/triplesec-4.0.3.tgz", @@ -9435,6 +10632,19 @@ "resolved": "https://registry.npmjs.org/typeforce/-/typeforce-1.18.0.tgz", "integrity": "sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g==" }, + "node_modules/typescript": { + "version": "5.5.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", + "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", + "peer": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/uglify-js": { "version": "3.17.4", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.4.tgz", @@ -9473,9 +10683,9 @@ } }, "node_modules/update-browserslist-db": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.10.tgz", - "integrity": "sha512-OztqDenkfFkbSG+tRxBeAnCVPckDBcvibKd35yDONx6OU8N7sqgwc7rCbkJ/WcYtVRZ4ba68d6byhC21GFh7sQ==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.0.tgz", + "integrity": "sha512-EdRAaAyk2cUE1wOf2DkEhzxqOQvFOoRJFNS6NeyJ01Gp2beMRpBAINjM2iDXE3KCuKhwnvHIQCJm6ThL2Z+HzQ==", "funding": [ { "type": "opencollective", @@ -9484,14 +10694,18 @@ { "type": "tidelift", "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" } ], "dependencies": { - "escalade": "^3.1.1", - "picocolors": "^1.0.0" + "escalade": "^3.1.2", + "picocolors": "^1.0.1" }, "bin": { - "browserslist-lint": "cli.js" + "update-browserslist-db": "cli.js" }, "peerDependencies": { "browserslist": ">= 4.21.0" @@ -10002,6 +11216,11 @@ "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, "node_modules/websocket": { "version": "1.0.34", "resolved": "https://registry.npmjs.org/websocket/-/websocket-1.0.34.tgz", @@ -10031,6 +11250,15 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/package.json b/package.json index 03080cb..b146ca7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "2.6.2", + "version": "2.7.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": { @@ -56,6 +56,7 @@ "@getsafle/vault-optimism-controller": "^1.0.8", "@getsafle/vault-polygon-controller": "^1.2.8", "@getsafle/vault-polygon-zkevm-controller": "^1.0.1", + "@getsafle/vault-sol-controller": "^1.0.1", "@getsafle/vault-stacks-controller": "^1.0.5", "@getsafle/vault-velas-controller": "^1.3.1", "bip39": "^3.0.4", diff --git a/src/chains/index.js b/src/chains/index.js index b1e6428..9fe67bb 100644 --- a/src/chains/index.js +++ b/src/chains/index.js @@ -10,9 +10,11 @@ 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 evmChains = { 'ethereum': 'ETH', 'bsc': 'BSC', 'polygon': 'MATIC', 'optimism': 'OP' ,'arbitrum': 'ARB', 'mantle': 'MNT', 'velas': 'VLX' , 'avalanche': 'AVAX', 'base':'BASE', 'zkEVM': 'ZKEVM'}; -const nonEvmChains = { 'bitcoin': 'BTC', 'stacks': 'STX' }; +const nonEvmChains = { 'bitcoin': 'BTC', 'stacks': 'STX', 'solana': 'SOL' }; module.exports = { ethereum, @@ -27,6 +29,7 @@ module.exports = { base, zkEVM, stacks, + solana, evmChains, nonEvmChains, } \ No newline at end of file diff --git a/src/lib/vault.js b/src/lib/vault.js index 8f4cc6c..8ab213e 100644 --- a/src/lib/vault.js +++ b/src/lib/vault.js @@ -2,6 +2,7 @@ const CryptoJS = require('crypto-js'); const { KeyringController } = require('@getsafle/vault-eth-controller'); const BitcoinKeyringController= require('@getsafle/vault-bitcoin-controller').KeyringController ; const StacksKeyringController = require('@getsafle/vault-stacks-controller').KeyringController; +const SolanaKeyringController = require('@getsafle/vault-sol-controller').KeyringController; const bip39 = require('bip39'); const helper = require('../utils/helper'); @@ -57,6 +58,9 @@ class Vault extends Keyring { const stacksKeyringController = new StacksKeyringController({mnemonic:mnemonic}); this["stacks"] = stacksKeyringController; + + const solanaKeyringController = new SolanaKeyringController({mnemonic:mnemonic}); + this["solana"] = solanaKeyringController; } async generateMnemonic(entropy) { From fe1645218570571971cf410f1e8bd9aae15f0958 Mon Sep 17 00:00:00 2001 From: SDargarh Date: Thu, 25 Jul 2024 16:59:12 +0530 Subject: [PATCH 79/98] Updated test cases --- CHANGELOG.md | 3 ++- src/lib/test/keyring.test.js | 1 + src/lib/test/vault.test.js | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3853a0..67ebb3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -658,4 +658,5 @@ ### 2.7.0 (2024-07-25) -* Integrated solana chain in safle vault \ No newline at end of file +* Integrated solana chain in safle vault +* Updated test cases \ No newline at end of file diff --git a/src/lib/test/keyring.test.js b/src/lib/test/keyring.test.js index 91d97c9..1ce23b4 100644 --- a/src/lib/test/keyring.test.js +++ b/src/lib/test/keyring.test.js @@ -288,6 +288,7 @@ describe('getActiveChains',()=>{ response: [ { chain: 'bitcoin', symbol: 'BTC' }, { chain: 'stacks', symbol: 'STX' }, + { chain: 'solana', symbol: 'SOL' }, { chain: 'ethereum', symbol: 'ETH' }, { chain: 'bsc', symbol: 'BSC' }, { chain: 'polygon', symbol: 'MATIC' }, diff --git a/src/lib/test/vault.test.js b/src/lib/test/vault.test.js index c90bda7..e4aaa4d 100644 --- a/src/lib/test/vault.test.js +++ b/src/lib/test/vault.test.js @@ -79,7 +79,7 @@ describe('getSupportedChains' , ()=>{ let result = await new Vault({}).getSupportedChains() expect({ evmChains: { ethereum: 'ETH', bsc: 'BSC', polygon: 'MATIC', optimism: 'OP', arbitrum: 'ARB', mantle: 'MNT', velas: 'VLX', avalanche: 'AVAX', base:'BASE', zkEVM: 'ZKEVM'}, - nonEvmChains: { bitcoin: 'BTC', stacks: 'STX' } + nonEvmChains: { bitcoin: 'BTC', stacks: 'STX', solana: 'SOL' } }).toMatchObject(result.response) }) From 6ef977e3bf39cbdbd2a62af9311b70006f3be262 Mon Sep 17 00:00:00 2001 From: Shubham Singhal Date: Thu, 8 Aug 2024 11:05:05 +0530 Subject: [PATCH 80/98] Added BEVM controller --- CHANGELOG.md | 6 +- package-lock.json | 283 ++++++++++++++++++++++++++++++++++++++++---- package.json | 3 +- src/chains/index.js | 4 +- 4 files changed, 271 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67ebb3a..60e8636 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -659,4 +659,8 @@ ### 2.7.0 (2024-07-25) * Integrated solana chain in safle vault -* Updated test cases \ No newline at end of file +* Updated test cases + +### 2.8.0 (2024-08-08) + +* Integrated BEVM chain in safle vault diff --git a/package-lock.json b/package-lock.json index 7d21b60..d998f44 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "2.7.0", + "version": "2.8.0", "lockfileVersion": 3, "requires": true, "packages": { @@ -14,6 +14,7 @@ "@getsafle/vault-arbitrum-controller": "^1.0.8", "@getsafle/vault-avalanche-controller": "^1.2.2", "@getsafle/vault-base-controller": "^1.0.2", + "@getsafle/vault-bevm-controller": "^1.0.1", "@getsafle/vault-bitcoin-controller": "^2.0.7", "@getsafle/vault-bsc-controller": "^1.2.4", "@getsafle/vault-eth-controller": "^1.4.6", @@ -1635,6 +1636,179 @@ "proxy-from-env": "^1.1.0" } }, + "node_modules/@getsafle/vault-bevm-controller": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@getsafle/vault-bevm-controller/-/vault-bevm-controller-1.0.1.tgz", + "integrity": "sha512-0Bqvtr0KWQ3AVljdHPDu/RyluYrfKqJKbrzfBnwke5bB8mQqpze9+CmwKeBoB23w6TJUFpyLUsqoTkQMxfwkFg==", + "dependencies": { + "assert": "^2.1.0", + "bip39": "^3.1.0", + "browser-passworder": "^2.0.3", + "crypto-js": "^4.2.0", + "eth-hd-keyring": "^3.6.0", + "eth-sig-util": "^3.0.1", + "eth-simple-keyring": "^4.2.0", + "ethereumjs-tx": "^2.1.2", + "ethereumjs-util": "^7.1.5", + "events": "^3.3.0", + "loglevel": "^1.9.1", + "nyc": "^17.0.0", + "obs-store": "^4.0.3", + "web3": "^1.6.0" + } + }, + "node_modules/@getsafle/vault-bevm-controller/node_modules/assert": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/assert/-/assert-2.1.0.tgz", + "integrity": "sha512-eLHpSK/Y4nhMJ07gDaAzoX/XAKS8PSaojml3M0DM4JpV1LAi5JOJ/p6H/XWrl8L+DzVEvVCW1z3vWAaB9oTsQw==", + "dependencies": { + "call-bind": "^1.0.2", + "is-nan": "^1.3.2", + "object-is": "^1.1.5", + "object.assign": "^4.1.4", + "util": "^0.12.5" + } + }, + "node_modules/@getsafle/vault-bevm-controller/node_modules/bip39": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bip39/-/bip39-3.1.0.tgz", + "integrity": "sha512-c9kiwdk45Do5GL0vJMe7tS95VjCii65mYAH7DfWl3uW8AVzXKQVUm64i3hzVybBDMp9r7j9iNxR85+ul8MdN/A==", + "dependencies": { + "@noble/hashes": "^1.2.0" + } + }, + "node_modules/@getsafle/vault-bevm-controller/node_modules/cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "node_modules/@getsafle/vault-bevm-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==" + }, + "node_modules/@getsafle/vault-bevm-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==", + "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-bevm-controller/node_modules/nyc": { + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/nyc/-/nyc-17.0.0.tgz", + "integrity": "sha512-ISp44nqNCaPugLLGGfknzQwSwt10SSS5IMoPR7GLoMAyS18Iw5js8U7ga2VF9lYuMZ42gOHr3UddZw4WZltxKg==", + "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-bevm-controller/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@getsafle/vault-bevm-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==", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@getsafle/vault-bevm-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==" + }, + "node_modules/@getsafle/vault-bevm-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==", + "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-bevm-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==", + "dependencies": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + }, + "engines": { + "node": ">=6" + } + }, "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", @@ -4868,12 +5042,18 @@ } }, "node_modules/call-bind": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", - "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", + "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", "dependencies": { - "function-bind": "^1.1.1", - "get-intrinsic": "^1.0.2" + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "set-function-length": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -5393,16 +5573,19 @@ } }, "node_modules/define-data-property": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.1.tgz", - "integrity": "sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", "dependencies": { - "get-intrinsic": "^1.2.1", - "gopd": "^1.0.1", - "has-property-descriptors": "^1.0.0" + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" }, "engines": { "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/define-properties": { @@ -5609,6 +5792,25 @@ "is-arrayish": "^0.2.1" } }, + "node_modules/es-define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", + "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", + "dependencies": { + "get-intrinsic": "^1.2.4" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "engines": { + "node": ">= 0.4" + } + }, "node_modules/es5-ext": { "version": "0.10.62", "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz", @@ -6510,15 +6712,19 @@ } }, "node_modules/get-intrinsic": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.2.tgz", - "integrity": "sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", + "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", "dependencies": { + "es-errors": "^1.3.0", "function-bind": "^1.1.2", "has-proto": "^1.0.1", "has-symbols": "^1.0.3", "hasown": "^2.0.0" }, + "engines": { + "node": ">= 0.4" + }, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -6688,11 +6894,11 @@ } }, "node_modules/has-property-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.1.tgz", - "integrity": "sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", "dependencies": { - "get-intrinsic": "^1.2.2" + "es-define-property": "^1.0.0" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -8185,9 +8391,9 @@ } }, "node_modules/loglevel": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.7.1.tgz", - "integrity": "sha512-Hesni4s5UkWkwCGJMQGAh71PaLUmKFM60dHvq0zi/vDhhrzuk+4GgNbTXJ12YYQJn6ZKBDNIjYcuQGKudvqrIw==", + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.9.1.tgz", + "integrity": "sha512-hP3I3kCrDIMuRwAwHltphhDM1r8i55H33GgqjXbrisuJhF4kRhW1dNuxsRklp4bXl8DSdLaNLuiL4A/LWRfxvg==", "engines": { "node": ">= 0.6.0" }, @@ -9012,6 +9218,23 @@ "node": ">= 0.4" } }, + "node_modules/object.assign": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.5.tgz", + "integrity": "sha512-byy+U7gp+FVwmyzKPYhW2h5l3crpmGsxl7X2s8y43IgxvG4g3QZ6CffDtsNQy1WsmZpQbO+ybo0AlW7TY6DcBQ==", + "dependencies": { + "call-bind": "^1.0.5", + "define-properties": "^1.2.1", + "has-symbols": "^1.0.3", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/oboe": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/oboe/-/oboe-2.1.5.tgz", @@ -9974,6 +10197,22 @@ "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==" }, + "node_modules/set-function-length": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/setimmediate": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", diff --git a/package.json b/package.json index b146ca7..6d1fafb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "2.7.0", + "version": "2.8.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": { @@ -49,6 +49,7 @@ "@getsafle/vault-arbitrum-controller": "^1.0.8", "@getsafle/vault-avalanche-controller": "^1.2.2", "@getsafle/vault-base-controller": "^1.0.2", + "@getsafle/vault-bevm-controller": "^1.0.1", "@getsafle/vault-bitcoin-controller": "^2.0.7", "@getsafle/vault-bsc-controller": "^1.2.4", "@getsafle/vault-eth-controller": "^1.4.6", diff --git a/src/chains/index.js b/src/chains/index.js index 9fe67bb..1ab266c 100644 --- a/src/chains/index.js +++ b/src/chains/index.js @@ -11,9 +11,10 @@ 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 evmChains = { 'ethereum': 'ETH', 'bsc': 'BSC', 'polygon': 'MATIC', 'optimism': 'OP' ,'arbitrum': 'ARB', 'mantle': 'MNT', 'velas': 'VLX' , 'avalanche': 'AVAX', 'base':'BASE', 'zkEVM': 'ZKEVM'}; +const evmChains = { 'ethereum': 'ETH', 'bsc': 'BSC', 'polygon': 'MATIC', 'optimism': 'OP' ,'arbitrum': 'ARB', 'mantle': 'MNT', 'velas': 'VLX' , 'avalanche': 'AVAX', 'base':'BASE', 'zkEVM': 'ZKEVM', 'bevm':'BTC'}; const nonEvmChains = { 'bitcoin': 'BTC', 'stacks': 'STX', 'solana': 'SOL' }; module.exports = { @@ -30,6 +31,7 @@ module.exports = { zkEVM, stacks, solana, + bevm, evmChains, nonEvmChains, } \ No newline at end of file From 683e1ed099b33813e67d1408717c43ef24f02e41 Mon Sep 17 00:00:00 2001 From: Shubham Singhal Date: Thu, 8 Aug 2024 11:11:43 +0530 Subject: [PATCH 81/98] Updated test cases --- src/lib/test/keyring.test.js | 3 ++- src/lib/test/vault.test.js | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lib/test/keyring.test.js b/src/lib/test/keyring.test.js index 1ce23b4..a004b88 100644 --- a/src/lib/test/keyring.test.js +++ b/src/lib/test/keyring.test.js @@ -298,7 +298,8 @@ describe('getActiveChains',()=>{ { chain: 'velas', symbol: 'VLX' }, { chain: 'avalanche', symbol: 'AVAX' }, { chain: 'base', symbol: 'BASE' }, - { chain: 'zkEVM', symbol: 'ZKEVM' } + { chain: 'zkEVM', symbol: 'ZKEVM' }, + { chain: 'bevm', symbol: 'BTC' } ] }).toMatchObject(result) diff --git a/src/lib/test/vault.test.js b/src/lib/test/vault.test.js index e4aaa4d..d01b0c3 100644 --- a/src/lib/test/vault.test.js +++ b/src/lib/test/vault.test.js @@ -78,13 +78,11 @@ describe('getSupportedChains' , ()=>{ let result = await new Vault({}).getSupportedChains() expect({ - evmChains: { ethereum: 'ETH', bsc: 'BSC', polygon: 'MATIC', optimism: 'OP', arbitrum: 'ARB', mantle: 'MNT', velas: 'VLX', avalanche: 'AVAX', base:'BASE', zkEVM: 'ZKEVM'}, + evmChains: { 'ethereum': 'ETH', 'bsc': 'BSC', 'polygon': 'MATIC', 'optimism': 'OP' ,'arbitrum': 'ARB', 'mantle': 'MNT', 'velas': 'VLX' , 'avalanche': 'AVAX', 'base':'BASE', 'zkEVM': 'ZKEVM', 'bevm':'BTC'}, nonEvmChains: { bitcoin: 'BTC', stacks: 'STX', solana: 'SOL' } }).toMatchObject(result.response) }) - - }) From 9f01ae218853534047e7674cea65b51569582663 Mon Sep 17 00:00:00 2001 From: Husien vora Date: Tue, 20 Aug 2024 15:18:05 +0530 Subject: [PATCH 82/98] integrating rootstock chain fixing tests --- CHANGELOG.md | 379 +++--- package-lock.json | 186 ++- package.json | 9 +- src/chains/index.js | 82 +- src/lib/keyring.js | 2023 +++++++++++++++++----------- src/lib/test/keyring.test.js | 2405 +++++++++++++++------------------- src/lib/test/vault.test.js | 532 ++++---- 7 files changed, 2979 insertions(+), 2637 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60e8636..6d9fe4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,424 +2,424 @@ ##### Initial commit -* Generate Mnemonic -* Generate a new vault -* Get the list of accounts -* Export mnemonic -* Export private keys -* Add a new account to the keyring -* Sign message -* Sign transaction -* Delete account -* Recover vault -* Added github actions workflow +- Generate Mnemonic +- Generate a new vault +- Get the list of accounts +- Export mnemonic +- Export private keys +- Add a new account to the keyring +- Sign message +- Sign transaction +- Delete account +- Recover vault +- Added github actions workflow ### 1.1.0 (2021-10-13) ##### Added support for EIP-1559 Tx Signing -* Implemented method to sign eip1559 transactions +- Implemented method to sign eip1559 transactions ### 1.1.1 (2021-11-16) ##### Updated constructor parameter -* Updated the constructor parameter to initialize the SDK using the encrypted vault string +- Updated the constructor parameter to initialize the SDK using the encrypted vault string ### 1.1.2 (2021-11-22) ##### Updated transaction signing method -* Implemented the updated vault-eth-controller sdk to sign eip1559 transactions. +- Implemented the updated vault-eth-controller sdk to sign eip1559 transactions. ### 1.1.3 (2021-11-23) ##### Added method to validate PIN -* Implemented the method to validate the user's PIN. +- Implemented the method to validate the user's PIN. ### 1.1.4 (2021-11-25) ##### Updated the validatePin function call -* Fixed the issue where some function were calling the validatePin function incorrectly. -* Updated the variable to return the error messages from `response` to `errorMessage` since `response` was conflicting with the function success. +- Fixed the issue where some function were calling the validatePin function incorrectly. +- Updated the variable to return the error messages from `response` to `errorMessage` since `response` was conflicting with the function success. ### 1.1.5 (2021-11-29) ##### Persist the updated vault in the local storage -* Fixed the issue where the updated vault was not getting stored in the local storage. -* Updated the README with the new constructor initialization and also the `validatePin` function. +- Fixed the issue where the updated vault was not getting stored in the local storage. +- Updated the README with the new constructor initialization and also the `validatePin` function. ### 1.2.0 (2021-12-01) ##### Integrated BSC controller -* Integrated the BSC controller with the vault. +- Integrated the BSC controller with the vault. ### 1.2.1 (2021-12-30) ##### Updated BSC controller package -* Updated the bsc controller package. +- Updated the bsc controller package. Deprecated package was `@getsafle/bsc-wallet-controller` and updated one is `@getsafle/vault-bsc-controller`. ### 1.2.2 (2021-12-30) ##### Integrated Polygon controller -* Integrated the [Polygon wallet controller](https://github.com/getsafle/vault-polygon-controller). +- Integrated the [Polygon wallet controller](https://github.com/getsafle/vault-polygon-controller). ### 1.2.3 (2021-12-30) ##### Integrated Bitcoin controller -* Integrated the [Bitcoin wallet controller](https://github.com/getsafle/vault-bitcoin-controller). +- Integrated the [Bitcoin wallet controller](https://github.com/getsafle/vault-bitcoin-controller). ### 1.2.4 (2022-01-05) ##### Delete account for non-eth chains -* Extended the functionality to delete an account for all the chains. +- Extended the functionality to delete an account for all the chains. ### 1.2.5 (2022-01-10) ##### Get the list of all the supported chains -* Implemented a method to get the list of all the supported EVM and non-EVM chains. +- Implemented a method to get the list of all the supported EVM and non-EVM chains. ### 1.2.6 (2022-01-12) ##### Integrated Harmony Controller -* Integrated the [Harmony wallet controller](https://github.com/getsafle/vault-harmony-controller). +- Integrated the [Harmony wallet controller](https://github.com/getsafle/vault-harmony-controller). ### 1.2.7 (2022-01-12) ##### Integrated Avalanche Controller -* Integrated the [Avalanche wallet controller](https://github.com/getsafle/vault-avalanche-controller). +- Integrated the [Avalanche wallet controller](https://github.com/getsafle/vault-avalanche-controller). ### 1.2.8 (2022-01-13) ##### Integrated Velas Controller -* Integrated the [Velas vault controller](https://github.com/getsafle/vault-velas-controller). +- Integrated the [Velas vault controller](https://github.com/getsafle/vault-velas-controller). ### 1.2.9 (2022-01-18) ##### Integrated Transaction Controller -* Integrated the [Transaction Controller](https://github.com/getsafle/transaction-controller) for asset discovery on Ethereum and Polygon chains for vault recovery. +- Integrated the [Transaction Controller](https://github.com/getsafle/transaction-controller) for asset discovery on Ethereum and Polygon chains for vault recovery. ### 1.3.0 (2022-01-24) ##### Method to validate mnemonic -* Added a method to validate the mnemonic phrase of the user. +- Added a method to validate the mnemonic phrase of the user. ### 1.4.0 (2022-01-29) ##### Import Wallets -* Created a method to import a wallet using private key for all the supported chains. +- Created a method to import a wallet using private key for all the supported chains. ### 1.5.0 (2022-01-29) ##### List active chains -* Created a method to get the list of chains for which the user has generated or imported a wallet. +- Created a method to get the list of chains for which the user has generated or imported a wallet. ### 1.5.1 (2022-01-31) ##### Import wallet function return the public address -* Updated the importWallet function to return the public address of the private key along with the encrypted vault string. +- Updated the importWallet function to return the public address of the private key along with the encrypted vault string. ### 1.5.2 (2022-02-05) ##### Updated `getActiveChains()` and `getSupportedChains()` -* Updated the `getActiveChains()` and `getSupportedChains()` functions to return the chains along with their symbols. +- Updated the `getActiveChains()` and `getSupportedChains()` functions to return the chains along with their symbols. ### 1.6.0 (2022-02-10) ##### Added logging functionality -* All the functions which changes the state of the vault now also maintains a log of the changes. -* Implemented a function to retrieve all the logs `getLogs()`. -* BREAKING CHANGE: `addAccounts()` function now returns an object with vault and the newly added account. +- All the functions which changes the state of the vault now also maintains a log of the changes. +- Implemented a function to retrieve all the logs `getLogs()`. +- BREAKING CHANGE: `addAccounts()` function now returns an object with vault and the newly added account. ### 1.7.0 (2022-03-08) ##### Added a function to get the detailed list of all the accounts for all chains [Breaking Changes] -* Added a function (`getVaultDetails()`) to get the detailed list of all accounts for all chains. Implemented token detection for all evm supported wallets for eth and polygon chains. -* BREAKING CHANGE: Vault initialization accepts only the vault string as the parameter. If the vault has not been generated, then the constructor will be empty. -* BREAKING CHANGE: `recoverVault()` function also accepts `rpcUrl` as the parameter. -* BREAKING CHANGE: `signTransaction()` function also accepts `rpcUrl` as the parameter. +- Added a function (`getVaultDetails()`) to get the detailed list of all accounts for all chains. Implemented token detection for all evm supported wallets for eth and polygon chains. +- BREAKING CHANGE: Vault initialization accepts only the vault string as the parameter. If the vault has not been generated, then the constructor will be empty. +- BREAKING CHANGE: `recoverVault()` function also accepts `rpcUrl` as the parameter. +- BREAKING CHANGE: `signTransaction()` function also accepts `rpcUrl` as the parameter. ### 1.8.0 (2022-03-09) ##### Added a function to get the native asset balance of an account -* Added a function (`getBalance()`) to get the native asset balance for an address. +- Added a function (`getBalance()`) to get the native asset balance for an address. ### 1.9.0 (2022-03-10) ##### Added a function to sign a message or rawTx and get signature object -* Added a function (`sign()`) to sign a transaction object or message and get the signature object. +- Added a function (`sign()`) to sign a transaction object or message and get the signature object. ### 1.9.1 (2022-03-16) ##### Added pin validation -* Added a validation to ensure that the pin entered is a positive integer value +- Added a validation to ensure that the pin entered is a positive integer value ### 1.9.2 (2022-03-22) ##### Fixed bug where user cannot delete imported wallets -* Fixed bug where user cannot delete imported wallets. +- Fixed bug where user cannot delete imported wallets. ### 1.10.0 (2022-04-08) ##### Integrated BSC chain -* Integrated BSC chain wallet scanning for `recoverVault()` function. -* Integrated BSC chain for `getVaultDetails()` function. +- Integrated BSC chain wallet scanning for `recoverVault()` function. +- Integrated BSC chain for `getVaultDetails()` function. ### 1.10.1 (2022-04-15) ##### [Bugfix]: Fixed the bug where the user was unable to export the private keys of their bitcoin wallet -* Fixed the bug where the user was unable to export the private keys of their bitcoin wallet +- Fixed the bug where the user was unable to export the private keys of their bitcoin wallet ### 1.10.2 (2022-04-15) ##### [Bugfix]: `importWallet()` function can be used to import an already existing wallet -* `importWallet()` function throws an error if the address is already present in the vault. -* Implemented lodash library to query the nested object keys for all functions. +- `importWallet()` function throws an error if the address is already present in the vault. +- Implemented lodash library to query the nested object keys for all functions. ### 1.10.3 (2022-04-18) ##### [Bugfix]: `importWallet()` function throws an error when importing a non evm wallet -* Added a condition in the `importWallet()` function to check if the output of the `getAccounts()` is an error. +- Added a condition in the `importWallet()` function to check if the output of the `getAccounts()` is an error. ### 1.11.0 (2022-04-19) ##### Wallet label -* Every address in the vault will have a default wallet label. -* Added the functionality to change the wallet label - `updateLabel()`. +- Every address in the vault will have a default wallet label. +- Added the functionality to change the wallet label - `updateLabel()`. ### 1.11.1 (2022-04-22) ##### Added the wallet label in `getVaultDetails()` function. -* `getVaultDetails()` will also return the wallet label in the output. +- `getVaultDetails()` will also return the wallet label in the output. ### 1.11.2 (2022-04-25) ##### [BugFix] `validatePin()` function. -* `validatePin()` fix an issue where the function returned an uncaught error `Malformed UTF-8 data`. +- `validatePin()` fix an issue where the function returned an uncaught error `Malformed UTF-8 data`. ### 1.11.3 (2022-04-26) ##### [BugFix] Error when generate bitcoin account for the first time. -* Fixed an issue where the user was unable to generate a bitcoin wallet for the first time. +- Fixed an issue where the user was unable to generate a bitcoin wallet for the first time. ### 1.12.0 (2022-04-28) ##### Updated the `restoreKeyringState()` function to restore the state for non-evm chains too -* Updated the `restoreKeyringState()` function to restore the state for non-evm chains too. +- Updated the `restoreKeyringState()` function to restore the state for non-evm chains too. ### 1.12.1 (2022-05-11) ##### Removed the condition which checks if the address is present in the vault to get the balance -* Removed the condition which checks if the address is present in the vault to get the balance. +- Removed the condition which checks if the address is present in the vault to get the balance. ### 1.13.0 (2022-05-17) ##### Integrated Solana chain -* Integrated Solana vault controller for generating solana wallets and perform operations. +- Integrated Solana vault controller for generating solana wallets and perform operations. ### 1.14.0 (2022-05-17) ##### Integrated Tezos chain -* Integrated Tezos vault controller for generating tezos wallets and perform operations. +- Integrated Tezos vault controller for generating tezos wallets and perform operations. ### 1.15.0 (2022-05-18) ##### [BREAKING Changes] Segregated the functionality of `getVaultDetails()` function into 2 diferent functions. -* `getVaultDetails()` function will only return the address of all the chains -* Created a new function `getAssets()` which returns the list of assets for all the addresses on all the chains passed in an array. +- `getVaultDetails()` function will only return the address of all the chains +- Created a new function `getAssets()` which returns the list of assets for all the addresses on all the chains passed in an array. ### 1.15.1 (2022-05-19) ##### [Bug] Fixed duplicate address issue. -* Fixed the issue where the addresses generated after executing `restoreKeyringState()` are duplicates. +- Fixed the issue where the addresses generated after executing `restoreKeyringState()` are duplicates. ### 1.15.2 (2022-05-23) ##### Removed Tezos integration. -* Removed tezos integration due to some compatibility issue in the tezos controller with RN framework. +- Removed tezos integration due to some compatibility issue in the tezos controller with RN framework. ### 1.15.3 (2022-05-27) ##### Updated Polygon controller version. -* Updated Polygon controller version to support type2 transaction signing. +- Updated Polygon controller version to support type2 transaction signing. ### 1.16.0 (2022-05-27) ##### [BREAKING] Added network selection for `validateMnemonic()` function. -* [BREAKING] Added network selection for `validateMnemonic()` function. +- [BREAKING] Added network selection for `validateMnemonic()` function. ### 1.17.0 (2022-06-06) ##### `changePin()` function. -* Implemented a function to change the vault pin. +- Implemented a function to change the vault pin. ### 1.17.1 (2022-06-09) ##### [Breaking] `changePin()` function returns the new vault string. -* `changePin()` function returns the new vault string. -* Added a new parameter `encryptionKey`. +- `changePin()` function returns the new vault string. +- Added a new parameter `encryptionKey`. ### 1.18.0 (2022-06-10) ##### Removed `velas`, `avalanche`, `solana` and `harmony` chain integration. -* Removed `velas`, `avalanche`, `solana` and `harmony` chain integration. +- Removed `velas`, `avalanche`, `solana` and `harmony` chain integration. ### 1.18.1 (2022-06-13) ##### Uncaught error in `validateMnemonic()`. -* Added error handling for an uncaught error when user inputs an invalid mnemonic in the `validateMnemonic()` function . +- Added error handling for an uncaught error when user inputs an invalid mnemonic in the `validateMnemonic()` function . ### 1.18.2 (2022-06-24) ##### Updated `safle-identity-wallet` package version. -* Updated `safle-identity-wallet` package version. -* [Breaking Change] - `validateMnemonic()` also accepts polygonRpcUrl. +- Updated `safle-identity-wallet` package version. +- [Breaking Change] - `validateMnemonic()` also accepts polygonRpcUrl. ### 1.18.3 (2022-06-30) ##### Updated the condition check for pin in the `generateVault()` function. -* Updated the condition check for pin in the `generateVault()` function. Now users can also choose `000000` as the pin. +- Updated the condition check for pin in the `generateVault()` function. Now users can also choose `000000` as the pin. ### 1.19.0 (2022-06-23) ##### Added a functionality for the host app to plug in their own encryption decryption functions -* The developer who wants to integrate the safle-vault sdk can inject their own encryption/decryption function in the constructor. The functions can be passed inside `encryptor` object. -* [Breaking Change] - Constructor parameters have to be passed as an object. +- The developer who wants to integrate the safle-vault sdk can inject their own encryption/decryption function in the constructor. The functions can be passed inside `encryptor` object. +- [Breaking Change] - Constructor parameters have to be passed as an object. ### 1.20.0 (2022-07-20) ##### Added a extra optional parameter (`platform`) in the constructor -* The constructor accepts a new optional parameter called `platform` which will be saved in the logs. +- The constructor accepts a new optional parameter called `platform` which will be saved in the logs. ### 1.18.4 (2022-08-24) ##### Fixed the bsc chain naming convention from `binance smart chain` to `bsc`. -* Fixed the bsc chain naming convention from `binance smart chain` to `bsc`. +- Fixed the bsc chain naming convention from `binance smart chain` to `bsc`. ### 1.18.5 (2022-08-29) ##### Fixed a bug which prevented a user from importing the same account post deleting it -* Fixed a bug which prevented a user from importing the same account post deleting it +- Fixed a bug which prevented a user from importing the same account post deleting it ### 1.18.6 (2022-09-07) ##### Updated BTC vault controller version -* Updated BTC vault controller version and fixed Bitcoin transaction signing issue +- Updated BTC vault controller version and fixed Bitcoin transaction signing issue ### 1.18.7 (2022-09-14) ##### Updated transaction controller version -* Updated transaction controller version +- Updated transaction controller version ### 1.18.8 (2022-09-16) ##### Updated bitcoin controller version -* Updated bitcoin controller version to fix the utxo calculation while transaction signing. +- Updated bitcoin controller version to fix the utxo calculation while transaction signing. ### 1.21.0 (2022-10-17) ##### Rebase the different released versions into one single version -* Rebased the versions 1.19.0, 1.20.0, 1.18.4, 1.18.5, 1.18.6, 1.18.7 and 1.18.8 into a new version 1.21.1 +- Rebased the versions 1.19.0, 1.20.0, 1.18.4, 1.18.5, 1.18.6, 1.18.7 and 1.18.8 into a new version 1.21.1 ### 1.21.1 (2022-10-17) ##### Track which address has exported their private key -* Every address has a new flag `isExported` associated with it to track if the private key of that address has been exported. -* [Breaking Change] encryptedEncryptionKey has to be passed in the `exportPrivateKey()`, `signTransaction()` and `sign()`function. +- Every address has a new flag `isExported` associated with it to track if the private key of that address has been exported. +- [Breaking Change] encryptedEncryptionKey has to be passed in the `exportPrivateKey()`, `signTransaction()` and `sign()`function. ### 1.21.2 (2022-10-17) ##### Updated the output of `getVaultDetails()` function to make it more consistent -* Updated the output of `getVaultDetails()` function to make it more consistent. All the wallet objects are returned in an array inside the `generatedWallets` or `importedWallets` object under their respective chains. +- Updated the output of `getVaultDetails()` function to make it more consistent. All the wallet objects are returned in an array inside the `generatedWallets` or `importedWallets` object under their respective chains. ### 1.22.0 (2022-10-17) ##### Constructor also accepts the parameter `storage` -* Constructor also accepts the parameter `storage` where the developer can pass the vault storage mechanisms as an array. +- Constructor also accepts the parameter `storage` where the developer can pass the vault storage mechanisms as an array. ### 1.23.0 (2022-10-18) ##### Function to restore the deleted wallets -* Created a function (`restoreAccount()`) to restore the deleted wallets. +- Created a function (`restoreAccount()`) to restore the deleted wallets. ### 1.24.0 (2022-10-18) ##### Enabled the user to change the wallet label for a specific EVM chain -* Enabled the user to change the wallet label for a specific EVM chain. -* [Breaking Change] - `updateLabel()` function accepts an extra parameter `chainName` which is the name of the EVM chain for which the label is to be updated. +- Enabled the user to change the wallet label for a specific EVM chain. +- [Breaking Change] - `updateLabel()` function accepts an extra parameter `chainName` which is the name of the EVM chain for which the label is to be updated. ### 1.24.1 (2022-10-18) ##### Updated the vault logs parameter -* Updated the vault logs parameters by removing the vault string and adding the platform and storage values. +- Updated the vault logs parameters by removing the vault string and adding the platform and storage values. ### 1.24.2 (2022-10-20) ##### New release with all the functionalities till v1.24.1 -* New release with all the functionalities till v1.24.1. +- New release with all the functionalities till v1.24.1. ### 1.24.3 (2023-01-25) @@ -429,238 +429,243 @@ ##### Backward compatiblity for updateLabel -* Implemented backward compatiblity for update label method for wallets created on versions before 1.24.1 +- Implemented backward compatiblity for update label method for wallets created on versions before 1.24.1 ### 1.26.0 (2023-02-17) -* Stable release 1.26.0 +- Stable release 1.26.0 ### 1.26.1 (2023-03-10) -* Added helper method createWalletLabels to create dynamic labels for wallets +- Added helper method createWalletLabels to create dynamic labels for wallets ### 1.26.2 (2023-03-15) -* Updated @getsafle/vault-eth-controller to v1.4.1 +- Updated @getsafle/vault-eth-controller to v1.4.1 ### 1.26.3 (2023-03-16) -* Implemented validateEncryptionKey method for importWallet -* Implement checksum addresses for validateMnemonic -* Implemented check for null accepted as a valid wallet label -* Implemented validateEncryptionKey method for UpdateLabel -* Updated error message from validateEncryptionKey -* Fxied issue with signTransaction method accepts from address in lowercase -* Add length validation for pin - +- Implemented validateEncryptionKey method for importWallet +- Implement checksum addresses for validateMnemonic +- Implemented check for null accepted as a valid wallet label +- Implemented validateEncryptionKey method for UpdateLabel +- Updated error message from validateEncryptionKey +- Fxied issue with signTransaction method accepts from address in lowercase +- Add length validation for pin ### 1.26.4 (2023-03-17) -* Added testcases for vault sdk +- Added testcases for vault sdk ### 1.26.5 (2023-03-22) -* Added coverage report -* Implemented test cases and fixed CI for the same +- Added coverage report +- Implemented test cases and fixed CI for the same ### 1.26.6 (2023-03-17) -* Updated Readme +- Updated Readme ### 1.26.7 (2023-05-08) -* Updated error message for incorrect PIN type entry +- Updated error message for incorrect PIN type entry ### 1.27.0 (2023-05-22) -* Updated outdated dependencies and removed unused package dependencies -* Added throttling on validate Pin +- Updated outdated dependencies and removed unused package dependencies +- Added throttling on validate Pin ### 1.27.1 (2023-06-07) -* Removed buffer creation for sign message +- Removed buffer creation for sign message ### 1.28.0 (2023-06-21) -* Updated sign message for imported wallets +- Updated sign message for imported wallets ### 1.28.1 (2023-06-21) -* update keyring to redirect to correct chain controller while importing wallet +- update keyring to redirect to correct chain controller while importing wallet ### 1.28.2 (2023-06-21) -* update keyring to slice incoming private key if it has '0x' prefixed for it to be imported +- update keyring to slice incoming private key if it has '0x' prefixed for it to be imported ### 1.28.3 (2023-06-22) -* Enabling sign transaction for an imported wallet on ETH chain +- Enabling sign transaction for an imported wallet on ETH chain ### 1.29.0 (2023-06-26) -* Upgrade ETH, polygon and BSC controller, adding new controllers Optimism and Arbitrum +- Upgrade ETH, polygon and BSC controller, adding new controllers Optimism and Arbitrum ### 1.29.1 (2023-07-05) -* Updated CI with added branches -* Updated node version in CI -* cleaned package structure +- Updated CI with added branches +- Updated node version in CI +- cleaned package structure ### 1.30.0 (2023-07-06) -* Updated all ethereum based controllers -* Added new controllers for Mantle and Velas chain -* Updated test cases according to new chain integrated -* Updated sign message for ethereum chain to filter message hash +- Updated all ethereum based controllers +- Added new controllers for Mantle and Velas chain +- Updated test cases according to new chain integrated +- Updated sign message for ethereum chain to filter message hash ### 1.30.01 (2023-07-8) Nightly version : only for experimental use -* Updated vault state with decryptedVault -* Updated rate limiting for pin validation, upto 10 +- Updated vault state with decryptedVault +- Updated rate limiting for pin validation, upto 10 ### 1.30.02 (2023-07-17) Nightly version : only for experimental use -* pakage dependency updates -* update lable correction +- pakage dependency updates +- update lable correction ### 1.30.03 (2023-08-17) Nightly version : only for experimental use -* Updated keyring to slice exported private key if it has '0x' prefixed to add backward campatability for imported wallets +- Updated keyring to slice exported private key if it has '0x' prefixed to add backward campatability for imported wallets ### 1.30.04 (2023-08-28) Nightly version : only for experimental use -* Updated the logs for label update & delete account -* Removed unused encryption key parameter in get accounts -* Added validation for pin parameter in export private key, restore keyring state & current pin parameter in change pin -* Added validation for encryption key in add account, sign message, delete account, get vault details & update label -* Sync the pin validation steps with other methods in import wallet -* Updated tests wrt changes in vault generation and parameter validations -* Implemented vault recovery using logs and updated tests +- Updated the logs for label update & delete account +- Removed unused encryption key parameter in get accounts +- Added validation for pin parameter in export private key, restore keyring state & current pin parameter in change pin +- Added validation for encryption key in add account, sign message, delete account, get vault details & update label +- Sync the pin validation steps with other methods in import wallet +- Updated tests wrt changes in vault generation and parameter validations +- Implemented vault recovery using logs and updated tests ### 1.30.05 (2023-09-08) Nightly version : only for experimental use -* Implemented account recovery in case of deleted accounts, both generated and imported -* Added test cases for account recovery -* Added logs for export mnemonic -* Added logs for export private key(for generated and imported accounts) -* Re-encrypted the private key of imported wallets and updated vault state after change pin +- Implemented account recovery in case of deleted accounts, both generated and imported +- Added test cases for account recovery +- Added logs for export mnemonic +- Added logs for export private key(for generated and imported accounts) +- Re-encrypted the private key of imported wallets and updated vault state after change pin ### 1.30.06 (2023-09-27) Nightly version : only for experimental use -* Added checksum for address comparison in export private key -* Updated label creation according to logs -* Updated test cases according to checksum address comparison in export private key +- Added checksum for address comparison in export private key +- Updated label creation according to logs +- Updated test cases according to checksum address comparison in export private key ### 1.30.07 (2023-10-05) Nightly version : only for experimental use -* Updated pin format from number to string -* updated test cases according to pin format changes +- Updated pin format from number to string +- updated test cases according to pin format changes ### 1.30.08 (2023-10-09) Nightly version : only for experimental use -* Updated pin while resetting imported wallets +- Updated pin while resetting imported wallets ### 1.31.0 (2023-10-09) Nightly version : only for experimental use -* Integrated upgraded bitcoin controller into vault -* Enable backward compatibility in vault recovery for evm chains for undefined chain parameter in logs -* Generate a default wallet for every chain when generating vault -* Add fallback for recover vault - the default address to be recovered for every chain -* Updated recover vault to create default wallet address for bitcoin for preexisting vaults -* Updated test result for bitcoin +- Integrated upgraded bitcoin controller into vault +- Enable backward compatibility in vault recovery for evm chains for undefined chain parameter in logs +- Generate a default wallet for every chain when generating vault +- Add fallback for recover vault - the default address to be recovered for every chain +- Updated recover vault to create default wallet address for bitcoin for preexisting vaults +- Updated test result for bitcoin ### 2.0.0 (2023-11-02) -* Removed workflow for nightly release branch -* Merging nightly release 1.31.0 into main branch +- Removed workflow for nightly release branch +- Merging nightly release 1.31.0 into main branch ### 2.0.1 (2023-11-02) -* Added backward compatibility in recover vault to handle incomplete logs for older users -* Updated restore keyring state for other chains +- Added backward compatibility in recover vault to handle incomplete logs for older users +- Updated restore keyring state for other chains ### 2.0.2 (2023-12-04) -* Response updated for no accounts found -* Added a precheck of current chain in decrypted vault while restoring keyring state -* Node version upgrade to 18.x +- Response updated for no accounts found +- Added a precheck of current chain in decrypted vault while restoring keyring state +- Node version upgrade to 18.x ### 2.1.0 (2023-12-04) -* Added getFees() method to get transaction fees -* Updated readme for getFees() method -* Added test for getFees() method -* Updated controller version of eth, polygon, bsc, optimism, arbitrum, mantle, velas, bitcoin +- Added getFees() method to get transaction fees +- Updated readme for getFees() method +- Added test for getFees() method +- Updated controller version of eth, polygon, bsc, optimism, arbitrum, mantle, velas, bitcoin ### 2.2.0 (2023-12-04) -* Integrated avalanche C chain in safle vault. +- Integrated avalanche C chain in safle vault. ### 2.3.0 (2023-12-19) -* Integrated base chain in safle vault. +- Integrated base chain in safle vault. ### 2.4.0 (2023-12-19) -* Integrated polygon zkEVM chain in safle vault. +- Integrated polygon zkEVM chain in safle vault. ### 2.4.1 (2024-01-05) -* Updated recover vault to handle disordered logs and duplicate addresses. +- Updated recover vault to handle disordered logs and duplicate addresses. ### 2.4.2 (2024-01-09) -* Updated bitcoin controller version +- Updated bitcoin controller version ### 2.4.3 (2024-01-23) -* Increased rate limit for validating pin -* Updated bitcoin controller version +- Increased rate limit for validating pin +- Updated bitcoin controller version ### 2.4.4 (2024-01-24) -* Updated bitcoin controller version with proxy service integrated +- Updated bitcoin controller version with proxy service integrated ### 2.4.5 (2024-01-30) -* Updated bitcoin controller version with network param for signing -* Updated restore keyring state and vault structure in recover vault function for bitcoin +- Updated bitcoin controller version with network param for signing +- Updated restore keyring state and vault structure in recover vault function for bitcoin ### 2.4.6 (2024-02-2) -* Updated recover vault to handle recurring addresses in logs +- 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. +- 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. ### 2.5.1 (2024-02-20) -* Refactored recover vault logic and generalized it for evm and non evm chains -* updated labeling for evm and non evm wallet accounts -* Integrated restore account logs for vault recovery +- Refactored recover vault logic and generalized it for evm and non evm chains +- updated labeling for evm and non evm wallet accounts +- Integrated restore account logs for vault recovery ### 2.6.0 (2024-05-07) -* Integrated stacks chain in safle vault +- Integrated stacks chain in safle vault ### 2.6.1 (2024-05-09) -* Upgraded stacks controller version +- Upgraded stacks controller version ### 2.6.2 (2024-05-31) -* Updated add account for stacks addresses -* Upgraded stacks controller version +- Updated add account for stacks addresses +- Upgraded stacks controller version ### 2.7.0 (2024-07-25) -* Integrated solana chain in safle vault -* Updated test cases +- Integrated solana chain in safle vault +- Updated test cases ### 2.8.0 (2024-08-08) -* Integrated BEVM chain in safle vault +- Integrated BEVM chain in safle vault + +### 2.9.0 (2024-08-20) + +- Integrated rootstock chain in safle vault +- Update BEVM controller version +- Fixed validatePin function for tests diff --git a/package-lock.json b/package-lock.json index d998f44..7be1057 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@getsafle/safle-vault", - "version": "2.8.0", + "version": "2.9.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@getsafle/safle-vault", - "version": "2.7.0", + "version": "2.8.0", "license": "MIT", "dependencies": { "@getsafle/safle-identity-wallet": "^1.3.0", @@ -14,7 +14,7 @@ "@getsafle/vault-arbitrum-controller": "^1.0.8", "@getsafle/vault-avalanche-controller": "^1.2.2", "@getsafle/vault-base-controller": "^1.0.2", - "@getsafle/vault-bevm-controller": "^1.0.1", + "@getsafle/vault-bevm-controller": "^1.0.3", "@getsafle/vault-bitcoin-controller": "^2.0.7", "@getsafle/vault-bsc-controller": "^1.2.4", "@getsafle/vault-eth-controller": "^1.4.6", @@ -22,6 +22,7 @@ "@getsafle/vault-optimism-controller": "^1.0.8", "@getsafle/vault-polygon-controller": "^1.2.8", "@getsafle/vault-polygon-zkevm-controller": "^1.0.1", + "@getsafle/vault-rootstock-controller": "^1.0.0", "@getsafle/vault-sol-controller": "^1.0.1", "@getsafle/vault-stacks-controller": "^1.0.5", "@getsafle/vault-velas-controller": "^1.3.1", @@ -1637,9 +1638,9 @@ } }, "node_modules/@getsafle/vault-bevm-controller": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@getsafle/vault-bevm-controller/-/vault-bevm-controller-1.0.1.tgz", - "integrity": "sha512-0Bqvtr0KWQ3AVljdHPDu/RyluYrfKqJKbrzfBnwke5bB8mQqpze9+CmwKeBoB23w6TJUFpyLUsqoTkQMxfwkFg==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@getsafle/vault-bevm-controller/-/vault-bevm-controller-1.0.3.tgz", + "integrity": "sha512-m9nyGGOUPFEEJFb/XkKpZrdIhMYX5B8iEt9hBcAbj5PiBfGwLmYuUXjOXRKpGGZYNk6e8xIf9vnLLu0EkKY8vw==", "dependencies": { "assert": "^2.1.0", "bip39": "^3.1.0", @@ -2155,6 +2156,179 @@ "safe-buffer": "^5.1.1" } }, + "node_modules/@getsafle/vault-rootstock-controller": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@getsafle/vault-rootstock-controller/-/vault-rootstock-controller-1.0.0.tgz", + "integrity": "sha512-QMHrexrFnzmBKML1h9zxZ/Fg+qfUZ7aR5ZvV33EQbtOFaIbHw/fwOa66Egw7sHT0zyU1OfyAi8Tv55zm8rK4Dw==", + "dependencies": { + "assert": "^2.1.0", + "bip39": "^3.1.0", + "browser-passworder": "^2.0.3", + "crypto-js": "^4.2.0", + "eth-hd-keyring": "^3.6.0", + "eth-sig-util": "^3.0.1", + "eth-simple-keyring": "^4.2.0", + "ethereumjs-tx": "^2.1.2", + "ethereumjs-util": "^7.1.5", + "events": "^3.3.0", + "loglevel": "^1.9.1", + "nyc": "^17.0.0", + "obs-store": "^4.0.3", + "web3": "^1.6.0" + } + }, + "node_modules/@getsafle/vault-rootstock-controller/node_modules/assert": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/assert/-/assert-2.1.0.tgz", + "integrity": "sha512-eLHpSK/Y4nhMJ07gDaAzoX/XAKS8PSaojml3M0DM4JpV1LAi5JOJ/p6H/XWrl8L+DzVEvVCW1z3vWAaB9oTsQw==", + "dependencies": { + "call-bind": "^1.0.2", + "is-nan": "^1.3.2", + "object-is": "^1.1.5", + "object.assign": "^4.1.4", + "util": "^0.12.5" + } + }, + "node_modules/@getsafle/vault-rootstock-controller/node_modules/bip39": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bip39/-/bip39-3.1.0.tgz", + "integrity": "sha512-c9kiwdk45Do5GL0vJMe7tS95VjCii65mYAH7DfWl3uW8AVzXKQVUm64i3hzVybBDMp9r7j9iNxR85+ul8MdN/A==", + "dependencies": { + "@noble/hashes": "^1.2.0" + } + }, + "node_modules/@getsafle/vault-rootstock-controller/node_modules/cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "node_modules/@getsafle/vault-rootstock-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==" + }, + "node_modules/@getsafle/vault-rootstock-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==", + "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-rootstock-controller/node_modules/nyc": { + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/nyc/-/nyc-17.0.0.tgz", + "integrity": "sha512-ISp44nqNCaPugLLGGfknzQwSwt10SSS5IMoPR7GLoMAyS18Iw5js8U7ga2VF9lYuMZ42gOHr3UddZw4WZltxKg==", + "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-rootstock-controller/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@getsafle/vault-rootstock-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==", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@getsafle/vault-rootstock-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==" + }, + "node_modules/@getsafle/vault-rootstock-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==", + "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-rootstock-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==", + "dependencies": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/@getsafle/vault-sol-controller": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@getsafle/vault-sol-controller/-/vault-sol-controller-1.0.1.tgz", diff --git a/package.json b/package.json index 6d1fafb..6f08193 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@getsafle/safle-vault", - "version": "2.8.0", + "version": "2.9.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": { @@ -35,6 +35,10 @@ { "name": "Subhanshu", "email": "subhanshu@getsafle.com" + }, + { + "name": "Husien", + "email": "husien@getsafle.com" } ], "keywords": [ @@ -49,7 +53,8 @@ "@getsafle/vault-arbitrum-controller": "^1.0.8", "@getsafle/vault-avalanche-controller": "^1.2.2", "@getsafle/vault-base-controller": "^1.0.2", - "@getsafle/vault-bevm-controller": "^1.0.1", + "@getsafle/vault-bevm-controller": "^1.0.3", + "@getsafle/vault-rootstock-controller": "^1.0.0", "@getsafle/vault-bitcoin-controller": "^2.0.7", "@getsafle/vault-bsc-controller": "^1.2.4", "@getsafle/vault-eth-controller": "^1.4.6", diff --git a/src/chains/index.js b/src/chains/index.js index 1ab266c..b5db95f 100644 --- a/src/chains/index.js +++ b/src/chains/index.js @@ -1,37 +1,51 @@ -const ethereum = require('@getsafle/vault-eth-controller'); -const bsc = require('@getsafle/vault-bsc-controller'); -const polygon = require('@getsafle/vault-polygon-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 ethereum = require("@getsafle/vault-eth-controller"); +const bsc = require("@getsafle/vault-bsc-controller"); +const polygon = require("@getsafle/vault-polygon-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"); - -const evmChains = { 'ethereum': 'ETH', 'bsc': 'BSC', 'polygon': 'MATIC', 'optimism': 'OP' ,'arbitrum': 'ARB', 'mantle': 'MNT', 'velas': 'VLX' , 'avalanche': 'AVAX', 'base':'BASE', 'zkEVM': 'ZKEVM', 'bevm':'BTC'}; -const nonEvmChains = { 'bitcoin': 'BTC', 'stacks': 'STX', 'solana': 'SOL' }; +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", +}; +const nonEvmChains = { bitcoin: "BTC", stacks: "STX", solana: "SOL" }; module.exports = { - ethereum, - bsc, - polygon, - bitcoin, - optimism, - arbitrum, - mantle, - velas, - avalanche, - base, - zkEVM, - stacks, - solana, - bevm, - evmChains, - nonEvmChains, -} \ No newline at end of file + ethereum, + bsc, + polygon, + bitcoin, + optimism, + arbitrum, + mantle, + velas, + avalanche, + base, + zkEVM, + stacks, + solana, + bevm, + rootstock, + evmChains, + nonEvmChains, +}; diff --git a/src/lib/keyring.js b/src/lib/keyring.js index 7f61c16..e32b443 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -1,1009 +1,1476 @@ -const SafleId = require('@getsafle/safle-identity-wallet').SafleID; +const SafleId = require("@getsafle/safle-identity-wallet").SafleID; const { ethers } = require("ethers"); -const ObservableStore = require('obs-store'); -const Web3 = require('web3'); -const _ = require('lodash'); +const ObservableStore = require("obs-store"); +const Web3 = require("web3"); +const _ = require("lodash"); const { RateLimiter } = require("limiter"); -const helper = require('../utils/helper'); -const ERROR_MESSAGE = require('../constants/responses'); -const Chains = require('../chains'); -const Config = require('../config') -const Constants = require('../constants/index') +const helper = require("../utils/helper"); +const ERROR_MESSAGE = require("../constants/responses"); +const Chains = require("../chains"); +const Config = require("../config"); +const Constants = require("../constants/index"); const limiter = new RateLimiter({ - tokensPerInterval: Config.TOKEN_COUNT, - interval: Config.TOKEN_WINDOW, - fireImmediately: true - }); + tokensPerInterval: Config.TOKEN_COUNT, + interval: Config.TOKEN_WINDOW, + fireImmediately: true, +}); class Keyring { - - constructor() { - this.logs = new ObservableStore({ - logs: [], - }); - this.timeout = 0; + constructor() { + this.logs = new ObservableStore({ + logs: [], + }); + this.timeout = 0; + } + + async exportMnemonic(pin) { + if ( + typeof pin != "string" || + pin.match(/^[0-9]+$/) === null || + pin < 0 || + pin.length != 6 + ) { + return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; } - async exportMnemonic(pin) { - if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { - return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; - } - - const response = await this.validatePin(pin); - - if (response.response == false || response.error) { - return { error: ERROR_MESSAGE.INCORRECT_PIN }; - } - - const mnemonic = await helper.cryptography(this.decryptedVault.eth.private.encryptedMnemonic, pin, 'decryption'); - - const spaceCount = mnemonic.split(" ").length - 1; + const response = await this.validatePin(pin); - if(spaceCount !== 11) { - return { error: ERROR_MESSAGE.INCORRECT_PIN }; - } - - this.logs.getState().logs.push({ timestamp: Date.now(), action: 'export-mnemonic', vault: this.vault, chain: this.chain }); - - return { response: mnemonic } + if (response.response == false || response.error) { + return { error: ERROR_MESSAGE.INCORRECT_PIN }; } - async validatePin(pin) { - let trace=new Error().stack.split('\n') - trace=trace[trace.length-1].toString().split('/') + const mnemonic = await helper.cryptography( + this.decryptedVault.eth.private.encryptedMnemonic, + pin, + "decryption" + ); - if(this.timeout>Date.now() && !trace.includes(Constants.CONSTANT_ONE,Constants.CONSTANT_TWO,Constants.CONSTANT_THREE)){ - return{ error: `${ERROR_MESSAGE.REQUEST_BLOCKED} for ${((this.timeout-Date.now())/60000).toFixed(0)} minutes` } - } - let remainingRequests - if(!trace.includes('node_modules','jest-runner','build')){ - remainingRequests = await limiter.removeTokens(1); + const spaceCount = mnemonic.split(" ").length - 1; - } - - if (remainingRequests <= 0 && !trace.includes('node_modules','jest-runner','build')) { - this.timeout = Date.now() + Config.REQUEST_BLOCKED_TIMEOUT; - return { error: ERROR_MESSAGE.REQUEST_LIMIT_EXCEEDED }; - } else { - if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { - return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; - } - - let spaceCount; - - try { - const mnemonic = await helper.cryptography(this.decryptedVault.eth.private.encryptedMnemonic, pin, 'decryption'); - - spaceCount = mnemonic.split(" ").length - 1; - } catch (error) { - return { response: false }; - } - - if(spaceCount !== 11) { - return { response: false }; - } - - return { response: true }; - } + if (spaceCount !== 11) { + return { error: ERROR_MESSAGE.INCORRECT_PIN }; } - - async validateMnemonic(mnemonic, safleID, network, polygonRpcUrl) { - if (network !== 'mainnet' && network !== 'testnet') { - throw ERROR_MESSAGE.INVALID_NETWORK; - } - - const safle = new SafleId(network, polygonRpcUrl); - - let address; - - try { - const wallet = ethers.Wallet.fromMnemonic(mnemonic); - - address = wallet.address; - } catch (e) { - return { response: false }; - } - - const safleId = await safle.getSafleId(address); - - if (safleId === '' || safleId != safleID) { - return { response: false }; - } - - return { response: true }; + this.logs.getState().logs.push({ + timestamp: Date.now(), + action: "export-mnemonic", + vault: this.vault, + chain: this.chain, + }); + + return { response: mnemonic }; + } + + async validatePin(pin) { + let trace = new Error().stack.split("\n"); + trace = trace[trace.length - 1].toString().split("/"); + trace = trace[0]; + + if ( + this.timeout > Date.now() && + !trace.includes( + Constants.CONSTANT_ONE, + Constants.CONSTANT_TWO, + Constants.CONSTANT_THREE + ) + ) { + return { + error: `${ERROR_MESSAGE.REQUEST_BLOCKED} for ${( + (this.timeout - Date.now()) / + 60000 + ).toFixed(0)} minutes`, + }; + } + let remainingRequests; + if (!trace.includes("node_modules", "jest-runner", "build")) { + remainingRequests = await limiter.removeTokens(1); } - async getAccounts() { - - const decryptedVault = this.decryptedVault; - - let chain = (Chains.evmChains.hasOwnProperty(this.chain) || this.chain === 'ethereum') ? 'eth' : this.chain; - - let accounts = []; - - if (chain === 'eth') { - accounts.push(...decryptedVault.eth.public); - - const containsImported = (_.get(decryptedVault, 'importedWallets.evmChains') !== undefined) ? true : false; - - if (containsImported) { - accounts.push(...decryptedVault.importedWallets.evmChains.data); - } - - return { response: accounts }; - } - - if (decryptedVault[this.chain] === undefined && _.get(decryptedVault, `importedWallets.${this.chain}`) === undefined) { - return { response: accounts }; - } - - (decryptedVault[this.chain] !== undefined) ? accounts.push(...decryptedVault[this.chain].public) : null; - - const containsImported = (_.get(decryptedVault, `importedWallets.${this.chain}`) !== undefined) ? true : false; - - if (containsImported) { - accounts.push(...decryptedVault.importedWallets[this.chain].data); - } + if ( + remainingRequests <= 0 && + !trace.includes("node_modules", "jest-runner", "build") + ) { + this.timeout = Date.now() + Config.REQUEST_BLOCKED_TIMEOUT; + return { error: ERROR_MESSAGE.REQUEST_LIMIT_EXCEEDED }; + } else { + if ( + typeof pin != "string" || + pin.match(/^[0-9]+$/) === null || + pin < 0 || + pin.length != 6 + ) { + return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; + } + + let spaceCount; + + try { + const mnemonic = await helper.cryptography( + this.decryptedVault.eth.private.encryptedMnemonic, + pin, + "decryption" + ); + + spaceCount = mnemonic.split(" ").length - 1; + } catch (error) { + return { response: false }; + } + + if (spaceCount !== 11) { + return { response: false }; + } + + return { response: true }; + } + } - return { response: accounts }; + async validateMnemonic(mnemonic, safleID, network, polygonRpcUrl) { + if (network !== "mainnet" && network !== "testnet") { + throw ERROR_MESSAGE.INVALID_NETWORK; } - async exportPrivateKey(address, pin) { - if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { - return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; - } + const safle = new SafleId(network, polygonRpcUrl); - const response = await this.validatePin(pin); + let address; - if (response.response == false || response.error) { - return { error: ERROR_MESSAGE.INCORRECT_PIN }; - }; + try { + const wallet = ethers.Wallet.fromMnemonic(mnemonic); - const chain = (Chains.evmChains.hasOwnProperty(this.chain) || this.chain === 'ethereum') ? 'eth' : this.chain; - const importedChain = (chain === 'eth') ? 'evmChains' : chain; + address = wallet.address; + } catch (e) { + return { response: false }; + } - let isImportedAddress; + const safleId = await safle.getSafleId(address); - if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) !== undefined && this.decryptedVault.importedWallets[importedChain].data.some(element => element.address === address) == true) { - isImportedAddress = true; - } else if (this.decryptedVault[chain] !== undefined && this.decryptedVault[chain].public.some(element => element.address.toLowerCase() === address.toLowerCase()) == true) { - isImportedAddress = false; - } else { - return { error: ERROR_MESSAGE.ADDRESS_NOT_PRESENT }; - } + if (safleId === "" || safleId != safleID) { + return { response: false }; + } - if (isImportedAddress) { - const privateKey = (chain === 'eth') ? this.decryptedVault.importedWallets.evmChains.data.find(element => element.address === address).privateKey : this.decryptedVault.importedWallets[chain].data.find(element => element.address === address).privateKey; + return { response: true }; + } - let decryptedPrivKey = await helper.cryptography(privateKey, pin, 'decryption'); + async getAccounts() { + const decryptedVault = this.decryptedVault; - if (decryptedPrivKey.startsWith('0x')) { - decryptedPrivKey = decryptedPrivKey.slice(2) - } + let chain = + Chains.evmChains.hasOwnProperty(this.chain) || this.chain === "ethereum" + ? "eth" + : this.chain; - this.logs.getState().logs.push({ timestamp: Date.now(), action: 'export-private-key', vault: this.vault, chain: this.chain, address: address, isImportedAddress: isImportedAddress }); - return { response: { privateKey: decryptedPrivKey, isImported : isImportedAddress}} - } + let accounts = []; - if (chain === 'eth') { - const privateKey = await this.keyringInstance.exportAccount(address) + if (chain === "eth") { + accounts.push(...decryptedVault.eth.public); - this.logs.getState().logs.push({ timestamp: Date.now(), action: 'export-private-key', vault: this.vault, chain: this.chain, address: address, isImportedAddress: isImportedAddress }); - return { response: {privateKey, isImported : isImportedAddress} } - } + const containsImported = + _.get(decryptedVault, "importedWallets.evmChains") !== undefined + ? true + : false; - const { privateKey } = await this[chain].exportPrivateKey(address); + if (containsImported) { + accounts.push(...decryptedVault.importedWallets.evmChains.data); + } - this.logs.getState().logs.push({ timestamp: Date.now(), action: 'export-private-key', vault: this.vault, chain: this.chain, address: address, isImportedAddress: isImportedAddress }); - return { response: {privateKey, isImported : isImportedAddress} }; + return { response: accounts }; } - async addAccount(encryptionKey, pin) { - if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { - return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; - } - - const response = await this.validatePin(pin) - - if(response.response == false || response.error) { - return { error: ERROR_MESSAGE.INCORRECT_PIN }; - }; - - const { error } = helper.validateEncryptionKey(this.vault, JSON.stringify(encryptionKey)); - - if (error) { - return { error } - } - - const acc = await this.getAccounts(); - - if (Chains.evmChains.hasOwnProperty(this.chain) || this.chain === 'ethereum') { + if ( + decryptedVault[this.chain] === undefined && + _.get(decryptedVault, `importedWallets.${this.chain}`) === undefined + ) { + return { response: accounts }; + } - let labelPrefix = 'EVM' - const accounts = await this.keyringInstance.getAccounts(); + decryptedVault[this.chain] !== undefined + ? accounts.push(...decryptedVault[this.chain].public) + : null; - const keyring = await this.keyringInstance.getKeyringForAccount(accounts[0]); + const containsImported = + _.get(decryptedVault, `importedWallets.${this.chain}`) !== undefined + ? true + : false; - await this.keyringInstance.addNewAccount(keyring); + if (containsImported) { + accounts.push(...decryptedVault.importedWallets[this.chain].data); + } - const newAccount = await this.keyringInstance.getAccounts(); + return { response: accounts }; + } + + async exportPrivateKey(address, pin) { + if ( + typeof pin != "string" || + pin.match(/^[0-9]+$/) === null || + pin < 0 || + pin.length != 6 + ) { + return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; + } - this.decryptedVault.eth.public.push({ address: newAccount[newAccount.length - 1], isDeleted: false, isImported: false, label: `${labelPrefix} Wallet ${acc.response.length + 1}` }) - this.decryptedVault.eth.numberOfAccounts++; + const response = await this.validatePin(pin); - const encryptedVault = await helper.cryptography(JSON.stringify(this.decryptedVault), JSON.stringify(encryptionKey), 'encryption'); + if (response.response == false || response.error) { + return { error: ERROR_MESSAGE.INCORRECT_PIN }; + } - this.vault = encryptedVault; + const chain = + Chains.evmChains.hasOwnProperty(this.chain) || this.chain === "ethereum" + ? "eth" + : this.chain; + const importedChain = chain === "eth" ? "evmChains" : chain; + + let isImportedAddress; + + if ( + _.get(this.decryptedVault, `importedWallets.${importedChain}`) !== + undefined && + this.decryptedVault.importedWallets[importedChain].data.some( + (element) => element.address === address + ) == true + ) { + isImportedAddress = true; + } else if ( + this.decryptedVault[chain] !== undefined && + this.decryptedVault[chain].public.some( + (element) => element.address.toLowerCase() === address.toLowerCase() + ) == true + ) { + isImportedAddress = false; + } else { + return { error: ERROR_MESSAGE.ADDRESS_NOT_PRESENT }; + } - this.logs.getState().logs.push({ timestamp: Date.now(), action: 'add-account', vault: this.vault, chain: this.chain, address: newAccount[newAccount.length - 1] }); + if (isImportedAddress) { + const privateKey = + chain === "eth" + ? this.decryptedVault.importedWallets.evmChains.data.find( + (element) => element.address === address + ).privateKey + : this.decryptedVault.importedWallets[chain].data.find( + (element) => element.address === address + ).privateKey; + + let decryptedPrivKey = await helper.cryptography( + privateKey, + pin, + "decryption" + ); + + if (decryptedPrivKey.startsWith("0x")) { + decryptedPrivKey = decryptedPrivKey.slice(2); + } + + this.logs.getState().logs.push({ + timestamp: Date.now(), + action: "export-private-key", + vault: this.vault, + chain: this.chain, + address: address, + isImportedAddress: isImportedAddress, + }); + return { + response: { + privateKey: decryptedPrivKey, + isImported: isImportedAddress, + }, + }; + } - return { response: { vault: encryptedVault, address: newAccount[newAccount.length - 1] }}; - } + if (chain === "eth") { + const privateKey = await this.keyringInstance.exportAccount(address); + + this.logs.getState().logs.push({ + timestamp: Date.now(), + action: "export-private-key", + vault: this.vault, + chain: this.chain, + address: address, + isImportedAddress: isImportedAddress, + }); + return { response: { privateKey, isImported: isImportedAddress } }; + } - const { response: mnemonic } = await this.exportMnemonic(pin); + const { privateKey } = await this[chain].exportPrivateKey(address); + + this.logs.getState().logs.push({ + timestamp: Date.now(), + action: "export-private-key", + vault: this.vault, + chain: this.chain, + address: address, + isImportedAddress: isImportedAddress, + }); + return { response: { privateKey, isImported: isImportedAddress } }; + } + + async addAccount(encryptionKey, pin) { + if ( + typeof pin != "string" || + pin.match(/^[0-9]+$/) === null || + pin < 0 || + pin.length != 6 + ) { + return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; + } - let newAddress; + const response = await this.validatePin(pin); - let labelPrefix = Chains.nonEvmChains[this.chain] + if (response.response == false || response.error) { + return { error: ERROR_MESSAGE.INCORRECT_PIN }; + } - if (this[this.chain] === undefined) { - const keyringInstance = await helper.getCoinInstance(this.chain, mnemonic); + const { error } = helper.validateEncryptionKey( + this.vault, + JSON.stringify(encryptionKey) + ); - this[this.chain] = keyringInstance; + if (error) { + return { error }; + } - if(this.chain === "stacks") { - newAddress = (await this[this.chain].generateWallet()).address; - } else { - const { address } = await this[this.chain].addAccount(); + const acc = await this.getAccounts(); + + if ( + Chains.evmChains.hasOwnProperty(this.chain) || + this.chain === "ethereum" + ) { + let labelPrefix = "EVM"; + const accounts = await this.keyringInstance.getAccounts(); + + const keyring = await this.keyringInstance.getKeyringForAccount( + accounts[0] + ); + + await this.keyringInstance.addNewAccount(keyring); + + const newAccount = await this.keyringInstance.getAccounts(); + + this.decryptedVault.eth.public.push({ + address: newAccount[newAccount.length - 1], + isDeleted: false, + isImported: false, + label: `${labelPrefix} Wallet ${acc.response.length + 1}`, + }); + this.decryptedVault.eth.numberOfAccounts++; + + const encryptedVault = await helper.cryptography( + JSON.stringify(this.decryptedVault), + JSON.stringify(encryptionKey), + "encryption" + ); + + this.vault = encryptedVault; + + this.logs.getState().logs.push({ + timestamp: Date.now(), + action: "add-account", + vault: this.vault, + chain: this.chain, + address: newAccount[newAccount.length - 1], + }); + + return { + response: { + vault: encryptedVault, + address: newAccount[newAccount.length - 1], + }, + }; + } - newAddress = address; - } + const { response: mnemonic } = await this.exportMnemonic(pin); - const publicData = [ { address: newAddress, isDeleted: false, isImported: false, label: `${labelPrefix} Wallet ${acc.response ? acc.response.length + 1 : 1}` } ]; - this.decryptedVault[this.chain] = { public: publicData, numberOfAccounts: 1 }; - } else { - const { address } = await this[this.chain].addAccount(); + let newAddress; - newAddress = address; + let labelPrefix = Chains.nonEvmChains[this.chain]; - (this.decryptedVault[this.chain] === undefined) ? this.decryptedVault[this.chain] = { public: [ { address: newAddress, isDeleted: false, isImported: false, label: `${labelPrefix} Wallet ${acc.response.length + 1}` } ], numberOfAccounts: 1 } : this.decryptedVault[this.chain].public.push({ address: newAddress, isDeleted: false, isImported: false, label: `${labelPrefix} Wallet ${acc.response.length + 1}` }); - this.decryptedVault[this.chain].numberOfAccounts++; - } + if (this[this.chain] === undefined) { + const keyringInstance = await helper.getCoinInstance( + this.chain, + mnemonic + ); - const encryptedVault = await helper.cryptography(JSON.stringify(this.decryptedVault), JSON.stringify(encryptionKey), 'encryption'); + this[this.chain] = keyringInstance; - this.vault = encryptedVault; + if (this.chain === "stacks") { + newAddress = (await this[this.chain].generateWallet()).address; + } else { + const { address } = await this[this.chain].addAccount(); - this.logs.getState().logs.push({ timestamp: Date.now(), action: 'add-account', vault: this.vault, chain: this.chain, address: newAddress }); + newAddress = address; + } - return { response: { vault: encryptedVault, address: newAddress }}; + const publicData = [ + { + address: newAddress, + isDeleted: false, + isImported: false, + label: `${labelPrefix} Wallet ${ + acc.response ? acc.response.length + 1 : 1 + }`, + }, + ]; + this.decryptedVault[this.chain] = { + public: publicData, + numberOfAccounts: 1, + }; + } else { + const { address } = await this[this.chain].addAccount(); + + newAddress = address; + + this.decryptedVault[this.chain] === undefined + ? (this.decryptedVault[this.chain] = { + public: [ + { + address: newAddress, + isDeleted: false, + isImported: false, + label: `${labelPrefix} Wallet ${acc.response.length + 1}`, + }, + ], + numberOfAccounts: 1, + }) + : this.decryptedVault[this.chain].public.push({ + address: newAddress, + isDeleted: false, + isImported: false, + label: `${labelPrefix} Wallet ${acc.response.length + 1}`, + }); + this.decryptedVault[this.chain].numberOfAccounts++; } - async getFees(rawTx, rpcUrl) { - let address = rawTx.from - const chain = (Chains.evmChains.hasOwnProperty(this.chain) || this.chain === 'ethereum') ? 'eth' : this.chain; - const importedChain = (chain === 'eth') ? 'evmChains' : chain; - - let isImportedAddress; - - if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) !== undefined && this.decryptedVault.importedWallets[importedChain].data.some(element => element.address === address) == true) { - isImportedAddress = true; - } else if (this.decryptedVault[chain] !== undefined && this.decryptedVault[chain].public.some(element => element.address.toLowerCase() === address.toLowerCase()) == true) { - isImportedAddress = false; - } else { - return { error: ERROR_MESSAGE.ADDRESS_NOT_PRESENT }; - } - + const encryptedVault = await helper.cryptography( + JSON.stringify(this.decryptedVault), + JSON.stringify(encryptionKey), + "encryption" + ); + + this.vault = encryptedVault; + + this.logs.getState().logs.push({ + timestamp: Date.now(), + action: "add-account", + vault: this.vault, + chain: this.chain, + address: newAddress, + }); + + return { response: { vault: encryptedVault, address: newAddress } }; + } + + async getFees(rawTx, rpcUrl) { + let address = rawTx.from; + const chain = + Chains.evmChains.hasOwnProperty(this.chain) || this.chain === "ethereum" + ? "eth" + : this.chain; + const importedChain = chain === "eth" ? "evmChains" : chain; + + let isImportedAddress; + + if ( + _.get(this.decryptedVault, `importedWallets.${importedChain}`) !== + undefined && + this.decryptedVault.importedWallets[importedChain].data.some( + (element) => element.address === address + ) == true + ) { + isImportedAddress = true; + } else if ( + this.decryptedVault[chain] !== undefined && + this.decryptedVault[chain].public.some( + (element) => element.address.toLowerCase() === address.toLowerCase() + ) == true + ) { + isImportedAddress = false; + } else { + return { error: ERROR_MESSAGE.ADDRESS_NOT_PRESENT }; + } - if (this.chain === 'ethereum') { - const web3 = new Web3(new Web3.providers.HttpProvider(rpcUrl)); - const fees = await this.keyringInstance.getFees(rawTx, web3); - return { response: fees }; - } - - if (Chains.evmChains.hasOwnProperty(this.chain)) { - const web3 = new Web3(new Web3.providers.HttpProvider(rpcUrl)); - const keyringInstance = await helper.getCoinInstance(this.chain); + if (this.chain === "ethereum") { + const web3 = new Web3(new Web3.providers.HttpProvider(rpcUrl)); + const fees = await this.keyringInstance.getFees(rawTx, web3); + return { response: fees }; + } - const fees = await keyringInstance.getFees(rawTx, web3); + if (Chains.evmChains.hasOwnProperty(this.chain)) { + const web3 = new Web3(new Web3.providers.HttpProvider(rpcUrl)); + const keyringInstance = await helper.getCoinInstance(this.chain); - return { response: fees }; - } + const fees = await keyringInstance.getFees(rawTx, web3); - const fees = await this[this.chain].getFees(rawTx); - return { response: fees }; + return { response: fees }; } - async signMessage(address, data, pin, encryptionKey, rpcUrl = '') { - if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { - return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; - } + const fees = await this[this.chain].getFees(rawTx); + return { response: fees }; + } + + async signMessage(address, data, pin, encryptionKey, rpcUrl = "") { + if ( + typeof pin != "string" || + pin.match(/^[0-9]+$/) === null || + pin < 0 || + pin.length != 6 + ) { + return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; + } - const res = await this.validatePin(pin) + const res = await this.validatePin(pin); - if(res.response == false || res.error) { - return { error: ERROR_MESSAGE.INCORRECT_PIN }; - }; + if (res.response == false || res.error) { + return { error: ERROR_MESSAGE.INCORRECT_PIN }; + } - const err = helper.validateEncryptionKey(this.vault, JSON.stringify(encryptionKey)); - - if (err.error) { - return { error : err.error } - } + const err = helper.validateEncryptionKey( + this.vault, + JSON.stringify(encryptionKey) + ); - const { error, response } = await this.exportPrivateKey(address, pin); + if (err.error) { + return { error: err.error }; + } - if (error) { - return { error }; - } - - const {privateKey, isImported} = response - + const { error, response } = await this.exportPrivateKey(address, pin); - if (isImported) { - const web3 = new Web3(new Web3.providers.HttpProvider(rpcUrl)); + if (error) { + return { error }; + } - if (this.chain === 'ethereum') { + const { privateKey, isImported } = response; - const signedMessage = await this.keyringInstance.sign(data, privateKey, web3); + if (isImported) { + const web3 = new Web3(new Web3.providers.HttpProvider(rpcUrl)); - return { response: signedMessage.message }; - } + if (this.chain === "ethereum") { + const signedMessage = await this.keyringInstance.sign( + data, + privateKey, + web3 + ); - if (Chains.evmChains.hasOwnProperty(this.chain)) { - const keyringInstance = await helper.getCoinInstance(this.chain); + return { response: signedMessage.message }; + } - const signedMessage = await keyringInstance.sign(data, privateKey, web3); + if (Chains.evmChains.hasOwnProperty(this.chain)) { + const keyringInstance = await helper.getCoinInstance(this.chain); - return { response: signedMessage.message }; - } + const signedMessage = await keyringInstance.sign( + data, + privateKey, + web3 + ); - if (Chains?.[this.chain]){ - const { signedMessage } = await this[this.chain].signMessage(data, address, privateKey); - return { response: signedMessage }; - - } + return { response: signedMessage.message }; + } - return { error: ERROR_MESSAGE.UNSUPPORTED_NON_EVM_FUNCTIONALITY } - - } - else{ - const accounts = await this.getAccounts(); + if (Chains?.[this.chain]) { + const { signedMessage } = await this[this.chain].signMessage( + data, + address, + privateKey + ); + return { response: signedMessage }; + } - if(accounts.response.filter(e => e.address === address).length < 1) { - return { error: ERROR_MESSAGE.NONEXISTENT_KEYRING_ACCOUNT }; - } + return { error: ERROR_MESSAGE.UNSUPPORTED_NON_EVM_FUNCTIONALITY }; + } else { + const accounts = await this.getAccounts(); - if (Chains.evmChains.hasOwnProperty(this.chain) || this.chain === 'ethereum') { + if (accounts.response.filter((e) => e.address === address).length < 1) { + return { error: ERROR_MESSAGE.NONEXISTENT_KEYRING_ACCOUNT }; + } - const msgParams = { from: address, data: data }; + if ( + Chains.evmChains.hasOwnProperty(this.chain) || + this.chain === "ethereum" + ) { + const msgParams = { from: address, data: data }; - const signedMsg = await this.keyringInstance.signMessage(msgParams); + const signedMsg = await this.keyringInstance.signMessage(msgParams); - return { response: signedMsg }; - } + return { response: signedMsg }; + } - const { signedMessage } = await this[this.chain].signMessage(data, address); + const { signedMessage } = await this[this.chain].signMessage( + data, + address + ); - return { response: signedMessage }; - } - + return { response: signedMessage }; + } + } + + async signTransaction(rawTx, pin, rpcUrl) { + if ( + typeof pin != "string" || + pin.match(/^[0-9]+$/) === null || + pin < 0 || + pin.length != 6 + ) { + return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; } - async signTransaction(rawTx, pin, rpcUrl) { - if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { - return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; - } - - const res = await this.validatePin(pin) + const res = await this.validatePin(pin); - if(res.response == false || res.error) { - return { error: ERROR_MESSAGE.INCORRECT_PIN }; - }; - - const { error, response } = await this.exportPrivateKey(rawTx.from, pin); - - if (error) { - return { error }; - } - - const {privateKey, isImported} = response - - if (this.chain === 'ethereum') { - const web3 = new Web3(new Web3.providers.HttpProvider(rpcUrl)); - if(isImported) { - const signedTransaction = await this.keyringInstance.signTransaction(rawTx, web3, privateKey); - return { response: signedTransaction }; - } - else { - const signedTx = await this.keyringInstance.signTransaction(rawTx, web3); - return { response: signedTx }; - } - } - - if (Chains.evmChains.hasOwnProperty(this.chain)) { - const keyringInstance = await helper.getCoinInstance(this.chain); + if (res.response == false || res.error) { + return { error: ERROR_MESSAGE.INCORRECT_PIN }; + } - const signedTx = await keyringInstance.signTransaction(rawTx, privateKey); + const { error, response } = await this.exportPrivateKey(rawTx.from, pin); - return { response: signedTx }; - } + if (error) { + return { error }; + } - if(isImported) { - const { signedTransaction } = await this[this.chain].signTransaction(rawTx, privateKey); - return { response: signedTransaction }; - } - else{ - const { signedTransaction } = await this[this.chain].signTransaction(rawTx); - return { response: signedTransaction }; - } - + const { privateKey, isImported } = response; + if (this.chain === "ethereum") { + const web3 = new Web3(new Web3.providers.HttpProvider(rpcUrl)); + if (isImported) { + const signedTransaction = await this.keyringInstance.signTransaction( + rawTx, + web3, + privateKey + ); return { response: signedTransaction }; + } else { + const signedTx = await this.keyringInstance.signTransaction( + rawTx, + web3 + ); + return { response: signedTx }; + } } - async restoreKeyringState(vault, pin, encryptionKey) { - if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { - return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; - } - - const res = await this.validatePin(pin) + if (Chains.evmChains.hasOwnProperty(this.chain)) { + const keyringInstance = await helper.getCoinInstance(this.chain); - if(res.response == false || res.error) { - return { error: ERROR_MESSAGE.INCORRECT_PIN }; - }; - - const { decryptedVault, error } = helper.validateEncryptionKey(vault, JSON.stringify(encryptionKey)); - - if (error) { - return { error } - } + const signedTx = await keyringInstance.signTransaction(rawTx, privateKey); - this.decryptedVault = decryptedVault; + return { response: signedTx }; + } - this.vault = vault; + if (isImported) { + const { signedTransaction } = await this[this.chain].signTransaction( + rawTx, + privateKey + ); + return { response: signedTransaction }; + } else { + const { signedTransaction } = await this[this.chain].signTransaction( + rawTx + ); + return { response: signedTransaction }; + } - const activeChains = await this.getActiveChains(); + return { response: signedTransaction }; + } + + async restoreKeyringState(vault, pin, encryptionKey) { + if ( + typeof pin != "string" || + pin.match(/^[0-9]+$/) === null || + pin < 0 || + pin.length != 6 + ) { + return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; + } - const evmChainList = Object.keys(Chains.evmChains); + const res = await this.validatePin(pin); - const filteredChains = activeChains.response.filter(activeChains => !evmChainList.includes(activeChains.chain)); + if (res.response == false || res.error) { + return { error: ERROR_MESSAGE.INCORRECT_PIN }; + } - //generate other chain's keyring instance and add accounts to it as per decrypted vault - if (filteredChains.length > 0) { - filteredChains.forEach(async (chainData) => { - const { response: mnemonic } = await this.exportMnemonic(pin); + const { decryptedVault, error } = helper.validateEncryptionKey( + vault, + JSON.stringify(encryptionKey) + ); - const keyringInstance = await helper.getCoinInstance(chainData.chain.toLowerCase(), mnemonic); + if (error) { + return { error }; + } - this[chainData.chain.toLowerCase()] = keyringInstance; + this.decryptedVault = decryptedVault; - const numberOfAcc = this.decryptedVault[chainData.chain.toLowerCase()].numberOfAccounts; + this.vault = vault; - for (let i = 0; i < numberOfAcc; i++) { - if(chainData.chain.toLowerCase() === 'stacks' && i === 0) { - await this[chainData.chain].generateWallet() - } else { - await this[chainData.chain].addAccount(); - } - } - }) - } + const activeChains = await this.getActiveChains(); - this.logs.getState().logs.push({ timestamp: Date.now(), action: 'restore-keyring', vault: this.vault }); + const evmChainList = Object.keys(Chains.evmChains); - const mnemonic = await helper.cryptography(decryptedVault.eth.private.encryptedMnemonic, pin, 'decryption'); + const filteredChains = activeChains.response.filter( + (activeChains) => !evmChainList.includes(activeChains.chain) + ); - // clearing vault state and adding new accounts as per decrypted vault - const restoredVault = await this.keyringInstance.createNewVaultAndRestore(JSON.stringify(encryptionKey), mnemonic); + //generate other chain's keyring instance and add accounts to it as per decrypted vault + if (filteredChains.length > 0) { + filteredChains.forEach(async (chainData) => { + const { response: mnemonic } = await this.exportMnemonic(pin); - let numberOfAcc = this.decryptedVault.eth.numberOfAccounts; + const keyringInstance = await helper.getCoinInstance( + chainData.chain.toLowerCase(), + mnemonic + ); - let decryptedkeyring = await this.keyringInstance.getKeyringsByType(restoredVault.keyrings[0].type); + this[chainData.chain.toLowerCase()] = keyringInstance; - if(numberOfAcc > 1) { - for(let i=0; i < numberOfAcc-1; i++) { - await this.keyringInstance.addNewAccount(decryptedkeyring[0]); + const numberOfAcc = + this.decryptedVault[chainData.chain.toLowerCase()].numberOfAccounts; - decryptedkeyring[0].opts.numberOfAccounts = numberOfAcc; - } - } else { - decryptedkeyring[0].opts.numberOfAccounts = numberOfAcc; + for (let i = 0; i < numberOfAcc; i++) { + if (chainData.chain.toLowerCase() === "stacks" && i === 0) { + await this[chainData.chain].generateWallet(); + } else { + await this[chainData.chain].addAccount(); + } } - + }); } - async deleteAccount(encryptionKey, address, pin) { - if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { - return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; - } - - const response = await this.validatePin(pin); - - if(response.response == false || response.error) { - return { error: ERROR_MESSAGE.INCORRECT_PIN }; - }; - - const { error } = helper.validateEncryptionKey(this.vault, JSON.stringify(encryptionKey)); - - if (error) { - return { error } - } - - let chain = (Chains.evmChains.hasOwnProperty(this.chain) || this.chain === 'ethereum') ? 'eth' : this.chain; - - const importedChain = (chain === 'eth') ? 'evmChains' : chain; - - let objIndex; - - if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) !== undefined && this.decryptedVault.importedWallets[importedChain].data.some(element => element.address === address) == true) { - - objIndex = this.decryptedVault.importedWallets[importedChain].data.findIndex((obj => - obj.address === address - )); - - this.decryptedVault.importedWallets[importedChain].data[objIndex].isDeleted = true; - } else { - - objIndex = this.decryptedVault[chain].public.findIndex((obj => - obj.address === address - )); - - if(objIndex < 0) { - return { error: ERROR_MESSAGE.ADDRESS_NOT_PRESENT }; - } - - this.decryptedVault[chain].public[objIndex].isDeleted = true; - } + this.logs.getState().logs.push({ + timestamp: Date.now(), + action: "restore-keyring", + vault: this.vault, + }); + + const mnemonic = await helper.cryptography( + decryptedVault.eth.private.encryptedMnemonic, + pin, + "decryption" + ); + + // clearing vault state and adding new accounts as per decrypted vault + const restoredVault = await this.keyringInstance.createNewVaultAndRestore( + JSON.stringify(encryptionKey), + mnemonic + ); + + let numberOfAcc = this.decryptedVault.eth.numberOfAccounts; + + let decryptedkeyring = await this.keyringInstance.getKeyringsByType( + restoredVault.keyrings[0].type + ); + + if (numberOfAcc > 1) { + for (let i = 0; i < numberOfAcc - 1; i++) { + await this.keyringInstance.addNewAccount(decryptedkeyring[0]); + + decryptedkeyring[0].opts.numberOfAccounts = numberOfAcc; + } + } else { + decryptedkeyring[0].opts.numberOfAccounts = numberOfAcc; + } + } + + async deleteAccount(encryptionKey, address, pin) { + if ( + typeof pin != "string" || + pin.match(/^[0-9]+$/) === null || + pin < 0 || + pin.length != 6 + ) { + return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; + } - const vault = await helper.cryptography(JSON.stringify(this.decryptedVault), JSON.stringify(encryptionKey), 'encryption'); + const response = await this.validatePin(pin); - this.vault = vault; + if (response.response == false || response.error) { + return { error: ERROR_MESSAGE.INCORRECT_PIN }; + } - this.logs.getState().logs.push({ timestamp: Date.now(), action: 'delete-account', vault: this.vault, chain: this.chain, address: address }); + const { error } = helper.validateEncryptionKey( + this.vault, + JSON.stringify(encryptionKey) + ); - return { response: vault }; + if (error) { + return { error }; } - async restoreAccount(encryptionKey, address, pin) { - if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { - return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; - } + let chain = + Chains.evmChains.hasOwnProperty(this.chain) || this.chain === "ethereum" + ? "eth" + : this.chain; + + const importedChain = chain === "eth" ? "evmChains" : chain; + + let objIndex; + + if ( + _.get(this.decryptedVault, `importedWallets.${importedChain}`) !== + undefined && + this.decryptedVault.importedWallets[importedChain].data.some( + (element) => element.address === address + ) == true + ) { + objIndex = this.decryptedVault.importedWallets[ + importedChain + ].data.findIndex((obj) => obj.address === address); + + this.decryptedVault.importedWallets[importedChain].data[ + objIndex + ].isDeleted = true; + } else { + objIndex = this.decryptedVault[chain].public.findIndex( + (obj) => obj.address === address + ); + + if (objIndex < 0) { + return { error: ERROR_MESSAGE.ADDRESS_NOT_PRESENT }; + } + + this.decryptedVault[chain].public[objIndex].isDeleted = true; + } - const { response } = await this.validatePin(pin); + const vault = await helper.cryptography( + JSON.stringify(this.decryptedVault), + JSON.stringify(encryptionKey), + "encryption" + ); + + this.vault = vault; + + this.logs.getState().logs.push({ + timestamp: Date.now(), + action: "delete-account", + vault: this.vault, + chain: this.chain, + address: address, + }); + + return { response: vault }; + } + + async restoreAccount(encryptionKey, address, pin) { + if ( + typeof pin != "string" || + pin.match(/^[0-9]+$/) === null || + pin < 0 || + pin.length != 6 + ) { + return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; + } - if(response == false) { - return { error: ERROR_MESSAGE.INCORRECT_PIN }; - }; + const { response } = await this.validatePin(pin); - const { error } = helper.validateEncryptionKey(this.vault, JSON.stringify(encryptionKey)); - - if (error) { - return { error } - } + if (response == false) { + return { error: ERROR_MESSAGE.INCORRECT_PIN }; + } - let chain = (Chains.evmChains.hasOwnProperty(this.chain) || this.chain === 'ethereum') ? 'eth' : this.chain; + const { error } = helper.validateEncryptionKey( + this.vault, + JSON.stringify(encryptionKey) + ); - const importedChain = (chain === 'eth') ? 'evmChains' : chain; + if (error) { + return { error }; + } - let objIndex; + let chain = + Chains.evmChains.hasOwnProperty(this.chain) || this.chain === "ethereum" + ? "eth" + : this.chain; + + const importedChain = chain === "eth" ? "evmChains" : chain; + + let objIndex; + + if ( + _.get(this.decryptedVault, `importedWallets.${importedChain}`) !== + undefined && + this.decryptedVault.importedWallets[importedChain].data.some( + (element) => element.address === address + ) == true + ) { + objIndex = this.decryptedVault.importedWallets[ + importedChain + ].data.findIndex((obj) => obj.address === address); + + this.decryptedVault.importedWallets[importedChain].data[ + objIndex + ].isDeleted = false; + } else { + objIndex = this.decryptedVault[chain].public.findIndex( + (obj) => obj.address === address + ); + + if (objIndex < 0) { + return { error: ERROR_MESSAGE.ADDRESS_NOT_PRESENT }; + } + + this.decryptedVault[chain].public[objIndex].isDeleted = false; + } - if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) !== undefined && this.decryptedVault.importedWallets[importedChain].data.some(element => element.address === address) == true) { + const vault = await helper.cryptography( + JSON.stringify(this.decryptedVault), + JSON.stringify(encryptionKey), + "encryption", + this.encryptor, + this.isCustomEncryptor + ); + + this.vault = vault; + + this.logs.getState().logs.push({ + timestamp: Date.now(), + action: "restore-account", + vault: this.vault, + chain: this.chain, + address, + platform: this.platform, + }); + + return { response: vault }; + } + + async importWallet(privateKey, pin, encryptionKey) { + if ( + typeof pin != "string" || + pin.match(/^[0-9]+$/) === null || + pin < 0 || + pin.length != 6 + ) { + return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; + } - objIndex = this.decryptedVault.importedWallets[importedChain].data.findIndex((obj => - obj.address === address - )); + const response = await this.validatePin(pin); - this.decryptedVault.importedWallets[importedChain].data[objIndex].isDeleted = false; - } else { + if (response.response == false || response.error) { + return { error: ERROR_MESSAGE.INCORRECT_PIN }; + } - objIndex = this.decryptedVault[chain].public.findIndex((obj => - obj.address === address - )); + const { error } = helper.validateEncryptionKey( + this.vault, + JSON.stringify(encryptionKey) + ); - if(objIndex < 0) { - return { error: ERROR_MESSAGE.ADDRESS_NOT_PRESENT }; - } + if (error) { + return { error }; + } - this.decryptedVault[chain].public[objIndex].isDeleted = false; - } + if (privateKey.startsWith("0x")) { + privateKey = privateKey.slice(2); + } - const vault = await helper.cryptography(JSON.stringify(this.decryptedVault), JSON.stringify(encryptionKey), 'encryption', this.encryptor, this.isCustomEncryptor); + const encryptedPrivKey = await helper.cryptography( + privateKey, + pin, + "encryption" + ); - this.vault = vault; + let address; + let accounts; + let isDuplicateAddress; + let numOfAcc; - this.logs.getState().logs.push({ timestamp: Date.now(), action: 'restore-account', vault: this.vault, chain: this.chain, address, platform: this.platform }); + accounts = await this.getAccounts(); - return { response: vault }; + if (accounts.error) { + numOfAcc = 0; } - async importWallet(privateKey, pin, encryptionKey) { - if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { - return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; - } + if ( + Chains.evmChains.hasOwnProperty(this.chain) || + this.chain === "ethereum" + ) { + let labelPrefix = "EVM"; - const response = await this.validatePin(pin); + const keyringInstance = await helper.getCoinInstance(this.chain); - if(response.response == false || response.error) { - return { error: ERROR_MESSAGE.INCORRECT_PIN }; - }; + address = await keyringInstance.importWallet(privateKey); - const { error } = helper.validateEncryptionKey(this.vault, JSON.stringify(encryptionKey)); + if (!accounts.error) { + numOfAcc = accounts.response.length; - if (error) { - return { error } - } + accounts.response.forEach((element) => { + if (element.address === address) { + isDuplicateAddress = true; + } + }); - if (privateKey.startsWith('0x')) { - privateKey = privateKey.slice(2) + if (isDuplicateAddress) { + return { error: ERROR_MESSAGE.ADDRESS_ALREADY_PRESENT }; } + } + + if (this.decryptedVault.importedWallets === undefined) { + this.decryptedVault.importedWallets = { + evmChains: { + data: [ + { + address, + privateKey: encryptedPrivKey, + isDeleted: false, + isImported: true, + label: `${labelPrefix} Wallet ${numOfAcc + 1}`, + }, + ], + }, + }; + } else if (this.decryptedVault.importedWallets.evmChains === undefined) { + this.decryptedVault.importedWallets.evmChains = { + data: [ + { + address, + privateKey: encryptedPrivKey, + isDeleted: false, + isImported: true, + label: `${labelPrefix} Wallet ${numOfAcc + 1}`, + }, + ], + }; + } else { + this.decryptedVault.importedWallets.evmChains.data.push({ + address, + privateKey: encryptedPrivKey, + isDeleted: false, + isImported: true, + label: `${labelPrefix} Wallet ${numOfAcc + 1}`, + }); + } + } else { + let labelPrefix = Chains.nonEvmChains[this.chain]; + const { response: mnemonic } = await this.exportMnemonic(pin); + + if (this[this.chain] === undefined) { + const keyringInstance = await helper.getCoinInstance( + this.chain, + mnemonic + ); + + this[this.chain] = keyringInstance; + + address = await keyringInstance.importWallet(privateKey); + } else { + address = await this[this.chain].importWallet(privateKey); + } + + if (!accounts.error) { + accounts.response.forEach((element) => { + numOfAcc = accounts.response.length; + + if (element.address === address) { + isDuplicateAddress = true; + } + }); - const encryptedPrivKey = await helper.cryptography(privateKey, pin, 'encryption'); - - let address; - let accounts; - let isDuplicateAddress; - let numOfAcc; - - accounts = await this.getAccounts(); - - if (accounts.error) { - numOfAcc = 0; + if (isDuplicateAddress) { + return { error: ERROR_MESSAGE.ADDRESS_ALREADY_PRESENT }; } + } + + if (this.decryptedVault.importedWallets === undefined) { + let object = {}; + + const data = [ + { + address, + isDeleted: false, + isImported: true, + privateKey: encryptedPrivKey, + label: `${labelPrefix} Wallet ${numOfAcc + 1}`, + }, + ]; + + object[this.chain] = { data }; + this.decryptedVault.importedWallets = object; + } else if ( + this.decryptedVault.importedWallets[this.chain] === undefined + ) { + const data = [ + { + address, + isDeleted: false, + isImported: true, + privateKey: encryptedPrivKey, + label: `${labelPrefix} Wallet ${numOfAcc + 1}`, + }, + ]; + + this.decryptedVault.importedWallets[this.chain] = { data }; + } else { + this.decryptedVault.importedWallets[this.chain].data.push({ + address, + isDeleted: false, + isImported: true, + privateKey: encryptedPrivKey, + label: `${labelPrefix} Wallet ${numOfAcc + 1}`, + }); + } + } - if (Chains.evmChains.hasOwnProperty(this.chain) || this.chain === 'ethereum') { - - let labelPrefix = 'EVM' - - const keyringInstance = await helper.getCoinInstance(this.chain); - - address = await keyringInstance.importWallet(privateKey); - - if (!accounts.error) { - numOfAcc = accounts.response.length; - - accounts.response.forEach(element => { - if (element.address === address) { - isDuplicateAddress = true; - } - }); - - if (isDuplicateAddress) { - return { error: ERROR_MESSAGE.ADDRESS_ALREADY_PRESENT }; - } - } + const vault = await helper.cryptography( + JSON.stringify(this.decryptedVault), + JSON.stringify(encryptionKey), + "encryption" + ); - if (this.decryptedVault.importedWallets === undefined) { - this.decryptedVault.importedWallets = { evmChains: { data: [{ address, privateKey: encryptedPrivKey, isDeleted: false, isImported: true, label: `${labelPrefix} Wallet ${numOfAcc + 1}` }] } }; - } else if (this.decryptedVault.importedWallets.evmChains === undefined) { - this.decryptedVault.importedWallets.evmChains = { data: [{ address, privateKey: encryptedPrivKey, isDeleted: false, isImported: true, label: `${labelPrefix} Wallet ${numOfAcc + 1}` }] }; - } else { - this.decryptedVault.importedWallets.evmChains.data.push({ address, privateKey: encryptedPrivKey, isDeleted: false, isImported: true, label: `${labelPrefix} Wallet ${numOfAcc + 1}` }); - } - } else { - let labelPrefix = Chains.nonEvmChains[this.chain] - const { response: mnemonic } = await this.exportMnemonic(pin); - - if (this[this.chain] === undefined) { - const keyringInstance = await helper.getCoinInstance(this.chain, mnemonic); - - this[this.chain] = keyringInstance; - - address = await keyringInstance.importWallet(privateKey); - } else { - address = await this[this.chain].importWallet(privateKey); - } - - if (!accounts.error) { - accounts.response.forEach(element => { - numOfAcc = accounts.response.length; - - if (element.address === address) { - isDuplicateAddress = true; - } - }); - - if (isDuplicateAddress) { - return { error: ERROR_MESSAGE.ADDRESS_ALREADY_PRESENT }; - } - } - - if (this.decryptedVault.importedWallets === undefined) { - let object = {}; - - const data = [ { address, isDeleted: false, isImported: true, privateKey: encryptedPrivKey, label: `${labelPrefix} Wallet ${numOfAcc + 1}` } ]; - - object[this.chain] = { data }; - this.decryptedVault.importedWallets = object; - } else if (this.decryptedVault.importedWallets[this.chain] === undefined) { - const data = [ { address, isDeleted: false, isImported: true, privateKey: encryptedPrivKey, label: `${labelPrefix} Wallet ${numOfAcc + 1}` } ]; - - this.decryptedVault.importedWallets[this.chain] = { data }; - } else { - this.decryptedVault.importedWallets[this.chain].data.push({ address, isDeleted: false, isImported: true, privateKey: encryptedPrivKey, label: `${labelPrefix} Wallet ${numOfAcc + 1}` }); - } - } + this.vault = vault; - const vault = await helper.cryptography(JSON.stringify(this.decryptedVault), JSON.stringify(encryptionKey), 'encryption'); + this.logs.getState().logs.push({ + timestamp: Date.now(), + action: "import-wallet", + vault: this.vault, + chain: this.chain, + address, + }); - this.vault = vault; + return { response: { vault, address } }; + } - this.logs.getState().logs.push({ timestamp: Date.now(), action: 'import-wallet', vault: this.vault, chain: this.chain, address }); + async getActiveChains() { + let importedChains = []; + let generatedChains = []; - return { response: { vault, address } }; - } + this.decryptedVault.importedWallets !== undefined + ? importedChains.push(...Object.keys(this.decryptedVault.importedWallets)) + : null; - async getActiveChains() { - let importedChains = []; - let generatedChains = []; + generatedChains.push(...Object.keys(this.decryptedVault)); - (this.decryptedVault.importedWallets !== undefined) ? importedChains.push(...Object.keys(this.decryptedVault.importedWallets)) : null; + generatedChains.push(...Object.keys(Chains.evmChains)); - generatedChains.push(...Object.keys(this.decryptedVault)); + generatedChains.includes("importedWallets") + ? generatedChains.splice(generatedChains.indexOf("importedWallets"), 1) + : null; - generatedChains.push(...Object.keys(Chains.evmChains)); + generatedChains.includes("eth") + ? generatedChains.splice(generatedChains.indexOf("eth"), 1) + : null; - (generatedChains.includes('importedWallets')) ? generatedChains.splice(generatedChains.indexOf('importedWallets'), 1) : null; - - (generatedChains.includes('eth')) ? generatedChains.splice(generatedChains.indexOf('eth'), 1) : null; + importedChains.includes("evmChains") + ? importedChains.splice(importedChains.indexOf("evmChains"), 1) + : null; - (importedChains.includes('evmChains')) ? importedChains.splice(importedChains.indexOf('evmChains'), 1) : null; + const array = importedChains.concat(generatedChains); - const array = importedChains.concat(generatedChains); + const result = array.filter((item, pos) => array.indexOf(item) === pos); - const result = array.filter((item, pos) => array.indexOf(item) === pos); + let chains = []; - let chains = []; - - result.map(chain => { - if(Chains.evmChains.hasOwnProperty(chain)) { - chains.push({ - chain: chain, - symbol: Chains.evmChains[chain], - }); - } else { - chains.push({ - chain: chain, - symbol: Chains.nonEvmChains[chain], - }); - } + result.map((chain) => { + if (Chains.evmChains.hasOwnProperty(chain)) { + chains.push({ + chain: chain, + symbol: Chains.evmChains[chain], }); + } else { + chains.push({ + chain: chain, + symbol: Chains.nonEvmChains[chain], + }); + } + }); - return { response: chains }; - } - - async getVaultDetails(encryptionKey) { - - const { error } = helper.validateEncryptionKey(this.vault, JSON.stringify(encryptionKey)); - - if (error) { - return { error } - } - - const decryptedVault = this.decryptedVault; - - let accounts = { evm: { } }; - - const activeChains = await this.getActiveChains(); + return { response: chains }; + } - const evmChainList = Object.keys(Chains.evmChains); + async getVaultDetails(encryptionKey) { + const { error } = helper.validateEncryptionKey( + this.vault, + JSON.stringify(encryptionKey) + ); - accounts.evm.generatedWallets = ({ ...decryptedVault.eth.public }) + if (error) { + return { error }; + } - const containsImported = (_.get(decryptedVault, 'importedWallets.evmChains') !== undefined) ? true : false; + const decryptedVault = this.decryptedVault; - if (containsImported) { - accounts.evm.importedWallets = ({ ...decryptedVault.importedWallets.evmChains.data }); - } + let accounts = { evm: {} }; - const filteredChains = activeChains.response.filter(activeChains => !evmChainList.includes(activeChains.chain)); + const activeChains = await this.getActiveChains(); - let nonEvmAccs = []; + const evmChainList = Object.keys(Chains.evmChains); - filteredChains.forEach(async ({ chain }) => { - const containsGenerated = (decryptedVault[chain] !== undefined) ? true : false; - const containsImported = (_.get(decryptedVault, `importedWallets.${chain}`) !== undefined) ? true : false; + accounts.evm.generatedWallets = { ...decryptedVault.eth.public }; - if (containsGenerated) { - nonEvmAccs = decryptedVault[chain].public.filter((address) => address.isDeleted === false); - accounts[chain] = { generatedWallets: { ...decryptedVault[chain].public } }; - } - - if (containsImported) { - nonEvmAccs = decryptedVault.importedWallets[chain].data.filter((address) => address.isDeleted === false); - (accounts[chain] === undefined) ? accounts[chain] = { importedWallets: { ...decryptedVault.importedWallets[chain].data } } : accounts[chain].importedWallets = { ...decryptedVault.importedWallets[chain].data }; - } - }); + const containsImported = + _.get(decryptedVault, "importedWallets.evmChains") !== undefined + ? true + : false; - return { response: accounts }; + if (containsImported) { + accounts.evm.importedWallets = { + ...decryptedVault.importedWallets.evmChains.data, + }; } - async getBalance(address, rpcUrl) { - if (Chains.evmChains.hasOwnProperty(this.chain)) { - const web3 = new Web3(new Web3.providers.HttpProvider(rpcUrl)); + const filteredChains = activeChains.response.filter( + (activeChains) => !evmChainList.includes(activeChains.chain) + ); + + let nonEvmAccs = []; + + filteredChains.forEach(async ({ chain }) => { + const containsGenerated = + decryptedVault[chain] !== undefined ? true : false; + const containsImported = + _.get(decryptedVault, `importedWallets.${chain}`) !== undefined + ? true + : false; + + if (containsGenerated) { + nonEvmAccs = decryptedVault[chain].public.filter( + (address) => address.isDeleted === false + ); + accounts[chain] = { + generatedWallets: { ...decryptedVault[chain].public }, + }; + } + + if (containsImported) { + nonEvmAccs = decryptedVault.importedWallets[chain].data.filter( + (address) => address.isDeleted === false + ); + accounts[chain] === undefined + ? (accounts[chain] = { + importedWallets: { + ...decryptedVault.importedWallets[chain].data, + }, + }) + : (accounts[chain].importedWallets = { + ...decryptedVault.importedWallets[chain].data, + }); + } + }); - const balance = await Chains[this.chain].getBalance(address, web3); + return { response: accounts }; + } - return { response: balance }; - } + async getBalance(address, rpcUrl) { + if (Chains.evmChains.hasOwnProperty(this.chain)) { + const web3 = new Web3(new Web3.providers.HttpProvider(rpcUrl)); - const balance = await Chains[this.chain].getBalance(address); + const balance = await Chains[this.chain].getBalance(address, web3); - return { response: balance }; + return { response: balance }; } - async sign(data, address, pin, rpcUrl) { - if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { - return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; - } - - const res = await this.validatePin(pin) + const balance = await Chains[this.chain].getBalance(address); - if(res.response == false || res.error) { - return { error: ERROR_MESSAGE.INCORRECT_PIN }; - }; - - const { error, response } = await this.exportPrivateKey(address, pin); + return { response: balance }; + } - if (error) { - return { error }; - } - - const {privateKey, isImported} = response + async sign(data, address, pin, rpcUrl) { + if ( + typeof pin != "string" || + pin.match(/^[0-9]+$/) === null || + pin < 0 || + pin.length != 6 + ) { + return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; + } - const web3 = new Web3(new Web3.providers.HttpProvider(rpcUrl)); + const res = await this.validatePin(pin); - if (this.chain === 'ethereum') { + if (res.response == false || res.error) { + return { error: ERROR_MESSAGE.INCORRECT_PIN }; + } - const signedData = await this.keyringInstance.sign(data, privateKey, web3); + const { error, response } = await this.exportPrivateKey(address, pin); - return { response: signedData }; - } + if (error) { + return { error }; + } - if (Chains.evmChains.hasOwnProperty(this.chain)) { - const keyringInstance = await helper.getCoinInstance(this.chain); + const { privateKey, isImported } = response; - const signedData = await keyringInstance.sign(data, privateKey, web3); + const web3 = new Web3(new Web3.providers.HttpProvider(rpcUrl)); - return { response: signedData }; - } + if (this.chain === "ethereum") { + const signedData = await this.keyringInstance.sign( + data, + privateKey, + web3 + ); - return { error: ERROR_MESSAGE.UNSUPPORTED_NON_EVM_FUNCTIONALITY } + return { response: signedData }; } - async updateLabel(address, encryptionKey, newLabel, chainName) { - - const { error } = helper.validateEncryptionKey(this.vault, JSON.stringify(encryptionKey)); - - if (error) { - return { error } - } + if (Chains.evmChains.hasOwnProperty(this.chain)) { + const keyringInstance = await helper.getCoinInstance(this.chain); - if (newLabel === null || newLabel === undefined) { - return { error: ERROR_MESSAGE.INCORRECT_LABEL_TYPE }; - } + const signedData = await keyringInstance.sign(data, privateKey, web3); - let chain = (Chains.evmChains.hasOwnProperty(this.chain) || this.chain === 'ethereum') ? 'eth' : this.chain; + return { response: signedData }; + } - const importedChain = (chain === 'eth') ? 'evmChains' : chain; + return { error: ERROR_MESSAGE.UNSUPPORTED_NON_EVM_FUNCTIONALITY }; + } - let objIndex; + async updateLabel(address, encryptionKey, newLabel, chainName) { + const { error } = helper.validateEncryptionKey( + this.vault, + JSON.stringify(encryptionKey) + ); - if (_.get(this.decryptedVault, `importedWallets.${importedChain}`) !== undefined && this.decryptedVault.importedWallets[importedChain].data.some(element => element.address === address) == true) { + if (error) { + return { error }; + } - objIndex = this.decryptedVault.importedWallets[importedChain].data.findIndex((obj => - obj.address === address - )); + if (newLabel === null || newLabel === undefined) { + return { error: ERROR_MESSAGE.INCORRECT_LABEL_TYPE }; + } - this.decryptedVault.importedWallets[importedChain].data[objIndex].label = newLabel; + let chain = + Chains.evmChains.hasOwnProperty(this.chain) || this.chain === "ethereum" + ? "eth" + : this.chain; + + const importedChain = chain === "eth" ? "evmChains" : chain; + + let objIndex; + + if ( + _.get(this.decryptedVault, `importedWallets.${importedChain}`) !== + undefined && + this.decryptedVault.importedWallets[importedChain].data.some( + (element) => element.address === address + ) == true + ) { + objIndex = this.decryptedVault.importedWallets[ + importedChain + ].data.findIndex((obj) => obj.address === address); + + this.decryptedVault.importedWallets[importedChain].data[objIndex].label = + newLabel; + } else { + objIndex = this.decryptedVault[chain].public.findIndex( + (obj) => obj.address === address + ); + + if (objIndex < 0) { + return { error: ERROR_MESSAGE.ADDRESS_NOT_PRESENT }; + } + if ( + typeof this.decryptedVault[chain].public[objIndex].label === "string" || + this.decryptedVault[chain].public[objIndex].label instanceof String + ) { + if (chain === "eth") { + const chains = Object.keys(Chains.evmChains); + let obj = chains.reduce(function (acc, curr) { + acc[curr] = newLabel; + return acc; + }, {}); + this.decryptedVault[chain].public[objIndex].label = obj; } else { - - objIndex = this.decryptedVault[chain].public.findIndex((obj => - obj.address === address - )); - - if(objIndex < 0) { - return { error: ERROR_MESSAGE.ADDRESS_NOT_PRESENT }; - } - if (typeof this.decryptedVault[chain].public[objIndex].label === 'string' || this.decryptedVault[chain].public[objIndex].label instanceof String){ - if(chain === 'eth') { - const chains = Object.keys(Chains.evmChains); - let obj = chains.reduce(function(acc, curr) { - acc[curr] = newLabel; - return acc; - }, {}); - this.decryptedVault[chain].public[objIndex].label = obj; - } - else { - this.decryptedVault[chain].public[objIndex].label = newLabel; - } - } - else{ - (chain === 'eth') ? this.decryptedVault[chain].public[objIndex].label[chainName] = newLabel : this.decryptedVault[chain].public[objIndex].label = newLabel; + this.decryptedVault[chain].public[objIndex].label = newLabel; } + } else { + chain === "eth" + ? (this.decryptedVault[chain].public[objIndex].label[chainName] = + newLabel) + : (this.decryptedVault[chain].public[objIndex].label = newLabel); + } } - const vault = await helper.cryptography(JSON.stringify(this.decryptedVault), JSON.stringify(encryptionKey), 'encryption'); - - this.vault = vault; + const vault = await helper.cryptography( + JSON.stringify(this.decryptedVault), + JSON.stringify(encryptionKey), + "encryption" + ); - this.logs.getState().logs.push({ timestamp: Date.now(), action: 'update-label', vault: this.vault, chain: this.chain, address: address }); - - return { response: vault }; - } + this.vault = vault; - async resetAllImportedWallets(currentPin, newPin) { + this.logs.getState().logs.push({ + timestamp: Date.now(), + action: "update-label", + vault: this.vault, + chain: this.chain, + address: address, + }); - if (_.get(this.decryptedVault, `importedWallets`) === undefined) { - return null; - } + return { response: vault }; + } - let importedChains = Object.keys(this.decryptedVault.importedWallets) - - for (let importedChain of importedChains) - { - let data = this.decryptedVault.importedWallets[importedChain].data - for(let i = 0; i < data.length; i++) { - let decryptedPrivKey = await helper.cryptography(data[i].privateKey, currentPin, 'decryption'); - let encryptedPrivKey = await helper.cryptography(decryptedPrivKey, newPin, 'encryption'); - this.decryptedVault.importedWallets[importedChain].data[i].privateKey = encryptedPrivKey - - } - } - -} + async resetAllImportedWallets(currentPin, newPin) { + if (_.get(this.decryptedVault, `importedWallets`) === undefined) { + return null; + } + let importedChains = Object.keys(this.decryptedVault.importedWallets); + + for (let importedChain of importedChains) { + let data = this.decryptedVault.importedWallets[importedChain].data; + for (let i = 0; i < data.length; i++) { + let decryptedPrivKey = await helper.cryptography( + data[i].privateKey, + currentPin, + "decryption" + ); + let encryptedPrivKey = await helper.cryptography( + decryptedPrivKey, + newPin, + "encryption" + ); + this.decryptedVault.importedWallets[importedChain].data[i].privateKey = + encryptedPrivKey; + } + } + } - async changePin(currentPin, newPin, encryptionKey) { - - if (typeof(currentPin) != 'string' || currentPin < 0) { - throw ERROR_MESSAGE.INCORRECT_PIN_TYPE - } + async changePin(currentPin, newPin, encryptionKey) { + if (typeof currentPin != "string" || currentPin < 0) { + throw ERROR_MESSAGE.INCORRECT_PIN_TYPE; + } - if (typeof(newPin) != 'string' || newPin < 0) { - throw ERROR_MESSAGE.INCORRECT_PIN_TYPE - } + if (typeof newPin != "string" || newPin < 0) { + throw ERROR_MESSAGE.INCORRECT_PIN_TYPE; + } - const response = await this.validatePin(currentPin); + const response = await this.validatePin(currentPin); - if (response.response == false || response.error) { - return { error: ERROR_MESSAGE.INCORRECT_PIN }; - }; + if (response.response == false || response.error) { + return { error: ERROR_MESSAGE.INCORRECT_PIN }; + } - const err = helper.validateEncryptionKey(this.vault, JSON.stringify(encryptionKey)); - - if (err.error) { - return { error : err.error } - } + const err = helper.validateEncryptionKey( + this.vault, + JSON.stringify(encryptionKey) + ); - const { error, response: mnemonic }= await this.exportMnemonic(currentPin); + if (err.error) { + return { error: err.error }; + } - if (error) { - return { error: ERROR_MESSAGE.INCORRECT_CURRENT_PIN }; - }; + const { error, response: mnemonic } = await this.exportMnemonic(currentPin); - const privData = await helper.generatePrivData(mnemonic, newPin); + if (error) { + return { error: ERROR_MESSAGE.INCORRECT_CURRENT_PIN }; + } - this.decryptedVault.eth.private = privData; + const privData = await helper.generatePrivData(mnemonic, newPin); - await this.resetAllImportedWallets(currentPin, newPin); + this.decryptedVault.eth.private = privData; - const vault = await helper.cryptography(JSON.stringify(this.decryptedVault), JSON.stringify(encryptionKey), 'encryption'); + await this.resetAllImportedWallets(currentPin, newPin); - this.vault = vault; + const vault = await helper.cryptography( + JSON.stringify(this.decryptedVault), + JSON.stringify(encryptionKey), + "encryption" + ); - this.logs.getState().logs.push({ timestamp: Date.now(), action: 'change-pin', vault: this.vault }); + this.vault = vault; - return { response: vault }; - } + this.logs.getState().logs.push({ + timestamp: Date.now(), + action: "change-pin", + vault: this.vault, + }); - getLogs() { - return this.logs.getState(); - } + return { response: vault }; + } + getLogs() { + return this.logs.getState(); + } } -module.exports = Keyring; \ No newline at end of file +module.exports = Keyring; diff --git a/src/lib/test/keyring.test.js b/src/lib/test/keyring.test.js index a004b88..d257c8f 100644 --- a/src/lib/test/keyring.test.js +++ b/src/lib/test/keyring.test.js @@ -1,1395 +1,1072 @@ -jest.setTimeout(30000) - - -const { before } = require('lodash') -let KeyRing = require('../keyring') -let Vault = require('../vault') -const Web3 = require('web3') -const bufView = [48, 0, 236, 187, 187, 172, 177, 90, 255, 184, 9, 116, 142, 96, 197, 158, 87, 35, 26, 101, 187, 30, 116, 138, 50, 131, 166, 50, 51, 197, 198, 83, 238, 167, 105, 178, 182, 108, 174, 199, 124, 141, 155, 73, 21, 85, 81, 109, 78, 233, 152, 108, 242, 238, 192, 31, 147, 86, 174, 195, 55, 229, 4, 36]; -let phrase="fun rough treat scan glimpse region century purpose expire video remind second" -let pin="696969" -let result -let vault =new Vault({}) -let vaultAddress -let privateKey -let accAddress -let privateKeyImp = "0x7a9633b8103fec11c9e855a6b6c8c072e9af311a69b92ab0ad8186b1fb57371f" -let impAccAddress - - -let chains -const ethUrl = 'https://mainnet.infura.io/v3/6145d532688844c4b6db32574d90e19f'; -const polygonRpcUrl = 'https://polygon-testnet.public.blastapi.io'; -const bscRpcUrl = 'https://rpc.ankr.com/bsc'; -beforeAll(async() => { - - result = await vault.generateVault(bufView,pin,phrase) - vaultAddress=result.response - await vault.getAccounts(bufView); - +jest.setTimeout(30000); + +const { before } = require("lodash"); +let KeyRing = require("../keyring"); +let Vault = require("../vault"); +const Web3 = require("web3"); +const bufView = [ + 48, 0, 236, 187, 187, 172, 177, 90, 255, 184, 9, 116, 142, 96, 197, 158, 87, + 35, 26, 101, 187, 30, 116, 138, 50, 131, 166, 50, 51, 197, 198, 83, 238, 167, + 105, 178, 182, 108, 174, 199, 124, 141, 155, 73, 21, 85, 81, 109, 78, 233, + 152, 108, 242, 238, 192, 31, 147, 86, 174, 195, 55, 229, 4, 36, +]; +let phrase = + "fun rough treat scan glimpse region century purpose expire video remind second"; +let pin = "696969"; +let result; +let vault = new Vault({}); +let vaultAddress; +let privateKey; +let accAddress; +let privateKeyImp = + "0x7a9633b8103fec11c9e855a6b6c8c072e9af311a69b92ab0ad8186b1fb57371f"; +let impAccAddress; + +let chains; +const ethUrl = "https://mainnet.infura.io/v3/6145d532688844c4b6db32574d90e19f"; +const polygonRpcUrl = "https://polygon-testnet.public.blastapi.io"; +const bscRpcUrl = "https://rpc.ankr.com/bsc"; +beforeAll(async () => { + result = await vault.generateVault(bufView, pin, phrase); + vaultAddress = result.response; + await vault.getAccounts(bufView); }); -describe('exportMnemonic' , ()=>{ - - test('Valid exportMnemonic/invalid pin' , async()=>{ - - let result = await new KeyRing().exportMnemonic(1111) - expect(result.error).toBe('Wrong pin type, format or length') - }) - test('Valid exportMnemonic/INCORRECT_PIN' , async()=>{ - - let result = await new KeyRing().exportMnemonic("111111") - expect(result.error).toBe('Incorrect pin') - }) - - test('Valid exportMnemonic/INCORRECT_PIN_TYPE' , async()=>{ - - try{ - - let resultResp = await vault.exportMnemonic("srdtfyu") - - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - } - - }) - - - test('Valid exportMnemonic' , async()=>{ - - let resultResp = await vault.exportMnemonic(pin) - expect(resultResp).toHaveProperty('response') - - - - }) - - -}) - - -describe('validatePin' , ()=>{ - - - - test('validatePin/invalid string' , async()=>{ - - try{ - - let result = await new KeyRing().validatePin("234rewtetyrjtuky") - - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - } - - }) - - test('validatePin/empty pin' , async()=>{ - - try{ - - let result = await new KeyRing().validatePin(null) - - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - } - - }) - - test('validatePin/valid pin' , async()=>{ - let result = await vault.validatePin(pin) - expect({response:true}).toMatchObject(result) - - }) - - - -}) - -describe('addAccount' , ()=>{ - - test('addAccount/valid' , async()=>{ - let result = await vault.addAccount(bufView,pin) - accAddress=result.response.address - - expect(result.response).toHaveProperty('address') - - }) - - test('addAccount/empty encryption key' , async()=>{ - try{ - let result = await vault.addAccount(null,pin) - } - catch(e){ - expect(e.message).toBe("Incorrect Encryption Key or vault string") - } - - }) - - test('addAccount/empty pin' , async()=>{ - - let result = await vault.addAccount(bufView,null) - expect(result.error).toBe("Wrong pin type, format or length") - - - - - - }) - test('addAccount/invalid pin' , async()=>{ - - let result = await vault.addAccount(bufView,123333) - expect(result.error).toBe("Wrong pin type, format or length") - - - - }) - test('addAccount/incorrect pin' , async()=>{ - - let result = await vault.addAccount(bufView,"123333") - expect(result.error).toBe("Incorrect pin") - - - - }) - test('addAccount/both param empty' , async()=>{ - - let result = await vault.addAccount("","") - expect(result.error).toBe("Wrong pin type, format or length") - - - - - }) - - - - -}) - -describe('exportPrivateKey' , ()=>{ - - test('exportPrivateKey/valid' , async()=>{ - let result = await vault.exportPrivateKey(accAddress,pin) - privateKey=result.response.privateKey - - - }) - - test('exportPrivateKey/empty accAddress' , async()=>{ - - try{ - let result = await vault.exportPrivateKey(null,pin) - } - catch(e){ - expect(e.message).toBe("Cannot read properties of null (reading 'toLowerCase')") - } - - - }) - - test('exportPrivateKey/empty pin' , async()=>{ - - let result = await vault.exportPrivateKey(accAddress,null) - expect(result.error).toBe("Wrong pin type, format or length") - - }) - - test('exportPrivateKey/both empty' , async()=>{ - - let result = await vault.exportPrivateKey(null,null) - expect(result.error).toBe("Wrong pin type, format or length") - - }) - test('exportPrivateKey/incorrect pin' , async()=>{ - - let result = await vault.exportPrivateKey(accAddress,"111111") - expect(result.error).toBe("Incorrect pin") - - }) - -}) - - -describe('importWallet' , ()=>{ - - test('importWallet/valid import' , async()=>{ - let result = await vault.importWallet("0x"+privateKeyImp,pin,bufView) - impAccAddress = result.response.address - expect(result).toHaveProperty('response.address') - - }) - - - test('importWallet/valid address exists already' , async()=>{ - let result = await vault.importWallet("0x"+privateKey,pin,bufView) - expect(result.error).toBe('This address is already present in the vault') - - - }) - - test('importWallet/empty private key' , async()=>{ - try{ - let result = await vault.importWallet(null,pin,bufView) - } - catch(e){ - expect(e.message).toBe("Cannot read properties of null (reading 'startsWith')") - } - - - - }) - - test('importWallet/empty pin' , async()=>{ - - let result = await vault.importWallet("0x"+privateKey,null,bufView) - expect(result.error).toBe("Wrong pin type, format or length") - - - }) - test('importWallet/incorrect pin' , async()=>{ - - let result = await vault.importWallet("0x"+privateKey,"111111",bufView) - expect(result.error).toBe("Incorrect pin") - - - }) - test('importWallet/empty encryption key' , async()=>{ - - let result = await vault.importWallet("0x"+privateKey,pin,null) - expect(result.error).toBe("Incorrect Encryption Key or vault string") - - }) - - test('importWallet/empty all params' , async()=>{ - - let result = await vault.importWallet(null,null,null) - expect(result.error).toBe("Wrong pin type, format or length") - - - - - - - }) - - - -}) - -describe('getActiveChains',()=>{ - - test('getActiveChains' , async()=>{ - let result = await vault.getActiveChains() - chains=result.response - expect({ +describe("exportMnemonic", () => { + test("Valid exportMnemonic/invalid pin", async () => { + let result = await new KeyRing().exportMnemonic(1111); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + test("Valid exportMnemonic/INCORRECT_PIN", async () => { + let result = await new KeyRing().exportMnemonic("111111"); + expect(result.error).toBe("Incorrect pin"); + }); + + test("Valid exportMnemonic/INCORRECT_PIN_TYPE", async () => { + try { + let resultResp = await vault.exportMnemonic("srdtfyu"); + } catch (e) { + expect(e).toBe("Wrong pin type, format or length"); + } + }); + + test("Valid exportMnemonic", async () => { + let resultResp = await vault.exportMnemonic(pin); + expect(resultResp).toHaveProperty("response"); + }); +}); + +describe("validatePin", () => { + test("validatePin/invalid string", async () => { + try { + let result = await new KeyRing().validatePin("234rewtetyrjtuky"); + } catch (e) { + expect(e).toBe("Wrong pin type, format or length"); + } + }); + + test("validatePin/empty pin", async () => { + try { + let result = await new KeyRing().validatePin(null); + } catch (e) { + expect(e).toBe("Wrong pin type, format or length"); + } + }); + + test("validatePin/valid pin", async () => { + let result = await vault.validatePin(pin); + expect({ response: true }).toMatchObject(result); + }); +}); + +describe("addAccount", () => { + test("addAccount/valid", async () => { + let result = await vault.addAccount(bufView, pin); + accAddress = result.response.address; + + expect(result.response).toHaveProperty("address"); + }); + + test("addAccount/empty encryption key", async () => { + try { + let result = await vault.addAccount(null, pin); + } catch (e) { + expect(e.message).toBe("Incorrect Encryption Key or vault string"); + } + }); + + test("addAccount/empty pin", async () => { + let result = await vault.addAccount(bufView, null); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + test("addAccount/invalid pin", async () => { + let result = await vault.addAccount(bufView, 123333); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + test("addAccount/incorrect pin", async () => { + let result = await vault.addAccount(bufView, "123333"); + expect(result.error).toBe("Incorrect pin"); + }); + test("addAccount/both param empty", async () => { + let result = await vault.addAccount("", ""); + expect(result.error).toBe("Wrong pin type, format or length"); + }); +}); + +describe("exportPrivateKey", () => { + test("exportPrivateKey/valid", async () => { + let result = await vault.exportPrivateKey(accAddress, pin); + privateKey = result.response.privateKey; + }); + + test("exportPrivateKey/empty accAddress", async () => { + try { + let result = await vault.exportPrivateKey(null, pin); + } catch (e) { + expect(e.message).toBe( + "Cannot read properties of null (reading 'toLowerCase')" + ); + } + }); + + test("exportPrivateKey/empty pin", async () => { + let result = await vault.exportPrivateKey(accAddress, null); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + + test("exportPrivateKey/both empty", async () => { + let result = await vault.exportPrivateKey(null, null); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + test("exportPrivateKey/incorrect pin", async () => { + let result = await vault.exportPrivateKey(accAddress, "111111"); + expect(result.error).toBe("Incorrect pin"); + }); +}); + +describe("importWallet", () => { + test("importWallet/valid import", async () => { + let result = await vault.importWallet("0x" + privateKeyImp, pin, bufView); + impAccAddress = result.response.address; + expect(result).toHaveProperty("response.address"); + }); + + test("importWallet/valid address exists already", async () => { + let result = await vault.importWallet("0x" + privateKey, pin, bufView); + expect(result.error).toBe("This address is already present in the vault"); + }); + + test("importWallet/empty private key", async () => { + try { + let result = await vault.importWallet(null, pin, bufView); + } catch (e) { + expect(e.message).toBe( + "Cannot read properties of null (reading 'startsWith')" + ); + } + }); + + test("importWallet/empty pin", async () => { + let result = await vault.importWallet("0x" + privateKey, null, bufView); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + test("importWallet/incorrect pin", async () => { + let result = await vault.importWallet("0x" + privateKey, "111111", bufView); + expect(result.error).toBe("Incorrect pin"); + }); + test("importWallet/empty encryption key", async () => { + let result = await vault.importWallet("0x" + privateKey, pin, null); + expect(result.error).toBe("Incorrect Encryption Key or vault string"); + }); + + test("importWallet/empty all params", async () => { + let result = await vault.importWallet(null, null, null); + expect(result.error).toBe("Wrong pin type, format or length"); + }); +}); + +describe("getActiveChains", () => { + test("getActiveChains", async () => { + let result = await vault.getActiveChains(); + chains = result.response; + expect({ response: [ - { chain: 'bitcoin', symbol: 'BTC' }, - { chain: 'stacks', symbol: 'STX' }, - { chain: 'solana', symbol: 'SOL' }, - { chain: 'ethereum', symbol: 'ETH' }, - { chain: 'bsc', symbol: 'BSC' }, - { chain: 'polygon', symbol: 'MATIC' }, - { chain: 'optimism', symbol: 'OP' }, - { chain: 'arbitrum', symbol: 'ARB' }, - { chain: 'mantle', symbol: 'MNT' }, - { chain: 'velas', symbol: 'VLX' }, - { chain: 'avalanche', symbol: 'AVAX' }, - { chain: 'base', symbol: 'BASE' }, - { chain: 'zkEVM', symbol: 'ZKEVM' }, - { chain: 'bevm', symbol: 'BTC' } - ] - }).toMatchObject(result) - - }) -}) - -describe('deleteAccount',()=>{ - test('deleteAccount/valid generated acc' , async()=>{ - - let result = await vault.deleteAccount(bufView,accAddress,pin) - expect(result).toHaveProperty('response') - - }) - - test('deleteAccount/valid imported acc' , async()=>{ - - let result = await vault.deleteAccount(bufView,impAccAddress,pin) - expect(result).toHaveProperty('response') - - }) - - - test('deleteAccount/empty encryption key' , async()=>{ - try{ - let result = await vault.deleteAccount(null,accAddress,pin) - } - catch(e){ - expect(e.message).toBe("Incorrect Encryption Key or vault string") - } - - - }) - - test('deleteAccount/invalid encryption key' , async()=>{ - try{ - let result = await vault.deleteAccount(null,accAddress,pin) - } - catch(e){ - expect(e.message).toBe("Incorrect Encryption Key or vault string") - } - - - }) - test('deleteAccount/empty address' , async()=>{ - - let result = await vault.deleteAccount(bufView,null,pin) - expect(result.error).toBe('This address is not present in the vault') - - - }) - test('deleteAccount/invalid address' , async()=>{ - - let result = await vault.deleteAccount(bufView,"rerwgtehry",pin) - expect(result.error).toBe('This address is not present in the vault') - - - }) - test('deleteAccount/empty pin' , async()=>{ - - let result = await vault.deleteAccount(bufView,accAddress,null) - expect(result.error).toBe("Wrong pin type, format or length") - - - - - - }) - test('deleteAccount/invalid pin' , async()=>{ - - let result = await vault.deleteAccount(bufView,accAddress,"efwe") - expect(result.error).toBe("Wrong pin type, format or length") - - - }) - test('deleteAccount/incorrect pin' , async()=>{ - - let result = await vault.deleteAccount(bufView,accAddress,"111111") - expect(result.error).toBe("Incorrect pin") - - - }) - test('deleteAccount/all params empty' , async()=>{ - try{ - let result = await vault.deleteAccount(null,null,null) - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - - } - - - }) -}) - - -describe('restoreAccount', ()=> { - - test('restoreAccount/valid generated acc' , async()=>{ - - let result = await vault.restoreAccount(bufView,accAddress,pin) - expect(result).toHaveProperty('response') - - }) - - test('restoreAccount/valid imported acc' , async()=>{ - - let result = await vault.restoreAccount(bufView,impAccAddress,pin) - expect(result).toHaveProperty('response') - - }) - - - test('restoreAccount/empty encryption key' , async()=>{ - try{ - let result = await vault.restoreAccount(null,accAddress,pin) - } - catch(e){ - expect(e.message).toBe("Incorrect Encryption Key or vault string") - } - - - }) - - test('restoreAccount/invalid encryption key' , async()=>{ - try{ - let result = await vault.restoreAccount(null,accAddress,pin) - } - catch(e){ - expect(e.message).toBe("Incorrect Encryption Key or vault string") - } - - - }) - test('restoreAccount/empty address' , async()=>{ - - let result = await vault.restoreAccount(bufView,null,pin) - expect(result.error).toBe('This address is not present in the vault') - - - }) - test('restoreAccount/invalid address' , async()=>{ - - let result = await vault.restoreAccount(bufView,"rerwgtehry",pin) - expect(result.error).toBe('This address is not present in the vault') - - - }) - test('restoreAccount/empty pin' , async()=>{ - - try { - let result = await vault.restoreAccount(bufView,accAddress,null) - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - } - - - }) - test('restoreAccount/invalid pin' , async()=>{ - - try { - let result = await vault.restoreAccount(bufView,accAddress,"efwe") - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - } - - - }) - test('restoreAccount/incorrect pin' , async()=>{ - - let result = await vault.restoreAccount(bufView,accAddress,"111111") - expect(result.error).toBe("Incorrect pin") - - - }) - test('restoreAccount/all params empty' , async()=>{ - try{ - let result = await vault.restoreAccount(null,null,null) - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - - } - - - }) -}) - - - -describe('restoreKeyringState',()=>{ - test('restoreKeyringState/valid' , async()=>{ - - - await vault.restoreKeyringState(vaultAddress,pin,bufView) - expect(result).toHaveProperty('response') - - - }) - - test('restoreKeyringState/empty vault address' , async()=>{ - try{ - let result= await vault.restoreKeyringState(null,pin,bufView) - - } - catch(e){ - expect(e.message).toBe("Cannot read properties of null (reading 'salt')") - } - - - }) - - test('restoreKeyringState/invalid vault address' , async()=>{ - - let result= await vault.restoreKeyringState("abc",pin,bufView) - expect(result.error).toBe('Incorrect Encryption Key or vault string') - - - }) - - test('restoreKeyringState/empty pin' , async()=>{ - - let result= await vault.restoreKeyringState(vaultAddress,null,bufView) - expect(result.error).toBe("Wrong pin type, format or length") - - - - - - }) - - test('restoreKeyringState/invalid pin' , async()=>{ - - let result= await vault.restoreKeyringState(vaultAddress,"avevr",bufView) - expect(result.error).toBe("Wrong pin type, format or length") - - - - - - }) - - test('restoreKeyringState/empty encrption key' , async()=>{ - - let result= await vault.restoreKeyringState(vaultAddress,pin,null) - expect(result.error).toBe('Incorrect Encryption Key or vault string') - - - - - }) - - test('restoreKeyringState/invalid encrption key' , async()=>{ - - let result= await vault.restoreKeyringState(vaultAddress,pin,"weefew") - expect(result.error).toBe('Incorrect Encryption Key or vault string') - - - }) - - test('restoreKeyringState/all params empty' , async()=>{ - - let result= await vault.restoreKeyringState(null,null,null) - expect(result.error).toBe("Wrong pin type, format or length") - - - - - - }) - - -}) - - - -describe('getVaultDetails',()=>{ - test('getVaultDetails/valid' , async()=>{ - let result = await vault.getVaultDetails(bufView) - expect(result.response).toHaveProperty('evm') - - - }) - - test('getVaultDetails/empty encryption key' , async()=>{ - let result = await vault.getVaultDetails(null) - expect(result.error).toBe('Incorrect Encryption Key or vault string') - - - - }) - - test('getVaultDetails/invalid encryption key' , async()=>{ - let result = await vault.getVaultDetails("adfaefae") - expect(result.error).toBe('Incorrect Encryption Key or vault string') - - - - }) -}) - -describe('getBalance',()=>{ - - - test('getBalance/valid' , async()=>{ - - let result = await vault.getBalance(accAddress,polygonRpcUrl) - expect(result.response).toHaveProperty('balance') - - - }) - - test('getBalance/empty address' , async()=>{ - try{ - let result = await vault.getBalance(null,ethUrl) - - } - catch(e){ - expect(e.message).toBe("Provided address null is invalid, the capitalization checksum test failed, or it's an indirect IBAN address which can't be converted.") - } - - - }) - - - - test('getBalance/invalid address' , async()=>{ - let addr="fghioiuhgf" - try{ - - let result = await vault.getBalance("fghioiuhgf",ethUrl) - - } - catch(e){ - expect(e.message).toBe(`Provided address ${addr} is invalid, the capitalization checksum test failed, or it's an indirect IBAN address which can't be converted.`) - } - - - }) - - test('getBalance/empty url' , async()=>{ - try{ - - let result = await vault.getBalance(accAddress,null) - - } - catch(e){ - expect(e.message).toBe(`CONNECTION ERROR: Couldn't connect to node http://localhost:8545.`) - } - - - }) - test('getBalance/invalid url' , async()=>{ - let url="https.11.com" - try{ - - let result = await vault.getBalance(accAddress,url) - - } - catch(e){ - expect(e.message).toBe(`CONNECTION ERROR: Couldn't connect to node ${url}.`) - } - - - }) - - - - -}) - - - - - - -describe('updateLabel',()=>{ - - test('updateLabel/valid' , async()=>{ - let result = await vault.updateLabel("0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd",bufView,"Wallet 1") - expect(result).toHaveProperty('response') - - - }) - - test('updateLabel/invalid address' , async()=>{ - let result = await vault.updateLabel("adeded",bufView,"Wallet 1") - expect(result.error).toBe('This address is not present in the vault') - - - }) - - test('updateLabel/empty address' , async()=>{ - let result = await vault.updateLabel(null,bufView,"Wallet 1") - expect(result.error).toBe('This address is not present in the vault') - - - }) - test('updateLabel/invalid encryption key' , async()=>{ - - let result = await vault.updateLabel("0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd","afers","Wallet 1") - expect(result.error).toBe('Incorrect Encryption Key or vault string') - - - - }) - test('updateLabel/empty encryption key' , async()=>{ - - let result = await vault.updateLabel("0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd",null,"Wallet 1") - expect(result.error).toBe('Incorrect Encryption Key or vault string') - - - - - - }) - test('updateLabel/empty label' , async()=>{ - try{ - let result = await vault.updateLabel("0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd",bufView,null) - } - catch(e){ - expect(e.message).toBe('chainName is not defined') - } - - - - }) - test('updateLabel/all empty params' , async()=>{ - - let result = await vault.updateLabel(null,null,null) - expect(result.error).toBe('Incorrect Encryption Key or vault string') - - - - }) - -}) - - -describe('sign',()=>{ - - test('sign/valid' , async()=>{ - let data="hello world" - console.log("sign/valid--->",pin,ethUrl) - await vault.restoreKeyringState(vault,pin,bufView) - - let result = await vault.sign(data,"0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd",pin,ethUrl) - console.log("sign/valid--->",result) - expect(result.response).toHaveProperty('signature') - - }) - - test('sign/empty data' , async()=>{ - - let data="hello world" - let result = await vault.sign("","0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd",pin,ethUrl) - expect(result.response).toHaveProperty('signature') - - }) - - - test('sign/empty address' , async()=>{ - - let data="hello world" - try{ - let result = await vault.sign(data,null,pin,ethUrl) - - }catch(e){ - expect(e.message).toBe("Cannot read properties of null (reading 'toLowerCase')") - } - - - }) - test('sign/invalid address' , async()=>{ - - let data="hello world" - try{ - let result = await vault.sign(data,"abc",pin,ethUrl) - } - catch(e){ - expect(e.message).toBe('Given address "abc" is not a valid Ethereum address.') - } - - - - - }) - test('sign/empty pin' , async()=>{ - - let data="hello world" - - let result = await vault.sign(data,"abc",null,ethUrl) - expect(result.error).toBe("Wrong pin type, format or length") - - }) - test('sign/incorrect pin' , async()=>{ - - let data="hello world" - - let result = await vault.sign(data,"abc","111111",ethUrl) - expect(result.error).toBe("Incorrect pin") - - }) - test('sign/invalid pin' , async()=>{ - - let data="hello world" - let result = await vault.sign(data,accAddress,"abc",ethUrl) - expect(result.error).toBe("Wrong pin type, format or length") - - }) - - test('sign/empty url' , async()=>{ - - let data="hello world" - let result = await vault.sign(data,"0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd",pin,null) - expect(result.response).toHaveProperty('signature') - - - - - - }) - - test('sign/invalid url' , async()=>{ - - let data="hello world" - let result = await vault.sign(data,"0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd",pin,"abc") - expect(result.response).toHaveProperty('signature') - - }) - - test('sign/all params empty' , async()=>{ - - let data="hello world" - - let result = await vault.sign(null,null,null,null) - expect(result.error).toBe("Wrong pin type, format or length") - - - }) - - - - - - - -}) - - -describe('validateMnemonic',()=>{ - let signUpPhrase='ladder equip piano open silent pizza solid cannon name volcano fee valley' - test('validateMnemonic/valid' , async()=>{ - let result = await vault.validateMnemonic(signUpPhrase,'abhi141','testnet',polygonRpcUrl) - expect(result.response).toBe(true) - - - }) - test('validateMnemonic/empty phrase' , async()=>{ - let result = await vault.validateMnemonic('','abhi141','testnet',polygonRpcUrl) - expect(result.response).toBe(false) - - - }) - test('validateMnemonic/invalid phrase' , async()=>{ - let result = await vault.validateMnemonic('waefsgrth','abhi141','testnet',polygonRpcUrl) - expect(result.response).toBe(false) - - - }) - test('validateMnemonic/empty safle id' , async()=>{ - let result = await vault.validateMnemonic(signUpPhrase,null,'testnet',polygonRpcUrl) - expect(result.response).toBe(false) - - - }) - test('validateMnemonic/invalid safle id' , async()=>{ - let result = await vault.validateMnemonic(signUpPhrase,"egsrrgr",'testnet',polygonRpcUrl) - expect(result.response).toBe(false) - - - }) - test('validateMnemonic/empty network' , async()=>{ - try{ - let result = await vault.validateMnemonic(signUpPhrase,'abhi141',null,polygonRpcUrl) - - } - catch(e){ - expect(e).toBe('Invalid network selected') - } - - - }) - test('validateMnemonic/invalid network' , async()=>{ - try{ - let result = await vault.validateMnemonic(signUpPhrase,'abhi141',"segsr",polygonRpcUrl) - - } - catch(e){ - expect(e).toBe('Invalid network selected') - } - - - }) - test('validateMnemonic/invalid network' , async()=>{ - try{ - let result = await vault.validateMnemonic(signUpPhrase,'abhi141',"segsr",polygonRpcUrl) - - } - catch(e){ - expect(e).toBe('Invalid network selected') - } - - - }) - test('validateMnemonic/invalid url' , async()=>{ - - let result = await vault.validateMnemonic(signUpPhrase,'abhi141','testnet',"awfe") - expect(result.response).toBe(false) - - }) - test('validateMnemonic/empty url' , async()=>{ - - let result = await vault.validateMnemonic(signUpPhrase,'abhi141','testnet',null) - expect(result.response).toBe(false) - - }) - test('validateMnemonic/all empty params' , async()=>{ - try{ - let result = await vault.validateMnemonic(null,null,null,null) - } - - catch(e){ - expect(e).toBe('Invalid network selected') - } - - }) -}) - -describe('changePin',()=>{ - test('changePin/valid' , async()=>{ - let result = await vault.changePin(pin,pin,bufView) - expect(result).toHaveProperty('response') - - - }) - - test('changePin/wrong currentpin' , async()=>{ - try{ - let result = await vault.changePin("111111",pin,bufView) - - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - } - - - }) - - test('changePin/invalid currentpin' , async()=>{ - try{ - let result = await vault.changePin('aefe',pin,bufView) - - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - } - - - - - }) - test('changePin/empty currentpin' , async()=>{ - try{ - let result = await vault.changePin(null,pin,bufView) - - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - } - - - }) - - test('changePin/empty new pin' , async()=>{ - try{ - let result = await vault.changePin(pin,null,bufView) - - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - } - - - }) - - test('changePin/invalid new pin' , async()=>{ - try{ - let result = await vault.changePin(pin,'afaef',bufView) - - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - } - - - }) - - test('changePin/empty encryption key' , async()=>{ - try{ - let result = await vault.changePin(pin,pin,null) - } - catch(e){ - expect(e.message).toBe("Incorrect Encryption Key or vault string") - } - - - }) - - test('changePin/invalid encryption key' , async()=>{ - try{ - let result = await vault.changePin(pin,pin,'efefe') - } - catch(e){ - expect(e.message).toBe("Incorrect Encryption Key or vault string") - } - - - - - }) - test('changePin/all empty params' , async()=>{ - try{ - let result = await vault.changePin(null,null,null) - - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - } - - - }) - -}) - - - -describe('getLogs',()=>{ - test('getLogs/valid' , async()=>{ - - let result = await vault.getLogs() - expect(result).toHaveProperty('logs') - - - }) -}) - - -describe('getAccounts',()=>{ - test('getAccounts/valid' , async()=>{ - await vault.restoreKeyringState(vaultAddress,pin,bufView) - let result = await vault.getAccounts() - expect(result).toHaveProperty('response') - - }) - -}) - - -describe('signTransaction',()=>{ - - - test('signTransaction/valid' , async()=>{ - let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" - const web3 = new Web3(polygonRpcUrl) - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + { chain: "bitcoin", symbol: "BTC" }, + { chain: "stacks", symbol: "STX" }, + { chain: "solana", symbol: "SOL" }, + { chain: "ethereum", symbol: "ETH" }, + { chain: "bsc", symbol: "BSC" }, + { chain: "polygon", symbol: "MATIC" }, + { chain: "optimism", symbol: "OP" }, + { chain: "arbitrum", symbol: "ARB" }, + { chain: "mantle", symbol: "MNT" }, + { chain: "velas", symbol: "VLX" }, + { chain: "avalanche", symbol: "AVAX" }, + { chain: "base", symbol: "BASE" }, + { chain: "zkEVM", symbol: "ZKEVM" }, + { chain: "bevm", symbol: "BTC" }, + { chain: "rootstock", symbol: "RBTC" }, + ], + }).toMatchObject(result); + }); +}); - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), - maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), - data: '0x0', // method to generate data is provided below - nonce: nonce, - type: '0x2', - }; - await vault.getActiveChains() - try{ +describe("deleteAccount", () => { + test("deleteAccount/valid generated acc", async () => { + let result = await vault.deleteAccount(bufView, accAddress, pin); + expect(result).toHaveProperty("response"); + }); + + test("deleteAccount/valid imported acc", async () => { + let result = await vault.deleteAccount(bufView, impAccAddress, pin); + expect(result).toHaveProperty("response"); + }); + + test("deleteAccount/empty encryption key", async () => { + try { + let result = await vault.deleteAccount(null, accAddress, pin); + } catch (e) { + expect(e.message).toBe("Incorrect Encryption Key or vault string"); + } + }); + + test("deleteAccount/invalid encryption key", async () => { + try { + let result = await vault.deleteAccount(null, accAddress, pin); + } catch (e) { + expect(e.message).toBe("Incorrect Encryption Key or vault string"); + } + }); + test("deleteAccount/empty address", async () => { + let result = await vault.deleteAccount(bufView, null, pin); + + expect(result.error).toBe("This address is not present in the vault"); + }); + test("deleteAccount/invalid address", async () => { + let result = await vault.deleteAccount(bufView, "rerwgtehry", pin); + expect(result.error).toBe("This address is not present in the vault"); + }); + test("deleteAccount/empty pin", async () => { + let result = await vault.deleteAccount(bufView, accAddress, null); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + test("deleteAccount/invalid pin", async () => { + let result = await vault.deleteAccount(bufView, accAddress, "efwe"); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + test("deleteAccount/incorrect pin", async () => { + let result = await vault.deleteAccount(bufView, accAddress, "111111"); + expect(result.error).toBe("Incorrect pin"); + }); + test("deleteAccount/all params empty", async () => { + try { + let result = await vault.deleteAccount(null, null, null); + } catch (e) { + expect(e).toBe("Wrong pin type, format or length"); + } + }); +}); + +describe("restoreAccount", () => { + test("restoreAccount/valid generated acc", async () => { + let result = await vault.restoreAccount(bufView, accAddress, pin); + expect(result).toHaveProperty("response"); + }); + + test("restoreAccount/valid imported acc", async () => { + let result = await vault.restoreAccount(bufView, impAccAddress, pin); + expect(result).toHaveProperty("response"); + }); + + test("restoreAccount/empty encryption key", async () => { + try { + let result = await vault.restoreAccount(null, accAddress, pin); + } catch (e) { + expect(e.message).toBe("Incorrect Encryption Key or vault string"); + } + }); + + test("restoreAccount/invalid encryption key", async () => { + try { + let result = await vault.restoreAccount(null, accAddress, pin); + } catch (e) { + expect(e.message).toBe("Incorrect Encryption Key or vault string"); + } + }); + test("restoreAccount/empty address", async () => { + let result = await vault.restoreAccount(bufView, null, pin); + expect(result.error).toBe("This address is not present in the vault"); + }); + test("restoreAccount/invalid address", async () => { + let result = await vault.restoreAccount(bufView, "rerwgtehry", pin); + expect(result.error).toBe("This address is not present in the vault"); + }); + test("restoreAccount/empty pin", async () => { + try { + let result = await vault.restoreAccount(bufView, accAddress, null); + } catch (e) { + expect(e).toBe("Wrong pin type, format or length"); + } + }); + test("restoreAccount/invalid pin", async () => { + try { + let result = await vault.restoreAccount(bufView, accAddress, "efwe"); + } catch (e) { + expect(e).toBe("Wrong pin type, format or length"); + } + }); + test("restoreAccount/incorrect pin", async () => { + let result = await vault.restoreAccount(bufView, accAddress, "111111"); + expect(result.error).toBe("Incorrect pin"); + }); + test("restoreAccount/all params empty", async () => { + try { + let result = await vault.restoreAccount(null, null, null); + } catch (e) { + expect(e).toBe("Wrong pin type, format or length"); + } + }); +}); - let result = await vault.signTransaction(rawTx,pin,polygonRpcUrl) +describe("restoreKeyringState", () => { + test("restoreKeyringState/valid", async () => { + await vault.restoreKeyringState(vaultAddress, pin, bufView); + expect(result).toHaveProperty("response"); + }); + + test("restoreKeyringState/empty vault address", async () => { + try { + let result = await vault.restoreKeyringState(null, pin, bufView); + } catch (e) { + expect(e.message).toBe("Cannot read properties of null (reading 'salt')"); + } + }); + + test("restoreKeyringState/invalid vault address", async () => { + let result = await vault.restoreKeyringState("abc", pin, bufView); + expect(result.error).toBe("Incorrect Encryption Key or vault string"); + }); + + test("restoreKeyringState/empty pin", async () => { + let result = await vault.restoreKeyringState(vaultAddress, null, bufView); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + + test("restoreKeyringState/invalid pin", async () => { + let result = await vault.restoreKeyringState( + vaultAddress, + "avevr", + bufView + ); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + + test("restoreKeyringState/empty encrption key", async () => { + let result = await vault.restoreKeyringState(vaultAddress, pin, null); + expect(result.error).toBe("Incorrect Encryption Key or vault string"); + }); + + test("restoreKeyringState/invalid encrption key", async () => { + let result = await vault.restoreKeyringState(vaultAddress, pin, "weefew"); + expect(result.error).toBe("Incorrect Encryption Key or vault string"); + }); + + test("restoreKeyringState/all params empty", async () => { + let result = await vault.restoreKeyringState(null, null, null); + expect(result.error).toBe("Wrong pin type, format or length"); + }); +}); - } - catch(e){ - expect(e.message).toBe("Cannot read property 'salt' of undefined") +describe("getVaultDetails", () => { + test("getVaultDetails/valid", async () => { + let result = await vault.getVaultDetails(bufView); + expect(result.response).toHaveProperty("evm"); + }); + + test("getVaultDetails/empty encryption key", async () => { + let result = await vault.getVaultDetails(null); + expect(result.error).toBe("Incorrect Encryption Key or vault string"); + }); + + test("getVaultDetails/invalid encryption key", async () => { + let result = await vault.getVaultDetails("adfaefae"); + expect(result.error).toBe("Incorrect Encryption Key or vault string"); + }); +}); - } - - - - - }) +describe("getBalance", () => { + test("getBalance/valid", async () => { + let result = await vault.getBalance(accAddress, polygonRpcUrl); + expect(result.response).toHaveProperty("balance"); + }); + + test("getBalance/empty address", async () => { + try { + let result = await vault.getBalance(null, ethUrl); + } catch (e) { + expect(e.message).toBe( + "Provided address null is invalid, the capitalization checksum test failed, or it's an indirect IBAN address which can't be converted." + ); + } + }); + + test("getBalance/invalid address", async () => { + let addr = "fghioiuhgf"; + try { + let result = await vault.getBalance("fghioiuhgf", ethUrl); + } catch (e) { + expect(e.message).toBe( + `Provided address ${addr} is invalid, the capitalization checksum test failed, or it's an indirect IBAN address which can't be converted.` + ); + } + }); + + test("getBalance/empty url", async () => { + try { + let result = await vault.getBalance(accAddress, null); + } catch (e) { + expect(e.message).toBe( + `CONNECTION ERROR: Couldn't connect to node http://localhost:8545.` + ); + } + }); + test("getBalance/invalid url", async () => { + let url = "https.11.com"; + try { + let result = await vault.getBalance(accAddress, url); + } catch (e) { + expect(e.message).toBe( + `CONNECTION ERROR: Couldn't connect to node ${url}.` + ); + } + }); +}); + +describe("updateLabel", () => { + test("updateLabel/valid", async () => { + let result = await vault.updateLabel( + "0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd", + bufView, + "Wallet 1" + ); + expect(result).toHaveProperty("response"); + }); + + test("updateLabel/invalid address", async () => { + let result = await vault.updateLabel("adeded", bufView, "Wallet 1"); + expect(result.error).toBe("This address is not present in the vault"); + }); + + test("updateLabel/empty address", async () => { + let result = await vault.updateLabel(null, bufView, "Wallet 1"); + expect(result.error).toBe("This address is not present in the vault"); + }); + test("updateLabel/invalid encryption key", async () => { + let result = await vault.updateLabel( + "0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd", + "afers", + "Wallet 1" + ); + expect(result.error).toBe("Incorrect Encryption Key or vault string"); + }); + test("updateLabel/empty encryption key", async () => { + let result = await vault.updateLabel( + "0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd", + null, + "Wallet 1" + ); + expect(result.error).toBe("Incorrect Encryption Key or vault string"); + }); + test("updateLabel/empty label", async () => { + try { + let result = await vault.updateLabel( + "0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd", + bufView, + null + ); + } catch (e) { + expect(e.message).toBe("chainName is not defined"); + } + }); + test("updateLabel/all empty params", async () => { + let result = await vault.updateLabel(null, null, null); + expect(result.error).toBe("Incorrect Encryption Key or vault string"); + }); +}); + +describe("sign", () => { + test("sign/valid", async () => { + let data = "hello world"; + console.log("sign/valid--->", pin, ethUrl); + await vault.restoreKeyringState(vault, pin, bufView); + + let result = await vault.sign( + data, + "0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd", + pin, + ethUrl + ); + console.log("sign/valid--->", result); + expect(result.response).toHaveProperty("signature"); + }); + + test("sign/empty data", async () => { + let data = "hello world"; + let result = await vault.sign( + "", + "0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd", + pin, + ethUrl + ); + expect(result.response).toHaveProperty("signature"); + }); + + test("sign/empty address", async () => { + let data = "hello world"; + try { + let result = await vault.sign(data, null, pin, ethUrl); + } catch (e) { + expect(e.message).toBe( + "Cannot read properties of null (reading 'toLowerCase')" + ); + } + }); + test("sign/invalid address", async () => { + let data = "hello world"; + try { + let result = await vault.sign(data, "abc", pin, ethUrl); + } catch (e) { + expect(e.message).toBe( + 'Given address "abc" is not a valid Ethereum address.' + ); + } + }); + test("sign/empty pin", async () => { + let data = "hello world"; + + let result = await vault.sign(data, "abc", null, ethUrl); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + test("sign/incorrect pin", async () => { + let data = "hello world"; + + let result = await vault.sign(data, "abc", "111111", ethUrl); + expect(result.error).toBe("Incorrect pin"); + }); + test("sign/invalid pin", async () => { + let data = "hello world"; + let result = await vault.sign(data, accAddress, "abc", ethUrl); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + + test("sign/empty url", async () => { + let data = "hello world"; + let result = await vault.sign( + data, + "0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd", + pin, + null + ); + expect(result.response).toHaveProperty("signature"); + }); + + test("sign/invalid url", async () => { + let data = "hello world"; + let result = await vault.sign( + data, + "0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd", + pin, + "abc" + ); + expect(result.response).toHaveProperty("signature"); + }); + + test("sign/all params empty", async () => { + let data = "hello world"; + + let result = await vault.sign(null, null, null, null); + expect(result.error).toBe("Wrong pin type, format or length"); + }); +}); + +describe("validateMnemonic", () => { + let signUpPhrase = + "ladder equip piano open silent pizza solid cannon name volcano fee valley"; + test("validateMnemonic/valid", async () => { + let result = await vault.validateMnemonic( + signUpPhrase, + "abhi141", + "testnet", + polygonRpcUrl + ); + expect(result.response).toBe(true); + }); + test("validateMnemonic/empty phrase", async () => { + let result = await vault.validateMnemonic( + "", + "abhi141", + "testnet", + polygonRpcUrl + ); + expect(result.response).toBe(false); + }); + test("validateMnemonic/invalid phrase", async () => { + let result = await vault.validateMnemonic( + "waefsgrth", + "abhi141", + "testnet", + polygonRpcUrl + ); + expect(result.response).toBe(false); + }); + test("validateMnemonic/empty safle id", async () => { + let result = await vault.validateMnemonic( + signUpPhrase, + null, + "testnet", + polygonRpcUrl + ); + expect(result.response).toBe(false); + }); + test("validateMnemonic/invalid safle id", async () => { + let result = await vault.validateMnemonic( + signUpPhrase, + "egsrrgr", + "testnet", + polygonRpcUrl + ); + expect(result.response).toBe(false); + }); + test("validateMnemonic/empty network", async () => { + try { + let result = await vault.validateMnemonic( + signUpPhrase, + "abhi141", + null, + polygonRpcUrl + ); + } catch (e) { + expect(e).toBe("Invalid network selected"); + } + }); + test("validateMnemonic/invalid network", async () => { + try { + let result = await vault.validateMnemonic( + signUpPhrase, + "abhi141", + "segsr", + polygonRpcUrl + ); + } catch (e) { + expect(e).toBe("Invalid network selected"); + } + }); + test("validateMnemonic/invalid network", async () => { + try { + let result = await vault.validateMnemonic( + signUpPhrase, + "abhi141", + "segsr", + polygonRpcUrl + ); + } catch (e) { + expect(e).toBe("Invalid network selected"); + } + }); + test("validateMnemonic/invalid url", async () => { + let result = await vault.validateMnemonic( + signUpPhrase, + "abhi141", + "testnet", + "awfe" + ); + expect(result.response).toBe(false); + }); + test("validateMnemonic/empty url", async () => { + let result = await vault.validateMnemonic( + signUpPhrase, + "abhi141", + "testnet", + null + ); + expect(result.response).toBe(false); + }); + test("validateMnemonic/all empty params", async () => { + try { + let result = await vault.validateMnemonic(null, null, null, null); + } catch (e) { + expect(e).toBe("Invalid network selected"); + } + }); +}); - test('signTransaction/empty raw tx' , async()=>{ - let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" - const web3 = new Web3(polygonRpcUrl) +describe("changePin", () => { + test("changePin/valid", async () => { + let result = await vault.changePin(pin, pin, bufView); + expect(result).toHaveProperty("response"); + }); + + test("changePin/wrong currentpin", async () => { + try { + let result = await vault.changePin("111111", pin, bufView); + } catch (e) { + expect(e).toBe("Wrong pin type, format or length"); + } + }); + + test("changePin/invalid currentpin", async () => { + try { + let result = await vault.changePin("aefe", pin, bufView); + } catch (e) { + expect(e).toBe("Wrong pin type, format or length"); + } + }); + test("changePin/empty currentpin", async () => { + try { + let result = await vault.changePin(null, pin, bufView); + } catch (e) { + expect(e).toBe("Wrong pin type, format or length"); + } + }); + + test("changePin/empty new pin", async () => { + try { + let result = await vault.changePin(pin, null, bufView); + } catch (e) { + expect(e).toBe("Wrong pin type, format or length"); + } + }); + + test("changePin/invalid new pin", async () => { + try { + let result = await vault.changePin(pin, "afaef", bufView); + } catch (e) { + expect(e).toBe("Wrong pin type, format or length"); + } + }); + + test("changePin/empty encryption key", async () => { + try { + let result = await vault.changePin(pin, pin, null); + } catch (e) { + expect(e.message).toBe("Incorrect Encryption Key or vault string"); + } + }); + + test("changePin/invalid encryption key", async () => { + try { + let result = await vault.changePin(pin, pin, "efefe"); + } catch (e) { + expect(e.message).toBe("Incorrect Encryption Key or vault string"); + } + }); + test("changePin/all empty params", async () => { + try { + let result = await vault.changePin(null, null, null); + } catch (e) { + expect(e).toBe("Wrong pin type, format or length"); + } + }); +}); + +describe("getLogs", () => { + test("getLogs/valid", async () => { + let result = await vault.getLogs(); + expect(result).toHaveProperty("logs"); + }); +}); + +describe("getAccounts", () => { + test("getAccounts/valid", async () => { + await vault.restoreKeyringState(vaultAddress, pin, bufView); + let result = await vault.getAccounts(); + expect(result).toHaveProperty("response"); + }); +}); + +describe("signTransaction", () => { + test("signTransaction/valid", async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(polygonRpcUrl); const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), - maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), - data: '0x0', // method to generate data is provided below - nonce: nonce, - type: '0x2', - }; - try{ - - let result = await vault.signTransaction({},pin,polygonRpcUrl) - - } - catch(e){ - expect(e.message).toBe("Cannot read properties of undefined (reading 'toLowerCase')") - - } - - - - - }) - - test('signTransaction/invalid raw tx' , async()=>{ - let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" - const web3 = new Web3(polygonRpcUrl) - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), - maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), - data: '0x0', // method to generate data is provided below - nonce: nonce, - type: '0x2', - }; - try{ - - let result = await vault.signTransaction("evwf",pin,polygonRpcUrl) - - } - catch(e){ - expect(e.message).toBe("Cannot read properties of undefined (reading 'toLowerCase')") - - } - - - - - }) - - test('signTransaction/empty pin' , async()=>{ - let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" - const web3 = new Web3(polygonRpcUrl) - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), - maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), - data: '0x0', // method to generate data is provided below - nonce: nonce, - type: '0x2', - }; - - - let result = await vault.signTransaction("evwf",null,polygonRpcUrl) - expect(result.error).toBe('Wrong pin type, format or length') - - - - - }) - - test('signTransaction/invalid pin' , async()=>{ - let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" - const web3 = new Web3(polygonRpcUrl) - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), - maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), - data: '0x0', // method to generate data is provided below - nonce: nonce, - type: '0x2', - }; - - - let result = await vault.signTransaction("evwf","afewf",polygonRpcUrl) - expect(result.error).toBe('Wrong pin type, format or length') - - - - - - }) - test('signTransaction/incorrect pin' , async()=>{ - let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" - const web3 = new Web3(polygonRpcUrl) - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), - maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), - data: '0x0', // method to generate data is provided below - nonce: nonce, - type: '0x2', - }; - - - let result = await vault.signTransaction("evwf","112344",polygonRpcUrl) - expect(result.error).toBe('Incorrect pin') - - - - - - }) - - test('signTransaction/empty polygon rpc' , async()=>{ - let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" - const web3 = new Web3(polygonRpcUrl) - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), - maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), - data: '0x0', // method to generate data is provided below - nonce: nonce, - type: '0x2', + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", }; - - try{ - let result = await vault.signTransaction("evwf",pin,null) - } - catch(e){ - expect(e.message).toBe("CONNECTION ERROR: Couldn't connect to node http://localhost:8545.") - } - - - - - - - }) - - test('signTransaction/invalid polygon rpc' , async()=>{ - let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" - const web3 = new Web3(polygonRpcUrl) - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), - maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), - data: '0x0', // method to generate data is provided below - nonce: nonce, - type: '0x2', + await vault.getActiveChains(); + try { + let result = await vault.signTransaction(rawTx, pin, polygonRpcUrl); + } catch (e) { + expect(e.message).toBe("Cannot read property 'salt' of undefined"); + } + }); + + test("signTransaction/empty raw tx", async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(polygonRpcUrl); + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", }; - let invalidRpc="efrwgrwdvfr" - try{ - let result = await vault.signTransaction("evwf",pin,invalidRpc) - } - catch(e){ - expect(e.message).toBe(`CONNECTION ERROR: Couldn't connect to node ${invalidRpc}.`) - } - - - - - - - }) - - test('signTransaction/all empty params' , async()=>{ - let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" - const web3 = new Web3(polygonRpcUrl) - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), - maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), - data: '0x0', // method to generate data is provided below - nonce: nonce, - type: '0x2', + try { + let result = await vault.signTransaction({}, pin, polygonRpcUrl); + } catch (e) { + expect(e.message).toBe( + "Cannot read properties of undefined (reading 'toLowerCase')" + ); + } + }); + + test("signTransaction/invalid raw tx", async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(polygonRpcUrl); + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", }; - let invalidRpc="efrwgrwdvfr" - - let result = await vault.signTransaction(null,null,null) - expect(result.error).toBe("Wrong pin type, format or length") + try { + let result = await vault.signTransaction("evwf", pin, polygonRpcUrl); + } catch (e) { + expect(e.message).toBe( + "Cannot read properties of undefined (reading 'toLowerCase')" + ); + } + }); + + test("signTransaction/empty pin", async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(polygonRpcUrl); + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - - + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", + }; - - - - - }) -}) + let result = await vault.signTransaction("evwf", null, polygonRpcUrl); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + test("signTransaction/invalid pin", async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(polygonRpcUrl); + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); -describe('get Fees', () => { + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", + }; - test('get Fees, validate', async () => { - vault.changeNetwork('polygon') - let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" - const web3 = new Web3(polygonRpcUrl) + let result = await vault.signTransaction("evwf", "afewf", polygonRpcUrl); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + test("signTransaction/incorrect pin", async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(polygonRpcUrl); + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0", 'ether')), - chainID: 137, - }; + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", + }; - let result = await vault.getFees(rawTx,polygonRpcUrl) - expect(result.response).toHaveProperty('gasLimit') - expect(result.response).toHaveProperty('fees') - - }) + let result = await vault.signTransaction("evwf", "112344", polygonRpcUrl); + expect(result.error).toBe("Incorrect pin"); + }); - test('get fees, invalid', async () => { - vault.changeNetwork('polygon') - let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" - const web3 = new Web3(polygonRpcUrl) + test("signTransaction/empty polygon rpc", async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(polygonRpcUrl); + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0", 'ether')), - chainID: 137, - }; + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", + }; - try { - let result = await vault.getFees(rawTx,'abc') - console.log("result = ", result); - } - catch (e) { - console.log(e.message); - expect(e.message).toBe("CONNECTION ERROR: Couldn't connect to node abc.") - } - - }) -}) + try { + let result = await vault.signTransaction("evwf", pin, null); + } catch (e) { + expect(e.message).toBe( + "CONNECTION ERROR: Couldn't connect to node http://localhost:8545." + ); + } + }); + + test("signTransaction/invalid polygon rpc", async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(polygonRpcUrl); + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", + }; + let invalidRpc = "efrwgrwdvfr"; + try { + let result = await vault.signTransaction("evwf", pin, invalidRpc); + } catch (e) { + expect(e.message).toBe( + `CONNECTION ERROR: Couldn't connect to node ${invalidRpc}.` + ); + } + }); + + test("signTransaction/all empty params", async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(polygonRpcUrl); + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", + }; + let invalidRpc = "efrwgrwdvfr"; + let result = await vault.signTransaction(null, null, null); + expect(result.error).toBe("Wrong pin type, format or length"); + }); +}); +describe("get Fees", () => { + test("get Fees, validate", async () => { + vault.changeNetwork("polygon"); + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(polygonRpcUrl); + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0", "ether")), + chainID: 137, + }; + let result = await vault.getFees(rawTx, polygonRpcUrl); + expect(result.response).toHaveProperty("gasLimit"); + expect(result.response).toHaveProperty("fees"); + }); + test("get fees, invalid", async () => { + vault.changeNetwork("polygon"); + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(polygonRpcUrl); + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0", "ether")), + chainID: 137, + }; + try { + let result = await vault.getFees(rawTx, "abc"); + console.log("result = ", result); + } catch (e) { + console.log(e.message); + expect(e.message).toBe("CONNECTION ERROR: Couldn't connect to node abc."); + } + }); +}); diff --git a/src/lib/test/vault.test.js b/src/lib/test/vault.test.js index d01b0c3..a0db9c9 100644 --- a/src/lib/test/vault.test.js +++ b/src/lib/test/vault.test.js @@ -1,271 +1,271 @@ -jest.setTimeout(30000) -const crypto = require('crypto'); - - -let Vault = require('../vault') -const bufView = [48, 0, 236, 187, 187, 172, 177, 90, 255, 184, 9, 116, 142, 96, 197, 158, 87, 35, 26, 101, 187, 30, 116, 138, 50, 131, 166, 50, 51, 197, 198, 83, 238, 167, 105, 178, 182, 108, 174, 199, 124, 141, 155, 73, 21, 85, 81, 109, 78, 233, 152, 108, 242, 238, 192, 31, 147, 86, 174, 195, 55, 229, 4, 36]; -let phrase="fun rough treat scan glimpse region century purpose expire video remind second" -let pin="696969" -let vault =new Vault({}) +jest.setTimeout(30000); +const crypto = require("crypto"); + +let Vault = require("../vault"); +const bufView = [ + 48, 0, 236, 187, 187, 172, 177, 90, 255, 184, 9, 116, 142, 96, 197, 158, 87, + 35, 26, 101, 187, 30, 116, 138, 50, 131, 166, 50, 51, 197, 198, 83, 238, 167, + 105, 178, 182, 108, 174, 199, 124, 141, 155, 73, 21, 85, 81, 109, 78, 233, + 152, 108, 242, 238, 192, 31, 147, 86, 174, 195, 55, 229, 4, 36, +]; +let phrase = + "fun rough treat scan glimpse region century purpose expire video remind second"; +let pin = "696969"; +let vault = new Vault({}); const logs = [ - { - "action": "add-account", - "timestamp": 1000000000001, - "platform": "web", - "address": "0xF8919220F674a553F0F0F6e86481612A2bEd44EB", - "storage": [ - "mobile" - ], - "_id": "64e881b05b04774ca85aee51" - }, - { - "action": "add-account", - "timestamp": 1000000000002, - "platform": "web", - "address": "0x627437E29e7363C0F53896e84467EF6F8f9D0247", - "storage": [ - "mobile" - ], - "_id": "64e881e3bae0e048dfaefc46" - }, - { - "action": "add-account", - "timestamp": 1000000000003, - "platform": "web", - "address": "0xa1F77e4D8306000639D1d44a6013ad53b992182E", - "storage": [ - "mobile" - ], - "_id": "64ec3339a58abcbf66a9b34a" - }, - { - "action": "add-account", - "timestamp": 1000000000004, - "platform": "web", - "address": "0x9e6627384a3E6453b9EC061e4DaeD4cE0223bbdc", - "storage": [ - "mobile" - ], - "_id": "64ec333ca58abcbf66a9b354" - }, - { - "action": "add-account", - "timestamp": 1000000000005, - "platform": "mobile", - "address": "0xCccbD31ea19acE5688731148a4f63907F273BEe0", - "storage": [ - "mobile" - ], - "_id": "64e87e9e72e00ccf96bce1fc" + { + action: "add-account", + timestamp: 1000000000001, + platform: "web", + address: "0xF8919220F674a553F0F0F6e86481612A2bEd44EB", + storage: ["mobile"], + _id: "64e881b05b04774ca85aee51", }, { - "action": "delete-account", - "timestamp": 1000000000006, - "platform": "web", - "address": "0x9e6627384a3E6453b9EC061e4DaeD4cE0223bbdc", - "storage": [ - "mobile" - ], - "_id": "64ec3339a58abcbf66a9b34a" + action: "add-account", + timestamp: 1000000000002, + platform: "web", + address: "0x627437E29e7363C0F53896e84467EF6F8f9D0247", + storage: ["mobile"], + _id: "64e881e3bae0e048dfaefc46", }, - ] - - -describe('getSupportedChains' , ()=>{ - - test('getSupportedChains' , async()=>{ - - let result = await new Vault({}).getSupportedChains() - expect({ - evmChains: { 'ethereum': 'ETH', 'bsc': 'BSC', 'polygon': 'MATIC', 'optimism': 'OP' ,'arbitrum': 'ARB', 'mantle': 'MNT', 'velas': 'VLX' , 'avalanche': 'AVAX', 'base':'BASE', 'zkEVM': 'ZKEVM', 'bevm':'BTC'}, - nonEvmChains: { bitcoin: 'BTC', stacks: 'STX', solana: 'SOL' } - }).toMatchObject(result.response) - }) - - -}) - -describe('generateMnemonic' , ()=>{ - - test('generateMnemonic' , async()=>{ - - let result = await new Vault({}).generateMnemonic() - Mnemonic=result - expect(typeof(result)).toBe("string") - - }) - - - - -}) - - - -describe("generateVault",()=>{ - - const buf = crypto.randomBytes(64); - const bufView = [48, 0, 236, 187, 187, 172, 177, 90, 255, 184, 9, 116, 142, 96, 197, 158, 87, 35, 26, 101, 187, 30, 116, 138, 50, 131, 166, 50, 51, 197, 198, 83, 238, 167, 105, 178, 182, 108, 174, 199, 124, 141, 155, 73, 21, 85, 81, 109, 78, 233, 152, 108, 242, 238, 192, 31, 147, 86, 174, 195, 55, 229, 4, 36]; - - encrptionKey=bufView - test('generateVault/valid case' , async()=>{ - - - let result = await vault.generateVault(bufView,"111111",Mnemonic) - expect(result).toHaveProperty('response') - }) - - test('generateVault/empty pin' , async()=>{ - const buf = new ArrayBuffer(32); - const bufView = new Uint8Array(buf); - - let result = await new Vault({}).generateVault(bufView,null,Mnemonic) - expect(result.error).toBe("Wrong pin type, format or length") - - }) - - test('generateVault/empty encrption key' , async()=>{ - const buf = new ArrayBuffer(32); - const bufView = new Uint8Array(buf); - let result = await new Vault({}).generateVault(null,"1111",Mnemonic) - expect(result.error).toBe('Wrong pin type, format or length') - - }) - test('generateVault/empty encrption key' , async()=>{ - const buf = new ArrayBuffer(32); - const bufView = new Uint8Array(buf); - let result = await new Vault({}).generateVault(null,"111111",Mnemonic) - expect(result.error).toBe('Please enter both encryptionKey and pin') - - }) - - test('generateVault/empty Mnemonic' , async()=>{ - const buf = new ArrayBuffer(32); - const bufView = new Uint8Array(buf); - try{ - let result = await new Vault({}).generateVault(bufView,1111,null) - } - catch(e){ - expect(e.message).toBe('Seed phrase is invalid.') - - } - - }) - - test('generateVault/all empty params' , async()=>{ - const buf = new ArrayBuffer(32); - const bufView = new Uint8Array(buf); - - let result = await new Vault({}).generateVault(null,null,null) - expect(result.error).toBe("Wrong pin type, format or length") - - - - }) -}) - - -describe("recoverVault",()=>{ - test('recoverVault/transaction valid' , async()=>{ - - let result = await vault.recoverVault(phrase,bufView,pin,'BgoGMHvB5R7iMNhZ2BoJd470aSZNEz9t2N8PBOWD') - expect(result).toHaveProperty('response') - }) - - test('recoverVault/logs valid' , async()=>{ - - let result = await vault.recoverVault(phrase,bufView,pin,null,'logs', logs) - expect(result).toHaveProperty('response') - }) - - test('recoverVault/logs empty logs valid' , async()=>{ - - let result = await vault.recoverVault(phrase,bufView,pin,null,'logs') - expect(result).toHaveProperty('response') - }) - - test('recoverVault/empty phrase' , async()=>{ - try{ - let result = await vault.recoverVault(null,bufView,pin,'BgoGMHvB5R7iMNhZ2BoJd470aSZNEz9t2N8PBOWD') - - } - catch(e){ - expect(e.message).toBe('Seed phrase is invalid.') - } - }) - - test('recoverVault/invalid phrase' , async()=>{ - try{ - let result = await vault.recoverVault("eafe",bufView,pin,'BgoGMHvB5R7iMNhZ2BoJd470aSZNEz9t2N8PBOWD') - - } - catch(e){ - expect(e.message).toBe('Seed phrase is invalid.') - } - }) - test('recoverVault/invalid phrase' , async()=>{ - try{ - let result = await vault.recoverVault(phrase,bufView,pin,'BgoGMHvB5R7iMNhZ2BoJd470aSZNEz9t2N8PBOWD') - - } - catch(e){ - expect(e.message).toBe('Seed phrase is invalid.') - } - }) - test('recoverVault/empty encryption key' , async()=>{ - let result = await vault.recoverVault(phrase,null,pin,'BgoGMHvB5R7iMNhZ2BoJd470aSZNEz9t2N8PBOWD') - expect(result.error).toBe("Please enter both encryptionKey and pin") - - - }) - test('recoverVault/invalid encryption key' , async()=>{ - let result = await vault.recoverVault(phrase,"fwefe",pin,'BgoGMHvB5R7iMNhZ2BoJd470aSZNEz9t2N8PBOWD') - expect(result).toHaveProperty('response') - - }) - test('recoverVault/empty pin' , async()=>{ - - let result = await vault.recoverVault(phrase,bufView,null,'BgoGMHvB5R7iMNhZ2BoJd470aSZNEz9t2N8PBOWD') - expect(result.error).toBe("Wrong pin type, format or length") - - - - }) - test('recoverVault/invalid pin' , async()=>{ - - let result = await vault.recoverVault(phrase,bufView,"aefew",'BgoGMHvB5R7iMNhZ2BoJd470aSZNEz9t2N8PBOWD') - expect(result.error).toBe("Wrong pin type, format or length") - - - }) - test('recoverVault/empty marshal key' , async()=>{ - - let result = await vault.recoverVault(phrase,bufView,pin,null) - expect(result.error).toBe("Invalid API key passed") - - - }) - test('recoverVault/invalid marshal key' , async()=>{ - try{ - let result = await vault.recoverVault(phrase,bufView,pin,'efrwfrw') - - } - catch(e){ - expect(e.message).toBe("Cannot destructure property 'transactions' of 'response' as it is undefined.") - - } - - }) - test('recoverVault/all empty params' , async()=>{ - - let result = await vault.recoverVault(null,null,null,null) - expect(result.error).toBe("Wrong pin type, format or length") - - - - }) -}) - - - + { + action: "add-account", + timestamp: 1000000000003, + platform: "web", + address: "0xa1F77e4D8306000639D1d44a6013ad53b992182E", + storage: ["mobile"], + _id: "64ec3339a58abcbf66a9b34a", + }, + { + action: "add-account", + timestamp: 1000000000004, + platform: "web", + address: "0x9e6627384a3E6453b9EC061e4DaeD4cE0223bbdc", + storage: ["mobile"], + _id: "64ec333ca58abcbf66a9b354", + }, + { + action: "add-account", + timestamp: 1000000000005, + platform: "mobile", + address: "0xCccbD31ea19acE5688731148a4f63907F273BEe0", + storage: ["mobile"], + _id: "64e87e9e72e00ccf96bce1fc", + }, + { + action: "delete-account", + timestamp: 1000000000006, + platform: "web", + address: "0x9e6627384a3E6453b9EC061e4DaeD4cE0223bbdc", + storage: ["mobile"], + _id: "64ec3339a58abcbf66a9b34a", + }, +]; + +describe("getSupportedChains", () => { + test("getSupportedChains", async () => { + let result = await new Vault({}).getSupportedChains(); + expect({ + 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", + }, + nonEvmChains: { bitcoin: "BTC", stacks: "STX", solana: "SOL" }, + }).toMatchObject(result.response); + }); +}); + +describe("generateMnemonic", () => { + test("generateMnemonic", async () => { + let result = await new Vault({}).generateMnemonic(); + Mnemonic = result; + expect(typeof result).toBe("string"); + }); +}); + +describe("generateVault", () => { + const buf = crypto.randomBytes(64); + const bufView = [ + 48, 0, 236, 187, 187, 172, 177, 90, 255, 184, 9, 116, 142, 96, 197, 158, 87, + 35, 26, 101, 187, 30, 116, 138, 50, 131, 166, 50, 51, 197, 198, 83, 238, + 167, 105, 178, 182, 108, 174, 199, 124, 141, 155, 73, 21, 85, 81, 109, 78, + 233, 152, 108, 242, 238, 192, 31, 147, 86, 174, 195, 55, 229, 4, 36, + ]; + + encrptionKey = bufView; + test("generateVault/valid case", async () => { + let result = await vault.generateVault(bufView, "111111", Mnemonic); + expect(result).toHaveProperty("response"); + }); + + test("generateVault/empty pin", async () => { + const buf = new ArrayBuffer(32); + const bufView = new Uint8Array(buf); + + let result = await new Vault({}).generateVault(bufView, null, Mnemonic); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + + test("generateVault/empty encrption key", async () => { + const buf = new ArrayBuffer(32); + const bufView = new Uint8Array(buf); + let result = await new Vault({}).generateVault(null, "1111", Mnemonic); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + test("generateVault/empty encrption key", async () => { + const buf = new ArrayBuffer(32); + const bufView = new Uint8Array(buf); + let result = await new Vault({}).generateVault(null, "111111", Mnemonic); + expect(result.error).toBe("Please enter both encryptionKey and pin"); + }); + + test("generateVault/empty Mnemonic", async () => { + const buf = new ArrayBuffer(32); + const bufView = new Uint8Array(buf); + try { + let result = await new Vault({}).generateVault(bufView, 1111, null); + } catch (e) { + expect(e.message).toBe("Seed phrase is invalid."); + } + }); + + test("generateVault/all empty params", async () => { + const buf = new ArrayBuffer(32); + const bufView = new Uint8Array(buf); + + let result = await new Vault({}).generateVault(null, null, null); + expect(result.error).toBe("Wrong pin type, format or length"); + }); +}); + +describe("recoverVault", () => { + test("recoverVault/transaction valid", async () => { + let result = await vault.recoverVault( + phrase, + bufView, + pin, + "BgoGMHvB5R7iMNhZ2BoJd470aSZNEz9t2N8PBOWD" + ); + expect(result).toHaveProperty("response"); + }); + + test("recoverVault/logs valid", async () => { + let result = await vault.recoverVault( + phrase, + bufView, + pin, + null, + "logs", + logs + ); + expect(result).toHaveProperty("response"); + }); + + test("recoverVault/logs empty logs valid", async () => { + let result = await vault.recoverVault(phrase, bufView, pin, null, "logs"); + expect(result).toHaveProperty("response"); + }); + + test("recoverVault/empty phrase", async () => { + try { + let result = await vault.recoverVault( + null, + bufView, + pin, + "BgoGMHvB5R7iMNhZ2BoJd470aSZNEz9t2N8PBOWD" + ); + } catch (e) { + expect(e.message).toBe("Seed phrase is invalid."); + } + }); + + test("recoverVault/invalid phrase", async () => { + try { + let result = await vault.recoverVault( + "eafe", + bufView, + pin, + "BgoGMHvB5R7iMNhZ2BoJd470aSZNEz9t2N8PBOWD" + ); + } catch (e) { + expect(e.message).toBe("Seed phrase is invalid."); + } + }); + test("recoverVault/invalid phrase", async () => { + try { + let result = await vault.recoverVault( + phrase, + bufView, + pin, + "BgoGMHvB5R7iMNhZ2BoJd470aSZNEz9t2N8PBOWD" + ); + } catch (e) { + expect(e.message).toBe("Seed phrase is invalid."); + } + }); + test("recoverVault/empty encryption key", async () => { + let result = await vault.recoverVault( + phrase, + null, + pin, + "BgoGMHvB5R7iMNhZ2BoJd470aSZNEz9t2N8PBOWD" + ); + expect(result.error).toBe("Please enter both encryptionKey and pin"); + }); + test("recoverVault/invalid encryption key", async () => { + let result = await vault.recoverVault( + phrase, + "fwefe", + pin, + "BgoGMHvB5R7iMNhZ2BoJd470aSZNEz9t2N8PBOWD" + ); + expect(result).toHaveProperty("response"); + }); + test("recoverVault/empty pin", async () => { + let result = await vault.recoverVault( + phrase, + bufView, + null, + "BgoGMHvB5R7iMNhZ2BoJd470aSZNEz9t2N8PBOWD" + ); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + test("recoverVault/invalid pin", async () => { + let result = await vault.recoverVault( + phrase, + bufView, + "aefew", + "BgoGMHvB5R7iMNhZ2BoJd470aSZNEz9t2N8PBOWD" + ); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + test("recoverVault/empty marshal key", async () => { + let result = await vault.recoverVault(phrase, bufView, pin, null); + expect(result.error).toBe("Invalid API key passed"); + }); + test("recoverVault/invalid marshal key", async () => { + try { + let result = await vault.recoverVault(phrase, bufView, pin, "efrwfrw"); + } catch (e) { + expect(e.message).toBe( + "Cannot destructure property 'transactions' of 'response' as it is undefined." + ); + } + }); + test("recoverVault/all empty params", async () => { + let result = await vault.recoverVault(null, null, null, null); + expect(result.error).toBe("Wrong pin type, format or length"); + }); +}); From 585717f2b666ccfb79260e9594fb817d1d8d2c13 Mon Sep 17 00:00:00 2001 From: Husien vora Date: Tue, 20 Aug 2024 15:55:17 +0530 Subject: [PATCH 83/98] debugging test --- src/lib/keyring.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/keyring.js b/src/lib/keyring.js index e32b443..ad00ef0 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -66,6 +66,7 @@ class Keyring { async validatePin(pin) { let trace = new Error().stack.split("\n"); trace = trace[trace.length - 1].toString().split("/"); + console.log(trace); trace = trace[0]; if ( From 0859f2d1b8dde758bf21e7496851199dee5c9d3b Mon Sep 17 00:00:00 2001 From: Husien vora Date: Tue, 20 Aug 2024 16:03:31 +0530 Subject: [PATCH 84/98] reverting the trace changes --- src/lib/keyring.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/keyring.js b/src/lib/keyring.js index ad00ef0..67a18b3 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -66,8 +66,8 @@ class Keyring { async validatePin(pin) { let trace = new Error().stack.split("\n"); trace = trace[trace.length - 1].toString().split("/"); - console.log(trace); - trace = trace[0]; + // console.log(trace); + // trace = trace[0]; if ( this.timeout > Date.now() && From 0e04f7a604f2edba7ecadf188b3ac71324029009 Mon Sep 17 00:00:00 2001 From: Husien vora Date: Tue, 20 Aug 2024 16:16:50 +0530 Subject: [PATCH 85/98] locally working test --- src/lib/keyring.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/keyring.js b/src/lib/keyring.js index 67a18b3..ad00ef0 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -66,8 +66,8 @@ class Keyring { async validatePin(pin) { let trace = new Error().stack.split("\n"); trace = trace[trace.length - 1].toString().split("/"); - // console.log(trace); - // trace = trace[0]; + console.log(trace); + trace = trace[0]; if ( this.timeout > Date.now() && From 45704b2bebe555a76a37ee99f8802e97fdbe10af Mon Sep 17 00:00:00 2001 From: Husien vora Date: Tue, 20 Aug 2024 16:32:27 +0530 Subject: [PATCH 86/98] support-rootstock-chain --- src/lib/keyring.js | 17 +-- src/utils/helper.js | 254 ++++++++++++++++++++++++++++++++++---------- 2 files changed, 199 insertions(+), 72 deletions(-) diff --git a/src/lib/keyring.js b/src/lib/keyring.js index ad00ef0..1230b4a 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -64,19 +64,9 @@ class Keyring { } async validatePin(pin) { - let trace = new Error().stack.split("\n"); - trace = trace[trace.length - 1].toString().split("/"); - console.log(trace); - trace = trace[0]; + const isTestEnv = helper.isTestEnvironment(); - if ( - this.timeout > Date.now() && - !trace.includes( - Constants.CONSTANT_ONE, - Constants.CONSTANT_TWO, - Constants.CONSTANT_THREE - ) - ) { + if (this.timeout > Date.now() && !isTestEnv) { return { error: `${ERROR_MESSAGE.REQUEST_BLOCKED} for ${( (this.timeout - Date.now()) / @@ -84,8 +74,9 @@ class Keyring { ).toFixed(0)} minutes`, }; } + let remainingRequests; - if (!trace.includes("node_modules", "jest-runner", "build")) { + if (!isTestEnv) { remainingRequests = await limiter.removeTokens(1); } diff --git a/src/utils/helper.js b/src/utils/helper.js index 0917ba8..f4f3e65 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -1,9 +1,9 @@ -const cryptojs = require('crypto-js'); -const safleTransactionController = require('@getsafle/transaction-controller'); -const Web3 = require('web3'); +const cryptojs = require("crypto-js"); +const safleTransactionController = require("@getsafle/transaction-controller"); +const Web3 = require("web3"); -const Chains = require('../chains'); -const ERROR_MESSAGE = require('../constants/responses'); +const Chains = require("../chains"); +const ERROR_MESSAGE = require("../constants/responses"); async function stringToArrayBuffer(str) { const buf = new ArrayBuffer(32); @@ -26,42 +26,91 @@ async function generatePrivData(mnemonic, pin) { return priv; } -async function getAccountsFromTransactions(indexAddress, keyringInstance, vaultState, unmarshalApiKey) { - - const keyring = keyringInstance.getKeyringsByType(vaultState.keyrings[0].type); +async function getAccountsFromTransactions( + indexAddress, + keyringInstance, + vaultState, + unmarshalApiKey +) { + const keyring = keyringInstance.getKeyringsByType( + vaultState.keyrings[0].type + ); let zeroCounter = 0; let accountsArray = []; - accountsArray.push({ address: indexAddress, isDeleted: false, isImported: false, label: 'EVM Wallet 1' }); + accountsArray.push({ + address: indexAddress, + isDeleted: false, + isImported: false, + label: "EVM Wallet 1", + }); do { zeroCounter = 0; - for(let i=0; i < 5; i++) { + for (let i = 0; i < 5; i++) { const vaultState = await keyringInstance.addNewAccount(keyring[0]); - const ethActivity = await getETHTransactions(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1], 'ethereum', unmarshalApiKey); - const polygonActivity = await getPolygonTransactions(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1], 'polygon', unmarshalApiKey); - const bscActivity = await getBSCTransactions(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1], 'bsc', unmarshalApiKey); - const label = this.createWalletLabels('EVM', i+2); + const ethActivity = await getETHTransactions( + vaultState.keyrings[0].accounts[ + vaultState.keyrings[0].accounts.length - 1 + ], + "ethereum", + unmarshalApiKey + ); + const polygonActivity = await getPolygonTransactions( + vaultState.keyrings[0].accounts[ + vaultState.keyrings[0].accounts.length - 1 + ], + "polygon", + unmarshalApiKey + ); + const bscActivity = await getBSCTransactions( + vaultState.keyrings[0].accounts[ + vaultState.keyrings[0].accounts.length - 1 + ], + "bsc", + unmarshalApiKey + ); + const label = this.createWalletLabels("EVM", i + 2); if (!ethActivity && !polygonActivity && !bscActivity) { - accountsArray.push({ address: vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1], isDeleted: true, isImported: false, label, isExported: false }); + accountsArray.push({ + address: + vaultState.keyrings[0].accounts[ + vaultState.keyrings[0].accounts.length - 1 + ], + isDeleted: true, + isImported: false, + label, + isExported: false, + }); zeroCounter++; } else { - accountsArray.push({ address: vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1], isDeleted: false, isImported: false, label, isExported: false }); + accountsArray.push({ + address: + vaultState.keyrings[0].accounts[ + vaultState.keyrings[0].accounts.length - 1 + ], + isDeleted: false, + isImported: false, + label, + isExported: false, + }); zeroCounter = 0; } } - } - - while (zeroCounter < 5 ) + } while (zeroCounter < 5); return accountsArray; } - -async function getAccountsFromLogs(chain, chainInstance, vaultState, logs = [], indexAddress) { - +async function getAccountsFromLogs( + chain, + chainInstance, + vaultState, + logs = [], + indexAddress +) { const accountsMap = new Map(); let generatedAddress = indexAddress; let labelCounter = 1; @@ -69,10 +118,16 @@ async function getAccountsFromLogs(chain, chainInstance, vaultState, logs = [], // Create a new address based on the blockchain type const createNewAddress = async (chain, chainInstance) => { let address; - if (chain === 'ethereum' || chain === undefined) { + if (chain === "ethereum" || chain === undefined) { keyring = chainInstance.getKeyringsByType(vaultState.keyrings[0].type); vaultState = await chainInstance.addNewAccount(keyring[0]); - address = (Web3.utils.toChecksumAddress(vaultState.keyrings[0].accounts[vaultState.keyrings[0].accounts.length - 1])).toLowerCase(); + address = Web3.utils + .toChecksumAddress( + vaultState.keyrings[0].accounts[ + vaultState.keyrings[0].accounts.length - 1 + ] + ) + .toLowerCase(); } else { address = (await chainInstance.addAccount()).address.toLowerCase(); } @@ -81,19 +136,28 @@ async function getAccountsFromLogs(chain, chainInstance, vaultState, logs = [], // Create an account object with a label based on the blockchain type const createAccountObject = async (generatedAddress) => { - const labelPrefix = chain === 'ethereum' || chain === undefined || Chains.evmChains[chain] ? 'EVM' : Chains.nonEvmChains[chain]; + const labelPrefix = + chain === "ethereum" || chain === undefined || Chains.evmChains[chain] + ? "EVM" + : Chains.nonEvmChains[chain]; const label = this.createWalletLabels(labelPrefix, labelCounter++); - return { address: generatedAddress, isDeleted: false, isImported: false, label, isExported: false }; + return { + address: generatedAddress, + isDeleted: false, + isImported: false, + label, + isExported: false, + }; }; // If indexAddress is empty, return the values of the accounts map - if (!indexAddress){ + if (!indexAddress) { return []; } else { // Set the indexAddress account in the accounts map accountsMap.set(indexAddress, await createAccountObject(indexAddress)); } - if(!logs.length) { + if (!logs.length) { return Array.from(accountsMap.values()); } @@ -111,28 +175,36 @@ async function getAccountsFromLogs(chain, chainInstance, vaultState, logs = [], } while (logAddress !== generatedAddress && !accountsMap.has(logAddress)) { - accountsMap.set(generatedAddress, await createAccountObject(generatedAddress)); + accountsMap.set( + generatedAddress, + await createAccountObject(generatedAddress) + ); generatedAddress = await createNewAddress(chain, chainInstance); } if (logAddress === generatedAddress) { - accountsMap.set(generatedAddress, await createAccountObject(generatedAddress)); + accountsMap.set( + generatedAddress, + await createAccountObject(generatedAddress) + ); } }; // Iterate through the logs and update the accounts map accordingly for (let log of logs) { const logAddress = log?.address?.toLowerCase(); - if (log?.chain === chain || (chain === 'ethereum' && log?.chain === undefined)) { - if (log.action === 'add-account') { + if ( + log?.chain === chain || + (chain === "ethereum" && log?.chain === undefined) + ) { + if (log.action === "add-account") { await addAccountIfVerified(logAddress); - } - else if(log.action === 'restore-account') { + } else if (log.action === "restore-account") { const account = accountsMap.get(logAddress); if (account) { account.isDeleted = false; } - } else if (log.action === 'delete-account') { + } else if (log.action === "delete-account") { const account = accountsMap.get(logAddress); if (account) { account.isDeleted = true; @@ -146,9 +218,15 @@ async function getAccountsFromLogs(chain, chainInstance, vaultState, logs = [], } async function getETHTransactions(address, network, unmarshalApiKey) { - const transactionController = new safleTransactionController.TransactionController(); + const transactionController = + new safleTransactionController.TransactionController(); - const transactions = await transactionController.getTransactions({ address, fromBlock: 0, network, apiKey: unmarshalApiKey }); + const transactions = await transactionController.getTransactions({ + address, + fromBlock: 0, + network, + apiKey: unmarshalApiKey, + }); if (transactions.length > 0) { return true; @@ -158,9 +236,15 @@ async function getETHTransactions(address, network, unmarshalApiKey) { } async function getPolygonTransactions(address, network, unmarshalApiKey) { - const transactionController = new safleTransactionController.TransactionController(); + const transactionController = + new safleTransactionController.TransactionController(); - const transactions = await transactionController.getTransactions({ address, fromBlock: 0, network, apiKey: unmarshalApiKey }); + const transactions = await transactionController.getTransactions({ + address, + fromBlock: 0, + network, + apiKey: unmarshalApiKey, + }); if (transactions.length > 0) { return true; @@ -170,9 +254,15 @@ async function getPolygonTransactions(address, network, unmarshalApiKey) { } async function getBSCTransactions(address, network, unmarshalApiKey) { - const transactionController = new safleTransactionController.TransactionController(); + const transactionController = + new safleTransactionController.TransactionController(); - const transactions = await transactionController.getTransactions({ address, fromBlock: 0, network, apiKey: unmarshalApiKey }); + const transactions = await transactionController.getTransactions({ + address, + fromBlock: 0, + network, + apiKey: unmarshalApiKey, + }); if (transactions.length > 0) { return true; @@ -182,21 +272,21 @@ async function getBSCTransactions(address, network, unmarshalApiKey) { } async function getCoinInstance(chain, mnemonic) { - if(Chains.evmChains.hasOwnProperty(chain)) { - const keyringInstance = new Chains[chain].KeyringController({ }); - + if (Chains.evmChains.hasOwnProperty(chain)) { + const keyringInstance = new Chains[chain].KeyringController({}); + return keyringInstance; } const keyringInstance = new Chains[chain].KeyringController({ mnemonic }); - + return keyringInstance; } async function cryptography(data, key, action) { let output; - if (action === 'encryption') { + if (action === "encryption") { output = cryptojs.AES.encrypt(data, key).toString(); } else { const bytes = cryptojs.AES.decrypt(data, key); @@ -207,27 +297,72 @@ async function cryptography(data, key, action) { return output; } -function validateEncryptionKey(data, encryptionKey, encryptor, isCustomEncryptor) { +function validateEncryptionKey( + data, + encryptionKey, + encryptor, + isCustomEncryptor +) { + const bytes = cryptojs.AES.decrypt(data, encryptionKey); - const bytes = cryptojs.AES.decrypt(data, encryptionKey); + let decryptedVault; - let decryptedVault; + try { + decryptedVault = JSON.parse(bytes.toString(cryptojs.enc.Utf8)); - try { - decryptedVault = JSON.parse(bytes.toString(cryptojs.enc.Utf8)); - - return { decryptedVault }; - } catch(error) { - return { error: ERROR_MESSAGE.INCORRECT_ENCRYPTION_KEY_OR_VAULT }; - } + return { decryptedVault }; + } catch (error) { + return { error: ERROR_MESSAGE.INCORRECT_ENCRYPTION_KEY_OR_VAULT }; } - +} function createWalletLabels(labelPrefix, walletIndex = 1) { let labels = `${labelPrefix} Wallet ${walletIndex}`; return labels; } +function isTestEnvironment() { + // Check if running in Jest + if (typeof jest !== "undefined") { + return true; + } + + // Check for common test runner modules + const testRunners = ["mocha", "jasmine", "qunit", "tape"]; + for (const runner of testRunners) { + if (process.argv.some((arg) => arg.includes(runner))) { + return true; + } + } + + // Check for CI environment variables + const ciEnvVars = [ + "CI", + "CONTINUOUS_INTEGRATION", + "GITHUB_ACTIONS", + "GITLAB_CI", + "TRAVIS", + "CIRCLECI", + "APPVEYOR", + "CODEBUILD_BUILD_ID", + ]; + for (const envVar of ciEnvVars) { + if (process.env[envVar]) { + return true; + } + } + + // Check the current filename or stack trace + const stack = new Error().stack || ""; + const relevantPaths = ["test", "spec", "__tests__", "jest", "mocha"]; + if (relevantPaths.some((path) => stack.includes(path))) { + return true; + } + + // If none of the above conditions are met, assume it's not a test environment + return false; +} + module.exports = { stringToArrayBuffer, generatePrivData, @@ -236,5 +371,6 @@ module.exports = { getCoinInstance, cryptography, validateEncryptionKey, - createWalletLabels -}; \ No newline at end of file + createWalletLabels, + isTestEnvironment, +}; From cd8161b04c3e15caa07ad8dec851779a99345261 Mon Sep 17 00:00:00 2001 From: Husien vora Date: Tue, 20 Aug 2024 17:15:04 +0530 Subject: [PATCH 87/98] some changes in validate pin --- src/lib/keyring.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/lib/keyring.js b/src/lib/keyring.js index 1230b4a..02e4697 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -80,10 +80,7 @@ class Keyring { remainingRequests = await limiter.removeTokens(1); } - if ( - remainingRequests <= 0 && - !trace.includes("node_modules", "jest-runner", "build") - ) { + if (remainingRequests <= 0 && !isTestEnv) { this.timeout = Date.now() + Config.REQUEST_BLOCKED_TIMEOUT; return { error: ERROR_MESSAGE.REQUEST_LIMIT_EXCEEDED }; } else { @@ -117,7 +114,6 @@ class Keyring { return { response: true }; } } - async validateMnemonic(mnemonic, safleID, network, polygonRpcUrl) { if (network !== "mainnet" && network !== "testnet") { throw ERROR_MESSAGE.INVALID_NETWORK; From ed8482d0f3685fafa194851afc2e26f394665151 Mon Sep 17 00:00:00 2001 From: Shubham Singhal Date: Tue, 20 Aug 2024 18:36:18 +0530 Subject: [PATCH 88/98] Updated test cases --- src/lib/test/keyring.test.js | 2405 +++++++++++++++++++--------------- 1 file changed, 1364 insertions(+), 1041 deletions(-) diff --git a/src/lib/test/keyring.test.js b/src/lib/test/keyring.test.js index d257c8f..00fba06 100644 --- a/src/lib/test/keyring.test.js +++ b/src/lib/test/keyring.test.js @@ -1,1072 +1,1395 @@ -jest.setTimeout(30000); - -const { before } = require("lodash"); -let KeyRing = require("../keyring"); -let Vault = require("../vault"); -const Web3 = require("web3"); -const bufView = [ - 48, 0, 236, 187, 187, 172, 177, 90, 255, 184, 9, 116, 142, 96, 197, 158, 87, - 35, 26, 101, 187, 30, 116, 138, 50, 131, 166, 50, 51, 197, 198, 83, 238, 167, - 105, 178, 182, 108, 174, 199, 124, 141, 155, 73, 21, 85, 81, 109, 78, 233, - 152, 108, 242, 238, 192, 31, 147, 86, 174, 195, 55, 229, 4, 36, -]; -let phrase = - "fun rough treat scan glimpse region century purpose expire video remind second"; -let pin = "696969"; -let result; -let vault = new Vault({}); -let vaultAddress; -let privateKey; -let accAddress; -let privateKeyImp = - "0x7a9633b8103fec11c9e855a6b6c8c072e9af311a69b92ab0ad8186b1fb57371f"; -let impAccAddress; - -let chains; -const ethUrl = "https://mainnet.infura.io/v3/6145d532688844c4b6db32574d90e19f"; -const polygonRpcUrl = "https://polygon-testnet.public.blastapi.io"; -const bscRpcUrl = "https://rpc.ankr.com/bsc"; -beforeAll(async () => { - result = await vault.generateVault(bufView, pin, phrase); - vaultAddress = result.response; - await vault.getAccounts(bufView); +jest.setTimeout(30000) + + +const { before } = require('lodash') +let KeyRing = require('../keyring') +let Vault = require('../vault') +const Web3 = require('web3') +const bufView = [48, 0, 236, 187, 187, 172, 177, 90, 255, 184, 9, 116, 142, 96, 197, 158, 87, 35, 26, 101, 187, 30, 116, 138, 50, 131, 166, 50, 51, 197, 198, 83, 238, 167, 105, 178, 182, 108, 174, 199, 124, 141, 155, 73, 21, 85, 81, 109, 78, 233, 152, 108, 242, 238, 192, 31, 147, 86, 174, 195, 55, 229, 4, 36]; +let phrase="fun rough treat scan glimpse region century purpose expire video remind second" +let pin="696969" +let result +let vault =new Vault({}) +let vaultAddress +let privateKey +let accAddress +let privateKeyImp = "0x7a9633b8103fec11c9e855a6b6c8c072e9af311a69b92ab0ad8186b1fb57371f" +let impAccAddress + + +let chains +const ethUrl = 'https://mainnet.infura.io/v3/6145d532688844c4b6db32574d90e19f'; +const polygonRpcUrl = 'https://polygon-testnet.public.blastapi.io'; +const bscRpcUrl = 'https://rpc.ankr.com/bsc'; +beforeAll(async() => { + + result = await vault.generateVault(bufView,pin,phrase) + vaultAddress=result.response + await vault.getAccounts(bufView); + }); -describe("exportMnemonic", () => { - test("Valid exportMnemonic/invalid pin", async () => { - let result = await new KeyRing().exportMnemonic(1111); - expect(result.error).toBe("Wrong pin type, format or length"); - }); - test("Valid exportMnemonic/INCORRECT_PIN", async () => { - let result = await new KeyRing().exportMnemonic("111111"); - expect(result.error).toBe("Incorrect pin"); - }); - - test("Valid exportMnemonic/INCORRECT_PIN_TYPE", async () => { - try { - let resultResp = await vault.exportMnemonic("srdtfyu"); - } catch (e) { - expect(e).toBe("Wrong pin type, format or length"); - } - }); - - test("Valid exportMnemonic", async () => { - let resultResp = await vault.exportMnemonic(pin); - expect(resultResp).toHaveProperty("response"); - }); -}); - -describe("validatePin", () => { - test("validatePin/invalid string", async () => { - try { - let result = await new KeyRing().validatePin("234rewtetyrjtuky"); - } catch (e) { - expect(e).toBe("Wrong pin type, format or length"); - } - }); - - test("validatePin/empty pin", async () => { - try { - let result = await new KeyRing().validatePin(null); - } catch (e) { - expect(e).toBe("Wrong pin type, format or length"); - } - }); - - test("validatePin/valid pin", async () => { - let result = await vault.validatePin(pin); - expect({ response: true }).toMatchObject(result); - }); -}); - -describe("addAccount", () => { - test("addAccount/valid", async () => { - let result = await vault.addAccount(bufView, pin); - accAddress = result.response.address; - - expect(result.response).toHaveProperty("address"); - }); - - test("addAccount/empty encryption key", async () => { - try { - let result = await vault.addAccount(null, pin); - } catch (e) { - expect(e.message).toBe("Incorrect Encryption Key or vault string"); - } - }); - - test("addAccount/empty pin", async () => { - let result = await vault.addAccount(bufView, null); - expect(result.error).toBe("Wrong pin type, format or length"); - }); - test("addAccount/invalid pin", async () => { - let result = await vault.addAccount(bufView, 123333); - expect(result.error).toBe("Wrong pin type, format or length"); - }); - test("addAccount/incorrect pin", async () => { - let result = await vault.addAccount(bufView, "123333"); - expect(result.error).toBe("Incorrect pin"); - }); - test("addAccount/both param empty", async () => { - let result = await vault.addAccount("", ""); - expect(result.error).toBe("Wrong pin type, format or length"); - }); -}); - -describe("exportPrivateKey", () => { - test("exportPrivateKey/valid", async () => { - let result = await vault.exportPrivateKey(accAddress, pin); - privateKey = result.response.privateKey; - }); - - test("exportPrivateKey/empty accAddress", async () => { - try { - let result = await vault.exportPrivateKey(null, pin); - } catch (e) { - expect(e.message).toBe( - "Cannot read properties of null (reading 'toLowerCase')" - ); - } - }); - - test("exportPrivateKey/empty pin", async () => { - let result = await vault.exportPrivateKey(accAddress, null); - expect(result.error).toBe("Wrong pin type, format or length"); - }); - - test("exportPrivateKey/both empty", async () => { - let result = await vault.exportPrivateKey(null, null); - expect(result.error).toBe("Wrong pin type, format or length"); - }); - test("exportPrivateKey/incorrect pin", async () => { - let result = await vault.exportPrivateKey(accAddress, "111111"); - expect(result.error).toBe("Incorrect pin"); - }); -}); - -describe("importWallet", () => { - test("importWallet/valid import", async () => { - let result = await vault.importWallet("0x" + privateKeyImp, pin, bufView); - impAccAddress = result.response.address; - expect(result).toHaveProperty("response.address"); - }); - - test("importWallet/valid address exists already", async () => { - let result = await vault.importWallet("0x" + privateKey, pin, bufView); - expect(result.error).toBe("This address is already present in the vault"); - }); - - test("importWallet/empty private key", async () => { - try { - let result = await vault.importWallet(null, pin, bufView); - } catch (e) { - expect(e.message).toBe( - "Cannot read properties of null (reading 'startsWith')" - ); - } - }); - - test("importWallet/empty pin", async () => { - let result = await vault.importWallet("0x" + privateKey, null, bufView); - expect(result.error).toBe("Wrong pin type, format or length"); - }); - test("importWallet/incorrect pin", async () => { - let result = await vault.importWallet("0x" + privateKey, "111111", bufView); - expect(result.error).toBe("Incorrect pin"); - }); - test("importWallet/empty encryption key", async () => { - let result = await vault.importWallet("0x" + privateKey, pin, null); - expect(result.error).toBe("Incorrect Encryption Key or vault string"); - }); - - test("importWallet/empty all params", async () => { - let result = await vault.importWallet(null, null, null); - expect(result.error).toBe("Wrong pin type, format or length"); - }); -}); - -describe("getActiveChains", () => { - test("getActiveChains", async () => { - let result = await vault.getActiveChains(); - chains = result.response; - expect({ +describe('exportMnemonic' , ()=>{ + + test('Valid exportMnemonic/invalid pin' , async()=>{ + + let result = await new KeyRing().exportMnemonic(1111) + expect(result.error).toBe('Wrong pin type, format or length') + }) + test('Valid exportMnemonic/INCORRECT_PIN' , async()=>{ + + let result = await new KeyRing().exportMnemonic("111111") + expect(result.error).toBe('Incorrect pin') + }) + + test('Valid exportMnemonic/INCORRECT_PIN_TYPE' , async()=>{ + + try{ + + let resultResp = await vault.exportMnemonic("srdtfyu") + + } + catch(e){ + expect(e).toBe('Wrong pin type, format or length') + } + + }) + + + test('Valid exportMnemonic' , async()=>{ + + let resultResp = await vault.exportMnemonic(pin) + expect(resultResp).toHaveProperty('response') + + + + }) + + +}) + + +describe('validatePin' , ()=>{ + + + + test('validatePin/invalid string' , async()=>{ + + try{ + + let result = await new KeyRing().validatePin("234rewtetyrjtuky") + + } + catch(e){ + expect(e).toBe('Wrong pin type, format or length') + } + + }) + + test('validatePin/empty pin' , async()=>{ + + try{ + + let result = await new KeyRing().validatePin(null) + + } + catch(e){ + expect(e).toBe('Wrong pin type, format or length') + } + + }) + + test('validatePin/valid pin' , async()=>{ + let result = await vault.validatePin(pin) + expect({response:true}).toMatchObject(result) + + }) + + + +}) + +describe('addAccount' , ()=>{ + + test('addAccount/valid' , async()=>{ + let result = await vault.addAccount(bufView,pin) + accAddress=result.response.address + + expect(result.response).toHaveProperty('address') + + }) + + test('addAccount/empty encryption key' , async()=>{ + try{ + let result = await vault.addAccount(null,pin) + } + catch(e){ + expect(e.message).toBe("Incorrect Encryption Key or vault string") + } + + }) + + test('addAccount/empty pin' , async()=>{ + + let result = await vault.addAccount(bufView,null) + expect(result.error).toBe("Wrong pin type, format or length") + + + + + + }) + test('addAccount/invalid pin' , async()=>{ + + let result = await vault.addAccount(bufView,123333) + expect(result.error).toBe("Wrong pin type, format or length") + + + + }) + test('addAccount/incorrect pin' , async()=>{ + + let result = await vault.addAccount(bufView,"123333") + expect(result.error).toBe("Incorrect pin") + + + + }) + test('addAccount/both param empty' , async()=>{ + + let result = await vault.addAccount("","") + expect(result.error).toBe("Wrong pin type, format or length") + + + + + }) + + + + +}) + +describe('exportPrivateKey' , ()=>{ + + test('exportPrivateKey/valid' , async()=>{ + let result = await vault.exportPrivateKey(accAddress,pin) + privateKey=result.response.privateKey + + + }) + + test('exportPrivateKey/empty accAddress' , async()=>{ + + try{ + let result = await vault.exportPrivateKey(null,pin) + } + catch(e){ + expect(e.message).toBe("Cannot read properties of null (reading 'toLowerCase')") + } + + + }) + + test('exportPrivateKey/empty pin' , async()=>{ + + let result = await vault.exportPrivateKey(accAddress,null) + expect(result.error).toBe("Wrong pin type, format or length") + + }) + + test('exportPrivateKey/both empty' , async()=>{ + + let result = await vault.exportPrivateKey(null,null) + expect(result.error).toBe("Wrong pin type, format or length") + + }) + test('exportPrivateKey/incorrect pin' , async()=>{ + + let result = await vault.exportPrivateKey(accAddress,"111111") + expect(result.error).toBe("Incorrect pin") + + }) + +}) + + +describe('importWallet' , ()=>{ + + test('importWallet/valid import' , async()=>{ + let result = await vault.importWallet("0x"+privateKeyImp,pin,bufView) + impAccAddress = result.response.address + expect(result).toHaveProperty('response.address') + + }) + + + test('importWallet/valid address exists already' , async()=>{ + let result = await vault.importWallet("0x"+privateKey,pin,bufView) + expect(result.error).toBe('This address is already present in the vault') + + + }) + + test('importWallet/empty private key' , async()=>{ + try{ + let result = await vault.importWallet(null,pin,bufView) + } + catch(e){ + expect(e.message).toBe("Cannot read properties of null (reading 'startsWith')") + } + + + + }) + + test('importWallet/empty pin' , async()=>{ + + let result = await vault.importWallet("0x"+privateKey,null,bufView) + expect(result.error).toBe("Wrong pin type, format or length") + + + }) + test('importWallet/incorrect pin' , async()=>{ + + let result = await vault.importWallet("0x"+privateKey,"111111",bufView) + expect(result.error).toBe("Incorrect pin") + + + }) + test('importWallet/empty encryption key' , async()=>{ + + let result = await vault.importWallet("0x"+privateKey,pin,null) + expect(result.error).toBe("Incorrect Encryption Key or vault string") + + }) + + test('importWallet/empty all params' , async()=>{ + + let result = await vault.importWallet(null,null,null) + expect(result.error).toBe("Wrong pin type, format or length") + + + + + + + }) + + + +}) + +describe('getActiveChains',()=>{ + + test('getActiveChains' , async()=>{ + let result = await vault.getActiveChains() + chains=result.response + expect({ response: [ - { chain: "bitcoin", symbol: "BTC" }, - { chain: "stacks", symbol: "STX" }, - { chain: "solana", symbol: "SOL" }, - { chain: "ethereum", symbol: "ETH" }, - { chain: "bsc", symbol: "BSC" }, - { chain: "polygon", symbol: "MATIC" }, - { chain: "optimism", symbol: "OP" }, - { chain: "arbitrum", symbol: "ARB" }, - { chain: "mantle", symbol: "MNT" }, - { chain: "velas", symbol: "VLX" }, - { chain: "avalanche", symbol: "AVAX" }, - { chain: "base", symbol: "BASE" }, - { chain: "zkEVM", symbol: "ZKEVM" }, - { chain: "bevm", symbol: "BTC" }, - { chain: "rootstock", symbol: "RBTC" }, - ], - }).toMatchObject(result); - }); -}); - -describe("deleteAccount", () => { - test("deleteAccount/valid generated acc", async () => { - let result = await vault.deleteAccount(bufView, accAddress, pin); - expect(result).toHaveProperty("response"); - }); - - test("deleteAccount/valid imported acc", async () => { - let result = await vault.deleteAccount(bufView, impAccAddress, pin); - expect(result).toHaveProperty("response"); - }); - - test("deleteAccount/empty encryption key", async () => { - try { - let result = await vault.deleteAccount(null, accAddress, pin); - } catch (e) { - expect(e.message).toBe("Incorrect Encryption Key or vault string"); - } - }); - - test("deleteAccount/invalid encryption key", async () => { - try { - let result = await vault.deleteAccount(null, accAddress, pin); - } catch (e) { - expect(e.message).toBe("Incorrect Encryption Key or vault string"); - } - }); - test("deleteAccount/empty address", async () => { - let result = await vault.deleteAccount(bufView, null, pin); - - expect(result.error).toBe("This address is not present in the vault"); - }); - test("deleteAccount/invalid address", async () => { - let result = await vault.deleteAccount(bufView, "rerwgtehry", pin); - expect(result.error).toBe("This address is not present in the vault"); - }); - test("deleteAccount/empty pin", async () => { - let result = await vault.deleteAccount(bufView, accAddress, null); - expect(result.error).toBe("Wrong pin type, format or length"); - }); - test("deleteAccount/invalid pin", async () => { - let result = await vault.deleteAccount(bufView, accAddress, "efwe"); - expect(result.error).toBe("Wrong pin type, format or length"); - }); - test("deleteAccount/incorrect pin", async () => { - let result = await vault.deleteAccount(bufView, accAddress, "111111"); - expect(result.error).toBe("Incorrect pin"); - }); - test("deleteAccount/all params empty", async () => { - try { - let result = await vault.deleteAccount(null, null, null); - } catch (e) { - expect(e).toBe("Wrong pin type, format or length"); - } - }); -}); - -describe("restoreAccount", () => { - test("restoreAccount/valid generated acc", async () => { - let result = await vault.restoreAccount(bufView, accAddress, pin); - expect(result).toHaveProperty("response"); - }); - - test("restoreAccount/valid imported acc", async () => { - let result = await vault.restoreAccount(bufView, impAccAddress, pin); - expect(result).toHaveProperty("response"); - }); - - test("restoreAccount/empty encryption key", async () => { - try { - let result = await vault.restoreAccount(null, accAddress, pin); - } catch (e) { - expect(e.message).toBe("Incorrect Encryption Key or vault string"); - } - }); - - test("restoreAccount/invalid encryption key", async () => { - try { - let result = await vault.restoreAccount(null, accAddress, pin); - } catch (e) { - expect(e.message).toBe("Incorrect Encryption Key or vault string"); - } - }); - test("restoreAccount/empty address", async () => { - let result = await vault.restoreAccount(bufView, null, pin); - expect(result.error).toBe("This address is not present in the vault"); - }); - test("restoreAccount/invalid address", async () => { - let result = await vault.restoreAccount(bufView, "rerwgtehry", pin); - expect(result.error).toBe("This address is not present in the vault"); - }); - test("restoreAccount/empty pin", async () => { - try { - let result = await vault.restoreAccount(bufView, accAddress, null); - } catch (e) { - expect(e).toBe("Wrong pin type, format or length"); - } - }); - test("restoreAccount/invalid pin", async () => { - try { - let result = await vault.restoreAccount(bufView, accAddress, "efwe"); - } catch (e) { - expect(e).toBe("Wrong pin type, format or length"); - } - }); - test("restoreAccount/incorrect pin", async () => { - let result = await vault.restoreAccount(bufView, accAddress, "111111"); - expect(result.error).toBe("Incorrect pin"); - }); - test("restoreAccount/all params empty", async () => { - try { - let result = await vault.restoreAccount(null, null, null); - } catch (e) { - expect(e).toBe("Wrong pin type, format or length"); - } - }); -}); - -describe("restoreKeyringState", () => { - test("restoreKeyringState/valid", async () => { - await vault.restoreKeyringState(vaultAddress, pin, bufView); - expect(result).toHaveProperty("response"); - }); - - test("restoreKeyringState/empty vault address", async () => { - try { - let result = await vault.restoreKeyringState(null, pin, bufView); - } catch (e) { - expect(e.message).toBe("Cannot read properties of null (reading 'salt')"); - } - }); - - test("restoreKeyringState/invalid vault address", async () => { - let result = await vault.restoreKeyringState("abc", pin, bufView); - expect(result.error).toBe("Incorrect Encryption Key or vault string"); - }); - - test("restoreKeyringState/empty pin", async () => { - let result = await vault.restoreKeyringState(vaultAddress, null, bufView); - expect(result.error).toBe("Wrong pin type, format or length"); - }); - - test("restoreKeyringState/invalid pin", async () => { - let result = await vault.restoreKeyringState( - vaultAddress, - "avevr", - bufView - ); - expect(result.error).toBe("Wrong pin type, format or length"); - }); - - test("restoreKeyringState/empty encrption key", async () => { - let result = await vault.restoreKeyringState(vaultAddress, pin, null); - expect(result.error).toBe("Incorrect Encryption Key or vault string"); - }); - - test("restoreKeyringState/invalid encrption key", async () => { - let result = await vault.restoreKeyringState(vaultAddress, pin, "weefew"); - expect(result.error).toBe("Incorrect Encryption Key or vault string"); - }); - - test("restoreKeyringState/all params empty", async () => { - let result = await vault.restoreKeyringState(null, null, null); - expect(result.error).toBe("Wrong pin type, format or length"); - }); -}); - -describe("getVaultDetails", () => { - test("getVaultDetails/valid", async () => { - let result = await vault.getVaultDetails(bufView); - expect(result.response).toHaveProperty("evm"); - }); - - test("getVaultDetails/empty encryption key", async () => { - let result = await vault.getVaultDetails(null); - expect(result.error).toBe("Incorrect Encryption Key or vault string"); - }); - - test("getVaultDetails/invalid encryption key", async () => { - let result = await vault.getVaultDetails("adfaefae"); - expect(result.error).toBe("Incorrect Encryption Key or vault string"); - }); -}); - -describe("getBalance", () => { - test("getBalance/valid", async () => { - let result = await vault.getBalance(accAddress, polygonRpcUrl); - expect(result.response).toHaveProperty("balance"); - }); - - test("getBalance/empty address", async () => { - try { - let result = await vault.getBalance(null, ethUrl); - } catch (e) { - expect(e.message).toBe( - "Provided address null is invalid, the capitalization checksum test failed, or it's an indirect IBAN address which can't be converted." - ); - } - }); - - test("getBalance/invalid address", async () => { - let addr = "fghioiuhgf"; - try { - let result = await vault.getBalance("fghioiuhgf", ethUrl); - } catch (e) { - expect(e.message).toBe( - `Provided address ${addr} is invalid, the capitalization checksum test failed, or it's an indirect IBAN address which can't be converted.` - ); - } - }); - - test("getBalance/empty url", async () => { - try { - let result = await vault.getBalance(accAddress, null); - } catch (e) { - expect(e.message).toBe( - `CONNECTION ERROR: Couldn't connect to node http://localhost:8545.` - ); - } - }); - test("getBalance/invalid url", async () => { - let url = "https.11.com"; - try { - let result = await vault.getBalance(accAddress, url); - } catch (e) { - expect(e.message).toBe( - `CONNECTION ERROR: Couldn't connect to node ${url}.` - ); - } - }); -}); - -describe("updateLabel", () => { - test("updateLabel/valid", async () => { - let result = await vault.updateLabel( - "0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd", - bufView, - "Wallet 1" - ); - expect(result).toHaveProperty("response"); - }); - - test("updateLabel/invalid address", async () => { - let result = await vault.updateLabel("adeded", bufView, "Wallet 1"); - expect(result.error).toBe("This address is not present in the vault"); - }); - - test("updateLabel/empty address", async () => { - let result = await vault.updateLabel(null, bufView, "Wallet 1"); - expect(result.error).toBe("This address is not present in the vault"); - }); - test("updateLabel/invalid encryption key", async () => { - let result = await vault.updateLabel( - "0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd", - "afers", - "Wallet 1" - ); - expect(result.error).toBe("Incorrect Encryption Key or vault string"); - }); - test("updateLabel/empty encryption key", async () => { - let result = await vault.updateLabel( - "0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd", - null, - "Wallet 1" - ); - expect(result.error).toBe("Incorrect Encryption Key or vault string"); - }); - test("updateLabel/empty label", async () => { - try { - let result = await vault.updateLabel( - "0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd", - bufView, - null - ); - } catch (e) { - expect(e.message).toBe("chainName is not defined"); - } - }); - test("updateLabel/all empty params", async () => { - let result = await vault.updateLabel(null, null, null); - expect(result.error).toBe("Incorrect Encryption Key or vault string"); - }); -}); - -describe("sign", () => { - test("sign/valid", async () => { - let data = "hello world"; - console.log("sign/valid--->", pin, ethUrl); - await vault.restoreKeyringState(vault, pin, bufView); - - let result = await vault.sign( - data, - "0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd", - pin, - ethUrl - ); - console.log("sign/valid--->", result); - expect(result.response).toHaveProperty("signature"); - }); - - test("sign/empty data", async () => { - let data = "hello world"; - let result = await vault.sign( - "", - "0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd", - pin, - ethUrl - ); - expect(result.response).toHaveProperty("signature"); - }); - - test("sign/empty address", async () => { - let data = "hello world"; - try { - let result = await vault.sign(data, null, pin, ethUrl); - } catch (e) { - expect(e.message).toBe( - "Cannot read properties of null (reading 'toLowerCase')" - ); - } - }); - test("sign/invalid address", async () => { - let data = "hello world"; - try { - let result = await vault.sign(data, "abc", pin, ethUrl); - } catch (e) { - expect(e.message).toBe( - 'Given address "abc" is not a valid Ethereum address.' - ); - } - }); - test("sign/empty pin", async () => { - let data = "hello world"; - - let result = await vault.sign(data, "abc", null, ethUrl); - expect(result.error).toBe("Wrong pin type, format or length"); - }); - test("sign/incorrect pin", async () => { - let data = "hello world"; - - let result = await vault.sign(data, "abc", "111111", ethUrl); - expect(result.error).toBe("Incorrect pin"); - }); - test("sign/invalid pin", async () => { - let data = "hello world"; - let result = await vault.sign(data, accAddress, "abc", ethUrl); - expect(result.error).toBe("Wrong pin type, format or length"); - }); - - test("sign/empty url", async () => { - let data = "hello world"; - let result = await vault.sign( - data, - "0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd", - pin, - null - ); - expect(result.response).toHaveProperty("signature"); - }); - - test("sign/invalid url", async () => { - let data = "hello world"; - let result = await vault.sign( - data, - "0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd", - pin, - "abc" - ); - expect(result.response).toHaveProperty("signature"); - }); - - test("sign/all params empty", async () => { - let data = "hello world"; - - let result = await vault.sign(null, null, null, null); - expect(result.error).toBe("Wrong pin type, format or length"); - }); -}); + { chain: 'bitcoin', symbol: 'BTC' }, + { chain: 'stacks', symbol: 'STX' }, + { chain: 'solana', symbol: 'SOL' }, + { chain: 'ethereum', symbol: 'ETH' }, + { chain: 'bsc', symbol: 'BSC' }, + { chain: 'polygon', symbol: 'MATIC' }, + { chain: 'optimism', symbol: 'OP' }, + { chain: 'arbitrum', symbol: 'ARB' }, + { chain: 'mantle', symbol: 'MNT' }, + { chain: 'velas', symbol: 'VLX' }, + { chain: 'avalanche', symbol: 'AVAX' }, + { chain: 'base', symbol: 'BASE' }, + { chain: 'zkEVM', symbol: 'ZKEVM' }, + { chain: 'bevm', symbol: 'BTC' }, + {chain: 'rootstock', symbol: 'RBTC'} + ] + }).toMatchObject(result) + + }) +}) + +describe('deleteAccount',()=>{ + test('deleteAccount/valid generated acc' , async()=>{ + + let result = await vault.deleteAccount(bufView,accAddress,pin) + expect(result).toHaveProperty('response') + + }) + + test('deleteAccount/valid imported acc' , async()=>{ + + let result = await vault.deleteAccount(bufView,impAccAddress,pin) + expect(result).toHaveProperty('response') + + }) + + + test('deleteAccount/empty encryption key' , async()=>{ + try{ + let result = await vault.deleteAccount(null,accAddress,pin) + } + catch(e){ + expect(e.message).toBe("Incorrect Encryption Key or vault string") + } + + + }) + + test('deleteAccount/invalid encryption key' , async()=>{ + try{ + let result = await vault.deleteAccount(null,accAddress,pin) + } + catch(e){ + expect(e.message).toBe("Incorrect Encryption Key or vault string") + } + + + }) + test('deleteAccount/empty address' , async()=>{ + + let result = await vault.deleteAccount(bufView,null,pin) + expect(result.error).toBe('This address is not present in the vault') + + + }) + test('deleteAccount/invalid address' , async()=>{ + + let result = await vault.deleteAccount(bufView,"rerwgtehry",pin) + expect(result.error).toBe('This address is not present in the vault') + + + }) + test('deleteAccount/empty pin' , async()=>{ + + let result = await vault.deleteAccount(bufView,accAddress,null) + expect(result.error).toBe("Wrong pin type, format or length") + + + + + + }) + test('deleteAccount/invalid pin' , async()=>{ + + let result = await vault.deleteAccount(bufView,accAddress,"efwe") + expect(result.error).toBe("Wrong pin type, format or length") + + + }) + test('deleteAccount/incorrect pin' , async()=>{ + + let result = await vault.deleteAccount(bufView,accAddress,"111111") + expect(result.error).toBe("Incorrect pin") + + + }) + test('deleteAccount/all params empty' , async()=>{ + try{ + let result = await vault.deleteAccount(null,null,null) + } + catch(e){ + expect(e).toBe('Wrong pin type, format or length') + + } + + + }) +}) + + +describe('restoreAccount', ()=> { + + test('restoreAccount/valid generated acc' , async()=>{ + + let result = await vault.restoreAccount(bufView,accAddress,pin) + expect(result).toHaveProperty('response') + + }) + + test('restoreAccount/valid imported acc' , async()=>{ + + let result = await vault.restoreAccount(bufView,impAccAddress,pin) + expect(result).toHaveProperty('response') + + }) + + + test('restoreAccount/empty encryption key' , async()=>{ + try{ + let result = await vault.restoreAccount(null,accAddress,pin) + } + catch(e){ + expect(e.message).toBe("Incorrect Encryption Key or vault string") + } + + + }) + + test('restoreAccount/invalid encryption key' , async()=>{ + try{ + let result = await vault.restoreAccount(null,accAddress,pin) + } + catch(e){ + expect(e.message).toBe("Incorrect Encryption Key or vault string") + } + + + }) + test('restoreAccount/empty address' , async()=>{ + + let result = await vault.restoreAccount(bufView,null,pin) + expect(result.error).toBe('This address is not present in the vault') + + + }) + test('restoreAccount/invalid address' , async()=>{ + + let result = await vault.restoreAccount(bufView,"rerwgtehry",pin) + expect(result.error).toBe('This address is not present in the vault') + + + }) + test('restoreAccount/empty pin' , async()=>{ + + try { + let result = await vault.restoreAccount(bufView,accAddress,null) + } + catch(e){ + expect(e).toBe('Wrong pin type, format or length') + } + + + }) + test('restoreAccount/invalid pin' , async()=>{ + + try { + let result = await vault.restoreAccount(bufView,accAddress,"efwe") + } + catch(e){ + expect(e).toBe('Wrong pin type, format or length') + } + + + }) + test('restoreAccount/incorrect pin' , async()=>{ + + let result = await vault.restoreAccount(bufView,accAddress,"111111") + expect(result.error).toBe("Incorrect pin") + + + }) + test('restoreAccount/all params empty' , async()=>{ + try{ + let result = await vault.restoreAccount(null,null,null) + } + catch(e){ + expect(e).toBe('Wrong pin type, format or length') + + } + + + }) +}) + + + +describe('restoreKeyringState',()=>{ + test('restoreKeyringState/valid' , async()=>{ + + + await vault.restoreKeyringState(vaultAddress,pin,bufView) + expect(result).toHaveProperty('response') + + + }) + + test('restoreKeyringState/empty vault address' , async()=>{ + try{ + let result= await vault.restoreKeyringState(null,pin,bufView) + + } + catch(e){ + expect(e.message).toBe("Cannot read properties of null (reading 'salt')") + } + + + }) + + test('restoreKeyringState/invalid vault address' , async()=>{ + + let result= await vault.restoreKeyringState("abc",pin,bufView) + expect(result.error).toBe('Incorrect Encryption Key or vault string') + + + }) + + test('restoreKeyringState/empty pin' , async()=>{ + + let result= await vault.restoreKeyringState(vaultAddress,null,bufView) + expect(result.error).toBe("Wrong pin type, format or length") + + + + + + }) + + test('restoreKeyringState/invalid pin' , async()=>{ + + let result= await vault.restoreKeyringState(vaultAddress,"avevr",bufView) + expect(result.error).toBe("Wrong pin type, format or length") + + + + + + }) + + test('restoreKeyringState/empty encrption key' , async()=>{ + + let result= await vault.restoreKeyringState(vaultAddress,pin,null) + expect(result.error).toBe('Incorrect Encryption Key or vault string') + + + + + }) + + test('restoreKeyringState/invalid encrption key' , async()=>{ + + let result= await vault.restoreKeyringState(vaultAddress,pin,"weefew") + expect(result.error).toBe('Incorrect Encryption Key or vault string') + + + }) + + test('restoreKeyringState/all params empty' , async()=>{ + + let result= await vault.restoreKeyringState(null,null,null) + expect(result.error).toBe("Wrong pin type, format or length") + + + + + + }) + + +}) + + + +describe('getVaultDetails',()=>{ + test('getVaultDetails/valid' , async()=>{ + let result = await vault.getVaultDetails(bufView) + expect(result.response).toHaveProperty('evm') + + + }) + + test('getVaultDetails/empty encryption key' , async()=>{ + let result = await vault.getVaultDetails(null) + expect(result.error).toBe('Incorrect Encryption Key or vault string') + + + + }) + + test('getVaultDetails/invalid encryption key' , async()=>{ + let result = await vault.getVaultDetails("adfaefae") + expect(result.error).toBe('Incorrect Encryption Key or vault string') + + + + }) +}) + +describe('getBalance',()=>{ + + + test('getBalance/valid' , async()=>{ + + let result = await vault.getBalance(accAddress,polygonRpcUrl) + expect(result.response).toHaveProperty('balance') + + + }) + + test('getBalance/empty address' , async()=>{ + try{ + let result = await vault.getBalance(null,ethUrl) + + } + catch(e){ + expect(e.message).toBe("Provided address null is invalid, the capitalization checksum test failed, or it's an indirect IBAN address which can't be converted.") + } + + + }) + + + + test('getBalance/invalid address' , async()=>{ + let addr="fghioiuhgf" + try{ + + let result = await vault.getBalance("fghioiuhgf",ethUrl) + + } + catch(e){ + expect(e.message).toBe(`Provided address ${addr} is invalid, the capitalization checksum test failed, or it's an indirect IBAN address which can't be converted.`) + } + + + }) + + test('getBalance/empty url' , async()=>{ + try{ + + let result = await vault.getBalance(accAddress,null) + + } + catch(e){ + expect(e.message).toBe(`CONNECTION ERROR: Couldn't connect to node http://localhost:8545.`) + } + + + }) + test('getBalance/invalid url' , async()=>{ + let url="https.11.com" + try{ + + let result = await vault.getBalance(accAddress,url) + + } + catch(e){ + expect(e.message).toBe(`CONNECTION ERROR: Couldn't connect to node ${url}.`) + } + + + }) + + + + +}) + + + + + + +describe('updateLabel',()=>{ + + test('updateLabel/valid' , async()=>{ + let result = await vault.updateLabel("0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd",bufView,"Wallet 1") + expect(result).toHaveProperty('response') + + + }) + + test('updateLabel/invalid address' , async()=>{ + let result = await vault.updateLabel("adeded",bufView,"Wallet 1") + expect(result.error).toBe('This address is not present in the vault') + + + }) + + test('updateLabel/empty address' , async()=>{ + let result = await vault.updateLabel(null,bufView,"Wallet 1") + expect(result.error).toBe('This address is not present in the vault') + + + }) + test('updateLabel/invalid encryption key' , async()=>{ + + let result = await vault.updateLabel("0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd","afers","Wallet 1") + expect(result.error).toBe('Incorrect Encryption Key or vault string') + + + + }) + test('updateLabel/empty encryption key' , async()=>{ + + let result = await vault.updateLabel("0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd",null,"Wallet 1") + expect(result.error).toBe('Incorrect Encryption Key or vault string') + + + + + + }) + test('updateLabel/empty label' , async()=>{ + try{ + let result = await vault.updateLabel("0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd",bufView,null) + } + catch(e){ + expect(e.message).toBe('chainName is not defined') + } + + + + }) + test('updateLabel/all empty params' , async()=>{ + + let result = await vault.updateLabel(null,null,null) + expect(result.error).toBe('Incorrect Encryption Key or vault string') + + + + }) + +}) + + +describe('sign',()=>{ + + test('sign/valid' , async()=>{ + let data="hello world" + console.log("sign/valid--->",pin,ethUrl) + await vault.restoreKeyringState(vault,pin,bufView) + + let result = await vault.sign(data,"0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd",pin,ethUrl) + console.log("sign/valid--->",result) + expect(result.response).toHaveProperty('signature') + + }) + + test('sign/empty data' , async()=>{ + + let data="hello world" + let result = await vault.sign("","0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd",pin,ethUrl) + expect(result.response).toHaveProperty('signature') + + }) + + + test('sign/empty address' , async()=>{ + + let data="hello world" + try{ + let result = await vault.sign(data,null,pin,ethUrl) + + }catch(e){ + expect(e.message).toBe("Cannot read properties of null (reading 'toLowerCase')") + } + + + }) + test('sign/invalid address' , async()=>{ + + let data="hello world" + try{ + let result = await vault.sign(data,"abc",pin,ethUrl) + } + catch(e){ + expect(e.message).toBe('Given address "abc" is not a valid Ethereum address.') + } + + + + + }) + test('sign/empty pin' , async()=>{ + + let data="hello world" + + let result = await vault.sign(data,"abc",null,ethUrl) + expect(result.error).toBe("Wrong pin type, format or length") + + }) + test('sign/incorrect pin' , async()=>{ + + let data="hello world" + + let result = await vault.sign(data,"abc","111111",ethUrl) + expect(result.error).toBe("Incorrect pin") + + }) + test('sign/invalid pin' , async()=>{ + + let data="hello world" + let result = await vault.sign(data,accAddress,"abc",ethUrl) + expect(result.error).toBe("Wrong pin type, format or length") + + }) + + test('sign/empty url' , async()=>{ + + let data="hello world" + let result = await vault.sign(data,"0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd",pin,null) + expect(result.response).toHaveProperty('signature') + + + + + + }) + + test('sign/invalid url' , async()=>{ + + let data="hello world" + let result = await vault.sign(data,"0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd",pin,"abc") + expect(result.response).toHaveProperty('signature') + + }) + + test('sign/all params empty' , async()=>{ + + let data="hello world" + + let result = await vault.sign(null,null,null,null) + expect(result.error).toBe("Wrong pin type, format or length") + + + }) + + + + + + + +}) + + +describe('validateMnemonic',()=>{ + let signUpPhrase='ladder equip piano open silent pizza solid cannon name volcano fee valley' + test('validateMnemonic/valid' , async()=>{ + let result = await vault.validateMnemonic(signUpPhrase,'abhi141','testnet',polygonRpcUrl) + expect(result.response).toBe(true) + + + }) + test('validateMnemonic/empty phrase' , async()=>{ + let result = await vault.validateMnemonic('','abhi141','testnet',polygonRpcUrl) + expect(result.response).toBe(false) + + + }) + test('validateMnemonic/invalid phrase' , async()=>{ + let result = await vault.validateMnemonic('waefsgrth','abhi141','testnet',polygonRpcUrl) + expect(result.response).toBe(false) + + + }) + test('validateMnemonic/empty safle id' , async()=>{ + let result = await vault.validateMnemonic(signUpPhrase,null,'testnet',polygonRpcUrl) + expect(result.response).toBe(false) + + + }) + test('validateMnemonic/invalid safle id' , async()=>{ + let result = await vault.validateMnemonic(signUpPhrase,"egsrrgr",'testnet',polygonRpcUrl) + expect(result.response).toBe(false) + + + }) + test('validateMnemonic/empty network' , async()=>{ + try{ + let result = await vault.validateMnemonic(signUpPhrase,'abhi141',null,polygonRpcUrl) + + } + catch(e){ + expect(e).toBe('Invalid network selected') + } + + + }) + test('validateMnemonic/invalid network' , async()=>{ + try{ + let result = await vault.validateMnemonic(signUpPhrase,'abhi141',"segsr",polygonRpcUrl) + + } + catch(e){ + expect(e).toBe('Invalid network selected') + } + + + }) + test('validateMnemonic/invalid network' , async()=>{ + try{ + let result = await vault.validateMnemonic(signUpPhrase,'abhi141',"segsr",polygonRpcUrl) + + } + catch(e){ + expect(e).toBe('Invalid network selected') + } + + + }) + test('validateMnemonic/invalid url' , async()=>{ + + let result = await vault.validateMnemonic(signUpPhrase,'abhi141','testnet',"awfe") + expect(result.response).toBe(false) + + }) + test('validateMnemonic/empty url' , async()=>{ + + let result = await vault.validateMnemonic(signUpPhrase,'abhi141','testnet',null) + expect(result.response).toBe(false) + + }) + test('validateMnemonic/all empty params' , async()=>{ + try{ + let result = await vault.validateMnemonic(null,null,null,null) + } + + catch(e){ + expect(e).toBe('Invalid network selected') + } + + }) +}) + +describe('changePin',()=>{ + test('changePin/valid' , async()=>{ + let result = await vault.changePin(pin,pin,bufView) + expect(result).toHaveProperty('response') + + + }) + + test('changePin/wrong currentpin' , async()=>{ + try{ + let result = await vault.changePin("111111",pin,bufView) + + } + catch(e){ + expect(e).toBe('Wrong pin type, format or length') + } + + + }) + + test('changePin/invalid currentpin' , async()=>{ + try{ + let result = await vault.changePin('aefe',pin,bufView) + + } + catch(e){ + expect(e).toBe('Wrong pin type, format or length') + } + + + + + }) + test('changePin/empty currentpin' , async()=>{ + try{ + let result = await vault.changePin(null,pin,bufView) + + } + catch(e){ + expect(e).toBe('Wrong pin type, format or length') + } + + + }) + + test('changePin/empty new pin' , async()=>{ + try{ + let result = await vault.changePin(pin,null,bufView) + + } + catch(e){ + expect(e).toBe('Wrong pin type, format or length') + } + + + }) + + test('changePin/invalid new pin' , async()=>{ + try{ + let result = await vault.changePin(pin,'afaef',bufView) + + } + catch(e){ + expect(e).toBe('Wrong pin type, format or length') + } + + + }) + + test('changePin/empty encryption key' , async()=>{ + try{ + let result = await vault.changePin(pin,pin,null) + } + catch(e){ + expect(e.message).toBe("Incorrect Encryption Key or vault string") + } + + + }) + + test('changePin/invalid encryption key' , async()=>{ + try{ + let result = await vault.changePin(pin,pin,'efefe') + } + catch(e){ + expect(e.message).toBe("Incorrect Encryption Key or vault string") + } + + + + + }) + test('changePin/all empty params' , async()=>{ + try{ + let result = await vault.changePin(null,null,null) + + } + catch(e){ + expect(e).toBe('Wrong pin type, format or length') + } + + + }) + +}) + + + +describe('getLogs',()=>{ + test('getLogs/valid' , async()=>{ + + let result = await vault.getLogs() + expect(result).toHaveProperty('logs') + + + }) +}) + + +describe('getAccounts',()=>{ + test('getAccounts/valid' , async()=>{ + await vault.restoreKeyringState(vaultAddress,pin,bufView) + let result = await vault.getAccounts() + expect(result).toHaveProperty('response') + + }) + +}) + + +describe('signTransaction',()=>{ + + + test('signTransaction/valid' , async()=>{ + let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" + const web3 = new Web3(polygonRpcUrl) + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); -describe("validateMnemonic", () => { - let signUpPhrase = - "ladder equip piano open silent pizza solid cannon name volcano fee valley"; - test("validateMnemonic/valid", async () => { - let result = await vault.validateMnemonic( - signUpPhrase, - "abhi141", - "testnet", - polygonRpcUrl - ); - expect(result.response).toBe(true); - }); - test("validateMnemonic/empty phrase", async () => { - let result = await vault.validateMnemonic( - "", - "abhi141", - "testnet", - polygonRpcUrl - ); - expect(result.response).toBe(false); - }); - test("validateMnemonic/invalid phrase", async () => { - let result = await vault.validateMnemonic( - "waefsgrth", - "abhi141", - "testnet", - polygonRpcUrl - ); - expect(result.response).toBe(false); - }); - test("validateMnemonic/empty safle id", async () => { - let result = await vault.validateMnemonic( - signUpPhrase, - null, - "testnet", - polygonRpcUrl - ); - expect(result.response).toBe(false); - }); - test("validateMnemonic/invalid safle id", async () => { - let result = await vault.validateMnemonic( - signUpPhrase, - "egsrrgr", - "testnet", - polygonRpcUrl - ); - expect(result.response).toBe(false); - }); - test("validateMnemonic/empty network", async () => { - try { - let result = await vault.validateMnemonic( - signUpPhrase, - "abhi141", - null, - polygonRpcUrl - ); - } catch (e) { - expect(e).toBe("Invalid network selected"); - } - }); - test("validateMnemonic/invalid network", async () => { - try { - let result = await vault.validateMnemonic( - signUpPhrase, - "abhi141", - "segsr", - polygonRpcUrl - ); - } catch (e) { - expect(e).toBe("Invalid network selected"); - } - }); - test("validateMnemonic/invalid network", async () => { - try { - let result = await vault.validateMnemonic( - signUpPhrase, - "abhi141", - "segsr", - polygonRpcUrl - ); - } catch (e) { - expect(e).toBe("Invalid network selected"); - } - }); - test("validateMnemonic/invalid url", async () => { - let result = await vault.validateMnemonic( - signUpPhrase, - "abhi141", - "testnet", - "awfe" - ); - expect(result.response).toBe(false); - }); - test("validateMnemonic/empty url", async () => { - let result = await vault.validateMnemonic( - signUpPhrase, - "abhi141", - "testnet", - null - ); - expect(result.response).toBe(false); - }); - test("validateMnemonic/all empty params", async () => { - try { - let result = await vault.validateMnemonic(null, null, null, null); - } catch (e) { - expect(e).toBe("Invalid network selected"); - } - }); -}); + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), + maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), + data: '0x0', // method to generate data is provided below + nonce: nonce, + type: '0x2', + }; + await vault.getActiveChains() + try{ -describe("changePin", () => { - test("changePin/valid", async () => { - let result = await vault.changePin(pin, pin, bufView); - expect(result).toHaveProperty("response"); - }); - - test("changePin/wrong currentpin", async () => { - try { - let result = await vault.changePin("111111", pin, bufView); - } catch (e) { - expect(e).toBe("Wrong pin type, format or length"); - } - }); - - test("changePin/invalid currentpin", async () => { - try { - let result = await vault.changePin("aefe", pin, bufView); - } catch (e) { - expect(e).toBe("Wrong pin type, format or length"); - } - }); - test("changePin/empty currentpin", async () => { - try { - let result = await vault.changePin(null, pin, bufView); - } catch (e) { - expect(e).toBe("Wrong pin type, format or length"); - } - }); - - test("changePin/empty new pin", async () => { - try { - let result = await vault.changePin(pin, null, bufView); - } catch (e) { - expect(e).toBe("Wrong pin type, format or length"); - } - }); - - test("changePin/invalid new pin", async () => { - try { - let result = await vault.changePin(pin, "afaef", bufView); - } catch (e) { - expect(e).toBe("Wrong pin type, format or length"); - } - }); - - test("changePin/empty encryption key", async () => { - try { - let result = await vault.changePin(pin, pin, null); - } catch (e) { - expect(e.message).toBe("Incorrect Encryption Key or vault string"); - } - }); - - test("changePin/invalid encryption key", async () => { - try { - let result = await vault.changePin(pin, pin, "efefe"); - } catch (e) { - expect(e.message).toBe("Incorrect Encryption Key or vault string"); - } - }); - test("changePin/all empty params", async () => { - try { - let result = await vault.changePin(null, null, null); - } catch (e) { - expect(e).toBe("Wrong pin type, format or length"); - } - }); -}); + let result = await vault.signTransaction(rawTx,pin,polygonRpcUrl) -describe("getLogs", () => { - test("getLogs/valid", async () => { - let result = await vault.getLogs(); - expect(result).toHaveProperty("logs"); - }); -}); + } + catch(e){ + expect(e.message).toBe("Cannot read property 'salt' of undefined") -describe("getAccounts", () => { - test("getAccounts/valid", async () => { - await vault.restoreKeyringState(vaultAddress, pin, bufView); - let result = await vault.getAccounts(); - expect(result).toHaveProperty("response"); - }); -}); + } + + + + + }) -describe("signTransaction", () => { - test("signTransaction/valid", async () => { - let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; - const web3 = new Web3(polygonRpcUrl); + test('signTransaction/empty raw tx' , async()=>{ + let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" + const web3 = new Web3(polygonRpcUrl) const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("42.25770", "gwei")) - ), - maxFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("150.99", "gwei")) - ), - data: "0x0", // method to generate data is provided below - nonce: nonce, - type: "0x2", + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), + maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), + data: '0x0', // method to generate data is provided below + nonce: nonce, + type: '0x2', }; - await vault.getActiveChains(); - try { - let result = await vault.signTransaction(rawTx, pin, polygonRpcUrl); - } catch (e) { - expect(e.message).toBe("Cannot read property 'salt' of undefined"); - } - }); - - test("signTransaction/empty raw tx", async () => { - let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; - const web3 = new Web3(polygonRpcUrl); - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("42.25770", "gwei")) - ), - maxFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("150.99", "gwei")) - ), - data: "0x0", // method to generate data is provided below - nonce: nonce, - type: "0x2", + try{ + + let result = await vault.signTransaction({},pin,polygonRpcUrl) + + } + catch(e){ + expect(e.message).toBe("Cannot read properties of undefined (reading 'toLowerCase')") + + } + + + + + }) + + test('signTransaction/invalid raw tx' , async()=>{ + let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" + const web3 = new Web3(polygonRpcUrl) + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), + maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), + data: '0x0', // method to generate data is provided below + nonce: nonce, + type: '0x2', }; - try { - let result = await vault.signTransaction({}, pin, polygonRpcUrl); - } catch (e) { - expect(e.message).toBe( - "Cannot read properties of undefined (reading 'toLowerCase')" - ); - } - }); - - test("signTransaction/invalid raw tx", async () => { - let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; - const web3 = new Web3(polygonRpcUrl); - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("42.25770", "gwei")) - ), - maxFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("150.99", "gwei")) - ), - data: "0x0", // method to generate data is provided below - nonce: nonce, - type: "0x2", + try{ + + let result = await vault.signTransaction("evwf",pin,polygonRpcUrl) + + } + catch(e){ + expect(e.message).toBe("Cannot read properties of undefined (reading 'toLowerCase')") + + } + + + + + }) + + test('signTransaction/empty pin' , async()=>{ + let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" + const web3 = new Web3(polygonRpcUrl) + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), + maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), + data: '0x0', // method to generate data is provided below + nonce: nonce, + type: '0x2', }; - try { - let result = await vault.signTransaction("evwf", pin, polygonRpcUrl); - } catch (e) { - expect(e.message).toBe( - "Cannot read properties of undefined (reading 'toLowerCase')" - ); - } - }); - - test("signTransaction/empty pin", async () => { - let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; - const web3 = new Web3(polygonRpcUrl); - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("42.25770", "gwei")) - ), - maxFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("150.99", "gwei")) - ), - data: "0x0", // method to generate data is provided below - nonce: nonce, - type: "0x2", + + + let result = await vault.signTransaction("evwf",null,polygonRpcUrl) + expect(result.error).toBe('Wrong pin type, format or length') + + + + + }) + + test('signTransaction/invalid pin' , async()=>{ + let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" + const web3 = new Web3(polygonRpcUrl) + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), + maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), + data: '0x0', // method to generate data is provided below + nonce: nonce, + type: '0x2', + }; + + + let result = await vault.signTransaction("evwf","afewf",polygonRpcUrl) + expect(result.error).toBe('Wrong pin type, format or length') + + + + + + }) + test('signTransaction/incorrect pin' , async()=>{ + let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" + const web3 = new Web3(polygonRpcUrl) + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), + maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), + data: '0x0', // method to generate data is provided below + nonce: nonce, + type: '0x2', }; + + + let result = await vault.signTransaction("evwf","112344",polygonRpcUrl) + expect(result.error).toBe('Incorrect pin') + + + + + + }) + + test('signTransaction/empty polygon rpc' , async()=>{ + let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" + const web3 = new Web3(polygonRpcUrl) + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), + maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), + data: '0x0', // method to generate data is provided below + nonce: nonce, + type: '0x2', + }; + + try{ + let result = await vault.signTransaction("evwf",pin,null) + } + catch(e){ + expect(e.message).toBe("CONNECTION ERROR: Couldn't connect to node http://localhost:8545.") + } + + + + + + + }) + + test('signTransaction/invalid polygon rpc' , async()=>{ + let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" + const web3 = new Web3(polygonRpcUrl) + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), + maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), + data: '0x0', // method to generate data is provided below + nonce: nonce, + type: '0x2', + }; + let invalidRpc="efrwgrwdvfr" + try{ + let result = await vault.signTransaction("evwf",pin,invalidRpc) + } + catch(e){ + expect(e.message).toBe(`CONNECTION ERROR: Couldn't connect to node ${invalidRpc}.`) + } + + + + + + + }) + + test('signTransaction/all empty params' , async()=>{ + let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" + const web3 = new Web3(polygonRpcUrl) + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), + maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), + data: '0x0', // method to generate data is provided below + nonce: nonce, + type: '0x2', + }; + let invalidRpc="efrwgrwdvfr" + + let result = await vault.signTransaction(null,null,null) + expect(result.error).toBe("Wrong pin type, format or length") - let result = await vault.signTransaction("evwf", null, polygonRpcUrl); - expect(result.error).toBe("Wrong pin type, format or length"); - }); + + + - test("signTransaction/invalid pin", async () => { - let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; - const web3 = new Web3(polygonRpcUrl); - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + + + + + }) +}) - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("42.25770", "gwei")) - ), - maxFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("150.99", "gwei")) - ), - data: "0x0", // method to generate data is provided below - nonce: nonce, - type: "0x2", - }; - let result = await vault.signTransaction("evwf", "afewf", polygonRpcUrl); - expect(result.error).toBe("Wrong pin type, format or length"); - }); - test("signTransaction/incorrect pin", async () => { - let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; - const web3 = new Web3(polygonRpcUrl); - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); +describe('get Fees', () => { - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("42.25770", "gwei")) - ), - maxFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("150.99", "gwei")) - ), - data: "0x0", // method to generate data is provided below - nonce: nonce, - type: "0x2", - }; + test('get Fees, validate', async () => { + vault.changeNetwork('polygon') + let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" + const web3 = new Web3(polygonRpcUrl) - let result = await vault.signTransaction("evwf", "112344", polygonRpcUrl); - expect(result.error).toBe("Incorrect pin"); - }); + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0", 'ether')), + chainID: 137, + }; - test("signTransaction/empty polygon rpc", async () => { - let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; - const web3 = new Web3(polygonRpcUrl); - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + let result = await vault.getFees(rawTx,polygonRpcUrl) + expect(result.response).toHaveProperty('gasLimit') + expect(result.response).toHaveProperty('fees') + + }) - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("42.25770", "gwei")) - ), - maxFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("150.99", "gwei")) - ), - data: "0x0", // method to generate data is provided below - nonce: nonce, - type: "0x2", - }; + test('get fees, invalid', async () => { + vault.changeNetwork('polygon') + let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" + const web3 = new Web3(polygonRpcUrl) - try { - let result = await vault.signTransaction("evwf", pin, null); - } catch (e) { - expect(e.message).toBe( - "CONNECTION ERROR: Couldn't connect to node http://localhost:8545." - ); - } - }); - - test("signTransaction/invalid polygon rpc", async () => { - let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; - const web3 = new Web3(polygonRpcUrl); - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0", 'ether')), + chainID: 137, + }; - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("42.25770", "gwei")) - ), - maxFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("150.99", "gwei")) - ), - data: "0x0", // method to generate data is provided below - nonce: nonce, - type: "0x2", - }; - let invalidRpc = "efrwgrwdvfr"; - try { - let result = await vault.signTransaction("evwf", pin, invalidRpc); - } catch (e) { - expect(e.message).toBe( - `CONNECTION ERROR: Couldn't connect to node ${invalidRpc}.` - ); - } - }); - - test("signTransaction/all empty params", async () => { - let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; - const web3 = new Web3(polygonRpcUrl); - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + try { + let result = await vault.getFees(rawTx,'abc') + console.log("result = ", result); + } + catch (e) { + console.log(e.message); + expect(e.message).toBe("CONNECTION ERROR: Couldn't connect to node abc.") + } + + }) +}) - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("42.25770", "gwei")) - ), - maxFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("150.99", "gwei")) - ), - data: "0x0", // method to generate data is provided below - nonce: nonce, - type: "0x2", - }; - let invalidRpc = "efrwgrwdvfr"; - let result = await vault.signTransaction(null, null, null); - expect(result.error).toBe("Wrong pin type, format or length"); - }); -}); -describe("get Fees", () => { - test("get Fees, validate", async () => { - vault.changeNetwork("polygon"); - let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; - const web3 = new Web3(polygonRpcUrl); - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0", "ether")), - chainID: 137, - }; - let result = await vault.getFees(rawTx, polygonRpcUrl); - expect(result.response).toHaveProperty("gasLimit"); - expect(result.response).toHaveProperty("fees"); - }); - test("get fees, invalid", async () => { - vault.changeNetwork("polygon"); - let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; - const web3 = new Web3(polygonRpcUrl); - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0", "ether")), - chainID: 137, - }; - try { - let result = await vault.getFees(rawTx, "abc"); - console.log("result = ", result); - } catch (e) { - console.log(e.message); - expect(e.message).toBe("CONNECTION ERROR: Couldn't connect to node abc."); - } - }); -}); From 7849ae138304c18a9aaa04de73075aabc18c2cb3 Mon Sep 17 00:00:00 2001 From: Shubham Singhal Date: Tue, 20 Aug 2024 18:42:24 +0530 Subject: [PATCH 89/98] Updated test cases --- src/lib/test/keyring.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/test/keyring.test.js b/src/lib/test/keyring.test.js index 00fba06..74ef7b0 100644 --- a/src/lib/test/keyring.test.js +++ b/src/lib/test/keyring.test.js @@ -346,14 +346,14 @@ describe('deleteAccount',()=>{ }) test('deleteAccount/empty address' , async()=>{ - let result = await vault.deleteAccount(bufView,null,pin) + let result = await vault.deleteAccount(bufView,null,'696969') expect(result.error).toBe('This address is not present in the vault') }) test('deleteAccount/invalid address' , async()=>{ - let result = await vault.deleteAccount(bufView,"rerwgtehry",pin) + let result = await vault.deleteAccount(bufView,"rerwgtehry",'696969') expect(result.error).toBe('This address is not present in the vault') From 8158536965808b71fbc7a0fba4e5a8d0ec1a067e Mon Sep 17 00:00:00 2001 From: Husien vora Date: Tue, 20 Aug 2024 18:59:02 +0530 Subject: [PATCH 90/98] some updates --- .github/workflows/main.yml | 3 +++ package-lock.json | 2 +- package.json | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3889aaa..1e97967 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,6 +14,9 @@ on: jobs: build: runs-on: ubuntu-latest + env: + CI: true + GITHUB_ACTIONS: true steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 diff --git a/package-lock.json b/package-lock.json index 7be1057..d08de14 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "@getsafle/safle-vault", - "version": "2.8.0", + "version": "2.9.0", "license": "MIT", "dependencies": { "@getsafle/safle-identity-wallet": "^1.3.0", diff --git a/package.json b/package.json index 6f08193..34847ca 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,6 @@ "@getsafle/vault-avalanche-controller": "^1.2.2", "@getsafle/vault-base-controller": "^1.0.2", "@getsafle/vault-bevm-controller": "^1.0.3", - "@getsafle/vault-rootstock-controller": "^1.0.0", "@getsafle/vault-bitcoin-controller": "^2.0.7", "@getsafle/vault-bsc-controller": "^1.2.4", "@getsafle/vault-eth-controller": "^1.4.6", @@ -62,6 +61,7 @@ "@getsafle/vault-optimism-controller": "^1.0.8", "@getsafle/vault-polygon-controller": "^1.2.8", "@getsafle/vault-polygon-zkevm-controller": "^1.0.1", + "@getsafle/vault-rootstock-controller": "^1.0.0", "@getsafle/vault-sol-controller": "^1.0.1", "@getsafle/vault-stacks-controller": "^1.0.5", "@getsafle/vault-velas-controller": "^1.3.1", From a8515f05edcda5640f08973f8aecd96588b08d16 Mon Sep 17 00:00:00 2001 From: Husien vora Date: Tue, 20 Aug 2024 19:00:38 +0530 Subject: [PATCH 91/98] updating tests and workflow --- src/lib/test/keyring.test.js | 2404 +++++++++++++++------------------- 1 file changed, 1040 insertions(+), 1364 deletions(-) diff --git a/src/lib/test/keyring.test.js b/src/lib/test/keyring.test.js index 74ef7b0..042f6b5 100644 --- a/src/lib/test/keyring.test.js +++ b/src/lib/test/keyring.test.js @@ -1,1395 +1,1071 @@ -jest.setTimeout(30000) - - -const { before } = require('lodash') -let KeyRing = require('../keyring') -let Vault = require('../vault') -const Web3 = require('web3') -const bufView = [48, 0, 236, 187, 187, 172, 177, 90, 255, 184, 9, 116, 142, 96, 197, 158, 87, 35, 26, 101, 187, 30, 116, 138, 50, 131, 166, 50, 51, 197, 198, 83, 238, 167, 105, 178, 182, 108, 174, 199, 124, 141, 155, 73, 21, 85, 81, 109, 78, 233, 152, 108, 242, 238, 192, 31, 147, 86, 174, 195, 55, 229, 4, 36]; -let phrase="fun rough treat scan glimpse region century purpose expire video remind second" -let pin="696969" -let result -let vault =new Vault({}) -let vaultAddress -let privateKey -let accAddress -let privateKeyImp = "0x7a9633b8103fec11c9e855a6b6c8c072e9af311a69b92ab0ad8186b1fb57371f" -let impAccAddress - - -let chains -const ethUrl = 'https://mainnet.infura.io/v3/6145d532688844c4b6db32574d90e19f'; -const polygonRpcUrl = 'https://polygon-testnet.public.blastapi.io'; -const bscRpcUrl = 'https://rpc.ankr.com/bsc'; -beforeAll(async() => { - - result = await vault.generateVault(bufView,pin,phrase) - vaultAddress=result.response - await vault.getAccounts(bufView); - +jest.setTimeout(30000); + +const { before } = require("lodash"); +let KeyRing = require("../keyring"); +let Vault = require("../vault"); +const Web3 = require("web3"); +const bufView = [ + 48, 0, 236, 187, 187, 172, 177, 90, 255, 184, 9, 116, 142, 96, 197, 158, 87, + 35, 26, 101, 187, 30, 116, 138, 50, 131, 166, 50, 51, 197, 198, 83, 238, 167, + 105, 178, 182, 108, 174, 199, 124, 141, 155, 73, 21, 85, 81, 109, 78, 233, + 152, 108, 242, 238, 192, 31, 147, 86, 174, 195, 55, 229, 4, 36, +]; +let phrase = + "fun rough treat scan glimpse region century purpose expire video remind second"; +let pin = "696969"; +let result; +let vault = new Vault({}); +let vaultAddress; +let privateKey; +let accAddress; +let privateKeyImp = + "0x7a9633b8103fec11c9e855a6b6c8c072e9af311a69b92ab0ad8186b1fb57371f"; +let impAccAddress; + +let chains; +const ethUrl = "https://mainnet.infura.io/v3/6145d532688844c4b6db32574d90e19f"; +const polygonRpcUrl = "https://polygon-testnet.public.blastapi.io"; +const bscRpcUrl = "https://rpc.ankr.com/bsc"; +beforeAll(async () => { + result = await vault.generateVault(bufView, pin, phrase); + vaultAddress = result.response; + await vault.getAccounts(bufView); }); -describe('exportMnemonic' , ()=>{ - - test('Valid exportMnemonic/invalid pin' , async()=>{ - - let result = await new KeyRing().exportMnemonic(1111) - expect(result.error).toBe('Wrong pin type, format or length') - }) - test('Valid exportMnemonic/INCORRECT_PIN' , async()=>{ - - let result = await new KeyRing().exportMnemonic("111111") - expect(result.error).toBe('Incorrect pin') - }) - - test('Valid exportMnemonic/INCORRECT_PIN_TYPE' , async()=>{ - - try{ - - let resultResp = await vault.exportMnemonic("srdtfyu") - - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - } - - }) - - - test('Valid exportMnemonic' , async()=>{ - - let resultResp = await vault.exportMnemonic(pin) - expect(resultResp).toHaveProperty('response') - - - - }) - - -}) - - -describe('validatePin' , ()=>{ - - - - test('validatePin/invalid string' , async()=>{ - - try{ - - let result = await new KeyRing().validatePin("234rewtetyrjtuky") - - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - } - - }) - - test('validatePin/empty pin' , async()=>{ - - try{ - - let result = await new KeyRing().validatePin(null) - - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - } - - }) - - test('validatePin/valid pin' , async()=>{ - let result = await vault.validatePin(pin) - expect({response:true}).toMatchObject(result) - - }) - - - -}) - -describe('addAccount' , ()=>{ - - test('addAccount/valid' , async()=>{ - let result = await vault.addAccount(bufView,pin) - accAddress=result.response.address - - expect(result.response).toHaveProperty('address') - - }) - - test('addAccount/empty encryption key' , async()=>{ - try{ - let result = await vault.addAccount(null,pin) - } - catch(e){ - expect(e.message).toBe("Incorrect Encryption Key or vault string") - } - - }) - - test('addAccount/empty pin' , async()=>{ - - let result = await vault.addAccount(bufView,null) - expect(result.error).toBe("Wrong pin type, format or length") - - - - - - }) - test('addAccount/invalid pin' , async()=>{ - - let result = await vault.addAccount(bufView,123333) - expect(result.error).toBe("Wrong pin type, format or length") - - - - }) - test('addAccount/incorrect pin' , async()=>{ - - let result = await vault.addAccount(bufView,"123333") - expect(result.error).toBe("Incorrect pin") - - - - }) - test('addAccount/both param empty' , async()=>{ - - let result = await vault.addAccount("","") - expect(result.error).toBe("Wrong pin type, format or length") - - - - - }) - - - - -}) - -describe('exportPrivateKey' , ()=>{ - - test('exportPrivateKey/valid' , async()=>{ - let result = await vault.exportPrivateKey(accAddress,pin) - privateKey=result.response.privateKey - - - }) - - test('exportPrivateKey/empty accAddress' , async()=>{ - - try{ - let result = await vault.exportPrivateKey(null,pin) - } - catch(e){ - expect(e.message).toBe("Cannot read properties of null (reading 'toLowerCase')") - } - - - }) - - test('exportPrivateKey/empty pin' , async()=>{ - - let result = await vault.exportPrivateKey(accAddress,null) - expect(result.error).toBe("Wrong pin type, format or length") - - }) - - test('exportPrivateKey/both empty' , async()=>{ - - let result = await vault.exportPrivateKey(null,null) - expect(result.error).toBe("Wrong pin type, format or length") - - }) - test('exportPrivateKey/incorrect pin' , async()=>{ - - let result = await vault.exportPrivateKey(accAddress,"111111") - expect(result.error).toBe("Incorrect pin") - - }) - -}) - - -describe('importWallet' , ()=>{ - - test('importWallet/valid import' , async()=>{ - let result = await vault.importWallet("0x"+privateKeyImp,pin,bufView) - impAccAddress = result.response.address - expect(result).toHaveProperty('response.address') - - }) - - - test('importWallet/valid address exists already' , async()=>{ - let result = await vault.importWallet("0x"+privateKey,pin,bufView) - expect(result.error).toBe('This address is already present in the vault') - - - }) - - test('importWallet/empty private key' , async()=>{ - try{ - let result = await vault.importWallet(null,pin,bufView) - } - catch(e){ - expect(e.message).toBe("Cannot read properties of null (reading 'startsWith')") - } - - - - }) - - test('importWallet/empty pin' , async()=>{ - - let result = await vault.importWallet("0x"+privateKey,null,bufView) - expect(result.error).toBe("Wrong pin type, format or length") - - - }) - test('importWallet/incorrect pin' , async()=>{ - - let result = await vault.importWallet("0x"+privateKey,"111111",bufView) - expect(result.error).toBe("Incorrect pin") - - - }) - test('importWallet/empty encryption key' , async()=>{ - - let result = await vault.importWallet("0x"+privateKey,pin,null) - expect(result.error).toBe("Incorrect Encryption Key or vault string") - - }) - - test('importWallet/empty all params' , async()=>{ - - let result = await vault.importWallet(null,null,null) - expect(result.error).toBe("Wrong pin type, format or length") - - - - - - - }) - - - -}) - -describe('getActiveChains',()=>{ - - test('getActiveChains' , async()=>{ - let result = await vault.getActiveChains() - chains=result.response - expect({ +describe("exportMnemonic", () => { + test("Valid exportMnemonic/invalid pin", async () => { + let result = await new KeyRing().exportMnemonic(1111); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + test("Valid exportMnemonic/INCORRECT_PIN", async () => { + let result = await new KeyRing().exportMnemonic("111111"); + expect(result.error).toBe("Incorrect pin"); + }); + + test("Valid exportMnemonic/INCORRECT_PIN_TYPE", async () => { + try { + let resultResp = await vault.exportMnemonic("srdtfyu"); + } catch (e) { + expect(e).toBe("Wrong pin type, format or length"); + } + }); + + test("Valid exportMnemonic", async () => { + let resultResp = await vault.exportMnemonic(pin); + expect(resultResp).toHaveProperty("response"); + }); +}); + +describe("validatePin", () => { + test("validatePin/invalid string", async () => { + try { + let result = await new KeyRing().validatePin("234rewtetyrjtuky"); + } catch (e) { + expect(e).toBe("Wrong pin type, format or length"); + } + }); + + test("validatePin/empty pin", async () => { + try { + let result = await new KeyRing().validatePin(null); + } catch (e) { + expect(e).toBe("Wrong pin type, format or length"); + } + }); + + test("validatePin/valid pin", async () => { + let result = await vault.validatePin(pin); + expect({ response: true }).toMatchObject(result); + }); +}); + +describe("addAccount", () => { + test("addAccount/valid", async () => { + let result = await vault.addAccount(bufView, pin); + accAddress = result.response.address; + + expect(result.response).toHaveProperty("address"); + }); + + test("addAccount/empty encryption key", async () => { + try { + let result = await vault.addAccount(null, pin); + } catch (e) { + expect(e.message).toBe("Incorrect Encryption Key or vault string"); + } + }); + + test("addAccount/empty pin", async () => { + let result = await vault.addAccount(bufView, null); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + test("addAccount/invalid pin", async () => { + let result = await vault.addAccount(bufView, 123333); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + test("addAccount/incorrect pin", async () => { + let result = await vault.addAccount(bufView, "123333"); + expect(result.error).toBe("Incorrect pin"); + }); + test("addAccount/both param empty", async () => { + let result = await vault.addAccount("", ""); + expect(result.error).toBe("Wrong pin type, format or length"); + }); +}); + +describe("exportPrivateKey", () => { + test("exportPrivateKey/valid", async () => { + let result = await vault.exportPrivateKey(accAddress, pin); + privateKey = result.response.privateKey; + }); + + test("exportPrivateKey/empty accAddress", async () => { + try { + let result = await vault.exportPrivateKey(null, pin); + } catch (e) { + expect(e.message).toBe( + "Cannot read properties of null (reading 'toLowerCase')" + ); + } + }); + + test("exportPrivateKey/empty pin", async () => { + let result = await vault.exportPrivateKey(accAddress, null); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + + test("exportPrivateKey/both empty", async () => { + let result = await vault.exportPrivateKey(null, null); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + test("exportPrivateKey/incorrect pin", async () => { + let result = await vault.exportPrivateKey(accAddress, "111111"); + expect(result.error).toBe("Incorrect pin"); + }); +}); + +describe("importWallet", () => { + test("importWallet/valid import", async () => { + let result = await vault.importWallet("0x" + privateKeyImp, pin, bufView); + impAccAddress = result.response.address; + expect(result).toHaveProperty("response.address"); + }); + + test("importWallet/valid address exists already", async () => { + let result = await vault.importWallet("0x" + privateKey, pin, bufView); + expect(result.error).toBe("This address is already present in the vault"); + }); + + test("importWallet/empty private key", async () => { + try { + let result = await vault.importWallet(null, pin, bufView); + } catch (e) { + expect(e.message).toBe( + "Cannot read properties of null (reading 'startsWith')" + ); + } + }); + + test("importWallet/empty pin", async () => { + let result = await vault.importWallet("0x" + privateKey, null, bufView); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + test("importWallet/incorrect pin", async () => { + let result = await vault.importWallet("0x" + privateKey, "111111", bufView); + expect(result.error).toBe("Incorrect pin"); + }); + test("importWallet/empty encryption key", async () => { + let result = await vault.importWallet("0x" + privateKey, pin, null); + expect(result.error).toBe("Incorrect Encryption Key or vault string"); + }); + + test("importWallet/empty all params", async () => { + let result = await vault.importWallet(null, null, null); + expect(result.error).toBe("Wrong pin type, format or length"); + }); +}); + +describe("getActiveChains", () => { + test("getActiveChains", async () => { + let result = await vault.getActiveChains(); + chains = result.response; + expect({ response: [ - { chain: 'bitcoin', symbol: 'BTC' }, - { chain: 'stacks', symbol: 'STX' }, - { chain: 'solana', symbol: 'SOL' }, - { chain: 'ethereum', symbol: 'ETH' }, - { chain: 'bsc', symbol: 'BSC' }, - { chain: 'polygon', symbol: 'MATIC' }, - { chain: 'optimism', symbol: 'OP' }, - { chain: 'arbitrum', symbol: 'ARB' }, - { chain: 'mantle', symbol: 'MNT' }, - { chain: 'velas', symbol: 'VLX' }, - { chain: 'avalanche', symbol: 'AVAX' }, - { chain: 'base', symbol: 'BASE' }, - { chain: 'zkEVM', symbol: 'ZKEVM' }, - { chain: 'bevm', symbol: 'BTC' }, - {chain: 'rootstock', symbol: 'RBTC'} - ] - }).toMatchObject(result) - - }) -}) - -describe('deleteAccount',()=>{ - test('deleteAccount/valid generated acc' , async()=>{ - - let result = await vault.deleteAccount(bufView,accAddress,pin) - expect(result).toHaveProperty('response') - - }) - - test('deleteAccount/valid imported acc' , async()=>{ - - let result = await vault.deleteAccount(bufView,impAccAddress,pin) - expect(result).toHaveProperty('response') - - }) - - - test('deleteAccount/empty encryption key' , async()=>{ - try{ - let result = await vault.deleteAccount(null,accAddress,pin) - } - catch(e){ - expect(e.message).toBe("Incorrect Encryption Key or vault string") - } - - - }) - - test('deleteAccount/invalid encryption key' , async()=>{ - try{ - let result = await vault.deleteAccount(null,accAddress,pin) - } - catch(e){ - expect(e.message).toBe("Incorrect Encryption Key or vault string") - } - - - }) - test('deleteAccount/empty address' , async()=>{ - - let result = await vault.deleteAccount(bufView,null,'696969') - expect(result.error).toBe('This address is not present in the vault') - - - }) - test('deleteAccount/invalid address' , async()=>{ - - let result = await vault.deleteAccount(bufView,"rerwgtehry",'696969') - expect(result.error).toBe('This address is not present in the vault') - - - }) - test('deleteAccount/empty pin' , async()=>{ - - let result = await vault.deleteAccount(bufView,accAddress,null) - expect(result.error).toBe("Wrong pin type, format or length") - - - - - - }) - test('deleteAccount/invalid pin' , async()=>{ - - let result = await vault.deleteAccount(bufView,accAddress,"efwe") - expect(result.error).toBe("Wrong pin type, format or length") - - - }) - test('deleteAccount/incorrect pin' , async()=>{ - - let result = await vault.deleteAccount(bufView,accAddress,"111111") - expect(result.error).toBe("Incorrect pin") - - - }) - test('deleteAccount/all params empty' , async()=>{ - try{ - let result = await vault.deleteAccount(null,null,null) - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - - } - - - }) -}) - - -describe('restoreAccount', ()=> { - - test('restoreAccount/valid generated acc' , async()=>{ - - let result = await vault.restoreAccount(bufView,accAddress,pin) - expect(result).toHaveProperty('response') - - }) - - test('restoreAccount/valid imported acc' , async()=>{ - - let result = await vault.restoreAccount(bufView,impAccAddress,pin) - expect(result).toHaveProperty('response') - - }) - - - test('restoreAccount/empty encryption key' , async()=>{ - try{ - let result = await vault.restoreAccount(null,accAddress,pin) - } - catch(e){ - expect(e.message).toBe("Incorrect Encryption Key or vault string") - } - - - }) - - test('restoreAccount/invalid encryption key' , async()=>{ - try{ - let result = await vault.restoreAccount(null,accAddress,pin) - } - catch(e){ - expect(e.message).toBe("Incorrect Encryption Key or vault string") - } - - - }) - test('restoreAccount/empty address' , async()=>{ - - let result = await vault.restoreAccount(bufView,null,pin) - expect(result.error).toBe('This address is not present in the vault') - - - }) - test('restoreAccount/invalid address' , async()=>{ - - let result = await vault.restoreAccount(bufView,"rerwgtehry",pin) - expect(result.error).toBe('This address is not present in the vault') - - - }) - test('restoreAccount/empty pin' , async()=>{ - - try { - let result = await vault.restoreAccount(bufView,accAddress,null) - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - } - - - }) - test('restoreAccount/invalid pin' , async()=>{ - - try { - let result = await vault.restoreAccount(bufView,accAddress,"efwe") - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - } - - - }) - test('restoreAccount/incorrect pin' , async()=>{ - - let result = await vault.restoreAccount(bufView,accAddress,"111111") - expect(result.error).toBe("Incorrect pin") - - - }) - test('restoreAccount/all params empty' , async()=>{ - try{ - let result = await vault.restoreAccount(null,null,null) - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - - } - - - }) -}) - - - -describe('restoreKeyringState',()=>{ - test('restoreKeyringState/valid' , async()=>{ - - - await vault.restoreKeyringState(vaultAddress,pin,bufView) - expect(result).toHaveProperty('response') - - - }) - - test('restoreKeyringState/empty vault address' , async()=>{ - try{ - let result= await vault.restoreKeyringState(null,pin,bufView) - - } - catch(e){ - expect(e.message).toBe("Cannot read properties of null (reading 'salt')") - } - - - }) - - test('restoreKeyringState/invalid vault address' , async()=>{ - - let result= await vault.restoreKeyringState("abc",pin,bufView) - expect(result.error).toBe('Incorrect Encryption Key or vault string') - - - }) - - test('restoreKeyringState/empty pin' , async()=>{ - - let result= await vault.restoreKeyringState(vaultAddress,null,bufView) - expect(result.error).toBe("Wrong pin type, format or length") - - - - - - }) - - test('restoreKeyringState/invalid pin' , async()=>{ - - let result= await vault.restoreKeyringState(vaultAddress,"avevr",bufView) - expect(result.error).toBe("Wrong pin type, format or length") - - - - - - }) - - test('restoreKeyringState/empty encrption key' , async()=>{ - - let result= await vault.restoreKeyringState(vaultAddress,pin,null) - expect(result.error).toBe('Incorrect Encryption Key or vault string') - - - - - }) - - test('restoreKeyringState/invalid encrption key' , async()=>{ - - let result= await vault.restoreKeyringState(vaultAddress,pin,"weefew") - expect(result.error).toBe('Incorrect Encryption Key or vault string') - - - }) - - test('restoreKeyringState/all params empty' , async()=>{ - - let result= await vault.restoreKeyringState(null,null,null) - expect(result.error).toBe("Wrong pin type, format or length") - - - - - - }) - - -}) - - - -describe('getVaultDetails',()=>{ - test('getVaultDetails/valid' , async()=>{ - let result = await vault.getVaultDetails(bufView) - expect(result.response).toHaveProperty('evm') - - - }) - - test('getVaultDetails/empty encryption key' , async()=>{ - let result = await vault.getVaultDetails(null) - expect(result.error).toBe('Incorrect Encryption Key or vault string') - - - - }) - - test('getVaultDetails/invalid encryption key' , async()=>{ - let result = await vault.getVaultDetails("adfaefae") - expect(result.error).toBe('Incorrect Encryption Key or vault string') - - - - }) -}) - -describe('getBalance',()=>{ - - - test('getBalance/valid' , async()=>{ - - let result = await vault.getBalance(accAddress,polygonRpcUrl) - expect(result.response).toHaveProperty('balance') - - - }) - - test('getBalance/empty address' , async()=>{ - try{ - let result = await vault.getBalance(null,ethUrl) - - } - catch(e){ - expect(e.message).toBe("Provided address null is invalid, the capitalization checksum test failed, or it's an indirect IBAN address which can't be converted.") - } - - - }) - - - - test('getBalance/invalid address' , async()=>{ - let addr="fghioiuhgf" - try{ - - let result = await vault.getBalance("fghioiuhgf",ethUrl) - - } - catch(e){ - expect(e.message).toBe(`Provided address ${addr} is invalid, the capitalization checksum test failed, or it's an indirect IBAN address which can't be converted.`) - } - - - }) - - test('getBalance/empty url' , async()=>{ - try{ - - let result = await vault.getBalance(accAddress,null) - - } - catch(e){ - expect(e.message).toBe(`CONNECTION ERROR: Couldn't connect to node http://localhost:8545.`) - } - - - }) - test('getBalance/invalid url' , async()=>{ - let url="https.11.com" - try{ - - let result = await vault.getBalance(accAddress,url) - - } - catch(e){ - expect(e.message).toBe(`CONNECTION ERROR: Couldn't connect to node ${url}.`) - } - - - }) - - - - -}) - - - - - - -describe('updateLabel',()=>{ - - test('updateLabel/valid' , async()=>{ - let result = await vault.updateLabel("0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd",bufView,"Wallet 1") - expect(result).toHaveProperty('response') - - - }) - - test('updateLabel/invalid address' , async()=>{ - let result = await vault.updateLabel("adeded",bufView,"Wallet 1") - expect(result.error).toBe('This address is not present in the vault') - - - }) - - test('updateLabel/empty address' , async()=>{ - let result = await vault.updateLabel(null,bufView,"Wallet 1") - expect(result.error).toBe('This address is not present in the vault') - - - }) - test('updateLabel/invalid encryption key' , async()=>{ - - let result = await vault.updateLabel("0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd","afers","Wallet 1") - expect(result.error).toBe('Incorrect Encryption Key or vault string') - - - - }) - test('updateLabel/empty encryption key' , async()=>{ - - let result = await vault.updateLabel("0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd",null,"Wallet 1") - expect(result.error).toBe('Incorrect Encryption Key or vault string') - - - - - - }) - test('updateLabel/empty label' , async()=>{ - try{ - let result = await vault.updateLabel("0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd",bufView,null) - } - catch(e){ - expect(e.message).toBe('chainName is not defined') - } - - - - }) - test('updateLabel/all empty params' , async()=>{ - - let result = await vault.updateLabel(null,null,null) - expect(result.error).toBe('Incorrect Encryption Key or vault string') - - - - }) - -}) - - -describe('sign',()=>{ - - test('sign/valid' , async()=>{ - let data="hello world" - console.log("sign/valid--->",pin,ethUrl) - await vault.restoreKeyringState(vault,pin,bufView) - - let result = await vault.sign(data,"0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd",pin,ethUrl) - console.log("sign/valid--->",result) - expect(result.response).toHaveProperty('signature') - - }) - - test('sign/empty data' , async()=>{ - - let data="hello world" - let result = await vault.sign("","0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd",pin,ethUrl) - expect(result.response).toHaveProperty('signature') - - }) - - - test('sign/empty address' , async()=>{ - - let data="hello world" - try{ - let result = await vault.sign(data,null,pin,ethUrl) - - }catch(e){ - expect(e.message).toBe("Cannot read properties of null (reading 'toLowerCase')") - } - - - }) - test('sign/invalid address' , async()=>{ - - let data="hello world" - try{ - let result = await vault.sign(data,"abc",pin,ethUrl) - } - catch(e){ - expect(e.message).toBe('Given address "abc" is not a valid Ethereum address.') - } - - - - - }) - test('sign/empty pin' , async()=>{ - - let data="hello world" - - let result = await vault.sign(data,"abc",null,ethUrl) - expect(result.error).toBe("Wrong pin type, format or length") - - }) - test('sign/incorrect pin' , async()=>{ - - let data="hello world" - - let result = await vault.sign(data,"abc","111111",ethUrl) - expect(result.error).toBe("Incorrect pin") - - }) - test('sign/invalid pin' , async()=>{ - - let data="hello world" - let result = await vault.sign(data,accAddress,"abc",ethUrl) - expect(result.error).toBe("Wrong pin type, format or length") - - }) - - test('sign/empty url' , async()=>{ - - let data="hello world" - let result = await vault.sign(data,"0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd",pin,null) - expect(result.response).toHaveProperty('signature') - - - - - - }) - - test('sign/invalid url' , async()=>{ - - let data="hello world" - let result = await vault.sign(data,"0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd",pin,"abc") - expect(result.response).toHaveProperty('signature') - - }) - - test('sign/all params empty' , async()=>{ - - let data="hello world" - - let result = await vault.sign(null,null,null,null) - expect(result.error).toBe("Wrong pin type, format or length") - - - }) - - - - - - - -}) - - -describe('validateMnemonic',()=>{ - let signUpPhrase='ladder equip piano open silent pizza solid cannon name volcano fee valley' - test('validateMnemonic/valid' , async()=>{ - let result = await vault.validateMnemonic(signUpPhrase,'abhi141','testnet',polygonRpcUrl) - expect(result.response).toBe(true) - - - }) - test('validateMnemonic/empty phrase' , async()=>{ - let result = await vault.validateMnemonic('','abhi141','testnet',polygonRpcUrl) - expect(result.response).toBe(false) - - - }) - test('validateMnemonic/invalid phrase' , async()=>{ - let result = await vault.validateMnemonic('waefsgrth','abhi141','testnet',polygonRpcUrl) - expect(result.response).toBe(false) - - - }) - test('validateMnemonic/empty safle id' , async()=>{ - let result = await vault.validateMnemonic(signUpPhrase,null,'testnet',polygonRpcUrl) - expect(result.response).toBe(false) - - - }) - test('validateMnemonic/invalid safle id' , async()=>{ - let result = await vault.validateMnemonic(signUpPhrase,"egsrrgr",'testnet',polygonRpcUrl) - expect(result.response).toBe(false) - - - }) - test('validateMnemonic/empty network' , async()=>{ - try{ - let result = await vault.validateMnemonic(signUpPhrase,'abhi141',null,polygonRpcUrl) - - } - catch(e){ - expect(e).toBe('Invalid network selected') - } - - - }) - test('validateMnemonic/invalid network' , async()=>{ - try{ - let result = await vault.validateMnemonic(signUpPhrase,'abhi141',"segsr",polygonRpcUrl) - - } - catch(e){ - expect(e).toBe('Invalid network selected') - } - - - }) - test('validateMnemonic/invalid network' , async()=>{ - try{ - let result = await vault.validateMnemonic(signUpPhrase,'abhi141',"segsr",polygonRpcUrl) - - } - catch(e){ - expect(e).toBe('Invalid network selected') - } - - - }) - test('validateMnemonic/invalid url' , async()=>{ - - let result = await vault.validateMnemonic(signUpPhrase,'abhi141','testnet',"awfe") - expect(result.response).toBe(false) - - }) - test('validateMnemonic/empty url' , async()=>{ - - let result = await vault.validateMnemonic(signUpPhrase,'abhi141','testnet',null) - expect(result.response).toBe(false) - - }) - test('validateMnemonic/all empty params' , async()=>{ - try{ - let result = await vault.validateMnemonic(null,null,null,null) - } - - catch(e){ - expect(e).toBe('Invalid network selected') - } - - }) -}) - -describe('changePin',()=>{ - test('changePin/valid' , async()=>{ - let result = await vault.changePin(pin,pin,bufView) - expect(result).toHaveProperty('response') - - - }) - - test('changePin/wrong currentpin' , async()=>{ - try{ - let result = await vault.changePin("111111",pin,bufView) - - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - } - - - }) - - test('changePin/invalid currentpin' , async()=>{ - try{ - let result = await vault.changePin('aefe',pin,bufView) - - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - } - - - - - }) - test('changePin/empty currentpin' , async()=>{ - try{ - let result = await vault.changePin(null,pin,bufView) - - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - } - - - }) - - test('changePin/empty new pin' , async()=>{ - try{ - let result = await vault.changePin(pin,null,bufView) - - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - } - - - }) - - test('changePin/invalid new pin' , async()=>{ - try{ - let result = await vault.changePin(pin,'afaef',bufView) - - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - } - - - }) - - test('changePin/empty encryption key' , async()=>{ - try{ - let result = await vault.changePin(pin,pin,null) - } - catch(e){ - expect(e.message).toBe("Incorrect Encryption Key or vault string") - } - - - }) - - test('changePin/invalid encryption key' , async()=>{ - try{ - let result = await vault.changePin(pin,pin,'efefe') - } - catch(e){ - expect(e.message).toBe("Incorrect Encryption Key or vault string") - } - - - - - }) - test('changePin/all empty params' , async()=>{ - try{ - let result = await vault.changePin(null,null,null) - - } - catch(e){ - expect(e).toBe('Wrong pin type, format or length') - } - - - }) - -}) - - - -describe('getLogs',()=>{ - test('getLogs/valid' , async()=>{ - - let result = await vault.getLogs() - expect(result).toHaveProperty('logs') - - - }) -}) - - -describe('getAccounts',()=>{ - test('getAccounts/valid' , async()=>{ - await vault.restoreKeyringState(vaultAddress,pin,bufView) - let result = await vault.getAccounts() - expect(result).toHaveProperty('response') - - }) - -}) - - -describe('signTransaction',()=>{ - - - test('signTransaction/valid' , async()=>{ - let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" - const web3 = new Web3(polygonRpcUrl) - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + { chain: "bitcoin", symbol: "BTC" }, + { chain: "stacks", symbol: "STX" }, + { chain: "solana", symbol: "SOL" }, + { chain: "ethereum", symbol: "ETH" }, + { chain: "bsc", symbol: "BSC" }, + { chain: "polygon", symbol: "MATIC" }, + { chain: "optimism", symbol: "OP" }, + { chain: "arbitrum", symbol: "ARB" }, + { chain: "mantle", symbol: "MNT" }, + { chain: "velas", symbol: "VLX" }, + { chain: "avalanche", symbol: "AVAX" }, + { chain: "base", symbol: "BASE" }, + { chain: "zkEVM", symbol: "ZKEVM" }, + { chain: "bevm", symbol: "BTC" }, + { chain: "rootstock", symbol: "RBTC" }, + ], + }).toMatchObject(result); + }); +}); - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), - maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), - data: '0x0', // method to generate data is provided below - nonce: nonce, - type: '0x2', - }; - await vault.getActiveChains() - try{ +describe("deleteAccount", () => { + test("deleteAccount/valid generated acc", async () => { + let result = await vault.deleteAccount(bufView, accAddress, pin); + expect(result).toHaveProperty("response"); + }); + + test("deleteAccount/valid imported acc", async () => { + let result = await vault.deleteAccount(bufView, impAccAddress, pin); + expect(result).toHaveProperty("response"); + }); + + test("deleteAccount/empty encryption key", async () => { + try { + let result = await vault.deleteAccount(null, accAddress, pin); + } catch (e) { + expect(e.message).toBe("Incorrect Encryption Key or vault string"); + } + }); + + test("deleteAccount/invalid encryption key", async () => { + try { + let result = await vault.deleteAccount(null, accAddress, pin); + } catch (e) { + expect(e.message).toBe("Incorrect Encryption Key or vault string"); + } + }); + test("deleteAccount/empty address", async () => { + let result = await vault.deleteAccount(bufView, null, "696969"); + expect(result.error).toBe("This address is not present in the vault"); + }); + test("deleteAccount/invalid address", async () => { + let result = await vault.deleteAccount(bufView, "rerwgtehry", "696969"); + expect(result.error).toBe("This address is not present in the vault"); + }); + test("deleteAccount/empty pin", async () => { + let result = await vault.deleteAccount(bufView, accAddress, null); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + test("deleteAccount/invalid pin", async () => { + let result = await vault.deleteAccount(bufView, accAddress, "efwe"); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + test("deleteAccount/incorrect pin", async () => { + let result = await vault.deleteAccount(bufView, accAddress, "111111"); + expect(result.error).toBe("Incorrect pin"); + }); + test("deleteAccount/all params empty", async () => { + try { + let result = await vault.deleteAccount(null, null, null); + } catch (e) { + expect(e).toBe("Wrong pin type, format or length"); + } + }); +}); + +describe("restoreAccount", () => { + test("restoreAccount/valid generated acc", async () => { + let result = await vault.restoreAccount(bufView, accAddress, pin); + expect(result).toHaveProperty("response"); + }); + + test("restoreAccount/valid imported acc", async () => { + let result = await vault.restoreAccount(bufView, impAccAddress, pin); + expect(result).toHaveProperty("response"); + }); + + test("restoreAccount/empty encryption key", async () => { + try { + let result = await vault.restoreAccount(null, accAddress, pin); + } catch (e) { + expect(e.message).toBe("Incorrect Encryption Key or vault string"); + } + }); + + test("restoreAccount/invalid encryption key", async () => { + try { + let result = await vault.restoreAccount(null, accAddress, pin); + } catch (e) { + expect(e.message).toBe("Incorrect Encryption Key or vault string"); + } + }); + test("restoreAccount/empty address", async () => { + let result = await vault.restoreAccount(bufView, null, pin); + expect(result.error).toBe("This address is not present in the vault"); + }); + test("restoreAccount/invalid address", async () => { + let result = await vault.restoreAccount(bufView, "rerwgtehry", pin); + expect(result.error).toBe("This address is not present in the vault"); + }); + test("restoreAccount/empty pin", async () => { + try { + let result = await vault.restoreAccount(bufView, accAddress, null); + } catch (e) { + expect(e).toBe("Wrong pin type, format or length"); + } + }); + test("restoreAccount/invalid pin", async () => { + try { + let result = await vault.restoreAccount(bufView, accAddress, "efwe"); + } catch (e) { + expect(e).toBe("Wrong pin type, format or length"); + } + }); + test("restoreAccount/incorrect pin", async () => { + let result = await vault.restoreAccount(bufView, accAddress, "111111"); + expect(result.error).toBe("Incorrect pin"); + }); + test("restoreAccount/all params empty", async () => { + try { + let result = await vault.restoreAccount(null, null, null); + } catch (e) { + expect(e).toBe("Wrong pin type, format or length"); + } + }); +}); - let result = await vault.signTransaction(rawTx,pin,polygonRpcUrl) +describe("restoreKeyringState", () => { + test("restoreKeyringState/valid", async () => { + await vault.restoreKeyringState(vaultAddress, pin, bufView); + expect(result).toHaveProperty("response"); + }); + + test("restoreKeyringState/empty vault address", async () => { + try { + let result = await vault.restoreKeyringState(null, pin, bufView); + } catch (e) { + expect(e.message).toBe("Cannot read properties of null (reading 'salt')"); + } + }); + + test("restoreKeyringState/invalid vault address", async () => { + let result = await vault.restoreKeyringState("abc", pin, bufView); + expect(result.error).toBe("Incorrect Encryption Key or vault string"); + }); + + test("restoreKeyringState/empty pin", async () => { + let result = await vault.restoreKeyringState(vaultAddress, null, bufView); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + + test("restoreKeyringState/invalid pin", async () => { + let result = await vault.restoreKeyringState( + vaultAddress, + "avevr", + bufView + ); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + + test("restoreKeyringState/empty encrption key", async () => { + let result = await vault.restoreKeyringState(vaultAddress, pin, null); + expect(result.error).toBe("Incorrect Encryption Key or vault string"); + }); + + test("restoreKeyringState/invalid encrption key", async () => { + let result = await vault.restoreKeyringState(vaultAddress, pin, "weefew"); + expect(result.error).toBe("Incorrect Encryption Key or vault string"); + }); + + test("restoreKeyringState/all params empty", async () => { + let result = await vault.restoreKeyringState(null, null, null); + expect(result.error).toBe("Wrong pin type, format or length"); + }); +}); - } - catch(e){ - expect(e.message).toBe("Cannot read property 'salt' of undefined") +describe("getVaultDetails", () => { + test("getVaultDetails/valid", async () => { + let result = await vault.getVaultDetails(bufView); + expect(result.response).toHaveProperty("evm"); + }); + + test("getVaultDetails/empty encryption key", async () => { + let result = await vault.getVaultDetails(null); + expect(result.error).toBe("Incorrect Encryption Key or vault string"); + }); + + test("getVaultDetails/invalid encryption key", async () => { + let result = await vault.getVaultDetails("adfaefae"); + expect(result.error).toBe("Incorrect Encryption Key or vault string"); + }); +}); - } - - - - - }) +describe("getBalance", () => { + test("getBalance/valid", async () => { + let result = await vault.getBalance(accAddress, polygonRpcUrl); + expect(result.response).toHaveProperty("balance"); + }); + + test("getBalance/empty address", async () => { + try { + let result = await vault.getBalance(null, ethUrl); + } catch (e) { + expect(e.message).toBe( + "Provided address null is invalid, the capitalization checksum test failed, or it's an indirect IBAN address which can't be converted." + ); + } + }); + + test("getBalance/invalid address", async () => { + let addr = "fghioiuhgf"; + try { + let result = await vault.getBalance("fghioiuhgf", ethUrl); + } catch (e) { + expect(e.message).toBe( + `Provided address ${addr} is invalid, the capitalization checksum test failed, or it's an indirect IBAN address which can't be converted.` + ); + } + }); + + test("getBalance/empty url", async () => { + try { + let result = await vault.getBalance(accAddress, null); + } catch (e) { + expect(e.message).toBe( + `CONNECTION ERROR: Couldn't connect to node http://localhost:8545.` + ); + } + }); + test("getBalance/invalid url", async () => { + let url = "https.11.com"; + try { + let result = await vault.getBalance(accAddress, url); + } catch (e) { + expect(e.message).toBe( + `CONNECTION ERROR: Couldn't connect to node ${url}.` + ); + } + }); +}); + +describe("updateLabel", () => { + test("updateLabel/valid", async () => { + let result = await vault.updateLabel( + "0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd", + bufView, + "Wallet 1" + ); + expect(result).toHaveProperty("response"); + }); + + test("updateLabel/invalid address", async () => { + let result = await vault.updateLabel("adeded", bufView, "Wallet 1"); + expect(result.error).toBe("This address is not present in the vault"); + }); + + test("updateLabel/empty address", async () => { + let result = await vault.updateLabel(null, bufView, "Wallet 1"); + expect(result.error).toBe("This address is not present in the vault"); + }); + test("updateLabel/invalid encryption key", async () => { + let result = await vault.updateLabel( + "0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd", + "afers", + "Wallet 1" + ); + expect(result.error).toBe("Incorrect Encryption Key or vault string"); + }); + test("updateLabel/empty encryption key", async () => { + let result = await vault.updateLabel( + "0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd", + null, + "Wallet 1" + ); + expect(result.error).toBe("Incorrect Encryption Key or vault string"); + }); + test("updateLabel/empty label", async () => { + try { + let result = await vault.updateLabel( + "0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd", + bufView, + null + ); + } catch (e) { + expect(e.message).toBe("chainName is not defined"); + } + }); + test("updateLabel/all empty params", async () => { + let result = await vault.updateLabel(null, null, null); + expect(result.error).toBe("Incorrect Encryption Key or vault string"); + }); +}); + +describe("sign", () => { + test("sign/valid", async () => { + let data = "hello world"; + console.log("sign/valid--->", pin, ethUrl); + await vault.restoreKeyringState(vault, pin, bufView); + + let result = await vault.sign( + data, + "0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd", + pin, + ethUrl + ); + console.log("sign/valid--->", result); + expect(result.response).toHaveProperty("signature"); + }); + + test("sign/empty data", async () => { + let data = "hello world"; + let result = await vault.sign( + "", + "0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd", + pin, + ethUrl + ); + expect(result.response).toHaveProperty("signature"); + }); + + test("sign/empty address", async () => { + let data = "hello world"; + try { + let result = await vault.sign(data, null, pin, ethUrl); + } catch (e) { + expect(e.message).toBe( + "Cannot read properties of null (reading 'toLowerCase')" + ); + } + }); + test("sign/invalid address", async () => { + let data = "hello world"; + try { + let result = await vault.sign(data, "abc", pin, ethUrl); + } catch (e) { + expect(e.message).toBe( + 'Given address "abc" is not a valid Ethereum address.' + ); + } + }); + test("sign/empty pin", async () => { + let data = "hello world"; + + let result = await vault.sign(data, "abc", null, ethUrl); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + test("sign/incorrect pin", async () => { + let data = "hello world"; + + let result = await vault.sign(data, "abc", "111111", ethUrl); + expect(result.error).toBe("Incorrect pin"); + }); + test("sign/invalid pin", async () => { + let data = "hello world"; + let result = await vault.sign(data, accAddress, "abc", ethUrl); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + + test("sign/empty url", async () => { + let data = "hello world"; + let result = await vault.sign( + data, + "0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd", + pin, + null + ); + expect(result.response).toHaveProperty("signature"); + }); + + test("sign/invalid url", async () => { + let data = "hello world"; + let result = await vault.sign( + data, + "0x80f850d6bfa120bcc462df27cf94d7d23bd8b7fd", + pin, + "abc" + ); + expect(result.response).toHaveProperty("signature"); + }); + + test("sign/all params empty", async () => { + let data = "hello world"; + + let result = await vault.sign(null, null, null, null); + expect(result.error).toBe("Wrong pin type, format or length"); + }); +}); + +describe("validateMnemonic", () => { + let signUpPhrase = + "ladder equip piano open silent pizza solid cannon name volcano fee valley"; + test("validateMnemonic/valid", async () => { + let result = await vault.validateMnemonic( + signUpPhrase, + "abhi141", + "testnet", + polygonRpcUrl + ); + expect(result.response).toBe(true); + }); + test("validateMnemonic/empty phrase", async () => { + let result = await vault.validateMnemonic( + "", + "abhi141", + "testnet", + polygonRpcUrl + ); + expect(result.response).toBe(false); + }); + test("validateMnemonic/invalid phrase", async () => { + let result = await vault.validateMnemonic( + "waefsgrth", + "abhi141", + "testnet", + polygonRpcUrl + ); + expect(result.response).toBe(false); + }); + test("validateMnemonic/empty safle id", async () => { + let result = await vault.validateMnemonic( + signUpPhrase, + null, + "testnet", + polygonRpcUrl + ); + expect(result.response).toBe(false); + }); + test("validateMnemonic/invalid safle id", async () => { + let result = await vault.validateMnemonic( + signUpPhrase, + "egsrrgr", + "testnet", + polygonRpcUrl + ); + expect(result.response).toBe(false); + }); + test("validateMnemonic/empty network", async () => { + try { + let result = await vault.validateMnemonic( + signUpPhrase, + "abhi141", + null, + polygonRpcUrl + ); + } catch (e) { + expect(e).toBe("Invalid network selected"); + } + }); + test("validateMnemonic/invalid network", async () => { + try { + let result = await vault.validateMnemonic( + signUpPhrase, + "abhi141", + "segsr", + polygonRpcUrl + ); + } catch (e) { + expect(e).toBe("Invalid network selected"); + } + }); + test("validateMnemonic/invalid network", async () => { + try { + let result = await vault.validateMnemonic( + signUpPhrase, + "abhi141", + "segsr", + polygonRpcUrl + ); + } catch (e) { + expect(e).toBe("Invalid network selected"); + } + }); + test("validateMnemonic/invalid url", async () => { + let result = await vault.validateMnemonic( + signUpPhrase, + "abhi141", + "testnet", + "awfe" + ); + expect(result.response).toBe(false); + }); + test("validateMnemonic/empty url", async () => { + let result = await vault.validateMnemonic( + signUpPhrase, + "abhi141", + "testnet", + null + ); + expect(result.response).toBe(false); + }); + test("validateMnemonic/all empty params", async () => { + try { + let result = await vault.validateMnemonic(null, null, null, null); + } catch (e) { + expect(e).toBe("Invalid network selected"); + } + }); +}); - test('signTransaction/empty raw tx' , async()=>{ - let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" - const web3 = new Web3(polygonRpcUrl) +describe("changePin", () => { + test("changePin/valid", async () => { + let result = await vault.changePin(pin, pin, bufView); + expect(result).toHaveProperty("response"); + }); + + test("changePin/wrong currentpin", async () => { + try { + let result = await vault.changePin("111111", pin, bufView); + } catch (e) { + expect(e).toBe("Wrong pin type, format or length"); + } + }); + + test("changePin/invalid currentpin", async () => { + try { + let result = await vault.changePin("aefe", pin, bufView); + } catch (e) { + expect(e).toBe("Wrong pin type, format or length"); + } + }); + test("changePin/empty currentpin", async () => { + try { + let result = await vault.changePin(null, pin, bufView); + } catch (e) { + expect(e).toBe("Wrong pin type, format or length"); + } + }); + + test("changePin/empty new pin", async () => { + try { + let result = await vault.changePin(pin, null, bufView); + } catch (e) { + expect(e).toBe("Wrong pin type, format or length"); + } + }); + + test("changePin/invalid new pin", async () => { + try { + let result = await vault.changePin(pin, "afaef", bufView); + } catch (e) { + expect(e).toBe("Wrong pin type, format or length"); + } + }); + + test("changePin/empty encryption key", async () => { + try { + let result = await vault.changePin(pin, pin, null); + } catch (e) { + expect(e.message).toBe("Incorrect Encryption Key or vault string"); + } + }); + + test("changePin/invalid encryption key", async () => { + try { + let result = await vault.changePin(pin, pin, "efefe"); + } catch (e) { + expect(e.message).toBe("Incorrect Encryption Key or vault string"); + } + }); + test("changePin/all empty params", async () => { + try { + let result = await vault.changePin(null, null, null); + } catch (e) { + expect(e).toBe("Wrong pin type, format or length"); + } + }); +}); + +describe("getLogs", () => { + test("getLogs/valid", async () => { + let result = await vault.getLogs(); + expect(result).toHaveProperty("logs"); + }); +}); + +describe("getAccounts", () => { + test("getAccounts/valid", async () => { + await vault.restoreKeyringState(vaultAddress, pin, bufView); + let result = await vault.getAccounts(); + expect(result).toHaveProperty("response"); + }); +}); + +describe("signTransaction", () => { + test("signTransaction/valid", async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(polygonRpcUrl); const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), - maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), - data: '0x0', // method to generate data is provided below - nonce: nonce, - type: '0x2', - }; - try{ - - let result = await vault.signTransaction({},pin,polygonRpcUrl) - - } - catch(e){ - expect(e.message).toBe("Cannot read properties of undefined (reading 'toLowerCase')") - - } - - - - - }) - - test('signTransaction/invalid raw tx' , async()=>{ - let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" - const web3 = new Web3(polygonRpcUrl) - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), - maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), - data: '0x0', // method to generate data is provided below - nonce: nonce, - type: '0x2', - }; - try{ - - let result = await vault.signTransaction("evwf",pin,polygonRpcUrl) - - } - catch(e){ - expect(e.message).toBe("Cannot read properties of undefined (reading 'toLowerCase')") - - } - - - - - }) - - test('signTransaction/empty pin' , async()=>{ - let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" - const web3 = new Web3(polygonRpcUrl) - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), - maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), - data: '0x0', // method to generate data is provided below - nonce: nonce, - type: '0x2', - }; - - - let result = await vault.signTransaction("evwf",null,polygonRpcUrl) - expect(result.error).toBe('Wrong pin type, format or length') - - - - - }) - - test('signTransaction/invalid pin' , async()=>{ - let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" - const web3 = new Web3(polygonRpcUrl) - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), - maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), - data: '0x0', // method to generate data is provided below - nonce: nonce, - type: '0x2', - }; - - - let result = await vault.signTransaction("evwf","afewf",polygonRpcUrl) - expect(result.error).toBe('Wrong pin type, format or length') - - - - - - }) - test('signTransaction/incorrect pin' , async()=>{ - let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" - const web3 = new Web3(polygonRpcUrl) - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), - maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), - data: '0x0', // method to generate data is provided below - nonce: nonce, - type: '0x2', + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", }; - - - let result = await vault.signTransaction("evwf","112344",polygonRpcUrl) - expect(result.error).toBe('Incorrect pin') - - - - - - }) - - test('signTransaction/empty polygon rpc' , async()=>{ - let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" - const web3 = new Web3(polygonRpcUrl) - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), - maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), - data: '0x0', // method to generate data is provided below - nonce: nonce, - type: '0x2', + await vault.getActiveChains(); + try { + let result = await vault.signTransaction(rawTx, pin, polygonRpcUrl); + } catch (e) { + expect(e.message).toBe("Cannot read property 'salt' of undefined"); + } + }); + + test("signTransaction/empty raw tx", async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(polygonRpcUrl); + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", }; - - try{ - let result = await vault.signTransaction("evwf",pin,null) - } - catch(e){ - expect(e.message).toBe("CONNECTION ERROR: Couldn't connect to node http://localhost:8545.") - } - - - - - - - }) - - test('signTransaction/invalid polygon rpc' , async()=>{ - let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" - const web3 = new Web3(polygonRpcUrl) - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), - maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), - data: '0x0', // method to generate data is provided below - nonce: nonce, - type: '0x2', + try { + let result = await vault.signTransaction({}, pin, polygonRpcUrl); + } catch (e) { + expect(e.message).toBe( + "Cannot read properties of undefined (reading 'toLowerCase')" + ); + } + }); + + test("signTransaction/invalid raw tx", async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(polygonRpcUrl); + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", }; - let invalidRpc="efrwgrwdvfr" - try{ - let result = await vault.signTransaction("evwf",pin,invalidRpc) - } - catch(e){ - expect(e.message).toBe(`CONNECTION ERROR: Couldn't connect to node ${invalidRpc}.`) - } - - - - - - - }) - - test('signTransaction/all empty params' , async()=>{ - let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" - const web3 = new Web3(polygonRpcUrl) - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", 'ether')), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('42.25770', 'gwei'))), - maxFeePerGas: web3.utils.numberToHex(parseFloat(web3.utils.toWei('150.99', 'gwei'))), - data: '0x0', // method to generate data is provided below - nonce: nonce, - type: '0x2', + try { + let result = await vault.signTransaction("evwf", pin, polygonRpcUrl); + } catch (e) { + expect(e.message).toBe( + "Cannot read properties of undefined (reading 'toLowerCase')" + ); + } + }); + + test("signTransaction/empty pin", async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(polygonRpcUrl); + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", }; - let invalidRpc="efrwgrwdvfr" - - let result = await vault.signTransaction(null,null,null) - expect(result.error).toBe("Wrong pin type, format or length") - - - + let result = await vault.signTransaction("evwf", null, polygonRpcUrl); + expect(result.error).toBe("Wrong pin type, format or length"); + }); - - - - - }) -}) + test("signTransaction/invalid pin", async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(polygonRpcUrl); + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", + }; -describe('get Fees', () => { + let result = await vault.signTransaction("evwf", "afewf", polygonRpcUrl); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + test("signTransaction/incorrect pin", async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(polygonRpcUrl); + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - test('get Fees, validate', async () => { - vault.changeNetwork('polygon') - let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" - const web3 = new Web3(polygonRpcUrl) + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", + }; - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0", 'ether')), - chainID: 137, - }; + let result = await vault.signTransaction("evwf", "112344", polygonRpcUrl); + expect(result.error).toBe("Incorrect pin"); + }); - let result = await vault.getFees(rawTx,polygonRpcUrl) - expect(result.response).toHaveProperty('gasLimit') - expect(result.response).toHaveProperty('fees') - - }) + test("signTransaction/empty polygon rpc", async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(polygonRpcUrl); + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - test('get fees, invalid', async () => { - vault.changeNetwork('polygon') - let from="0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD" - const web3 = new Web3(polygonRpcUrl) + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", + }; - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0", 'ether')), - chainID: 137, - }; + try { + let result = await vault.signTransaction("evwf", pin, null); + } catch (e) { + expect(e.message).toBe( + "CONNECTION ERROR: Couldn't connect to node http://localhost:8545." + ); + } + }); + + test("signTransaction/invalid polygon rpc", async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(polygonRpcUrl); + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - try { - let result = await vault.getFees(rawTx,'abc') - console.log("result = ", result); - } - catch (e) { - console.log(e.message); - expect(e.message).toBe("CONNECTION ERROR: Couldn't connect to node abc.") - } - - }) -}) + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", + }; + let invalidRpc = "efrwgrwdvfr"; + try { + let result = await vault.signTransaction("evwf", pin, invalidRpc); + } catch (e) { + expect(e.message).toBe( + `CONNECTION ERROR: Couldn't connect to node ${invalidRpc}.` + ); + } + }); + + test("signTransaction/all empty params", async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(polygonRpcUrl); + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", + }; + let invalidRpc = "efrwgrwdvfr"; + let result = await vault.signTransaction(null, null, null); + expect(result.error).toBe("Wrong pin type, format or length"); + }); +}); +describe("get Fees", () => { + test("get Fees, validate", async () => { + vault.changeNetwork("polygon"); + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(polygonRpcUrl); + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0", "ether")), + chainID: 137, + }; + let result = await vault.getFees(rawTx, polygonRpcUrl); + expect(result.response).toHaveProperty("gasLimit"); + expect(result.response).toHaveProperty("fees"); + }); + test("get fees, invalid", async () => { + vault.changeNetwork("polygon"); + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(polygonRpcUrl); + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0", "ether")), + chainID: 137, + }; + try { + let result = await vault.getFees(rawTx, "abc"); + console.log("result = ", result); + } catch (e) { + console.log(e.message); + expect(e.message).toBe("CONNECTION ERROR: Couldn't connect to node abc."); + } + }); +}); From 27cfd74806cfc4aad0d6a3b079be981f71f898bf Mon Sep 17 00:00:00 2001 From: Husienvora Date: Fri, 6 Sep 2024 12:18:39 +0530 Subject: [PATCH 92/98] Update chain intialization and controller imports --- package-lock.json | 206 ++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + src/chains/index.js | 89 ++++++++++--------- 3 files changed, 257 insertions(+), 39 deletions(-) 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; + // }, }; From 09aed230b7860e9bcbc3caf1a95ac0935cc4e9de Mon Sep 17 00:00:00 2001 From: Husienvora Date: Fri, 6 Sep 2024 12:39:34 +0530 Subject: [PATCH 93/98] custom networks on the chain intialization side --- src/chains/index.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/chains/index.js b/src/chains/index.js index ba2bccf..8ac2dc2 100644 --- a/src/chains/index.js +++ b/src/chains/index.js @@ -49,14 +49,14 @@ module.exports = { solana, 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 + 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; - // }, + evmChainSymbols[chainName] = chainInfo.symbol; + }, }; From a3ecbf61f4531af70c5c1b5543dbc8c51b1a5ca2 Mon Sep 17 00:00:00 2001 From: Husienvora Date: Fri, 6 Sep 2024 12:46:55 +0530 Subject: [PATCH 94/98] Update intialize keyring controller method,for new evm controller --- src/lib/vault.js | 457 +++++++++++++++++++++++++++++------------------ 1 file changed, 285 insertions(+), 172 deletions(-) diff --git a/src/lib/vault.js b/src/lib/vault.js index 8ab213e..bfe54be 100644 --- a/src/lib/vault.js +++ b/src/lib/vault.js @@ -1,205 +1,318 @@ -const CryptoJS = require('crypto-js'); -const { KeyringController } = require('@getsafle/vault-eth-controller'); -const BitcoinKeyringController= require('@getsafle/vault-bitcoin-controller').KeyringController ; -const StacksKeyringController = require('@getsafle/vault-stacks-controller').KeyringController; -const SolanaKeyringController = require('@getsafle/vault-sol-controller').KeyringController; -const bip39 = require('bip39'); - -const helper = require('../utils/helper'); -const Keyring = require('./keyring'); -const Chains = require('../chains'); - -const ERROR_MESSAGE = require('../constants/responses'); +const CryptoJS = require("crypto-js"); +const { KeyringController } = require("@getsafle/vault-evm-controller"); +const BitcoinKeyringController = + require("@getsafle/vault-bitcoin-controller").KeyringController; +const StacksKeyringController = + require("@getsafle/vault-stacks-controller").KeyringController; +const SolanaKeyringController = + require("@getsafle/vault-sol-controller").KeyringController; +const bip39 = require("bip39"); + +const helper = require("../utils/helper"); +const Keyring = require("./keyring"); +const Chains = require("../chains"); + +const ERROR_MESSAGE = require("../constants/responses"); class Vault extends Keyring { - - constructor({vault, encryptionKey}) { - super(); - this.chain = 'ethereum'; - this.vault = vault; - this.initializeKeyringController(); - if (vault && encryptionKey) { - this.initializeDecryptedVault(vault, encryptionKey); - } + constructor({ vault, encryptionKey }) { + super(); + this.chain = "ethereum"; + this.vault = vault; + this.initializeKeyringController(); + if (vault && encryptionKey) { + this.initializeDecryptedVault(vault, encryptionKey); } - - initializeDecryptedVault(vault, encryptionKey) { - const { decryptedVault, error } = helper.validateEncryptionKey(vault, JSON.stringify(encryptionKey)); - if (error) { - return { error } - } - this.decryptedVault = decryptedVault; - + } + + initializeDecryptedVault(vault, encryptionKey) { + const { decryptedVault, error } = helper.validateEncryptionKey( + vault, + JSON.stringify(encryptionKey) + ); + if (error) { + return { error }; } - - initializeKeyringController() { - const keyringController = new KeyringController({ - encryptor: { - encrypt(pass, object) { - const ciphertext = CryptoJS.AES.encrypt(JSON.stringify(object), pass).toString(); - - return ciphertext; - }, - decrypt(pass, encryptedString) { - const bytes = CryptoJS.AES.decrypt(encryptedString, pass); - const decryptedData = JSON.parse(bytes.toString(CryptoJS.enc.Utf8)); - - return decryptedData; - }, + this.decryptedVault = decryptedVault; + } + + initializeKeyringController() { + const evmChainInfo = Chains.getEvmChainInfo(this.chain); + const keyringController = new KeyringController({ + txType: evmChainInfo.txType, + + encryptor: { + encrypt(pass, object) { + const ciphertext = CryptoJS.AES.encrypt( + JSON.stringify(object), + pass + ).toString(); + return ciphertext; }, - }); - - this.keyringInstance = keyringController; + decrypt(pass, encryptedString) { + const bytes = CryptoJS.AES.decrypt(encryptedString, pass); + const decryptedData = JSON.parse(bytes.toString(CryptoJS.enc.Utf8)); + return decryptedData; + }, + }, + }); + + this.keyringInstance = keyringController; + } + + initializeSupportedChainKeyringController(mnemonic) { + const keyringController = new BitcoinKeyringController({ + mnemonic: mnemonic, + }); + this["bitcoin"] = keyringController; + + const stacksKeyringController = new StacksKeyringController({ + mnemonic: mnemonic, + }); + this["stacks"] = stacksKeyringController; + + const solanaKeyringController = new SolanaKeyringController({ + mnemonic: mnemonic, + }); + this["solana"] = solanaKeyringController; + } + + async generateMnemonic(entropy) { + var mnemonic; + + if (entropy) { + mnemonic = bip39.entropyToMnemonic(entropy); + } else { + mnemonic = bip39.generateMnemonic(); } - initializeSupportedChainKeyringController(mnemonic) { - const keyringController = new BitcoinKeyringController({mnemonic:mnemonic}); - this["bitcoin"] = keyringController; + return mnemonic; + } - const stacksKeyringController = new StacksKeyringController({mnemonic:mnemonic}); - this["stacks"] = stacksKeyringController; - - const solanaKeyringController = new SolanaKeyringController({mnemonic:mnemonic}); - this["solana"] = solanaKeyringController; + async changeNetwork(chain) { + if ( + !Chains.evmChains.hasOwnProperty(chain) && + !Chains.nonEvmChains.hasOwnProperty(chain) + ) { + throw ERROR_MESSAGE.CHAIN_NOT_SUPPORTED; } - - async generateMnemonic(entropy) { - var mnemonic; - - if(entropy) { - mnemonic = bip39.entropyToMnemonic(entropy); - } else { - mnemonic = bip39.generateMnemonic(); - } - - return mnemonic; + this.chain = chain; + if (Chains.evmChains.hasOwnProperty(chain)) { + this.initializeKeyringController(); } - - async changeNetwork(chain) { - if (chain !== 'ethereum' && !Chains.evmChains.hasOwnProperty(chain) && !Chains.nonEvmChains.hasOwnProperty(chain)) { - throw ERROR_MESSAGE.CHAIN_NOT_SUPPORTED; - } - this.chain = chain; + } + + // async addNetwork(chainName, chainInfo) { + // try { + // Chains.addEvmChain(chainName, chainInfo); + // return { response: `Network ${chainName} added successfully` }; + // } catch (error) { + // return { error: error.message }; + // } + // } + + async generateVault(encryptionKey, pin, mnemonic) { + if ( + typeof pin != "string" || + pin.match(/^[0-9]+$/) === null || + pin < 0 || + pin.length != 6 + ) { + return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; } - async generateVault(encryptionKey, pin, mnemonic) { - - if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { - return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; - } - - if(!encryptionKey || pin === undefined || pin === null) { - return { error: ERROR_MESSAGE.ENTER_CREDS }; - } - - await this.keyringInstance.createNewVaultAndRestore(JSON.stringify(encryptionKey), mnemonic); - - const accounts = await this.keyringInstance.getAccounts(); - - const privData = await helper.generatePrivData(mnemonic, pin); - - const rawVault = { eth: { public: [ { address: accounts[0], isDeleted: false, isImported: false, label: 'EVM Wallet 1' } ], private: privData, numberOfAccounts: 1 }} - - this.initializeSupportedChainKeyringController(mnemonic); - - for (const chain of Object.keys(Chains.nonEvmChains)) { - let addedAcc - if (chain === 'stacks') { - addedAcc = (await this[chain].generateWallet()).address; - } else { - addedAcc = (await this[chain].addAccount()).address; - } - let label = `${Chains.nonEvmChains[chain]} Wallet 1` - rawVault[chain] = { public: [ { address: addedAcc, isDeleted: false, isImported: false, label: label } ], numberOfAccounts: 1 } - - } + if (!encryptionKey || pin === undefined || pin === null) { + return { error: ERROR_MESSAGE.ENTER_CREDS }; + } - const vault = await helper.cryptography(JSON.stringify(rawVault), JSON.stringify(encryptionKey), 'encryption'); + await this.keyringInstance.createNewVaultAndRestore( + JSON.stringify(encryptionKey), + mnemonic + ); + + const accounts = await this.keyringInstance.getAccounts(); + + const privData = await helper.generatePrivData(mnemonic, pin); + + const rawVault = { + eth: { + public: [ + { + address: accounts[0], + isDeleted: false, + isImported: false, + label: "EVM Wallet 1", + }, + ], + private: privData, + numberOfAccounts: 1, + }, + }; + + this.initializeSupportedChainKeyringController(mnemonic); + + for (const chain of Object.keys(Chains.nonEvmChains)) { + let addedAcc; + if (chain === "stacks") { + addedAcc = (await this[chain].generateWallet()).address; + } else { + addedAcc = (await this[chain].addAccount()).address; + } + let label = `${Chains.nonEvmChains[chain]} Wallet 1`; + rawVault[chain] = { + public: [ + { + address: addedAcc, + isDeleted: false, + isImported: false, + label: label, + }, + ], + numberOfAccounts: 1, + }; + } - this.initializeDecryptedVault(vault, encryptionKey); + const vault = await helper.cryptography( + JSON.stringify(rawVault), + JSON.stringify(encryptionKey), + "encryption" + ); - this.vault = vault; + this.initializeDecryptedVault(vault, encryptionKey); - this.logs.updateState({ - logs: [{ timestamp: Date.now(), action: 'vault-generation', vault: this.vault }], - }); + this.vault = vault; - return { response: vault }; + this.logs.updateState({ + logs: [ + { + timestamp: Date.now(), + action: "vault-generation", + vault: this.vault, + }, + ], + }); + + return { response: vault }; + } + + async recoverVault( + mnemonic, + encryptionKey, + pin, + unmarshalApiKey, + recoverMechanism = "transactions", + logs = {} + ) { + if ( + typeof pin != "string" || + pin.match(/^[0-9]+$/) === null || + pin < 0 || + pin.length != 6 + ) { + return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; } - async recoverVault(mnemonic, encryptionKey, pin, unmarshalApiKey, recoverMechanism = 'transactions', logs = {}) { - - if (typeof(pin) != 'string'|| pin.match(/^[0-9]+$/) === null || pin < 0 || pin.length !=6 ) { - return { error: ERROR_MESSAGE.INCORRECT_PIN_TYPE }; - } - - if (!encryptionKey) { - return { error : ERROR_MESSAGE.ENTER_CREDS } - } + if (!encryptionKey) { + return { error: ERROR_MESSAGE.ENTER_CREDS }; + } - if(recoverMechanism === 'transactions' && !unmarshalApiKey) { - return { error: ERROR_MESSAGE.INVALID_API_KEY }; - } + if (recoverMechanism === "transactions" && !unmarshalApiKey) { + return { error: ERROR_MESSAGE.INVALID_API_KEY }; + } - const vaultState = await this.keyringInstance.createNewVaultAndRestore(JSON.stringify(encryptionKey), mnemonic); + const vaultState = await this.keyringInstance.createNewVaultAndRestore( + JSON.stringify(encryptionKey), + mnemonic + ); + + let accountsArray = []; + if (recoverMechanism === "transactions") { + accountsArray = await helper.getAccountsFromTransactions( + vaultState.keyrings[0].accounts[0], + this.keyringInstance, + vaultState, + unmarshalApiKey + ); + } else if (recoverMechanism === "logs") { + accountsArray = await helper.getAccountsFromLogs( + "ethereum", + this.keyringInstance, + vaultState, + logs, + vaultState.keyrings[0].accounts[0] + ); + } - let accountsArray = []; - if(recoverMechanism === 'transactions') { - accountsArray = await helper.getAccountsFromTransactions(vaultState.keyrings[0].accounts[0], this.keyringInstance, vaultState, unmarshalApiKey) - } - else if (recoverMechanism === 'logs') { - accountsArray = await helper.getAccountsFromLogs('ethereum', this.keyringInstance, vaultState, logs, vaultState.keyrings[0].accounts[0]) + const privData = await helper.generatePrivData(mnemonic, pin); + + const numberOfAccounts = accountsArray.length; + + let rawVault = { + eth: { public: accountsArray, private: privData, numberOfAccounts }, + }; + + const nonEvmChainList = Object.keys(Chains.nonEvmChains); + + //generate other chain's keyring instance and get accounts from logs + let obj = {}; + for (let chain of nonEvmChainList) { + const keyringInstance = await helper.getCoinInstance( + chain.toLowerCase(), + mnemonic + ); + let address; + if (chain === "stacks") { + address = (await keyringInstance.generateWallet()).address; + } else { + address = (await keyringInstance.addAccount()).address; + } + + const accArray = await helper.getAccountsFromLogs( + chain, + keyringInstance, + vaultState, + logs, + address + ); + + if (chain === "stacks") { + for (let ele of accArray) { + ele.address = ele.address.toUpperCase(); } - - const privData = await helper.generatePrivData(mnemonic, pin); - - const numberOfAccounts = accountsArray.length; - - let rawVault = { eth: { public: accountsArray, private: privData, numberOfAccounts } } - - const nonEvmChainList = Object.keys(Chains.nonEvmChains); - - //generate other chain's keyring instance and get accounts from logs - let obj = {} - for ( let chain of nonEvmChainList) { - const keyringInstance = await helper.getCoinInstance(chain.toLowerCase(), mnemonic); - let address - if(chain === 'stacks') { - address = (await keyringInstance.generateWallet()).address; - } else { - address = (await keyringInstance.addAccount()).address; - } - - const accArray = await helper.getAccountsFromLogs(chain, keyringInstance, vaultState, logs, address); - - if(chain === 'stacks') { - for( let ele of accArray) { - ele.address = ele.address.toUpperCase(); - } - } - const numberOfAcc = accArray.length; - - rawVault[chain.toLowerCase()] = { public: accArray, numberOfAccounts: numberOfAcc } + } + const numberOfAcc = accArray.length; - } + rawVault[chain.toLowerCase()] = { + public: accArray, + numberOfAccounts: numberOfAcc, + }; + } - this.decryptedVault = rawVault + this.decryptedVault = rawVault; - const vault = await helper.cryptography(JSON.stringify(rawVault), JSON.stringify(encryptionKey), 'encryption'); + const vault = await helper.cryptography( + JSON.stringify(rawVault), + JSON.stringify(encryptionKey), + "encryption" + ); - this.vault = vault; + this.vault = vault; - this.logs.getState().logs.push({ timestamp: Date.now(), action: 'vault-recovery', vault: this.vault }); + this.logs.getState().logs.push({ + timestamp: Date.now(), + action: "vault-recovery", + vault: this.vault, + }); - return { response: vault }; - } + return { response: vault }; + } - getSupportedChains() { - const evmChains = Chains.evmChains; - const nonEvmChains = Chains.nonEvmChains; + getSupportedChains() { + const evmChains = Chains.evmChains; + const nonEvmChains = Chains.nonEvmChains; - return { response: { evmChains, nonEvmChains } }; - } + return { response: { evmChains, nonEvmChains } }; + } } -module.exports = Vault \ No newline at end of file +module.exports = Vault; From d2c285d90cdfdebfb70fc4514bf6ea7202cbd99a Mon Sep 17 00:00:00 2001 From: Husienvora Date: Fri, 6 Sep 2024 13:34:43 +0530 Subject: [PATCH 95/98] add network --- src/lib/vault.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lib/vault.js b/src/lib/vault.js index bfe54be..b469239 100644 --- a/src/lib/vault.js +++ b/src/lib/vault.js @@ -102,14 +102,14 @@ class Vault extends Keyring { } } - // async addNetwork(chainName, chainInfo) { - // try { - // Chains.addEvmChain(chainName, chainInfo); - // return { response: `Network ${chainName} added successfully` }; - // } catch (error) { - // return { error: error.message }; - // } - // } + async addNetwork(chainName, chainInfo) { + try { + Chains.addEvmChain(chainName, chainInfo); + return { response: `Network ${chainName} added successfully` }; + } catch (error) { + return { error: error.message }; + } + } async generateVault(encryptionKey, pin, mnemonic) { if ( From 609da622b82f6b645d4f32af4d25e5d0a5759348 Mon Sep 17 00:00:00 2001 From: Husienvora Date: Fri, 6 Sep 2024 19:29:19 +0530 Subject: [PATCH 96/98] updated tests --- src/lib/test/keyring.test.js | 674 +++++++++++++++++++++-------------- src/lib/vault.js | 3 + src/utils/helper.js | 6 +- 3 files changed, 405 insertions(+), 278 deletions(-) diff --git a/src/lib/test/keyring.test.js b/src/lib/test/keyring.test.js index 042f6b5..a22d17b 100644 --- a/src/lib/test/keyring.test.js +++ b/src/lib/test/keyring.test.js @@ -4,6 +4,84 @@ const { before } = require("lodash"); let KeyRing = require("../keyring"); let Vault = require("../vault"); const Web3 = require("web3"); +const NETWORKS = { + ethereum: { + URL: "https://eth-goerli.public.blastapi.io", + CHAIN_ID: 5, + }, + bsc: { + URL: "https://data-seed-prebsc-1-s1.binance.org:8545/", + CHAIN_ID: 97, + }, + polygon: { + URL: "https://polygon-amoy.blockpi.network/v1/rpc/public", + CHAIN_ID: 80001, + }, + optimism: { + URL: "https://optimism-goerli.public.blastapi.io", + CHAIN_ID: 420, + }, + arbitrum: { + URL: "https://sepolia-rollup.arbitrum.io/rpc", + CHAIN_ID: 421614, + }, + mantle: { + URL: "https://rpc.ankr.com/mantle_sepolia", + CHAIN_ID: 5001, + }, + velas: { + URL: "https://explorer.testnet.velas.com/rpc", + CHAIN_ID: 111, + }, + avalanche: { + URL: "https://api.avax-test.network/ext/bc/C/rpc", + CHAIN_ID: 43113, + }, + base: { + URL: "https://base-sepolia.blockpi.network/v1/rpc/public", + CHAIN_ID: 84532, + }, + zkEVM: { + URL: "https://endpoints.omniatech.io/v1/polygon-zkevm/testnet/public", + CHAIN_ID: 1442, + }, + bevm: { + URL: "https://testnet.bevm.io/", + CHAIN_ID: 1978, + }, + rootstock: { + URL: "https://public-node.testnet.rsk.co", + CHAIN_ID: 31, + }, +}; + +const chainConfigs = { + 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 }, +}; + +// Add the helper function +const getNetworkConfig = (chainName) => { + const network = NETWORKS[chainName]; + const chainConfig = chainConfigs[chainName]; + return { + url: network.URL, + chainId: network.CHAIN_ID, + symbol: chainConfig.symbol, + txType: chainConfig.txType, + }; +}; + const bufView = [ 48, 0, 236, 187, 187, 172, 177, 90, 255, 184, 9, 116, 142, 96, 197, 158, 87, 35, 26, 101, 187, 30, 116, 138, 50, 131, 166, 50, 51, 197, 198, 83, 238, 167, @@ -782,290 +860,332 @@ describe("getAccounts", () => { }); }); -describe("signTransaction", () => { - test("signTransaction/valid", async () => { - let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; - const web3 = new Web3(polygonRpcUrl); - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("42.25770", "gwei")) - ), - maxFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("150.99", "gwei")) - ), - data: "0x0", // method to generate data is provided below - nonce: nonce, - type: "0x2", - }; - await vault.getActiveChains(); - try { - let result = await vault.signTransaction(rawTx, pin, polygonRpcUrl); - } catch (e) { - expect(e.message).toBe("Cannot read property 'salt' of undefined"); - } - }); - - test("signTransaction/empty raw tx", async () => { - let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; - const web3 = new Web3(polygonRpcUrl); - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("42.25770", "gwei")) - ), - maxFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("150.99", "gwei")) - ), - data: "0x0", // method to generate data is provided below - nonce: nonce, - type: "0x2", - }; - try { - let result = await vault.signTransaction({}, pin, polygonRpcUrl); - } catch (e) { - expect(e.message).toBe( - "Cannot read properties of undefined (reading 'toLowerCase')" - ); - } - }); - - test("signTransaction/invalid raw tx", async () => { - let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; - const web3 = new Web3(polygonRpcUrl); - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("42.25770", "gwei")) - ), - maxFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("150.99", "gwei")) - ), - data: "0x0", // method to generate data is provided below - nonce: nonce, - type: "0x2", - }; - try { - let result = await vault.signTransaction("evwf", pin, polygonRpcUrl); - } catch (e) { - expect(e.message).toBe( - "Cannot read properties of undefined (reading 'toLowerCase')" - ); - } - }); - - test("signTransaction/empty pin", async () => { - let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; - const web3 = new Web3(polygonRpcUrl); - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("42.25770", "gwei")) - ), - maxFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("150.99", "gwei")) - ), - data: "0x0", // method to generate data is provided below - nonce: nonce, - type: "0x2", - }; - - let result = await vault.signTransaction("evwf", null, polygonRpcUrl); - expect(result.error).toBe("Wrong pin type, format or length"); +describe("Add new network", () => { + test("Add network", async () => { + await vault.addNetwork("TestChain", { symbol: "TST", txType: 0 }); + let chainInfo = await vault.getChainInfo("TestChain"); + console.log(chainInfo); + expect(chainInfo.symbol).toBe("TST"); }); +}); - test("signTransaction/invalid pin", async () => { - let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; - const web3 = new Web3(polygonRpcUrl); - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("42.25770", "gwei")) - ), - maxFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("150.99", "gwei")) - ), - data: "0x0", // method to generate data is provided below - nonce: nonce, - type: "0x2", - }; - - let result = await vault.signTransaction("evwf", "afewf", polygonRpcUrl); - expect(result.error).toBe("Wrong pin type, format or length"); - }); - test("signTransaction/incorrect pin", async () => { - let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; - const web3 = new Web3(polygonRpcUrl); - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("42.25770", "gwei")) - ), - maxFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("150.99", "gwei")) - ), - data: "0x0", // method to generate data is provided below - nonce: nonce, - type: "0x2", - }; - - let result = await vault.signTransaction("evwf", "112344", polygonRpcUrl); - expect(result.error).toBe("Incorrect pin"); - }); - - test("signTransaction/empty polygon rpc", async () => { - let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; - const web3 = new Web3(polygonRpcUrl); - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("42.25770", "gwei")) - ), - maxFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("150.99", "gwei")) - ), - data: "0x0", // method to generate data is provided below - nonce: nonce, - type: "0x2", - }; - - try { - let result = await vault.signTransaction("evwf", pin, null); - } catch (e) { - expect(e.message).toBe( - "CONNECTION ERROR: Couldn't connect to node http://localhost:8545." +describe("signTransaction", () => { + Object.keys(NETWORKS).forEach((chainName) => { + const networkConfig = getNetworkConfig(chainName); + vault.changeNetwork(chainName); + test(`signTransaction/valid for ${chainName}`, async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(networkConfig.url); + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", + }; + await vault.getActiveChains(); + try { + let result = await vault.signTransaction(rawTx, pin, networkConfig.url); + } catch (e) { + expect(e.message).toBe("Cannot read property 'salt' of undefined"); + } + }); + + test(`signTransaction/empty raw tx for ${chainName}`, async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(networkConfig.url); + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", + }; + try { + let result = await vault.signTransaction({}, pin, networkConfig.url); + } catch (e) { + expect(e.message).toBe( + "Cannot read properties of undefined (reading 'toLowerCase')" + ); + } + }); + + test(`signTransaction/invalid raw for ${chainName}`, async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(networkConfig.url); + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", + }; + try { + let result = await vault.signTransaction( + "evwf", + pin, + networkConfig.url + ); + } catch (e) { + expect(e.message).toBe( + "Cannot read properties of undefined (reading 'toLowerCase')" + ); + } + }); + + test(`signTransaction/empty pin for ${chainName}`, async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(networkConfig.url); + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", + }; + + let result = await vault.signTransaction("evwf", null, networkConfig.url); + expect(result.error).toBe("Wrong pin type, format or length"); + }); + + test(`signTransaction/invalid pin for ${chainName}`, async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(networkConfig.url); + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", + }; + + let result = await vault.signTransaction( + "evwf", + "afewf", + networkConfig.url ); - } - }); - - test("signTransaction/invalid polygon rpc", async () => { - let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; - const web3 = new Web3(polygonRpcUrl); - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("42.25770", "gwei")) - ), - maxFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("150.99", "gwei")) - ), - data: "0x0", // method to generate data is provided below - nonce: nonce, - type: "0x2", - }; - let invalidRpc = "efrwgrwdvfr"; - try { - let result = await vault.signTransaction("evwf", pin, invalidRpc); - } catch (e) { - expect(e.message).toBe( - `CONNECTION ERROR: Couldn't connect to node ${invalidRpc}.` + expect(result.error).toBe("Wrong pin type, format or length"); + }); + test(`signTransaction/incorrect pin for ${chainName}`, async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(networkConfig.url); + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", + }; + + let result = await vault.signTransaction( + "evwf", + "112344", + networkConfig.url ); - } - }); - - test("signTransaction/all empty params", async () => { - let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; - const web3 = new Web3(polygonRpcUrl); - const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), - gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below - maxPriorityFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("42.25770", "gwei")) - ), - maxFeePerGas: web3.utils.numberToHex( - parseFloat(web3.utils.toWei("150.99", "gwei")) - ), - data: "0x0", // method to generate data is provided below - nonce: nonce, - type: "0x2", - }; - let invalidRpc = "efrwgrwdvfr"; - - let result = await vault.signTransaction(null, null, null); - expect(result.error).toBe("Wrong pin type, format or length"); + expect(result.error).toBe("Incorrect pin"); + }); + + test(`signTransaction/empty polygon rpc for ${chainName}`, async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(networkConfig.url); + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", + }; + + try { + let result = await vault.signTransaction("evwf", pin, null); + } catch (e) { + expect(e.message).toBe( + "CONNECTION ERROR: Couldn't connect to node http://localhost:8545." + ); + } + }); + + test(`signTransaction/invalid polygon rpc for ${chainName}`, async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(networkConfig.url); + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", + }; + let invalidRpc = "efrwgrwdvfr"; + try { + let result = await vault.signTransaction("evwf", pin, invalidRpc); + } catch (e) { + expect(e.message).toBe( + `CONNECTION ERROR: Couldn't connect to node ${invalidRpc}.` + ); + } + }); + + test(`signTransaction/all empty params for ${chainName}`, async () => { + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(networkConfig.url); + const nonce = await web3.eth.getTransactionCount(from.toLowerCase()); + + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address + from: from.toLowerCase(), //sender address + value: web3.utils.numberToHex(web3.utils.toWei("0.001", "ether")), + gasLimit: web3.utils.numberToHex(21000), //method to compute gas provided below + maxPriorityFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("42.25770", "gwei")) + ), + maxFeePerGas: web3.utils.numberToHex( + parseFloat(web3.utils.toWei("150.99", "gwei")) + ), + data: "0x0", // method to generate data is provided below + nonce: nonce, + type: "0x2", + }; + let invalidRpc = "efrwgrwdvfr"; + + let result = await vault.signTransaction(null, null, null); + expect(result.error).toBe("Wrong pin type, format or length"); + }); }); }); describe("get Fees", () => { - test("get Fees, validate", async () => { - vault.changeNetwork("polygon"); - let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; - const web3 = new Web3(polygonRpcUrl); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0", "ether")), - chainID: 137, - }; - - let result = await vault.getFees(rawTx, polygonRpcUrl); - expect(result.response).toHaveProperty("gasLimit"); - expect(result.response).toHaveProperty("fees"); - }); - - test("get fees, invalid", async () => { - vault.changeNetwork("polygon"); - let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; - const web3 = new Web3(polygonRpcUrl); - - const rawTx = { - to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", //recepient address - from: from.toLowerCase(), //sender address - value: web3.utils.numberToHex(web3.utils.toWei("0", "ether")), - chainID: 137, - }; - - try { - let result = await vault.getFees(rawTx, "abc"); - console.log("result = ", result); - } catch (e) { - console.log(e.message); - expect(e.message).toBe("CONNECTION ERROR: Couldn't connect to node abc."); - } + Object.keys(NETWORKS).forEach((chainName) => { + test(`get Fees, validate for ${chainName}`, async () => { + const networkConfig = getNetworkConfig(chainName); + vault.changeNetwork(chainName); + + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(networkConfig.url); + + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", + from: from.toLowerCase(), + value: web3.utils.numberToHex(web3.utils.toWei("0", "ether")), + chainID: networkConfig.chainId, + }; + + let result = await vault.getFees(rawTx, networkConfig.url); + expect(result.response).toHaveProperty("gasLimit"); + expect(result.response).toHaveProperty("fees"); + + // Additional checks specific to the chain + if (networkConfig.txType === 2) { + expect(result.response.fees.fast).toHaveProperty("maxFeePerGas"); + expect(result.response.fees.fast).toHaveProperty( + "maxPriorityFeePerGas" + ); + } else { + expect(result.response.fees.fast).toHaveProperty("gasPrice"); + } + }); + + test(`get fees, invalid for ${chainName}`, async () => { + const networkConfig = getNetworkConfig(chainName); + vault.changeNetwork(chainName); + + let from = "0x80F850d6BFA120Bcc462df27cF94d7D23bd8B7FD"; + const web3 = new Web3(networkConfig.url); + + const rawTx = { + to: "0xacde0f575d8caf7bdba417326797c1a1d1b21f88", + from: from.toLowerCase(), + value: web3.utils.numberToHex(web3.utils.toWei("0", "ether")), + chainID: networkConfig.chainId, + }; + + try { + let result = await vault.getFees(rawTx, "invalid_url"); + fail("Should have thrown an error"); + } catch (e) { + expect(e.message).toBe( + "CONNECTION ERROR: Couldn't connect to node invalid_url." + ); + } + }); }); }); diff --git a/src/lib/vault.js b/src/lib/vault.js index b469239..1cf5238 100644 --- a/src/lib/vault.js +++ b/src/lib/vault.js @@ -101,6 +101,9 @@ class Vault extends Keyring { this.initializeKeyringController(); } } + async getChainInfo(chain) { + return Chains.getEvmChainInfo(chain); + } async addNetwork(chainName, chainInfo) { try { diff --git a/src/utils/helper.js b/src/utils/helper.js index f4f3e65..73c8c8b 100644 --- a/src/utils/helper.js +++ b/src/utils/helper.js @@ -273,7 +273,11 @@ async function getBSCTransactions(address, network, unmarshalApiKey) { async function getCoinInstance(chain, mnemonic) { if (Chains.evmChains.hasOwnProperty(chain)) { - const keyringInstance = new Chains[chain].KeyringController({}); + const evmChainInfo = Chains.getEvmChainInfo(chain); + + const keyringInstance = new Chains[chain].KeyringController({ + txType: evmChainInfo.txType, + }); return keyringInstance; } From eb292312458fc3c6650a79b6c33a1d363c9e1811 Mon Sep 17 00:00:00 2001 From: Husienvora Date: Tue, 17 Sep 2024 18:53:10 +0530 Subject: [PATCH 97/98] safle import wallet changes done --- src/lib/keyring.js | 37 +++++++++++++++++++++++++++++++++++- src/lib/test/keyring.test.js | 11 ++++++----- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/src/lib/keyring.js b/src/lib/keyring.js index 02e4697..c69ee68 100644 --- a/src/lib/keyring.js +++ b/src/lib/keyring.js @@ -982,7 +982,42 @@ class Keyring { }); if (isDuplicateAddress) { - return { error: ERROR_MESSAGE.ADDRESS_ALREADY_PRESENT }; + try { + Object.keys(this.decryptedVault) + .slice(0, -1) + .forEach((chain) => { + this.decryptedVault[chain]?.public?.forEach( + (account, index) => { + if (account.address === address && account.isDeleted) { + this.decryptedVault[chain].public[ + index + ].isDeleted = false; + } + } + ); + }); + + const vault = await helper.cryptography( + JSON.stringify(this.decryptedVault), + JSON.stringify(encryptionKey), + "encryption" + ); + + this.vault = vault; + + this.logs.getState().logs.push({ + timestamp: Date.now(), + action: "import-wallet", + vault: this.vault, + chain: this.chain, + address, + }); + + return { response: { vault, address } }; + } catch (error) { + console.error("Error processing duplicate address:", error); + throw error; // or handle it as appropriate for your application + } } } diff --git a/src/lib/test/keyring.test.js b/src/lib/test/keyring.test.js index a22d17b..d0cc836 100644 --- a/src/lib/test/keyring.test.js +++ b/src/lib/test/keyring.test.js @@ -14,7 +14,7 @@ const NETWORKS = { CHAIN_ID: 97, }, polygon: { - URL: "https://polygon-amoy.blockpi.network/v1/rpc/public", + URL: "https://polygon-amoy-bor-rpc.publicnode.com", CHAIN_ID: 80001, }, optimism: { @@ -26,7 +26,7 @@ const NETWORKS = { CHAIN_ID: 421614, }, mantle: { - URL: "https://rpc.ankr.com/mantle_sepolia", + URL: "https://rpc.mantle.xyz", CHAIN_ID: 5001, }, velas: { @@ -42,7 +42,7 @@ const NETWORKS = { CHAIN_ID: 84532, }, zkEVM: { - URL: "https://endpoints.omniatech.io/v1/polygon-zkevm/testnet/public", + URL: "https://polygon-zkevm.drpc.org", CHAIN_ID: 1442, }, bevm: { @@ -102,7 +102,7 @@ let impAccAddress; let chains; const ethUrl = "https://mainnet.infura.io/v3/6145d532688844c4b6db32574d90e19f"; -const polygonRpcUrl = "https://polygon-testnet.public.blastapi.io"; +const polygonRpcUrl = "https://polygon-amoy-bor-rpc.publicnode.com"; const bscRpcUrl = "https://rpc.ankr.com/bsc"; beforeAll(async () => { result = await vault.generateVault(bufView, pin, phrase); @@ -230,7 +230,7 @@ describe("importWallet", () => { test("importWallet/valid address exists already", async () => { let result = await vault.importWallet("0x" + privateKey, pin, bufView); - expect(result.error).toBe("This address is already present in the vault"); + expect(result.response).toHaveProperty("vault"); }); test("importWallet/empty private key", async () => { @@ -291,6 +291,7 @@ describe("getActiveChains", () => { describe("deleteAccount", () => { test("deleteAccount/valid generated acc", async () => { let result = await vault.deleteAccount(bufView, accAddress, pin); + expect(result).toHaveProperty("response"); }); From 76878f81c994214ace22d5b5e50b5ff6e84d1c00 Mon Sep 17 00:00:00 2001 From: Husienvora Date: Wed, 18 Sep 2024 18:01:59 +0530 Subject: [PATCH 98/98] fix test --- src/lib/test/keyring.test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/test/keyring.test.js b/src/lib/test/keyring.test.js index d0cc836..d783518 100644 --- a/src/lib/test/keyring.test.js +++ b/src/lib/test/keyring.test.js @@ -102,7 +102,7 @@ let impAccAddress; let chains; const ethUrl = "https://mainnet.infura.io/v3/6145d532688844c4b6db32574d90e19f"; -const polygonRpcUrl = "https://polygon-amoy-bor-rpc.publicnode.com"; +const polygonRpcUrl = "https://polygon.llamarpc.com"; const bscRpcUrl = "https://rpc.ankr.com/bsc"; beforeAll(async () => { result = await vault.generateVault(bufView, pin, phrase); @@ -668,12 +668,12 @@ describe("sign", () => { describe("validateMnemonic", () => { let signUpPhrase = - "ladder equip piano open silent pizza solid cannon name volcano fee valley"; + "join danger verb slide lava blossom garment school panel shaft damp ghost"; test("validateMnemonic/valid", async () => { let result = await vault.validateMnemonic( signUpPhrase, - "abhi141", - "testnet", + "polygonamoytest", + "mainnet", polygonRpcUrl ); expect(result.response).toBe(true);