diff --git a/package-lock.json b/package-lock.json index aa8b6e8c3..ff6fcf615 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,21 +32,21 @@ "husky": "^9.0.11", "lerna": "^8.1.5", "lint-staged": "^15.2.7", - "mocha": "^10.5.1", + "mocha": "^10.6.0", "prettier": "^3.3.2", "rimraf": "^5.0.7", "ts-node": "^10.9.2", "tsconfig-paths": "^4.2.0", "tsconfig-paths-webpack-plugin": "^4.1.0", "tslib": "^2.6.3", - "typescript": "^5.5.2" + "typescript": "^5.5.3" }, "engines": { "node": ">=18.x", "npm": ">=9.x" }, "optionalDependencies": { - "@nx/nx-linux-x64-gnu": "^19.3.1", + "@nx/nx-linux-x64-gnu": "^19.4.0", "@rollup/rollup-linux-x64-gnu": "^4.18.0" } }, @@ -3746,9 +3746,9 @@ } }, "node_modules/@nx/nx-linux-x64-gnu": { - "version": "19.3.1", - "resolved": "https://registry.npmjs.org/@nx/nx-linux-x64-gnu/-/nx-linux-x64-gnu-19.3.1.tgz", - "integrity": "sha512-cVmDMtolaqK7PziWxvjus1nCyj2wMNM+N0/4+rBEjG4v47gTtBxlZJoxK02jApdV+XELehsTjd0Z/xVfO4Rl1Q==", + "version": "19.4.0", + "resolved": "https://registry.npmjs.org/@nx/nx-linux-x64-gnu/-/nx-linux-x64-gnu-19.4.0.tgz", + "integrity": "sha512-7kBM0TCxO6IcwgGFCdkFPb2E+rkfpZZd97xtcQAfJi2mvzlQQtekIbM3J8uNcWveTbqDkVDJaJbpvrekloQfzw==", "cpu": [ "x64" ], @@ -4911,9 +4911,9 @@ } }, "node_modules/@solana/web3.js": { - "version": "1.93.2", - "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.93.2.tgz", - "integrity": "sha512-U8GlrvjfheJTFNavJHb2v/CnpzoqbGKaShLJGf1cELeFUlweUrfYXc9YFX0tw8Icb4ll48vDxt/zEPQOQ29+kw==", + "version": "1.94.0", + "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.94.0.tgz", + "integrity": "sha512-wMiBebzu5I2fTSz623uj6VXpWFhl0d7qJKqPFK2I4IBLTNUdv+bOeA4H7OBM7Gworv7sOvB3xibRql6l61MeqA==", "dependencies": { "@babel/runtime": "^7.24.7", "@noble/curves": "^1.4.0", @@ -5466,9 +5466,9 @@ "dev": true }, "node_modules/@toruslabs/base-controllers": { - "version": "5.9.0", - "resolved": "https://registry.npmjs.org/@toruslabs/base-controllers/-/base-controllers-5.9.0.tgz", - "integrity": "sha512-XEgYdHCt4Di+L9JUlZFsfQjA89Ah5PQNp1LHo4H5Vv6seS/e0bmBkqACf6nYQHwAld3zhhy9m+14xIeQpxx+qw==", + "version": "5.9.2", + "resolved": "https://registry.npmjs.org/@toruslabs/base-controllers/-/base-controllers-5.9.2.tgz", + "integrity": "sha512-LtyCxzcUkC7dyriGO23oYtgVVaAC8uPfx7OS2IeFw9wYC2Wms6plvCA3BxIpCTbLwxPzdd/6L7uLtpTe6FP+IQ==", "dependencies": { "@ethereumjs/util": "^9.0.3", "@metamask/rpc-errors": "^6.2.1", @@ -5480,7 +5480,6 @@ "bignumber.js": "^9.1.2", "bowser": "^2.11.0", "jwt-decode": "^4.0.0", - "lodash": "^4.17.21", "loglevel": "^1.9.1" }, "engines": { @@ -5627,16 +5626,16 @@ } }, "node_modules/@toruslabs/ethereum-controllers": { - "version": "5.9.1", - "resolved": "https://registry.npmjs.org/@toruslabs/ethereum-controllers/-/ethereum-controllers-5.9.1.tgz", - "integrity": "sha512-E40DTDfYDcCp52y57NOm6HSwo7ArwZhN90gfW6m3wm55v+/SOA5KcCcomGVXV8X3sey8+abScA6vtyVJmI0/Mg==", + "version": "5.9.2", + "resolved": "https://registry.npmjs.org/@toruslabs/ethereum-controllers/-/ethereum-controllers-5.9.2.tgz", + "integrity": "sha512-27fawj705yf+y2scTCDZ8lMJljvgGE7+UTNhlxZBt8lUVeho4CmqP/lSU9YI8LwiSHoHsanQjLDScC9npYvM+w==", "dependencies": { "@ethereumjs/common": "^4.3.0", "@ethereumjs/tx": "^5.3.0", "@ethereumjs/util": "^9.0.3", "@metamask/eth-sig-util": "^7.0.2", "@metamask/rpc-errors": "^6.2.1", - "@toruslabs/base-controllers": "^5.9.0", + "@toruslabs/base-controllers": "^5.9.2", "@toruslabs/http-helpers": "^6.1.1", "@toruslabs/openlogin-jrpc": "^8.1.1", "async-mutex": "^0.5.0", @@ -10837,9 +10836,9 @@ "dev": true }, "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" }, @@ -11201,9 +11200,9 @@ "dev": true }, "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==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", + "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", "dev": true, "engines": { "node": ">=0.3.1" @@ -19097,31 +19096,31 @@ } }, "node_modules/mocha": { - "version": "10.5.1", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.5.1.tgz", - "integrity": "sha512-eq5tEnaz2kM9ade8cuGJBMh5fBb9Ih/TB+ddlmPR+wLQmwLhUwa0ovqDlg7OTfKquW0BI7NUcNWX7DH8sC+3gw==", + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.6.0.tgz", + "integrity": "sha512-hxjt4+EEB0SA0ZDygSS015t65lJw/I2yRCS3Ae+SJ5FrbzrXgfYwJr96f0OvIXdj7h4lv/vLCrH3rkiuizFSvw==", "dev": true, "dependencies": { - "ansi-colors": "4.1.1", - "browser-stdout": "1.3.1", + "ansi-colors": "^4.1.3", + "browser-stdout": "^1.3.1", "chokidar": "^3.5.3", - "debug": "4.3.4", - "diff": "5.0.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.0.1", - "ms": "2.1.3", - "serialize-javascript": "6.0.0", - "strip-json-comments": "3.1.1", - "supports-color": "8.1.1", - "workerpool": "6.2.1", - "yargs": "16.2.0", - "yargs-parser": "20.2.4", - "yargs-unparser": "2.0.0" + "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", @@ -19131,15 +19130,6 @@ "node": ">= 14.0.0" } }, - "node_modules/mocha/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==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/mocha/node_modules/cliui": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", @@ -19173,9 +19163,9 @@ } }, "node_modules/mocha/node_modules/minimatch": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", - "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", "dev": true, "dependencies": { "brace-expansion": "^2.0.1" @@ -19224,9 +19214,9 @@ } }, "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==", + "version": "20.2.9", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", + "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", "dev": true, "engines": { "node": ">=10" @@ -20015,6 +20005,22 @@ } } }, + "node_modules/nx/node_modules/@nx/nx-linux-x64-gnu": { + "version": "19.3.1", + "resolved": "https://registry.npmjs.org/@nx/nx-linux-x64-gnu/-/nx-linux-x64-gnu-19.3.1.tgz", + "integrity": "sha512-cVmDMtolaqK7PziWxvjus1nCyj2wMNM+N0/4+rBEjG4v47gTtBxlZJoxK02jApdV+XELehsTjd0Z/xVfO4Rl1Q==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, "node_modules/nx/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -21152,9 +21158,9 @@ } }, "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==", "dev": true }, "node_modules/picomatch": { @@ -21359,9 +21365,9 @@ } }, "node_modules/postcss": { - "version": "8.4.38", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.38.tgz", - "integrity": "sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==", + "version": "8.4.39", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.39.tgz", + "integrity": "sha512-0vzE+lAiG7hZl1/9I8yzKLx3aR9Xbof3fBHKunvMfOCYAtMhrsnccJY2iTURb9EZd5+pLuiNV9/c/GZJOHsgIw==", "dev": true, "funding": [ { @@ -21379,7 +21385,7 @@ ], "dependencies": { "nanoid": "^3.3.7", - "picocolors": "^1.0.0", + "picocolors": "^1.0.1", "source-map-js": "^1.2.0" }, "engines": { @@ -22710,16 +22716,16 @@ "dev": true }, "node_modules/react-qrcode-logo": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/react-qrcode-logo/-/react-qrcode-logo-2.10.0.tgz", - "integrity": "sha512-Q1+jLtcyDl5rLR29YdkXVLzYk62p3+541x00HxURVBQhs6SqFyEZZVhvkU/VQ082ytXa3GdCmGWMLK5z0Vhe7g==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/react-qrcode-logo/-/react-qrcode-logo-3.0.0.tgz", + "integrity": "sha512-2+vZ3GNBdUpYxIKyt6SFZsDGXa0xniyUQ0wPI4O0hJTzRjttPIx1pPnH9IWQmp/4nDMoN47IBhi3Breu1KudYw==", "dependencies": { "lodash.isequal": "^4.5.0", - "qrcode-generator": "^1.4.1" + "qrcode-generator": "^1.4.4" }, "peerDependencies": { - "react": ">=16.4.1", - "react-dom": ">=16.4.1" + "react": ">=18.0.0", + "react-dom": ">=18.0.0" } }, "node_modules/read": { @@ -24918,9 +24924,9 @@ } }, "node_modules/serialize-javascript": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", - "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", + "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", "dev": true, "dependencies": { "randombytes": "^2.1.0" @@ -26502,15 +26508,6 @@ "url": "https://opencollective.com/webpack" } }, - "node_modules/terser-webpack-plugin/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==", - "dev": true, - "dependencies": { - "randombytes": "^2.1.0" - } - }, "node_modules/terser-webpack-plugin/node_modules/supports-color": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", @@ -27102,9 +27099,9 @@ "dev": true }, "node_modules/typescript": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.2.tgz", - "integrity": "sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==", + "version": "5.5.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.3.tgz", + "integrity": "sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -28347,9 +28344,9 @@ "dev": true }, "node_modules/workerpool": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", - "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==", + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz", + "integrity": "sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==", "dev": true }, "node_modules/wrap-ansi": { @@ -28798,7 +28795,7 @@ "version": "8.7.0", "license": "ISC", "dependencies": { - "@toruslabs/base-controllers": "^5.9.0", + "@toruslabs/base-controllers": "^5.9.2", "@web3auth/base": "^8.7.0" }, "engines": { @@ -28814,7 +28811,7 @@ "version": "8.7.0", "license": "ISC", "dependencies": { - "@toruslabs/base-controllers": "^5.9.0", + "@toruslabs/base-controllers": "^5.9.2", "@web3auth/base": "^8.7.0", "bs58": "^5.0.0" }, @@ -28975,7 +28972,7 @@ "bn.js": "^5.2.1" }, "devDependencies": { - "@solana/web3.js": "^1.93.2", + "@solana/web3.js": "^1.94.0", "@solflare-wallet/sdk": "^1.4.2" }, "engines": { @@ -29241,7 +29238,7 @@ }, "devDependencies": { "@metamask/rpc-errors": "^6.3.0", - "@toruslabs/ethereum-controllers": "^5.9.1", + "@toruslabs/ethereum-controllers": "^5.9.2", "@toruslabs/openlogin-utils": "^8.2.1" }, "engines": { @@ -29258,7 +29255,7 @@ "license": "ISC", "dependencies": { "@metamask/rpc-errors": "^6.3.0", - "@toruslabs/base-controllers": "^5.9.0", + "@toruslabs/base-controllers": "^5.9.2", "@toruslabs/openlogin-jrpc": "^8.1.1", "@web3auth/base": "^8.7.0", "json-rpc-random-id": "^1.0.1" @@ -29284,7 +29281,7 @@ "@ethereumjs/util": "^9.0.3", "@metamask/eth-sig-util": "^7.0.2", "@metamask/rpc-errors": "^6.3.0", - "@toruslabs/base-controllers": "^5.9.0", + "@toruslabs/base-controllers": "^5.9.2", "@toruslabs/openlogin-jrpc": "^8.1.1", "@web3auth/base": "^8.7.0", "@web3auth/base-provider": "^8.7.0", @@ -29308,7 +29305,7 @@ "@ethereumjs/util": "^9.0.3", "@metamask/eth-sig-util": "^7.0.2", "@metamask/rpc-errors": "^6.3.0", - "@toruslabs/base-controllers": "^5.9.0", + "@toruslabs/base-controllers": "^5.9.2", "@toruslabs/http-helpers": "^6.1.1", "@toruslabs/openlogin-jrpc": "^8.1.1", "@web3auth/base": "^8.7.0", @@ -29337,7 +29334,7 @@ "license": "ISC", "dependencies": { "@metamask/rpc-errors": "^6.3.0", - "@toruslabs/base-controllers": "^5.9.0", + "@toruslabs/base-controllers": "^5.9.2", "@toruslabs/openlogin-ed25519": "^8.1.0", "@toruslabs/openlogin-jrpc": "^8.1.1", "@toruslabs/tweetnacl-js": "^1.0.4", @@ -29348,7 +29345,7 @@ "json-rpc-random-id": "^1.0.1" }, "devDependencies": { - "@solana/web3.js": "^1.93.2", + "@solana/web3.js": "^1.94.0", "@solflare-wallet/sdk": "^1.4.2", "@types/bn.js": "^5.1.5", "@types/bs58": "^4.0.4", @@ -29369,7 +29366,7 @@ "license": "ISC", "dependencies": { "@metamask/rpc-errors": "^6.3.0", - "@toruslabs/base-controllers": "^5.9.0", + "@toruslabs/base-controllers": "^5.9.2", "@toruslabs/openlogin-jrpc": "^8.1.1", "@web3auth/base": "^8.7.0", "@web3auth/base-provider": "^8.7.0", @@ -29402,7 +29399,7 @@ "lodash.clonedeep": "^4.5.0", "lodash.merge": "^4.6.2", "react-i18next": "^14.1.2", - "react-qrcode-logo": "^2.10.0" + "react-qrcode-logo": "^3.0.0" }, "devDependencies": { "@babel/preset-react": "^7.24.7", @@ -29421,7 +29418,7 @@ "autoprefixer": "^10.4.19", "css-loader": "^7.1.2", "live-server": "^1.2.2", - "postcss": "^8.4.38", + "postcss": "^8.4.39", "postcss-loader": "^8.1.1", "postcss-prefix-selector": "^1.16.1", "react": "^18.3.1", diff --git a/package.json b/package.json index ba60835d4..caff10eb6 100644 --- a/package.json +++ b/package.json @@ -42,17 +42,17 @@ "husky": "^9.0.11", "lerna": "^8.1.5", "lint-staged": "^15.2.7", - "mocha": "^10.5.1", + "mocha": "^10.6.0", "prettier": "^3.3.2", "rimraf": "^5.0.7", "ts-node": "^10.9.2", "tsconfig-paths": "^4.2.0", "tsconfig-paths-webpack-plugin": "^4.1.0", "tslib": "^2.6.3", - "typescript": "^5.5.2" + "typescript": "^5.5.3" }, "optionalDependencies": { - "@nx/nx-linux-x64-gnu": "^19.3.1", + "@nx/nx-linux-x64-gnu": "^19.4.0", "@rollup/rollup-linux-x64-gnu": "^4.18.0" }, "repository": { diff --git a/packages/adapters/base-evm-adapter/package.json b/packages/adapters/base-evm-adapter/package.json index 102728765..9ded638a3 100644 --- a/packages/adapters/base-evm-adapter/package.json +++ b/packages/adapters/base-evm-adapter/package.json @@ -19,7 +19,7 @@ "pre-commit": "lint-staged --cwd ." }, "dependencies": { - "@toruslabs/base-controllers": "^5.9.0", + "@toruslabs/base-controllers": "^5.9.2", "@web3auth/base": "^8.7.0" }, "files": [ diff --git a/packages/adapters/base-solana-adapter/package.json b/packages/adapters/base-solana-adapter/package.json index 71d08cbb3..3fe958ab1 100644 --- a/packages/adapters/base-solana-adapter/package.json +++ b/packages/adapters/base-solana-adapter/package.json @@ -19,7 +19,7 @@ "pre-commit": "lint-staged --cwd ." }, "dependencies": { - "@toruslabs/base-controllers": "^5.9.0", + "@toruslabs/base-controllers": "^5.9.2", "@web3auth/base": "^8.7.0", "bs58": "^5.0.0" }, diff --git a/packages/adapters/coinbase-adapter/src/coinbaseAdapter.ts b/packages/adapters/coinbase-adapter/src/coinbaseAdapter.ts index 8fae62b6e..8fc7639ad 100644 --- a/packages/adapters/coinbase-adapter/src/coinbaseAdapter.ts +++ b/packages/adapters/coinbase-adapter/src/coinbaseAdapter.ts @@ -115,7 +115,7 @@ class CoinbaseAdapter extends BaseEvmAdapter { this.rehydrated = false; this.emit(ADAPTER_EVENTS.ERRORED, error); if (error instanceof Web3AuthError) throw error; - throw WalletLoginError.connectionError("Failed to login with coinbase wallet"); + throw WalletLoginError.connectionError("Failed to login with coinbase wallet", error); } } diff --git a/packages/adapters/default-evm-adapter/src/index.ts b/packages/adapters/default-evm-adapter/src/index.ts index 4a750e7bb..7128f0e1b 100644 --- a/packages/adapters/default-evm-adapter/src/index.ts +++ b/packages/adapters/default-evm-adapter/src/index.ts @@ -1,9 +1,10 @@ -import { CHAIN_NAMESPACES, CustomChainConfig, getChainConfig, IAdapter, IWeb3AuthCoreOptions } from "@web3auth/base"; +import { CHAIN_NAMESPACES, CustomChainConfig, getChainConfig, IAdapter, IWeb3AuthCoreOptions, WalletInitializationError } from "@web3auth/base"; export const getDefaultExternalAdapters = async (params: { options: IWeb3AuthCoreOptions }): Promise[]> => { const { options } = params; const { clientId, chainConfig, sessionTime, web3AuthNetwork, useCoreKitKey } = options; - if (!Object.values(CHAIN_NAMESPACES).includes(chainConfig.chainNamespace)) throw new Error(`Invalid chainNamespace: ${chainConfig.chainNamespace}`); + if (!Object.values(CHAIN_NAMESPACES).includes(chainConfig.chainNamespace)) + throw WalletInitializationError.invalidParams(`Invalid chainNamespace: ${chainConfig.chainNamespace}`); const finalChainConfig = { ...(getChainConfig(chainConfig.chainNamespace, chainConfig?.chainId) as CustomChainConfig), ...(chainConfig || {}), diff --git a/packages/adapters/default-solana-adapter/src/index.ts b/packages/adapters/default-solana-adapter/src/index.ts index 8e334fac9..d08b56fe1 100644 --- a/packages/adapters/default-solana-adapter/src/index.ts +++ b/packages/adapters/default-solana-adapter/src/index.ts @@ -1,9 +1,10 @@ -import { CHAIN_NAMESPACES, CustomChainConfig, getChainConfig, IAdapter, IWeb3AuthCoreOptions } from "@web3auth/base"; +import { CHAIN_NAMESPACES, CustomChainConfig, getChainConfig, IAdapter, IWeb3AuthCoreOptions, WalletInitializationError } from "@web3auth/base"; export const getDefaultExternalAdapters = async (params: { options: IWeb3AuthCoreOptions }): Promise[]> => { const { options } = params; const { clientId, chainConfig, sessionTime, web3AuthNetwork, useCoreKitKey } = options; - if (!Object.values(CHAIN_NAMESPACES).includes(chainConfig.chainNamespace)) throw new Error(`Invalid chainNamespace: ${chainConfig.chainNamespace}`); + if (!Object.values(CHAIN_NAMESPACES).includes(chainConfig.chainNamespace)) + throw WalletInitializationError.invalidParams(`Invalid chainNamespace: ${chainConfig.chainNamespace}`); const finalChainConfig = { ...(getChainConfig(chainConfig.chainNamespace, chainConfig?.chainId) as CustomChainConfig), ...(chainConfig || {}), diff --git a/packages/adapters/metamask-adapter/src/metamaskAdapter.ts b/packages/adapters/metamask-adapter/src/metamaskAdapter.ts index bf736cf76..4d065b6c7 100644 --- a/packages/adapters/metamask-adapter/src/metamaskAdapter.ts +++ b/packages/adapters/metamask-adapter/src/metamaskAdapter.ts @@ -125,7 +125,7 @@ class MetamaskAdapter extends BaseEvmAdapter { this.rehydrated = false; this.emit(ADAPTER_EVENTS.ERRORED, error); if (error instanceof Web3AuthError) throw error; - throw WalletLoginError.connectionError("Failed to login with metamask wallet"); + throw WalletLoginError.connectionError("Failed to login with metamask wallet", error); } } diff --git a/packages/adapters/openlogin-adapter/src/openloginAdapter.ts b/packages/adapters/openlogin-adapter/src/openloginAdapter.ts index 801cb6a6c..47cc27521 100644 --- a/packages/adapters/openlogin-adapter/src/openloginAdapter.ts +++ b/packages/adapters/openlogin-adapter/src/openloginAdapter.ts @@ -139,7 +139,7 @@ export class OpenloginAdapter extends BaseAdapter { } else if (error instanceof Web3AuthError) { throw error; } - throw WalletLoginError.connectionError("Failed to login with openlogin"); + throw WalletLoginError.connectionError("Failed to login with openlogin", error); } } @@ -153,7 +153,7 @@ export class OpenloginAdapter extends BaseAdapter { if (error instanceof Web3AuthError) { throw error; } - throw WalletLoginError.connectionError((error as Error).message || "Failed to enable MFA with openlogin"); + throw WalletLoginError.connectionError("Failed to enable MFA with openlogin", error); } } diff --git a/packages/adapters/phantom-adapter/src/phantomAdapter.ts b/packages/adapters/phantom-adapter/src/phantomAdapter.ts index 30193af7a..76f649e77 100644 --- a/packages/adapters/phantom-adapter/src/phantomAdapter.ts +++ b/packages/adapters/phantom-adapter/src/phantomAdapter.ts @@ -109,7 +109,7 @@ export class PhantomAdapter extends BaseSolanaAdapter { }); } catch (error: unknown) { if (error instanceof Web3AuthError) throw error; - throw WalletLoginError.connectionError((error as Error)?.message); + throw WalletLoginError.connectionError((error as Error)?.message, error); } finally { this._wallet._handleDisconnect = handleDisconnect; } diff --git a/packages/adapters/slope-adapter/src/slopeAdapter.ts b/packages/adapters/slope-adapter/src/slopeAdapter.ts index a32fe2891..da8a21da3 100644 --- a/packages/adapters/slope-adapter/src/slopeAdapter.ts +++ b/packages/adapters/slope-adapter/src/slopeAdapter.ts @@ -91,7 +91,7 @@ export class SlopeAdapter extends BaseSolanaAdapter { await this.connectWithProvider(this._wallet); } catch (error: unknown) { if (error instanceof Web3AuthError) throw error; - throw WalletLoginError.connectionError((error as Error)?.message); + throw WalletLoginError.connectionError((error as Error)?.message, error); } return this.provider; diff --git a/packages/adapters/solflare-adapter/package.json b/packages/adapters/solflare-adapter/package.json index dd236e7f7..bf30e7410 100644 --- a/packages/adapters/solflare-adapter/package.json +++ b/packages/adapters/solflare-adapter/package.json @@ -44,7 +44,7 @@ "bn.js": "^5.2.1" }, "devDependencies": { - "@solana/web3.js": "^1.93.2", + "@solana/web3.js": "^1.94.0", "@solflare-wallet/sdk": "^1.4.2" }, "lint-staged": { diff --git a/packages/adapters/solflare-adapter/src/solflareAdapter.ts b/packages/adapters/solflare-adapter/src/solflareAdapter.ts index 514c358ff..9101ac88f 100644 --- a/packages/adapters/solflare-adapter/src/solflareAdapter.ts +++ b/packages/adapters/solflare-adapter/src/solflareAdapter.ts @@ -96,7 +96,7 @@ export class SolflareAdapter extends BaseSolanaAdapter { await wallet.connect(); } catch (error: unknown) { if (error instanceof Web3AuthError) throw error; - throw WalletLoginError.connectionError((error as Error)?.message); + throw WalletLoginError.connectionError((error as Error)?.message, error); } } await this.connectWithProvider(wallet as SolflareWallet); diff --git a/packages/adapters/torus-evm-adapter/src/torusWalletAdapter.ts b/packages/adapters/torus-evm-adapter/src/torusWalletAdapter.ts index c372c81fb..7123ebb8b 100644 --- a/packages/adapters/torus-evm-adapter/src/torusWalletAdapter.ts +++ b/packages/adapters/torus-evm-adapter/src/torusWalletAdapter.ts @@ -144,7 +144,7 @@ export class TorusWalletAdapter extends BaseEvmAdapter { this.status = ADAPTER_STATUS.READY; this.rehydrated = false; this.emit(ADAPTER_STATUS.ERRORED, error); - throw error instanceof Web3AuthError ? error : WalletLoginError.connectionError("Failed to login with torus wallet"); + throw error instanceof Web3AuthError ? error : WalletLoginError.connectionError("Failed to login with torus wallet", error); } } diff --git a/packages/adapters/torus-solana-adapter/src/solanaWalletAdapter.ts b/packages/adapters/torus-solana-adapter/src/solanaWalletAdapter.ts index b8d65161f..bf94873aa 100644 --- a/packages/adapters/torus-solana-adapter/src/solanaWalletAdapter.ts +++ b/packages/adapters/torus-solana-adapter/src/solanaWalletAdapter.ts @@ -139,7 +139,7 @@ export class SolanaWalletAdapter extends BaseSolanaAdapter { this.rehydrated = false; this.emit(ADAPTER_EVENTS.ERRORED, error); if (error instanceof Web3AuthError) throw error; - throw WalletLoginError.connectionError("Failed to login with torus solana wallet"); + throw WalletLoginError.connectionError("Failed to login with torus solana wallet", error); } } diff --git a/packages/adapters/wallet-connect-v2-adapter/src/walletConnectV2Utils.ts b/packages/adapters/wallet-connect-v2-adapter/src/walletConnectV2Utils.ts index d90de6bae..acb9e07c1 100644 --- a/packages/adapters/wallet-connect-v2-adapter/src/walletConnectV2Utils.ts +++ b/packages/adapters/wallet-connect-v2-adapter/src/walletConnectV2Utils.ts @@ -3,6 +3,7 @@ import { providerErrors, rpcErrors } from "@metamask/rpc-errors"; import type { JRPCRequest } from "@toruslabs/openlogin-jrpc"; import type { ISignClient, SessionTypes } from "@walletconnect/types"; import { getAccountsFromNamespaces, parseAccountId } from "@walletconnect/utils"; +import { WalletLoginError } from "@web3auth/base"; import type { AddEthereumChainParameter, IProviderHandlers, MessageParams, TransactionParams, TypedMessageParams } from "@web3auth/ethereum-provider"; async function getLastActiveSession(signClient: ISignClient): Promise { @@ -43,7 +44,7 @@ export async function getAccounts(signClient: ISignClient): Promise { ), ]; } - throw new Error("Failed to get accounts"); + throw WalletLoginError.connectionError("Failed to get accounts"); } export function getProviderHandlers({ connector, chainId }: { connector: ISignClient; chainId: number }): IProviderHandlers { diff --git a/packages/adapters/wallet-connect-v2-adapter/src/walletConnectV2adapter.ts b/packages/adapters/wallet-connect-v2-adapter/src/walletConnectV2adapter.ts index 9650fa5b9..36202afba 100644 --- a/packages/adapters/wallet-connect-v2-adapter/src/walletConnectV2adapter.ts +++ b/packages/adapters/wallet-connect-v2-adapter/src/walletConnectV2adapter.ts @@ -146,7 +146,7 @@ class WalletConnectV2Adapter extends BaseEvmAdapter { const finalError = error instanceof Web3AuthError ? error - : WalletLoginError.connectionError(`Failed to login with wallet connect: ${(error as Error)?.message || ""}`); + : WalletLoginError.connectionError(`Failed to login with wallet connect: ${(error as Error)?.message || ""}`, error); throw finalError; } } diff --git a/packages/base/src/chain/config.ts b/packages/base/src/chain/config.ts index 5355c0505..7399dd877 100644 --- a/packages/base/src/chain/config.ts +++ b/packages/base/src/chain/config.ts @@ -1,3 +1,4 @@ +import { WalletInitializationError } from "../errors"; import { CHAIN_NAMESPACES, ChainNamespaceType, CustomChainConfig } from "./IChainInterface"; const getDefaultNetworkId = (chainNamespace: ChainNamespaceType): number => { if (chainNamespace === CHAIN_NAMESPACES.EIP155) { @@ -7,7 +8,7 @@ const getDefaultNetworkId = (chainNamespace: ChainNamespaceType): number => { } else if (chainNamespace === CHAIN_NAMESPACES.XRPL) { return 1; } - throw new Error(`Chain namespace ${chainNamespace} is not supported`); + throw WalletInitializationError.invalidParams(`Chain namespace ${chainNamespace} is not supported`); }; export const getEvmChainConfig = (chainId: number): CustomChainConfig | null => { diff --git a/packages/base/src/errors/index.ts b/packages/base/src/errors/index.ts index 2e6289933..3213382d5 100644 --- a/packages/base/src/errors/index.ts +++ b/packages/base/src/errors/index.ts @@ -4,6 +4,7 @@ import { CustomError } from "ts-custom-error"; export interface IWeb3AuthError extends CustomError { code: number; message: string; + cause?: unknown; toString(): string; } @@ -11,17 +12,39 @@ export type ErrorCodes = { [key: number]: string; }; +function serializeError(args: unknown[]): [Error, unknown[]] { + // Find first Error or create an "unknown" Error to keep stack trace. + const index = args.findIndex((arg) => arg instanceof Error); + const msgIndex = args.findIndex((arg) => typeof arg === "string"); + const apiErrorIdx = args.findIndex((arg) => arg && typeof arg === "object" && "status" in arg && "type" in arg); + let err: Error; + if (apiErrorIdx !== -1) { + const apiError = args[apiErrorIdx] as Response; + err = new Error(`${apiError.status} ${apiError.type.toString()} ${apiError.statusText}`); + } else if (index !== -1) { + err = args.splice(index, 1)[0] as Error; + } else if (msgIndex !== -1) { + err = new Error(args.splice(msgIndex, 1)[0] as string); + } else { + err = new Error("Unknown error"); + } + return [err, args]; +} + export abstract class Web3AuthError extends CustomError implements IWeb3AuthError { code: number; message: string; - public constructor(code: number, message?: string) { + cause?: unknown; + + public constructor(code: number, message?: string, cause?: unknown) { // takes care of stack and proto super(message); this.code = code; this.message = message || ""; + this.cause = cause; // Set name explicitly as minification can mangle class names Object.defineProperty(this, "name", { value: "Web3AuthError" }); } @@ -31,6 +54,7 @@ export abstract class Web3AuthError extends CustomError implements IWeb3AuthErro name: this.name, code: this.code, message: this.message, + cause: serializeError([this.cause]), }; } @@ -56,65 +80,65 @@ export class WalletInitializationError extends Web3AuthError { 5013: "Invalid network provided", }; - public constructor(code: number, message?: string) { + public constructor(code: number, message?: string, cause?: unknown) { // takes care of stack and proto - super(code, message); + super(code, message, cause); // Set name explicitly as minification can mangle class names Object.defineProperty(this, "name", { value: "WalletInitializationError" }); } - public static fromCode(code: number, extraMessage = ""): IWeb3AuthError { - return new WalletInitializationError(code, `${WalletInitializationError.messages[code]}, ${extraMessage}`); + public static fromCode(code: number, extraMessage = "", cause?: unknown): IWeb3AuthError { + return new WalletInitializationError(code, `${WalletInitializationError.messages[code]}, ${extraMessage}`, cause); } // Custom methods - public static notFound(extraMessage = ""): IWeb3AuthError { - return WalletInitializationError.fromCode(5001, extraMessage); + public static notFound(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletInitializationError.fromCode(5001, extraMessage, cause); } - public static notInstalled(extraMessage = ""): IWeb3AuthError { - return WalletInitializationError.fromCode(5002, extraMessage); + public static notInstalled(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletInitializationError.fromCode(5002, extraMessage, cause); } - public static notReady(extraMessage = ""): IWeb3AuthError { - return WalletInitializationError.fromCode(5003, extraMessage); + public static notReady(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletInitializationError.fromCode(5003, extraMessage, cause); } - public static windowBlocked(extraMessage = ""): IWeb3AuthError { - return WalletInitializationError.fromCode(5004, extraMessage); + public static windowBlocked(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletInitializationError.fromCode(5004, extraMessage, cause); } - public static windowClosed(extraMessage = ""): IWeb3AuthError { - return WalletInitializationError.fromCode(5005, extraMessage); + public static windowClosed(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletInitializationError.fromCode(5005, extraMessage, cause); } - public static incompatibleChainNameSpace(extraMessage = ""): IWeb3AuthError { - return WalletInitializationError.fromCode(5006, extraMessage); + public static incompatibleChainNameSpace(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletInitializationError.fromCode(5006, extraMessage, cause); } - public static duplicateAdapterError(extraMessage = ""): IWeb3AuthError { - return WalletInitializationError.fromCode(5007, extraMessage); + public static duplicateAdapterError(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletInitializationError.fromCode(5007, extraMessage, cause); } - public static invalidProviderConfigError(extraMessage = ""): IWeb3AuthError { - return WalletInitializationError.fromCode(5008, extraMessage); + public static invalidProviderConfigError(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletInitializationError.fromCode(5008, extraMessage, cause); } - public static providerNotReadyError(extraMessage = ""): IWeb3AuthError { - return WalletInitializationError.fromCode(5009, extraMessage); + public static providerNotReadyError(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletInitializationError.fromCode(5009, extraMessage, cause); } - public static rpcConnectionError(extraMessage = ""): IWeb3AuthError { - return WalletInitializationError.fromCode(5010, extraMessage); + public static rpcConnectionError(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletInitializationError.fromCode(5010, extraMessage, cause); } - public static invalidParams(extraMessage = ""): IWeb3AuthError { - return WalletInitializationError.fromCode(5011, extraMessage); + public static invalidParams(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletInitializationError.fromCode(5011, extraMessage, cause); } - public static invalidNetwork(extraMessage = ""): IWeb3AuthError { - return WalletInitializationError.fromCode(5013, extraMessage); + public static invalidNetwork(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletInitializationError.fromCode(5013, extraMessage, cause); } } @@ -136,52 +160,52 @@ export class WalletLoginError extends Web3AuthError { 5119: "User not logged in.", }; - public constructor(code: number, message?: string) { + public constructor(code: number, message?: string, cause?: unknown) { // takes care of stack and proto - super(code, message); + super(code, message, cause); // Set name explicitly as minification can mangle class names Object.defineProperty(this, "name", { value: "WalletLoginError" }); } - public static fromCode(code: number, extraMessage = ""): IWeb3AuthError { - return new WalletLoginError(code, `${WalletLoginError.messages[code]}. ${extraMessage}`); + public static fromCode(code: number, extraMessage = "", cause?: unknown): IWeb3AuthError { + return new WalletLoginError(code, `${WalletLoginError.messages[code]}. ${extraMessage}`, cause); } - public static connectionError(extraMessage = ""): IWeb3AuthError { - return WalletLoginError.fromCode(5111, extraMessage); + public static connectionError(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletLoginError.fromCode(5111, extraMessage, cause); } - public static disconnectionError(extraMessage = ""): IWeb3AuthError { - return WalletLoginError.fromCode(5112, extraMessage); + public static disconnectionError(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletLoginError.fromCode(5112, extraMessage, cause); } - public static notConnectedError(extraMessage = ""): IWeb3AuthError { - return WalletLoginError.fromCode(5113, extraMessage); + public static notConnectedError(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletLoginError.fromCode(5113, extraMessage, cause); } - public static popupClosed(extraMessage = ""): IWeb3AuthError { - return WalletLoginError.fromCode(5114, extraMessage); + public static popupClosed(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletLoginError.fromCode(5114, extraMessage, cause); } - public static mfaEnabled(extraMessage = ""): IWeb3AuthError { - return WalletLoginError.fromCode(5115, extraMessage); + public static mfaEnabled(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletLoginError.fromCode(5115, extraMessage, cause); } - public static chainConfigNotAdded(extraMessage = ""): IWeb3AuthError { - return WalletLoginError.fromCode(5116, extraMessage); + public static chainConfigNotAdded(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletLoginError.fromCode(5116, extraMessage, cause); } - public static unsupportedOperation(extraMessage = ""): IWeb3AuthError { - return WalletLoginError.fromCode(5117, extraMessage); + public static unsupportedOperation(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletLoginError.fromCode(5117, extraMessage, cause); } - public static coreKitKeyNotFound(extraMessage = ""): IWeb3AuthError { - return WalletLoginError.fromCode(5118, extraMessage); + public static coreKitKeyNotFound(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletLoginError.fromCode(5118, extraMessage, cause); } - public static userNotLoggedIn(extraMessage = ""): IWeb3AuthError { - return WalletLoginError.fromCode(5119, extraMessage); + public static userNotLoggedIn(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletLoginError.fromCode(5119, extraMessage, cause); } } @@ -192,29 +216,29 @@ export class WalletOperationsError extends Web3AuthError { 5202: "This operation is not allowed", }; - public constructor(code: number, message?: string) { + public constructor(code: number, message?: string, cause?: unknown) { // takes care of stack and proto - super(code, message); + super(code, message, cause); // Set name explicitly as minification can mangle class names Object.defineProperty(this, "name", { value: "WalletOperationsError" }); } - public static fromCode(code: number, extraMessage = ""): IWeb3AuthError { - return new WalletOperationsError(code, `${WalletOperationsError.messages[code]}, ${extraMessage}`); + public static fromCode(code: number, extraMessage = "", cause?: unknown): IWeb3AuthError { + return new WalletOperationsError(code, `${WalletOperationsError.messages[code]}, ${extraMessage}`, cause); } // Custom methods - public static chainIDNotAllowed(extraMessage = ""): IWeb3AuthError { - return WalletOperationsError.fromCode(5201, extraMessage); + public static chainIDNotAllowed(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletOperationsError.fromCode(5201, extraMessage, cause); } - public static operationNotAllowed(extraMessage = ""): IWeb3AuthError { - return WalletOperationsError.fromCode(5202, extraMessage); + public static operationNotAllowed(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletOperationsError.fromCode(5202, extraMessage, cause); } - public static chainNamespaceNotAllowed(extraMessage = ""): IWeb3AuthError { - return WalletOperationsError.fromCode(5203, extraMessage); + public static chainNamespaceNotAllowed(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletOperationsError.fromCode(5203, extraMessage, cause); } } @@ -226,28 +250,28 @@ export class WalletProviderError extends Web3AuthError { 5303: "'args.params' must be an object or array if provided.", }; - public constructor(code: number, message?: string) { + public constructor(code: number, message?: string, cause?: unknown) { // takes care of stack and proto - super(code, message); + super(code, message, cause); // Set name explicitly as minification can mangle class names Object.defineProperty(this, "name", { value: "WalletProviderError" }); } - public static fromCode(code: number, extraMessage = ""): IWeb3AuthError { - return new WalletOperationsError(code, `${WalletProviderError.messages[code]}, ${extraMessage}`); + public static fromCode(code: number, extraMessage = "", cause?: unknown): IWeb3AuthError { + return new WalletOperationsError(code, `${WalletProviderError.messages[code]}, ${extraMessage}`, cause); } // Custom methods - public static invalidRequestArgs(extraMessage = ""): IWeb3AuthError { - return WalletOperationsError.fromCode(5301, extraMessage); + public static invalidRequestArgs(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletOperationsError.fromCode(5301, extraMessage, cause); } - public static invalidRequestMethod(extraMessage = ""): IWeb3AuthError { - return WalletOperationsError.fromCode(5302, extraMessage); + public static invalidRequestMethod(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletOperationsError.fromCode(5302, extraMessage, cause); } - public static invalidRequestParams(extraMessage = ""): IWeb3AuthError { - return WalletOperationsError.fromCode(5303, extraMessage); + public static invalidRequestParams(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletOperationsError.fromCode(5303, extraMessage, cause); } } diff --git a/packages/base/src/plugin/errors.ts b/packages/base/src/plugin/errors.ts index 4486f9703..edc226567 100644 --- a/packages/base/src/plugin/errors.ts +++ b/packages/base/src/plugin/errors.ts @@ -10,53 +10,63 @@ export class WalletServicesPluginError extends Web3AuthError { 5216: "Plugin is already initialized", 5218: "Unsupported chain namespace.", 5219: "Plugin network different than web3auth instance network.", + 5221: "Web3Auth is not initialized", + 5222: "Invalid session inside wallet services. Please report this issue.", }; - public constructor(code: number, message?: string) { + public constructor(code: number, message?: string, cause?: unknown) { // takes care of stack and proto - super(code, message); + super(code, message, cause); // Set name explicitly as minification can mangle class names Object.defineProperty(this, "name", { value: "WalletServicesPluginError" }); } - public static fromCode(code: number, extraMessage = ""): IWeb3AuthError { - return new WalletServicesPluginError(code, `${WalletServicesPluginError.messages[code]}${extraMessage}`); + public static fromCode(code: number, extraMessage = "", cause?: unknown): IWeb3AuthError { + return new WalletServicesPluginError(code, `${WalletServicesPluginError.messages[code]}${extraMessage}`, cause); } - public static notInitialized(extraMessage = ""): IWeb3AuthError { - return WalletServicesPluginError.fromCode(5210, extraMessage); + public static notInitialized(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletServicesPluginError.fromCode(5210, extraMessage, cause); } - public static unsupportedAdapter(extraMessage = ""): IWeb3AuthError { - return WalletServicesPluginError.fromCode(5211, extraMessage); + public static unsupportedAdapter(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletServicesPluginError.fromCode(5211, extraMessage, cause); } - public static providerRequired(extraMessage = ""): IWeb3AuthError { - return WalletServicesPluginError.fromCode(5212, extraMessage); + public static providerRequired(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletServicesPluginError.fromCode(5212, extraMessage, cause); } - public static web3authRequired(extraMessage = ""): IWeb3AuthError { - return WalletServicesPluginError.fromCode(5213, extraMessage); + public static web3authRequired(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletServicesPluginError.fromCode(5213, extraMessage, cause); } - public static web3AuthNotConnected(extraMessage = ""): IWeb3AuthError { - return WalletServicesPluginError.fromCode(5214, extraMessage); + public static web3AuthNotConnected(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletServicesPluginError.fromCode(5214, extraMessage, cause); } - public static alreadyInitialized(extraMessage = ""): IWeb3AuthError { - return WalletServicesPluginError.fromCode(5216, extraMessage); + public static alreadyInitialized(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletServicesPluginError.fromCode(5216, extraMessage, cause); } - public static unsupportedChainNamespace(extraMessage = ""): IWeb3AuthError { - return WalletServicesPluginError.fromCode(5218, extraMessage); + public static unsupportedChainNamespace(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletServicesPluginError.fromCode(5218, extraMessage, cause); } - public static differentWeb3AuthNetwork(extraMessage = ""): IWeb3AuthError { - return WalletServicesPluginError.fromCode(5219, extraMessage); + public static differentWeb3AuthNetwork(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletServicesPluginError.fromCode(5219, extraMessage, cause); } - public static invalidParams(extraMessage = ""): IWeb3AuthError { - return WalletServicesPluginError.fromCode(5220, extraMessage); + public static invalidParams(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletServicesPluginError.fromCode(5220, extraMessage, cause); + } + + public static web3authNotInitialized(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletServicesPluginError.fromCode(5221, extraMessage, cause); + } + + public static invalidSession(extraMessage = "", cause?: unknown): IWeb3AuthError { + return WalletServicesPluginError.fromCode(5222, extraMessage, cause); } } diff --git a/packages/base/src/utils.ts b/packages/base/src/utils.ts index 95fa15c07..7e3ba9278 100644 --- a/packages/base/src/utils.ts +++ b/packages/base/src/utils.ts @@ -58,14 +58,10 @@ export const signerHost = (web3AuthNetwork?: OPENLOGIN_NETWORK_TYPE): string => }; export const fetchProjectConfig = async (clientId: string, web3AuthNetwork: OPENLOGIN_NETWORK_TYPE): Promise => { - try { - const url = new URL(`${signerHost(web3AuthNetwork)}/api/configuration`); - url.searchParams.append("project_id", clientId); - url.searchParams.append("network", web3AuthNetwork); - url.searchParams.append("whitelist", "true"); - const res = await get(url.href); - return res; - } catch (e) { - throw new Error(`Failed to fetch project config: ${(e as Error).message}`); - } + const url = new URL(`${signerHost(web3AuthNetwork)}/api/configuration`); + url.searchParams.append("project_id", clientId); + url.searchParams.append("network", web3AuthNetwork); + url.searchParams.append("whitelist", "true"); + const res = await get(url.href); + return res; }; diff --git a/packages/modal/src/modalManager.ts b/packages/modal/src/modalManager.ts index 87083a2a5..5863f7354 100644 --- a/packages/modal/src/modalManager.ts +++ b/packages/modal/src/modalManager.ts @@ -67,7 +67,7 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal { projectConfig = await fetchProjectConfig(this.options.clientId, this.options.web3AuthNetwork); } catch (e) { log.error("Failed to fetch project configurations", e); - throw WalletInitializationError.notReady("failed to fetch project configurations"); + throw WalletInitializationError.notReady("failed to fetch project configurations", e); } const { whitelabel } = projectConfig; @@ -323,7 +323,7 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal { } public async connect(): Promise { - if (!this.loginModal) throw new Error("Login modal is not initialized"); + if (!this.loginModal) throw WalletInitializationError.notReady("Login modal is not initialized"); // if already connected return provider if (this.connectedAdapterName && this.status === ADAPTER_STATUS.CONNECTED && this.provider) return this.provider; this.loginModal.open(); diff --git a/packages/no-modal/src/noModal.ts b/packages/no-modal/src/noModal.ts index 483b00c89..3287e68d3 100644 --- a/packages/no-modal/src/noModal.ts +++ b/packages/no-modal/src/noModal.ts @@ -98,7 +98,7 @@ export class Web3AuthNoModal extends SafeEventEmitter implements IWeb3Auth { projectConfig = await fetchProjectConfig(this.coreOptions.clientId, this.coreOptions.web3AuthNetwork); } catch (e) { log.error("Failed to fetch project configurations", e); - throw WalletInitializationError.notReady("failed to fetch project configurations"); + throw WalletInitializationError.notReady("failed to fetch project configurations", e); } const initPromises = Object.keys(this.walletAdapters).map(async (adapterName) => { @@ -277,9 +277,9 @@ export class Web3AuthNoModal extends SafeEventEmitter implements IWeb3Auth { } public addPlugin(plugin: IPlugin): IWeb3Auth { - if (this.plugins[plugin.name]) throw new Error(`Plugin ${plugin.name} already exist`); + if (this.plugins[plugin.name]) throw WalletInitializationError.duplicateAdapterError(`Plugin ${plugin.name} already exist`); if (plugin.pluginNamespace !== PLUGIN_NAMESPACES.MULTICHAIN && plugin.pluginNamespace !== this.coreOptions.chainConfig.chainNamespace) - throw new Error( + throw WalletInitializationError.incompatibleChainNameSpace( `This plugin belongs to ${plugin.pluginNamespace} namespace which is incompatible with currently used namespace: ${this.coreOptions.chainConfig.chainNamespace}` ); diff --git a/packages/plugins/solana-wallet-connector-plugin/src/errors.ts b/packages/plugins/solana-wallet-connector-plugin/src/errors.ts deleted file mode 100644 index 6ed561e4e..000000000 --- a/packages/plugins/solana-wallet-connector-plugin/src/errors.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { ErrorCodes, IWeb3AuthError, Web3AuthError } from "@web3auth/base"; - -export class SolanaWalletPluginError extends Web3AuthError { - protected static messages: ErrorCodes = { - 5210: "Torus Wallet Plugin is not initialized", - 5211: "Web3Auth is connected to unsupported adapter. Torus wallet connector plugin requires web3auth connected to openlogin adapter.", - 5212: "Provider is required..", - 5213: "Web3Auth instance is required while initialization.", - 5214: "Web3Auth is not connected.", - 5215: "UserInfo is required.", - 5216: "Plugin is already initialized", - 5217: "Torus wallet instance is not set.", - 5222: "Invalid session inside wallet services. Please report this issue.", - }; - - public constructor(code: number, message?: string) { - // takes care of stack and proto - super(code, message); - - // Set name explicitly as minification can mangle class names - Object.defineProperty(this, "name", { value: "SolanaWalletPluginError" }); - } - - public static fromCode(code: number, extraMessage = ""): IWeb3AuthError { - return new SolanaWalletPluginError(code, `${SolanaWalletPluginError.messages[code]}${extraMessage}`); - } - - public static notInitialized(extraMessage = ""): IWeb3AuthError { - return SolanaWalletPluginError.fromCode(5210, extraMessage); - } - - public static unsupportedAdapter(extraMessage = ""): IWeb3AuthError { - return SolanaWalletPluginError.fromCode(5211, extraMessage); - } - - public static providerRequired(extraMessage = ""): IWeb3AuthError { - return SolanaWalletPluginError.fromCode(5212, extraMessage); - } - - public static web3authRequired(extraMessage = ""): IWeb3AuthError { - return SolanaWalletPluginError.fromCode(5213, extraMessage); - } - - public static web3AuthNotConnected(extraMessage = ""): IWeb3AuthError { - return SolanaWalletPluginError.fromCode(5214, extraMessage); - } - - public static userInfoRequired(extraMessage = ""): IWeb3AuthError { - return SolanaWalletPluginError.fromCode(5215, extraMessage); - } - - public static alreadyInitialized(extraMessage = ""): IWeb3AuthError { - return SolanaWalletPluginError.fromCode(5216, extraMessage); - } - - public static torusWalletNotSet(extraMessage = ""): IWeb3AuthError { - return SolanaWalletPluginError.fromCode(5217, extraMessage); - } - - public static unsupportedChainNamespace(extraMessage = ""): IWeb3AuthError { - return SolanaWalletPluginError.fromCode(5218, extraMessage); - } - - public static invalidParams(extraMessage = ""): IWeb3AuthError { - return SolanaWalletPluginError.fromCode(5220, extraMessage); - } - - public static invalidSession(extraMessage = ""): IWeb3AuthError { - return SolanaWalletPluginError.fromCode(5222, extraMessage); - } -} diff --git a/packages/plugins/solana-wallet-connector-plugin/src/plugin.ts b/packages/plugins/solana-wallet-connector-plugin/src/plugin.ts index 3b40af597..58c5d73b1 100644 --- a/packages/plugins/solana-wallet-connector-plugin/src/plugin.ts +++ b/packages/plugins/solana-wallet-connector-plugin/src/plugin.ts @@ -17,11 +17,10 @@ import { SOLANA_PLUGINS, UserInfo, WALLET_ADAPTERS, + WalletServicesPluginError, } from "@web3auth/base"; import log from "loglevel"; -import { SolanaWalletPluginError } from "./errors"; - export type ProviderInfo = { provider?: SafeEventEmitterProvider; userInfo?: Omit; @@ -61,9 +60,9 @@ export class SolanaWalletConnectorPlugin extends SafeEventEmitter implements IPl async initWithWeb3Auth(web3auth: IWeb3AuthCore, whiteLabel: WhiteLabelData): Promise { if (this.isInitialized) return; - if (!web3auth) throw SolanaWalletPluginError.web3authRequired(); - if (web3auth.provider && !this.SUPPORTED_ADAPTERS.includes(web3auth.connectedAdapterName)) throw SolanaWalletPluginError.unsupportedAdapter(); - if (web3auth.coreOptions.chainConfig.chainNamespace !== this.pluginNamespace) throw SolanaWalletPluginError.unsupportedChainNamespace(); + if (!web3auth) throw WalletServicesPluginError.web3authRequired(); + if (web3auth.provider && !this.SUPPORTED_ADAPTERS.includes(web3auth.connectedAdapterName)) throw WalletServicesPluginError.unsupportedAdapter(); + if (web3auth.coreOptions.chainConfig.chainNamespace !== this.pluginNamespace) throw WalletServicesPluginError.unsupportedChainNamespace(); // Not connected yet to openlogin if (web3auth.provider) { this.provider = web3auth.provider; @@ -71,15 +70,15 @@ export class SolanaWalletConnectorPlugin extends SafeEventEmitter implements IPl } this.web3auth = web3auth; const { logoDark, logoLight } = whiteLabel || {}; - if (!logoDark || !logoLight) throw new Error("logoDark and logoLight are required in whiteLabel config"); + if (!logoDark || !logoLight) throw WalletServicesPluginError.invalidParams("logoDark and logoLight are required in whiteLabel config"); this.subscribeToWeb3AuthNoModalEvents(web3auth); const connectedChainConfig = web3auth.coreOptions.chainConfig as CustomChainConfig; - if (!connectedChainConfig.blockExplorerUrl) throw SolanaWalletPluginError.invalidParams("blockExplorerUrl is required in chainConfig"); - if (!connectedChainConfig.displayName) throw SolanaWalletPluginError.invalidParams("displayName is required in chainConfig"); - if (!connectedChainConfig.logo) throw SolanaWalletPluginError.invalidParams("logo is required in chainConfig"); - if (!connectedChainConfig.ticker) throw SolanaWalletPluginError.invalidParams("ticker is required in chainConfig"); - if (!connectedChainConfig.tickerName) throw SolanaWalletPluginError.invalidParams("tickerName is required in chainConfig"); + if (!connectedChainConfig.blockExplorerUrl) throw WalletServicesPluginError.invalidParams("blockExplorerUrl is required in chainConfig"); + if (!connectedChainConfig.displayName) throw WalletServicesPluginError.invalidParams("displayName is required in chainConfig"); + if (!connectedChainConfig.logo) throw WalletServicesPluginError.invalidParams("logo is required in chainConfig"); + if (!connectedChainConfig.ticker) throw WalletServicesPluginError.invalidParams("ticker is required in chainConfig"); + if (!connectedChainConfig.tickerName) throw WalletServicesPluginError.invalidParams("tickerName is required in chainConfig"); await this.torusWalletInstance.init({ ...(this.walletInitOptions || {}), @@ -110,7 +109,7 @@ export class SolanaWalletConnectorPlugin extends SafeEventEmitter implements IPl async connect(_: PluginConnectParams): Promise { // if web3auth is being used and connected to unsupported adapter throw error - if (!this.isInitialized) throw SolanaWalletPluginError.notInitialized(); + if (!this.isInitialized) throw WalletServicesPluginError.notInitialized(); this.emit(PLUGIN_EVENTS.CONNECTING); this.status = PLUGIN_STATUS.CONNECTING; // Not connected yet to openlogin @@ -119,9 +118,9 @@ export class SolanaWalletConnectorPlugin extends SafeEventEmitter implements IPl this.provider = this.web3auth.provider; this.userInfo = (await this.web3auth.getUserInfo()) as UserInfo; } else if (this.web3auth) { - throw SolanaWalletPluginError.web3AuthNotConnected(); + throw WalletServicesPluginError.web3AuthNotConnected(); } else { - throw SolanaWalletPluginError.providerRequired(); + throw WalletServicesPluginError.providerRequired(); } } let privateKey: string | undefined; @@ -130,11 +129,11 @@ export class SolanaWalletConnectorPlugin extends SafeEventEmitter implements IPl // it should throw if provider doesn't support `solanaSecretKey` function privateKey = (await this.provider.request({ method: "solanaSecretKey" })) as string; } catch (error: unknown) { - log.warn("unsupported method", error, SolanaWalletPluginError.unsupportedAdapter()); - if ((error as JsonRpcError)?.code === -32004) throw SolanaWalletPluginError.unsupportedAdapter(); + log.warn("unsupported method", error, WalletServicesPluginError.unsupportedAdapter()); + if ((error as JsonRpcError)?.code === -32004) throw WalletServicesPluginError.unsupportedAdapter(); throw error; } - if (!privateKey) throw SolanaWalletPluginError.web3AuthNotConnected(); + if (!privateKey) throw WalletServicesPluginError.web3AuthNotConnected(); try { await this.torusWalletInstance.loginWithPrivateKey({ privateKey, @@ -157,19 +156,19 @@ export class SolanaWalletConnectorPlugin extends SafeEventEmitter implements IPl } async initiateTopup(provider: PAYMENT_PROVIDER_TYPE, params: PaymentParams): Promise { - if (!this.torusWalletInstance.isLoggedIn) throw SolanaWalletPluginError.web3AuthNotConnected(); + if (!this.torusWalletInstance.isLoggedIn) throw WalletServicesPluginError.web3AuthNotConnected(); await this.torusWalletInstance.initiateTopup(provider, params); } async disconnect(): Promise { // if web3auth is being used and connected to unsupported adapter throw error - if (this.web3auth?.connectedAdapterName !== WALLET_ADAPTERS.OPENLOGIN) throw SolanaWalletPluginError.unsupportedAdapter(); + if (this.web3auth?.connectedAdapterName !== WALLET_ADAPTERS.OPENLOGIN) throw WalletServicesPluginError.unsupportedAdapter(); if (this.torusWalletInstance.isLoggedIn) { await this.torusWalletInstance.logout(); this.emit(PLUGIN_EVENTS.DISCONNECTED); this.status = PLUGIN_STATUS.DISCONNECTED; } else { - throw new Error("Torus Wallet plugin is not connected"); + throw WalletServicesPluginError.invalidSession("Torus Wallet plugin is not connected"); } } @@ -193,7 +192,7 @@ export class SolanaWalletConnectorPlugin extends SafeEventEmitter implements IPl web3Auth.on(ADAPTER_EVENTS.CONNECTED, async (data: CONNECTED_EVENT_DATA) => { this.provider = data.provider; this.userInfo = (await web3Auth.getUserInfo()) as Omit; - if (!this.provider) throw SolanaWalletPluginError.web3AuthNotConnected(); + if (!this.provider) throw WalletServicesPluginError.web3AuthNotConnected(); this.subscribeToProviderEvents(this.provider); }); @@ -208,7 +207,7 @@ export class SolanaWalletConnectorPlugin extends SafeEventEmitter implements IPl } private async sessionConfig(): Promise<{ chainId: number; accounts: string[]; privateKey: string; chainConfig: CustomChainConfig }> { - if (!this.provider) throw SolanaWalletPluginError.web3AuthNotConnected(); + if (!this.provider) throw WalletServicesPluginError.web3AuthNotConnected(); const [accounts, chainId, privateKey, chainConfig] = await Promise.all([ this.provider.request({ method: "requestAccounts" }), this.provider.request({ method: "solana_chainId" }), @@ -224,7 +223,7 @@ export class SolanaWalletConnectorPlugin extends SafeEventEmitter implements IPl } private async torusWalletSessionConfig(): Promise<{ chainId: number; accounts: string[] }> { - if (!this.torusWalletInstance.provider) throw SolanaWalletPluginError.web3AuthNotConnected(); + if (!this.torusWalletInstance.provider) throw WalletServicesPluginError.web3AuthNotConnected(); const [accounts, chainId] = await Promise.all([ this.torusWalletInstance.provider.request({ method: "solana_accounts" }), this.torusWalletInstance.provider.request({ method: "solana_chainId" }), @@ -236,10 +235,10 @@ export class SolanaWalletConnectorPlugin extends SafeEventEmitter implements IPl } private async setSelectedAddress(address: string): Promise { - if (!this.torusWalletInstance.isLoggedIn || !this.userInfo) throw SolanaWalletPluginError.web3AuthNotConnected(); + if (!this.torusWalletInstance.isLoggedIn || !this.userInfo) throw WalletServicesPluginError.web3AuthNotConnected(); const [, torusWalletSessionConfig] = await Promise.all([this.sessionConfig(), this.torusWalletSessionConfig()]); if (address !== torusWalletSessionConfig.accounts?.[0]) { - throw SolanaWalletPluginError.invalidSession(); + throw WalletServicesPluginError.invalidSession(); } } diff --git a/packages/plugins/wallet-services-plugin/package.json b/packages/plugins/wallet-services-plugin/package.json index 165a170cb..e6587a769 100644 --- a/packages/plugins/wallet-services-plugin/package.json +++ b/packages/plugins/wallet-services-plugin/package.json @@ -31,7 +31,7 @@ ], "devDependencies": { "@metamask/rpc-errors": "^6.3.0", - "@toruslabs/ethereum-controllers": "^5.9.1", + "@toruslabs/ethereum-controllers": "^5.9.2", "@toruslabs/openlogin-utils": "^8.2.1" }, "dependencies": { diff --git a/packages/plugins/wallet-services-plugin/src/errors.ts b/packages/plugins/wallet-services-plugin/src/errors.ts deleted file mode 100644 index 251573bc3..000000000 --- a/packages/plugins/wallet-services-plugin/src/errors.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { ErrorCodes, IWeb3AuthError, Web3AuthError } from "@web3auth/base"; - -export class WalletServicesPluginError extends Web3AuthError { - protected static messages: ErrorCodes = { - 5210: "Wallet Services Plugin is not initialized", - 5211: "Web3Auth is connected to unsupported adapter. Wallet services connector plugin requires web3auth connected to openlogin adapter.", - 5212: "Provider is required..", - 5213: "Web3Auth instance is required while initialization.", - 5214: "Web3Auth is not connected.", - 5216: "Plugin is already initialized", - 5218: "Unsupported chain namespace.", - 5219: "Plugin network different than web3auth instance network.", - 5221: "Web3Auth is not initialized", - 5222: "Invalid session inside wallet services. Please report this issue.", - }; - - public constructor(code: number, message?: string) { - // takes care of stack and proto - super(code, message); - - // Set name explicitly as minification can mangle class names - Object.defineProperty(this, "name", { value: "WalletServicesPluginError" }); - } - - public static fromCode(code: number, extraMessage = ""): IWeb3AuthError { - return new WalletServicesPluginError(code, `${WalletServicesPluginError.messages[code]}${extraMessage}`); - } - - public static notInitialized(extraMessage = ""): IWeb3AuthError { - return WalletServicesPluginError.fromCode(5210, extraMessage); - } - - public static unsupportedAdapter(extraMessage = ""): IWeb3AuthError { - return WalletServicesPluginError.fromCode(5211, extraMessage); - } - - public static providerRequired(extraMessage = ""): IWeb3AuthError { - return WalletServicesPluginError.fromCode(5212, extraMessage); - } - - public static web3authRequired(extraMessage = ""): IWeb3AuthError { - return WalletServicesPluginError.fromCode(5213, extraMessage); - } - - public static web3AuthNotConnected(extraMessage = ""): IWeb3AuthError { - return WalletServicesPluginError.fromCode(5214, extraMessage); - } - - public static alreadyInitialized(extraMessage = ""): IWeb3AuthError { - return WalletServicesPluginError.fromCode(5216, extraMessage); - } - - public static unsupportedChainNamespace(extraMessage = ""): IWeb3AuthError { - return WalletServicesPluginError.fromCode(5218, extraMessage); - } - - public static differentWeb3AuthNetwork(extraMessage = ""): IWeb3AuthError { - return WalletServicesPluginError.fromCode(5219, extraMessage); - } - - public static invalidParams(extraMessage = ""): IWeb3AuthError { - return WalletServicesPluginError.fromCode(5220, extraMessage); - } - - public static web3authNotInitialized(extraMessage = ""): IWeb3AuthError { - return WalletServicesPluginError.fromCode(5221, extraMessage); - } - - public static invalidSession(extraMessage = ""): IWeb3AuthError { - return WalletServicesPluginError.fromCode(5222, extraMessage); - } -} diff --git a/packages/plugins/wallet-services-plugin/src/plugin.ts b/packages/plugins/wallet-services-plugin/src/plugin.ts index 9f68f1ec8..bd01dbfab 100644 --- a/packages/plugins/wallet-services-plugin/src/plugin.ts +++ b/packages/plugins/wallet-services-plugin/src/plugin.ts @@ -16,12 +16,11 @@ import { PluginConnectParams, SafeEventEmitterProvider, WALLET_ADAPTERS, + WalletServicesPluginError, } from "@web3auth/base"; import WsEmbed, { CtorArgs, WsEmbedParams } from "@web3auth/ws-embed"; import log from "loglevel"; -import { WalletServicesPluginError } from "./errors"; - type WsPluginEmbedParams = Omit & { /** * Determines how to show confirmation screens @@ -84,7 +83,7 @@ export class WalletServicesPlugin extends SafeEventEmitter implements IPlugin { }; const { logoDark, logoLight } = mergedWhitelabelSettings || {}; - if (!logoDark || !logoLight) throw new Error("logoDark and logoLight are required in whiteLabel config"); + if (!logoDark || !logoLight) throw WalletServicesPluginError.invalidParams("logoDark and logoLight are required in whiteLabel config"); this.wsEmbedInstance.web3AuthClientId = this.web3auth.coreOptions.clientId; this.wsEmbedInstance.web3AuthNetwork = this.web3auth.coreOptions.web3AuthNetwork; @@ -174,7 +173,7 @@ export class WalletServicesPlugin extends SafeEventEmitter implements IPlugin { this.emit(PLUGIN_EVENTS.DISCONNECTED); this.status = PLUGIN_STATUS.DISCONNECTED; } else { - throw new Error("Wallet Services plugin is not connected"); + throw WalletServicesPluginError.invalidSession("Wallet Services plugin is not connected"); } } diff --git a/packages/providers/base-provider/package.json b/packages/providers/base-provider/package.json index ac90be076..2d87d3697 100644 --- a/packages/providers/base-provider/package.json +++ b/packages/providers/base-provider/package.json @@ -20,7 +20,7 @@ }, "dependencies": { "@metamask/rpc-errors": "^6.3.0", - "@toruslabs/base-controllers": "^5.9.0", + "@toruslabs/base-controllers": "^5.9.2", "@toruslabs/openlogin-jrpc": "^8.1.1", "@web3auth/base": "^8.7.0", "json-rpc-random-id": "^1.0.1" diff --git a/packages/providers/ethereum-mpc-provider/package.json b/packages/providers/ethereum-mpc-provider/package.json index 0230990c1..e975a2ccf 100644 --- a/packages/providers/ethereum-mpc-provider/package.json +++ b/packages/providers/ethereum-mpc-provider/package.json @@ -24,7 +24,7 @@ "@ethereumjs/util": "^9.0.3", "@metamask/eth-sig-util": "^7.0.2", "@metamask/rpc-errors": "^6.3.0", - "@toruslabs/base-controllers": "^5.9.0", + "@toruslabs/base-controllers": "^5.9.2", "@toruslabs/openlogin-jrpc": "^8.1.1", "@web3auth/base": "^8.7.0", "@web3auth/base-provider": "^8.7.0", diff --git a/packages/providers/ethereum-provider/package.json b/packages/providers/ethereum-provider/package.json index f1d604ac2..29c439c6f 100644 --- a/packages/providers/ethereum-provider/package.json +++ b/packages/providers/ethereum-provider/package.json @@ -24,7 +24,7 @@ "@ethereumjs/util": "^9.0.3", "@metamask/eth-sig-util": "^7.0.2", "@metamask/rpc-errors": "^6.3.0", - "@toruslabs/base-controllers": "^5.9.0", + "@toruslabs/base-controllers": "^5.9.2", "@toruslabs/http-helpers": "^6.1.1", "@toruslabs/openlogin-jrpc": "^8.1.1", "@web3auth/base": "^8.7.0", diff --git a/packages/providers/solana-provider/package.json b/packages/providers/solana-provider/package.json index 8cd07b873..41597d66a 100644 --- a/packages/providers/solana-provider/package.json +++ b/packages/providers/solana-provider/package.json @@ -20,7 +20,7 @@ }, "dependencies": { "@metamask/rpc-errors": "^6.3.0", - "@toruslabs/base-controllers": "^5.9.0", + "@toruslabs/base-controllers": "^5.9.2", "@toruslabs/openlogin-ed25519": "^8.1.0", "@toruslabs/openlogin-jrpc": "^8.1.1", "@toruslabs/tweetnacl-js": "^1.0.4", @@ -31,7 +31,7 @@ "json-rpc-random-id": "^1.0.1" }, "devDependencies": { - "@solana/web3.js": "^1.93.2", + "@solana/web3.js": "^1.94.0", "@solflare-wallet/sdk": "^1.4.2", "@types/bn.js": "^5.1.5", "@types/bs58": "^4.0.4", diff --git a/packages/providers/xrpl-provider/package.json b/packages/providers/xrpl-provider/package.json index 7a4ca1aad..e3d975dc4 100644 --- a/packages/providers/xrpl-provider/package.json +++ b/packages/providers/xrpl-provider/package.json @@ -20,7 +20,7 @@ }, "dependencies": { "@metamask/rpc-errors": "^6.3.0", - "@toruslabs/base-controllers": "^5.9.0", + "@toruslabs/base-controllers": "^5.9.2", "@toruslabs/openlogin-jrpc": "^8.1.1", "@web3auth/base": "^8.7.0", "@web3auth/base-provider": "^8.7.0", diff --git a/packages/ui/package.json b/packages/ui/package.json index af202422f..a061489a5 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -53,7 +53,7 @@ "autoprefixer": "^10.4.19", "css-loader": "^7.1.2", "live-server": "^1.2.2", - "postcss": "^8.4.38", + "postcss": "^8.4.39", "postcss-loader": "^8.1.1", "postcss-prefix-selector": "^1.16.1", "react": "^18.3.1", @@ -76,7 +76,7 @@ "lodash.clonedeep": "^4.5.0", "lodash.merge": "^4.6.2", "react-i18next": "^14.1.2", - "react-qrcode-logo": "^2.10.0" + "react-qrcode-logo": "^3.0.0" }, "lint-staged": { "!(*d).ts": [ diff --git a/packages/ui/src/utils.ts b/packages/ui/src/utils.ts index 6a36e2129..619bbd25a 100644 --- a/packages/ui/src/utils.ts +++ b/packages/ui/src/utils.ts @@ -1,6 +1,6 @@ import { get, post } from "@toruslabs/http-helpers"; import { LANGUAGE_MAP, LANGUAGE_TYPE, LANGUAGES } from "@toruslabs/openlogin-utils"; -import { log, LoginMethodConfig, WALLET_ADAPTERS } from "@web3auth/base"; +import { log, LoginMethodConfig, WALLET_ADAPTERS, WalletInitializationError } from "@web3auth/base"; import { OPENLOGIN_PROVIDERS, OPENLOGIN_PROVIDERS_NAMES } from "./config"; @@ -18,7 +18,7 @@ export const getAdapterSocialLogins = (adapterName: string, loginMethodsConfig: }); log.debug("OpenLogin login method ui config", finalLoginMethodsConfig); } else { - throw new Error(`${adapterName} is not a valid adapter`); + throw WalletInitializationError.invalidParams(`${adapterName} is not a valid adapter`); } return finalLoginMethodsConfig; };