diff --git a/package-lock.json b/package-lock.json index 0a070ba41..aa0a7ad53 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,13 +7,15 @@ "": { "name": "core-components", "version": "1.0.0", + "hasInstallScript": true, "license": "Apache-2.0", "workspaces": [ "packages/*", "e2e/meta-tx-gateway" ], "dependencies": { - "clone-deep": "^4.0.1" + "clone-deep": "^4.0.1", + "patch-package": "^8.0.0" }, "devDependencies": { "@graphql-codegen/cli": "^2.6.2", @@ -15967,6 +15969,11 @@ "dev": true, "license": "Apache-2.0" }, + "node_modules/@yarnpkg/lockfile": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz", + "integrity": "sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==" + }, "node_modules/abab": { "version": "2.0.6", "dev": true, @@ -18104,11 +18111,13 @@ } }, "node_modules/call-bind": { - "version": "1.0.2", - "license": "MIT", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.5.tgz", + "integrity": "sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ==", "dependencies": { - "function-bind": "^1.1.1", - "get-intrinsic": "^1.0.2" + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.1", + "set-function-length": "^1.1.1" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -18387,9 +18396,18 @@ } }, "node_modules/ci-info": { - "version": "3.4.0", - "dev": true, - "license": "MIT" + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", + "integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "engines": { + "node": ">=8" + } }, "node_modules/cids": { "version": "0.7.5", @@ -21006,6 +21024,19 @@ "clone": "^1.0.2" } }, + "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-lazy-prop": { "version": "2.0.0", "dev": true, @@ -22919,6 +22950,68 @@ "xtend": "^4.0.1" } }, + "node_modules/eth-revert-reason": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/eth-revert-reason/-/eth-revert-reason-1.0.3.tgz", + "integrity": "sha512-HD4pB+s2Jr4cwdywbcTcdLXPwxOZNrnH/luVuploeqEBlCNvFZQGzOwfgOy8WTSTqqEvjZOrIt+cNPt5Zl4pXw==", + "dependencies": { + "ethers": "^4.0.46" + }, + "bin": { + "getRevertReason": "cli.js" + } + }, + "node_modules/eth-revert-reason/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" + }, + "node_modules/eth-revert-reason/node_modules/ethers": { + "version": "4.0.49", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-4.0.49.tgz", + "integrity": "sha512-kPltTvWiyu+OktYy1IStSO16i2e7cS9D9OxZ81q2UUaiNPVrm/RTcbxamCXF9VUSKzJIdJV68EAIhTEVBalRWg==", + "dependencies": { + "aes-js": "3.0.0", + "bn.js": "^4.11.9", + "elliptic": "6.5.4", + "hash.js": "1.1.3", + "js-sha3": "0.5.7", + "scrypt-js": "2.0.4", + "setimmediate": "1.0.4", + "uuid": "2.0.1", + "xmlhttprequest": "1.8.0" + } + }, + "node_modules/eth-revert-reason/node_modules/hash.js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", + "integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==", + "dependencies": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.0" + } + }, + "node_modules/eth-revert-reason/node_modules/js-sha3": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", + "integrity": "sha512-GII20kjaPX0zJ8wzkTbNDYMY7msuZcTWk8S5UOh6806Jq/wz1J8/bnr8uGU0DAUmYDjj2Mr4X1cW8v/GLYnR+g==" + }, + "node_modules/eth-revert-reason/node_modules/scrypt-js": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-2.0.4.tgz", + "integrity": "sha512-4KsaGcPnuhtCZQCxFxN3GVYIhKFPTdLd8PLC552XwbMndtD0cjRFAhDuuydXQ0h08ZfPgzqe6EKHozpuH74iDw==" + }, + "node_modules/eth-revert-reason/node_modules/setimmediate": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.4.tgz", + "integrity": "sha512-/TjEmXQVEzdod/FFskf3o7oOAsGhHf2j1dZqRFbDzq4F3mvvxflIIi4Hd3bLQE9y/CpwqfSQam5JakI/mi3Pog==" + }, + "node_modules/eth-revert-reason/node_modules/uuid": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.1.tgz", + "integrity": "sha512-nWg9+Oa3qD2CQzHIP4qKUqwNfzKn8P0LtFhotaCTFchsV7ZfDhAybeip/HZVeMIpZi9JgY1E3nUlwaCmZT1sEg==", + "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details." + }, "node_modules/eth-rpc-errors": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/eth-rpc-errors/-/eth-rpc-errors-4.0.2.tgz", @@ -23970,6 +24063,14 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/find-yarn-workspace-root": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz", + "integrity": "sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ==", + "dependencies": { + "micromatch": "^4.0.2" + } + }, "node_modules/flat": { "version": "5.0.2", "dev": true, @@ -24427,8 +24528,12 @@ "license": "ISC" }, "node_modules/function-bind": { - "version": "1.1.1", - "license": "MIT" + "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/function.prototype.name": { "version": "1.1.5", @@ -25426,7 +25531,6 @@ }, "node_modules/has-property-descriptors": { "version": "1.0.0", - "dev": true, "license": "MIT", "dependencies": { "get-intrinsic": "^1.1.1" @@ -26944,7 +27048,6 @@ }, "node_modules/is-docker": { "version": "2.2.1", - "dev": true, "license": "MIT", "bin": { "is-docker": "cli.js" @@ -27530,7 +27633,6 @@ }, "node_modules/is-wsl": { "version": "2.2.0", - "dev": true, "license": "MIT", "dependencies": { "is-docker": "^2.0.0" @@ -30327,11 +30429,20 @@ "license": "MIT" }, "node_modules/json-stable-stringify": { - "version": "1.0.1", - "dev": true, - "license": "MIT", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.1.0.tgz", + "integrity": "sha512-zfA+5SuwYN2VWqN1/5HZaDzQKLJHaBVMZIIM+wuYjdptkaQsqzDdqjqf+lZZJUuJq1aanHiY8LhH8LmH+qBYJA==", "dependencies": { - "jsonify": "~0.0.0" + "call-bind": "^1.0.5", + "isarray": "^2.0.5", + "jsonify": "^0.0.1", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/json-stable-stringify-without-jsonify": { @@ -30339,6 +30450,11 @@ "dev": true, "license": "MIT" }, + "node_modules/json-stable-stringify/node_modules/isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==" + }, "node_modules/json-stringify-nice": { "version": "1.1.4", "dev": true, @@ -30398,9 +30514,12 @@ } }, "node_modules/jsonify": { - "version": "0.0.0", - "dev": true, - "license": "Public Domain" + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.1.tgz", + "integrity": "sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, "node_modules/jsonparse": { "version": "1.3.1", @@ -30565,6 +30684,14 @@ "node": ">=0.10.0" } }, + "node_modules/klaw-sync": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/klaw-sync/-/klaw-sync-6.0.0.tgz", + "integrity": "sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==", + "dependencies": { + "graceful-fs": "^4.1.11" + } + }, "node_modules/kleur": { "version": "3.0.3", "dev": true, @@ -32863,7 +32990,6 @@ }, "node_modules/micromatch": { "version": "4.0.5", - "dev": true, "license": "MIT", "dependencies": { "braces": "^3.0.2", @@ -34706,7 +34832,6 @@ }, "node_modules/object-keys": { "version": "1.1.1", - "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -34988,7 +35113,6 @@ }, "node_modules/os-tmpdir": { "version": "1.0.2", - "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -35477,6 +35601,102 @@ "node": ">=0.10.0" } }, + "node_modules/patch-package": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/patch-package/-/patch-package-8.0.0.tgz", + "integrity": "sha512-da8BVIhzjtgScwDJ2TtKsfT5JFWz1hYoBl9rUQ1f38MC2HwnEIkK8VN3dKMKcP7P7bvvgzNDbfNHtx3MsQb5vA==", + "dependencies": { + "@yarnpkg/lockfile": "^1.1.0", + "chalk": "^4.1.2", + "ci-info": "^3.7.0", + "cross-spawn": "^7.0.3", + "find-yarn-workspace-root": "^2.0.0", + "fs-extra": "^9.0.0", + "json-stable-stringify": "^1.0.2", + "klaw-sync": "^6.0.0", + "minimist": "^1.2.6", + "open": "^7.4.2", + "rimraf": "^2.6.3", + "semver": "^7.5.3", + "slash": "^2.0.0", + "tmp": "^0.0.33", + "yaml": "^2.2.2" + }, + "bin": { + "patch-package": "index.js" + }, + "engines": { + "node": ">=14", + "npm": ">5" + } + }, + "node_modules/patch-package/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/patch-package/node_modules/open": { + "version": "7.4.2", + "resolved": "https://registry.npmjs.org/open/-/open-7.4.2.tgz", + "integrity": "sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==", + "dependencies": { + "is-docker": "^2.0.0", + "is-wsl": "^2.1.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/patch-package/node_modules/rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + } + }, + "node_modules/patch-package/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/patch-package/node_modules/slash": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "engines": { + "node": ">=6" + } + }, + "node_modules/patch-package/node_modules/yaml": { + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.4.tgz", + "integrity": "sha512-8aAvwVUSHpfEqTQ4w/KMlf3HcRdt50E5ODIQJBw1fQ5RL34xabzxtUlzTXVqc4rkZsPbvrXKWnABCD7kWSmocA==", + "engines": { + "node": ">= 14" + } + }, "node_modules/path-browserify": { "version": "1.0.1", "dev": true, @@ -42272,6 +42492,20 @@ "version": "2.0.0", "license": "ISC" }, + "node_modules/set-function-length": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.1.1.tgz", + "integrity": "sha512-VoaqjbBJKiWtg4yRcKBQ7g7wnGnLV3M8oLvVWwOk2PdYY6PEFegR1vezXR0tw6fZGF9csVakIRjrJiy2veSBFQ==", + "dependencies": { + "define-data-property": "^1.1.1", + "get-intrinsic": "^1.2.1", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/set-value": { "version": "2.0.1", "dev": true, @@ -44387,7 +44621,6 @@ }, "node_modules/tmp": { "version": "0.0.33", - "dev": true, "license": "MIT", "dependencies": { "os-tmpdir": "~1.0.2" @@ -47877,6 +48110,14 @@ "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", "dev": true }, + "node_modules/xmlhttprequest": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz", + "integrity": "sha512-58Im/U0mlVBLM38NdZjHyhuMtCqa61469k2YP/AaPbvCoV9aQGUpbJBj1QRm2ytRiVQBD/fsw7L2bJGDVQswBA==", + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/xtend": { "version": "4.0.2", "license": "MIT", @@ -48191,6 +48432,7 @@ "@tippyjs/react": "4.2.6", "@uniswap/sdk-core": "^4.0.7", "dayjs": "1.11.7", + "eth-revert-reason": "^1.0.3", "formik": "2.2.9", "graphql-request": "5.2.0", "lodash.merge": "4.6.2", @@ -54446,6 +54688,7 @@ "customize-cra": "^1.0.0", "dayjs": "1.11.7", "eslint": "^8.10.0", + "eth-revert-reason": "^1.0.3", "file-loader": "^6.2.0", "formik": "2.2.9", "graphql-request": "5.2.0", @@ -67599,6 +67842,11 @@ "version": "4.2.2", "dev": true }, + "@yarnpkg/lockfile": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz", + "integrity": "sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==" + }, "abab": { "version": "2.0.6", "dev": true @@ -69059,10 +69307,13 @@ } }, "call-bind": { - "version": "1.0.2", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.5.tgz", + "integrity": "sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ==", "requires": { - "function-bind": "^1.1.1", - "get-intrinsic": "^1.0.2" + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.1", + "set-function-length": "^1.1.1" } }, "call-me-maybe": { @@ -69235,8 +69486,9 @@ "dev": true }, "ci-info": { - "version": "3.4.0", - "dev": true + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", + "integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==" }, "cids": { "version": "0.7.5", @@ -71005,6 +71257,16 @@ "clone": "^1.0.2" } }, + "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==", + "requires": { + "get-intrinsic": "^1.2.1", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.0" + } + }, "define-lazy-prop": { "version": "2.0.0", "dev": true @@ -72316,6 +72578,66 @@ "xtend": "^4.0.1" } }, + "eth-revert-reason": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/eth-revert-reason/-/eth-revert-reason-1.0.3.tgz", + "integrity": "sha512-HD4pB+s2Jr4cwdywbcTcdLXPwxOZNrnH/luVuploeqEBlCNvFZQGzOwfgOy8WTSTqqEvjZOrIt+cNPt5Zl4pXw==", + "requires": { + "ethers": "^4.0.46" + }, + "dependencies": { + "bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" + }, + "ethers": { + "version": "4.0.49", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-4.0.49.tgz", + "integrity": "sha512-kPltTvWiyu+OktYy1IStSO16i2e7cS9D9OxZ81q2UUaiNPVrm/RTcbxamCXF9VUSKzJIdJV68EAIhTEVBalRWg==", + "requires": { + "aes-js": "3.0.0", + "bn.js": "^4.11.9", + "elliptic": "6.5.4", + "hash.js": "1.1.3", + "js-sha3": "0.5.7", + "scrypt-js": "2.0.4", + "setimmediate": "1.0.4", + "uuid": "2.0.1", + "xmlhttprequest": "1.8.0" + } + }, + "hash.js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", + "integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==", + "requires": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.0" + } + }, + "js-sha3": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", + "integrity": "sha512-GII20kjaPX0zJ8wzkTbNDYMY7msuZcTWk8S5UOh6806Jq/wz1J8/bnr8uGU0DAUmYDjj2Mr4X1cW8v/GLYnR+g==" + }, + "scrypt-js": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/scrypt-js/-/scrypt-js-2.0.4.tgz", + "integrity": "sha512-4KsaGcPnuhtCZQCxFxN3GVYIhKFPTdLd8PLC552XwbMndtD0cjRFAhDuuydXQ0h08ZfPgzqe6EKHozpuH74iDw==" + }, + "setimmediate": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.4.tgz", + "integrity": "sha512-/TjEmXQVEzdod/FFskf3o7oOAsGhHf2j1dZqRFbDzq4F3mvvxflIIi4Hd3bLQE9y/CpwqfSQam5JakI/mi3Pog==" + }, + "uuid": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.1.tgz", + "integrity": "sha512-nWg9+Oa3qD2CQzHIP4qKUqwNfzKn8P0LtFhotaCTFchsV7ZfDhAybeip/HZVeMIpZi9JgY1E3nUlwaCmZT1sEg==" + } + } + }, "eth-rpc-errors": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/eth-rpc-errors/-/eth-rpc-errors-4.0.2.tgz", @@ -73086,6 +73408,14 @@ "path-exists": "^4.0.0" } }, + "find-yarn-workspace-root": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz", + "integrity": "sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ==", + "requires": { + "micromatch": "^4.0.2" + } + }, "flat": { "version": "5.0.2", "dev": true @@ -73397,7 +73727,9 @@ "version": "1.0.0" }, "function-bind": { - "version": "1.1.1" + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==" }, "function.prototype.name": { "version": "1.1.5", @@ -74048,7 +74380,6 @@ }, "has-property-descriptors": { "version": "1.0.0", - "dev": true, "requires": { "get-intrinsic": "^1.1.1" } @@ -75060,8 +75391,7 @@ } }, "is-docker": { - "version": "2.2.1", - "dev": true + "version": "2.2.1" }, "is-dom": { "version": "1.1.0", @@ -75424,7 +75754,6 @@ }, "is-wsl": { "version": "2.2.0", - "dev": true, "requires": { "is-docker": "^2.0.0" } @@ -77547,10 +77876,21 @@ "version": "0.4.1" }, "json-stable-stringify": { - "version": "1.0.1", - "dev": true, + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.1.0.tgz", + "integrity": "sha512-zfA+5SuwYN2VWqN1/5HZaDzQKLJHaBVMZIIM+wuYjdptkaQsqzDdqjqf+lZZJUuJq1aanHiY8LhH8LmH+qBYJA==", "requires": { - "jsonify": "~0.0.0" + "call-bind": "^1.0.5", + "isarray": "^2.0.5", + "jsonify": "^0.0.1", + "object-keys": "^1.1.1" + }, + "dependencies": { + "isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==" + } } }, "json-stable-stringify-without-jsonify": { @@ -77596,8 +77936,9 @@ } }, "jsonify": { - "version": "0.0.0", - "dev": true + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.1.tgz", + "integrity": "sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==" }, "jsonparse": { "version": "1.3.1" @@ -77715,6 +78056,14 @@ "kind-of": { "version": "6.0.3" }, + "klaw-sync": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/klaw-sync/-/klaw-sync-6.0.0.tgz", + "integrity": "sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==", + "requires": { + "graceful-fs": "^4.1.11" + } + }, "kleur": { "version": "3.0.3", "dev": true @@ -79242,7 +79591,6 @@ }, "micromatch": { "version": "4.0.5", - "dev": true, "requires": { "braces": "^3.0.2", "picomatch": "^2.3.1" @@ -80524,8 +80872,7 @@ } }, "object-keys": { - "version": "1.1.1", - "dev": true + "version": "1.1.1" }, "object-visit": { "version": "1.0.1", @@ -80708,8 +81055,7 @@ "optional": true }, "os-tmpdir": { - "version": "1.0.2", - "dev": true + "version": "1.0.2" }, "outdent": { "version": "0.8.0", @@ -81039,6 +81385,73 @@ "version": "0.1.1", "dev": true }, + "patch-package": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/patch-package/-/patch-package-8.0.0.tgz", + "integrity": "sha512-da8BVIhzjtgScwDJ2TtKsfT5JFWz1hYoBl9rUQ1f38MC2HwnEIkK8VN3dKMKcP7P7bvvgzNDbfNHtx3MsQb5vA==", + "requires": { + "@yarnpkg/lockfile": "^1.1.0", + "chalk": "^4.1.2", + "ci-info": "^3.7.0", + "cross-spawn": "^7.0.3", + "find-yarn-workspace-root": "^2.0.0", + "fs-extra": "^9.0.0", + "json-stable-stringify": "^1.0.2", + "klaw-sync": "^6.0.0", + "minimist": "^1.2.6", + "open": "^7.4.2", + "rimraf": "^2.6.3", + "semver": "^7.5.3", + "slash": "^2.0.0", + "tmp": "^0.0.33", + "yaml": "^2.2.2" + }, + "dependencies": { + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "requires": { + "yallist": "^4.0.0" + } + }, + "open": { + "version": "7.4.2", + "resolved": "https://registry.npmjs.org/open/-/open-7.4.2.tgz", + "integrity": "sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==", + "requires": { + "is-docker": "^2.0.0", + "is-wsl": "^2.1.1" + } + }, + "rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "requires": { + "glob": "^7.1.3" + } + }, + "semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "requires": { + "lru-cache": "^6.0.0" + } + }, + "slash": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==" + }, + "yaml": { + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.4.tgz", + "integrity": "sha512-8aAvwVUSHpfEqTQ4w/KMlf3HcRdt50E5ODIQJBw1fQ5RL34xabzxtUlzTXVqc4rkZsPbvrXKWnABCD7kWSmocA==" + } + } + }, "path-browserify": { "version": "1.0.1", "dev": true @@ -85445,6 +85858,17 @@ "set-blocking": { "version": "2.0.0" }, + "set-function-length": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.1.1.tgz", + "integrity": "sha512-VoaqjbBJKiWtg4yRcKBQ7g7wnGnLV3M8oLvVWwOk2PdYY6PEFegR1vezXR0tw6fZGF9csVakIRjrJiy2veSBFQ==", + "requires": { + "define-data-property": "^1.1.1", + "get-intrinsic": "^1.2.1", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.0" + } + }, "set-value": { "version": "2.0.1", "dev": true, @@ -86907,7 +87331,6 @@ }, "tmp": { "version": "0.0.33", - "dev": true, "requires": { "os-tmpdir": "~1.0.2" } @@ -89290,6 +89713,11 @@ "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", "dev": true }, + "xmlhttprequest": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz", + "integrity": "sha512-58Im/U0mlVBLM38NdZjHyhuMtCqa61469k2YP/AaPbvCoV9aQGUpbJBj1QRm2ytRiVQBD/fsw7L2bJGDVQswBA==" + }, "xtend": { "version": "4.0.2" }, diff --git a/package.json b/package.json index 2f6c51ae8..b6a4bb964 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ "pin-to-pinata": "ts-node -P tsconfig.base.json ./scripts/pin-to-pinata.ts", "complete-exchange": "ts-node -P tsconfig.base.json ./scripts/complete-exchange.ts", "update-contract-uri": "ts-node -P tsconfig.base.json ./scripts/change-contract-uri.ts", - "check-offer-exchange-policy": "ts-node -P tsconfig.base.json ./scripts/checkOfferExchangePolicy.ts" + "check-offer-exchange-policy": "ts-node -P tsconfig.base.json ./scripts/checkOfferExchangePolicy.ts", + "postinstall": "patch-package" }, "repository": { "type": "git", @@ -84,6 +85,7 @@ "npm": "8.11.0" }, "dependencies": { - "clone-deep": "^4.0.1" + "clone-deep": "^4.0.1", + "patch-package": "^8.0.0" } } diff --git a/packages/react-kit/package.json b/packages/react-kit/package.json index f72fe1e56..393630ba4 100644 --- a/packages/react-kit/package.json +++ b/packages/react-kit/package.json @@ -26,6 +26,7 @@ "@tippyjs/react": "4.2.6", "@uniswap/sdk-core": "^4.0.7", "dayjs": "1.11.7", + "eth-revert-reason": "^1.0.3", "formik": "2.2.9", "graphql-request": "5.2.0", "lodash.merge": "4.6.2", diff --git a/packages/react-kit/src/components/magicLink/MagicContext.tsx b/packages/react-kit/src/components/magicLink/MagicContext.tsx index 62714c153..28ecb8d90 100644 --- a/packages/react-kit/src/components/magicLink/MagicContext.tsx +++ b/packages/react-kit/src/components/magicLink/MagicContext.tsx @@ -3,7 +3,7 @@ import React, { createContext, ReactNode, useMemo } from "react"; import { UserProvider } from "./UserContext"; import { CONFIG } from "../../lib/config/config"; import { useConfigContext } from "../config/ConfigContext"; -import type { getRpcUrls } from "../../lib/constants/networks"; +import type { getRpcUrls } from "../../lib/const/networks"; export const MagicContext = createContext< | (Magic & { diff --git a/packages/react-kit/src/components/modal/components/Redeem/Confirmation/Confirmation.tsx b/packages/react-kit/src/components/modal/components/Redeem/Confirmation/Confirmation.tsx index 0c3af8676..3a84b8c28 100644 --- a/packages/react-kit/src/components/modal/components/Redeem/Confirmation/Confirmation.tsx +++ b/packages/react-kit/src/components/modal/components/Redeem/Confirmation/Confirmation.tsx @@ -41,6 +41,7 @@ import { RedemptionWidgetAction, useRedemptionContext } from "../../../../widgets/redemption/provider/RedemptionContext"; +import { extractUserFriendlyError } from "../../../../../lib/errors/transactions"; const colors = theme.colors.light; const StyledGrid = styled(Grid)` @@ -315,9 +316,9 @@ ${FormModel.formFields.phone.placeholder}: ${phoneField.value}`; )} {redemptionInfoError && ( - + )} - {redeemError && } + {redeemError && } { - const [error] = args; - console.error("Error while redeeming", error); + onError={async (...args) => { + const [error, context] = args; + const errorMessage = await extractUserFriendlyError(error, { + txResponse: context.txResponse, + provider: signer?.provider + }); + console.error("Error while redeeming", error, errorMessage); + error.message = errorMessage; // call postRedemptionSubmitted if error before the transaction is submitted OR postRedemptionConfirmed if error after if (isTxPending) { postRedemptionConfirmed?.({ diff --git a/packages/react-kit/src/components/modal/components/Redeem/ExchangeView/cancellation/CancelExchange.tsx b/packages/react-kit/src/components/modal/components/Redeem/ExchangeView/cancellation/CancelExchange.tsx index 7050a83cd..038932652 100644 --- a/packages/react-kit/src/components/modal/components/Redeem/ExchangeView/cancellation/CancelExchange.tsx +++ b/packages/react-kit/src/components/modal/components/Redeem/ExchangeView/cancellation/CancelExchange.tsx @@ -27,6 +27,7 @@ import { RedemptionWidgetAction, useRedemptionContext } from "../../../../../widgets/redemption/provider/RedemptionContext"; +import { extractUserFriendlyError } from "../../../../../../lib/errors/transactions"; const colors = theme.colors.light; @@ -185,7 +186,7 @@ export function CancelExchange({ Your rNFT will be burned after cancellation. )} - {cancelError && } + {cancelError && } { - const [error] = args; - console.error(error); + onError={async (...args) => { + const [error, context] = args; + const errorMessage = await extractUserFriendlyError(error, { + txResponse: context.txResponse, + provider: signer?.provider + }); + console.error("Error while cancelling", error, errorMessage); + error.message = errorMessage; setCancelError(error); setIsLoading(false); onError?.(...args); diff --git a/packages/react-kit/src/components/modal/components/Redeem/ExchangeView/expireVoucher/ExpireVoucher.tsx b/packages/react-kit/src/components/modal/components/Redeem/ExchangeView/expireVoucher/ExpireVoucher.tsx index 65bfa51dc..52a414094 100644 --- a/packages/react-kit/src/components/modal/components/Redeem/ExchangeView/expireVoucher/ExpireVoucher.tsx +++ b/packages/react-kit/src/components/modal/components/Redeem/ExchangeView/expireVoucher/ExpireVoucher.tsx @@ -21,6 +21,7 @@ import ThemedButton from "../../../../../ui/ThemedButton"; import Typography from "../../../../../ui/Typography"; import DetailTable from "../detail/DetailTable"; import { useSigner } from "../../../../../../hooks/connection/connection"; +import { extractUserFriendlyError } from "../../../../../../lib/errors/transactions"; const colors = theme.colors.light; @@ -177,7 +178,7 @@ export default function ExpireVoucher({ } ]} /> - {expireError && } + {expireError && } @@ -197,9 +198,18 @@ export default function ExpireVoucher({ metaTx: coreSDK.metaTxConfig }} disabled={isLoading} - onError={(...args) => { - const [error] = args; - console.error(error); + onError={async (...args) => { + const [error, context] = args; + const errorMessage = await extractUserFriendlyError(error, { + txResponse: context.txResponse, + provider: signer?.provider + }); + console.error( + "Error while expiring voucher", + error, + errorMessage + ); + error.message = errorMessage; setExpireError(error); setIsLoading(false); onError?.(...args); diff --git a/packages/react-kit/src/components/modal/components/SellerFinance/FinanceDeposit.tsx b/packages/react-kit/src/components/modal/components/SellerFinance/FinanceDeposit.tsx index 3cce50924..1b9810369 100644 --- a/packages/react-kit/src/components/modal/components/SellerFinance/FinanceDeposit.tsx +++ b/packages/react-kit/src/components/modal/components/SellerFinance/FinanceDeposit.tsx @@ -1,4 +1,5 @@ import React from "react"; +import * as Sentry from "@sentry/browser"; import { BigNumber, ethers } from "ethers"; import { useState } from "react"; @@ -23,6 +24,10 @@ import { useCoreSDKWithContext } from "../../../../hooks/useCoreSdkWithContext"; import { useAddPendingTransactionWithContext } from "../../../../hooks/transactions/usePendingTransactionsWithContext"; import { subgraph } from "@bosonprotocol/core-sdk"; import { useAccount, useSigner } from "../../../../hooks/connection/connection"; +import { + extractUserFriendlyError, + getHasUserRejectedTx +} from "../../../../lib/errors/transactions"; interface Props { protocolBalance: string; @@ -188,13 +193,23 @@ export default function FinanceDeposit({ setIsBeingDeposit(false); hideModal(); }} - onError={(error) => { - console.error("onError", error); - const hasUserRejectedTx = - "code" in error && - (error as unknown as { code: string }).code === "ACTION_REJECTED"; + onError={async (...args) => { + const [error, context] = args; + const errorMessage = await extractUserFriendlyError(error, { + txResponse: context.txResponse, + provider: signer?.provider + }); + console.error("Error while depositing funds", error, errorMessage); + error.message = errorMessage; + const hasUserRejectedTx = getHasUserRejectedTx(error); if (hasUserRejectedTx) { showModal("CONFIRMATION_FAILED"); + } else { + Sentry.captureException(error); + showModal("CONFIRMATION_FAILED", { + errorMessage: "Something went wrong", + detailedErrorMessage: errorMessage + }); } setDepositError(error); reload(); diff --git a/packages/react-kit/src/components/modal/components/SellerFinance/FinanceWithdraw.tsx b/packages/react-kit/src/components/modal/components/SellerFinance/FinanceWithdraw.tsx index b63cf1da9..09271a679 100644 --- a/packages/react-kit/src/components/modal/components/SellerFinance/FinanceWithdraw.tsx +++ b/packages/react-kit/src/components/modal/components/SellerFinance/FinanceWithdraw.tsx @@ -1,4 +1,5 @@ import React from "react"; +import * as Sentry from "@sentry/browser"; import { BigNumber, ethers } from "ethers"; import { Spinner } from "phosphor-react"; @@ -28,6 +29,10 @@ import { useEnvContext } from "../../../environment/EnvironmentContext"; import { useAddPendingTransactionWithContext } from "../../../../hooks/transactions/usePendingTransactionsWithContext"; import { subgraph } from "@bosonprotocol/core-sdk"; import { useAccount, useSigner } from "../../../../hooks/connection/connection"; +import { + extractUserFriendlyError, + getHasUserRejectedTx +} from "../../../../lib/errors/transactions"; const colors = theme.colors.light; const MaxLimitWrapper = styled.div` @@ -198,13 +203,23 @@ export default function FinanceWithdraw({ reload(); setIsBeingWithdrawn(false); }} - onError={(error) => { - console.error("onError", error); - const hasUserRejectedTx = - "code" in error && - (error as unknown as { code: string }).code === "ACTION_REJECTED"; + onError={async (...args) => { + const [error, context] = args; + const errorMessage = await extractUserFriendlyError(error, { + txResponse: context.txResponse, + provider: signer?.provider + }); + console.error("Error while withdrawing funds", error, errorMessage); + error.message = errorMessage; + const hasUserRejectedTx = getHasUserRejectedTx(error); if (hasUserRejectedTx) { showModal("CONFIRMATION_FAILED"); + } else { + Sentry.captureException(error); + showModal("CONFIRMATION_FAILED", { + errorMessage: "Something went wrong", + detailedErrorMessage: errorMessage + }); } setWithdrawError(error); reload(); diff --git a/packages/react-kit/src/components/modal/components/Transactions/ConfirmationFailedModal/ConfirmationFailedModal.tsx b/packages/react-kit/src/components/modal/components/Transactions/ConfirmationFailedModal/ConfirmationFailedModal.tsx index caf1b4fc1..8ac20fc73 100644 --- a/packages/react-kit/src/components/modal/components/Transactions/ConfirmationFailedModal/ConfirmationFailedModal.tsx +++ b/packages/react-kit/src/components/modal/components/Transactions/ConfirmationFailedModal/ConfirmationFailedModal.tsx @@ -1,16 +1,19 @@ -import React from "react"; import { WarningCircle } from "phosphor-react"; -import { useEffect } from "react"; +import React, { useEffect } from "react"; import Grid from "../../../../ui/Grid"; import Typography from "../../../../ui/Typography"; import { useModal } from "../../../useModal"; import { theme } from "../../../../../theme"; import { GenericModalProps } from "../../../ModalContext"; - const colors = theme.colors.light; - -export default function ConfirmationFailedModal(_: Record) { +export default function ConfirmationFailedModal({ + errorMessage, + detailedErrorMessage +}: { + errorMessage: string; + detailedErrorMessage?: string; +}) { const { updateProps, store } = useModal(); useEffect(() => { updateProps<"CONFIRMATION_FAILED">({ @@ -30,7 +33,7 @@ export default function ConfirmationFailedModal(_: Record) { - Confirmation Failed + {errorMessage || "Confirmation Failed"} ) { lineHeight="150%" margin="0.5rem 0 1.5rem 0" > - Please retry this action + {detailedErrorMessage || "Please retry this action"} ); diff --git a/packages/react-kit/src/hooks/useCtaClickHandler.ts b/packages/react-kit/src/hooks/useCtaClickHandler.ts index ab2223041..63df51b27 100644 --- a/packages/react-kit/src/hooks/useCtaClickHandler.ts +++ b/packages/react-kit/src/hooks/useCtaClickHandler.ts @@ -134,6 +134,8 @@ export function useCtaClickHandler({ ); receipt = error.receipt; } + } else { + throw error; } } } diff --git a/packages/react-kit/src/index.tsx b/packages/react-kit/src/index.tsx index 52b78107f..bec054af2 100644 --- a/packages/react-kit/src/index.tsx +++ b/packages/react-kit/src/index.tsx @@ -44,4 +44,5 @@ export * from "./components/magicLink/MagicContext"; export * from "./components/magicLink/UserContext"; export * from "./lib/magicLink/logout"; export * from "./lib/magicLink/provider"; -export * from "./lib/constants/networks"; +export * from "./lib/const/networks"; +export * from "./lib/errors/transactions"; diff --git a/packages/react-kit/src/lib/config/config.ts b/packages/react-kit/src/lib/config/config.ts index 6a13e3bed..f82937e8a 100644 --- a/packages/react-kit/src/lib/config/config.ts +++ b/packages/react-kit/src/lib/config/config.ts @@ -1,4 +1,4 @@ -import { getRpcUrls } from "../constants/networks"; +import { getRpcUrls } from "../const/networks"; const magicLinkKey = process.env.REACT_APP_MAGIC_API_KEY; if (!magicLinkKey) { diff --git a/packages/react-kit/src/lib/constants/networks.ts b/packages/react-kit/src/lib/const/networks.ts similarity index 100% rename from packages/react-kit/src/lib/constants/networks.ts rename to packages/react-kit/src/lib/const/networks.ts diff --git a/packages/react-kit/src/lib/errors/transactions.ts b/packages/react-kit/src/lib/errors/transactions.ts new file mode 100644 index 000000000..95c345f35 --- /dev/null +++ b/packages/react-kit/src/lib/errors/transactions.ts @@ -0,0 +1,61 @@ +import { Provider } from "@bosonprotocol/ethers-sdk"; +import * as Sentry from "@sentry/browser"; +import getRevertReason from "eth-revert-reason"; +import { providers } from "ethers"; + +export async function extractUserFriendlyError( + error: unknown, + { + defaultError = "Please retry this action", + txResponse, + provider + }: { + defaultError?: string; + txResponse?: providers.TransactionResponse; + provider?: Provider; + } = {} +): Promise { + try { + if (!error || typeof error !== "object") { + return defaultError; + } + if (txResponse) { + const revertReason = await getRevertReason( + txResponse.hash, + "mainnet", // mumbai is not supported + txResponse.blockNumber, + provider + ); + return revertReason ?? defaultError; + } + // meta transactions + const m = error.toString().match(/(?<=execution reverted: ).*/)?.[0]; + const endIndexSlash = m?.indexOf(`\\",`); + const endIndexWithoutSlash = m?.indexOf(`",`); + const details = m?.substring( + 0, + endIndexSlash && + endIndexSlash !== -1 && + endIndexWithoutSlash && + endIndexWithoutSlash !== -1 + ? Math.min(endIndexSlash, endIndexWithoutSlash) + : endIndexSlash !== -1 && endIndexSlash + ? endIndexSlash + : endIndexWithoutSlash + ); + return details ?? defaultError; + } catch (error) { + console.error("[extractUserFriendlyError]", error); + Sentry.captureException(error); + return defaultError; + } +} + +export function getHasUserRejectedTx(error: unknown): boolean { + const hasUserRejectedTx = + !!error && + typeof error === "object" && + "code" in error && + error.code === "ACTION_REJECTED"; + return hasUserRejectedTx; +} diff --git a/patches/eth-revert-reason+1.0.3.patch b/patches/eth-revert-reason+1.0.3.patch new file mode 100644 index 000000000..9960c0147 --- /dev/null +++ b/patches/eth-revert-reason+1.0.3.patch @@ -0,0 +1,15 @@ +diff --git a/node_modules/eth-revert-reason/index.js b/node_modules/eth-revert-reason/index.js +index 4e43d12..17f5cb9 100644 +--- a/node_modules/eth-revert-reason/index.js ++++ b/node_modules/eth-revert-reason/index.js +@@ -16,7 +16,9 @@ async function getRevertReason (txHash, network = 'mainnet', blockNumber = undef + await validateInputPostProvider(txHash, network, blockNumber, provider) + + try { +- const tx = await provider.getTransaction(txHash) ++ const tx = await provider.getTransaction(txHash); ++ delete tx.maxPriorityFeePerGas; ++ delete tx.maxFeePerGas; + const code = await getCode(tx, network, blockNumber, provider) + return decodeMessage(code, network) + } catch (err) {