diff --git a/.changeset/old-pans-retire.md b/.changeset/old-pans-retire.md new file mode 100644 index 00000000000..77501cb72c4 --- /dev/null +++ b/.changeset/old-pans-retire.md @@ -0,0 +1,5 @@ +--- +'@audius/sdk': major +--- + +Updates target, module, and lib to ES2022 to access new features such as Error.cause, updates @solana/web3.js, and updates SolanaRelay service to throw SendTransactionError on failure diff --git a/.circleci/src/jobs/@identity-jobs.yml b/.circleci/src/jobs/@identity-jobs.yml index ef6d44d4a56..1215865ee27 100644 --- a/.circleci/src/jobs/@identity-jobs.yml +++ b/.circleci/src/jobs/@identity-jobs.yml @@ -22,3 +22,5 @@ identity-init: - node_modules - packages/libs/node_modules - packages/libs/dist + - packages/spl/dist + - packages/spl/node_modules diff --git a/package-lock.json b/package-lock.json index a7f8fc49d44..fc62f3b3513 100644 --- a/package-lock.json +++ b/package-lock.json @@ -600,27 +600,24 @@ "link": true }, "node_modules/@audius/fetch-nft": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/@audius/fetch-nft/-/fetch-nft-0.2.6.tgz", - "integrity": "sha512-zVWJSI+DKOn/BwYFTtWr2h1/JeJi0JUdo9rXAWtNRvWKQzyC7XyIVZ/AJumFKGVUwwcwnO2uTbHU1O+E8XWQ2w==", + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/@audius/fetch-nft/-/fetch-nft-0.2.7.tgz", + "integrity": "sha512-Y0xxsUmV2H4qp3MMT61jumkbRfkDSAxlg332Z2lYVVl+Xd0y8vtVYS8io4URE5Xr2FMpGJRCCWteFTJlx53FoQ==", "license": "ISC", "dependencies": { "@metaplex-foundation/mpl-token-metadata": "3.2.1", "@metaplex-foundation/umi": "0.9.1", "@solana/spl-token": "0.3.8", - "@solana/web3.js": "1.78.4", + "@solana/web3.js": "1.93.4", "cross-fetch": "3.1.4", "dayjs": "1.11.10" - }, - "peerDependencies": { - "@solana/spl-token": "0.3.8", - "@solana/web3.js": "1.78.4" } }, "node_modules/@audius/fetch-nft/node_modules/cross-fetch": { "version": "3.1.4", "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.4.tgz", "integrity": "sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ==", + "license": "MIT", "dependencies": { "node-fetch": "2.6.1" } @@ -628,7 +625,8 @@ "node_modules/@audius/fetch-nft/node_modules/dayjs": { "version": "1.11.10", "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz", - "integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==" + "integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==", + "license": "MIT" }, "node_modules/@audius/fixed-decimal": { "resolved": "packages/fixed-decimal", @@ -24514,14 +24512,16 @@ } }, "node_modules/@solana/web3.js": { - "version": "1.78.4", + "version": "1.93.4", + "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.93.4.tgz", + "integrity": "sha512-6hHtSYmkUPwcm3eGeqBanMT3pDAhTprrm2IUoboSjNN4gKCBEkY9uIeS2TZKLpsGY+R6fDub5pRi+e4xFVv55w==", "license": "MIT", "dependencies": { - "@babel/runtime": "^7.22.6", - "@noble/curves": "^1.0.0", - "@noble/hashes": "^1.3.1", - "@solana/buffer-layout": "^4.0.0", - "agentkeepalive": "^4.3.0", + "@babel/runtime": "^7.24.7", + "@noble/curves": "^1.4.0", + "@noble/hashes": "^1.4.0", + "@solana/buffer-layout": "^4.0.1", + "agentkeepalive": "^4.5.0", "bigint-buffer": "^1.1.5", "bn.js": "^5.2.1", "borsh": "^0.7.0", @@ -24529,13 +24529,15 @@ "buffer": "6.0.3", "fast-stable-stringify": "^1.0.0", "jayson": "^4.1.0", - "node-fetch": "^2.6.12", - "rpc-websockets": "^7.5.1", - "superstruct": "^0.14.2" + "node-fetch": "^2.7.0", + "rpc-websockets": "^9.0.2", + "superstruct": "^1.0.4" } }, "node_modules/@solana/web3.js/node_modules/@babel/runtime": { - "version": "7.23.2", + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.7.tgz", + "integrity": "sha512-UwgBRMjJP+xv857DCngvqXI3Iq6J4v0wXmwc6sapg+zyhbwmQX67LUEFrkK5tbyJ30jGuG3ZvWpBiB9LCy1kWw==", "license": "MIT", "dependencies": { "regenerator-runtime": "^0.14.0" @@ -24544,6 +24546,30 @@ "node": ">=6.9.0" } }, + "node_modules/@solana/web3.js/node_modules/@noble/curves": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.4.2.tgz", + "integrity": "sha512-TavHr8qycMChk8UwMld0ZDRvatedkzWfH8IiaeGCfymOP5i0hSCozz9vHOL0nkwk7HRMlFnAiKpS2jrUmSybcw==", + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.4.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@solana/web3.js/node_modules/@noble/hashes": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", + "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==", + "license": "MIT", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@solana/web3.js/node_modules/borsh": { "version": "0.7.0", "license": "Apache-2.0", @@ -24572,11 +24598,9 @@ } }, "node_modules/@solana/web3.js/node_modules/regenerator-runtime": { - "version": "0.14.0", - "license": "MIT" - }, - "node_modules/@solana/web3.js/node_modules/superstruct": { - "version": "0.14.2", + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", + "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==", "license": "MIT" }, "node_modules/@solana/web3.js/node_modules/tr46": { @@ -39840,6 +39864,7 @@ "version": "0.5.11", "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.11.tgz", "integrity": "sha512-YNlnKRWF2sVojTpIyzwou9XoTNbzbzONwRhOoniEioF1AtaitTvVZblaQRrAzChWQ1bLYyYSWzM18y4WwgzJ+A==", + "license": "Apache-2.0", "dependencies": { "tslib": "^2.4.0" } @@ -39847,7 +39872,8 @@ "node_modules/@swc/helpers/node_modules/tslib": { "version": "2.6.3", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", - "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==", + "license": "0BSD" }, "node_modules/@swc/jest": { "version": "0.2.29", @@ -92453,11 +92479,16 @@ } }, "node_modules/rpc-websockets": { - "version": "7.6.2", + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/rpc-websockets/-/rpc-websockets-9.0.2.tgz", + "integrity": "sha512-YzggvfItxMY3Lwuax5rC18inhbjJv9Py7JXRHxTIi94JOLrqBsSsUUc5bbl5W6c11tXhdfpDPK0KzBhoGe8jjw==", "license": "LGPL-3.0-only", "dependencies": { - "@babel/runtime": "^7.17.2", - "eventemitter3": "^4.0.7", + "@swc/helpers": "^0.5.11", + "@types/uuid": "^8.3.4", + "@types/ws": "^8.2.2", + "buffer": "^6.0.3", + "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, @@ -92470,15 +92501,40 @@ "utf-8-validate": "^5.0.2" } }, + "node_modules/rpc-websockets/node_modules/@types/uuid": { + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz", + "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==", + "license": "MIT" + }, + "node_modules/rpc-websockets/node_modules/@types/ws": { + "version": "8.5.10", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.10.tgz", + "integrity": "sha512-vmQSUcfalpIq0R9q7uTo2lXs6eGIpt9wtnLdMv9LVpIjCA/+ufZRozlVoVelIYixx1ugCBKDhn89vnsEGOCx9A==", + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/rpc-websockets/node_modules/eventemitter3": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", + "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==", + "license": "MIT" + }, "node_modules/rpc-websockets/node_modules/uuid": { "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", "license": "MIT", "bin": { "uuid": "dist/bin/uuid" } }, "node_modules/rpc-websockets/node_modules/ws": { - "version": "8.14.2", + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", + "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", "license": "MIT", "engines": { "node": ">=10.0.0" @@ -111331,7 +111387,7 @@ "@audius/sdk": "*", "@audius/spl": "*", "@solana/spl-token": "0.3.8", - "@solana/web3.js": "1.78.4", + "@solana/web3.js": "1.93.4", "bn.js": "^5.2.1", "chalk": "^5.0.1", "commander": "^9.4.0" @@ -111360,7 +111416,7 @@ "name": "@audius/common", "version": "1.5.76", "dependencies": { - "@audius/fetch-nft": "0.2.6", + "@audius/fetch-nft": "0.2.7", "@audius/fixed-decimal": "*", "@audius/sdk": "*", "@audius/trpc-server": "*", @@ -111416,7 +111472,7 @@ "peerDependencies": { "@reduxjs/toolkit": "1.6.1", "@solana/spl-token": "0.3.8", - "@solana/web3.js": "1.78.4", + "@solana/web3.js": "1.93.4", "@stripe/crypto": "0.0.4", "react": "^18.2.0", "redux-saga": "1.1.3" @@ -129104,17 +129160,6 @@ "vitest": "0.34.6" } }, - "packages/discovery-provider/plugins/pedalboard/apps/solana-relay/node_modules/@babel/runtime": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.7.tgz", - "integrity": "sha512-UwgBRMjJP+xv857DCngvqXI3Iq6J4v0wXmwc6sapg+zyhbwmQX67LUEFrkK5tbyJ30jGuG3ZvWpBiB9LCy1kWw==", - "dependencies": { - "regenerator-runtime": "^0.14.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, "packages/discovery-provider/plugins/pedalboard/apps/solana-relay/node_modules/@noble/curves": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.3.0.tgz", @@ -129170,65 +129215,6 @@ "url": "https://paulmillr.com/funding/" } }, - "packages/discovery-provider/plugins/pedalboard/apps/solana-relay/node_modules/@solana/web3.js": { - "version": "1.93.4", - "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.93.4.tgz", - "integrity": "sha512-6hHtSYmkUPwcm3eGeqBanMT3pDAhTprrm2IUoboSjNN4gKCBEkY9uIeS2TZKLpsGY+R6fDub5pRi+e4xFVv55w==", - "dependencies": { - "@babel/runtime": "^7.24.7", - "@noble/curves": "^1.4.0", - "@noble/hashes": "^1.4.0", - "@solana/buffer-layout": "^4.0.1", - "agentkeepalive": "^4.5.0", - "bigint-buffer": "^1.1.5", - "bn.js": "^5.2.1", - "borsh": "^0.7.0", - "bs58": "^4.0.1", - "buffer": "6.0.3", - "fast-stable-stringify": "^1.0.0", - "jayson": "^4.1.0", - "node-fetch": "^2.7.0", - "rpc-websockets": "^9.0.2", - "superstruct": "^1.0.4" - } - }, - "packages/discovery-provider/plugins/pedalboard/apps/solana-relay/node_modules/@solana/web3.js/node_modules/@noble/curves": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.4.0.tgz", - "integrity": "sha512-p+4cb332SFCrReJkCYe8Xzm0OWi4Jji5jVdIZRL/PmacmDkFNw6MrrV+gGpiPxLHbV+zKFRywUWbaseT+tZRXg==", - "dependencies": { - "@noble/hashes": "1.4.0" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "packages/discovery-provider/plugins/pedalboard/apps/solana-relay/node_modules/@solana/web3.js/node_modules/@noble/hashes": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", - "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==", - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "packages/discovery-provider/plugins/pedalboard/apps/solana-relay/node_modules/@solana/web3.js/node_modules/bn.js": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", - "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" - }, - "packages/discovery-provider/plugins/pedalboard/apps/solana-relay/node_modules/@solana/web3.js/node_modules/borsh": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/borsh/-/borsh-0.7.0.tgz", - "integrity": "sha512-CLCsZGIBCFnPtkNnieW/a8wmreDmfUtjU2m9yHrzPXIlNbqVs0AQrSatSG6vdNYUqdc83tkQi2eHfF98ubzQLA==", - "dependencies": { - "bn.js": "^5.2.0", - "bs58": "^4.0.0", - "text-encoding-utf-8": "^1.0.2" - } - }, "packages/discovery-provider/plugins/pedalboard/apps/solana-relay/node_modules/@types/body-parser": { "version": "1.19.0", "dev": true, @@ -130075,38 +130061,6 @@ "@redis/time-series": "1.0.5" } }, - "packages/discovery-provider/plugins/pedalboard/apps/solana-relay/node_modules/regenerator-runtime": { - "version": "0.14.1", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", - "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==" - }, - "packages/discovery-provider/plugins/pedalboard/apps/solana-relay/node_modules/rpc-websockets": { - "version": "9.0.2", - "resolved": "https://registry.npmjs.org/rpc-websockets/-/rpc-websockets-9.0.2.tgz", - "integrity": "sha512-YzggvfItxMY3Lwuax5rC18inhbjJv9Py7JXRHxTIi94JOLrqBsSsUUc5bbl5W6c11tXhdfpDPK0KzBhoGe8jjw==", - "dependencies": { - "@swc/helpers": "^0.5.11", - "@types/uuid": "^8.3.4", - "@types/ws": "^8.2.2", - "buffer": "^6.0.3", - "eventemitter3": "^5.0.1", - "uuid": "^8.3.2", - "ws": "^8.5.0" - }, - "funding": { - "type": "paypal", - "url": "https://paypal.me/kozjak" - }, - "optionalDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" - } - }, - "packages/discovery-provider/plugins/pedalboard/apps/solana-relay/node_modules/rpc-websockets/node_modules/@types/uuid": { - "version": "8.3.4", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz", - "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==" - }, "packages/discovery-provider/plugins/pedalboard/apps/solana-relay/node_modules/safe-buffer": { "version": "5.1.2", "license": "MIT" @@ -130220,14 +130174,6 @@ "node": ">=4.2.0" } }, - "packages/discovery-provider/plugins/pedalboard/apps/solana-relay/node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "bin": { - "uuid": "dist/bin/uuid" - } - }, "packages/discovery-provider/plugins/pedalboard/apps/solana-relay/node_modules/web3-core": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/web3-core/-/web3-core-4.3.2.tgz", @@ -136130,7 +136076,7 @@ "packages/embed": { "version": "1.5.76", "dependencies": { - "@audius/fetch-nft": "0.2.6", + "@audius/fetch-nft": "0.2.7", "@audius/fixed-decimal": "*", "@audius/harmony": "*", "@audius/sdk": "*", @@ -137789,7 +137735,7 @@ "@solana/buffer-layout": "4.0.1", "@solana/buffer-layout-utils": "0.2.0", "@solana/spl-token": "0.3.8", - "@solana/web3.js": "1.78.4", + "@solana/web3.js": "1.93.4", "apn": "2.2.0", "async-retry": "1.3.3", "aws-sdk": "2.595.0", @@ -139063,7 +139009,7 @@ "@project-serum/anchor": "0.24.1", "@scure/base": "1.1.1", "@solana/spl-token": "0.3.8", - "@solana/web3.js": "1.78.4", + "@solana/web3.js": "1.93.4", "abi-decoder": "2.4.0", "ajv": "6.12.2", "assert": "2.0.0", @@ -139539,6 +139485,18 @@ "@sinonjs/commons": "^3.0.0" } }, + "packages/libs/node_modules/@noble/hashes": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", + "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==", + "license": "MIT", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "packages/libs/node_modules/@rollup/plugin-typescript": { "version": "11.1.5", "dev": true, @@ -140907,7 +140865,7 @@ "dependencies": { "@amplitude/react-native": "2.17.2", "@audius/common": "*", - "@audius/fetch-nft": "0.2.6", + "@audius/fetch-nft": "0.2.7", "@audius/fixed-decimal": "*", "@audius/harmony": "*", "@audius/sdk": "*", @@ -143522,7 +143480,7 @@ "@solana/buffer-layout": "4.0.1", "@solana/buffer-layout-utils": "0.2.0", "@solana/spl-token": "0.3.8", - "@solana/web3.js": "1.78.4" + "@solana/web3.js": "1.93.4" }, "devDependencies": { "vitest": "0.34.6" @@ -143995,7 +143953,7 @@ "version": "1.5.92", "dependencies": { "@audius/common": "*", - "@audius/fetch-nft": "0.2.6", + "@audius/fetch-nft": "0.2.7", "@audius/fixed-decimal": "*", "@audius/harmony": "*", "@audius/sdk": "*", @@ -144024,7 +143982,7 @@ "@sentry/browser": "7.117.0", "@sentry/cli": "2.31.2", "@solana/spl-token": "0.3.8", - "@solana/web3.js": "1.78.4", + "@solana/web3.js": "1.93.4", "@stripe/crypto": "0.0.4", "@stripe/stripe-js": "1.54.1", "@tanstack/react-query": "4.35.7", @@ -144214,7 +144172,9 @@ } }, "packages/web/node_modules/@babel/runtime": { - "version": "7.24.0", + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.7.tgz", + "integrity": "sha512-UwgBRMjJP+xv857DCngvqXI3Iq6J4v0wXmwc6sapg+zyhbwmQX67LUEFrkK5tbyJ30jGuG3ZvWpBiB9LCy1kWw==", "dev": true, "license": "MIT", "dependencies": { diff --git a/packages/commands/package.json b/packages/commands/package.json index a3d28cf4cf0..efcd6a4224b 100644 --- a/packages/commands/package.json +++ b/packages/commands/package.json @@ -17,7 +17,7 @@ "@audius/sdk": "*", "@audius/spl": "*", "@solana/spl-token": "0.3.8", - "@solana/web3.js": "1.78.4", + "@solana/web3.js": "1.93.4", "bn.js": "^5.2.1", "chalk": "^5.0.1", "commander": "^9.4.0" diff --git a/packages/common/package.json b/packages/common/package.json index f0db5667468..fd41b38cb96 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -36,7 +36,7 @@ "url": "https://github.com/AudiusProject/audius-protocol/issues" }, "dependencies": { - "@audius/fetch-nft": "0.2.6", + "@audius/fetch-nft": "0.2.7", "@audius/fixed-decimal": "*", "@audius/sdk": "*", "@audius/trpc-server": "*", @@ -92,7 +92,7 @@ "peerDependencies": { "@reduxjs/toolkit": "1.6.1", "@solana/spl-token": "0.3.8", - "@solana/web3.js": "1.78.4", + "@solana/web3.js": "1.93.4", "@stripe/crypto": "0.0.4", "react": "^18.2.0", "redux-saga": "1.1.3" diff --git a/packages/common/src/models/Analytics.ts b/packages/common/src/models/Analytics.ts index da970438d11..945592d45f4 100644 --- a/packages/common/src/models/Analytics.ts +++ b/packages/common/src/models/Analytics.ts @@ -1708,6 +1708,7 @@ type RewardsClaimFailure = { amount: number url?: string error: string + instruction?: string } type RewardsClaimBlocked = { diff --git a/packages/discovery-provider/plugins/pedalboard/apps/solana-relay/src/middleware/errorHandler.ts b/packages/discovery-provider/plugins/pedalboard/apps/solana-relay/src/middleware/errorHandler.ts index 4b49adf3437..9972c4aafff 100644 --- a/packages/discovery-provider/plugins/pedalboard/apps/solana-relay/src/middleware/errorHandler.ts +++ b/packages/discovery-provider/plugins/pedalboard/apps/solana-relay/src/middleware/errorHandler.ts @@ -10,12 +10,13 @@ export const errorHandlerMiddleware = ( _next: NextFunction ) => { const status = error instanceof ResponseError ? error.status : 500 + const meta = error instanceof Error ? { ...error } : {} if (!res.headersSent) { res .status(status) .set('X-Request-ID', res.locals.requestId) .set('Access-Control-Expose-Headers', 'X-Request-ID') - .send({ error: (error as any).toString() }) + .send({ error: (error as any).toString(), ...meta }) } // in milliseconds const responseTime = new Date().getTime() - res.locals.requestStartTime diff --git a/packages/discovery-provider/plugins/pedalboard/apps/solana-relay/src/utils/transaction.ts b/packages/discovery-provider/plugins/pedalboard/apps/solana-relay/src/utils/transaction.ts index 6a61178be4b..57815ea2a02 100644 --- a/packages/discovery-provider/plugins/pedalboard/apps/solana-relay/src/utils/transaction.ts +++ b/packages/discovery-provider/plugins/pedalboard/apps/solana-relay/src/utils/transaction.ts @@ -110,12 +110,11 @@ export const sendTransactionWithRetries = async ({ if (!sendOptions?.skipPreflight) { const simulatedRes = await connection.simulateTransaction(transaction) if (simulatedRes.value.err) { - // @ts-ignore Typescript is confused about deps throw new SendTransactionError({ action: 'simulate', signature: confirmationStrategy.signature, transactionMessage: JSON.stringify(simulatedRes.value.err), - logs: simulatedRes.value.logs + logs: simulatedRes.value.logs ?? undefined }) } } @@ -132,7 +131,6 @@ export const sendTransactionWithRetries = async ({ throw new Error('Failed to get transaction confirmation result') } if (res.value.err) { - // @ts-ignore Typescript is confused about deps throw new SendTransactionError({ action: 'send', signature: confirmationStrategy.signature, diff --git a/packages/embed/package.json b/packages/embed/package.json index 7b7abc0e6e3..a5b705341ca 100644 --- a/packages/embed/package.json +++ b/packages/embed/package.json @@ -33,7 +33,7 @@ "webpack-cli": "4.5.0" }, "dependencies": { - "@audius/fetch-nft": "0.2.6", + "@audius/fetch-nft": "0.2.7", "@audius/fixed-decimal": "*", "@audius/harmony": "*", "@audius/sdk": "*", diff --git a/packages/identity-service/package.json b/packages/identity-service/package.json index dd4e6424c7d..db569e49c6b 100644 --- a/packages/identity-service/package.json +++ b/packages/identity-service/package.json @@ -50,7 +50,7 @@ "@solana/buffer-layout": "4.0.1", "@solana/buffer-layout-utils": "0.2.0", "@solana/spl-token": "0.3.8", - "@solana/web3.js": "1.78.4", + "@solana/web3.js": "1.93.4", "apn": "2.2.0", "async-retry": "1.3.3", "aws-sdk": "2.595.0", diff --git a/packages/libs/libs.test.tsconfig.json b/packages/libs/libs.test.tsconfig.json new file mode 100644 index 00000000000..2c7b284162f --- /dev/null +++ b/packages/libs/libs.test.tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs" + } +} diff --git a/packages/libs/package.json b/packages/libs/package.json index 44bf8bb0d23..bcbc94f4016 100644 --- a/packages/libs/package.json +++ b/packages/libs/package.json @@ -28,7 +28,7 @@ "test:sdk:browser": "./node_modules/.bin/jest --env jsdom", "test": "npm run test:unit && npm run test:sdk", "test:libs": "./scripts/test.sh", - "test:unit": "ts-mocha 'src/**/*.test.{js,ts}' --ignore 'src/sdk/**/*.test.{js,ts}' --exit", + "test:unit": "export TS_NODE_PROJECT=libs.test.tsconfig.json; ts-mocha 'src/**/*.test.{js,ts}' --ignore 'src/sdk/**/*.test.{js,ts}' --exit", "test:unit:watch": "ts-mocha 'src/[!sdk]**/*.test.{js,ts}' --ignore 'src/sdk/**/*.test.{js,ts}' --watch", "test:integration": "ts-mocha tests/index.js", "setup": "./scripts/migrate_contracts.sh", @@ -79,7 +79,7 @@ "@project-serum/anchor": "0.24.1", "@scure/base": "1.1.1", "@solana/spl-token": "0.3.8", - "@solana/web3.js": "1.78.4", + "@solana/web3.js": "1.93.4", "abi-decoder": "2.4.0", "ajv": "6.12.2", "assert": "2.0.0", diff --git a/packages/libs/src/sdk/api/generated/default/runtime.ts b/packages/libs/src/sdk/api/generated/default/runtime.ts index 1b3e46f5ab3..329034d928a 100644 --- a/packages/libs/src/sdk/api/generated/default/runtime.ts +++ b/packages/libs/src/sdk/api/generated/default/runtime.ts @@ -250,8 +250,8 @@ export class ResponseError extends Error { export class FetchError extends Error { override name: "FetchError" = "FetchError"; - constructor(public cause: Error, msg?: string) { - super(msg); + constructor(cause: Error, msg?: string) { + super(msg, { cause }); } } diff --git a/packages/libs/src/sdk/api/generated/full/runtime.ts b/packages/libs/src/sdk/api/generated/full/runtime.ts index dd5f2f05a71..360f4ccecef 100644 --- a/packages/libs/src/sdk/api/generated/full/runtime.ts +++ b/packages/libs/src/sdk/api/generated/full/runtime.ts @@ -250,8 +250,8 @@ export class ResponseError extends Error { export class FetchError extends Error { override name: "FetchError" = "FetchError"; - constructor(public cause: Error, msg?: string) { - super(msg); + constructor(cause: Error, msg?: string) { + super(msg, { cause }); } } diff --git a/packages/libs/src/sdk/api/generator/templates/typescript-fetch/runtime.mustache b/packages/libs/src/sdk/api/generator/templates/typescript-fetch/runtime.mustache index 88d99a67dd1..14c41141147 100644 --- a/packages/libs/src/sdk/api/generator/templates/typescript-fetch/runtime.mustache +++ b/packages/libs/src/sdk/api/generator/templates/typescript-fetch/runtime.mustache @@ -239,8 +239,8 @@ export class ResponseError extends Error { export class FetchError extends Error { override name: "FetchError" = "FetchError"; - constructor(public cause: Error, msg?: string) { - super(msg); + constructor(cause: Error, msg?: string) { + super(msg, { cause }); } } diff --git a/packages/libs/src/sdk/services/Solana/SolanaRelay.ts b/packages/libs/src/sdk/services/Solana/SolanaRelay.ts index 15a2d36859e..ba976c10df3 100644 --- a/packages/libs/src/sdk/services/Solana/SolanaRelay.ts +++ b/packages/libs/src/sdk/services/Solana/SolanaRelay.ts @@ -1,4 +1,8 @@ -import { PublicKey, TransactionInstruction } from '@solana/web3.js' +import { + PublicKey, + SendTransactionError, + TransactionInstruction +} from '@solana/web3.js' import { BaseAPI } from '../../api/generated/default' import * as runtime from '../../api/generated/default/runtime' @@ -102,15 +106,38 @@ export class SolanaRelay extends BaseAPI { sendOptions } - const response = await this.request( - { - path: '/relay', - method: 'POST', - headers: headerParameters, - body - }, - initOverrides - ) + let response: Response + try { + response = await this.request( + { + path: '/relay', + method: 'POST', + headers: headerParameters, + body + }, + initOverrides + ) + } catch (e) { + // Catch response errors, and if possible, recreate the original + // SendTransactionError to transparently raise to the caller. + if (e instanceof Error && e.name === 'ResponseError') { + const resp = (e as runtime.ResponseError).response.clone() + const body = await resp.json() + if ( + 'error' in body && + 'transactionMessage' in body && + 'signature' in body + ) { + throw new SendTransactionError({ + action: body.error.indexOf('Simulation') > -1 ? 'simulate' : 'send', + signature: body.signature, + transactionMessage: body.transactionMessage, + logs: body.transactionLogs + }) + } + } + throw e + } return await new runtime.JSONApiResponse(response, (json) => { if (!runtime.exists(json, 'signature')) { diff --git a/packages/libs/src/sdk/services/Solana/programs/RewardManagerClient/RewardManagerClient.ts b/packages/libs/src/sdk/services/Solana/programs/RewardManagerClient/RewardManagerClient.ts index 1edae9f976a..3e751058658 100644 --- a/packages/libs/src/sdk/services/Solana/programs/RewardManagerClient/RewardManagerClient.ts +++ b/packages/libs/src/sdk/services/Solana/programs/RewardManagerClient/RewardManagerClient.ts @@ -1,6 +1,17 @@ -import { RewardManagerProgram } from '@audius/spl' +import { + RewardManagerInstruction, + RewardManagerErrorCode, + RewardManagerProgram +} from '@audius/spl' import type { RewardManagerStateData } from '@audius/spl/dist/types/reward-manager/types' -import { Secp256k1Program, type PublicKey } from '@solana/web3.js' +import { SendTransactionOptions } from '@solana/wallet-adapter-base' +import { + Secp256k1Program, + SendTransactionError, + Transaction, + VersionedTransaction, + type PublicKey +} from '@solana/web3.js' import { productionConfig } from '../../../../config/production' import { mergeConfigWithDefaults } from '../../../../utils/mergeConfigs' @@ -22,6 +33,61 @@ import { GetSubmittedAttestationsSchema } from './types' +type CustomInstructionErrorMessage = { + InstructionError: [number, { Custom: number }] +} + +/** + * Mapping of custom instruction error codes to error messages + * @see {@link https://github.com/AudiusProject/audius-protocol/blob/2a37bcff1bb1a82efdf187d1723b3457dc0dcb9b/solana-programs/reward-manager/program/src/error.rs solana-programs/reward-manager/program/src/errors.rs} + */ +const codeMessageMap: Record = { + [RewardManagerErrorCode.IncorrectOwner]: + 'Input account owner is not the program address', + [RewardManagerErrorCode.SignCollision]: + 'Signature with an already met principal', + [RewardManagerErrorCode.WrongSigner]: 'Unexpected signer met', + [RewardManagerErrorCode.NotEnoughSigners]: "Isn't enough signers keys", + [RewardManagerErrorCode.Secp256InstructionMissing]: + 'Secp256 instruction missing', + [RewardManagerErrorCode.InstructionLoadError]: 'Instruction load error', + [RewardManagerErrorCode.RepeatedSenders]: 'Repeated sender', + [RewardManagerErrorCode.SignatureVerificationFailed]: + 'Signature verification failed', + [RewardManagerErrorCode.OperatorCollision]: + 'Some signers have same operators', + [RewardManagerErrorCode.AlreadySent]: 'Funds already sent', + [RewardManagerErrorCode.IncorrectMessages]: 'Incorrect messages', + [RewardManagerErrorCode.MessagesOverflow]: 'Messages overflow', + [RewardManagerErrorCode.MathOverflow]: 'Math overflow', + [RewardManagerErrorCode.InvalidRecipient]: 'Invalid Recipient' +} + +export class RewardManagerError extends Error { + override name = 'RewardManagerError' + public code: number + public instructionName: string + public customErrorName?: string + constructor({ + code, + instructionName, + cause + }: { + code: number + instructionName: string + cause?: Error + }) { + super( + codeMessageMap[code as RewardManagerErrorCode] ?? + `Unknown error: ${code}`, + { cause } + ) + this.code = code + this.instructionName = instructionName + this.customErrorName = RewardManagerErrorCode[code] + } +} + /** * Connected client to the Solana RewardManager program. * @@ -245,4 +311,74 @@ export class RewardManagerClient extends BaseSolanaProgramClient { } return this.rewardManagerState } + + /** + * Override the sendTransaction method to provide some more friendly errors + * back to the consumer for RewardManager instructions + */ + public override async sendTransaction( + transaction: Transaction | VersionedTransaction, + sendOptions?: SendTransactionOptions | undefined + ): Promise { + try { + return await super.sendTransaction(transaction, sendOptions) + } catch (e) { + if (e instanceof SendTransactionError) { + try { + const error = JSON.parse( + e.transactionError.message + ) as CustomInstructionErrorMessage + if (error && error.InstructionError) { + const instructionIndex = error.InstructionError[0] + const code = error.InstructionError[1]?.Custom + + // Parse the different transaction types differently + if ('instructions' in transaction) { + // Legacy Transaction + const instruction = transaction.instructions[instructionIndex] + // Check error instruction is from RewardManagerProgram + if (instruction && instruction.programId.equals(this.programId)) { + const decodedInstruction = + RewardManagerProgram.decodeInstruction(instruction) + throw new RewardManagerError({ + code, + instructionName: + RewardManagerInstruction[ + decodedInstruction.data.instruction + ] ?? 'Unknown', + cause: e + }) + } + } else { + // VersionedTransaction + const instruction = + transaction.message.compiledInstructions[instructionIndex] + // Check error instruction is from RewardManagerProgram + if ( + instruction && + transaction.message.staticAccountKeys[ + instruction.programIdIndex + ]?.equals(this.programId) + ) { + throw new RewardManagerError({ + code, + instructionName: + RewardManagerInstruction[instruction!.data[0] as number] ?? + 'Unknown', + cause: e + }) + } + } + } + } catch (e) { + if (e instanceof RewardManagerError) { + throw e + } + // If failed to provide user friendly error, surface original error + console.warn('Failed to parse RewardManagerError error', e) + } + } + throw e + } + } } diff --git a/packages/libs/src/sdk/services/Solana/programs/RewardManagerClient/index.ts b/packages/libs/src/sdk/services/Solana/programs/RewardManagerClient/index.ts index 67c1bdbf94a..16432df30cb 100644 --- a/packages/libs/src/sdk/services/Solana/programs/RewardManagerClient/index.ts +++ b/packages/libs/src/sdk/services/Solana/programs/RewardManagerClient/index.ts @@ -1,2 +1,2 @@ -export { RewardManagerClient } from './RewardManagerClient' +export { RewardManagerClient, RewardManagerError } from './RewardManagerClient' export { getDefaultRewardManagerClentConfig } from './getDefaultConfig' diff --git a/packages/libs/src/utils/network.test.ts b/packages/libs/src/utils/network.test.ts index 6adc3268fce..a0eaf27f5b7 100644 --- a/packages/libs/src/utils/network.test.ts +++ b/packages/libs/src/utils/network.test.ts @@ -1,6 +1,5 @@ import assert from 'assert' -import { describe, it } from 'mocha' import nock from 'nock' import { timeRequests } from './network' @@ -65,7 +64,10 @@ describe('timeRequests()', () => { assert.strictEqual(res[4]?.request.url, 'https://slowAndError.audius.co') }) - it('respects an equivalency delta', async () => { + it('respects an equivalency delta', async function () { + // @ts-ignore annoying amount of time trying to figure out how to type this + // so that typescript knows that "this" is the TestFunction type from Mocha + this.timeout(10000) const allResults: string[] = [] for (let i = 0; i < 20; ++i) { const requests = [ @@ -104,7 +106,7 @@ describe('timeRequests()', () => { // Make sure there is some variance assert(!allResults.every((val) => val === allResults[0])) - }).timeout(10000) + }) it('filterNonResponsive = true', async () => { const requests = [ diff --git a/packages/libs/tsconfig.json b/packages/libs/tsconfig.json index 4471753b794..d97b018dc7c 100644 --- a/packages/libs/tsconfig.json +++ b/packages/libs/tsconfig.json @@ -1,8 +1,9 @@ { "extends": "@tsconfig/strictest/tsconfig.json", "compilerOptions": { - "lib": ["ES2020", "dom"], - "target": "es5", + "module": "ES2022", + "lib": ["ES2022", "dom"], + "target": "ES2022", "checkJs": false, "allowJs": true, "resolveJsonModule": true, diff --git a/packages/mobile/package.json b/packages/mobile/package.json index 96ae05d193b..45676e05cd8 100644 --- a/packages/mobile/package.json +++ b/packages/mobile/package.json @@ -55,7 +55,7 @@ "dependencies": { "@amplitude/react-native": "2.17.2", "@audius/common": "*", - "@audius/fetch-nft": "0.2.6", + "@audius/fetch-nft": "0.2.7", "@audius/fixed-decimal": "*", "@audius/harmony": "*", "@audius/sdk": "*", diff --git a/packages/spl/package.json b/packages/spl/package.json index ff9c4ea9429..21f4df4c77e 100644 --- a/packages/spl/package.json +++ b/packages/spl/package.json @@ -27,7 +27,7 @@ "@solana/buffer-layout": "4.0.1", "@solana/buffer-layout-utils": "0.2.0", "@solana/spl-token": "0.3.8", - "@solana/web3.js": "1.78.4" + "@solana/web3.js": "1.93.4" }, "devDependencies": { "vitest": "0.34.6" diff --git a/packages/spl/src/index.ts b/packages/spl/src/index.ts index 89cf1805fa6..c30d12beeaf 100644 --- a/packages/spl/src/index.ts +++ b/packages/spl/src/index.ts @@ -1,5 +1,8 @@ export { ClaimableTokensProgram } from './claimable-tokens/ClaimableTokensProgram' -export { RewardManagerInstruction } from './reward-manager/constants' +export { + RewardManagerInstruction, + RewardManagerErrorCode +} from './reward-manager/constants' export { RewardManagerProgram } from './reward-manager/RewardManagerProgram' export { Secp256k1Program } from './secp256k1/Secp256k1Program' export { ethAddress } from './layout-utils' diff --git a/packages/spl/src/reward-manager/constants.ts b/packages/spl/src/reward-manager/constants.ts index 4c6055697ed..07fa78f42f2 100644 --- a/packages/spl/src/reward-manager/constants.ts +++ b/packages/spl/src/reward-manager/constants.ts @@ -8,3 +8,24 @@ export enum RewardManagerInstruction { SubmitAttestation = 6, EvaluateAttestations = 7 } + +/** + * Possible custom error messages from the Reward Manager program + * @see {@link https://github.com/AudiusProject/audius-protocol/blob/2a37bcff1bb1a82efdf187d1723b3457dc0dcb9b/solana-programs/reward-manager/program/src/error.rs solana-programs/reward-manager/program/src/errors.rs} + */ +export enum RewardManagerErrorCode { + IncorrectOwner = 0, + SignCollision, + WrongSigner, + NotEnoughSigners, + Secp256InstructionMissing, + InstructionLoadError, + RepeatedSenders, + SignatureVerificationFailed, + OperatorCollision, + AlreadySent, + IncorrectMessages, + MessagesOverflow, + MathOverflow, + InvalidRecipient +} diff --git a/packages/web/package.json b/packages/web/package.json index e8c83b661d4..358f8e9ee33 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -72,7 +72,7 @@ }, "dependencies": { "@audius/common": "*", - "@audius/fetch-nft": "0.2.6", + "@audius/fetch-nft": "0.2.7", "@audius/fixed-decimal": "*", "@audius/harmony": "*", "@audius/sdk": "*", @@ -101,7 +101,7 @@ "@sentry/browser": "7.117.0", "@sentry/cli": "2.31.2", "@solana/spl-token": "0.3.8", - "@solana/web3.js": "1.78.4", + "@solana/web3.js": "1.93.4", "@stripe/crypto": "0.0.4", "@stripe/stripe-js": "1.54.1", "@tanstack/react-query": "4.35.7", diff --git a/packages/web/src/common/store/pages/audio-rewards/sagas.ts b/packages/web/src/common/store/pages/audio-rewards/sagas.ts index f03ce6f9653..fe60ec0e5f2 100644 --- a/packages/web/src/common/store/pages/audio-rewards/sagas.ts +++ b/packages/web/src/common/store/pages/audio-rewards/sagas.ts @@ -26,7 +26,7 @@ import { } from '@audius/common/store' import { encodeHashId, waitForValue } from '@audius/common/utils' import { AUDIO } from '@audius/fixed-decimal' -import { AudiusSdk, ChallengeId, Errors } from '@audius/sdk' +import { AudiusSdk, ChallengeId, Errors, RewardManagerError } from '@audius/sdk' import { call, fork, @@ -280,6 +280,17 @@ async function claimRewardsForChallenge({ error: await error.response.clone().text() }) ) + } else if (error instanceof RewardManagerError) { + await track( + make({ + eventName: Name.REWARDS_CLAIM_FAILURE, + challengeId, + specifier: specifierWithAmount.specifier, + amount: specifierWithAmount.amount, + error: error.customErrorName ?? 'Unkown', + instruction: error.instructionName + }) + ) } else { await track( make({