diff --git a/api/Dockerfile b/api/Dockerfile index 8eef979bf..9d76f4658 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -1,7 +1,7 @@ -FROM node:16-alpine +FROM node:16.20.2-bullseye ## Include the build tools for any npm packages that rebuild -RUN apk --no-cache add git curl python3 build-base cmake +RUN apt install git curl python3 # Working DIR WORKDIR /usr/src/app diff --git a/api/package-lock.json b/api/package-lock.json index 50e3ea772..45b3327a7 100644 --- a/api/package-lock.json +++ b/api/package-lock.json @@ -1,28 +1,25 @@ { "name": "explorer-api", - "version": "3.2.0", + "version": "3.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "explorer-api", - "version": "3.2.0", + "version": "3.3.0", "license": "Apache-2.0", "dependencies": { "@google-cloud/logging-winston": "^5.3.0", "@iota/core": "^1.0.0-beta.30", "@iota/crypto.js": "^1.8.6", - "@iota/crypto.js-stardust": "npm:@iota/crypto.js@2.0.0-rc.2", "@iota/identity-wasm": "^0.5.0-dev.6", "@iota/identity-wasm-0.4": "npm:@iota/identity-wasm@^0.4.3", "@iota/identity-wasm-0.7": "npm:@iota/identity-wasm@^0.7.0-alpha.6", "@iota/iota.js-chrysalis": "npm:@iota/iota.js@^1.8.6", - "@iota/iota.js-stardust": "npm:@iota/iota.js@2.0.0-rc.4", "@iota/mqtt.js": "^1.8.6", - "@iota/mqtt.js-stardust": "npm:@iota/mqtt.js@2.0.0-rc.3", + "@iota/sdk": "1.1.1", "@iota/sdk-wasm": "^1.0.4", "@iota/util.js": "^1.8.6", - "@iota/util.js-stardust": "npm:@iota/util.js@2.0.0-rc.2", "@iota/validators": "^1.0.0-beta.30", "@types/moment": "^2.13.0", "@types/node-cron": "^3.0.2", @@ -47,7 +44,7 @@ "@types/express": "^4.17.13", "@types/jest": "^29.2.3", "@types/jszip": "^3.4.1", - "@types/node": "^16.10.3", + "@types/node": "^16.18.51", "@types/uuid": "^8.3.1", "@types/winston": "^2.4.4", "@typescript-eslint/eslint-plugin": "^5.36.0", @@ -65,7 +62,37 @@ "typescript": "^4.8.2" }, "engines": { - "node": ">=14 <=16.16" + "node": ">=14 <=16.20" + } + }, + "../../../iota-sdk/bindings/nodejs": { + "name": "@iota/sdk", + "version": "0.1.0", + "extraneous": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "@iota/types": "^1.0.0-beta.15", + "@types/node": "^18.15.12", + "cargo-cp-artifact": "^0.1.6", + "prebuild-install": "^7.1.1", + "typescript": "^4.9.4" + }, + "devDependencies": { + "@types/jest": "^29.4.0", + "@typescript-eslint/eslint-plugin": "^5.30.7", + "@typescript-eslint/parser": "^5.30.7", + "dotenv": "^16.0.3", + "electron-build-env": "^0.2.0", + "eslint": "^8.20.0", + "eslint-config-prettier": "^8.5.0", + "jest": "^29.4.2", + "jest-matcher-utils": "^29.5.0", + "prebuild": "^11.0.4", + "prettier": "^2.8.3", + "ts-jest": "^29.0.5", + "typedoc": "^0.24.6", + "typedoc-plugin-markdown": "^3.14.0" } }, "@iota/crypto.js-stardust@1.9.0-stardust.4": { @@ -971,30 +998,6 @@ "node": ">=14.0.0" } }, - "node_modules/@iota/crypto.js-stardust": { - "name": "@iota/crypto.js", - "version": "2.0.0-rc.2", - "resolved": "https://registry.npmjs.org/@iota/crypto.js/-/crypto.js-2.0.0-rc.2.tgz", - "integrity": "sha512-gydR6weJ4g8W67yGffpYd3N7Bt83pgqqOCLBM1SV6+wztNuwMYcO8V/yMTyqI9P4Er426QB83cTiwdaOJzs/zQ==", - "dependencies": { - "@iota/util.js": "2.0.0-rc.2", - "big-integer": "^1.6.51" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/@iota/crypto.js-stardust/node_modules/@iota/util.js": { - "version": "2.0.0-rc.2", - "resolved": "https://registry.npmjs.org/@iota/util.js/-/util.js-2.0.0-rc.2.tgz", - "integrity": "sha512-c6n5LPiimwkz5aCKsMjRg3GKWzcK+zELmJK1AVaziLneJ8BsdZBKvWJyQGNqjREQjOhRaixizmZc3nGuihldnQ==", - "dependencies": { - "big-integer": "^1.6.51" - }, - "engines": { - "node": ">=14.0.0" - } - }, "node_modules/@iota/curl": { "version": "1.0.0-beta.19", "integrity": "sha512-bUr6VW8lP1XYhAkzUacc8U28qO2Ibdl6R5CSF7N34GgjO2sEkn4DnlzL1VU8cCv+8rfBlZ9qIvYGzklic49JJw==" @@ -1060,44 +1063,6 @@ "node": ">=14.0.0" } }, - "node_modules/@iota/iota.js-stardust": { - "name": "@iota/iota.js", - "version": "2.0.0-rc.4", - "resolved": "https://registry.npmjs.org/@iota/iota.js/-/iota.js-2.0.0-rc.4.tgz", - "integrity": "sha512-fXlM6Q/jSQG0dEXULugbgE9ZT9R5nN3G8oz71Ti6vhbxL1lbQN4M/IzddGg+cn2NfKezNcdMjs8xBbOOBJveCQ==", - "dependencies": { - "@iota/crypto.js": "2.0.0-rc.2", - "@iota/util.js": "2.0.0-rc.2", - "big-integer": "^1.6.51", - "node-fetch": "2.6.7" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/@iota/iota.js-stardust/node_modules/@iota/crypto.js": { - "version": "2.0.0-rc.2", - "resolved": "https://registry.npmjs.org/@iota/crypto.js/-/crypto.js-2.0.0-rc.2.tgz", - "integrity": "sha512-gydR6weJ4g8W67yGffpYd3N7Bt83pgqqOCLBM1SV6+wztNuwMYcO8V/yMTyqI9P4Er426QB83cTiwdaOJzs/zQ==", - "dependencies": { - "@iota/util.js": "2.0.0-rc.2", - "big-integer": "^1.6.51" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/@iota/iota.js-stardust/node_modules/@iota/util.js": { - "version": "2.0.0-rc.2", - "resolved": "https://registry.npmjs.org/@iota/util.js/-/util.js-2.0.0-rc.2.tgz", - "integrity": "sha512-c6n5LPiimwkz5aCKsMjRg3GKWzcK+zELmJK1AVaziLneJ8BsdZBKvWJyQGNqjREQjOhRaixizmZc3nGuihldnQ==", - "dependencies": { - "big-integer": "^1.6.51" - }, - "engines": { - "node": ">=14.0.0" - } - }, "node_modules/@iota/kerl": { "version": "1.0.0-beta.30", "integrity": "sha512-vVx7916Sb1fZWV9FmsFUUoxrgBbxeK4lc2Y0NYIw4OnU/Q6NsTu+GEXGNMArp97daU4UQhbceE7DNTj9HOICfQ==", @@ -1119,57 +1084,6 @@ "node": ">=12.0.0" } }, - "node_modules/@iota/mqtt.js-stardust": { - "name": "@iota/mqtt.js", - "version": "2.0.0-rc.3", - "resolved": "https://registry.npmjs.org/@iota/mqtt.js/-/mqtt.js-2.0.0-rc.3.tgz", - "integrity": "sha512-uS8EtyY78t+periL8tp41HxaI0vkQkQ7jfrW4W2Qyb1YhaTCsGfvfV1RFr8S0LSks6f7TCRk79UpA+Ys8b1tjw==", - "dependencies": { - "@iota/iota.js": "2.0.0-rc.3", - "@iota/util.js": "2.0.0-rc.1", - "mqtt": "^4.3.7" - }, - "engines": { - "node": ">=12.0.0" - } - }, - "node_modules/@iota/mqtt.js-stardust/node_modules/@iota/crypto.js": { - "version": "2.0.0-rc.1", - "resolved": "https://registry.npmjs.org/@iota/crypto.js/-/crypto.js-2.0.0-rc.1.tgz", - "integrity": "sha512-gidDFvbIcthVIaxqntffUCFHHNZNhu1e3zjwt6yaYLeuqJcc2AXPv/UF8Lz9Mfkw9aSM8xVUwo8/uYDkvs2eOQ==", - "dependencies": { - "@iota/util.js": "2.0.0-rc.1", - "big-integer": "^1.6.51" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/@iota/mqtt.js-stardust/node_modules/@iota/iota.js": { - "version": "2.0.0-rc.3", - "resolved": "https://registry.npmjs.org/@iota/iota.js/-/iota.js-2.0.0-rc.3.tgz", - "integrity": "sha512-lrnmFDmI3vWscJAGzka2VOpi+x/kH1xMwvLgPOQ2WlyKOouLv/gmjc6S0K3TYCxKPRgw6DsVYMkFsK4GXXV5BA==", - "dependencies": { - "@iota/crypto.js": "2.0.0-rc.1", - "@iota/util.js": "2.0.0-rc.1", - "big-integer": "^1.6.51", - "node-fetch": "2.6.7" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/@iota/mqtt.js-stardust/node_modules/@iota/util.js": { - "version": "2.0.0-rc.1", - "resolved": "https://registry.npmjs.org/@iota/util.js/-/util.js-2.0.0-rc.1.tgz", - "integrity": "sha512-tG+qsCHhztGuthUPqLlckih3Ump+IcKCDEl+Sb7ACOOR7JM73KOGaRud8NlLu4GNqQyQh7s9Gn2GRkXBJ1apiA==", - "dependencies": { - "big-integer": "^1.6.51" - }, - "engines": { - "node": ">=14.0.0" - } - }, "node_modules/@iota/mqtt.js/node_modules/@iota/iota.js": { "version": "1.8.6", "resolved": "https://registry.npmjs.org/@iota/iota.js/-/iota.js-1.8.6.tgz", @@ -1188,6 +1102,20 @@ "version": "1.0.0-beta.30", "integrity": "sha512-fnhPMPul18WunLq9Ni4rxzBFmhna6eaG8WroDg6GdQqSK/eN62uFHV8tpspJHXuCqwgCUVp6NpuUna7+B2OV9g==" }, + "node_modules/@iota/sdk": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@iota/sdk/-/sdk-1.1.1.tgz", + "integrity": "sha512-63WcGZGwlIwZpIhk+F+ozxm9miRy+eDmCoyIS/8actUNlH8zG5DXmjtWqxZx89se9UEAZyr4eZH7JJlwfkieqQ==", + "hasInstallScript": true, + "dependencies": { + "@types/node": "^18.15.12", + "cargo-cp-artifact": "^0.1.6", + "class-transformer": "^0.5.1", + "prebuild-install": "^7.1.1", + "reflect-metadata": "^0.1.13", + "typescript": "^4.9.4" + } + }, "node_modules/@iota/sdk-wasm": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/@iota/sdk-wasm/-/sdk-wasm-1.0.5.tgz", @@ -1207,6 +1135,14 @@ "fsevents": "^2.3.2" } }, + "node_modules/@iota/sdk/node_modules/@types/node": { + "version": "18.18.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.18.7.tgz", + "integrity": "sha512-bw+lEsxis6eqJYW8Ql6+yTqkE6RuFtsQPSe5JxXbqYRFQEER5aJA9a5UH9igqDWm3X4iLHIKOHlnAXLM4mi7uQ==", + "dependencies": { + "undici-types": "~5.26.4" + } + }, "node_modules/@iota/signing": { "version": "1.0.0-beta.30", "integrity": "sha512-VnOCBq8uAsMwQKv7VeYe2Yx2hTWxNp/lkNEqN6xgPsTII17elj0wjwR+b4euf48h3nIiGeCLWRK5a+k9r46o/g==", @@ -1249,18 +1185,6 @@ "node": ">=14.0.0" } }, - "node_modules/@iota/util.js-stardust": { - "name": "@iota/util.js", - "version": "2.0.0-rc.2", - "resolved": "https://registry.npmjs.org/@iota/util.js/-/util.js-2.0.0-rc.2.tgz", - "integrity": "sha512-c6n5LPiimwkz5aCKsMjRg3GKWzcK+zELmJK1AVaziLneJ8BsdZBKvWJyQGNqjREQjOhRaixizmZc3nGuihldnQ==", - "dependencies": { - "big-integer": "^1.6.51" - }, - "engines": { - "node": ">=14.0.0" - } - }, "node_modules/@iota/validators": { "version": "1.0.0-beta.30", "integrity": "sha512-A1GJXBBf7G8tgn1YQCaGX45T3iGCzW+67lEOZ9dz6bXhaOc1CZa1pjM+FgmE0DuJjKVLkCwj4eV9A+SqGt9Tbw==", @@ -2008,8 +1932,9 @@ } }, "node_modules/@types/node": { - "version": "16.11.19", - "integrity": "sha512-BPAcfDPoHlRQNKktbsbnpACGdypPFBuX4xQlsWDE7B8XXcfII+SpOLay3/qZmCLb39kV5S1RTYwXdkx2lwLYng==" + "version": "16.18.51", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.51.tgz", + "integrity": "sha512-LKA7ZhY30I8PiUOzBzhtnIULQTACpiEpPXLiYMWyS+tPAORf+rmXUadHZXB/KFrFyMjeHeKc1GFvLd+3f7LE3w==" }, "node_modules/@types/node-cron": { "version": "3.0.2", @@ -2920,6 +2845,14 @@ } ] }, + "node_modules/cargo-cp-artifact": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/cargo-cp-artifact/-/cargo-cp-artifact-0.1.8.tgz", + "integrity": "sha512-3j4DaoTrsCD1MRkTF2Soacii0Nx7UHCce0EwUf4fHnggwiE4fbmF2AbnfzayR36DF8KGadfh7M/Yfy625kgPlA==", + "bin": { + "cargo-cp-artifact": "bin/cargo-cp-artifact.js" + } + }, "node_modules/catharsis": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.9.0.tgz", @@ -2991,6 +2924,11 @@ "fsevents": "~2.3.2" } }, + "node_modules/chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" + }, "node_modules/ci-info": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.3.2.tgz", @@ -3314,12 +3252,34 @@ } } }, + "node_modules/decompress-response": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "dependencies": { + "mimic-response": "^3.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/dedent": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", "integrity": "sha512-Q6fKUPqnAHAyhiUgFU7BUzLiv0kd8saH9al7tnu5Q/okj6dnupxyTgFIBjVzJATdfIAm9NAsvXNzjaKa+bxVyA==", "dev": true }, + "node_modules/deep-extend": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", + "engines": { + "node": ">=4.0.0" + } + }, "node_modules/deep-is": { "version": "0.1.4", "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==" @@ -3373,6 +3333,14 @@ "npm": "1.2.8000 || >= 1.4.16" } }, + "node_modules/detect-libc": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.2.tgz", + "integrity": "sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw==", + "engines": { + "node": ">=8" + } + }, "node_modules/detect-newline": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", @@ -4192,6 +4160,14 @@ "node": ">= 0.8.0" } }, + "node_modules/expand-template": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", + "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==", + "engines": { + "node": ">=6" + } + }, "node_modules/expect": { "version": "29.3.1", "resolved": "https://registry.npmjs.org/expect/-/expect-29.3.1.tgz", @@ -4456,6 +4432,11 @@ "node": ">= 0.6" } }, + "node_modules/fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, "node_modules/fs.realpath": { "version": "1.0.0", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" @@ -4597,6 +4578,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/github-from-package": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", + "integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==" + }, "node_modules/glob": { "version": "7.2.0", "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", @@ -5031,6 +5017,11 @@ "version": "2.0.4", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, + "node_modules/ini": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" + }, "node_modules/internal-slot": { "version": "1.0.3", "integrity": "sha512-O0DB1JC/sPyZl7cIo78n5dR7eUSwwpYPiXRhTzNxZVAMUuB8vlnRFyLxdrVToks6XPLVnFfbzaVd5WLjhgg+vA==", @@ -6593,6 +6584,17 @@ "node": ">=6" } }, + "node_modules/mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/min-indent": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", @@ -6628,6 +6630,11 @@ "node": ">=10" } }, + "node_modules/mkdirp-classic": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" + }, "node_modules/moment": { "version": "2.29.4", "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", @@ -6685,6 +6692,11 @@ "version": "2.14.2", "integrity": "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ==" }, + "node_modules/napi-build-utils": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", + "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==" + }, "node_modules/natural-compare": { "version": "1.4.0", "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", @@ -6703,6 +6715,17 @@ "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", "dev": true }, + "node_modules/node-abi": { + "version": "3.47.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.47.0.tgz", + "integrity": "sha512-2s6B2CWZM//kPgwnuI0KrYwNjfdByE25zvAaEpq9IH4zcNsarH8Ihu/UuX6XMPEogDAxkuUFeZn60pXNHAqn3A==", + "dependencies": { + "semver": "^7.3.5" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/node-cron": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/node-cron/-/node-cron-3.0.2.tgz", @@ -7376,6 +7399,31 @@ "node": ">=4" } }, + "node_modules/prebuild-install": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.1.tgz", + "integrity": "sha512-jAXscXWMcCK8GgCoHOfIr0ODh5ai8mj63L2nWrjuAgXE6tDyYGnx4/8o/rCgU+B4JSyZBKbeZqzhtwtC3ovxjw==", + "dependencies": { + "detect-libc": "^2.0.0", + "expand-template": "^2.0.3", + "github-from-package": "0.0.0", + "minimist": "^1.2.3", + "mkdirp-classic": "^0.5.3", + "napi-build-utils": "^1.0.1", + "node-abi": "^3.3.0", + "pump": "^3.0.0", + "rc": "^1.2.7", + "simple-get": "^4.0.0", + "tar-fs": "^2.0.0", + "tunnel-agent": "^0.6.0" + }, + "bin": { + "prebuild-install": "bin.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/prelude-ls": { "version": "1.2.1", "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", @@ -7652,6 +7700,28 @@ "node": ">= 0.8" } }, + "node_modules/rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "dependencies": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "bin": { + "rc": "cli.js" + } + }, + "node_modules/rc/node_modules/strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/react-is": { "version": "18.2.0", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", @@ -8072,6 +8142,49 @@ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", "dev": true }, + "node_modules/simple-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", + "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/simple-get": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", + "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "decompress-response": "^6.0.0", + "once": "^1.3.1", + "simple-concat": "^1.0.0" + } + }, "node_modules/simple-swizzle": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", @@ -8414,6 +8527,32 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/tar-fs": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", + "integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==", + "dependencies": { + "chownr": "^1.1.1", + "mkdirp-classic": "^0.5.2", + "pump": "^3.0.0", + "tar-stream": "^2.1.4" + } + }, + "node_modules/tar-stream": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "dependencies": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/teeny-request": { "version": "8.0.3", "resolved": "https://registry.npmjs.org/teeny-request/-/teeny-request-8.0.3.tgz", @@ -8664,6 +8803,17 @@ "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" } }, + "node_modules/tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", + "dependencies": { + "safe-buffer": "^5.0.1" + }, + "engines": { + "node": "*" + } + }, "node_modules/type-check": { "version": "0.4.0", "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", @@ -8713,10 +8863,9 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" }, "node_modules/typescript": { - "version": "4.8.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.2.tgz", - "integrity": "sha512-C0I1UsrrDHo2fYI5oaCGbSejwX4ch+9Y5jTQELvovfmFkK3HHSZJB8MSJcWLmCUBzQBchCrZ9rMRV6GuNrvGtw==", - "dev": true, + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -8765,6 +8914,11 @@ "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.6.tgz", "integrity": "sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A==" }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + }, "node_modules/unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", @@ -9853,25 +10007,6 @@ "big-integer": "^1.6.51" } }, - "@iota/crypto.js-stardust": { - "version": "npm:@iota/crypto.js@2.0.0-rc.2", - "resolved": "https://registry.npmjs.org/@iota/crypto.js/-/crypto.js-2.0.0-rc.2.tgz", - "integrity": "sha512-gydR6weJ4g8W67yGffpYd3N7Bt83pgqqOCLBM1SV6+wztNuwMYcO8V/yMTyqI9P4Er426QB83cTiwdaOJzs/zQ==", - "requires": { - "@iota/util.js": "2.0.0-rc.2", - "big-integer": "^1.6.51" - }, - "dependencies": { - "@iota/util.js": { - "version": "2.0.0-rc.2", - "resolved": "https://registry.npmjs.org/@iota/util.js/-/util.js-2.0.0-rc.2.tgz", - "integrity": "sha512-c6n5LPiimwkz5aCKsMjRg3GKWzcK+zELmJK1AVaziLneJ8BsdZBKvWJyQGNqjREQjOhRaixizmZc3nGuihldnQ==", - "requires": { - "big-integer": "^1.6.51" - } - } - } - }, "@iota/curl": { "version": "1.0.0-beta.19", "integrity": "sha512-bUr6VW8lP1XYhAkzUacc8U28qO2Ibdl6R5CSF7N34GgjO2sEkn4DnlzL1VU8cCv+8rfBlZ9qIvYGzklic49JJw==" @@ -9922,36 +10057,6 @@ "node-fetch": "2.6.7" } }, - "@iota/iota.js-stardust": { - "version": "npm:@iota/iota.js@2.0.0-rc.4", - "resolved": "https://registry.npmjs.org/@iota/iota.js/-/iota.js-2.0.0-rc.4.tgz", - "integrity": "sha512-fXlM6Q/jSQG0dEXULugbgE9ZT9R5nN3G8oz71Ti6vhbxL1lbQN4M/IzddGg+cn2NfKezNcdMjs8xBbOOBJveCQ==", - "requires": { - "@iota/crypto.js": "2.0.0-rc.2", - "@iota/util.js": "2.0.0-rc.2", - "big-integer": "^1.6.51", - "node-fetch": "2.6.7" - }, - "dependencies": { - "@iota/crypto.js": { - "version": "2.0.0-rc.2", - "resolved": "https://registry.npmjs.org/@iota/crypto.js/-/crypto.js-2.0.0-rc.2.tgz", - "integrity": "sha512-gydR6weJ4g8W67yGffpYd3N7Bt83pgqqOCLBM1SV6+wztNuwMYcO8V/yMTyqI9P4Er426QB83cTiwdaOJzs/zQ==", - "requires": { - "@iota/util.js": "2.0.0-rc.2", - "big-integer": "^1.6.51" - } - }, - "@iota/util.js": { - "version": "2.0.0-rc.2", - "resolved": "https://registry.npmjs.org/@iota/util.js/-/util.js-2.0.0-rc.2.tgz", - "integrity": "sha512-c6n5LPiimwkz5aCKsMjRg3GKWzcK+zELmJK1AVaziLneJ8BsdZBKvWJyQGNqjREQjOhRaixizmZc3nGuihldnQ==", - "requires": { - "big-integer": "^1.6.51" - } - } - } - }, "@iota/kerl": { "version": "1.0.0-beta.30", "integrity": "sha512-vVx7916Sb1fZWV9FmsFUUoxrgBbxeK4lc2Y0NYIw4OnU/Q6NsTu+GEXGNMArp97daU4UQhbceE7DNTj9HOICfQ==", @@ -9983,50 +10088,33 @@ } } }, - "@iota/mqtt.js-stardust": { - "version": "npm:@iota/mqtt.js@2.0.0-rc.3", - "resolved": "https://registry.npmjs.org/@iota/mqtt.js/-/mqtt.js-2.0.0-rc.3.tgz", - "integrity": "sha512-uS8EtyY78t+periL8tp41HxaI0vkQkQ7jfrW4W2Qyb1YhaTCsGfvfV1RFr8S0LSks6f7TCRk79UpA+Ys8b1tjw==", + "@iota/pad": { + "version": "1.0.0-beta.30", + "integrity": "sha512-fnhPMPul18WunLq9Ni4rxzBFmhna6eaG8WroDg6GdQqSK/eN62uFHV8tpspJHXuCqwgCUVp6NpuUna7+B2OV9g==" + }, + "@iota/sdk": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@iota/sdk/-/sdk-1.1.1.tgz", + "integrity": "sha512-63WcGZGwlIwZpIhk+F+ozxm9miRy+eDmCoyIS/8actUNlH8zG5DXmjtWqxZx89se9UEAZyr4eZH7JJlwfkieqQ==", "requires": { - "@iota/iota.js": "2.0.0-rc.3", - "@iota/util.js": "2.0.0-rc.1", - "mqtt": "^4.3.7" + "@types/node": "^18.15.12", + "cargo-cp-artifact": "^0.1.6", + "class-transformer": "^0.5.1", + "prebuild-install": "^7.1.1", + "reflect-metadata": "^0.1.13", + "typescript": "^4.9.4" }, "dependencies": { - "@iota/crypto.js": { - "version": "2.0.0-rc.1", - "resolved": "https://registry.npmjs.org/@iota/crypto.js/-/crypto.js-2.0.0-rc.1.tgz", - "integrity": "sha512-gidDFvbIcthVIaxqntffUCFHHNZNhu1e3zjwt6yaYLeuqJcc2AXPv/UF8Lz9Mfkw9aSM8xVUwo8/uYDkvs2eOQ==", - "requires": { - "@iota/util.js": "2.0.0-rc.1", - "big-integer": "^1.6.51" - } - }, - "@iota/iota.js": { - "version": "2.0.0-rc.3", - "resolved": "https://registry.npmjs.org/@iota/iota.js/-/iota.js-2.0.0-rc.3.tgz", - "integrity": "sha512-lrnmFDmI3vWscJAGzka2VOpi+x/kH1xMwvLgPOQ2WlyKOouLv/gmjc6S0K3TYCxKPRgw6DsVYMkFsK4GXXV5BA==", - "requires": { - "@iota/crypto.js": "2.0.0-rc.1", - "@iota/util.js": "2.0.0-rc.1", - "big-integer": "^1.6.51", - "node-fetch": "2.6.7" - } - }, - "@iota/util.js": { - "version": "2.0.0-rc.1", - "resolved": "https://registry.npmjs.org/@iota/util.js/-/util.js-2.0.0-rc.1.tgz", - "integrity": "sha512-tG+qsCHhztGuthUPqLlckih3Ump+IcKCDEl+Sb7ACOOR7JM73KOGaRud8NlLu4GNqQyQh7s9Gn2GRkXBJ1apiA==", + "@types/node": { + "version": "18.18.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.18.7.tgz", + "integrity": "sha512-bw+lEsxis6eqJYW8Ql6+yTqkE6RuFtsQPSe5JxXbqYRFQEER5aJA9a5UH9igqDWm3X4iLHIKOHlnAXLM4mi7uQ==", "requires": { - "big-integer": "^1.6.51" + "undici-types": "~5.26.4" } } } }, - "@iota/pad": { - "version": "1.0.0-beta.30", - "integrity": "sha512-fnhPMPul18WunLq9Ni4rxzBFmhna6eaG8WroDg6GdQqSK/eN62uFHV8tpspJHXuCqwgCUVp6NpuUna7+B2OV9g==" - }, "@iota/sdk-wasm": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/@iota/sdk-wasm/-/sdk-wasm-1.0.5.tgz", @@ -10080,14 +10168,6 @@ "big-integer": "^1.6.51" } }, - "@iota/util.js-stardust": { - "version": "npm:@iota/util.js@2.0.0-rc.2", - "resolved": "https://registry.npmjs.org/@iota/util.js/-/util.js-2.0.0-rc.2.tgz", - "integrity": "sha512-c6n5LPiimwkz5aCKsMjRg3GKWzcK+zELmJK1AVaziLneJ8BsdZBKvWJyQGNqjREQjOhRaixizmZc3nGuihldnQ==", - "requires": { - "big-integer": "^1.6.51" - } - }, "@iota/validators": { "version": "1.0.0-beta.30", "integrity": "sha512-A1GJXBBf7G8tgn1YQCaGX45T3iGCzW+67lEOZ9dz6bXhaOc1CZa1pjM+FgmE0DuJjKVLkCwj4eV9A+SqGt9Tbw==", @@ -10735,8 +10815,9 @@ } }, "@types/node": { - "version": "16.11.19", - "integrity": "sha512-BPAcfDPoHlRQNKktbsbnpACGdypPFBuX4xQlsWDE7B8XXcfII+SpOLay3/qZmCLb39kV5S1RTYwXdkx2lwLYng==" + "version": "16.18.51", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.51.tgz", + "integrity": "sha512-LKA7ZhY30I8PiUOzBzhtnIULQTACpiEpPXLiYMWyS+tPAORf+rmXUadHZXB/KFrFyMjeHeKc1GFvLd+3f7LE3w==" }, "@types/node-cron": { "version": "3.0.2", @@ -11369,6 +11450,11 @@ "integrity": "sha512-zBUoFU0ZcxpvSt9IU66dXVT/3ctO1cy4y9cscs1szkPlcWb6pasYM144GqrUygUbT+k7cmUCW61cvskjcv0enQ==", "dev": true }, + "cargo-cp-artifact": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/cargo-cp-artifact/-/cargo-cp-artifact-0.1.8.tgz", + "integrity": "sha512-3j4DaoTrsCD1MRkTF2Soacii0Nx7UHCce0EwUf4fHnggwiE4fbmF2AbnfzayR36DF8KGadfh7M/Yfy625kgPlA==" + }, "catharsis": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.9.0.tgz", @@ -11419,6 +11505,11 @@ "readdirp": "~3.6.0" } }, + "chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" + }, "ci-info": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.3.2.tgz", @@ -11688,12 +11779,25 @@ "ms": "2.1.2" } }, + "decompress-response": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "requires": { + "mimic-response": "^3.1.0" + } + }, "dedent": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", "integrity": "sha512-Q6fKUPqnAHAyhiUgFU7BUzLiv0kd8saH9al7tnu5Q/okj6dnupxyTgFIBjVzJATdfIAm9NAsvXNzjaKa+bxVyA==", "dev": true }, + "deep-extend": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==" + }, "deep-is": { "version": "0.1.4", "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==" @@ -11728,6 +11832,11 @@ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==" }, + "detect-libc": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.2.tgz", + "integrity": "sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw==" + }, "detect-newline": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", @@ -12329,6 +12438,11 @@ "integrity": "sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==", "dev": true }, + "expand-template": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", + "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==" + }, "expect": { "version": "29.3.1", "resolved": "https://registry.npmjs.org/expect/-/expect-29.3.1.tgz", @@ -12561,6 +12675,11 @@ "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==" }, + "fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, "fs.realpath": { "version": "1.0.0", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" @@ -12656,6 +12775,11 @@ "get-intrinsic": "^1.1.1" } }, + "github-from-package": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", + "integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==" + }, "glob": { "version": "7.2.0", "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", @@ -12968,6 +13092,11 @@ "version": "2.0.4", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, + "ini": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" + }, "internal-slot": { "version": "1.0.3", "integrity": "sha512-O0DB1JC/sPyZl7cIo78n5dR7eUSwwpYPiXRhTzNxZVAMUuB8vlnRFyLxdrVToks6XPLVnFfbzaVd5WLjhgg+vA==", @@ -14159,6 +14288,11 @@ "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", "dev": true }, + "mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==" + }, "min-indent": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", @@ -14182,6 +14316,11 @@ "version": "1.0.4", "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==" }, + "mkdirp-classic": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" + }, "moment": { "version": "2.29.4", "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", @@ -14228,6 +14367,11 @@ "version": "2.14.2", "integrity": "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ==" }, + "napi-build-utils": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", + "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==" + }, "natural-compare": { "version": "1.4.0", "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", @@ -14243,6 +14387,14 @@ "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", "dev": true }, + "node-abi": { + "version": "3.47.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.47.0.tgz", + "integrity": "sha512-2s6B2CWZM//kPgwnuI0KrYwNjfdByE25zvAaEpq9IH4zcNsarH8Ihu/UuX6XMPEogDAxkuUFeZn60pXNHAqn3A==", + "requires": { + "semver": "^7.3.5" + } + }, "node-cron": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/node-cron/-/node-cron-3.0.2.tgz", @@ -14729,6 +14881,25 @@ "integrity": "sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==", "dev": true }, + "prebuild-install": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.1.tgz", + "integrity": "sha512-jAXscXWMcCK8GgCoHOfIr0ODh5ai8mj63L2nWrjuAgXE6tDyYGnx4/8o/rCgU+B4JSyZBKbeZqzhtwtC3ovxjw==", + "requires": { + "detect-libc": "^2.0.0", + "expand-template": "^2.0.3", + "github-from-package": "0.0.0", + "minimist": "^1.2.3", + "mkdirp-classic": "^0.5.3", + "napi-build-utils": "^1.0.1", + "node-abi": "^3.3.0", + "pump": "^3.0.0", + "rc": "^1.2.7", + "simple-get": "^4.0.0", + "tar-fs": "^2.0.0", + "tunnel-agent": "^0.6.0" + } + }, "prelude-ls": { "version": "1.2.1", "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", @@ -14933,6 +15104,24 @@ } } }, + "rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "requires": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "dependencies": { + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==" + } + } + }, "react-is": { "version": "18.2.0", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", @@ -15241,6 +15430,21 @@ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", "dev": true }, + "simple-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", + "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==" + }, + "simple-get": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", + "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", + "requires": { + "decompress-response": "^6.0.0", + "once": "^1.3.1", + "simple-concat": "^1.0.0" + } + }, "simple-swizzle": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", @@ -15514,6 +15718,29 @@ "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", "dev": true }, + "tar-fs": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", + "integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==", + "requires": { + "chownr": "^1.1.1", + "mkdirp-classic": "^0.5.2", + "pump": "^3.0.0", + "tar-stream": "^2.1.4" + } + }, + "tar-stream": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "requires": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + } + }, "teeny-request": { "version": "8.0.3", "resolved": "https://registry.npmjs.org/teeny-request/-/teeny-request-8.0.3.tgz", @@ -15703,6 +15930,14 @@ "tslib": "^1.8.1" } }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", + "requires": { + "safe-buffer": "^5.0.1" + } + }, "type-check": { "version": "0.4.0", "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", @@ -15737,10 +15972,9 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" }, "typescript": { - "version": "4.8.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.2.tgz", - "integrity": "sha512-C0I1UsrrDHo2fYI5oaCGbSejwX4ch+9Y5jTQELvovfmFkK3HHSZJB8MSJcWLmCUBzQBchCrZ9rMRV6GuNrvGtw==", - "dev": true + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==" }, "uc.micro": { "version": "1.0.6", @@ -15773,6 +16007,11 @@ "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.6.tgz", "integrity": "sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A==" }, + "undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + }, "unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", diff --git a/api/package.json b/api/package.json index 05cfab18d..e13687860 100644 --- a/api/package.json +++ b/api/package.json @@ -1,7 +1,7 @@ { "name": "explorer-api", "description": "API for Tangle Explorer", - "version": "3.2.0", + "version": "3.3.0", "author": "Martyn Janes ", "repository": { "type": "git", @@ -22,22 +22,19 @@ "start": "node ./dist/index" }, "engines": { - "node": ">=14 <=16.16" + "node": ">=14 <=16.20" }, "dependencies": { "@google-cloud/logging-winston": "^5.3.0", "@iota/core": "^1.0.0-beta.30", "@iota/crypto.js": "^1.8.6", - "@iota/crypto.js-stardust": "npm:@iota/crypto.js@2.0.0-rc.2", "@iota/identity-wasm": "^0.5.0-dev.6", "@iota/identity-wasm-0.4": "npm:@iota/identity-wasm@^0.4.3", "@iota/identity-wasm-0.7": "npm:@iota/identity-wasm@^0.7.0-alpha.6", "@iota/iota.js-chrysalis": "npm:@iota/iota.js@^1.8.6", - "@iota/iota.js-stardust": "npm:@iota/iota.js@2.0.0-rc.4", + "@iota/sdk": "1.1.1", "@iota/mqtt.js": "^1.8.6", - "@iota/mqtt.js-stardust": "npm:@iota/mqtt.js@2.0.0-rc.3", "@iota/util.js": "^1.8.6", - "@iota/util.js-stardust": "npm:@iota/util.js@2.0.0-rc.2", "@iota/validators": "^1.0.0-beta.30", "@types/moment": "^2.13.0", "@types/node-cron": "^3.0.2", @@ -63,7 +60,7 @@ "@types/express": "^4.17.13", "@types/jest": "^29.2.3", "@types/jszip": "^3.4.1", - "@types/node": "^16.10.3", + "@types/node": "^16.18.51", "@types/uuid": "^8.3.1", "@types/winston": "^2.4.4", "@typescript-eslint/eslint-plugin": "^5.36.0", diff --git a/api/src/initServices.ts b/api/src/initServices.ts index 743079539..0344ecd6e 100644 --- a/api/src/initServices.ts +++ b/api/src/initServices.ts @@ -1,5 +1,5 @@ import { MqttClient as ChrysalisMqttClient } from "@iota/mqtt.js"; -import { MqttClient as StardustMqttClient } from "@iota/mqtt.js-stardust"; +import { Client as StardustMqttClient } from "@iota/sdk"; import { ServiceFactory } from "./factories/serviceFactory"; import logger from "./logger"; import { IConfiguration } from "./models/configuration/IConfiguration"; @@ -169,8 +169,8 @@ function initStardustServices(networkConfig: INetwork): void { ); ServiceFactory.register( - `mqtt-${networkConfig.network}`, () => new StardustMqttClient( - networkConfig.feedEndpoint.split(";")) + `mqtt-${networkConfig.network}`, + () => new StardustMqttClient({ nodes: [networkConfig.feedEndpoint], brokerOptions: { useWs: true } }) ); ServiceFactory.register( diff --git a/api/src/models/api/stardust/IAddressDetailsResponse.ts b/api/src/models/api/stardust/IAddressDetailsResponse.ts index 2eaaf01b2..98d8a74da 100644 --- a/api/src/models/api/stardust/IAddressDetailsResponse.ts +++ b/api/src/models/api/stardust/IAddressDetailsResponse.ts @@ -1,9 +1,9 @@ -import { IOutputResponse } from "@iota/iota.js-stardust"; +import { OutputResponse } from "@iota/sdk"; import { IResponse } from "../IResponse"; export interface IAddressDetailsResponse extends IResponse { /** * The outputs data. */ - outputs?: IOutputResponse[]; + outputs?: OutputResponse[]; } diff --git a/api/src/models/api/stardust/IAliasResponse.ts b/api/src/models/api/stardust/IAliasResponse.ts index 96f4c763d..1c28fff93 100644 --- a/api/src/models/api/stardust/IAliasResponse.ts +++ b/api/src/models/api/stardust/IAliasResponse.ts @@ -1,10 +1,10 @@ -import { IOutputResponse } from "@iota/iota.js-stardust"; +import { OutputResponse } from "@iota/sdk"; import { IResponse } from "./IResponse"; export interface IAliasResponse extends IResponse { /** * The alias details response. */ - aliasDetails?: IOutputResponse; + aliasDetails?: OutputResponse; } diff --git a/api/src/models/api/stardust/IBlockDetailsResponse.ts b/api/src/models/api/stardust/IBlockDetailsResponse.ts index 1b24e448c..95c0ae292 100644 --- a/api/src/models/api/stardust/IBlockDetailsResponse.ts +++ b/api/src/models/api/stardust/IBlockDetailsResponse.ts @@ -1,4 +1,4 @@ -import { IBlockMetadata } from "@iota/iota.js-stardust"; +import { IBlockMetadata } from "@iota/sdk"; import { IResponse } from "../IResponse"; export interface IBlockDetailsResponse extends IResponse { diff --git a/api/src/models/api/stardust/IBlockResponse.ts b/api/src/models/api/stardust/IBlockResponse.ts index 3cc57a19b..322517a85 100644 --- a/api/src/models/api/stardust/IBlockResponse.ts +++ b/api/src/models/api/stardust/IBlockResponse.ts @@ -1,10 +1,10 @@ -import { IBlock } from "@iota/iota.js-stardust"; +import { Block } from "@iota/sdk"; import { IResponse } from "../IResponse"; export interface IBlockResponse extends IResponse { /** * The deserialized block. */ - block?: IBlock; + block?: Block; } diff --git a/api/src/models/api/stardust/INodeInfoResponse.ts b/api/src/models/api/stardust/INodeInfoResponse.ts index 7f3b3e629..ea5978e9e 100644 --- a/api/src/models/api/stardust/INodeInfoResponse.ts +++ b/api/src/models/api/stardust/INodeInfoResponse.ts @@ -1,4 +1,4 @@ -import { INodeInfoBaseToken, IRent } from "@iota/iota.js-stardust"; +import { INodeInfoBaseToken, IRent } from "@iota/sdk"; import { IResponse } from "../IResponse"; /** diff --git a/api/src/models/api/stardust/IOutputDetailsResponse.ts b/api/src/models/api/stardust/IOutputDetailsResponse.ts index cc2a17557..7cd3aa561 100644 --- a/api/src/models/api/stardust/IOutputDetailsResponse.ts +++ b/api/src/models/api/stardust/IOutputDetailsResponse.ts @@ -1,9 +1,9 @@ -import { IOutputResponse } from "@iota/iota.js-stardust"; +import { OutputResponse } from "@iota/sdk"; import { IResponse } from "./IResponse"; export interface IOutputDetailsResponse extends IResponse { /** * The output data. */ - output?: IOutputResponse; + output?: OutputResponse; } diff --git a/api/src/models/api/stardust/ISearchResponse.ts b/api/src/models/api/stardust/ISearchResponse.ts index 4fcbf0a00..c00dba761 100644 --- a/api/src/models/api/stardust/ISearchResponse.ts +++ b/api/src/models/api/stardust/ISearchResponse.ts @@ -1,4 +1,4 @@ -import { IBlock, IOutputResponse } from "@iota/iota.js-stardust"; +import { Block, OutputResponse } from "@iota/sdk"; import { IResponse } from "../IResponse"; import { IBech32AddressDetails } from "./IBech32AddressDetails"; import { ITaggedOutputsResponse } from "./ITaggedOutputsResponse"; @@ -8,12 +8,12 @@ export interface ISearchResponse extends IResponse { /** * Block if it was found. */ - block?: IBlock; + block?: Block; /** * Transaction included block. */ - transactionBlock?: IBlock; + transactionBlock?: Block; /** * Address details. @@ -23,7 +23,7 @@ export interface ISearchResponse extends IResponse { /** * Output if it was found (block will also be populated). */ - output?: IOutputResponse; + output?: OutputResponse; /** * Basic and/or Nft tagged output ids. diff --git a/api/src/models/api/stardust/ITransactionDetailsResponse.ts b/api/src/models/api/stardust/ITransactionDetailsResponse.ts index bae82a221..6d97b28c8 100644 --- a/api/src/models/api/stardust/ITransactionDetailsResponse.ts +++ b/api/src/models/api/stardust/ITransactionDetailsResponse.ts @@ -1,9 +1,9 @@ -import { IBlock } from "@iota/iota.js-stardust"; +import { Block } from "@iota/sdk"; import { IResponse } from "../IResponse"; export interface ITransactionDetailsResponse extends IResponse { /** * Transaction included block. */ - block?: IBlock; + block?: Block; } diff --git a/api/src/models/api/stardust/basic/IBasicOutputsResponse.ts b/api/src/models/api/stardust/basic/IBasicOutputsResponse.ts index 6f5df2109..373201458 100644 --- a/api/src/models/api/stardust/basic/IBasicOutputsResponse.ts +++ b/api/src/models/api/stardust/basic/IBasicOutputsResponse.ts @@ -1,4 +1,4 @@ -import { IOutputsResponse } from "@iota/iota.js-stardust"; +import { IOutputsResponse } from "@iota/sdk"; import { IResponse } from "../../IResponse"; export interface IBasicOutputsResponse extends IResponse { diff --git a/api/src/models/api/stardust/chronicle/IBlockChildrenResponse.ts b/api/src/models/api/stardust/chronicle/IBlockChildrenResponse.ts index 5fcc4532f..97d0dc091 100644 --- a/api/src/models/api/stardust/chronicle/IBlockChildrenResponse.ts +++ b/api/src/models/api/stardust/chronicle/IBlockChildrenResponse.ts @@ -1,4 +1,4 @@ -import { HexEncodedString } from "@iota/iota.js-stardust"; +import { HexEncodedString } from "@iota/sdk"; import { IResponse } from "../../IResponse"; export interface IBlockChildrenResponse extends IResponse { diff --git a/api/src/models/api/stardust/chronicle/IRichestAddressesResponse.ts b/api/src/models/api/stardust/chronicle/IRichestAddressesResponse.ts index 0cf5044fd..4c3e85b48 100644 --- a/api/src/models/api/stardust/chronicle/IRichestAddressesResponse.ts +++ b/api/src/models/api/stardust/chronicle/IRichestAddressesResponse.ts @@ -1,4 +1,4 @@ -import { IResponse } from "@iota/iota.js-stardust"; +import { IResponse } from "@iota/sdk"; export interface IRichAddress { address: string; diff --git a/api/src/models/api/stardust/chronicle/ITokenDistributionResponse.ts b/api/src/models/api/stardust/chronicle/ITokenDistributionResponse.ts index c87d74007..61f69a128 100644 --- a/api/src/models/api/stardust/chronicle/ITokenDistributionResponse.ts +++ b/api/src/models/api/stardust/chronicle/ITokenDistributionResponse.ts @@ -1,4 +1,4 @@ -import { IResponse } from "@iota/iota.js-stardust"; +import { IResponse } from "@iota/sdk"; export interface IDistributionEntry { addressCount: string; diff --git a/api/src/models/api/stardust/feed/IFeedItemMetadata.ts b/api/src/models/api/stardust/feed/IFeedItemMetadata.ts index 00c9105a4..7b1eabb46 100644 --- a/api/src/models/api/stardust/feed/IFeedItemMetadata.ts +++ b/api/src/models/api/stardust/feed/IFeedItemMetadata.ts @@ -1,4 +1,4 @@ -import { ConflictReason } from "@iota/iota.js-stardust"; +import { ConflictReason } from "@iota/sdk"; export interface IFeedItemMetadata { /** diff --git a/api/src/models/api/stardust/feed/IFeedSubscriptionItem.ts b/api/src/models/api/stardust/feed/IFeedSubscriptionItem.ts deleted file mode 100644 index 05569d151..000000000 --- a/api/src/models/api/stardust/feed/IFeedSubscriptionItem.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { IFeedItemMetadata } from "./IFeedItemMetadata"; - -export interface IFeedSubscriptionItem { - /** - * The subscription id created. - */ - subscriptionId: string; - - /** - * The latest items. - */ - items: string[]; - - /** - * The items metadata. - */ - itemsMetadata: { - [id: string]: IFeedItemMetadata; - }; -} diff --git a/api/src/models/api/stardust/feed/IFeedUpdate.ts b/api/src/models/api/stardust/feed/IFeedUpdate.ts index a93305a60..1618e5b14 100644 --- a/api/src/models/api/stardust/feed/IFeedUpdate.ts +++ b/api/src/models/api/stardust/feed/IFeedUpdate.ts @@ -1,7 +1,7 @@ -import { IMilestonePayload } from "@iota/iota.js-stardust"; +import { Block, MilestonePayload } from "@iota/sdk"; import { IFeedItemMetadata } from "./IFeedItemMetadata"; -type IFeedBlockUpdate = string; +type IFeedBlockUpdate = Block; interface IFeedBlockMetadataUpdate { blockId: string; @@ -12,7 +12,7 @@ interface IFeedMilestoneUpdate { blockId: string; milestoneId: string; milestoneIndex: number; - payload: IMilestonePayload; + payload: MilestonePayload; timestamp: number; } diff --git a/api/src/models/api/stardust/foundry/IFoundriesResponse.ts b/api/src/models/api/stardust/foundry/IFoundriesResponse.ts index 0aa0359f6..d3606cb13 100644 --- a/api/src/models/api/stardust/foundry/IFoundriesResponse.ts +++ b/api/src/models/api/stardust/foundry/IFoundriesResponse.ts @@ -1,4 +1,4 @@ -import { IOutputsResponse } from "@iota/iota.js-stardust"; +import { IOutputsResponse } from "@iota/sdk"; import { IResponse } from "../IResponse"; export interface IFoundriesResponse extends IResponse { diff --git a/api/src/models/api/stardust/foundry/IFoundryResponse.ts b/api/src/models/api/stardust/foundry/IFoundryResponse.ts index d64431ae0..8384e0c33 100644 --- a/api/src/models/api/stardust/foundry/IFoundryResponse.ts +++ b/api/src/models/api/stardust/foundry/IFoundryResponse.ts @@ -1,10 +1,10 @@ -import { IOutputResponse } from "@iota/iota.js-stardust"; +import { OutputResponse } from "@iota/sdk"; import { IResponse } from "../IResponse"; export interface IFoundryResponse extends IResponse { /** * The foundry details response. */ - foundryDetails?: IOutputResponse; + foundryDetails?: OutputResponse; } diff --git a/api/src/models/api/stardust/milestone/IMilestoneDetailsResponse.ts b/api/src/models/api/stardust/milestone/IMilestoneDetailsResponse.ts index 3503ad772..958438c2d 100644 --- a/api/src/models/api/stardust/milestone/IMilestoneDetailsResponse.ts +++ b/api/src/models/api/stardust/milestone/IMilestoneDetailsResponse.ts @@ -1,4 +1,4 @@ -import { IMilestonePayload } from "@iota/iota.js-stardust"; +import { MilestonePayload } from "@iota/sdk"; import { IResponse } from "../../IResponse"; export interface IMilestoneDetailsResponse extends IResponse { @@ -13,5 +13,5 @@ export interface IMilestoneDetailsResponse extends IResponse { /** * The milestone data. */ - milestone?: IMilestonePayload; + milestone?: MilestonePayload; } diff --git a/api/src/models/api/stardust/nft/INftDetailsResponse.ts b/api/src/models/api/stardust/nft/INftDetailsResponse.ts index ccf60a95d..bf179c2ca 100644 --- a/api/src/models/api/stardust/nft/INftDetailsResponse.ts +++ b/api/src/models/api/stardust/nft/INftDetailsResponse.ts @@ -1,10 +1,10 @@ -import { IOutputResponse } from "@iota/iota.js-stardust"; +import { OutputResponse } from "@iota/sdk"; import { IResponse } from "../IResponse"; export interface INftDetailsResponse extends IResponse { /** * The nft details response. */ - nftDetails?: IOutputResponse; + nftDetails?: OutputResponse; } diff --git a/api/src/models/api/stardust/nft/INftOutputsResponse.ts b/api/src/models/api/stardust/nft/INftOutputsResponse.ts index 99ef62c9a..3feb56325 100644 --- a/api/src/models/api/stardust/nft/INftOutputsResponse.ts +++ b/api/src/models/api/stardust/nft/INftOutputsResponse.ts @@ -1,4 +1,4 @@ -import { IOutputsResponse } from "@iota/iota.js-stardust"; +import { IOutputsResponse } from "@iota/sdk"; import { IResponse } from "../../IResponse"; export interface INftOutputsResponse extends IResponse { diff --git a/api/src/routes/networks/get.ts b/api/src/routes/networks/get.ts index 35f59ee80..19a823e45 100644 --- a/api/src/routes/networks/get.ts +++ b/api/src/routes/networks/get.ts @@ -15,10 +15,10 @@ export async function get(_: IConfiguration): Promise { return { networks: all - // Only return networks that are not hidden + // Only return networks that are not hidden and enabled // and copy the fields needed by the client // as we don't want to expose all the information - .filter(n => !n.isHidden).map(n => ({ + .filter(n => !n.isHidden && n.isEnabled).map(n => ({ network: n.network, label: n.label, protocolVersion: n.protocolVersion, diff --git a/api/src/routes/stardust/output/tagged/get.ts b/api/src/routes/stardust/output/tagged/get.ts index 6e927802a..173978e29 100644 --- a/api/src/routes/stardust/output/tagged/get.ts +++ b/api/src/routes/stardust/output/tagged/get.ts @@ -1,4 +1,3 @@ -import { Converter } from "@iota/util.js-stardust"; import { ServiceFactory } from "../../../../factories/serviceFactory"; import { IBasicOutputsResponse } from "../../../../models/api/stardust/basic/IBasicOutputsResponse"; import { ITaggedOutputsRequest } from "../../../../models/api/stardust/ITaggedOutputsRequest"; @@ -6,6 +5,7 @@ import { INftOutputsResponse } from "../../../../models/api/stardust/nft/INftOut import { IConfiguration } from "../../../../models/configuration/IConfiguration"; import { STARDUST } from "../../../../models/db/protocolVersion"; import { NetworkService } from "../../../../services/networkService"; +import { Converter } from "../../../../utils/convertUtils"; import { StardustTangleHelper } from "../../../../utils/stardust/stardustTangleHelper"; import { ValidationHelper } from "../../../../utils/validationHelper"; diff --git a/api/src/services/stardust/feed/stardustFeed.ts b/api/src/services/stardust/feed/stardustFeed.ts index 613683697..e03e73cdc 100644 --- a/api/src/services/stardust/feed/stardustFeed.ts +++ b/api/src/services/stardust/feed/stardustFeed.ts @@ -1,11 +1,11 @@ -import { blockIdFromMilestonePayload, IBlockMetadata, milestoneIdFromMilestonePayload } from "@iota/iota.js-stardust"; -import { IMqttClient } from "@iota/mqtt.js-stardust"; -import { Converter } from "@iota/util.js-stardust"; +import { Block, Client, IBlockMetadata, MilestonePayload, Utils } from "@iota/sdk"; +import { ClassConstructor, plainToInstance } from "class-transformer"; import { ServiceFactory } from "../../../factories/serviceFactory"; import logger from "../../../logger"; import { IFeedItemMetadata } from "../../../models/api/stardust/feed/IFeedItemMetadata"; import { IFeedUpdate } from "../../../models/api/stardust/feed/IFeedUpdate"; import { ILatestMilestone } from "../../../models/api/stardust/milestone/ILatestMilestonesResponse"; +import { blockIdFromMilestonePayload } from "../../../utils/stardust/utils"; import { NodeInfoService } from "../nodeInfoService"; const CACHE_TRIM_INTERVAL_MS = 60000; @@ -35,7 +35,7 @@ export class StardustFeed { /** * Mqtt service for data (upstream). */ - private readonly _mqttClient: IMqttClient; + private readonly _mqttClient: Client; /** * The latest milestones. @@ -65,11 +65,10 @@ export class StardustFeed { this.blockSubscribers = {}; this.milestoneSubscribers = {}; this.blockMetadataCache = new Map(); - this._mqttClient = ServiceFactory.get(`mqtt-${networkId}`); + this._mqttClient = ServiceFactory.get(`mqtt-${networkId}`); const nodeInfoService = ServiceFactory.get(`node-info-${networkId}`); if (this._mqttClient && nodeInfoService) { - this._mqttClient.statusChanged(data => logger.debug(`[Mqtt] Stardust status changed (${data.state})`)); const nodeInfo = nodeInfoService.getNodeInfo(); this.networkProtocolVersion = nodeInfo.protocolVersion; @@ -127,55 +126,63 @@ export class StardustFeed { * Connects the callbacks for upstream data. */ private connect() { - this._mqttClient.blocksRaw( - (_: string, block: Uint8Array) => { - const serializedBlock = Converter.bytesToHex(block); - + logger.info("[StardustFeed] Connecting upstream feed!"); + // eslint-disable-next-line no-void + void this._mqttClient.listenMqtt(["blocks"], (_, message) => { + try { + const block: Block = this.parseMqttPayloadMessage(Block, message); const update: Partial = { - block: serializedBlock + block }; // eslint-disable-next-line no-void void this.broadcastBlock(update); - }); - - this._mqttClient.blocksReferenced( - (_: string, metadata: IBlockMetadata) => { - // update cache - let currentEntry = this.blockMetadataCache.get(metadata.blockId) ?? null; - currentEntry = !currentEntry ? { - milestone: metadata.milestoneIndex, - referenced: metadata.referencedByMilestoneIndex, - solid: metadata.isSolid, - conflicting: metadata.ledgerInclusionState === "conflicting", - conflictReason: metadata.conflictReason, - included: metadata.ledgerInclusionState === "included" - } : { - ...currentEntry, - milestone: metadata.milestoneIndex, - referenced: metadata.referencedByMilestoneIndex, - solid: metadata.isSolid, - conflicting: metadata.ledgerInclusionState === "conflicting", - conflictReason: metadata.conflictReason, - included: metadata.ledgerInclusionState === "included" - }; - - this.blockMetadataCache.set(metadata.blockId, currentEntry); - - const update: Partial = { - blockMetadata: { - blockId: metadata.blockId, - metadata: currentEntry - } - }; + } catch { + logger.error("[FeedClient]: Failed broadcasting block downstream."); + } + }); - // eslint-disable-next-line no-void - void this.broadcastBlock(update); - }); + // eslint-disable-next-line no-void + void this._mqttClient.listenMqtt(["block-metadata/referenced"], (_, message) => { + const parsed: { topic: string; payload: string } = JSON.parse(message); + const metadata: IBlockMetadata = JSON.parse(parsed.payload); + // update cache + let currentEntry = this.blockMetadataCache.get(metadata.blockId) ?? null; + currentEntry = !currentEntry ? { + milestone: metadata.milestoneIndex, + referenced: metadata.referencedByMilestoneIndex, + solid: metadata.isSolid, + conflicting: metadata.ledgerInclusionState === "conflicting", + conflictReason: metadata.conflictReason, + included: metadata.ledgerInclusionState === "included" + } : { + ...currentEntry, + milestone: metadata.milestoneIndex, + referenced: metadata.referencedByMilestoneIndex, + solid: metadata.isSolid, + conflicting: metadata.ledgerInclusionState === "conflicting", + conflictReason: metadata.conflictReason, + included: metadata.ledgerInclusionState === "included" + }; + + this.blockMetadataCache.set(metadata.blockId, currentEntry); + + const update: Partial = { + blockMetadata: { + blockId: metadata.blockId, + metadata: currentEntry + } + }; + + // eslint-disable-next-line no-void + void this.broadcastBlock(update); + }); - this._mqttClient.milestone(async (_, milestonePayload) => { + // eslint-disable-next-line no-void + void this._mqttClient.listenMqtt(["milestones"], (_, message) => { try { - const milestoneId = milestoneIdFromMilestonePayload(milestonePayload); + const milestonePayload: MilestonePayload = this.parseMqttPayloadMessage(MilestonePayload, message); + const milestoneId = Utils.milestoneId(milestonePayload); const blockId = blockIdFromMilestonePayload(this.networkProtocolVersion, milestonePayload); const milestoneIndex = milestonePayload.index; const timestamp = milestonePayload.timestamp; @@ -195,8 +202,8 @@ export class StardustFeed { // eslint-disable-next-line no-void void this.broadcastMilestone(update); - } catch (err) { - logger.error(`[FeedClient] Mqtt milestone callback failed: ${err}`); + } catch (err: unknown) { + logger.error(`[FeedClient] Mqtt milestone callback failed: ${JSON.stringify(err)}`); } }); } @@ -263,6 +270,20 @@ export class StardustFeed { } } + private parseMqttPayloadMessage(cls: ClassConstructor, serializedMessage: string): T { + try { + const message: { topic: string; payload: string } = JSON.parse(serializedMessage); + const payload: T = plainToInstance>( + cls, + JSON.parse(message.payload) as Record + ); + + return payload; + } catch (error) { + logger.warn(`[FeedClient] Failed to parse mqtt payload. ${error}`); + } + } + /** * Setup a periodic interval to trim if the cache map is over the max limit. */ diff --git a/api/src/services/stardust/nodeInfoService.ts b/api/src/services/stardust/nodeInfoService.ts index af4ac803d..ceee1ea68 100644 --- a/api/src/services/stardust/nodeInfoService.ts +++ b/api/src/services/stardust/nodeInfoService.ts @@ -1,4 +1,4 @@ -import { INodeInfoBaseToken, IRent, SingleNodeClient } from "@iota/iota.js-stardust"; +import { INodeInfoBaseToken, IRent, Client } from "@iota/sdk"; import { NodeInfoError } from "../../errors/nodeInfoError"; import { INetwork } from "../../models/db/INetwork"; @@ -53,13 +53,13 @@ export class NodeInfoService { public init(): void { const endpoint = this._network.provider; - const apiClient = new SingleNodeClient(endpoint); - apiClient.info().then(nodeInfo => { + const apiClient = new Client({ nodes: [endpoint] }); + apiClient.getInfo().then(response => { this._nodeInfo = { - baseToken: nodeInfo.baseToken, - protocolVersion: nodeInfo.protocol.version, - bech32Hrp: nodeInfo.protocol.bech32Hrp, - rentStructure: nodeInfo.protocol.rentStructure + baseToken: response.nodeInfo.baseToken, + protocolVersion: response.nodeInfo.protocol.version, + bech32Hrp: response.nodeInfo.protocol.bech32Hrp, + rentStructure: response.nodeInfo.protocol.rentStructure }; }).catch(err => { throw new NodeInfoError(`Failed to fetch node info for "${this._network.network}" with error:\n${err}`); diff --git a/api/src/services/stardust/stats/stardustStatsService.ts b/api/src/services/stardust/stats/stardustStatsService.ts index f27f8e804..b49f9e4c7 100644 --- a/api/src/services/stardust/stats/stardustStatsService.ts +++ b/api/src/services/stardust/stats/stardustStatsService.ts @@ -1,5 +1,5 @@ /* eslint-disable no-void */ -import { SingleNodeClient } from "@iota/iota.js-stardust"; +import { Client } from "@iota/sdk"; import logger from "../../../logger"; import { BaseStatsService } from "./baseStatsService"; @@ -13,16 +13,16 @@ export class StardustStatsService extends BaseStatsService { */ protected async updateStatistics(): Promise { try { - const client = new SingleNodeClient(this._networkConfiguration.provider); - const info = await client.info(); + const client = new Client({ nodes: [this._networkConfiguration.provider] }); + const response = await client.getInfo(); - if (info) { + if (response) { this._statistics.push({ - itemsPerSecond: info.metrics.blocksPerSecond, - confirmedItemsPerSecond: info.metrics.referencedBlocksPerSecond, - confirmationRate: info.metrics.referencedRate, - latestMilestoneIndex: info.status.latestMilestone.index, - latestMilestoneIndexTime: info.status.latestMilestone.timestamp * 1000 + itemsPerSecond: response.nodeInfo.metrics.blocksPerSecond, + confirmedItemsPerSecond: response.nodeInfo.metrics.referencedBlocksPerSecond, + confirmationRate: response.nodeInfo.metrics.referencedRate, + latestMilestoneIndex: response.nodeInfo.status.latestMilestone.index, + latestMilestoneIndexTime: response.nodeInfo.status.latestMilestone.timestamp * 1000 }); logger.debug( diff --git a/api/src/utils/chrysalis/chrysalisTangleHelper.ts b/api/src/utils/chrysalis/chrysalisTangleHelper.ts index b5aceaa75..e148e0e2b 100644 --- a/api/src/utils/chrysalis/chrysalisTangleHelper.ts +++ b/api/src/utils/chrysalis/chrysalisTangleHelper.ts @@ -1,12 +1,12 @@ import { Blake2b } from "@iota/crypto.js"; import { Bech32Helper, IAddressOutputsResponse, IMessagesResponse, IMilestoneResponse, IOutputResponse, serializeMessage, SingleNodeClient } from "@iota/iota.js-chrysalis"; import { Converter, WriteStream } from "@iota/util.js"; -import { HexHelper } from "@iota/util.js-stardust"; import { IMessageDetailsResponse } from "../../models/api/chrysalis/IMessageDetailsResponse"; import { ISearchResponse } from "../../models/api/chrysalis/ISearchResponse"; import { ITransactionHistoryRequest } from "../../models/api/chrysalis/ITransactionHistoryRequest"; import { ITransactionHistoryResponse } from "../../models/api/chrysalis/ITransactionHistoryResponse"; import { INetwork } from "../../models/db/INetwork"; +import { HexHelper } from "../hexHelper"; import { ExtendedSingleNodeClient } from "./extendedSingleNodeClient"; /** diff --git a/api/src/utils/convertUtils.ts b/api/src/utils/convertUtils.ts new file mode 100644 index 000000000..8f4ddcf63 --- /dev/null +++ b/api/src/utils/convertUtils.ts @@ -0,0 +1,249 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 +/* eslint-disable no-bitwise */ +/* eslint-disable unicorn/number-literal-case */ +/* eslint-disable unicorn/prefer-code-point */ +import { HexHelper } from "./hexHelper"; + +/** + * Convert arrays to and from different formats. + */ +export class Converter { + /** + * Lookup table for encoding. + * @internal + */ + private static ENCODE_LOOKUP: string[] | undefined; + + /** + * Lookup table for decoding. + * @internal + */ + private static DECODE_LOOKUP: number[] | undefined; + + /** + * Encode a raw array to UTF8 string. + * @param array The bytes to encode. + * @param startIndex The index to start in the bytes. + * @param length The length of bytes to read. + * @returns The array formated as UTF8. + */ + public static bytesToUtf8(array: ArrayLike, startIndex?: number, length?: number | undefined): string { + const start = startIndex ?? 0; + const len = length ?? array.length; + let str = ""; + + for (let i = start; i < start + len; i++) { + const value = array[i]; + + if (value < 0x80) { + str += String.fromCharCode(value); + } else if (value > 0xbf && value < 0xe0) { + str += String.fromCharCode(((value & 0x1f) << 6) | (array[i + 1] & 0x3f)); + i += 1; + } else if (value > 0xdf && value < 0xf0) { + str += String.fromCharCode( + ((value & 0x0f) << 12) | ((array[i + 1] & 0x3f) << 6) | (array[i + 2] & 0x3f) + ); + i += 2; + } else { + // surrogate pair + const charCode = + (((value & 0x07) << 18) | + ((array[i + 1] & 0x3f) << 12) | + ((array[i + 2] & 0x3f) << 6) | + (array[i + 3] & 0x3f)) - + 0x010000; + + str += String.fromCharCode((charCode >> 10) | 0xd800, (charCode & 0x03ff) | 0xdc00); + i += 3; + } + } + + return str; + } + + /** + * Convert a UTF8 string to raw array. + * @param utf8 The text to decode. + * @returns The array. + */ + public static utf8ToBytes(utf8: string): Uint8Array { + const bytes: number[] = []; + + for (let i = 0; i < utf8.length; i++) { + let charcode = utf8.charCodeAt(i); + if (charcode < 0x80) { + bytes.push(charcode); + } else if (charcode < 0x800) { + bytes.push(0xc0 | (charcode >> 6), 0x80 | (charcode & 0x3f)); + } else if (charcode < 0xd800 || charcode >= 0xe000) { + bytes.push(0xe0 | (charcode >> 12), 0x80 | ((charcode >> 6) & 0x3f), 0x80 | (charcode & 0x3f)); + } else { + // surrogate pair + i++; + // UTF-16 encodes 0x10000-0x10FFFF by + // subtracting 0x10000 and splitting the + // 20 bits of 0x0-0xFFFFF into two halves + charcode = 0x10000 + (((charcode & 0x3ff) << 10) | (utf8.charCodeAt(i) & 0x3ff)); + bytes.push( + 0xf0 | (charcode >> 18), + 0x80 | ((charcode >> 12) & 0x3f), + 0x80 | ((charcode >> 6) & 0x3f), + 0x80 | (charcode & 0x3f) + ); + } + } + + return Uint8Array.from(bytes); + } + + /** + * Encode a raw array to hex string. + * @param array The bytes to encode. + * @param includePrefix Include the 0x prefix on the returned hex. + * @param startIndex The index to start in the bytes. + * @param length The length of bytes to read. + * @param reverse Reverse the combine direction. + * @returns The array formated as hex. + */ + public static bytesToHex( + array: ArrayLike, + includePrefix: boolean = false, + startIndex?: number, + length?: number | undefined, + reverse?: boolean + ): string { + let hex = ""; + this.buildHexLookups(); + if (Converter.ENCODE_LOOKUP) { + const len = length ?? array.length; + const start = startIndex ?? 0; + if (reverse) { + for (let i = 0; i < len; i++) { + hex = Converter.ENCODE_LOOKUP[array[start + i]] + hex; + } + } else { + for (let i = 0; i < len; i++) { + hex += Converter.ENCODE_LOOKUP[array[start + i]]; + } + } + } + return includePrefix ? HexHelper.addPrefix(hex) : hex; + } + + /** + * Decode a hex string to raw array. + * @param hex The hex to decode. + * @param reverse Store the characters in reverse. + * @returns The array. + */ + public static hexToBytes(hex: string, reverse?: boolean): Uint8Array { + const strippedHex = HexHelper.stripPrefix(hex); + const sizeof = strippedHex.length >> 1; + const length = sizeof << 1; + const array = new Uint8Array(sizeof); + + this.buildHexLookups(); + if (Converter.DECODE_LOOKUP) { + let i = 0; + let n = 0; + while (i < length) { + array[n++] = + (Converter.DECODE_LOOKUP[strippedHex.charCodeAt(i++)] << 4) | + Converter.DECODE_LOOKUP[strippedHex.charCodeAt(i++)]; + } + + if (reverse) { + array.reverse(); + } + } + return array; + } + + /** + * Convert the UTF8 to hex. + * @param utf8 The text to convert. + * @param includePrefix Include the 0x prefix on the returned hex. + * @returns The hex version of the bytes. + */ + public static utf8ToHex(utf8: string, includePrefix: boolean = false): string { + const hex = Converter.bytesToHex(Converter.utf8ToBytes(utf8)); + return includePrefix ? HexHelper.addPrefix(hex) : hex; + } + + /** + * Convert the hex text to text. + * @param hex The hex to convert. + * @returns The UTF8 version of the bytes. + */ + public static hexToUtf8(hex: string): string { + return Converter.bytesToUtf8(Converter.hexToBytes(HexHelper.stripPrefix(hex))); + } + + /** + * Is the data hex format. + * @param value The value to test. + * @param allowPrefix Allow the hex to have the 0x prefix. + * @returns True if the string is hex. + */ + public static isHex(value: string, allowPrefix: boolean = false): boolean { + const localHex = allowPrefix ? HexHelper.stripPrefix(value) : value; + + if (localHex.length % 2 === 1) { + return false; + } + return /^[\da-f]+$/g.test(localHex); + } + + /** + * Convert bytes to binary string. + * @param bytes The bytes to convert. + * @returns A binary string of the bytes. + */ + public static bytesToBinary(bytes: Uint8Array): string { + const b = []; + for (let i = 0; i < bytes.length; i++) { + b.push(bytes[i].toString(2).padStart(8, "0")); + } + return b.join(""); + } + + /** + * Convert a binary string to bytes. + * @param binary The binary string. + * @returns The bytes. + */ + public static binaryToBytes(binary: string): Uint8Array { + const bytes = new Uint8Array(Math.ceil(binary.length / 8)); + for (let i = 0; i < bytes.length; i++) { + bytes[i] = Number.parseInt(binary.slice(i * 8, (i + 1) * 8), 2); + } + return bytes; + } + + /** + * Build the static lookup tables. + * @internal + */ + private static buildHexLookups(): void { + if (!Converter.ENCODE_LOOKUP || !Converter.DECODE_LOOKUP) { + const alphabet = "0123456789abcdef"; + Converter.ENCODE_LOOKUP = []; + Converter.DECODE_LOOKUP = []; + + for (let i = 0; i < 256; i++) { + Converter.ENCODE_LOOKUP[i] = alphabet[(i >> 4) & 0xf] + alphabet[i & 0xf]; + if (i < 16) { + if (i < 10) { + Converter.DECODE_LOOKUP[0x30 + i] = i; + } else { + Converter.DECODE_LOOKUP[0x61 - 10 + i] = i; + } + } + } + } + } +} + + diff --git a/api/src/utils/hexHelper.ts b/api/src/utils/hexHelper.ts new file mode 100644 index 000000000..a0c632dee --- /dev/null +++ b/api/src/utils/hexHelper.ts @@ -0,0 +1,71 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 +import bigInt, { BigInteger } from "big-integer"; + +/** + * Helper methods for hex conversions. + */ +export class HexHelper { + /** + * Const defining the maximum value for a 256 bit int. + */ + public static readonly BIG_INT_MAX_256_BIT: BigInteger = bigInt( + "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + 16 + ); + + /** + * Convert the big int 256 bit to hex string. + * @param value The big int value to convert. + * @returns The hex encoded big int. + */ + public static fromBigInt256(value: BigInteger): string { + if (value.gt(HexHelper.BIG_INT_MAX_256_BIT)) { + return HexHelper.addPrefix(HexHelper.BIG_INT_MAX_256_BIT.toString(16)); + } + return HexHelper.addPrefix(value.toString(16)); + } + + /** + * Convert the hex string to a big int. + * @param hex The hex value to convert. + * @returns The big int. + */ + public static toBigInt256(hex: string): BigInteger { + const bi = bigInt(HexHelper.stripPrefix(hex), 16); + + if (bi.greater(HexHelper.BIG_INT_MAX_256_BIT)) { + return HexHelper.BIG_INT_MAX_256_BIT; + } + + return bi; + } + + /** + * Strip the 0x prefix if it exists. + * @param hex The hex value to strip. + * @returns The stripped hex without the prefix. + */ + public static stripPrefix(hex: string): string { + return hex.replace(/^0x/, ""); + } + + /** + * Add the 0x prefix if it does not exist. + * @param hex The hex value to add the prefix to. + * @returns The hex with the prefix. + */ + public static addPrefix(hex: string): string { + return hex.startsWith("0x") ? hex : `0x${hex}`; + } + + /** + * Does the hex string have the prefix. + * @param hex The hex value to check for the prefix. + * @returns True if the hex string has the prefix. + */ + public static hasPrefix(hex: string): boolean { + return hex.startsWith("0x"); + } +} + diff --git a/api/src/utils/stardust/associatedOutputsHelper.ts b/api/src/utils/stardust/associatedOutputsHelper.ts index 10fb639da..3ccac6773 100644 --- a/api/src/utils/stardust/associatedOutputsHelper.ts +++ b/api/src/utils/stardust/associatedOutputsHelper.ts @@ -1,6 +1,6 @@ import { - SingleNodeClient, IndexerPluginClient, IOutputsResponse, NFT_ADDRESS_TYPE, ALIAS_ADDRESS_TYPE -} from "@iota/iota.js-stardust"; + Client, IOutputsResponse, QueryParameter, AliasQueryParameter, FoundryQueryParameter, NftQueryParameter, AddressType +} from "@iota/sdk"; import { AssociationType } from "../../models/api/stardust/IAssociationsResponse"; import { IBech32AddressDetails } from "../../models/api/stardust/IBech32AddressDetails"; import { INetwork } from "../../models/db/INetwork"; @@ -13,7 +13,6 @@ export class AssociatedOutputsHelper { private readonly network: INetwork; - private readonly addressDetails: IBech32AddressDetails; constructor(network: INetwork, addressDetails: IBech32AddressDetails) { @@ -25,56 +24,51 @@ export class AssociatedOutputsHelper { const network = this.network; const address = this.addressDetails.bech32; - const client = new SingleNodeClient(network.provider, { - userName: network.user, - password: network.password - }); - - const indexerPlugin = new IndexerPluginClient(client); + const client = new Client({ nodes: [network.provider] }); const promises: Promise[] = []; promises.push( // Basic output -> owner address - this.tryFetchAssociatedOutputs>( - async query => indexerPlugin.basicOutputs(query), - { addressBech32: address }, + this.fetchAssociatedOutputIds( + async query => client.basicOutputIds([query]), + { address }, AssociationType.BASIC_ADDRESS ) ); promises.push( // Basic output -> storage return address - this.tryFetchAssociatedOutputs>( - async query => indexerPlugin.basicOutputs(query), - { storageDepositReturnAddressBech32: address }, + this.fetchAssociatedOutputIds( + async query => client.basicOutputIds([query]), + { storageDepositReturnAddress: address }, AssociationType.BASIC_STORAGE_RETURN ) ); promises.push( // Basic output -> expiration return address - this.tryFetchAssociatedOutputs>( - async query => indexerPlugin.basicOutputs(query), - { expirationReturnAddressBech32: address }, + this.fetchAssociatedOutputIds( + async query => client.basicOutputIds([query]), + { expirationReturnAddress: address }, AssociationType.BASIC_EXPIRATION_RETURN ) ); promises.push( // Basic output -> sender address - this.tryFetchAssociatedOutputs>( - async query => indexerPlugin.basicOutputs(query), - { senderBech32: address }, + this.fetchAssociatedOutputIds( + async query => client.basicOutputIds([query]), + { sender: address }, AssociationType.BASIC_SENDER ) ); - if (this.addressDetails.type === ALIAS_ADDRESS_TYPE && this.addressDetails.hex) { + if (this.addressDetails.type === AddressType.Alias && this.addressDetails.hex) { const aliasId = this.addressDetails.hex; promises.push( // Alias id - this.tryFetchAssociatedOutputs( - async query => indexerPlugin.alias(query), + this.fetchAssociatedOutputIds( + async query => client.aliasOutputId(query), aliasId, AssociationType.ALIAS_ID ) @@ -83,55 +77,55 @@ export class AssociatedOutputsHelper { promises.push( // Alias output -> state controller address - this.tryFetchAssociatedOutputs>( - async query => indexerPlugin.aliases(query), - { stateControllerBech32: address }, + this.fetchAssociatedOutputIds( + async query => client.aliasOutputIds([query]), + { stateController: address }, AssociationType.ALIAS_STATE_CONTROLLER ) ); promises.push( // Alias output -> governor address - this.tryFetchAssociatedOutputs>( - async query => indexerPlugin.aliases(query), - { governorBech32: address }, + this.fetchAssociatedOutputIds( + async query => client.aliasOutputIds([query]), + { governor: address }, AssociationType.ALIAS_GOVERNOR ) ); promises.push( // Alias output -> issuer address - this.tryFetchAssociatedOutputs>( - async query => indexerPlugin.aliases(query), - { issuerBech32: address }, + this.fetchAssociatedOutputIds( + async query => client.aliasOutputIds([query]), + { issuer: address }, AssociationType.ALIAS_ISSUER ) ); promises.push( // Alias output -> sender address - this.tryFetchAssociatedOutputs>( - async query => indexerPlugin.aliases(query), - { senderBech32: address }, + this.fetchAssociatedOutputIds( + async query => client.aliasOutputIds([query]), + { sender: address }, AssociationType.ALIAS_SENDER ) ); promises.push( // Foundry output -> alias address - this.tryFetchAssociatedOutputs>( - async query => indexerPlugin.foundries(query), - { aliasAddressBech32: address }, + this.fetchAssociatedOutputIds( + async query => client.foundryOutputIds([query]), + { aliasAddress: address }, AssociationType.FOUNDRY_ALIAS ) ); - if (this.addressDetails.type === NFT_ADDRESS_TYPE && this.addressDetails.hex) { + if (this.addressDetails.type === AddressType.Nft && this.addressDetails.hex) { const nftId = this.addressDetails.hex; promises.push( // Nft id - this.tryFetchAssociatedOutputs( - async query => indexerPlugin.nft(query), + this.fetchAssociatedOutputIds( + async query => client.nftOutputId(query), nftId, AssociationType.NFT_ID ) @@ -140,45 +134,45 @@ export class AssociatedOutputsHelper { promises.push( // Nft output -> owner address - this.tryFetchAssociatedOutputs>( - async query => indexerPlugin.nfts(query), - { addressBech32: address }, + this.fetchAssociatedOutputIds( + async query => client.nftOutputIds([query]), + { address }, AssociationType.NFT_ADDRESS ) ); promises.push( // Nft output -> storage return address - this.tryFetchAssociatedOutputs>( - async query => indexerPlugin.nfts(query), - { storageDepositReturnAddressBech32: address }, + this.fetchAssociatedOutputIds( + async query => client.nftOutputIds([query]), + { storageDepositReturnAddress: address }, AssociationType.NFT_STORAGE_RETURN ) ); promises.push( // Nft output -> expiration return address - this.tryFetchAssociatedOutputs>( - async query => indexerPlugin.nfts(query), - { expirationReturnAddressBech32: address }, + this.fetchAssociatedOutputIds( + async query => client.nftOutputIds([query]), + { expirationReturnAddress: address }, AssociationType.NFT_EXPIRATION_RETURN ) ); promises.push( - // Alias output -> issuer address - this.tryFetchAssociatedOutputs>( - async query => indexerPlugin.nfts(query), - { issuerBech32: address }, + // Nft output -> issuer address + this.fetchAssociatedOutputIds( + async query => client.nftOutputIds([query]), + { issuer: address }, AssociationType.NFT_ISSUER ) ); promises.push( // Nft output -> sender address - this.tryFetchAssociatedOutputs>( - async query => indexerPlugin.nfts(query), - { senderBech32: address }, + this.fetchAssociatedOutputIds( + async query => client.nftOutputIds([query]), + { sender: address }, AssociationType.NFT_SENDER ) ); @@ -192,8 +186,8 @@ export class AssociatedOutputsHelper { * @param args The parameters to pass to the call * @param association The association we are looking for. */ - private async tryFetchAssociatedOutputs( - fetch: (req: T) => Promise, + private async fetchAssociatedOutputIds( + fetch: (req: T) => Promise, args: T, association: AssociationType ): Promise { @@ -202,23 +196,28 @@ export class AssociatedOutputsHelper { do { try { - const outputs = typeof args === "string" ? + const response = typeof args === "string" ? await fetch(args) : await fetch({ ...args, cursor }); - if (outputs.items.length > 0) { + if (typeof response === "string") { const outputIds = associationToOutputIds.get(association); - if (!outputIds) { - associationToOutputIds.set(association, outputs.items); + associationToOutputIds.set(association, [response]); } else { - const mergedOutputIds = outputIds.concat(outputs.items); - associationToOutputIds.set(association, mergedOutputIds); + associationToOutputIds.set(association, outputIds.concat([response])); + } + } else if (response.items.length > 0) { + const outputIds = associationToOutputIds.get(association); + if (!outputIds) { + associationToOutputIds.set(association, response.items); + } else { + associationToOutputIds.set(association, outputIds.concat(response.items)); } - } - cursor = outputs.cursor; - } catch {} + cursor = response.cursor; + } + } catch { } } while (cursor); } } diff --git a/api/src/utils/stardust/searchExecutor.ts b/api/src/utils/stardust/searchExecutor.ts index 1b21c21b9..a55e61331 100644 --- a/api/src/utils/stardust/searchExecutor.ts +++ b/api/src/utils/stardust/searchExecutor.ts @@ -1,4 +1,4 @@ -import { IOutputResponse, IOutputsResponse } from "@iota/iota.js-stardust"; +import { OutputResponse, IOutputsResponse } from "@iota/sdk"; import { ISearchResponse } from "../../models/api/stardust/ISearchResponse"; import { INetwork } from "../../models/db/INetwork"; import { SearchQuery } from "./searchQueryBuilder"; @@ -125,7 +125,7 @@ export class SearchExecutor { if (searchQuery.output) { promises.push( new Promise((resolve, reject) => { - StardustTangleHelper.tryFetchNodeThenPermanode( + StardustTangleHelper.tryFetchNodeThenPermanode( searchQuery.output, "output", network @@ -151,8 +151,7 @@ export class SearchExecutor { StardustTangleHelper.tryFetchNodeThenPermanode( searchQuery.aliasId, "alias", - network, - true + network ).then( aliasOutputs => { if (aliasOutputs.items.length > 0) { @@ -177,8 +176,7 @@ export class SearchExecutor { StardustTangleHelper.tryFetchNodeThenPermanode( searchQuery.nftId, "nft", - network, - true + network ).then( nftOutputs => { if (nftOutputs.items.length > 0) { @@ -203,8 +201,7 @@ export class SearchExecutor { StardustTangleHelper.tryFetchNodeThenPermanode( searchQuery.foundryId, "foundry", - network, - true + network ).then( foundryOutputs => { if (foundryOutputs.items.length > 0) { diff --git a/api/src/utils/stardust/searchQueryBuilder.ts b/api/src/utils/stardust/searchQueryBuilder.ts index 872a6a4d6..cdcbefa94 100644 --- a/api/src/utils/stardust/searchQueryBuilder.ts +++ b/api/src/utils/stardust/searchQueryBuilder.ts @@ -1,5 +1,7 @@ -import { ALIAS_ADDRESS_TYPE, Bech32Helper, ED25519_ADDRESS_TYPE, HexEncodedString, NFT_ADDRESS_TYPE } from "@iota/iota.js-stardust"; -import { Converter, HexHelper } from "@iota/util.js-stardust"; +import { Bech32Helper } from "@iota/iota.js-chrysalis"; +import { AddressType, HexEncodedString, Utils } from "@iota/sdk"; +import { Converter } from "../convertUtils"; +import { HexHelper } from "../hexHelper"; interface QueryDetails { /** @@ -146,7 +148,7 @@ export class SearchQueryBuilder { queryDetails.hex && queryDetails.hexNoPrefix && Converter.isHex(queryDetails.hex, true) && queryDetails.hexNoPrefix.length === 76 && - Number.parseInt(queryDetails.hexNoPrefix.slice(0, 2), 16) === ALIAS_ADDRESS_TYPE + Number.parseInt(queryDetails.hexNoPrefix.slice(0, 2), 16) === AddressType.Alias ) { foundryId = queryDetails.hex; } else if ( @@ -158,8 +160,8 @@ export class SearchQueryBuilder { // also perform a tag search const maybeTag = Converter.isHex(this.query, true) ? - HexHelper.addPrefix(this.query) : - Converter.utf8ToHex(this.query, true); + HexHelper.addPrefix(this.query) : + Converter.utf8ToHex(this.query, true); if (maybeTag.length < 66) { tag = maybeTag; } @@ -198,16 +200,12 @@ export class SearchQueryBuilder { isBech32 = true; try { - const result = Bech32Helper.fromBech32(q, hrp); + const result = Utils.parseBech32Address(q); if (result) { bech32 = q; - addressType = result.addressType; - hex = HexHelper.addPrefix( - Converter.bytesToHex(result.addressBytes) - ); - hexNoPrefix = HexHelper.stripPrefix( - Converter.bytesToHex(result.addressBytes) - ); + addressType = result.type; + hex = HexHelper.addPrefix(result.toString()); + hexNoPrefix = HexHelper.stripPrefix(result.toString()); } } catch { } } @@ -216,11 +214,10 @@ export class SearchQueryBuilder { // We assume it's a hex hex = HexHelper.addPrefix(q); hexNoPrefix = HexHelper.stripPrefix(q); - addressType = ED25519_ADDRESS_TYPE; - bech32 = Bech32Helper.toBech32(ED25519_ADDRESS_TYPE, Converter.hexToBytes(hex), hrp); + addressType = AddressType.Ed25519; + bech32 = Bech32Helper.toBech32(AddressType.Ed25519, Converter.hexToBytes(hex), hrp); } - return { bech32, hex, @@ -237,11 +234,11 @@ export class SearchQueryBuilder { * @returns The label. */ private typeLabel(addressType?: number): string | undefined { - if (addressType === ED25519_ADDRESS_TYPE) { + if (addressType === AddressType.Ed25519) { return "Ed25519"; - } else if (addressType === ALIAS_ADDRESS_TYPE) { + } else if (addressType === AddressType.Alias) { return "Alias"; - } else if (addressType === NFT_ADDRESS_TYPE) { + } else if (addressType === AddressType.Nft) { return "NFT"; } } diff --git a/api/src/utils/stardust/stardustTangleHelper.ts b/api/src/utils/stardust/stardustTangleHelper.ts index 9b6751020..31decf703 100644 --- a/api/src/utils/stardust/stardustTangleHelper.ts +++ b/api/src/utils/stardust/stardustTangleHelper.ts @@ -1,10 +1,8 @@ /* eslint-disable no-warning-comments */ import { - addressBalance, IOutputResponse, SingleNodeClient, - IndexerPluginClient, blockIdFromMilestonePayload, milestoneIdFromMilestonePayload, - IBlockMetadata, IMilestonePayload, IOutputsResponse, deserializeBlock, HexEncodedString -} from "@iota/iota.js-stardust"; -import { HexHelper, ReadStream } from "@iota/util.js-stardust"; + OutputResponse, Client, IBlockMetadata, MilestonePayload, IOutputsResponse, + HexEncodedString, Block, Utils, QueryParameter, NftQueryParameter, AliasQueryParameter, FoundryQueryParameter +} from "@iota/sdk"; import { ServiceFactory } from "../../factories/serviceFactory"; import logger from "../../logger"; import { IBasicOutputsResponse } from "../../models/api/stardust/basic/IBasicOutputsResponse"; @@ -27,8 +25,10 @@ import { IParticipationEventResponse } from "../../models/api/stardust/participa import { IParticipationEventStatus } from "../../models/api/stardust/participation/IParticipationEventStatus"; import { INetwork } from "../../models/db/INetwork"; import { NodeInfoService } from "../../services/stardust/nodeInfoService"; +import { HexHelper } from "../hexHelper"; import { SearchExecutor } from "./searchExecutor"; import { SearchQueryBuilder, SearchQuery } from "./searchQueryBuilder"; +import { addressBalance, blockIdFromMilestonePayload } from "./utils"; /** * Helper functions for use with tangle. @@ -43,8 +43,8 @@ export class StardustTangleHelper { public static async addressDetails( network: INetwork, addressBech32: string ): Promise { - const { bechHrp, provider, user, password } = network; - const node = new SingleNodeClient(provider, { userName: user, password }); + const { bechHrp, provider } = network; + const node = new Client({ nodes: [provider] }); const searchQuery: SearchQuery = new SearchQueryBuilder(addressBech32, bechHrp).build(); if (!searchQuery.address) { @@ -52,6 +52,7 @@ export class StardustTangleHelper { } try { + // Using ported balance from iota.js until it is added to iota-sdk https://github.com/iotaledger/iota-sdk/issues/604 const addressBalanceDetails = await addressBalance(node, searchQuery.address.bech32); if (addressBalanceDetails) { @@ -75,26 +76,25 @@ export class StardustTangleHelper { */ public static async block(network: INetwork, blockId: string): Promise { blockId = HexHelper.addPrefix(blockId); - const blockRaw = await this.tryFetchNodeThenPermanode( + const block = await this.tryFetchNodeThenPermanode( blockId, - "blockRaw", + "getBlock", network ); - if (!blockRaw) { + if (!block) { return { error: `Couldn't find block with id ${blockId}` }; } try { - const block = deserializeBlock(new ReadStream(blockRaw)); if (block && Object.keys(block).length > 0) { return { block }; } } catch (e) { - logger.error(`Block deserialization failed for block with block id ${blockId}. Cause: ${e}`); - return { error: "Block deserialization failed." }; + logger.error(`Failed fetching block with block id ${blockId}. Cause: ${e}`); + return { error: "Block fetch failed." }; } } @@ -108,7 +108,7 @@ export class StardustTangleHelper { blockId = HexHelper.addPrefix(blockId); const metadata = await this.tryFetchNodeThenPermanode( blockId, - "blockMetadata", + "getBlockMetadata", network ); @@ -130,25 +130,24 @@ export class StardustTangleHelper { transactionId: string ): Promise { transactionId = HexHelper.addPrefix(transactionId); - const blockRaw = await this.tryFetchNodeThenPermanode( + const block = await this.tryFetchNodeThenPermanode( transactionId, - "transactionIncludedBlockRaw", + "getIncludedBlock", network ); - if (!blockRaw) { + if (!block) { return { error: `Couldn't find block from transaction id ${transactionId}` }; } try { - const block = deserializeBlock(new ReadStream(blockRaw)); if (block && Object.keys(block).length > 0) { return { block }; } } catch (e) { - logger.error(`Block deserialization failed for block with transaction id ${transactionId}. Cause: ${e}`); + logger.error(`Failed fetching block with transaction id ${transactionId}. Cause: ${e}`); } } @@ -159,9 +158,9 @@ export class StardustTangleHelper { * @returns The item details. */ public static async outputDetails(network: INetwork, outputId: string): Promise { - const outputResponse = await this.tryFetchNodeThenPermanode( + const outputResponse = await this.tryFetchNodeThenPermanode( outputId, - "output", + "getOutput", network ); @@ -176,9 +175,9 @@ export class StardustTangleHelper { * @param outputIds The output ids to get the details. * @returns The item details. */ - public static async outputsDetails(network: INetwork, outputIds: string[]): Promise { + public static async outputsDetails(network: INetwork, outputIds: string[]): Promise { const promises: Promise[] = []; - const outputResponses: IOutputResponse[] = []; + const outputResponses: OutputResponse[] = []; for (const outputId of outputIds) { const promise = this.outputDetails(network, outputId); @@ -209,9 +208,9 @@ export class StardustTangleHelper { public static async milestoneDetailsById( network: INetwork, milestoneId: string ): Promise { - const milestonePayload = await this.tryFetchNodeThenPermanode( + const milestonePayload = await this.tryFetchNodeThenPermanode( milestoneId, - "milestoneById", + "getMilestoneById", network ); @@ -237,9 +236,9 @@ export class StardustTangleHelper { public static async milestoneDetailsByIndex( network: INetwork, milestoneIndex: number ): Promise { - const milestonePayload = await this.tryFetchNodeThenPermanode( + const milestonePayload = await this.tryFetchNodeThenPermanode( milestoneIndex, - "milestoneByIndex", + "getMilestoneByIndex", network ); @@ -248,7 +247,7 @@ export class StardustTangleHelper { const protocolVersion = nodeInfoService.getNodeInfo().protocolVersion; const blockId = blockIdFromMilestonePayload(protocolVersion, milestonePayload); - const milestoneId = milestoneIdFromMilestonePayload(milestonePayload); + const milestoneId = Utils.milestoneId(milestonePayload); return { blockId, @@ -271,11 +270,10 @@ export class StardustTangleHelper { let outputIds: string[] = []; do { - const outputIdsResponse = await this.tryFetchNodeThenPermanode, IOutputsResponse>( - { addressBech32, cursor }, - "basicOutputs", - network, - true + const outputIdsResponse = await this.tryFetchNodeThenPermanode( + [{ address: addressBech32 }, { cursor: cursor ?? "" }], + "basicOutputIds", + network ); outputIds = outputIds.concat(outputIdsResponse.items); @@ -302,11 +300,10 @@ export class StardustTangleHelper { let outputIds: string[] = []; do { - const outputIdsResponse = await this.tryFetchNodeThenPermanode, IOutputsResponse>( - { stateControllerBech32: addressBech32, cursor }, - "aliases", - network, - true + const outputIdsResponse = await this.tryFetchNodeThenPermanode( + [{ stateController: addressBech32 }, { cursor: cursor ?? "" }], + "aliasOutputIds", + network ); outputIds = outputIds.concat(outputIdsResponse.items); @@ -333,11 +330,10 @@ export class StardustTangleHelper { let outputIds: string[] = []; do { - const outputIdsResponse = await this.tryFetchNodeThenPermanode, IOutputsResponse>( - { addressBech32, cursor }, - "nfts", - network, - true + const outputIdsResponse = await this.tryFetchNodeThenPermanode( + [{ address: addressBech32 }, { cursor: cursor ?? "" }], + "nftOutputIds", + network ); outputIds = outputIds.concat(outputIdsResponse.items); @@ -360,15 +356,14 @@ export class StardustTangleHelper { network: INetwork, aliasId: string ): Promise { - const aliasOutput = await this.tryFetchNodeThenPermanode( + const aliasOutputId = await this.tryFetchNodeThenPermanode( aliasId, - "alias", - network, - true + "aliasOutputId", + network ); - if (aliasOutput?.items.length > 0) { - const outputResponse = await this.outputDetails(network, aliasOutput.items[0]); + if (aliasOutputId) { + const outputResponse = await this.outputDetails(network, aliasOutputId); return !outputResponse.error ? { aliasDetails: outputResponse.output } : @@ -389,11 +384,10 @@ export class StardustTangleHelper { aliasAddress: string ): Promise { try { - const response = await this.tryFetchNodeThenPermanode, IOutputsResponse>( - { aliasAddressBech32: aliasAddress }, - "foundries", - network, - true + const response = await this.tryFetchNodeThenPermanode( + [{ aliasAddress }], + "foundryOutputIds", + network ); if (response) { @@ -416,15 +410,14 @@ export class StardustTangleHelper { network: INetwork, foundryId: string ): Promise { - const foundryOutput = await this.tryFetchNodeThenPermanode( + const foundryOutputId = await this.tryFetchNodeThenPermanode( foundryId, - "foundry", - network, - true + "foundryOutputId", + network ); - if (foundryOutput?.items.length > 0) { - const outputResponse = await this.outputDetails(network, foundryOutput.items[0]); + if (foundryOutputId) { + const outputResponse = await this.outputDetails(network, foundryOutputId); return !outputResponse.error ? { foundryDetails: outputResponse.output } : @@ -445,15 +438,14 @@ export class StardustTangleHelper { nftId: string ): Promise { try { - const nftOutputs = await this.tryFetchNodeThenPermanode( + const nftOutputId = await this.tryFetchNodeThenPermanode( nftId, - "nft", - network, - true + "nftOutputId", + network ); - if (nftOutputs?.items.length > 0) { - const outputResponse = await this.outputDetails(network, nftOutputs.items[0]); + if (nftOutputId) { + const outputResponse = await this.outputDetails(network, nftOutputId); return !outputResponse.error ? { nftDetails: outputResponse.output } : @@ -479,10 +471,15 @@ export class StardustTangleHelper { cursor?: string ): Promise { try { + const params: NftQueryParameter[] = [{ tag: encodedTag }, { pageSize }, { cursor: cursor ?? "" }]; const basicOutputIdsResponse: IOutputsResponse = await this.tryFetchNodeThenPermanode< - Record, + QueryParameter[], IOutputsResponse - >({ tagHex: encodedTag, pageSize, cursor }, "basicOutputs", network, true); + >( + params, + "basicOutputIds", + network + ); if (basicOutputIdsResponse?.items.length > 0) { return { outputs: basicOutputIdsResponse }; @@ -507,10 +504,15 @@ export class StardustTangleHelper { cursor?: string ): Promise { try { + const params: NftQueryParameter[] = [{ tag: encodedTag }, { pageSize }, { cursor: cursor ?? "" }]; const nftOutputIdsResponse: IOutputsResponse = await this.tryFetchNodeThenPermanode< - Record, + NftQueryParameter[], IOutputsResponse - >({ tagHex: encodedTag, pageSize, cursor }, "nfts", network, true); + >( + params, + "nftOutputIds", + network + ); if (nftOutputIdsResponse?.items.length > 0) { return { outputs: nftOutputIdsResponse }; @@ -548,16 +550,16 @@ export class StardustTangleHelper { public static async participationEventDetails( network: INetwork, eventId: string ): Promise { - const basePluginPath: string = "participation/v1/"; - const method = "get"; + const basePluginPath: string = "api/participation/v1/"; + const method = "GET"; const methodPath: string = `events/${eventId}`; - const info = await this.nodePluginFetch( + const info = await this.nodePluginFetch( network, basePluginPath, method, methodPath ); - const status = await this.nodePluginFetch( + const status = await this.nodePluginFetch( network, basePluginPath, method, @@ -592,25 +594,18 @@ export class StardustTangleHelper { * @param args The argument(s) to pass to the fetch calls. * @param methodName The function to call on the client. * @param network The network config in context. - * @param isIndexerCall The boolean flag for indexer api instead of core api. * @returns The results or null if call(s) failed. */ public static async tryFetchNodeThenPermanode( args: A, methodName: string, - network: INetwork, - isIndexerCall: boolean = false + network: INetwork ): Promise | null { const { - provider, user, password, permaNodeEndpoint, - permaNodeEndpointUser, permaNodeEndpointPassword, disableApiFallback + provider, permaNodeEndpoint, disableApiFallback } = network; const isFallbackEnabled = !disableApiFallback; - const node = !isIndexerCall ? - new SingleNodeClient(provider, { userName: user, password }) : - new IndexerPluginClient( - new SingleNodeClient(provider, { userName: user, password }) - ); + const node = new Client({ nodes: [provider] }); try { // try fetch from node @@ -619,17 +614,7 @@ export class StardustTangleHelper { } catch { } if (permaNodeEndpoint && isFallbackEnabled) { - const permanode = !isIndexerCall ? - new SingleNodeClient( - permaNodeEndpoint, - { userName: permaNodeEndpointUser, password: permaNodeEndpointPassword } - ) : - new IndexerPluginClient( - new SingleNodeClient( - permaNodeEndpoint, - { userName: permaNodeEndpointUser, password: permaNodeEndpointPassword } - ) - ); + const permanode = new Client({ nodes: [permaNodeEndpoint] }); try { // try fetch from permanode (chronicle) @@ -651,26 +636,28 @@ export class StardustTangleHelper { * @param request The request object. * @returns The response object. */ - private static async nodePluginFetch( + private static async nodePluginFetch( network: INetwork, basePluginPath: string, - method: "get" | "post" | "delete", + method: "GET" | "POST", methodPath: string, queryParams?: string[], - request?: T + request?: string ): Promise | null { - const { provider, user, password } = network; + const { provider } = network; + + const client = new Client({ nodes: [provider] }); - const client = new SingleNodeClient(provider, { userName: user, password }); try { - const result: S = await client.pluginFetch( + const response: S = await client.callPluginRoute( basePluginPath, method, methodPath, queryParams, request - ); - return result; + ) as S; + + return response; } catch { } return null; diff --git a/api/src/utils/stardust/utils.ts b/api/src/utils/stardust/utils.ts new file mode 100644 index 000000000..40638a6f7 --- /dev/null +++ b/api/src/utils/stardust/utils.ts @@ -0,0 +1,87 @@ +import { Block, Client, CommonOutput, IOutputsResponse, MilestonePayload, Utils } from "@iota/sdk"; +import bigInt, { BigInteger } from "big-integer"; + +/** + * Compute a blockId from a milestone payload. + * @param protocolVersion The protocol version to use. + * @param payload The milestone payload. + * @returns The blockId of the block with the milestone payload. + */ +export function blockIdFromMilestonePayload(protocolVersion: number, payload: MilestonePayload): string { + const block = new Block(); + block.protocolVersion = protocolVersion; + block.parents = payload.parents; + block.payload = payload; + block.nonce = "0"; + + return Utils.blockId(block); +} + +/** + * Get the balance for an address. + * @param client The client or node endpoint to get the information from. + * @param address The address to get the balances for (Bech 32). + * @returns The balance. + */ +export async function addressBalance( + client: Client, + address: string +): Promise<{ + balance: BigInteger; + nativeTokens: { [id: string]: BigInteger }; + ledgerIndex: number; +}> { + let total: BigInteger = bigInt(0); + let ledgerIndex = 0; + const nativeTokens: { [id: string]: BigInteger } = {}; + + let response: IOutputsResponse; + let expirationResponse: IOutputsResponse; + let cursor: string | undefined; + let expirationCursor: string | undefined; + do { + response = await client.basicOutputIds([{ address }, { cursor }]); + + for (const outputId of response.items) { + const outputResponse = await client.getOutput(outputId); + + if (!outputResponse.metadata.isSpent) { + total = total.plus(outputResponse.output.getAmount()); + + const nativeTokenOutput = outputResponse.output as CommonOutput; + if (Array.isArray(nativeTokenOutput.getNativeTokens())) { + for (const token of nativeTokenOutput.getNativeTokens()) { + nativeTokens[token.id] = nativeTokens[token.id] ?? bigInt(0); + nativeTokens[token.id] = nativeTokens[token.id].add(token.amount); + } + } + } + ledgerIndex = outputResponse.metadata.ledgerIndex; + } + cursor = response.cursor; + } while (cursor && response.items.length > 0); + + do { + expirationResponse = await client.basicOutputIds([ + { expirationReturnAddress: address }, + { expiresBefore: Math.floor(Date.now() / 1000) }, + { cursor: expirationCursor } + ]); + + for (const outputId of expirationResponse.items) { + const output = await client.getOutput(outputId); + + if (!output.metadata.isSpent) { + total = total.plus(output.output.getAmount()); + } + } + expirationCursor = expirationResponse.cursor; + } while (expirationCursor && expirationResponse.items.length > 0); + + return { + balance: total, + nativeTokens, + ledgerIndex + }; +} + diff --git a/client/craco.config.js b/client/craco.config.js index aa7316157..b3f7b41b9 100644 --- a/client/craco.config.js +++ b/client/craco.config.js @@ -3,17 +3,48 @@ const NodePolyfillPlugin = require("node-polyfill-webpack-plugin"); const evalSourceMap = require("react-dev-utils/evalSourceMapMiddleware"); const redirectServedPath = require("react-dev-utils/redirectServedPathMiddleware"); const noopServiceWorker = require("react-dev-utils/noopServiceWorkerMiddleware"); +const CopyWebPlugin = require('copy-webpack-plugin'); + +const { addAfterLoader, loaderByName } = require('@craco/craco'); module.exports = { eslint: { enable: false }, webpack: { + configure: (webpackConfig) => { + const wasmExtensionRegExp = /\.wasm$/; + webpackConfig.resolve.extensions.push('.wasm'); + + webpackConfig.module.rules.forEach((rule) => { + (rule.oneOf || []).forEach((oneOf) => { + if (oneOf.loader && oneOf.loader.indexOf('file-loader') >= 0) { + oneOf.exclude.push(wasmExtensionRegExp); + } + }); + }); + + const wasmLoader = { + loader: require.resolve('wasm-loader'), + }; + + addAfterLoader(webpackConfig, loaderByName('file-loader'), wasmLoader); + + return webpackConfig; + }, plugins: { add: [ + new CopyWebPlugin({ + patterns: [ + { + from: 'node_modules/@iota/sdk-wasm/web/wasm/iota_sdk_wasm_bg.wasm', + to: 'iota_sdk_wasm_bg.wasm' + } + ] + }), new NodePolyfillPlugin({ excludeAliases: ["console"], - }), + }) ], }, }, diff --git a/client/package-lock.json b/client/package-lock.json index 957659331..c1fb01b82 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -1,25 +1,23 @@ { "name": "explorer-client", - "version": "3.2.0", + "version": "3.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "explorer-client", - "version": "3.2.0", + "version": "3.3.0", "license": "Apache-2.0", "dependencies": { "@d3fc/d3fc-axis": "^3.0.6", "@fontsource/ibm-plex-mono": "^4.5.12", "@fontsource/material-icons": "^4.5.4", "@iota/crypto.js": "^1.8.6", - "@iota/crypto.js-stardust": "npm:@iota/crypto.js@2.0.0-rc.2", "@iota/iota.js": "^1.8.6", - "@iota/iota.js-stardust": "npm:@iota/iota.js@2.0.0-rc.4", "@iota/mam-legacy": "github:iotaledger/mam.js#fddc95f60539b9a31a4db1b5b56e0dedb8994883", "@iota/mam.js": "^1.6.2", + "@iota/sdk-wasm": "1.1.1", "@iota/util.js": "^1.8.6", - "@iota/util.js-stardust": "npm:@iota/util.js@2.0.0-rc.2", "classnames": "^2.3.1", "crypto": "npm:crypto-browserify", "d3-array": "^3.2.1", @@ -46,7 +44,8 @@ "socket.io-client": "^4.2.0", "stream": "npm:stream-browserify", "universal-cookie": "^4.0.4", - "vivagraphjs": "^0.12.0" + "vivagraphjs": "^0.12.0", + "wasm-loader": "^1.3.0" }, "devDependencies": { "@babel/plugin-transform-typescript": "^7.18.12", @@ -75,6 +74,8 @@ "@typescript-eslint/eslint-plugin": "^5.36.0", "@typescript-eslint/parser": "^5.36.0", "buffer": "^6.0.3", + "class-transformer": "^0.5.1", + "copy-webpack-plugin": "^11.0.0", "cross-env": "^7.0.3", "crypto-browserify": "^3.12.0", "eslint": "^8.1.0", @@ -99,11 +100,109 @@ "node": ">=14 <=16.16" } }, + "../../../iota-sdk/bindings/nodejs": { + "name": "@iota/sdk", + "version": "0.1.0", + "extraneous": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "@iota/types": "^1.0.0-beta.15", + "@types/node": "^18.15.12", + "cargo-cp-artifact": "^0.1.6", + "prebuild-install": "^7.1.1", + "typescript": "^4.9.4" + }, + "devDependencies": { + "@types/jest": "^29.4.0", + "@typescript-eslint/eslint-plugin": "^5.30.7", + "@typescript-eslint/parser": "^5.30.7", + "dotenv": "^16.0.3", + "electron-build-env": "^0.2.0", + "eslint": "^8.20.0", + "eslint-config-prettier": "^8.5.0", + "jest": "^29.4.2", + "jest-matcher-utils": "^29.5.0", + "prebuild": "^11.0.4", + "prettier": "^2.8.3", + "ts-jest": "^29.0.5", + "typedoc": "^0.24.6", + "typedoc-plugin-markdown": "^3.14.0" + } + }, + "../../../temp-repos/kwek20/iota-sdk/bindings/nodejs": { + "name": "@iota/sdk", + "version": "1.0.0-rc.1", + "extraneous": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "@types/node": "^18.15.12", + "cargo-cp-artifact": "^0.1.6", + "class-transformer": "^0.5.1", + "prebuild-install": "^7.1.1", + "reflect-metadata": "^0.1.13", + "typescript": "^4.9.4" + }, + "devDependencies": { + "@types/jest": "^29.4.0", + "@typescript-eslint/eslint-plugin": "^5.30.7", + "@typescript-eslint/parser": "^5.30.7", + "dotenv": "^16.0.3", + "electron-build-env": "^0.2.0", + "eslint": "^8.20.0", + "eslint-config-prettier": "^8.5.0", + "jest": "^29.4.2", + "jest-matcher-utils": "^29.5.0", + "prebuild": "^11.0.4", + "prettier": "^2.8.3", + "ts-jest": "^29.0.5", + "typedoc": "^0.24.6", + "typedoc-plugin-markdown": "^3.14.0" + } + }, + "../../../temp-repos/kwek20/iota-sdk/bindings/wasm": { + "name": "@iota/sdk-wasm", + "version": "0.1.0", + "extraneous": true, + "license": "Apache-2.0", + "dependencies": { + "@iota/types": "^1.0.0-beta.11", + "class-transformer": "^0.5.1", + "node-fetch": "^2.6.7", + "reflect-metadata": "^0.1.13", + "text-encoding": "^0.7.0" + }, + "devDependencies": { + "@types/jest": "^27.5.2", + "@typescript-eslint/eslint-plugin": "^5.31.0", + "@typescript-eslint/parser": "^5.31.0", + "copy-webpack-plugin": "^11.0.0", + "dotenv": "^16.0.1", + "eslint": "^8.20.0", + "eslint-config-prettier": "^8.5.0", + "fs-extra": "^10.1.0", + "jest": "^27.5.1", + "jest-matcher-utils": "^28.1.3", + "prettier": "^2.7.1", + "ts-jest": "^27.1.5", + "ts-node": "^10.9.1", + "typedoc": "^0.23.9", + "typedoc-plugin-markdown": "^3.13.4", + "typescript": "^4.7.4", + "wasm-opt": "^1.3.0" + }, + "engines": { + "node": ">=16" + }, + "optionalDependencies": { + "fsevents": "^2.3.2" + } + }, "node_modules/@ampproject/remapping": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.0.tgz", "integrity": "sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w==", - "dev": true, "dependencies": { "@jridgewell/gen-mapping": "^0.1.0", "@jridgewell/trace-mapping": "^0.3.9" @@ -127,7 +226,6 @@ "version": "7.18.13", "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.18.13.tgz", "integrity": "sha512-5yUzC5LqyTFp2HLmDoxGQelcdYgSpP9xsnMWBphAscOdFrHSAVbLNzWiy32sVNDqJRDiJK6klfDnAgu6PAGSHw==", - "dev": true, "engines": { "node": ">=6.9.0" } @@ -136,7 +234,6 @@ "version": "7.18.13", "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.18.13.tgz", "integrity": "sha512-ZisbOvRRusFktksHSG6pjj1CSvkPkcZq/KHD45LAkVP/oiHJkNBZWfpvlLmX8OtHDG8IuzsFlVRWo08w7Qxn0A==", - "dev": true, "dependencies": { "@ampproject/remapping": "^2.1.0", "@babel/code-frame": "^7.18.6", @@ -193,7 +290,6 @@ "version": "7.18.13", "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.18.13.tgz", "integrity": "sha512-CkPg8ySSPuHTYPJYo7IRALdqyjM9HCbt/3uOBEFbzyGVP6Mn8bwFPB0jX6982JVNBlYzM1nnPkfjuXSOPtQeEQ==", - "dev": true, "dependencies": { "@babel/types": "^7.18.13", "@jridgewell/gen-mapping": "^0.3.2", @@ -207,7 +303,6 @@ "version": "0.3.2", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz", "integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==", - "dev": true, "dependencies": { "@jridgewell/set-array": "^1.0.1", "@jridgewell/sourcemap-codec": "^1.4.10", @@ -246,7 +341,6 @@ "version": "7.18.9", "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.18.9.tgz", "integrity": "sha512-tzLCyVmqUiFlcFoAPLA/gL9TeYrF61VLNtb+hvkuVaB5SUjW7jcfrglBIX1vUIoT7CLP3bBlIMeyEsIl2eFQNg==", - "dev": true, "dependencies": { "@babel/compat-data": "^7.18.8", "@babel/helper-validator-option": "^7.18.6", @@ -318,7 +412,6 @@ "version": "7.18.9", "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz", "integrity": "sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg==", - "dev": true, "engines": { "node": ">=6.9.0" } @@ -339,7 +432,6 @@ "version": "7.18.9", "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.18.9.tgz", "integrity": "sha512-fJgWlZt7nxGksJS9a0XdSaI4XvpExnNIgRP+rVefWh5U7BL8pPuir6SJUmFKRfjWQ51OtWSzwOxhaH/EBWWc0A==", - "dev": true, "dependencies": { "@babel/template": "^7.18.6", "@babel/types": "^7.18.9" @@ -352,7 +444,6 @@ "version": "7.18.6", "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz", "integrity": "sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==", - "dev": true, "dependencies": { "@babel/types": "^7.18.6" }, @@ -387,7 +478,6 @@ "version": "7.18.9", "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.18.9.tgz", "integrity": "sha512-KYNqY0ICwfv19b31XzvmI/mfcylOzbLtowkw+mfvGPAQ3kfCnMLYbED3YecL5tPd8nAYFQFAd6JHp2LxZk/J1g==", - "dev": true, "dependencies": { "@babel/helper-environment-visitor": "^7.18.9", "@babel/helper-module-imports": "^7.18.6", @@ -461,7 +551,6 @@ "version": "7.18.6", "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.18.6.tgz", "integrity": "sha512-iNpIgTgyAvDQpDj76POqg+YEt8fPxx3yaNBg3S30dxNKm2SWfYhD0TGrK/Eu9wHpUW63VQU894TsTg+GLbUa1g==", - "dev": true, "dependencies": { "@babel/types": "^7.18.6" }, @@ -485,7 +574,6 @@ "version": "7.18.6", "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz", "integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==", - "dev": true, "dependencies": { "@babel/types": "^7.18.6" }, @@ -513,7 +601,6 @@ "version": "7.18.6", "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.18.6.tgz", "integrity": "sha512-XO7gESt5ouv/LRJdrVjkShckw6STTaB7l9BrpBaAHDeF5YZT+01PCwmR0SJHnkW6i8OwW/EVWRShfi4j2x+KQw==", - "dev": true, "engines": { "node": ">=6.9.0" } @@ -537,7 +624,6 @@ "version": "7.18.9", "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.18.9.tgz", "integrity": "sha512-Jf5a+rbrLoR4eNdUmnFu8cN5eNJT6qdTdOg5IHIzq87WwyRw9PwguLFOWYgktN/60IP4fgDUawJvs7PjQIzELQ==", - "dev": true, "dependencies": { "@babel/template": "^7.18.6", "@babel/traverse": "^7.18.9", @@ -564,7 +650,6 @@ "version": "7.18.13", "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.18.13.tgz", "integrity": "sha512-dgXcIfMuQ0kgzLB2b9tRZs7TTFFaGM2AbtA4fJgUUYukzGH4jwsS7hzQHEGs67jdehpm22vkgKwvbU+aEflgwg==", - "dev": true, "bin": { "parser": "bin/babel-parser.js" }, @@ -1959,7 +2044,6 @@ "version": "7.18.10", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.18.10.tgz", "integrity": "sha512-TI+rCtooWHr3QJ27kJxfjutghu44DLnasDMwpDqCXVTal9RLp3RSYNh4NdBrRP2cQAoG9A8juOQl6P6oZG4JxA==", - "dev": true, "dependencies": { "@babel/code-frame": "^7.18.6", "@babel/parser": "^7.18.10", @@ -1973,7 +2057,6 @@ "version": "7.18.13", "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.18.13.tgz", "integrity": "sha512-N6kt9X1jRMLPxxxPYWi7tgvJRH/rtoU+dbKAPDM44RFHiMH8igdsaSBgFeskhSl/kLWLDUvIh1RXCrTmg0/zvA==", - "dev": true, "dependencies": { "@babel/code-frame": "^7.18.6", "@babel/generator": "^7.18.13", @@ -2637,30 +2720,6 @@ "node": ">=14.0.0" } }, - "node_modules/@iota/crypto.js-stardust": { - "name": "@iota/crypto.js", - "version": "2.0.0-rc.2", - "resolved": "https://registry.npmjs.org/@iota/crypto.js/-/crypto.js-2.0.0-rc.2.tgz", - "integrity": "sha512-gydR6weJ4g8W67yGffpYd3N7Bt83pgqqOCLBM1SV6+wztNuwMYcO8V/yMTyqI9P4Er426QB83cTiwdaOJzs/zQ==", - "dependencies": { - "@iota/util.js": "2.0.0-rc.2", - "big-integer": "^1.6.51" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/@iota/crypto.js-stardust/node_modules/@iota/util.js": { - "version": "2.0.0-rc.2", - "resolved": "https://registry.npmjs.org/@iota/util.js/-/util.js-2.0.0-rc.2.tgz", - "integrity": "sha512-c6n5LPiimwkz5aCKsMjRg3GKWzcK+zELmJK1AVaziLneJ8BsdZBKvWJyQGNqjREQjOhRaixizmZc3nGuihldnQ==", - "dependencies": { - "big-integer": "^1.6.51" - }, - "engines": { - "node": ">=14.0.0" - } - }, "node_modules/@iota/curl": { "version": "1.0.0-beta.19", "resolved": "https://registry.npmjs.org/@iota/curl/-/curl-1.0.0-beta.19.tgz", @@ -2690,44 +2749,6 @@ "node": ">=14.0.0" } }, - "node_modules/@iota/iota.js-stardust": { - "name": "@iota/iota.js", - "version": "2.0.0-rc.4", - "resolved": "https://registry.npmjs.org/@iota/iota.js/-/iota.js-2.0.0-rc.4.tgz", - "integrity": "sha512-fXlM6Q/jSQG0dEXULugbgE9ZT9R5nN3G8oz71Ti6vhbxL1lbQN4M/IzddGg+cn2NfKezNcdMjs8xBbOOBJveCQ==", - "dependencies": { - "@iota/crypto.js": "2.0.0-rc.2", - "@iota/util.js": "2.0.0-rc.2", - "big-integer": "^1.6.51", - "node-fetch": "2.6.7" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/@iota/iota.js-stardust/node_modules/@iota/crypto.js": { - "version": "2.0.0-rc.2", - "resolved": "https://registry.npmjs.org/@iota/crypto.js/-/crypto.js-2.0.0-rc.2.tgz", - "integrity": "sha512-gydR6weJ4g8W67yGffpYd3N7Bt83pgqqOCLBM1SV6+wztNuwMYcO8V/yMTyqI9P4Er426QB83cTiwdaOJzs/zQ==", - "dependencies": { - "@iota/util.js": "2.0.0-rc.2", - "big-integer": "^1.6.51" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/@iota/iota.js-stardust/node_modules/@iota/util.js": { - "version": "2.0.0-rc.2", - "resolved": "https://registry.npmjs.org/@iota/util.js/-/util.js-2.0.0-rc.2.tgz", - "integrity": "sha512-c6n5LPiimwkz5aCKsMjRg3GKWzcK+zELmJK1AVaziLneJ8BsdZBKvWJyQGNqjREQjOhRaixizmZc3nGuihldnQ==", - "dependencies": { - "big-integer": "^1.6.51" - }, - "engines": { - "node": ">=14.0.0" - } - }, "node_modules/@iota/kerl": { "version": "1.0.0-beta.30", "resolved": "https://registry.npmjs.org/@iota/kerl/-/kerl-1.0.0-beta.30.tgz", @@ -2765,6 +2786,39 @@ "resolved": "https://registry.npmjs.org/@iota/pad/-/pad-1.0.0-beta.30.tgz", "integrity": "sha512-fnhPMPul18WunLq9Ni4rxzBFmhna6eaG8WroDg6GdQqSK/eN62uFHV8tpspJHXuCqwgCUVp6NpuUna7+B2OV9g==" }, + "node_modules/@iota/sdk-wasm": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@iota/sdk-wasm/-/sdk-wasm-1.1.1.tgz", + "integrity": "sha512-PoGo4SaQA20oY1hBvNPl10yaWoGh786LklVwKLfGiv/Hw86+bhuHOdNqP4VX1eNa2HmCiP5tPgkEtQj8WvGxIQ==", + "dependencies": { + "class-transformer": "^0.5.1", + "node-fetch": "^2.6.7", + "qs": "^6.9.7", + "reflect-metadata": "^0.1.13", + "semver": "^7.5.2", + "text-encoding": "^0.7.0" + }, + "engines": { + "node": ">=16" + }, + "optionalDependencies": { + "fsevents": "^2.3.2" + } + }, + "node_modules/@iota/sdk-wasm/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/@iota/signing": { "version": "1.0.0-beta.30", "resolved": "https://registry.npmjs.org/@iota/signing/-/signing-1.0.0-beta.30.tgz", @@ -2810,18 +2864,6 @@ "node": ">=14.0.0" } }, - "node_modules/@iota/util.js-stardust": { - "name": "@iota/util.js", - "version": "2.0.0-rc.2", - "resolved": "https://registry.npmjs.org/@iota/util.js/-/util.js-2.0.0-rc.2.tgz", - "integrity": "sha512-c6n5LPiimwkz5aCKsMjRg3GKWzcK+zELmJK1AVaziLneJ8BsdZBKvWJyQGNqjREQjOhRaixizmZc3nGuihldnQ==", - "dependencies": { - "big-integer": "^1.6.51" - }, - "engines": { - "node": ">=14.0.0" - } - }, "node_modules/@iota/validators": { "version": "1.0.0-beta.30", "resolved": "https://registry.npmjs.org/@iota/validators/-/validators-1.0.0-beta.30.tgz", @@ -3603,7 +3645,6 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz", "integrity": "sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w==", - "dev": true, "dependencies": { "@jridgewell/set-array": "^1.0.0", "@jridgewell/sourcemap-codec": "^1.4.10" @@ -3616,7 +3657,6 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", - "dev": true, "engines": { "node": ">=6.0.0" } @@ -3625,7 +3665,6 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", - "dev": true, "engines": { "node": ">=6.0.0" } @@ -3657,14 +3696,12 @@ "node_modules/@jridgewell/sourcemap-codec": { "version": "1.4.14", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", - "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", - "dev": true + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==" }, "node_modules/@jridgewell/trace-mapping": { "version": "0.3.15", "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.15.tgz", "integrity": "sha512-oWZNOULl+UbhsgB51uuZzglikfIKSUBO/M9W2OfEjn7cmqoAiCgmv9lyACTUacZwBz0ITnJ2NqjU8Tx0DHL88g==", - "dev": true, "dependencies": { "@jridgewell/resolve-uri": "^3.0.3", "@jridgewell/sourcemap-codec": "^1.4.10" @@ -6495,6 +6532,17 @@ "npm": ">=6" } }, + "node_modules/babylon": { + "version": "7.0.0-beta.47", + "resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.47.tgz", + "integrity": "sha512-+rq2cr4GDhtToEzKFD6KZZMDBXhjFAr9JjPw9pAppZACeEWqNM294j+NdBzkSHYXwzzBmVjZ3nEVJlOhbR2gOQ==", + "bin": { + "babylon": "bin/babylon.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -6554,7 +6602,6 @@ "version": "5.2.2", "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", - "dev": true, "engines": { "node": "*" } @@ -6775,7 +6822,6 @@ "version": "4.21.3", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.3.tgz", "integrity": "sha512-898rgRXLAyRkM1GryrrBHGkqA5hlpkV5MhtZwg9QXeiyLUYs2k00Un05aX5l2/yJIOObYKOpS2JNo8nJDE7fWQ==", - "dev": true, "funding": [ { "type": "opencollective", @@ -6963,7 +7009,6 @@ "version": "1.0.30001458", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001458.tgz", "integrity": "sha512-lQ1VlUUq5q9ro9X+5gOEyH7i3vm+AYVT1WDCVB69XOZ17KZRhnZ9J0Sqz7wTHQaLBJccNCHq8/Ww5LlOIZbB0w==", - "dev": true, "funding": [ { "type": "opencollective", @@ -7081,6 +7126,11 @@ "integrity": "sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA==", "dev": true }, + "node_modules/class-transformer": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.5.1.tgz", + "integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==" + }, "node_modules/classnames": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.1.tgz", @@ -7373,6 +7423,114 @@ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" }, + "node_modules/copy-webpack-plugin": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/copy-webpack-plugin/-/copy-webpack-plugin-11.0.0.tgz", + "integrity": "sha512-fX2MWpamkW0hZxMEg0+mYnA40LTosOSa5TqZ9GYIBzyJa9C3QUaMPSE2xAi/buNr8u89SfD9wHSQVBzrRa/SOQ==", + "dev": true, + "dependencies": { + "fast-glob": "^3.2.11", + "glob-parent": "^6.0.1", + "globby": "^13.1.1", + "normalize-path": "^3.0.0", + "schema-utils": "^4.0.0", + "serialize-javascript": "^6.0.0" + }, + "engines": { + "node": ">= 14.15.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependencies": { + "webpack": "^5.1.0" + } + }, + "node_modules/copy-webpack-plugin/node_modules/ajv": { + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", + "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/copy-webpack-plugin/node_modules/ajv-keywords": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", + "integrity": "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.3" + }, + "peerDependencies": { + "ajv": "^8.8.2" + } + }, + "node_modules/copy-webpack-plugin/node_modules/globby": { + "version": "13.2.2", + "resolved": "https://registry.npmjs.org/globby/-/globby-13.2.2.tgz", + "integrity": "sha512-Y1zNGV+pzQdh7H39l9zgB4PJqjRNqydvdYCDG4HFXM4XuvSaQQlEc91IU1yALL8gUTDomgBAfz3XJdmUS+oo0w==", + "dev": true, + "dependencies": { + "dir-glob": "^3.0.1", + "fast-glob": "^3.3.0", + "ignore": "^5.2.4", + "merge2": "^1.4.1", + "slash": "^4.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/copy-webpack-plugin/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true + }, + "node_modules/copy-webpack-plugin/node_modules/schema-utils": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.2.0.tgz", + "integrity": "sha512-L0jRsrPpjdckP3oPug3/VxNKt2trR8TcabrM6FOAAlvC/9Phcmm+cuAgTlxBqdBR1WJx7Naj9WHw+aOmheSVbw==", + "dev": true, + "dependencies": { + "@types/json-schema": "^7.0.9", + "ajv": "^8.9.0", + "ajv-formats": "^2.1.1", + "ajv-keywords": "^5.1.0" + }, + "engines": { + "node": ">= 12.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + } + }, + "node_modules/copy-webpack-plugin/node_modules/slash": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz", + "integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/core-js": { "version": "3.25.0", "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.25.0.tgz", @@ -8708,8 +8866,7 @@ "node_modules/electron-to-chromium": { "version": "1.4.233", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.233.tgz", - "integrity": "sha512-ejwIKXTg1wqbmkcRJh9Ur3hFGHFDZDw1POzdsVrB2WZjgRuRMHIQQKNpe64N/qh3ZtH2otEoRoS+s6arAAuAAw==", - "dev": true + "integrity": "sha512-ejwIKXTg1wqbmkcRJh9Ur3hFGHFDZDw1POzdsVrB2WZjgRuRMHIQQKNpe64N/qh3ZtH2otEoRoS+s6arAAuAAw==" }, "node_modules/elliptic": { "version": "6.5.4", @@ -8752,7 +8909,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz", "integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==", - "dev": true, "engines": { "node": ">= 4" } @@ -8945,7 +9101,6 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", - "dev": true, "engines": { "node": ">=6" } @@ -10036,9 +10191,9 @@ "dev": true }, "node_modules/fast-glob": { - "version": "3.2.11", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.11.tgz", - "integrity": "sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", + "integrity": "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==", "dev": true, "dependencies": { "@nodelib/fs.stat": "^2.0.2", @@ -10577,7 +10732,6 @@ "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, "hasInstallScript": true, "optional": true, "os": [ @@ -10629,7 +10783,6 @@ "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", - "dev": true, "engines": { "node": ">=6.9.0" } @@ -10784,7 +10937,6 @@ "version": "11.12.0", "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", - "dev": true, "engines": { "node": ">=4" } @@ -11362,9 +11514,9 @@ ] }, "node_modules/ignore": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", - "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==", + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", + "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", "dev": true, "engines": { "node": ">= 4" @@ -14251,7 +14403,6 @@ "version": "2.5.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", - "dev": true, "bin": { "jsesc": "bin/jsesc" }, @@ -14292,7 +14443,6 @@ "version": "2.2.3", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", - "dev": true, "bin": { "json5": "lib/cli.js" }, @@ -14543,6 +14693,14 @@ "integrity": "sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==", "dev": true }, + "node_modules/long": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/long/-/long-3.2.0.tgz", + "integrity": "sha512-ZYvPPOMqUwPoDsbJaR10iQJYnMuZhRTvHYl62ErLIEX7RgFlziSBUUvrt3OVfc47QlHHpzPZYP17g3Fv7oeJkg==", + "engines": { + "node": ">=0.6" + } + }, "node_modules/loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", @@ -14567,7 +14725,6 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, "dependencies": { "yallist": "^4.0.0" }, @@ -14969,8 +15126,7 @@ "node_modules/minimist": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", - "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", - "dev": true + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==" }, "node_modules/minimist-options": { "version": "4.1.0", @@ -15260,8 +15416,7 @@ "node_modules/node-releases": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.6.tgz", - "integrity": "sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==", - "dev": true + "integrity": "sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==" }, "node_modules/normalize-package-data": { "version": "2.5.0", @@ -15865,8 +16020,7 @@ "node_modules/picocolors": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", - "dev": true + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" }, "node_modules/picomatch": { "version": "2.3.1", @@ -18192,6 +18346,11 @@ "node": ">=8" } }, + "node_modules/reflect-metadata": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz", + "integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==" + }, "node_modules/regenerate": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", @@ -18756,7 +18915,6 @@ "version": "6.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true, "bin": { "semver": "bin/semver.js" } @@ -20114,6 +20272,12 @@ "node": ">=8" } }, + "node_modules/text-encoding": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/text-encoding/-/text-encoding-0.7.0.tgz", + "integrity": "sha512-oJQ3f1hrOnbRLOcwKz0Liq2IcrvDeZRHXhd9RgLrsT+DjWY/nty1Hi7v3dtkaEYbPYe0mUoOfzRrMwfXXwgPUA==", + "deprecated": "no longer maintained" + }, "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", @@ -20411,9 +20575,9 @@ } }, "node_modules/typescript": { - "version": "4.8.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.2.tgz", - "integrity": "sha512-C0I1UsrrDHo2fYI5oaCGbSejwX4ch+9Y5jTQELvovfmFkK3HHSZJB8MSJcWLmCUBzQBchCrZ9rMRV6GuNrvGtw==", + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -20530,7 +20694,6 @@ "version": "1.0.5", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.5.tgz", "integrity": "sha512-dteFFpCyvuDdr9S/ff1ISkKt/9YZxKjI9WlRR99c180GaztJtRa/fn18FdxGVKVsnPY7/a/FDN68mcvUmP4U7Q==", - "dev": true, "funding": [ { "type": "opencollective", @@ -20748,6 +20911,54 @@ "loose-envify": "^1.0.0" } }, + "node_modules/wasm-dce": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wasm-dce/-/wasm-dce-1.0.2.tgz", + "integrity": "sha512-Fq1+nu43ybsjSnBquLrW/cULmKs61qbv9k8ep13QUe0nABBezMoNAA+j6QY66MW0/eoDVDp1rjXDqQ2VKyS/Xg==", + "dependencies": { + "@babel/core": "^7.0.0-beta.39", + "@babel/traverse": "^7.0.0-beta.39", + "@babel/types": "^7.0.0-beta.39", + "babylon": "^7.0.0-beta.39", + "webassembly-interpreter": "0.0.30" + } + }, + "node_modules/wasm-loader": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/wasm-loader/-/wasm-loader-1.3.0.tgz", + "integrity": "sha512-R4s75XH+o8qM+WaRrAU9S2rbAMDzob18/S3V8R9ZoFpZkPWLAohWWlzWAp1ybeTkOuuku/X1zJtxiV0pBYxZww==", + "dependencies": { + "loader-utils": "^1.1.0", + "wasm-dce": "^1.0.0" + }, + "peerDependencies": { + "wasm-dce": "1.x" + } + }, + "node_modules/wasm-loader/node_modules/json5": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", + "dependencies": { + "minimist": "^1.2.0" + }, + "bin": { + "json5": "lib/cli.js" + } + }, + "node_modules/wasm-loader/node_modules/loader-utils": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.2.tgz", + "integrity": "sha512-I5d00Pd/jwMD2QCduo657+YM/6L3KZu++pmX9VFncxaxvHcru9jx1lBaFft+r4Mt2jK0Yhp41XlRAihzPxHNCg==", + "dependencies": { + "big.js": "^5.2.2", + "emojis-list": "^3.0.0", + "json5": "^1.0.1" + }, + "engines": { + "node": ">=4.0.0" + } + }, "node_modules/watchpack": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", @@ -20770,6 +20981,32 @@ "minimalistic-assert": "^1.0.0" } }, + "node_modules/webassembly-floating-point-hex-parser": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/webassembly-floating-point-hex-parser/-/webassembly-floating-point-hex-parser-0.1.2.tgz", + "integrity": "sha512-TUf1H++8U10+stJbFydnvrpG5Sznz5Rilez/oZlV5zI0C/e4cSxd8rALAJ8VpTvjVWxLmL3SVSJUK6Ap9AoiNg==", + "engines": { + "node": "*" + } + }, + "node_modules/webassembly-interpreter": { + "version": "0.0.30", + "resolved": "https://registry.npmjs.org/webassembly-interpreter/-/webassembly-interpreter-0.0.30.tgz", + "integrity": "sha512-+Jdy2piEvz9T5j751mOE8+rBO12p+nNW6Fg4kJZ+zP1oUfsm+151sbAbM8AFxWTURmWCGP+r8Lxwfv3pzN1bCQ==", + "dependencies": { + "@babel/code-frame": "^7.0.0-beta.36", + "long": "^3.2.0", + "webassembly-floating-point-hex-parser": "0.1.2" + }, + "bin": { + "wasm": "lib/bin/repl.js", + "wasm2wast": "lib/bin/wasm2wast.js", + "wasmast": "lib/bin/wasmast.js", + "wasmdump": "lib/bin/wasmdump.js", + "wasmrun": "lib/bin/wasmrun.js", + "wastast": "lib/bin/wastast.js" + } + }, "node_modules/webidl-conversions": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-6.1.0.tgz", @@ -21684,8 +21921,7 @@ "node_modules/yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, "node_modules/yaml": { "version": "1.10.2", @@ -21749,7 +21985,6 @@ "version": "2.2.0", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.0.tgz", "integrity": "sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w==", - "dev": true, "requires": { "@jridgewell/gen-mapping": "^0.1.0", "@jridgewell/trace-mapping": "^0.3.9" @@ -21766,14 +22001,12 @@ "@babel/compat-data": { "version": "7.18.13", "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.18.13.tgz", - "integrity": "sha512-5yUzC5LqyTFp2HLmDoxGQelcdYgSpP9xsnMWBphAscOdFrHSAVbLNzWiy32sVNDqJRDiJK6klfDnAgu6PAGSHw==", - "dev": true + "integrity": "sha512-5yUzC5LqyTFp2HLmDoxGQelcdYgSpP9xsnMWBphAscOdFrHSAVbLNzWiy32sVNDqJRDiJK6klfDnAgu6PAGSHw==" }, "@babel/core": { "version": "7.18.13", "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.18.13.tgz", "integrity": "sha512-ZisbOvRRusFktksHSG6pjj1CSvkPkcZq/KHD45LAkVP/oiHJkNBZWfpvlLmX8OtHDG8IuzsFlVRWo08w7Qxn0A==", - "dev": true, "requires": { "@ampproject/remapping": "^2.1.0", "@babel/code-frame": "^7.18.6", @@ -21815,7 +22048,6 @@ "version": "7.18.13", "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.18.13.tgz", "integrity": "sha512-CkPg8ySSPuHTYPJYo7IRALdqyjM9HCbt/3uOBEFbzyGVP6Mn8bwFPB0jX6982JVNBlYzM1nnPkfjuXSOPtQeEQ==", - "dev": true, "requires": { "@babel/types": "^7.18.13", "@jridgewell/gen-mapping": "^0.3.2", @@ -21826,7 +22058,6 @@ "version": "0.3.2", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz", "integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==", - "dev": true, "requires": { "@jridgewell/set-array": "^1.0.1", "@jridgewell/sourcemap-codec": "^1.4.10", @@ -21858,7 +22089,6 @@ "version": "7.18.9", "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.18.9.tgz", "integrity": "sha512-tzLCyVmqUiFlcFoAPLA/gL9TeYrF61VLNtb+hvkuVaB5SUjW7jcfrglBIX1vUIoT7CLP3bBlIMeyEsIl2eFQNg==", - "dev": true, "requires": { "@babel/compat-data": "^7.18.8", "@babel/helper-validator-option": "^7.18.6", @@ -21908,8 +22138,7 @@ "@babel/helper-environment-visitor": { "version": "7.18.9", "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz", - "integrity": "sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg==", - "dev": true + "integrity": "sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg==" }, "@babel/helper-explode-assignable-expression": { "version": "7.18.6", @@ -21924,7 +22153,6 @@ "version": "7.18.9", "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.18.9.tgz", "integrity": "sha512-fJgWlZt7nxGksJS9a0XdSaI4XvpExnNIgRP+rVefWh5U7BL8pPuir6SJUmFKRfjWQ51OtWSzwOxhaH/EBWWc0A==", - "dev": true, "requires": { "@babel/template": "^7.18.6", "@babel/types": "^7.18.9" @@ -21934,7 +22162,6 @@ "version": "7.18.6", "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz", "integrity": "sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==", - "dev": true, "requires": { "@babel/types": "^7.18.6" } @@ -21960,7 +22187,6 @@ "version": "7.18.9", "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.18.9.tgz", "integrity": "sha512-KYNqY0ICwfv19b31XzvmI/mfcylOzbLtowkw+mfvGPAQ3kfCnMLYbED3YecL5tPd8nAYFQFAd6JHp2LxZk/J1g==", - "dev": true, "requires": { "@babel/helper-environment-visitor": "^7.18.9", "@babel/helper-module-imports": "^7.18.6", @@ -22016,7 +22242,6 @@ "version": "7.18.6", "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.18.6.tgz", "integrity": "sha512-iNpIgTgyAvDQpDj76POqg+YEt8fPxx3yaNBg3S30dxNKm2SWfYhD0TGrK/Eu9wHpUW63VQU894TsTg+GLbUa1g==", - "dev": true, "requires": { "@babel/types": "^7.18.6" } @@ -22034,7 +22259,6 @@ "version": "7.18.6", "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz", "integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==", - "dev": true, "requires": { "@babel/types": "^7.18.6" } @@ -22052,8 +22276,7 @@ "@babel/helper-validator-option": { "version": "7.18.6", "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.18.6.tgz", - "integrity": "sha512-XO7gESt5ouv/LRJdrVjkShckw6STTaB7l9BrpBaAHDeF5YZT+01PCwmR0SJHnkW6i8OwW/EVWRShfi4j2x+KQw==", - "dev": true + "integrity": "sha512-XO7gESt5ouv/LRJdrVjkShckw6STTaB7l9BrpBaAHDeF5YZT+01PCwmR0SJHnkW6i8OwW/EVWRShfi4j2x+KQw==" }, "@babel/helper-wrap-function": { "version": "7.18.11", @@ -22071,7 +22294,6 @@ "version": "7.18.9", "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.18.9.tgz", "integrity": "sha512-Jf5a+rbrLoR4eNdUmnFu8cN5eNJT6qdTdOg5IHIzq87WwyRw9PwguLFOWYgktN/60IP4fgDUawJvs7PjQIzELQ==", - "dev": true, "requires": { "@babel/template": "^7.18.6", "@babel/traverse": "^7.18.9", @@ -22091,8 +22313,7 @@ "@babel/parser": { "version": "7.18.13", "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.18.13.tgz", - "integrity": "sha512-dgXcIfMuQ0kgzLB2b9tRZs7TTFFaGM2AbtA4fJgUUYukzGH4jwsS7hzQHEGs67jdehpm22vkgKwvbU+aEflgwg==", - "dev": true + "integrity": "sha512-dgXcIfMuQ0kgzLB2b9tRZs7TTFFaGM2AbtA4fJgUUYukzGH4jwsS7hzQHEGs67jdehpm22vkgKwvbU+aEflgwg==" }, "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": { "version": "7.18.6", @@ -23019,7 +23240,6 @@ "version": "7.18.10", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.18.10.tgz", "integrity": "sha512-TI+rCtooWHr3QJ27kJxfjutghu44DLnasDMwpDqCXVTal9RLp3RSYNh4NdBrRP2cQAoG9A8juOQl6P6oZG4JxA==", - "dev": true, "requires": { "@babel/code-frame": "^7.18.6", "@babel/parser": "^7.18.10", @@ -23030,7 +23250,6 @@ "version": "7.18.13", "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.18.13.tgz", "integrity": "sha512-N6kt9X1jRMLPxxxPYWi7tgvJRH/rtoU+dbKAPDM44RFHiMH8igdsaSBgFeskhSl/kLWLDUvIh1RXCrTmg0/zvA==", - "dev": true, "requires": { "@babel/code-frame": "^7.18.6", "@babel/generator": "^7.18.13", @@ -23488,25 +23707,6 @@ "big-integer": "^1.6.51" } }, - "@iota/crypto.js-stardust": { - "version": "npm:@iota/crypto.js@2.0.0-rc.2", - "resolved": "https://registry.npmjs.org/@iota/crypto.js/-/crypto.js-2.0.0-rc.2.tgz", - "integrity": "sha512-gydR6weJ4g8W67yGffpYd3N7Bt83pgqqOCLBM1SV6+wztNuwMYcO8V/yMTyqI9P4Er426QB83cTiwdaOJzs/zQ==", - "requires": { - "@iota/util.js": "2.0.0-rc.2", - "big-integer": "^1.6.51" - }, - "dependencies": { - "@iota/util.js": { - "version": "2.0.0-rc.2", - "resolved": "https://registry.npmjs.org/@iota/util.js/-/util.js-2.0.0-rc.2.tgz", - "integrity": "sha512-c6n5LPiimwkz5aCKsMjRg3GKWzcK+zELmJK1AVaziLneJ8BsdZBKvWJyQGNqjREQjOhRaixizmZc3nGuihldnQ==", - "requires": { - "big-integer": "^1.6.51" - } - } - } - }, "@iota/curl": { "version": "1.0.0-beta.19", "resolved": "https://registry.npmjs.org/@iota/curl/-/curl-1.0.0-beta.19.tgz", @@ -23533,36 +23733,6 @@ "node-fetch": "2.6.7" } }, - "@iota/iota.js-stardust": { - "version": "npm:@iota/iota.js@2.0.0-rc.4", - "resolved": "https://registry.npmjs.org/@iota/iota.js/-/iota.js-2.0.0-rc.4.tgz", - "integrity": "sha512-fXlM6Q/jSQG0dEXULugbgE9ZT9R5nN3G8oz71Ti6vhbxL1lbQN4M/IzddGg+cn2NfKezNcdMjs8xBbOOBJveCQ==", - "requires": { - "@iota/crypto.js": "2.0.0-rc.2", - "@iota/util.js": "2.0.0-rc.2", - "big-integer": "^1.6.51", - "node-fetch": "2.6.7" - }, - "dependencies": { - "@iota/crypto.js": { - "version": "2.0.0-rc.2", - "resolved": "https://registry.npmjs.org/@iota/crypto.js/-/crypto.js-2.0.0-rc.2.tgz", - "integrity": "sha512-gydR6weJ4g8W67yGffpYd3N7Bt83pgqqOCLBM1SV6+wztNuwMYcO8V/yMTyqI9P4Er426QB83cTiwdaOJzs/zQ==", - "requires": { - "@iota/util.js": "2.0.0-rc.2", - "big-integer": "^1.6.51" - } - }, - "@iota/util.js": { - "version": "2.0.0-rc.2", - "resolved": "https://registry.npmjs.org/@iota/util.js/-/util.js-2.0.0-rc.2.tgz", - "integrity": "sha512-c6n5LPiimwkz5aCKsMjRg3GKWzcK+zELmJK1AVaziLneJ8BsdZBKvWJyQGNqjREQjOhRaixizmZc3nGuihldnQ==", - "requires": { - "big-integer": "^1.6.51" - } - } - } - }, "@iota/kerl": { "version": "1.0.0-beta.30", "resolved": "https://registry.npmjs.org/@iota/kerl/-/kerl-1.0.0-beta.30.tgz", @@ -23598,6 +23768,30 @@ "resolved": "https://registry.npmjs.org/@iota/pad/-/pad-1.0.0-beta.30.tgz", "integrity": "sha512-fnhPMPul18WunLq9Ni4rxzBFmhna6eaG8WroDg6GdQqSK/eN62uFHV8tpspJHXuCqwgCUVp6NpuUna7+B2OV9g==" }, + "@iota/sdk-wasm": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@iota/sdk-wasm/-/sdk-wasm-1.1.1.tgz", + "integrity": "sha512-PoGo4SaQA20oY1hBvNPl10yaWoGh786LklVwKLfGiv/Hw86+bhuHOdNqP4VX1eNa2HmCiP5tPgkEtQj8WvGxIQ==", + "requires": { + "class-transformer": "^0.5.1", + "fsevents": "^2.3.2", + "node-fetch": "^2.6.7", + "qs": "^6.9.7", + "reflect-metadata": "^0.1.13", + "semver": "^7.5.2", + "text-encoding": "^0.7.0" + }, + "dependencies": { + "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" + } + } + } + }, "@iota/signing": { "version": "1.0.0-beta.30", "resolved": "https://registry.npmjs.org/@iota/signing/-/signing-1.0.0-beta.30.tgz", @@ -23640,14 +23834,6 @@ "big-integer": "^1.6.51" } }, - "@iota/util.js-stardust": { - "version": "npm:@iota/util.js@2.0.0-rc.2", - "resolved": "https://registry.npmjs.org/@iota/util.js/-/util.js-2.0.0-rc.2.tgz", - "integrity": "sha512-c6n5LPiimwkz5aCKsMjRg3GKWzcK+zELmJK1AVaziLneJ8BsdZBKvWJyQGNqjREQjOhRaixizmZc3nGuihldnQ==", - "requires": { - "big-integer": "^1.6.51" - } - }, "@iota/validators": { "version": "1.0.0-beta.30", "resolved": "https://registry.npmjs.org/@iota/validators/-/validators-1.0.0-beta.30.tgz", @@ -24243,7 +24429,6 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz", "integrity": "sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w==", - "dev": true, "requires": { "@jridgewell/set-array": "^1.0.0", "@jridgewell/sourcemap-codec": "^1.4.10" @@ -24252,14 +24437,12 @@ "@jridgewell/resolve-uri": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", - "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", - "dev": true + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==" }, "@jridgewell/set-array": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", - "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", - "dev": true + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==" }, "@jridgewell/source-map": { "version": "0.3.2", @@ -24287,14 +24470,12 @@ "@jridgewell/sourcemap-codec": { "version": "1.4.14", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", - "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", - "dev": true + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==" }, "@jridgewell/trace-mapping": { "version": "0.3.15", "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.15.tgz", "integrity": "sha512-oWZNOULl+UbhsgB51uuZzglikfIKSUBO/M9W2OfEjn7cmqoAiCgmv9lyACTUacZwBz0ITnJ2NqjU8Tx0DHL88g==", - "dev": true, "requires": { "@jridgewell/resolve-uri": "^3.0.3", "@jridgewell/sourcemap-codec": "^1.4.10" @@ -26441,6 +26622,11 @@ } } }, + "babylon": { + "version": "7.0.0-beta.47", + "resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.47.tgz", + "integrity": "sha512-+rq2cr4GDhtToEzKFD6KZZMDBXhjFAr9JjPw9pAppZACeEWqNM294j+NdBzkSHYXwzzBmVjZ3nEVJlOhbR2gOQ==" + }, "balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -26479,8 +26665,7 @@ "big.js": { "version": "5.2.2", "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", - "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", - "dev": true + "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==" }, "binary-extensions": { "version": "2.2.0", @@ -26672,7 +26857,6 @@ "version": "4.21.3", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.3.tgz", "integrity": "sha512-898rgRXLAyRkM1GryrrBHGkqA5hlpkV5MhtZwg9QXeiyLUYs2k00Un05aX5l2/yJIOObYKOpS2JNo8nJDE7fWQ==", - "dev": true, "requires": { "caniuse-lite": "^1.0.30001370", "electron-to-chromium": "^1.4.202", @@ -26798,8 +26982,7 @@ "caniuse-lite": { "version": "1.0.30001458", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001458.tgz", - "integrity": "sha512-lQ1VlUUq5q9ro9X+5gOEyH7i3vm+AYVT1WDCVB69XOZ17KZRhnZ9J0Sqz7wTHQaLBJccNCHq8/Ww5LlOIZbB0w==", - "dev": true + "integrity": "sha512-lQ1VlUUq5q9ro9X+5gOEyH7i3vm+AYVT1WDCVB69XOZ17KZRhnZ9J0Sqz7wTHQaLBJccNCHq8/Ww5LlOIZbB0w==" }, "case-sensitive-paths-webpack-plugin": { "version": "2.4.0", @@ -26883,6 +27066,11 @@ "integrity": "sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA==", "dev": true }, + "class-transformer": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.5.1.tgz", + "integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==" + }, "classnames": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.1.tgz", @@ -27121,6 +27309,80 @@ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" }, + "copy-webpack-plugin": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/copy-webpack-plugin/-/copy-webpack-plugin-11.0.0.tgz", + "integrity": "sha512-fX2MWpamkW0hZxMEg0+mYnA40LTosOSa5TqZ9GYIBzyJa9C3QUaMPSE2xAi/buNr8u89SfD9wHSQVBzrRa/SOQ==", + "dev": true, + "requires": { + "fast-glob": "^3.2.11", + "glob-parent": "^6.0.1", + "globby": "^13.1.1", + "normalize-path": "^3.0.0", + "schema-utils": "^4.0.0", + "serialize-javascript": "^6.0.0" + }, + "dependencies": { + "ajv": { + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", + "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + } + }, + "ajv-keywords": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", + "integrity": "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.3" + } + }, + "globby": { + "version": "13.2.2", + "resolved": "https://registry.npmjs.org/globby/-/globby-13.2.2.tgz", + "integrity": "sha512-Y1zNGV+pzQdh7H39l9zgB4PJqjRNqydvdYCDG4HFXM4XuvSaQQlEc91IU1yALL8gUTDomgBAfz3XJdmUS+oo0w==", + "dev": true, + "requires": { + "dir-glob": "^3.0.1", + "fast-glob": "^3.3.0", + "ignore": "^5.2.4", + "merge2": "^1.4.1", + "slash": "^4.0.0" + } + }, + "json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true + }, + "schema-utils": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.2.0.tgz", + "integrity": "sha512-L0jRsrPpjdckP3oPug3/VxNKt2trR8TcabrM6FOAAlvC/9Phcmm+cuAgTlxBqdBR1WJx7Naj9WHw+aOmheSVbw==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.9", + "ajv": "^8.9.0", + "ajv-formats": "^2.1.1", + "ajv-keywords": "^5.1.0" + } + }, + "slash": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz", + "integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==", + "dev": true + } + } + }, "core-js": { "version": "3.25.0", "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.25.0.tgz", @@ -28108,8 +28370,7 @@ "electron-to-chromium": { "version": "1.4.233", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.233.tgz", - "integrity": "sha512-ejwIKXTg1wqbmkcRJh9Ur3hFGHFDZDw1POzdsVrB2WZjgRuRMHIQQKNpe64N/qh3ZtH2otEoRoS+s6arAAuAAw==", - "dev": true + "integrity": "sha512-ejwIKXTg1wqbmkcRJh9Ur3hFGHFDZDw1POzdsVrB2WZjgRuRMHIQQKNpe64N/qh3ZtH2otEoRoS+s6arAAuAAw==" }, "elliptic": { "version": "6.5.4", @@ -28147,8 +28408,7 @@ "emojis-list": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz", - "integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==", - "dev": true + "integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==" }, "emotion": { "version": "10.0.27", @@ -28298,8 +28558,7 @@ "escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", - "dev": true + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==" }, "escape-html": { "version": "1.0.3", @@ -29097,9 +29356,9 @@ "dev": true }, "fast-glob": { - "version": "3.2.11", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.11.tgz", - "integrity": "sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", + "integrity": "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==", "dev": true, "requires": { "@nodelib/fs.stat": "^2.0.2", @@ -29497,7 +29756,6 @@ "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, "optional": true }, "function-bind": { @@ -29532,8 +29790,7 @@ "gensync": { "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", - "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", - "dev": true + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==" }, "get-caller-file": { "version": "2.0.5", @@ -29647,8 +29904,7 @@ "globals": { "version": "11.12.0", "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", - "dev": true + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==" }, "globby": { "version": "11.1.0", @@ -30079,9 +30335,9 @@ "dev": true }, "ignore": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", - "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==", + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", + "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", "dev": true }, "immer": { @@ -32208,8 +32464,7 @@ "jsesc": { "version": "2.5.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", - "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", - "dev": true + "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==" }, "json-parse-better-errors": { "version": "1.0.2", @@ -32243,8 +32498,7 @@ "json5": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", - "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", - "dev": true + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==" }, "jsonfile": { "version": "6.1.0", @@ -32441,6 +32695,11 @@ "integrity": "sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==", "dev": true }, + "long": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/long/-/long-3.2.0.tgz", + "integrity": "sha512-ZYvPPOMqUwPoDsbJaR10iQJYnMuZhRTvHYl62ErLIEX7RgFlziSBUUvrt3OVfc47QlHHpzPZYP17g3Fv7oeJkg==" + }, "loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", @@ -32462,7 +32721,6 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, "requires": { "yallist": "^4.0.0" } @@ -32761,8 +33019,7 @@ "minimist": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", - "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", - "dev": true + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==" }, "minimist-options": { "version": "4.1.0", @@ -33011,8 +33268,7 @@ "node-releases": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.6.tgz", - "integrity": "sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==", - "dev": true + "integrity": "sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==" }, "normalize-package-data": { "version": "2.5.0", @@ -33465,8 +33721,7 @@ "picocolors": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", - "dev": true + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" }, "picomatch": { "version": "2.3.1", @@ -35017,6 +35272,11 @@ "strip-indent": "^3.0.0" } }, + "reflect-metadata": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz", + "integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==" + }, "regenerate": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", @@ -35417,8 +35677,7 @@ "semver": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" }, "send": { "version": "0.18.0", @@ -36490,6 +36749,11 @@ "minimatch": "^3.0.4" } }, + "text-encoding": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/text-encoding/-/text-encoding-0.7.0.tgz", + "integrity": "sha512-oJQ3f1hrOnbRLOcwKz0Liq2IcrvDeZRHXhd9RgLrsT+DjWY/nty1Hi7v3dtkaEYbPYe0mUoOfzRrMwfXXwgPUA==" + }, "text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", @@ -36722,9 +36986,9 @@ } }, "typescript": { - "version": "4.8.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.2.tgz", - "integrity": "sha512-C0I1UsrrDHo2fYI5oaCGbSejwX4ch+9Y5jTQELvovfmFkK3HHSZJB8MSJcWLmCUBzQBchCrZ9rMRV6GuNrvGtw==", + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "dev": true }, "unbox-primitive": { @@ -36806,7 +37070,6 @@ "version": "1.0.5", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.5.tgz", "integrity": "sha512-dteFFpCyvuDdr9S/ff1ISkKt/9YZxKjI9WlRR99c180GaztJtRa/fn18FdxGVKVsnPY7/a/FDN68mcvUmP4U7Q==", - "dev": true, "requires": { "escalade": "^3.1.1", "picocolors": "^1.0.0" @@ -36994,6 +37257,47 @@ "loose-envify": "^1.0.0" } }, + "wasm-dce": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wasm-dce/-/wasm-dce-1.0.2.tgz", + "integrity": "sha512-Fq1+nu43ybsjSnBquLrW/cULmKs61qbv9k8ep13QUe0nABBezMoNAA+j6QY66MW0/eoDVDp1rjXDqQ2VKyS/Xg==", + "requires": { + "@babel/core": "^7.0.0-beta.39", + "@babel/traverse": "^7.0.0-beta.39", + "@babel/types": "^7.0.0-beta.39", + "babylon": "^7.0.0-beta.39", + "webassembly-interpreter": "0.0.30" + } + }, + "wasm-loader": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/wasm-loader/-/wasm-loader-1.3.0.tgz", + "integrity": "sha512-R4s75XH+o8qM+WaRrAU9S2rbAMDzob18/S3V8R9ZoFpZkPWLAohWWlzWAp1ybeTkOuuku/X1zJtxiV0pBYxZww==", + "requires": { + "loader-utils": "^1.1.0", + "wasm-dce": "^1.0.0" + }, + "dependencies": { + "json5": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", + "requires": { + "minimist": "^1.2.0" + } + }, + "loader-utils": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.2.tgz", + "integrity": "sha512-I5d00Pd/jwMD2QCduo657+YM/6L3KZu++pmX9VFncxaxvHcru9jx1lBaFft+r4Mt2jK0Yhp41XlRAihzPxHNCg==", + "requires": { + "big.js": "^5.2.2", + "emojis-list": "^3.0.0", + "json5": "^1.0.1" + } + } + } + }, "watchpack": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", @@ -37013,6 +37317,21 @@ "minimalistic-assert": "^1.0.0" } }, + "webassembly-floating-point-hex-parser": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/webassembly-floating-point-hex-parser/-/webassembly-floating-point-hex-parser-0.1.2.tgz", + "integrity": "sha512-TUf1H++8U10+stJbFydnvrpG5Sznz5Rilez/oZlV5zI0C/e4cSxd8rALAJ8VpTvjVWxLmL3SVSJUK6Ap9AoiNg==" + }, + "webassembly-interpreter": { + "version": "0.0.30", + "resolved": "https://registry.npmjs.org/webassembly-interpreter/-/webassembly-interpreter-0.0.30.tgz", + "integrity": "sha512-+Jdy2piEvz9T5j751mOE8+rBO12p+nNW6Fg4kJZ+zP1oUfsm+151sbAbM8AFxWTURmWCGP+r8Lxwfv3pzN1bCQ==", + "requires": { + "@babel/code-frame": "^7.0.0-beta.36", + "long": "^3.2.0", + "webassembly-floating-point-hex-parser": "0.1.2" + } + }, "webidl-conversions": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-6.1.0.tgz", @@ -37746,8 +38065,7 @@ "yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, "yaml": { "version": "1.10.2", diff --git a/client/package.json b/client/package.json index 426ed069c..a8ad23d4a 100644 --- a/client/package.json +++ b/client/package.json @@ -1,7 +1,7 @@ { "name": "explorer-client", "description": "Tangle Explorer UI", - "version": "3.2.0", + "version": "3.3.0", "author": "Martyn Janes ", "repository": { "type": "git", @@ -21,13 +21,11 @@ "@fontsource/ibm-plex-mono": "^4.5.12", "@fontsource/material-icons": "^4.5.4", "@iota/crypto.js": "^1.8.6", - "@iota/crypto.js-stardust": "npm:@iota/crypto.js@2.0.0-rc.2", "@iota/iota.js": "^1.8.6", - "@iota/iota.js-stardust": "npm:@iota/iota.js@2.0.0-rc.4", + "@iota/sdk-wasm": "1.1.1", "@iota/mam-legacy": "github:iotaledger/mam.js#fddc95f60539b9a31a4db1b5b56e0dedb8994883", "@iota/mam.js": "^1.6.2", "@iota/util.js": "^1.8.6", - "@iota/util.js-stardust": "npm:@iota/util.js@2.0.0-rc.2", "classnames": "^2.3.1", "crypto": "npm:crypto-browserify", "d3-array": "^3.2.1", @@ -54,7 +52,8 @@ "socket.io-client": "^4.2.0", "stream": "npm:stream-browserify", "universal-cookie": "^4.0.4", - "vivagraphjs": "^0.12.0" + "vivagraphjs": "^0.12.0", + "wasm-loader": "^1.3.0" }, "devDependencies": { "@babel/plugin-transform-typescript": "^7.18.12", @@ -83,6 +82,8 @@ "@typescript-eslint/eslint-plugin": "^5.36.0", "@typescript-eslint/parser": "^5.36.0", "buffer": "^6.0.3", + "class-transformer": "^0.5.1", + "copy-webpack-plugin": "^11.0.0", "cross-env": "^7.0.3", "crypto-browserify": "^3.12.0", "eslint": "^8.1.0", diff --git a/client/src/app/components/DataToggle.tsx b/client/src/app/components/DataToggle.tsx index 25baa4494..55956c9fb 100644 --- a/client/src/app/components/DataToggle.tsx +++ b/client/src/app/components/DataToggle.tsx @@ -1,13 +1,14 @@ -import { HexEncodedString } from "@iota/iota.js-stardust"; -import { Converter, ReadStream } from "@iota/util.js-stardust"; +import { HexEncodedString } from "@iota/sdk-wasm/web"; import classNames from "classnames"; import React, { useEffect, useState } from "react"; +import { Converter } from "../../helpers/stardust/convertUtils"; import { deserializeParticipationEventMetadata } from "../../helpers/stardust/participationUtils"; +import { ReadStream } from "../../helpers/stardust/readStreamUtils"; import { TextHelper } from "../../helpers/textHelper"; import CopyButton from "./CopyButton"; -import "./DataToggle.scss"; import { DataToggleProps } from "./DataToggleProps"; import JsonViewer from "./JsonViewer"; +import "./DataToggle.scss"; interface DataToggleOption { /** diff --git a/client/src/app/components/FiatValue.tsx b/client/src/app/components/FiatValue.tsx index 52efdef0a..e912eced2 100644 --- a/client/src/app/components/FiatValue.tsx +++ b/client/src/app/components/FiatValue.tsx @@ -1,4 +1,4 @@ -import { INodeInfoBaseToken } from "@iota/iota.js-stardust"; +import { INodeInfoBaseToken } from "@iota/sdk-wasm/web"; import React, { ReactNode } from "react"; import NetworkContext from "../context/NetworkContext"; import Currency from "./Currency"; diff --git a/client/src/app/components/chrysalis/InclusionState.tsx b/client/src/app/components/chrysalis/InclusionState.tsx index 69d76257e..2cad14029 100644 --- a/client/src/app/components/chrysalis/InclusionState.tsx +++ b/client/src/app/components/chrysalis/InclusionState.tsx @@ -1,4 +1,4 @@ -import { LedgerInclusionState } from "@iota/iota.js-stardust"; +import { LedgerInclusionState } from "@iota/sdk-wasm/web"; import React, { Component, ReactNode } from "react"; interface InclusionStateProps { diff --git a/client/src/app/components/stardust/Feature.tsx b/client/src/app/components/stardust/Feature.tsx index 989afb2b3..832364454 100644 --- a/client/src/app/components/stardust/Feature.tsx +++ b/client/src/app/components/stardust/Feature.tsx @@ -1,4 +1,4 @@ -import { ISSUER_FEATURE_TYPE, METADATA_FEATURE_TYPE, SENDER_FEATURE_TYPE, TAG_FEATURE_TYPE } from "@iota/iota.js-stardust"; +import { FeatureType, IssuerFeature, MetadataFeature, SenderFeature, TagFeature } from "@iota/sdk-wasm/web"; import classNames from "classnames"; import React, { useState } from "react"; import { ReactComponent as DropdownIcon } from "../../../assets/dropdown-arrow.svg"; @@ -28,30 +28,30 @@ const Feature: React.FC = ( {isExpanded && (
- {feature.type === SENDER_FEATURE_TYPE && ( + {feature.type === FeatureType.Sender && (
)} - {feature.type === ISSUER_FEATURE_TYPE && ( + {feature.type === FeatureType.Issuer && (
)} - {feature.type === METADATA_FEATURE_TYPE && ( + {feature.type === FeatureType.Metadata && (
)} - {feature.type === TAG_FEATURE_TYPE && ( + {feature.type === FeatureType.Tag && (
- {feature.tag && ( + {(feature as TagFeature).tag && ( )} diff --git a/client/src/app/components/stardust/FeatureProps.tsx b/client/src/app/components/stardust/FeatureProps.tsx index fc0a9034c..22adcb1f0 100644 --- a/client/src/app/components/stardust/FeatureProps.tsx +++ b/client/src/app/components/stardust/FeatureProps.tsx @@ -1,10 +1,10 @@ -import { FeatureTypes } from "@iota/iota.js-stardust"; +import { Feature } from "@iota/sdk-wasm/web"; export interface FeatureProps { /** * The feature. */ - feature: FeatureTypes; + feature: Feature; /** * Is the feature pre-expanded. diff --git a/client/src/app/components/stardust/InclusionState.tsx b/client/src/app/components/stardust/InclusionState.tsx index 67ec9135d..47ea8a31c 100644 --- a/client/src/app/components/stardust/InclusionState.tsx +++ b/client/src/app/components/stardust/InclusionState.tsx @@ -1,4 +1,4 @@ -import { LedgerInclusionState } from "@iota/iota.js-stardust"; +import { LedgerInclusionState } from "@iota/sdk-wasm/web"; import React from "react"; interface InclusionStateProps { diff --git a/client/src/app/components/stardust/Input.tsx b/client/src/app/components/stardust/Input.tsx index 91422b0ff..702772762 100644 --- a/client/src/app/components/stardust/Input.tsx +++ b/client/src/app/components/stardust/Input.tsx @@ -1,6 +1,6 @@ /* eslint-disable jsdoc/require-param */ /* eslint-disable jsdoc/require-returns */ -import { TransactionHelper } from "@iota/iota.js-stardust"; +import { Utils } from "@iota/sdk-wasm/web"; import classNames from "classnames"; import React, { useContext, useState } from "react"; import { useHistory, Link } from "react-router-dom"; @@ -77,13 +77,13 @@ const Input: React.FC = ({ input, network }) => {
Transaction Output Index
-
{input.transactionOutputIndex}
+
{input.transactionInputIndex}
)} ); - const outputId = TransactionHelper.outputIdFromTransactionData( - input.transactionId, input.transactionOutputIndex + const outputId = Utils.computeOutputId( + input.transactionId, input.transactionInputIndex ); return input.output ? diff --git a/client/src/app/components/stardust/Output.tsx b/client/src/app/components/stardust/Output.tsx index 1ae8eaf4e..8df7e094d 100644 --- a/client/src/app/components/stardust/Output.tsx +++ b/client/src/app/components/stardust/Output.tsx @@ -1,10 +1,11 @@ import { - BASIC_OUTPUT_TYPE, ALIAS_OUTPUT_TYPE, FOUNDRY_OUTPUT_TYPE, NFT_OUTPUT_TYPE, - TREASURY_OUTPUT_TYPE, SIMPLE_TOKEN_SCHEME_TYPE, ALIAS_ADDRESS_TYPE, - NFT_ADDRESS_TYPE, IImmutableAliasUnlockCondition, IAliasAddress, INodeInfoBaseToken, - UnlockConditionTypes, STORAGE_DEPOSIT_RETURN_UNLOCK_CONDITION_TYPE, EXPIRATION_UNLOCK_CONDITION_TYPE, - TIMELOCK_UNLOCK_CONDITION_TYPE, TransactionHelper -} from "@iota/iota.js-stardust"; + AddressType, AliasAddress, AliasOutput, + CommonOutput, ExpirationUnlockCondition, FoundryOutput, ImmutableAliasAddressUnlockCondition, + INodeInfoBaseToken, NftOutput, OutputType, SimpleTokenScheme, + StorageDepositReturnUnlockCondition, + TimelockUnlockCondition, + TokenSchemeType, UnlockCondition as IUnlockCondition, UnlockConditionType, Utils +} from "@iota/sdk-wasm/web"; import classNames from "classnames"; import React, { Component, ReactNode } from "react"; import { Link } from "react-router-dom"; @@ -23,8 +24,8 @@ import NativeToken from "./NativeToken"; import { OutputProps } from "./OutputProps"; import { OutputState } from "./OutputState"; import TruncatedId from "./TruncatedId"; -import UnlockCondition from "./UnlockCondition"; import "./Output.scss"; +import UnlockCondition from "./UnlockCondition"; /** * Component which will display an output. @@ -75,13 +76,13 @@ class Output extends Component { const isParticipationOutput = TransactionsHelper.isParticipationEventOutput(output); const specialUnlockCondition = ( - output.type !== TREASURY_OUTPUT_TYPE && isSpecialCondition) && ( - output.unlockConditions.map((unlockCondition, idx) => ( + output.type !== OutputType.Treasury && isSpecialCondition) && ( + (output as CommonOutput).unlockConditions.map((unlockCondition, idx) => ( - {unlockCondition.type === STORAGE_DEPOSIT_RETURN_UNLOCK_CONDITION_TYPE && "arrow_back"} - {unlockCondition.type === EXPIRATION_UNLOCK_CONDITION_TYPE && "hourglass_bottom"} - {unlockCondition.type === TIMELOCK_UNLOCK_CONDITION_TYPE && "schedule"} + {unlockCondition.type === UnlockConditionType.StorageDepositReturn && "arrow_back"} + {unlockCondition.type === UnlockConditionType.Expiration && "hourglass_bottom"} + {unlockCondition.type === UnlockConditionType.Timelock && "schedule"} )) @@ -140,7 +141,7 @@ class Output extends Component { {outputHeader} {isExpanded && (
- {output.type === ALIAS_OUTPUT_TYPE && ( + {output.type === OutputType.Alias && (
Alias address:
@@ -151,24 +152,24 @@ class Output extends Component { />
State index:
-
{output.stateIndex}
- {output.stateMetadata && ( +
{(output as AliasOutput).stateIndex}
+ {(output as AliasOutput).stateMetadata !== undefined && (
State metadata:
)}
Foundry counter:
-
{output.foundryCounter}
+
{(output as AliasOutput).foundryCounter}
)} - {output.type === NFT_OUTPUT_TYPE && ( + {output.type === OutputType.Nft && (
Nft address:
@@ -181,7 +182,7 @@ class Output extends Component { )} - {output.type === FOUNDRY_OUTPUT_TYPE && ( + {output.type === OutputType.Foundry && (
Foundry id:
@@ -194,22 +195,33 @@ class Output extends Component { )}
Serial number:
-
{output.serialNumber}
+
{(output as FoundryOutput).serialNumber}
Token scheme type:
-
{output.tokenScheme.type}
- {output.tokenScheme.type === SIMPLE_TOKEN_SCHEME_TYPE && ( +
+ {(output as FoundryOutput).tokenScheme.type} +
+ {(output as FoundryOutput).tokenScheme.type === TokenSchemeType.Simple && (
Minted tokens:
- {Number(output.tokenScheme.mintedTokens)} + {Number( + ((output as FoundryOutput).tokenScheme as SimpleTokenScheme) + .mintedTokens + )}
Melted tokens:
- {Number(output.tokenScheme.meltedTokens)} + {Number( + ((output as FoundryOutput).tokenScheme as SimpleTokenScheme) + .meltedTokens + )}
Maximum supply:
- {Number(output.tokenScheme.maximumSupply)} + {Number( + ((output as FoundryOutput).tokenScheme as SimpleTokenScheme) + .maximumSupply + )}
)} @@ -217,16 +229,16 @@ class Output extends Component { )} {/* all output types except Treasury have common output conditions */} - {output.type !== TREASURY_OUTPUT_TYPE && ( + {output.type !== OutputType.Treasury && ( - {output.unlockConditions.map((unlockCondition, idx) => ( + {(output as CommonOutput).unlockConditions.map((unlockCondition, idx) => ( ))} - {output.features?.map((feature, idx) => ( + {(output as CommonOutput).features?.map((feature, idx) => ( { isParticipationEventMetadata={isParticipationOutput} /> ))} - {output.type !== BASIC_OUTPUT_TYPE && output.immutableFeatures && ( - - {output.immutableFeatures.map((immutableFeature, idx) => ( + {output.type === OutputType.Alias && ( + (output as AliasOutput) + .immutableFeatures?.map((immutableFeature, idx) => ( - ))} - + )) )} - {output.nativeTokens?.map((token, idx) => ( + {output.type === OutputType.Nft && ( + (output as NftOutput) + .immutableFeatures?.map((immutableFeature, idx) => ( + + )) + )} + {output.type === OutputType.Foundry && ( + (output as FoundryOutput) + .immutableFeatures?.map((immutableFeature, idx) => ( + + )) + )} + {(output as CommonOutput).nativeTokens?.map((token, idx) => ( { let address: string = ""; let addressType: number = 0; - if (output.type === ALIAS_OUTPUT_TYPE) { - const aliasId = TransactionsHelper.buildIdHashForAliasOrNft(output.aliasId, outputId); + if (output.type === OutputType.Alias) { + const aliasId = TransactionsHelper.buildIdHashForNft((output as AliasOutput).aliasId, outputId); address = aliasId; - addressType = ALIAS_ADDRESS_TYPE; - } else if (output.type === NFT_OUTPUT_TYPE) { - const nftId = TransactionsHelper.buildIdHashForAliasOrNft(output.nftId, outputId); + addressType = AddressType.Alias; + } else if (output.type === OutputType.Nft) { + const nftId = TransactionsHelper.buildIdHashForAlias((output as NftOutput).nftId, outputId); address = nftId; - addressType = NFT_ADDRESS_TYPE; + addressType = AddressType.Nft; } return Bech32AddressHelper.buildAddress( @@ -295,13 +328,18 @@ class Output extends Component { */ private buildFoundryId(): string | undefined { const output = this.props.output; - if (output.type === FOUNDRY_OUTPUT_TYPE) { - const immutableAliasUnlockCondition = output.unlockConditions[0] as IImmutableAliasUnlockCondition; - const aliasId = (immutableAliasUnlockCondition.address as IAliasAddress).aliasId; - return TransactionHelper.constructTokenId( + if (output.type === OutputType.Foundry) { + const foundryOutput = output as FoundryOutput; + const unlockConditions = foundryOutput.unlockConditions; + const immutableAliasUnlockCondition = unlockConditions[0] as ImmutableAliasAddressUnlockCondition; + const aliasId = (immutableAliasUnlockCondition.address as AliasAddress).aliasId; + const serialNumber = (output as FoundryOutput).serialNumber; + const tokenSchemeType = (output as FoundryOutput).tokenScheme.type; + + return Utils.computeTokenId( aliasId, - output.serialNumber, - output.tokenScheme.type + serialNumber, + tokenSchemeType ); } } @@ -311,24 +349,27 @@ class Output extends Component { * @param unlockCondition Unlock condition of output. * @returns The tooltip content. */ - private getSpecialUnlockConditionContent(unlockCondition: UnlockConditionTypes): React.ReactNode { - if (unlockCondition.type === STORAGE_DEPOSIT_RETURN_UNLOCK_CONDITION_TYPE) { + private getSpecialUnlockConditionContent(unlockCondition: IUnlockCondition): React.ReactNode { + if (unlockCondition.type === UnlockConditionType.StorageDepositReturn) { + const storageDepositReturnUC = unlockCondition as StorageDepositReturnUnlockCondition; return ( Storage Deposit Return Unlock Condition
- Return Amount: {unlockCondition.amount} glow + Return Amount: {storageDepositReturnUC.amount} glow
); - } else if (unlockCondition.type === EXPIRATION_UNLOCK_CONDITION_TYPE) { - const time = DateHelper.format(DateHelper.milliseconds(unlockCondition.unixTime)); + } else if (unlockCondition.type === UnlockConditionType.Expiration) { + const expirationUnlockCondition = unlockCondition as ExpirationUnlockCondition; + const time = DateHelper.format(DateHelper.milliseconds(expirationUnlockCondition.unixTime)); return ( Expiration Unlock Condition
Time: {time}
); - } else if (unlockCondition.type === TIMELOCK_UNLOCK_CONDITION_TYPE) { - const time = DateHelper.format(DateHelper.milliseconds(unlockCondition.unixTime)); + } else if (unlockCondition.type === UnlockConditionType.Timelock) { + const timelockUnlockCondition = unlockCondition as TimelockUnlockCondition; + const time = DateHelper.format(DateHelper.milliseconds(timelockUnlockCondition.unixTime)); return ( Timelock Unlock Condition
@@ -344,11 +385,13 @@ class Output extends Component { */ private hasSpecialCondition(): boolean { let specialUnlockConditionExists = false; - if (this.props.output.type !== TREASURY_OUTPUT_TYPE) { - specialUnlockConditionExists = this.props.output.unlockConditions.some(condition => - condition.type === STORAGE_DEPOSIT_RETURN_UNLOCK_CONDITION_TYPE || - condition.type === EXPIRATION_UNLOCK_CONDITION_TYPE || - condition.type === TIMELOCK_UNLOCK_CONDITION_TYPE + + if (this.props.output.type !== OutputType.Treasury) { + const commonOutput = this.props.output as CommonOutput; + specialUnlockConditionExists = commonOutput.unlockConditions.some(condition => + condition.type === UnlockConditionType.StorageDepositReturn || + condition.type === UnlockConditionType.Expiration || + condition.type === UnlockConditionType.Timelock ); } return specialUnlockConditionExists; diff --git a/client/src/app/components/stardust/OutputProps.tsx b/client/src/app/components/stardust/OutputProps.tsx index fcd8295f0..11559cd5b 100644 --- a/client/src/app/components/stardust/OutputProps.tsx +++ b/client/src/app/components/stardust/OutputProps.tsx @@ -1,4 +1,4 @@ -import { OutputTypes } from "@iota/iota.js-stardust"; +import { Output } from "@iota/sdk-wasm/web"; export interface OutputProps { /** @@ -9,7 +9,7 @@ export interface OutputProps { /** * The output to display. */ - output: OutputTypes; + output: Output; /** * The amount to display. diff --git a/client/src/app/components/stardust/UnlockCondition.tsx b/client/src/app/components/stardust/UnlockCondition.tsx index 8ec2e1d52..a53a80d1c 100644 --- a/client/src/app/components/stardust/UnlockCondition.tsx +++ b/client/src/app/components/stardust/UnlockCondition.tsx @@ -1,8 +1,9 @@ import { - ADDRESS_UNLOCK_CONDITION_TYPE, EXPIRATION_UNLOCK_CONDITION_TYPE, GOVERNOR_ADDRESS_UNLOCK_CONDITION_TYPE, - IMMUTABLE_ALIAS_UNLOCK_CONDITION_TYPE, STORAGE_DEPOSIT_RETURN_UNLOCK_CONDITION_TYPE, TIMELOCK_UNLOCK_CONDITION_TYPE, - STATE_CONTROLLER_ADDRESS_UNLOCK_CONDITION_TYPE, INodeInfoBaseToken -} from "@iota/iota.js-stardust"; + AddressUnlockCondition, ExpirationUnlockCondition, GovernorAddressUnlockCondition, + ImmutableAliasAddressUnlockCondition, INodeInfoBaseToken, + StateControllerAddressUnlockCondition, StorageDepositReturnUnlockCondition, + TimelockUnlockCondition, UnlockConditionType +} from "@iota/sdk-wasm/web"; import classNames from "classnames"; import React, { ReactNode } from "react"; import { DateHelper } from "../../../helpers/dateHelper"; @@ -69,18 +70,20 @@ class UnlockCondition extends AsyncComponent {isExpanded && (
- {unlockCondition.type === ADDRESS_UNLOCK_CONDITION_TYPE && ( + {unlockCondition.type === UnlockConditionType.Address && (
)} - {unlockCondition.type === STORAGE_DEPOSIT_RETURN_UNLOCK_CONDITION_TYPE && ( + {unlockCondition.type === UnlockConditionType.StorageDepositReturn && (
Return address
Amount: @@ -90,52 +93,62 @@ class UnlockCondition extends AsyncComponent this.setState({ isFormattedBalance: !isFormattedBalance })} > - {formatAmount(Number(unlockCondition.amount), tokenInfo, !isFormattedBalance)} + {formatAmount( + Number( + (unlockCondition as StorageDepositReturnUnlockCondition).amount + ), + tokenInfo, + !isFormattedBalance + )}
)} - {unlockCondition.type === TIMELOCK_UNLOCK_CONDITION_TYPE && - unlockCondition.unixTime && ( + {unlockCondition.type === UnlockConditionType.Timelock && + (unlockCondition as TimelockUnlockCondition).unixTime && (
Unix time
- {DateHelper.formatShort(unlockCondition.unixTime * 1000)} + {DateHelper.formatShort( + (unlockCondition as TimelockUnlockCondition).unixTime * 1000 + )}
)} - {unlockCondition.type === EXPIRATION_UNLOCK_CONDITION_TYPE && ( + {unlockCondition.type === UnlockConditionType.Expiration && (
- {unlockCondition.unixTime && ( + {(unlockCondition as ExpirationUnlockCondition).unixTime && (
Unix time
- {DateHelper.formatShort(unlockCondition.unixTime * 1000)} + {DateHelper.formatShort( + (unlockCondition as ExpirationUnlockCondition).unixTime * 1000 + )}
)} )} - {unlockCondition.type === GOVERNOR_ADDRESS_UNLOCK_CONDITION_TYPE && ( + {unlockCondition.type === UnlockConditionType.GovernorAddress && (
)} - {unlockCondition.type === IMMUTABLE_ALIAS_UNLOCK_CONDITION_TYPE && ( + {unlockCondition.type === UnlockConditionType.ImmutableAliasAddress && (
)} - {unlockCondition.type === STATE_CONTROLLER_ADDRESS_UNLOCK_CONDITION_TYPE && ( + {unlockCondition.type === UnlockConditionType.StateControllerAddress && (
)}
diff --git a/client/src/app/components/stardust/UnlockConditionProps.tsx b/client/src/app/components/stardust/UnlockConditionProps.tsx index b9afeae3e..2c7aa818f 100644 --- a/client/src/app/components/stardust/UnlockConditionProps.tsx +++ b/client/src/app/components/stardust/UnlockConditionProps.tsx @@ -1,10 +1,10 @@ -import { UnlockConditionTypes } from "@iota/iota.js-stardust"; +import { UnlockCondition } from "@iota/sdk-wasm/web"; export interface UnlockConditionProps { /** * The unlock condition. */ - unlockCondition: UnlockConditionTypes; + unlockCondition: UnlockCondition; /** * Is the unlock condition pre-expanded. diff --git a/client/src/app/components/stardust/Unlocks.tsx b/client/src/app/components/stardust/Unlocks.tsx index 0846cc8ec..9d1c1a96a 100644 --- a/client/src/app/components/stardust/Unlocks.tsx +++ b/client/src/app/components/stardust/Unlocks.tsx @@ -1,4 +1,4 @@ -import { SIGNATURE_UNLOCK_TYPE, UnlockTypes } from "@iota/iota.js-stardust"; +import { ReferenceUnlock, SignatureUnlock, Unlock, UnlockType } from "@iota/sdk-wasm/web"; import classNames from "classnames"; import React, { useState } from "react"; import { NameHelper } from "../../../helpers/stardust/nameHelper"; @@ -6,7 +6,7 @@ import { ReactComponent as DropdownIcon } from "./../../../assets/dropdown-arrow import TruncatedId from "./TruncatedId"; interface IUnlocksProps { - unlocks: UnlockTypes[]; + unlocks: Unlock[]; } const Unlocks: React.FC = ({ unlocks }) => { @@ -45,27 +45,33 @@ const Unlocks: React.FC = ({ unlocks }) => {
{ unlocks.map((unlock, idx) => ( - unlock.type === SIGNATURE_UNLOCK_TYPE ? + unlock.type === UnlockType.Signature ?
{displayUnlocksTypeAndIndex(unlock.type, idx)}
Public Key:
- +
Signature:
- +
:
- {displayUnlocksTypeAndIndex(unlock.type, idx)} + {displayUnlocksTypeAndIndex((unlock as ReferenceUnlock).type, idx)}
References unlock at index: - {unlock.reference} + {(unlock as ReferenceUnlock).reference}
)) diff --git a/client/src/app/components/stardust/address/AddressProps.tsx b/client/src/app/components/stardust/address/AddressProps.tsx index 1a725ec91..8be110e9b 100644 --- a/client/src/app/components/stardust/address/AddressProps.tsx +++ b/client/src/app/components/stardust/address/AddressProps.tsx @@ -1,8 +1,8 @@ -import { AddressTypes } from "@iota/iota.js-stardust"; +import { Address } from "@iota/sdk-wasm/web"; export interface AddressProps { /** * The address. */ - address: AddressTypes; + address: Address; } diff --git a/client/src/app/components/stardust/address/section/AddressPageTabbedSections.tsx b/client/src/app/components/stardust/address/section/AddressPageTabbedSections.tsx index 08b013abe..7bd9df774 100644 --- a/client/src/app/components/stardust/address/section/AddressPageTabbedSections.tsx +++ b/client/src/app/components/stardust/address/section/AddressPageTabbedSections.tsx @@ -1,4 +1,4 @@ -import { ALIAS_ADDRESS_TYPE, NFT_ADDRESS_TYPE } from "@iota/iota.js-stardust"; +import { AddressType } from "@iota/sdk-wasm/web"; import React from "react"; import nativeTokensMessage from "../../../../../assets/modals/stardust/address/assets-in-wallet.json"; import associatedOuputsMessage from "../../../../../assets/modals/stardust/address/associated-outputs.json"; @@ -188,7 +188,7 @@ export const AddressPageTabbedSections: React.FC ]; - const aliasAddressSections = addressType !== ALIAS_ADDRESS_TYPE ? null : [ + const aliasAddressSections = addressType !== AddressType.Alias ? null : [ ]; - const nftAddressSections = addressType !== NFT_ADDRESS_TYPE ? null : [ + const nftAddressSections = addressType !== AddressType.Nft ? null : [ = ({ output }) => ( diff --git a/client/src/app/components/stardust/address/section/alias/AliasStateSection.tsx b/client/src/app/components/stardust/address/section/alias/AliasStateSection.tsx index f6cc906bc..577c4a7e0 100644 --- a/client/src/app/components/stardust/address/section/alias/AliasStateSection.tsx +++ b/client/src/app/components/stardust/address/section/alias/AliasStateSection.tsx @@ -1,4 +1,4 @@ -import { IAliasOutput } from "@iota/iota.js-stardust"; +import { AliasOutput } from "@iota/sdk-wasm/web"; import React from "react"; import DataToggle from "../../../../DataToggle"; @@ -6,32 +6,36 @@ interface AliasStateSectionProps { /** * The Alias Output */ - output: IAliasOutput | null; + output: AliasOutput | null; } -const AliasStateSection: React.FC = ({ output }) => ( -
-
-
-
State Index
-
- {output?.stateIndex} -
-
- {output?.stateMetadata && ( +const AliasStateSection: React.FC = ({ output }) => { + const stateMetadata = output?.stateMetadata; + + return ( +
+
-
State Metadata
+
State Index
- + {output?.stateIndex}
- )} + {stateMetadata && ( +
+
State Metadata
+
+ +
+
+ )} +
-
-); + ); +}; export default AliasStateSection; diff --git a/client/src/app/components/stardust/address/section/native-tokens/Asset.tsx b/client/src/app/components/stardust/address/section/native-tokens/Asset.tsx index 3d468b212..ea2c75c7e 100644 --- a/client/src/app/components/stardust/address/section/native-tokens/Asset.tsx +++ b/client/src/app/components/stardust/address/section/native-tokens/Asset.tsx @@ -1,12 +1,12 @@ /* eslint-disable jsdoc/require-param */ /* eslint-disable jsdoc/require-returns */ -import { IFoundryOutput, IMetadataFeature, METADATA_FEATURE_TYPE } from "@iota/iota.js-stardust"; -import { Converter } from "@iota/util.js-stardust"; +import { FoundryOutput, MetadataFeature, FeatureType } from "@iota/sdk-wasm/web"; import { Validator as JsonSchemaValidator } from "jsonschema"; import React, { ReactElement, useEffect, useState } from "react"; import tokenSchemeIRC30 from "../../../../../../assets/schemas/token-schema-IRC30.json"; import { useFoundryDetails } from "../../../../../../helpers/hooks/useFoundryDetails"; import { useTokenRegistryNativeTokenCheck } from "../../../../../../helpers/hooks/useTokenRegistryNativeTokenCheck"; +import { Converter } from "../../../../../../helpers/stardust/convertUtils"; import { ITokenMetadata } from "../../../../../../models/api/stardust/foundry/ITokenMetadata"; import Spinner from "../../../../Spinner"; import TruncatedId from "../../../TruncatedId"; @@ -24,11 +24,11 @@ const Asset: React.FC = ( useEffect(() => { if (isWhitelisted && foundryDetails) { - const immutableFeatures = (foundryDetails?.output as IFoundryOutput).immutableFeatures; + const immutableFeatures = (foundryDetails?.output as FoundryOutput).immutableFeatures; const metadata = immutableFeatures?.find( - feature => feature.type === METADATA_FEATURE_TYPE - ) as IMetadataFeature; + feature => feature.type === FeatureType.Metadata + ) as MetadataFeature; if (metadata) { updateTokenInfo(metadata); @@ -36,7 +36,7 @@ const Asset: React.FC = ( } }, [isWhitelisted, foundryDetails]); - const updateTokenInfo = (metadata: IMetadataFeature): void => { + const updateTokenInfo = (metadata: MetadataFeature): void => { const validator = new JsonSchemaValidator(); try { @@ -88,7 +88,7 @@ const Asset: React.FC = ( link={`/${network}/foundry/${token?.id}`} /> - {token.amount ?? "-"} + {token.amount.toString() ?? "-"} ) : (
@@ -123,7 +123,7 @@ const Asset: React.FC = (
Quantity
-
{token.amount ?? "-"}
+
{token.amount.toString() ?? "-"}
) diff --git a/client/src/app/components/stardust/address/section/native-tokens/AssetsTable.tsx b/client/src/app/components/stardust/address/section/native-tokens/AssetsTable.tsx index 47761c90b..34c765fb9 100644 --- a/client/src/app/components/stardust/address/section/native-tokens/AssetsTable.tsx +++ b/client/src/app/components/stardust/address/section/native-tokens/AssetsTable.tsx @@ -1,7 +1,6 @@ import { - ALIAS_OUTPUT_TYPE, BASIC_OUTPUT_TYPE, - FOUNDRY_OUTPUT_TYPE, IOutputResponse, NFT_OUTPUT_TYPE -} from "@iota/iota.js-stardust"; + OutputType, OutputResponse, CommonOutput +} from "@iota/sdk-wasm/web"; import React, { useEffect, useState } from "react"; import { IToken } from "../../../../../../models/api/stardust/foundry/IToken"; import Pagination from "../../../../Pagination"; @@ -10,7 +9,7 @@ import "./AssetsTable.scss"; interface AssetsTableProps { networkId: string; - outputs: IOutputResponse[] | null; + outputs: OutputResponse[] | null; setTokenCount?: (count: number) => void; } @@ -30,14 +29,14 @@ const AssetsTable: React.FC = ({ networkId, outputs, setTokenC const theTokens: IToken[] = []; for (const outputResponse of outputs) { const output = outputResponse.output; - if (output.type === BASIC_OUTPUT_TYPE || output.type === ALIAS_OUTPUT_TYPE || - output.type === FOUNDRY_OUTPUT_TYPE || output.type === NFT_OUTPUT_TYPE) { - for (const token of output.nativeTokens ?? []) { + if (output.type === OutputType.Basic || output.type === OutputType.Alias || + output.type === OutputType.Foundry || output.type === OutputType.Nft) { + for (const token of (output as CommonOutput).nativeTokens ?? []) { const existingToken = theTokens.find(t => t.id === token.id); if (existingToken) { - existingToken.amount += Number(token.amount); + existingToken.amount += token.amount; } else { - theTokens.push({ id: token.id, amount: Number.parseInt(token.amount, 16) }); + theTokens.push({ id: token.id, amount: token.amount }); } } } diff --git a/client/src/app/components/stardust/address/section/nft/Nft.tsx b/client/src/app/components/stardust/address/section/nft/Nft.tsx index 6965335fa..06e80cca9 100644 --- a/client/src/app/components/stardust/address/section/nft/Nft.tsx +++ b/client/src/app/components/stardust/address/section/nft/Nft.tsx @@ -1,4 +1,4 @@ -import { INftAddress, NFT_ADDRESS_TYPE } from "@iota/iota.js-stardust"; +import { NftAddress } from "@iota/sdk-wasm/web"; import React, { useContext, useEffect, useState } from "react"; import { Link } from "react-router-dom"; import nftSchemeIRC27 from "../../../../../../assets/schemas/nft-schema-IRC27.json"; @@ -23,7 +23,7 @@ const Nft: React.FC = ({ network, nft }) => { tryParseMetadata(nft.metadata, nftSchemeIRC27) : null; const { bech32Hrp } = useContext(NetworkContext); - const address: INftAddress = { type: NFT_ADDRESS_TYPE, nftId: id }; + const address: NftAddress = new NftAddress(id); const nftAddress = Bech32AddressHelper.buildAddress(bech32Hrp, address); const [isWhitelisted] = useTokenRegistryNftCheck(nft.issuerId, id); const [name, setName] = useState(); diff --git a/client/src/app/components/stardust/address/section/nft/NftSection.tsx b/client/src/app/components/stardust/address/section/nft/NftSection.tsx index b630786d7..d4cd5cd71 100644 --- a/client/src/app/components/stardust/address/section/nft/NftSection.tsx +++ b/client/src/app/components/stardust/address/section/nft/NftSection.tsx @@ -1,10 +1,7 @@ import { - ALIAS_ADDRESS_TYPE, - ED25519_ADDRESS_TYPE, - IIssuerFeature, IMetadataFeature, IOutputResponse, - ISSUER_FEATURE_TYPE, METADATA_FEATURE_TYPE, NFT_ADDRESS_TYPE, NFT_OUTPUT_TYPE, TransactionHelper -} from "@iota/iota.js-stardust"; - + AddressType, AliasAddress, Ed25519Address, FeatureType, IssuerFeature, MetadataFeature, + NftAddress, NftOutput, OutputResponse, OutputType, Utils +} from "@iota/sdk-wasm/web"; import React, { useEffect, useState } from "react"; import { useIsMounted } from "../../../../../../helpers/hooks/useIsMounted"; import { TransactionsHelper } from "../../../../../../helpers/stardust/transactionsHelper"; @@ -15,7 +12,7 @@ import Nft from "./Nft"; interface NftSectionProps { network: string; bech32Address?: string; - outputs: IOutputResponse[] | null; + outputs: OutputResponse[] | null; setNftCount?: (count: number) => void; } @@ -38,37 +35,37 @@ const NftSection: React.FC = ({ network, bech32Address, outputs if ( outputResponse && !outputResponse.metadata.isSpent && - outputResponse.output.type === NFT_OUTPUT_TYPE + outputResponse.output.type === OutputType.Nft ) { - const outputId = TransactionHelper.outputIdFromTransactionData( + const outputId = Utils.computeOutputId( outputResponse.metadata.transactionId, outputResponse.metadata.outputIndex ); - const nftOutput = outputResponse.output; - const nftId = TransactionsHelper.buildIdHashForAliasOrNft(nftOutput.nftId, outputId); + const nftOutput = outputResponse.output as NftOutput; + const nftId = TransactionsHelper.buildIdHashForNft(nftOutput.nftId, outputId); const metadataFeature = nftOutput.immutableFeatures?.find( - feature => feature.type === METADATA_FEATURE_TYPE - ) as IMetadataFeature; + feature => feature.type === FeatureType.Metadata + ) as MetadataFeature; const issuerFeature = nftOutput.immutableFeatures?.find( - feature => feature.type === ISSUER_FEATURE_TYPE - ) as IIssuerFeature; + feature => feature.type === FeatureType.Issuer + ) as IssuerFeature; let issuerId = null; if (issuerFeature) { switch (issuerFeature.address.type) { - case ED25519_ADDRESS_TYPE: - issuerId = issuerFeature.address.pubKeyHash; - break; - case ALIAS_ADDRESS_TYPE: - issuerId = issuerFeature.address.aliasId; - break; - case NFT_ADDRESS_TYPE: - issuerId = issuerFeature.address.nftId; - break; + case AddressType.Ed25519: + issuerId = (issuerFeature.address as Ed25519Address).pubKeyHash; + break; + case AddressType.Alias: + issuerId = (issuerFeature.address as AliasAddress).aliasId; + break; + case AddressType.Nft: + issuerId = (issuerFeature.address as NftAddress).nftId; + break; default: - break; + break; } } diff --git a/client/src/app/components/stardust/block/MilestoneControls.tsx b/client/src/app/components/stardust/block/MilestoneControls.tsx index 8280be5ba..e9626b5db 100644 --- a/client/src/app/components/stardust/block/MilestoneControls.tsx +++ b/client/src/app/components/stardust/block/MilestoneControls.tsx @@ -1,12 +1,13 @@ -import { blockIdFromMilestonePayload, IMilestonePayload } from "@iota/iota.js-stardust"; +import { MilestonePayload } from "@iota/sdk-wasm/web"; import React, { useContext, useEffect, useState } from "react"; import { useHistory } from "react-router-dom"; import { useMilestoneDetails } from "../../../../helpers/hooks/useMilestoneDetails"; +import { TransactionsHelper } from "../../../../helpers/stardust/transactionsHelper"; import NetworkContext from "../../../context/NetworkContext"; import "./MilestoneControls.scss"; interface MilestoneControlProps { - milestone: IMilestonePayload; + milestone: MilestonePayload; } const MilestoneControls: React.FC = ({ milestone }) => { @@ -20,10 +21,14 @@ const MilestoneControls: React.FC = ({ milestone }) => { useEffect(() => { if (previousMsDetails?.milestone) { - setPreviousMsBlockId(blockIdFromMilestonePayload(protocolVersion, previousMsDetails.milestone)); + setPreviousMsBlockId( + TransactionsHelper.blockIdFromMilestonePayload(protocolVersion, previousMsDetails.milestone) + ); } if (nextMsDetails?.milestone) { - setNextMsBlockId(blockIdFromMilestonePayload(protocolVersion, nextMsDetails.milestone)); + setNextMsBlockId( + TransactionsHelper.blockIdFromMilestonePayload(protocolVersion, nextMsDetails.milestone) + ); } }, [nextMsDetails, previousMsDetails]); diff --git a/client/src/app/components/stardust/block/payload/ReceiptPayload.tsx b/client/src/app/components/stardust/block/payload/ReceiptPayload.tsx index dbe6a256e..d45b440a3 100644 --- a/client/src/app/components/stardust/block/payload/ReceiptPayload.tsx +++ b/client/src/app/components/stardust/block/payload/ReceiptPayload.tsx @@ -1,5 +1,5 @@ /* eslint-disable max-len */ -import { INodeInfoBaseToken } from "@iota/iota.js-stardust"; +import { INodeInfoBaseToken } from "@iota/sdk-wasm/web"; import React, { Component, ReactNode } from "react"; import { Bech32AddressHelper } from "../../../../../helpers/stardust/bech32AddressHelper"; import { formatAmount } from "../../../../../helpers/stardust/valueFormatHelper"; diff --git a/client/src/app/components/stardust/block/payload/ReceiptPayloadProps.tsx b/client/src/app/components/stardust/block/payload/ReceiptPayloadProps.tsx index 2ec6f5422..9c6dceee2 100644 --- a/client/src/app/components/stardust/block/payload/ReceiptPayloadProps.tsx +++ b/client/src/app/components/stardust/block/payload/ReceiptPayloadProps.tsx @@ -1,4 +1,4 @@ -import { IReceiptMilestoneOption } from "@iota/iota.js-stardust"; +import { ReceiptMilestoneOption } from "@iota/sdk-wasm/web"; import * as H from "history"; export interface ReceiptPayloadProps { @@ -10,7 +10,7 @@ export interface ReceiptPayloadProps { /** * The receipt payload. */ - payload: IReceiptMilestoneOption; + payload: ReceiptMilestoneOption; /** * Display advanced mode. diff --git a/client/src/app/components/stardust/block/payload/TaggedDataPayloadProps.tsx b/client/src/app/components/stardust/block/payload/TaggedDataPayloadProps.tsx index 5440891f2..a2d445ed0 100644 --- a/client/src/app/components/stardust/block/payload/TaggedDataPayloadProps.tsx +++ b/client/src/app/components/stardust/block/payload/TaggedDataPayloadProps.tsx @@ -1,4 +1,4 @@ -import { ITaggedDataPayload } from "@iota/iota.js-stardust"; +import { TaggedDataPayload } from "@iota/sdk-wasm/web"; import * as H from "history"; export interface TaggedDataPayloadProps { @@ -10,7 +10,7 @@ export interface TaggedDataPayloadProps { /** * The tagged data payload. */ - payload: ITaggedDataPayload; + payload: TaggedDataPayload; /** * History for navigation. diff --git a/client/src/app/components/stardust/block/payload/TransactionPayloadProps.tsx b/client/src/app/components/stardust/block/payload/TransactionPayloadProps.tsx index 27ebc5323..ab4a6bcb2 100644 --- a/client/src/app/components/stardust/block/payload/TransactionPayloadProps.tsx +++ b/client/src/app/components/stardust/block/payload/TransactionPayloadProps.tsx @@ -1,4 +1,4 @@ -import { UnlockTypes } from "@iota/iota.js-stardust"; +import { Unlock } from "@iota/sdk-wasm/web"; import { IInput } from "../../../../../models/api/stardust/IInput"; import { IOutput } from "../../../../../models/api/stardust/IOutput"; @@ -16,7 +16,7 @@ export interface TransactionPayloadProps { /** * The unlocks of the transaction. */ - unlocks: UnlockTypes[]; + unlocks: Unlock[]; /** * The outputs. diff --git a/client/src/app/components/stardust/block/payload/milestone/MilestonePayload.tsx b/client/src/app/components/stardust/block/payload/milestone/MilestonePayload.tsx index 2c711ffbc..a0b0e588c 100644 --- a/client/src/app/components/stardust/block/payload/milestone/MilestonePayload.tsx +++ b/client/src/app/components/stardust/block/payload/milestone/MilestonePayload.tsx @@ -1,7 +1,6 @@ import { - IMilestonePayload, IProtocolParamsMilestoneOption, IReceiptMilestoneOption, - PROTOCOL_PARAMETERS_MILESTONE_OPTION_TYPE, RECEIPT_MILESTONE_OPTION_TYPE -} from "@iota/iota.js-stardust"; + MilestoneOptionType, MilestonePayload as IMilestonePayload, ProtocolParamsMilestoneOption, ReceiptMilestoneOption +} from "@iota/sdk-wasm/web"; import React, { ReactNode } from "react"; import { DateHelper } from "../../../../../../helpers/dateHelper"; import AsyncComponent from "../../../../AsyncComponent"; @@ -36,19 +35,19 @@ class MilestonePayload extends AsyncComponent { appliedMerkleRoot, metadata, options, signatures }: IMilestonePayload = milestonePayload; - let receiptMilestoneOption: IReceiptMilestoneOption | null = null; - let protocolParamsMilestoneOption: IProtocolParamsMilestoneOption | null = null; + let receiptMilestoneOption: ReceiptMilestoneOption | null = null; + let protocolParamsMilestoneOption: ProtocolParamsMilestoneOption | null = null; - if (options?.some((option => option.type === RECEIPT_MILESTONE_OPTION_TYPE))) { + if (options?.some((option => option.type === MilestoneOptionType.Receipt))) { receiptMilestoneOption = options.find( - option => option.type === RECEIPT_MILESTONE_OPTION_TYPE - ) as IReceiptMilestoneOption; + option => option.type === MilestoneOptionType.Receipt + ) as ReceiptMilestoneOption; } - if (options?.some((option => option.type === PROTOCOL_PARAMETERS_MILESTONE_OPTION_TYPE))) { + if (options?.some((option => option.type === MilestoneOptionType.ProtocolParams))) { protocolParamsMilestoneOption = options.find( - option => option.type === PROTOCOL_PARAMETERS_MILESTONE_OPTION_TYPE - ) as IProtocolParamsMilestoneOption; + option => option.type === MilestoneOptionType.ProtocolParams + ) as ProtocolParamsMilestoneOption; } return ( diff --git a/client/src/app/components/stardust/block/payload/milestone/MilestonePayloadProps.tsx b/client/src/app/components/stardust/block/payload/milestone/MilestonePayloadProps.tsx index 54b26dac3..66b2fa1d3 100644 --- a/client/src/app/components/stardust/block/payload/milestone/MilestonePayloadProps.tsx +++ b/client/src/app/components/stardust/block/payload/milestone/MilestonePayloadProps.tsx @@ -1,4 +1,4 @@ -import { IMilestonePayload } from "@iota/iota.js-stardust"; +import { MilestonePayload } from "@iota/sdk-wasm/web"; import * as H from "history"; export interface MilestonePayloadProps { @@ -10,7 +10,7 @@ export interface MilestonePayloadProps { /** * The milestone payload. */ - milestonePayload: IMilestonePayload; + milestonePayload: MilestonePayload; /** * History for navigation. diff --git a/client/src/app/components/stardust/block/payload/milestone/MilestoneSignaturesSection.tsx b/client/src/app/components/stardust/block/payload/milestone/MilestoneSignaturesSection.tsx index 49e963563..a029ebc52 100644 --- a/client/src/app/components/stardust/block/payload/milestone/MilestoneSignaturesSection.tsx +++ b/client/src/app/components/stardust/block/payload/milestone/MilestoneSignaturesSection.tsx @@ -1,4 +1,4 @@ -import { IEd25519Signature } from "@iota/iota.js-stardust"; +import { Ed25519Signature } from "@iota/sdk-wasm/web"; import classNames from "classnames"; import React, { useState } from "react"; import { ReactComponent as DropdownIcon } from "../../../../../../assets/dropdown-arrow.svg"; @@ -6,7 +6,7 @@ import { ReactComponent as KeyIcon } from "../../../../../../assets/key-icon.svg import "./MilestoneSignaturesSection.scss"; interface MilestoneSignaturesProps { - signatures: IEd25519Signature[]; + signatures: Ed25519Signature[]; } const MilestoneSignaturesSection: React.FC = ({ signatures }) => { diff --git a/client/src/app/components/stardust/block/section/BlockMetadataSection.tsx b/client/src/app/components/stardust/block/section/BlockMetadataSection.tsx index d629339d0..da715d51b 100644 --- a/client/src/app/components/stardust/block/section/BlockMetadataSection.tsx +++ b/client/src/app/components/stardust/block/section/BlockMetadataSection.tsx @@ -1,4 +1,4 @@ -import { HexEncodedString, IBlockMetadata } from "@iota/iota.js-stardust"; +import { HexEncodedString, IBlockMetadata } from "@iota/sdk-wasm/web"; import React from "react"; import Spinner from "../../../Spinner"; import InclusionState from "../../InclusionState"; diff --git a/client/src/app/components/stardust/block/section/BlockPayloadSection.tsx b/client/src/app/components/stardust/block/section/BlockPayloadSection.tsx index 2e3eef29e..76468052b 100644 --- a/client/src/app/components/stardust/block/section/BlockPayloadSection.tsx +++ b/client/src/app/components/stardust/block/section/BlockPayloadSection.tsx @@ -1,7 +1,7 @@ import { - IBlock, IUTXOInput, MILESTONE_PAYLOAD_TYPE, - TAGGED_DATA_PAYLOAD_TYPE, TRANSACTION_PAYLOAD_TYPE, UnlockTypes -} from "@iota/iota.js-stardust"; + Block, PayloadType, Unlock, TransactionPayload as ITransactionPayload, + MilestonePayload as IMilestonePayload, RegularTransactionEssence, TaggedDataPayload as ITaggedDataPayload +} from "@iota/sdk-wasm/web"; import * as H from "history"; import React from "react"; import { IInput } from "../../../../../models/api/stardust/IInput"; @@ -13,9 +13,9 @@ import TransactionPayload from "../payload/TransactionPayload"; interface BlockPayloadSectionProps { network: string; protocolVersion: number; - block: IBlock; - inputs?: (IUTXOInput & IInput)[]; - unlocks?: UnlockTypes[]; + block: Block; + inputs?: IInput[]; + unlocks?: Unlock[]; outputs?: IOutput[]; transferTotal?: number; history: H.History; @@ -24,51 +24,64 @@ interface BlockPayloadSectionProps { const BlockPayloadSection: React.FC = ( { network, protocolVersion, block, inputs, outputs, unlocks, transferTotal, history, isLinksDisabled } -) => ( - - {block.payload?.type === TRANSACTION_PAYLOAD_TYPE && - inputs && unlocks && outputs && transferTotal !== undefined && ( - +) => { + if ( + block.payload?.type === PayloadType.Transaction && + inputs && unlocks && outputs && transferTotal !== undefined + ) { + const transactionPayload = block.payload as ITransactionPayload; + const transactionEssence = transactionPayload.essence as RegularTransactionEssence; + + return ( + +
+ +
+ { + transactionEssence.payload?.type === PayloadType.TaggedData &&
-
- { - block.payload.essence.payload && -
- -
- } -
- )} - {block.payload?.type === MILESTONE_PAYLOAD_TYPE && ( + } +
+ ); + } else if ( + block.payload?.type === PayloadType.Milestone + ) { + return ( - )} - {block.payload?.type === TAGGED_DATA_PAYLOAD_TYPE && ( + ); + } else if ( + block.payload?.type === PayloadType.TaggedData + ) { + return (
- )} -
-); + ); + } + + return null; +}; BlockPayloadSection.defaultProps = { inputs: undefined, diff --git a/client/src/app/components/stardust/foundry/TokenInfoSection.tsx b/client/src/app/components/stardust/foundry/TokenInfoSection.tsx index 013f27b27..030231675 100644 --- a/client/src/app/components/stardust/foundry/TokenInfoSection.tsx +++ b/client/src/app/components/stardust/foundry/TokenInfoSection.tsx @@ -1,4 +1,4 @@ -import { TokenSchemeTypes } from "@iota/iota.js-stardust"; +import { SimpleTokenScheme, TokenScheme, TokenSchemeType } from "@iota/sdk-wasm/web"; import React from "react"; import { useTokenRegistryNativeTokenCheck } from "../../../../helpers/hooks/useTokenRegistryNativeTokenCheck"; import { formatNumberWithCommas } from "../../../../helpers/stardust/valueFormatHelper"; @@ -13,7 +13,7 @@ interface TokenInfoSectionProps { /** * The token scheme for the foundry. */ - tokenScheme: TokenSchemeTypes; + tokenScheme: TokenScheme; /** * The IRC standard metadata. */ @@ -23,9 +23,16 @@ interface TokenInfoSectionProps { const TokenInfoSection: React.FC = ({ tokenId, tokenScheme, tokenMetadata }) => { const [isWhitelisted] = useTokenRegistryNativeTokenCheck(tokenId); - const maximumSupply = formatNumberWithCommas(tokenScheme.maximumSupply); - const mintedTokens = formatNumberWithCommas(tokenScheme.mintedTokens); - const meltedTokens = formatNumberWithCommas(tokenScheme.meltedTokens); + if (tokenScheme.type !== TokenSchemeType.Simple) { + return null; + } + + const simpleTokenScheme = tokenScheme as SimpleTokenScheme; + + const maximumSupply = formatNumberWithCommas(simpleTokenScheme.maximumSupply); + const mintedTokens = formatNumberWithCommas(simpleTokenScheme.mintedTokens); + const meltedTokens = formatNumberWithCommas(simpleTokenScheme.meltedTokens); + return (
diff --git a/client/src/app/components/stardust/statistics/ChartUtils.tsx b/client/src/app/components/stardust/statistics/ChartUtils.tsx index 2d421bd6f..f3340a359 100644 --- a/client/src/app/components/stardust/statistics/ChartUtils.tsx +++ b/client/src/app/components/stardust/statistics/ChartUtils.tsx @@ -1,4 +1,4 @@ -import { INodeInfoBaseToken } from "@iota/iota.js-stardust"; +import { INodeInfoBaseToken } from "@iota/sdk-wasm/web"; import { Axis, axisBottom, axisLeft } from "d3-axis"; import { format } from "d3-format"; import { NumberValue, ScaleLinear, ScaleTime } from "d3-scale"; diff --git a/client/src/app/context/NetworkContext.ts b/client/src/app/context/NetworkContext.ts index bee4a61a8..99ea9d916 100644 --- a/client/src/app/context/NetworkContext.ts +++ b/client/src/app/context/NetworkContext.ts @@ -1,4 +1,4 @@ -import { INodeInfoBaseToken, IRent } from "@iota/iota.js-stardust"; +import { INodeInfoBaseToken, IRent } from "@iota/sdk-wasm/web"; import { createContext } from "react"; import { IOTA_UI } from "../../models/config/uiTheme"; diff --git a/client/src/app/routes/stardust/AddressPage.tsx b/client/src/app/routes/stardust/AddressPage.tsx index feabcdd10..a136821ee 100644 --- a/client/src/app/routes/stardust/AddressPage.tsx +++ b/client/src/app/routes/stardust/AddressPage.tsx @@ -1,4 +1,4 @@ -import { ALIAS_ADDRESS_TYPE, NFT_ADDRESS_TYPE } from "@iota/iota.js-stardust"; +import { AddressType } from "@iota/sdk-wasm/web"; import React from "react"; import { RouteComponentProps } from "react-router-dom"; import addressMainHeaderInfo from "../../../assets/modals/stardust/address/main-header.json"; @@ -54,9 +54,9 @@ const AddressPage: React.FC> = ( const addressType = bech32AddressDetails.type; let addressMessage = addressMainHeaderInfo; - if (addressType === ALIAS_ADDRESS_TYPE) { + if (addressType === AddressType.Alias) { addressMessage = aliasMainHeaderInfo; - } else if (addressType === NFT_ADDRESS_TYPE) { + } else if (addressType === AddressType.Nft) { addressMessage = nftMainHeaderInfo; } diff --git a/client/src/app/routes/stardust/AddressState.ts b/client/src/app/routes/stardust/AddressState.ts index efa0c24fd..5d96a35d6 100644 --- a/client/src/app/routes/stardust/AddressState.ts +++ b/client/src/app/routes/stardust/AddressState.ts @@ -1,5 +1,8 @@ -import { ALIAS_ADDRESS_TYPE, BASIC_OUTPUT_TYPE, Bech32Helper, HexEncodedString, IAliasOutput, IMetadataFeature, IOutputResponse, METADATA_FEATURE_TYPE, NFT_ADDRESS_TYPE, OutputTypes } from "@iota/iota.js-stardust"; -import { Converter, ReadStream } from "@iota/util.js-stardust"; +import { Bech32Helper } from "@iota/iota.js"; +import { + HexEncodedString, AliasOutput, MetadataFeature, OutputResponse, + OutputType, AddressType, Output, BasicOutput, FeatureType +} from "@iota/sdk-wasm/web"; import { Reducer, useContext, useEffect, useReducer } from "react"; import { useLocation, useParams } from "react-router-dom"; import { useAddressAliasOutputs } from "../../../helpers/hooks/useAddressAliasOutputs"; @@ -12,7 +15,9 @@ import { useNftDetails } from "../../../helpers/hooks/useNftDetails"; import { IEventDetails, useParticipationEventDetails } from "../../../helpers/hooks/useParticipationEventDetails"; import { scrollToTop } from "../../../helpers/pageUtils"; import { Bech32AddressHelper } from "../../../helpers/stardust/bech32AddressHelper"; +import { Converter } from "../../../helpers/stardust/convertUtils"; import { deserializeParticipationEventMetadata } from "../../../helpers/stardust/participationUtils"; +import { ReadStream } from "../../../helpers/stardust/readStreamUtils"; import { TransactionsHelper } from "../../../helpers/stardust/transactionsHelper"; import { IBech32AddressDetails } from "../../../models/api/IBech32AddressDetails"; import { IParticipation } from "../../../models/api/stardust/participation/IParticipation"; @@ -24,17 +29,17 @@ export interface IAddressState { balance: number | null; sigLockedBalance: number | null; storageRentBalance: number | null; - addressOutputs: IOutputResponse[] | null; - addressBasicOutputs: IOutputResponse[] | null; + addressOutputs: OutputResponse[] | null; + addressBasicOutputs: OutputResponse[] | null; isBasicOutputsLoading: boolean; - addressAliasOutputs: IOutputResponse[] | null; + addressAliasOutputs: OutputResponse[] | null; isAliasOutputsLoading: boolean; - addressNftOutputs: IOutputResponse[] | null; + addressNftOutputs: OutputResponse[] | null; isNftOutputsLoading: boolean; nftMetadata: HexEncodedString | null; nftIssuerId: string | null; isNftDetailsLoading: boolean; - aliasOutput: IAliasOutput | null; + aliasOutput: AliasOutput | null; isAliasDetailsLoading: boolean; aliasFoundries: string[] | null; isAliasFoundriesLoading: boolean; @@ -100,13 +105,13 @@ export const useAddressPageState = (): [IAddressState, React.Dispatch { if (addressBasicOutputs && addressAliasOutputs && addressNftOutputs) { const mergedOutputResponses = [...addressBasicOutputs, ...addressAliasOutputs, ...addressNftOutputs]; - const outputs = mergedOutputResponses.map(or => or.output); + const outputs = mergedOutputResponses.map(or => or.output); const storageRentBalanceUpdate = TransactionsHelper.computeStorageRentBalance( outputs, rentStructure @@ -162,13 +167,13 @@ export const useAddressPageState = (): [IAddressState, React.Dispatch feature.type === METADATA_FEATURE_TYPE - ) as IMetadataFeature; + const metadataFeature = (outputResponse.output as BasicOutput).features?.find( + feature => feature.type === FeatureType.Metadata + ) as MetadataFeature; if (metadataFeature) { const readStream = new ReadStream(Converter.hexToBytes(metadataFeature.data)); diff --git a/client/src/app/routes/stardust/Block.tsx b/client/src/app/routes/stardust/Block.tsx index e57280e85..6594f3d01 100644 --- a/client/src/app/routes/stardust/Block.tsx +++ b/client/src/app/routes/stardust/Block.tsx @@ -1,8 +1,6 @@ -/* eslint-disable @typescript-eslint/no-shadow */ import { - MILESTONE_PAYLOAD_TYPE, TRANSACTION_PAYLOAD_TYPE, - TAGGED_DATA_PAYLOAD_TYPE, milestoneIdFromMilestonePayload, IMilestonePayload -} from "@iota/iota.js-stardust"; + MilestonePayload, PayloadType, TransactionPayload, Utils +} from "@iota/sdk-wasm/web"; import React, { useContext, useEffect, useState } from "react"; import { RouteComponentProps } from "react-router-dom"; import mainHeaderMessage from "../../../assets/modals/stardust/block/main-header.json"; @@ -31,7 +29,6 @@ import BlockPayloadSection from "../../components/stardust/block/section/BlockPa import ReferencedBlocksSection from "../../components/stardust/block/section/referenced-blocks/ReferencedBlocksSection"; import TruncatedId from "../../components/stardust/TruncatedId"; import NetworkContext from "../../context/NetworkContext"; -import { TransactionsHelper } from "./../../../helpers/stardust/transactionsHelper"; import { BlockProps } from "./BlockProps"; import "./Block.scss"; @@ -51,14 +48,14 @@ const Block: React.FC> = ( ); useEffect(() => { - if (block?.payload?.type === TRANSACTION_PAYLOAD_TYPE) { - const tsxId = TransactionsHelper.computeTransactionIdFromTransactionPayload( - block.payload + if (block?.payload?.type === PayloadType.Transaction) { + const tsxId = Utils.transactionId( + block.payload as TransactionPayload ); setTransactionId(tsxId); } - if (block?.payload?.type === MILESTONE_PAYLOAD_TYPE) { - const mId = milestoneIdFromMilestonePayload(block.payload); + if (block?.payload?.type === PayloadType.Milestone) { + const mId = Utils.milestoneId(block.payload as MilestonePayload); setMilestoneId(mId); } }, [block]); @@ -66,23 +63,23 @@ const Block: React.FC> = ( const { metadata, metadataError, conflictReason, blockTangleStatus } = blockMetadata; const isMarketed = isMarketedNetwork(network); - const isMilestoneBlock = block?.payload?.type === MILESTONE_PAYLOAD_TYPE; - const isTransactionBlock = block?.payload?.type === TRANSACTION_PAYLOAD_TYPE; + const isMilestoneBlock = block?.payload?.type === PayloadType.Milestone; + const isTransactionBlock = block?.payload?.type === PayloadType.Transaction; const isLinksDisabled = metadata?.ledgerInclusionState === "conflicting"; const isLoading = isBlockLoading || isInputsAndOutputsLoading || isBlockMetadataLoading || isMilestoneReferencedBlockLoading; - const milestoneIndex = isMilestoneBlock ? (block.payload as IMilestonePayload).index : undefined; + const milestoneIndex = isMilestoneBlock ? (block?.payload as MilestonePayload).index : undefined; let pageTitle = "Block"; switch (block?.payload?.type) { - case MILESTONE_PAYLOAD_TYPE: + case PayloadType.Milestone: pageTitle = `Milestone Block ${milestoneIndex}`; break; - case TRANSACTION_PAYLOAD_TYPE: + case PayloadType.Transaction: pageTitle = "Transaction Block"; break; - case TAGGED_DATA_PAYLOAD_TYPE: + case PayloadType.TaggedData: pageTitle = "Data Block"; break; default: @@ -204,7 +201,7 @@ const Block: React.FC> = (
)} - {block?.payload?.type === TRANSACTION_PAYLOAD_TYPE && + {block?.payload?.type === PayloadType.Transaction && transferTotal !== null && (
@@ -289,13 +286,13 @@ const Block: React.FC> = ( hasConflicts={isLinksDisabled} conflictReason={conflictReason} onClick={metadata?.referencedByMilestoneIndex - ? (blockId: string) => history.push(`/${network}/block/${blockId}`) + ? (theBlockId: string) => history.push(`/${network}/block/${theBlockId}`) : undefined} />
{isMilestoneBlock && ( )}
diff --git a/client/src/app/routes/stardust/BlockState.ts b/client/src/app/routes/stardust/BlockState.ts index 5681f10e7..e88f7fcd7 100644 --- a/client/src/app/routes/stardust/BlockState.ts +++ b/client/src/app/routes/stardust/BlockState.ts @@ -1,4 +1,4 @@ -import { IBlockMetadata } from "@iota/iota.js-stardust"; +import { IBlockMetadata } from "@iota/sdk-wasm/web"; import { TangleStatus } from "../../../models/tangleStatus"; export interface BlockMetadata { diff --git a/client/src/app/routes/stardust/Foundry.tsx b/client/src/app/routes/stardust/Foundry.tsx index 87c5f4ad5..aafc9a6ed 100644 --- a/client/src/app/routes/stardust/Foundry.tsx +++ b/client/src/app/routes/stardust/Foundry.tsx @@ -1,4 +1,6 @@ -import { ALIAS_ADDRESS_TYPE, IAliasAddress, IFoundryOutput, IImmutableAliasUnlockCondition, IMetadataFeature, METADATA_FEATURE_TYPE } from "@iota/iota.js-stardust"; +import { + AddressType, AliasAddress, FeatureType, FoundryOutput, ImmutableAliasAddressUnlockCondition, MetadataFeature +} from "@iota/sdk-wasm/web"; import React, { useContext, useEffect, useState } from "react"; import { RouteComponentProps } from "react-router"; import nativeTokensMessage from "../../../assets/modals/stardust/address/assets-in-wallet.json"; @@ -40,22 +42,22 @@ const Foundry: React.FC> = ( const [isFormattedBalance, setIsFormattedBalance] = useState(true); const [foundryDetails, isFoundryDetailsLoading, foundryError] = useFoundryDetails(network, foundryId); - const [foundryOutput, setFoundryOutput] = useState(); + const [foundryOutput, setFoundryOutput] = useState(); const [controllerAlias, setControllerAlias] = useState(); const [tokenMetadata, setTokenMetadata] = useState(); const [tokenCount, setTokenCount] = useState(0); useEffect(() => { if (foundryDetails) { - const output = foundryDetails?.output as IFoundryOutput; + const output = foundryDetails?.output as FoundryOutput; const immutableAliasUnlockCondition = - output.unlockConditions[0] as IImmutableAliasUnlockCondition; - const aliasId = (immutableAliasUnlockCondition.address as IAliasAddress).aliasId; + output.unlockConditions[0] as ImmutableAliasAddressUnlockCondition; + const aliasId = (immutableAliasUnlockCondition.address as AliasAddress).aliasId; - const immutableFeatures = (foundryDetails?.output as IFoundryOutput).immutableFeatures; + const immutableFeatures = (foundryDetails?.output as FoundryOutput).immutableFeatures; const metadataFeature = immutableFeatures?.find( - feature => feature.type === METADATA_FEATURE_TYPE - ) as IMetadataFeature; + feature => feature.type === FeatureType.Metadata + ) as MetadataFeature; if (isMounted && metadataFeature) { const parsedMetadata = tryParseMetadata(metadataFeature.data, tokenSchemeIRC30); @@ -75,7 +77,7 @@ const Foundry: React.FC> = ( const balance = Number(foundryOutput.amount); const controllerAliasBech32 = controllerAlias ? - Bech32AddressHelper.buildAddress(bech32Hrp, controllerAlias, ALIAS_ADDRESS_TYPE) : + Bech32AddressHelper.buildAddress(bech32Hrp, controllerAlias, AddressType.Alias) : undefined; foundryContent = ( diff --git a/client/src/app/routes/stardust/NftRedirectRoute.tsx b/client/src/app/routes/stardust/NftRedirectRoute.tsx index b1c445d62..5a0852e61 100644 --- a/client/src/app/routes/stardust/NftRedirectRoute.tsx +++ b/client/src/app/routes/stardust/NftRedirectRoute.tsx @@ -1,4 +1,4 @@ -import { NFT_ADDRESS_TYPE } from "@iota/iota.js-stardust"; +import { AddressType } from "@iota/sdk-wasm/web"; import React, { useContext } from "react"; import { Redirect, RouteComponentProps } from "react-router-dom"; import { Bech32AddressHelper } from "../../../helpers/stardust/bech32AddressHelper"; @@ -22,7 +22,7 @@ const NftRedirectRoute: React.FC> = ( { match: { params: { network, nftId } } } ) => { const { bech32Hrp } = useContext(NetworkContext); - const nftAddress = Bech32AddressHelper.buildAddress(bech32Hrp, nftId, NFT_ADDRESS_TYPE); + const nftAddress = Bech32AddressHelper.buildAddress(bech32Hrp, nftId, AddressType.Nft); const redirectState = { addressDetails: nftAddress }; diff --git a/client/src/app/routes/stardust/Search.tsx b/client/src/app/routes/stardust/Search.tsx index 4661120d6..a82b3b518 100644 --- a/client/src/app/routes/stardust/Search.tsx +++ b/client/src/app/routes/stardust/Search.tsx @@ -1,4 +1,4 @@ -import { ALIAS_ADDRESS_TYPE, NFT_ADDRESS_TYPE, TransactionHelper } from "@iota/iota.js-stardust"; +import { AddressType, Utils } from "@iota/sdk-wasm/web"; import React, { ReactNode } from "react"; import { Redirect, RouteComponentProps } from "react-router-dom"; import { ServiceFactory } from "../../../factories/serviceFactory"; @@ -237,7 +237,7 @@ class Search extends AsyncComponent, Searc }; } else if (response.output) { route = "output"; - const outputId = TransactionHelper.outputIdFromTransactionData( + const outputId = Utils.computeOutputId( response.output.metadata.transactionId, response.output.metadata.outputIndex ); @@ -254,7 +254,7 @@ class Search extends AsyncComponent, Searc } else if (response.aliasId) { route = "addr"; const aliasAddress = this.buildAddressFromIdAndType( - response.aliasId, ALIAS_ADDRESS_TYPE + response.aliasId, AddressType.Alias ); redirectState = { addressDetails: aliasAddress @@ -267,7 +267,7 @@ class Search extends AsyncComponent, Searc route = "addr"; const nftAddress = this.buildAddressFromIdAndType( response.nftId, - NFT_ADDRESS_TYPE + AddressType.Nft ); redirectState = { addressDetails: nftAddress diff --git a/client/src/app/routes/stardust/TransactionPage.tsx b/client/src/app/routes/stardust/TransactionPage.tsx index c2ad0d2a7..db9f1d4a6 100644 --- a/client/src/app/routes/stardust/TransactionPage.tsx +++ b/client/src/app/routes/stardust/TransactionPage.tsx @@ -1,5 +1,5 @@ /* eslint-disable react/jsx-no-useless-fragment */ -import { TransactionHelper, TRANSACTION_PAYLOAD_TYPE } from "@iota/iota.js-stardust"; +import { PayloadType, RegularTransactionEssence, TransactionPayload as ITransactionPayload, Utils } from "@iota/sdk-wasm/web"; import React, { useContext, useEffect, useState } from "react"; import { RouteComponentProps } from "react-router-dom"; import metadataInfoMessage from "../../../assets/modals/stardust/block/metadata.json"; @@ -43,10 +43,12 @@ const TransactionPage: React.FC> = ( const [isFormattedBalance, setIsFormattedBalance] = useState(true); useEffect(() => { - if (block?.payload?.type === TRANSACTION_PAYLOAD_TYPE) { - setIncludedBlockId(TransactionHelper.calculateBlockId(block)); - setTangleNetworkId(block.payload.essence.networkId); - setInputsCommitment(block.payload.essence.inputsCommitment); + if (block?.payload?.type === PayloadType.Transaction) { + const transactionPayload = block.payload as ITransactionPayload; + const transactionEssence = transactionPayload.essence as RegularTransactionEssence; + setIncludedBlockId(Utils.blockId(block)); + setTangleNetworkId(transactionEssence.networkId); + setInputsCommitment(transactionEssence.inputsCommitment); } }, [block]); diff --git a/client/src/app/routes/stardust/Visualizer.tsx b/client/src/app/routes/stardust/Visualizer.tsx index df8146b78..170a0c36a 100644 --- a/client/src/app/routes/stardust/Visualizer.tsx +++ b/client/src/app/routes/stardust/Visualizer.tsx @@ -1,6 +1,5 @@ /* eslint-disable react/jsx-no-useless-fragment */ -import { CONFLICT_REASON_STRINGS, ConflictReason } from "@iota/iota.js-stardust"; -import { Converter } from "@iota/util.js-stardust"; +import { CONFLICT_REASON_STRINGS, ConflictReason, hexToUtf8 } from "@iota/sdk-wasm/web"; import classNames from "classnames"; import React, { useContext, useRef, useState } from "react"; import { Link, RouteComponentProps } from "react-router-dom"; @@ -165,9 +164,7 @@ export const Visualizer: React.FC> = (
Tag
- {Converter.hexToUtf8( - properties.tag - )} + {hexToUtf8(properties.tag)}
Hex
diff --git a/client/src/app/routes/stardust/landing/AnalyticStats.tsx b/client/src/app/routes/stardust/landing/AnalyticStats.tsx index f9af0ffb1..dd3af1c56 100644 --- a/client/src/app/routes/stardust/landing/AnalyticStats.tsx +++ b/client/src/app/routes/stardust/landing/AnalyticStats.tsx @@ -1,4 +1,4 @@ -import { INodeInfoBaseToken } from "@iota/iota.js-stardust"; +import { INodeInfoBaseToken } from "@iota/sdk-wasm/web"; import React from "react"; import { formatAmount } from "../../../../helpers/stardust/valueFormatHelper"; import { IAnalyticStats } from "../../../../models/api/stats/IAnalyticStats"; diff --git a/client/src/app/routes/stardust/landing/MilestoneFeed.tsx b/client/src/app/routes/stardust/landing/MilestoneFeed.tsx index e2a8a0495..d1e3d8f22 100644 --- a/client/src/app/routes/stardust/landing/MilestoneFeed.tsx +++ b/client/src/app/routes/stardust/landing/MilestoneFeed.tsx @@ -1,8 +1,8 @@ -import { HexHelper } from "@iota/util.js-stardust"; import React from "react"; import { Link } from "react-router-dom"; import { DateHelper } from "../../../../helpers/dateHelper"; import { useMilestoneInterval } from "../../../../helpers/hooks/useMilestoneInterval"; +import { HexHelper } from "../../../../helpers/stardust/hexHelper"; import { INetwork } from "../../../../models/config/INetwork"; import { IMilestoneFeedItem } from "../../../../models/IMilestoneFeedItem"; import TruncatedId from "../../../components/stardust/TruncatedId"; diff --git a/client/src/app/routes/stardust/landing/ShimmerClaimedUtils.spec.ts b/client/src/app/routes/stardust/landing/ShimmerClaimedUtils.spec.ts index ba4ce501a..f48405a68 100644 --- a/client/src/app/routes/stardust/landing/ShimmerClaimedUtils.spec.ts +++ b/client/src/app/routes/stardust/landing/ShimmerClaimedUtils.spec.ts @@ -1,4 +1,4 @@ -import { INodeInfoBaseToken } from "@iota/iota.js-stardust"; +import { INodeInfoBaseToken } from "@iota/sdk-wasm/web"; import { buildShimmerClaimedStats } from "./ShimmerClaimedUtils"; const TOKEN_INFO: INodeInfoBaseToken = { diff --git a/client/src/app/routes/stardust/landing/ShimmerClaimedUtils.ts b/client/src/app/routes/stardust/landing/ShimmerClaimedUtils.ts index e56ac7f39..f24e19145 100644 --- a/client/src/app/routes/stardust/landing/ShimmerClaimedUtils.ts +++ b/client/src/app/routes/stardust/landing/ShimmerClaimedUtils.ts @@ -1,4 +1,4 @@ -import { INodeInfoBaseToken } from "@iota/iota.js-stardust"; +import { INodeInfoBaseToken } from "@iota/sdk-wasm/web"; import BigDecimal from "../../../../helpers/bigDecimal"; import { formatAmount } from "../../../../helpers/stardust/valueFormatHelper"; diff --git a/client/src/helpers/hooks/useAddressAliasOutputs.ts b/client/src/helpers/hooks/useAddressAliasOutputs.ts index fc5692903..14f6add40 100644 --- a/client/src/helpers/hooks/useAddressAliasOutputs.ts +++ b/client/src/helpers/hooks/useAddressAliasOutputs.ts @@ -1,4 +1,4 @@ -import { IOutputResponse } from "@iota/iota.js-stardust"; +import { OutputResponse } from "@iota/sdk-wasm/web"; import { useEffect, useState } from "react"; import { ServiceFactory } from "../../factories/serviceFactory"; import { STARDUST } from "../../models/config/protocolVersion"; @@ -13,10 +13,10 @@ import { useIsMounted } from "./useIsMounted"; */ export function useAddressAliasOutputs( network: string, addressBech32: string | null -): [IOutputResponse[] | null, boolean] { +): [OutputResponse[] | null, boolean] { const isMounted = useIsMounted(); const [apiClient] = useState(ServiceFactory.get(`api-client-${STARDUST}`)); - const [outputs, setOutputs] = useState(null); + const [outputs, setOutputs] = useState(null); const [isLoading, setIsLoading] = useState(true); useEffect(() => { diff --git a/client/src/helpers/hooks/useAddressBasicOutputs.ts b/client/src/helpers/hooks/useAddressBasicOutputs.ts index 42c2640c0..51ff87fb2 100644 --- a/client/src/helpers/hooks/useAddressBasicOutputs.ts +++ b/client/src/helpers/hooks/useAddressBasicOutputs.ts @@ -1,4 +1,4 @@ -import { IOutputResponse } from "@iota/iota.js-stardust"; +import { OutputResponse } from "@iota/sdk-wasm/web"; import { useEffect, useState } from "react"; import { ServiceFactory } from "../../factories/serviceFactory"; import { STARDUST } from "../../models/config/protocolVersion"; @@ -13,10 +13,10 @@ import { useIsMounted } from "./useIsMounted"; */ export function useAddressBasicOutputs( network: string, addressBech32: string | null -): [IOutputResponse[] | null, boolean] { +): [OutputResponse[] | null, boolean] { const isMounted = useIsMounted(); const [apiClient] = useState(ServiceFactory.get(`api-client-${STARDUST}`)); - const [outputs, setOutputs] = useState(null); + const [outputs, setOutputs] = useState(null); const [isLoading, setIsLoading] = useState(true); useEffect(() => { diff --git a/client/src/helpers/hooks/useAddressHistory.ts b/client/src/helpers/hooks/useAddressHistory.ts index 7c3b700be..cc7065897 100644 --- a/client/src/helpers/hooks/useAddressHistory.ts +++ b/client/src/helpers/hooks/useAddressHistory.ts @@ -1,4 +1,4 @@ -import { IOutputResponse } from "@iota/iota.js-stardust"; +import { OutputResponse } from "@iota/sdk-wasm/web"; import { useEffect, useState } from "react"; import { ServiceFactory } from "../../factories/serviceFactory"; import { ITransactionHistoryRequest } from "../../models/api/stardust/ITransactionHistoryRequest"; @@ -8,7 +8,7 @@ import { StardustApiClient } from "../../services/stardust/stardustApiClient"; import { useIsMounted } from "./useIsMounted"; interface IOutputDetailsMap { - [outputId: string]: IOutputResponse; + [outputId: string]: OutputResponse; } /** diff --git a/client/src/helpers/hooks/useAddressNftOutputs.ts b/client/src/helpers/hooks/useAddressNftOutputs.ts index cd04f037c..2c3024d51 100644 --- a/client/src/helpers/hooks/useAddressNftOutputs.ts +++ b/client/src/helpers/hooks/useAddressNftOutputs.ts @@ -1,4 +1,4 @@ -import { IOutputResponse } from "@iota/iota.js-stardust"; +import { OutputResponse } from "@iota/sdk-wasm/web"; import { useEffect, useState } from "react"; import { ServiceFactory } from "../../factories/serviceFactory"; import { STARDUST } from "../../models/config/protocolVersion"; @@ -13,10 +13,10 @@ import { useIsMounted } from "./useIsMounted"; */ export function useAddressNftOutputs( network: string, addressBech32: string | null -): [IOutputResponse[] | null, boolean] { +): [OutputResponse[] | null, boolean] { const isMounted = useIsMounted(); const [apiClient] = useState(ServiceFactory.get(`api-client-${STARDUST}`)); - const [outputs, setOutputs] = useState(null); + const [outputs, setOutputs] = useState(null); const [isLoading, setIsLoading] = useState(true); useEffect(() => { diff --git a/client/src/helpers/hooks/useAliasControlledFoundries.ts b/client/src/helpers/hooks/useAliasControlledFoundries.ts index d84358764..efaa568ca 100644 --- a/client/src/helpers/hooks/useAliasControlledFoundries.ts +++ b/client/src/helpers/hooks/useAliasControlledFoundries.ts @@ -1,4 +1,4 @@ -import { FOUNDRY_OUTPUT_TYPE, HexEncodedString, TransactionHelper } from "@iota/iota.js-stardust"; +import { OutputType, HexEncodedString, FoundryOutput, Utils } from "@iota/sdk-wasm/web"; import { useEffect, useState } from "react"; import { ServiceFactory } from "../../factories/serviceFactory"; import { IBech32AddressDetails } from "../../models/api/IBech32AddressDetails"; @@ -59,11 +59,11 @@ export function useAliasControlledFoundries(network: string, aliasAddress: IBech const foundryId = apiClient.outputDetails({ network, outputId }).then( response => { const details = response.output; - if (aliasAddress?.hex && !response.error && details?.output?.type === FOUNDRY_OUTPUT_TYPE) { - const output = details.output; + if (aliasAddress?.hex && !response.error && details?.output?.type === OutputType.Foundry) { + const output = details.output as FoundryOutput; const serialNumber = output.serialNumber; const tokenSchemeType = output.tokenScheme.type; - const tokenId = TransactionHelper.constructTokenId( + const tokenId = Utils.computeTokenId( aliasAddress.hex, serialNumber, tokenSchemeType diff --git a/client/src/helpers/hooks/useAliasDetails.ts b/client/src/helpers/hooks/useAliasDetails.ts index c87bc133d..3d8b361c0 100644 --- a/client/src/helpers/hooks/useAliasDetails.ts +++ b/client/src/helpers/hooks/useAliasDetails.ts @@ -1,9 +1,9 @@ -import { IAliasOutput } from "@iota/iota.js-stardust"; -import { HexHelper } from "@iota/util.js-stardust"; +import { AliasOutput } from "@iota/sdk-wasm/web"; import { useEffect, useState } from "react"; import { ServiceFactory } from "../../factories/serviceFactory"; import { STARDUST } from "../../models/config/protocolVersion"; import { StardustApiClient } from "../../services/stardust/stardustApiClient"; +import { HexHelper } from "../stardust/hexHelper"; import { useIsMounted } from "./useIsMounted"; /** @@ -14,12 +14,12 @@ import { useIsMounted } from "./useIsMounted"; */ export function useAliasDetails(network: string, aliasId: string | null): [ - IAliasOutput | null, + AliasOutput | null, boolean ] { const isMounted = useIsMounted(); const [apiClient] = useState(ServiceFactory.get(`api-client-${STARDUST}`)); - const [aliasOutput, setAliasOutput] = useState(null); + const [aliasOutput, setAliasOutput] = useState(null); const [isLoading, setIsLoading] = useState(true); useEffect(() => { @@ -32,7 +32,7 @@ export function useAliasDetails(network: string, aliasId: string | null): aliasId: HexHelper.addPrefix(aliasId) }).then(response => { if (!response?.error && isMounted) { - const output = response.aliasDetails?.output as IAliasOutput; + const output = response.aliasDetails?.output as AliasOutput; setAliasOutput(output); } diff --git a/client/src/helpers/hooks/useBlock.ts b/client/src/helpers/hooks/useBlock.ts index 56131efdf..6e7c1d194 100644 --- a/client/src/helpers/hooks/useBlock.ts +++ b/client/src/helpers/hooks/useBlock.ts @@ -1,9 +1,9 @@ -import { IBlock } from "@iota/iota.js-stardust"; -import { HexHelper } from "@iota/util.js-stardust"; +import { Block } from "@iota/sdk-wasm/web"; import { useEffect, useState } from "react"; import { ServiceFactory } from "../../factories/serviceFactory"; import { STARDUST } from "../../models/config/protocolVersion"; import { StardustApiClient } from "../../services/stardust/stardustApiClient"; +import { HexHelper } from "../stardust/hexHelper"; import { useIsMounted } from "./useIsMounted"; /** @@ -14,18 +14,19 @@ import { useIsMounted } from "./useIsMounted"; */ export function useBlock(network: string, blockId: string | null): [ - IBlock | null, + Block | null, boolean, string? ] { const isMounted = useIsMounted(); const [apiClient] = useState(ServiceFactory.get(`api-client-${STARDUST}`)); - const [block, setBlock] = useState(null); + const [block, setBlock] = useState(null); const [error, setError] = useState(); const [isLoading, setIsLoading] = useState(true); useEffect(() => { setIsLoading(true); + setBlock(null); if (blockId) { // eslint-disable-next-line no-void void (async () => { diff --git a/client/src/helpers/hooks/useBlockChildren.ts b/client/src/helpers/hooks/useBlockChildren.ts index 49d1ca670..87bf1ba55 100644 --- a/client/src/helpers/hooks/useBlockChildren.ts +++ b/client/src/helpers/hooks/useBlockChildren.ts @@ -1,9 +1,9 @@ -import { HexEncodedString } from "@iota/iota.js-stardust"; -import { HexHelper } from "@iota/util.js-stardust"; +import { HexEncodedString } from "@iota/sdk-wasm/web"; import { useEffect, useState } from "react"; import { ServiceFactory } from "../../factories/serviceFactory"; import { STARDUST } from "../../models/config/protocolVersion"; import { StardustApiClient } from "../../services/stardust/stardustApiClient"; +import { HexHelper } from "../stardust/hexHelper"; import { useIsMounted } from "./useIsMounted"; /** diff --git a/client/src/helpers/hooks/useBlockMetadata.ts b/client/src/helpers/hooks/useBlockMetadata.ts index 06829a747..d1b4ce785 100644 --- a/client/src/helpers/hooks/useBlockMetadata.ts +++ b/client/src/helpers/hooks/useBlockMetadata.ts @@ -1,10 +1,10 @@ -import { HexHelper } from "@iota/util.js-stardust"; import { useEffect, useState } from "react"; import { BlockMetadata } from "../../app/routes/stardust/BlockState"; import { ServiceFactory } from "../../factories/serviceFactory"; import { STARDUST } from "../../models/config/protocolVersion"; import { calculateConflictReason, calculateStatus } from "../../models/tangleStatus"; import { StardustApiClient } from "../../services/stardust/stardustApiClient"; +import { HexHelper } from "../stardust/hexHelper"; import { useIsMounted } from "./useIsMounted"; /** diff --git a/client/src/helpers/hooks/useFoundryDetails.ts b/client/src/helpers/hooks/useFoundryDetails.ts index a1caacd38..e8bb94ca4 100644 --- a/client/src/helpers/hooks/useFoundryDetails.ts +++ b/client/src/helpers/hooks/useFoundryDetails.ts @@ -1,9 +1,9 @@ -import { IOutputResponse } from "@iota/iota.js-stardust"; -import { HexHelper } from "@iota/util.js-stardust"; +import { OutputResponse } from "@iota/sdk-wasm/web"; import { useEffect, useState } from "react"; import { ServiceFactory } from "../../factories/serviceFactory"; import { STARDUST } from "../../models/config/protocolVersion"; import { StardustApiClient } from "../../services/stardust/stardustApiClient"; +import { HexHelper } from "../stardust/hexHelper"; import { useIsMounted } from "./useIsMounted"; /** @@ -14,13 +14,13 @@ import { useIsMounted } from "./useIsMounted"; */ export function useFoundryDetails(network: string, foundryId: string | null): [ - IOutputResponse | null, + OutputResponse | null, boolean, string? ] { const isMounted = useIsMounted(); const [apiClient] = useState(ServiceFactory.get(`api-client-${STARDUST}`)); - const [foundryDetails, setFoundryDetails] = useState(null); + const [foundryDetails, setFoundryDetails] = useState(null); const [error, setError] = useState(); const [isLoading, setIsLoading] = useState(true); diff --git a/client/src/helpers/hooks/useInputsAndOutputs.ts b/client/src/helpers/hooks/useInputsAndOutputs.ts index 1dc62f4c3..2b9d71d1a 100644 --- a/client/src/helpers/hooks/useInputsAndOutputs.ts +++ b/client/src/helpers/hooks/useInputsAndOutputs.ts @@ -1,4 +1,4 @@ -import { IBlock, IUTXOInput, TRANSACTION_PAYLOAD_TYPE, UnlockTypes } from "@iota/iota.js-stardust"; +import { Block, Unlock, PayloadType } from "@iota/sdk-wasm/web"; import { useContext, useEffect, useState } from "react"; import NetworkContext from "../../app/context/NetworkContext"; import { ServiceFactory } from "../../factories/serviceFactory"; @@ -15,10 +15,10 @@ import { useIsMounted } from "./useIsMounted"; * @param block The block * @returns The inputs, unlocks, outputs, transfer total an a loading bool. */ -export function useInputsAndOutputs(network: string, block: IBlock | null): +export function useInputsAndOutputs(network: string, block: Block | null): [ - (IUTXOInput & IInput)[] | null, - UnlockTypes[] | null, + IInput[] | null, + Unlock[] | null, IOutput[] | null, number | null, boolean @@ -26,8 +26,8 @@ export function useInputsAndOutputs(network: string, block: IBlock | null): const isMounted = useIsMounted(); const [apiClient] = useState(ServiceFactory.get(`api-client-${STARDUST}`)); const { bech32Hrp } = useContext(NetworkContext); - const [tsxInputs, setInputs] = useState<(IUTXOInput & IInput)[] | null>(null); - const [tsxUnlocks, setUnlocks] = useState(null); + const [tsxInputs, setInputs] = useState(null); + const [tsxUnlocks, setUnlocks] = useState(null); const [tsxOutputs, setOutputs] = useState(null); const [tsxTransferTotal, setTransferTotal] = useState(null); @@ -35,7 +35,7 @@ export function useInputsAndOutputs(network: string, block: IBlock | null): useEffect(() => { setIsLoading(true); - if (block?.payload?.type === TRANSACTION_PAYLOAD_TYPE) { + if (block?.payload?.type === PayloadType.Transaction) { // eslint-disable-next-line no-void void (async () => { const { inputs, unlocks, outputs, transferTotal } = diff --git a/client/src/helpers/hooks/useMilestoneDetails.ts b/client/src/helpers/hooks/useMilestoneDetails.ts index 93daf0f26..19c4ada38 100644 --- a/client/src/helpers/hooks/useMilestoneDetails.ts +++ b/client/src/helpers/hooks/useMilestoneDetails.ts @@ -1,4 +1,4 @@ -import { IMilestonePayload } from "@iota/iota.js-stardust"; +import { MilestonePayload } from "@iota/sdk-wasm/web"; import { useEffect, useState } from "react"; import { ServiceFactory } from "../../factories/serviceFactory"; import { STARDUST } from "../../models/config/protocolVersion"; @@ -8,7 +8,7 @@ import { useIsMounted } from "./useIsMounted"; interface IMilestoneDetails { blockId?: string; milestoneId?: string; - milestone?: IMilestonePayload; + milestone?: MilestonePayload; error?: string; } diff --git a/client/src/helpers/hooks/useMilestoneReferencedBlock.ts b/client/src/helpers/hooks/useMilestoneReferencedBlock.ts index cf601df78..94b2f1a64 100644 --- a/client/src/helpers/hooks/useMilestoneReferencedBlock.ts +++ b/client/src/helpers/hooks/useMilestoneReferencedBlock.ts @@ -1,8 +1,8 @@ -import { HexHelper } from "@iota/util.js-stardust"; import { useEffect, useState } from "react"; import { ServiceFactory } from "../../factories/serviceFactory"; import { STARDUST } from "../../models/config/protocolVersion"; import { StardustApiClient } from "../../services/stardust/stardustApiClient"; +import { HexHelper } from "../stardust/hexHelper"; import { useIsMounted } from "./useIsMounted"; /** diff --git a/client/src/helpers/hooks/useNftDetails.ts b/client/src/helpers/hooks/useNftDetails.ts index 0cd51a8ca..8b544f29c 100644 --- a/client/src/helpers/hooks/useNftDetails.ts +++ b/client/src/helpers/hooks/useNftDetails.ts @@ -1,12 +1,15 @@ import { - ED25519_ADDRESS_TYPE, ALIAS_ADDRESS_TYPE, HexEncodedString, IIssuerFeature, - IMetadataFeature, INftOutput, ISSUER_FEATURE_TYPE, METADATA_FEATURE_TYPE, NFT_ADDRESS_TYPE -} from "@iota/iota.js-stardust"; -import { HexHelper } from "@iota/util.js-stardust"; + AddressType, + AliasAddress, + Ed25519Address, + FeatureType, + HexEncodedString, IssuerFeature, MetadataFeature, NftAddress, NftOutput +} from "@iota/sdk-wasm/web"; import { useEffect, useState } from "react"; import { ServiceFactory } from "../../factories/serviceFactory"; import { STARDUST } from "../../models/config/protocolVersion"; import { StardustApiClient } from "../../services/stardust/stardustApiClient"; +import { HexHelper } from "../stardust/hexHelper"; import { useIsMounted } from "./useIsMounted"; @@ -18,14 +21,14 @@ import { useIsMounted } from "./useIsMounted"; */ export function useNftDetails(network: string, nftId: string | null): [ - INftOutput | null, + NftOutput | null, HexEncodedString | null, string | null, boolean ] { const isMounted = useIsMounted(); const [apiClient] = useState(ServiceFactory.get(`api-client-${STARDUST}`)); - const [nftOutput, setNftOutput] = useState(null); + const [nftOutput, setNftOutput] = useState(null); const [nftMetadata, setNftMetadata] = useState(null); const [nftIssuerId, setNftIssuerId] = useState(null); const [isLoading, setIsLoading] = useState(true); @@ -43,28 +46,34 @@ export function useNftDetails(network: string, nftId: string | null): nftId: HexHelper.addPrefix(nftId) }).then(response => { if (!response?.error) { - const output = response.nftDetails?.output as INftOutput; + const output = response.nftDetails?.output as NftOutput; const metadataFeature = output?.immutableFeatures?.find( - feature => feature.type === METADATA_FEATURE_TYPE - ) as IMetadataFeature; + feature => feature.type === FeatureType.Metadata + ) as MetadataFeature; const issuerFeature = output?.immutableFeatures?.find( - feature => feature.type === ISSUER_FEATURE_TYPE - ) as IIssuerFeature; + feature => feature.type === FeatureType.Issuer + ) as IssuerFeature; let issuerId = null; if (issuerFeature) { switch (issuerFeature.address.type) { - case ED25519_ADDRESS_TYPE: - issuerId = issuerFeature.address.pubKeyHash; + case AddressType.Ed25519: { + const ed25519Address = issuerFeature.address as Ed25519Address; + issuerId = ed25519Address.pubKeyHash; break; - case ALIAS_ADDRESS_TYPE: - issuerId = issuerFeature.address.aliasId; + } + case AddressType.Alias: { + const aliasAddress = issuerFeature.address as AliasAddress; + issuerId = aliasAddress.aliasId; break; - case NFT_ADDRESS_TYPE: - issuerId = issuerFeature.address.nftId; + } + case AddressType.Nft: { + const nftAddress = issuerFeature.address as NftAddress; + issuerId = nftAddress.nftId; break; + } default: break; } diff --git a/client/src/helpers/hooks/useOutputDetails.ts b/client/src/helpers/hooks/useOutputDetails.ts index e590b0dfa..396689b55 100644 --- a/client/src/helpers/hooks/useOutputDetails.ts +++ b/client/src/helpers/hooks/useOutputDetails.ts @@ -1,9 +1,9 @@ -import { OutputTypes, IOutputMetadataResponse } from "@iota/iota.js-stardust"; -import { HexHelper } from "@iota/util.js-stardust"; +import { Output, IOutputMetadataResponse } from "@iota/sdk-wasm/web"; import { useEffect, useState } from "react"; import { ServiceFactory } from "../../factories/serviceFactory"; import { STARDUST } from "../../models/config/protocolVersion"; import { StardustApiClient } from "../../services/stardust/stardustApiClient"; +import { HexHelper } from "../stardust/hexHelper"; import { useIsMounted } from "./useIsMounted"; /** @@ -14,14 +14,14 @@ import { useIsMounted } from "./useIsMounted"; */ export function useOutputDetails(network: string, outputId: string | null): [ - OutputTypes | null, + Output | null, IOutputMetadataResponse | null, boolean, string? ] { const isMounted = useIsMounted(); const [apiClient] = useState(ServiceFactory.get(`api-client-${STARDUST}`)); - const [output, setOutput] = useState(null); + const [output, setOutput] = useState(null); const [metadata, setMetadata] = useState(null); const [error, setError] = useState(); const [isLoading, setIsLoading] = useState(true); diff --git a/client/src/helpers/hooks/useOutputsDetails.ts b/client/src/helpers/hooks/useOutputsDetails.ts index ce65c52b7..b657308c9 100644 --- a/client/src/helpers/hooks/useOutputsDetails.ts +++ b/client/src/helpers/hooks/useOutputsDetails.ts @@ -1,13 +1,13 @@ -import { IOutputResponse } from "@iota/iota.js-stardust"; -import { HexHelper } from "@iota/util.js-stardust"; +import { OutputResponse } from "@iota/sdk-wasm/web"; import { useEffect, useState } from "react"; import { ServiceFactory } from "../../factories/serviceFactory"; import { STARDUST } from "../../models/config/protocolVersion"; import { StardustApiClient } from "../../services/stardust/stardustApiClient"; +import { HexHelper } from "../stardust/hexHelper"; import { useIsMounted } from "./useIsMounted"; interface IOutputDetails { - outputDetails: IOutputResponse; + outputDetails: OutputResponse; outputId: string; } diff --git a/client/src/helpers/hooks/useTaggedOutputs.ts b/client/src/helpers/hooks/useTaggedOutputs.ts index e62072672..a10b001ab 100644 --- a/client/src/helpers/hooks/useTaggedOutputs.ts +++ b/client/src/helpers/hooks/useTaggedOutputs.ts @@ -1,4 +1,4 @@ -import { IOutputResponse } from "@iota/iota.js-stardust"; +import { OutputResponse } from "@iota/sdk-wasm/web"; import { useEffect, useState } from "react"; import { useHistory, useLocation } from "react-router-dom"; import { OUTPUT_LIST_TABS } from "../../app/routes/stardust/OutputList"; @@ -14,7 +14,7 @@ interface OutputListLocationProps { } interface OutputListItem { - outputDetails: IOutputResponse; + outputDetails: OutputResponse; outputId: string; } diff --git a/client/src/helpers/hooks/useTransactionIncludedBlock.ts b/client/src/helpers/hooks/useTransactionIncludedBlock.ts index 47bb4de84..728783927 100644 --- a/client/src/helpers/hooks/useTransactionIncludedBlock.ts +++ b/client/src/helpers/hooks/useTransactionIncludedBlock.ts @@ -1,9 +1,9 @@ -import { IBlock } from "@iota/iota.js-stardust"; -import { HexHelper } from "@iota/util.js-stardust"; +import { Block } from "@iota/sdk-wasm/web"; import { useEffect, useState } from "react"; import { ServiceFactory } from "../../factories/serviceFactory"; import { STARDUST } from "../../models/config/protocolVersion"; import { StardustApiClient } from "../../services/stardust/stardustApiClient"; +import { HexHelper } from "../stardust/hexHelper"; import { useIsMounted } from "./useIsMounted"; /** @@ -14,13 +14,13 @@ import { useIsMounted } from "./useIsMounted"; */ export function useTransactionIncludedBlock(network: string, transactionId: string | null): [ - IBlock | null, + Block | null, boolean, string? ] { const isMounted = useIsMounted(); const [apiClient] = useState(ServiceFactory.get(`api-client-${STARDUST}`)); - const [block, setBlock] = useState(null); + const [block, setBlock] = useState(null); const [error, setError] = useState(); const [isLoading, setIsLoading] = useState(true); diff --git a/client/src/helpers/hooks/useVisualizerState.tsx b/client/src/helpers/hooks/useVisualizerState.tsx index 5bf5d2a12..7a5bd1a61 100644 --- a/client/src/helpers/hooks/useVisualizerState.tsx +++ b/client/src/helpers/hooks/useVisualizerState.tsx @@ -1,4 +1,3 @@ -import { Converter } from "@iota/util.js-stardust"; import { useEffect, useRef, useState } from "react"; import Viva from "vivagraphjs"; import { ServiceFactory } from "../../factories/serviceFactory"; @@ -8,6 +7,7 @@ import { INodeData } from "../../models/graph/stardust/INodeData"; import { SettingsService } from "../../services/settingsService"; import { StardustFeedClient } from "../../services/stardust/stardustFeedClient"; import { buildNodeShader } from "../nodeShader"; +import { Converter } from "../stardust/convertUtils"; const MAX_ITEMS: number = 2500; const FEED_PROBE_THRESHOLD: number = 3000; diff --git a/client/src/helpers/stardust/base64Encode.ts b/client/src/helpers/stardust/base64Encode.ts new file mode 100644 index 000000000..a54b50c09 --- /dev/null +++ b/client/src/helpers/stardust/base64Encode.ts @@ -0,0 +1,250 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 +/* eslint-disable no-bitwise */ +/* eslint-disable no-mixed-operators */ +/* eslint-disable unicorn/number-literal-case */ +/* eslint-disable unicorn/prefer-code-point */ +/** + * Class to help with base64 Encoding/Decoding. + * Sourced from https://github.com/beatgammit/base64-js. + */ +export class Base64 { + /** + * Alphabet table for encoding. + * @internal + */ + private static readonly _LOOKUP: string = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + + /** + * Alphabet table for decoding. + * @internal + */ + private static readonly _REVERSE_LOOKUP: { [id: number]: number } = { + "43": 62, + "45": 62, + "47": 63, + "48": 52, + "49": 53, + "50": 54, + "51": 55, + "52": 56, + "53": 57, + "54": 58, + "55": 59, + "56": 60, + "57": 61, + "65": 0, + "66": 1, + "67": 2, + "68": 3, + "69": 4, + "70": 5, + "71": 6, + "72": 7, + "73": 8, + "74": 9, + "75": 10, + "76": 11, + "77": 12, + "78": 13, + "79": 14, + "80": 15, + "81": 16, + "82": 17, + "83": 18, + "84": 19, + "85": 20, + "86": 21, + "87": 22, + "88": 23, + "89": 24, + "90": 25, + "95": 63, + "97": 26, + "98": 27, + "99": 28, + "100": 29, + "101": 30, + "102": 31, + "103": 32, + "104": 33, + "105": 34, + "106": 35, + "107": 36, + "108": 37, + "109": 38, + "110": 39, + "111": 40, + "112": 41, + "113": 42, + "114": 43, + "115": 44, + "116": 45, + "117": 46, + "118": 47, + "119": 48, + "120": 49, + "121": 50, + "122": 51 + }; + + /** + * Get the byte length of the data. + * @param base64 The base64 string. + * @returns The byte length of the data. + */ + public static byteLength(base64: string): number { + const lens = Base64.getLengths(base64); + return Base64.calcByteLength(lens[0], lens[1]); + } + + /** + * Convert the base 64 string to a byte array. + * @param base64 The base64 string to convert. + * @returns The byte array. + */ + public static decode(base64: string): Uint8Array { + let tmp; + const lens = Base64.getLengths(base64); + const validLen = lens[0]; + const placeHoldersLen = lens[1]; + + const arr = new Uint8Array(Base64.calcByteLength(validLen, placeHoldersLen)); + + let curByte = 0; + + // if there are placeholders, only get up to the last complete 4 chars + const len = placeHoldersLen > 0 ? validLen - 4 : validLen; + + let i; + for (i = 0; i < len; i += 4) { + tmp = + (Base64._REVERSE_LOOKUP[base64.charCodeAt(i)] << 18) | + (Base64._REVERSE_LOOKUP[base64.charCodeAt(i + 1)] << 12) | + (Base64._REVERSE_LOOKUP[base64.charCodeAt(i + 2)] << 6) | + Base64._REVERSE_LOOKUP[base64.charCodeAt(i + 3)]; + arr[curByte++] = (tmp >> 16) & 0xff; + arr[curByte++] = (tmp >> 8) & 0xff; + arr[curByte++] = tmp & 0xff; + } + + if (placeHoldersLen === 2) { + tmp = + (Base64._REVERSE_LOOKUP[base64.charCodeAt(i)] << 2) | + (Base64._REVERSE_LOOKUP[base64.charCodeAt(i + 1)] >> 4); + arr[curByte++] = tmp & 0xff; + } + + if (placeHoldersLen === 1) { + tmp = + (Base64._REVERSE_LOOKUP[base64.charCodeAt(i)] << 10) | + (Base64._REVERSE_LOOKUP[base64.charCodeAt(i + 1)] << 4) | + (Base64._REVERSE_LOOKUP[base64.charCodeAt(i + 2)] >> 2); + arr[curByte++] = (tmp >> 8) & 0xff; + arr[curByte++] = tmp & 0xff; + } + + return arr; + } + + /** + * Convert a byte array to base 64. + * @param bytes The byte array to convert. + * @returns The data as bas64 string. + */ + public static encode(bytes: Uint8Array): string { + let tmp; + const len = bytes.length; + const extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes + const parts = []; + const maxChunkLength = 16383; // must be multiple of 3 + + // go through the array every three bytes, we'll deal with trailing stuff later + for (let i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(Base64.encodeChunk(bytes, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength)); + } + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = bytes[len - 1]; + parts.push(`${Base64._LOOKUP[tmp >> 2] + Base64._LOOKUP[(tmp << 4) & 0x3f]}==`); + } else if (extraBytes === 2) { + tmp = (bytes[len - 2] << 8) + bytes[len - 1]; + parts.push( + `${Base64._LOOKUP[tmp >> 10] + Base64._LOOKUP[(tmp >> 4) & 0x3f] + Base64._LOOKUP[(tmp << 2) & 0x3f]}=` + ); + } + + return parts.join(""); + } + + /** + * Calculate the byte length. + * @param validLen The valid length. + * @param placeHoldersLen The placeholder length. + * @returns The length. + * @internal + */ + private static calcByteLength(validLen: number, placeHoldersLen: number): number { + return ((validLen + placeHoldersLen) * 3) / 4 - placeHoldersLen; + } + + /** + * Get the valid and placeholder lengths from a bas64 string. + * @param base64 The base64 string. + * @returns The lengths. + * @internal + */ + private static getLengths(base64: string): number[] { + const len = base64.length; + + if (len % 4 > 0) { + throw new Error("Invalid string. Length must be a multiple of 4"); + } + + // Trim off extra bytes after placeholder bytes are found + // See: https://github.com/beatgammit/base64-js/issues/42 + let validLen = base64.indexOf("="); + if (validLen === -1) { + validLen = len; + } + + const placeHoldersLen = validLen === len ? 0 : 4 - (validLen % 4); + + return [validLen, placeHoldersLen]; + } + + /** + * Convert the triplet to base 64. + * @param num The number to convert. + * @returns The base64 erncoding. + * @internal + */ + private static tripletToBase64(num: number): string { + return ( + Base64._LOOKUP[(num >> 18) & 0x3f] + + Base64._LOOKUP[(num >> 12) & 0x3f] + + Base64._LOOKUP[(num >> 6) & 0x3f] + + Base64._LOOKUP[num & 0x3f] + ); + } + + /** + * Encode a chunk. + * @param bytes The byte array. + * @param start The start index in the buffer. + * @param end The end index in the buffer. + * @returns The encoded chunk. + * @internal + */ + private static encodeChunk(bytes: Uint8Array, start: number, end: number): string { + let tmp; + const output = []; + for (let i = start; i < end; i += 3) { + tmp = ((bytes[i] << 16) & 0xff0000) + ((bytes[i + 1] << 8) & 0xff00) + (bytes[i + 2] & 0xff); + output.push(Base64.tripletToBase64(tmp)); + } + return output.join(""); + } +} + diff --git a/client/src/helpers/stardust/bech32AddressHelper.ts b/client/src/helpers/stardust/bech32AddressHelper.ts index bfc3a2e71..ef883a203 100644 --- a/client/src/helpers/stardust/bech32AddressHelper.ts +++ b/client/src/helpers/stardust/bech32AddressHelper.ts @@ -1,6 +1,8 @@ -import { AddressTypes, ALIAS_ADDRESS_TYPE, Bech32Helper, ED25519_ADDRESS_TYPE, NFT_ADDRESS_TYPE } from "@iota/iota.js-stardust"; -import { Converter, HexHelper } from "@iota/util.js-stardust"; +import { Bech32Helper } from "@iota/iota.js"; +import { Address, AddressType, AliasAddress, Ed25519Address, NftAddress } from "@iota/sdk-wasm/web"; import { IBech32AddressDetails } from "../../models/api/IBech32AddressDetails"; +import { Converter } from "./convertUtils"; +import { HexHelper } from "./hexHelper"; export class Bech32AddressHelper { /** @@ -10,7 +12,7 @@ export class Bech32AddressHelper { * @param typeHint The type of the address. * @returns The parts of the address. */ - public static buildAddress(hrp: string, address: string | AddressTypes, typeHint?: number): IBech32AddressDetails { + public static buildAddress(hrp: string, address: string | Address, typeHint?: number): IBech32AddressDetails { return typeof address === "string" ? this.buildAddressFromString(hrp, address, typeHint) : this.buildAddressFromTypes(hrp, address); @@ -36,7 +38,7 @@ export class Bech32AddressHelper { if (!bech32) { // We assume this is hex and either use the hint or assume ed25519 for now hex = address; - type = typeHint ?? ED25519_ADDRESS_TYPE; + type = typeHint ?? AddressType.Ed25519; bech32 = Bech32Helper.toBech32(type, Converter.hexToBytes(hex), hrp); } @@ -48,20 +50,20 @@ export class Bech32AddressHelper { }; } - private static buildAddressFromTypes(hrp: string, address: AddressTypes): IBech32AddressDetails { + private static buildAddressFromTypes(hrp: string, address: Address): IBech32AddressDetails { let hex: string = ""; - if (address.type === ED25519_ADDRESS_TYPE) { + if (address.type === AddressType.Ed25519) { hex = HexHelper.stripPrefix( - address.pubKeyHash + (address as Ed25519Address).pubKeyHash ); - } else if (address.type === ALIAS_ADDRESS_TYPE) { + } else if (address.type === AddressType.Alias) { hex = HexHelper.stripPrefix( - address.aliasId + (address as AliasAddress).aliasId ); - } else if (address.type === NFT_ADDRESS_TYPE) { + } else if (address.type === AddressType.Nft) { hex = HexHelper.stripPrefix( - address.nftId + (address as NftAddress).nftId ); } @@ -74,11 +76,11 @@ export class Bech32AddressHelper { * @returns The label. */ private static typeLabel(addressType?: number): string | undefined { - if (addressType === ED25519_ADDRESS_TYPE) { + if (addressType === AddressType.Ed25519) { return "Ed25519"; - } else if (addressType === ALIAS_ADDRESS_TYPE) { + } else if (addressType === AddressType.Alias) { return "Alias"; - } else if (addressType === NFT_ADDRESS_TYPE) { + } else if (addressType === AddressType.Nft) { return "NFT"; } } diff --git a/client/src/helpers/stardust/bigIntHelper.ts b/client/src/helpers/stardust/bigIntHelper.ts new file mode 100644 index 000000000..1417ae3ed --- /dev/null +++ b/client/src/helpers/stardust/bigIntHelper.ts @@ -0,0 +1,102 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 +/* eslint-disable no-bitwise */ +/* eslint-disable newline-per-chained-call */ +/* eslint-disable no-mixed-operators */ +import bigInt, { BigInteger } from "big-integer"; +import { Converter } from "./convertUtils"; + +/** + * Helper methods for bigints. + */ +export class BigIntHelper { + /** + * Load 3 bytes from array as bigint. + * @param data The input array. + * @param byteOffset The start index to read from. + * @returns The bigint. + */ + public static read3(data: Uint8Array, byteOffset: number): BigInteger { + const v0 = (data[byteOffset + 0] + (data[byteOffset + 1] << 8) + (data[byteOffset + 2] << 16)) >>> 0; + + return bigInt(v0); + } + + /** + * Load 4 bytes from array as bigint. + * @param data The input array. + * @param byteOffset The start index to read from. + * @returns The bigint. + */ + public static read4(data: Uint8Array, byteOffset: number): BigInteger { + const v0 = + (data[byteOffset + 0] + + (data[byteOffset + 1] << 8) + + (data[byteOffset + 2] << 16) + + (data[byteOffset + 3] << 24)) >>> + 0; + + return bigInt(v0); + } + + /** + * Load 8 bytes from array as bigint. + * @param data The data to read from. + * @param byteOffset The start index to read from. + * @returns The bigint. + */ + public static read8(data: Uint8Array, byteOffset: number): BigInteger { + const bytes = data.slice(byteOffset, byteOffset + 8); + + // convert to little endian hex by reversing the bytes + const hex = Converter.bytesToHex(bytes, false, undefined, undefined, true); + + return bigInt(hex, 16); + } + + /** + * Load 32 bytes (256 bits) from array as bigint. + * @param data The data to read from. + * @param byteOffset The start index to read from. + * @returns The bigint. + */ + public static read32(data: Uint8Array, byteOffset: number): BigInteger { + const bytes = data.slice(byteOffset, byteOffset + 32); + + // convert to little endian hex by reversing the bytes + const hex = Converter.bytesToHex(bytes, false, undefined, undefined, true); + + return bigInt(hex, 16); + } + + /** + * Convert a big int to bytes. + * @param value The bigint. + * @param data The buffer to write into. + * @param byteOffset The start index to write from. + */ + public static write8(value: BigInteger, data: Uint8Array, byteOffset: number): void { + let hex = value.toString(16); + // Hex is twice the length of the bytes for padding + hex = hex.padStart(16, "0"); + // Reverse so little endian + const littleEndian = Converter.hexToBytes(hex, true); + data.set(littleEndian, byteOffset); + } + + /** + * Convert a big int 32 bytes (256 bits) to bytes. + * @param value The bigint. + * @param data The buffer to write into. + * @param byteOffset The start index to write from. + */ + public static write32(value: BigInteger, data: Uint8Array, byteOffset: number): void { + let hex = value.toString(16); + // Hex is twice the length of the bytes for padding + hex = hex.padStart(64, "0"); + // Reverse so little endian + const littleEndian = Converter.hexToBytes(hex, true); + data.set(littleEndian, byteOffset); + } +} + diff --git a/client/src/helpers/stardust/convertUtils.ts b/client/src/helpers/stardust/convertUtils.ts new file mode 100644 index 000000000..c086f459f --- /dev/null +++ b/client/src/helpers/stardust/convertUtils.ts @@ -0,0 +1,268 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 +/* eslint-disable no-bitwise */ +/* eslint-disable unicorn/number-literal-case */ +/* eslint-disable unicorn/prefer-code-point */ +import { Base64 } from "./base64Encode"; +import { HexHelper } from "./hexHelper"; + +/** + * Convert arrays to and from different formats. + */ +export class Converter { + /** + * Lookup table for encoding. + * @internal + */ + private static ENCODE_LOOKUP: string[] | undefined; + + /** + * Lookup table for decoding. + * @internal + */ + private static DECODE_LOOKUP: number[] | undefined; + + /** + * Encode a raw array to UTF8 string. + * @param array The bytes to encode. + * @param startIndex The index to start in the bytes. + * @param length The length of bytes to read. + * @returns The array formated as UTF8. + */ + public static bytesToUtf8(array: ArrayLike, startIndex?: number, length?: number | undefined): string { + const start = startIndex ?? 0; + const len = length ?? array.length; + let str = ""; + + for (let i = start; i < start + len; i++) { + const value = array[i]; + + if (value < 0x80) { + str += String.fromCharCode(value); + } else if (value > 0xbf && value < 0xe0) { + str += String.fromCharCode(((value & 0x1f) << 6) | (array[i + 1] & 0x3f)); + i += 1; + } else if (value > 0xdf && value < 0xf0) { + str += String.fromCharCode( + ((value & 0x0f) << 12) | ((array[i + 1] & 0x3f) << 6) | (array[i + 2] & 0x3f) + ); + i += 2; + } else { + // surrogate pair + const charCode = + (((value & 0x07) << 18) | + ((array[i + 1] & 0x3f) << 12) | + ((array[i + 2] & 0x3f) << 6) | + (array[i + 3] & 0x3f)) - + 0x010000; + + str += String.fromCharCode((charCode >> 10) | 0xd800, (charCode & 0x03ff) | 0xdc00); + i += 3; + } + } + + return str; + } + + /** + * Convert a UTF8 string to raw array. + * @param utf8 The text to decode. + * @returns The array. + */ + public static utf8ToBytes(utf8: string): Uint8Array { + const bytes: number[] = []; + + for (let i = 0; i < utf8.length; i++) { + let charcode = utf8.charCodeAt(i); + if (charcode < 0x80) { + bytes.push(charcode); + } else if (charcode < 0x800) { + bytes.push(0xc0 | (charcode >> 6), 0x80 | (charcode & 0x3f)); + } else if (charcode < 0xd800 || charcode >= 0xe000) { + bytes.push(0xe0 | (charcode >> 12), 0x80 | ((charcode >> 6) & 0x3f), 0x80 | (charcode & 0x3f)); + } else { + // surrogate pair + i++; + // UTF-16 encodes 0x10000-0x10FFFF by + // subtracting 0x10000 and splitting the + // 20 bits of 0x0-0xFFFFF into two halves + charcode = 0x10000 + (((charcode & 0x3ff) << 10) | (utf8.charCodeAt(i) & 0x3ff)); + bytes.push( + 0xf0 | (charcode >> 18), + 0x80 | ((charcode >> 12) & 0x3f), + 0x80 | ((charcode >> 6) & 0x3f), + 0x80 | (charcode & 0x3f) + ); + } + } + + return Uint8Array.from(bytes); + } + + /** + * Encode a raw array to hex string. + * @param array The bytes to encode. + * @param includePrefix Include the 0x prefix on the returned hex. + * @param startIndex The index to start in the bytes. + * @param length The length of bytes to read. + * @param reverse Reverse the combine direction. + * @returns The array formated as hex. + */ + public static bytesToHex( + array: ArrayLike, + includePrefix: boolean = false, + startIndex?: number, + length?: number | undefined, + reverse?: boolean + ): string { + let hex = ""; + this.buildHexLookups(); + if (Converter.ENCODE_LOOKUP) { + const len = length ?? array.length; + const start = startIndex ?? 0; + if (reverse) { + for (let i = 0; i < len; i++) { + hex = Converter.ENCODE_LOOKUP[array[start + i]] + hex; + } + } else { + for (let i = 0; i < len; i++) { + hex += Converter.ENCODE_LOOKUP[array[start + i]]; + } + } + } + return includePrefix ? HexHelper.addPrefix(hex) : hex; + } + + /** + * Decode a hex string to raw array. + * @param hex The hex to decode. + * @param reverse Store the characters in reverse. + * @returns The array. + */ + public static hexToBytes(hex: string, reverse?: boolean): Uint8Array { + const strippedHex = HexHelper.stripPrefix(hex); + const sizeof = strippedHex.length >> 1; + const length = sizeof << 1; + const array = new Uint8Array(sizeof); + + this.buildHexLookups(); + if (Converter.DECODE_LOOKUP) { + let i = 0; + let n = 0; + while (i < length) { + array[n++] = + (Converter.DECODE_LOOKUP[strippedHex.charCodeAt(i++)] << 4) | + Converter.DECODE_LOOKUP[strippedHex.charCodeAt(i++)]; + } + + if (reverse) { + array.reverse(); + } + } + return array; + } + + /** + * Convert the UTF8 to hex. + * @param utf8 The text to convert. + * @param includePrefix Include the 0x prefix on the returned hex. + * @returns The hex version of the bytes. + */ + public static utf8ToHex(utf8: string, includePrefix: boolean = false): string { + const hex = Converter.bytesToHex(Converter.utf8ToBytes(utf8)); + return includePrefix ? HexHelper.addPrefix(hex) : hex; + } + + /** + * Convert the hex text to text. + * @param hex The hex to convert. + * @returns The UTF8 version of the bytes. + */ + public static hexToUtf8(hex: string): string { + return Converter.bytesToUtf8(Converter.hexToBytes(HexHelper.stripPrefix(hex))); + } + + /** + * Is the data hex format. + * @param value The value to test. + * @param allowPrefix Allow the hex to have the 0x prefix. + * @returns True if the string is hex. + */ + public static isHex(value: string, allowPrefix: boolean = false): boolean { + const localHex = allowPrefix ? HexHelper.stripPrefix(value) : value; + + if (localHex.length % 2 === 1) { + return false; + } + return /^[\da-f]+$/g.test(localHex); + } + + /** + * Convert bytes to binary string. + * @param bytes The bytes to convert. + * @returns A binary string of the bytes. + */ + public static bytesToBinary(bytes: Uint8Array): string { + const b = []; + for (let i = 0; i < bytes.length; i++) { + b.push(bytes[i].toString(2).padStart(8, "0")); + } + return b.join(""); + } + + /** + * Convert a binary string to bytes. + * @param binary The binary string. + * @returns The bytes. + */ + public static binaryToBytes(binary: string): Uint8Array { + const bytes = new Uint8Array(Math.ceil(binary.length / 8)); + for (let i = 0; i < bytes.length; i++) { + bytes[i] = Number.parseInt(binary.slice(i * 8, (i + 1) * 8), 2); + } + return bytes; + } + + /** + * Convert bytes to base64 string. + * @param bytes The bytes to convert. + * @returns A base64 string of the bytes. + */ + public static bytesToBase64(bytes: Uint8Array): string { + return Base64.encode(bytes); + } + + /** + * Convert a base64 string to bytes. + * @param base64 The base64 string. + * @returns The bytes. + */ + public static base64ToBytes(base64: string): Uint8Array { + return Base64.decode(base64); + } + + /** + * Build the static lookup tables. + * @internal + */ + private static buildHexLookups(): void { + if (!Converter.ENCODE_LOOKUP || !Converter.DECODE_LOOKUP) { + const alphabet = "0123456789abcdef"; + Converter.ENCODE_LOOKUP = []; + Converter.DECODE_LOOKUP = []; + + for (let i = 0; i < 256; i++) { + Converter.ENCODE_LOOKUP[i] = alphabet[(i >> 4) & 0xf] + alphabet[i & 0xf]; + if (i < 16) { + if (i < 10) { + Converter.DECODE_LOOKUP[0x30 + i] = i; + } else { + Converter.DECODE_LOOKUP[0x61 - 10 + i] = i; + } + } + } + } + } +} + + diff --git a/client/src/helpers/stardust/crypto.ts b/client/src/helpers/stardust/crypto.ts new file mode 100644 index 000000000..37edac505 --- /dev/null +++ b/client/src/helpers/stardust/crypto.ts @@ -0,0 +1,351 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 +/* eslint-disable no-bitwise */ +/* eslint-disable no-mixed-operators */ +/* eslint-disable unicorn/number-literal-case */ + +/** + * Class to help with Blake2B Signature scheme. + * TypeScript conversion from https://github.com/dcposch/blakejs. + */ +export class Blake2b { + /** + * Blake2b 160. + */ + public static SIZE_160: number = 20; + + /** + * Blake2b 256. + */ + public static SIZE_256: number = 32; + + /** + * Blake2b 512. + */ + public static SIZE_512: number = 64; + + /** + * Initialization Vector. + * @internal + */ + private static readonly BLAKE2B_IV32 = new Uint32Array([ + 0xf3bcc908, 0x6a09e667, 0x84caa73b, 0xbb67ae85, 0xfe94f82b, 0x3c6ef372, 0x5f1d36f1, 0xa54ff53a, 0xade682d1, + 0x510e527f, 0x2b3e6c1f, 0x9b05688c, 0xfb41bd6b, 0x1f83d9ab, 0x137e2179, 0x5be0cd19 + ]); + + /** + * Initialization Vector. + * @internal + */ + private static readonly SIGMA8 = [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, 11, + 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, 9, 0, 5, + 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, 12, 5, 1, 15, + 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, 6, 15, 14, 9, 11, + 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0, 0, 1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 + ]; + + /** + * These are offsets into a uint64 buffer. + * Multiply them all by 2 to make them offsets into a uint32 buffer, + * because this is Javascript and we don't have uint64s + * @internal + */ + private static readonly SIGMA82 = new Uint8Array(Blake2b.SIGMA8.map(x => x * 2)); + + /** + * The V vector. + * @internal + */ + private _v: Uint32Array; + + /** + * The M vector. + * @internal + */ + private _m: Uint32Array; + + /** + * The context for the current hash. + * @internal + */ + private _context: { + b: Uint8Array; + h: Uint32Array; + t: number; + c: number; + outlen: number; + }; + + /** + * Create a new instance of Blake2b. + * @param outlen Output length between 1 and 64 bytes. + * @param key Optional key. + */ + constructor(outlen: number, key?: Uint8Array) { + this._v = new Uint32Array(32); + this._m = new Uint32Array(32); + this._context = { + b: new Uint8Array(128), + h: new Uint32Array(16), + t: 0, // input count + c: 0, // pointer within buffer + outlen // output length in bytes + }; + this.init(outlen, key); + } + + /** + * Perform Sum 160 on the data. + * @param data The data to operate on. + * @param key Optional key for the hash. + * @returns The sum 160 of the data. + */ + public static sum160(data: Uint8Array, key?: Uint8Array): Uint8Array { + const b2b = new Blake2b(Blake2b.SIZE_160, key); + b2b.update(data); + return b2b.final(); + } + + /** + * Perform Sum 256 on the data. + * @param data The data to operate on. + * @param key Optional key for the hash. + * @returns The sum 256 of the data. + */ + public static sum256(data: Uint8Array, key?: Uint8Array): Uint8Array { + const b2b = new Blake2b(Blake2b.SIZE_256, key); + b2b.update(data); + return b2b.final(); + } + + /** + * Perform Sum 512 on the data. + * @param data The data to operate on. + * @param key Optional key for the hash. + * @returns The sum 512 of the data. + */ + public static sum512(data: Uint8Array, key?: Uint8Array): Uint8Array { + const b2b = new Blake2b(Blake2b.SIZE_512, key); + b2b.update(data); + return b2b.final(); + } + + /** + * Updates a BLAKE2b streaming hash. + * @param input The data to hash. + */ + public update(input: Uint8Array): void { + for (let i = 0; i < input.length; i++) { + if (this._context.c === 128) { + // buffer full ? + this._context.t += this._context.c; // add counters + this.compress(false); // compress (not last) + this._context.c = 0; // counter to zero + } + this._context.b[this._context.c++] = input[i]; + } + } + + /** + * Completes a BLAKE2b streaming hash. + * @returns The final data. + */ + public final(): Uint8Array { + this._context.t += this._context.c; // mark last block offset + + while (this._context.c < 128) { + // fill up with zeros + this._context.b[this._context.c++] = 0; + } + this.compress(true); // final block flag = 1 + + // little endian convert and store + const out = new Uint8Array(this._context.outlen); + for (let i = 0; i < this._context.outlen; i++) { + out[i] = this._context.h[i >> 2] >> (8 * (i & 3)); + } + return out; + } + + /** + * Creates a BLAKE2b hashing context. + * @param outlen Output length between 1 and 64 bytes. + * @param key Optional key. + */ + private init(outlen: number, key?: Uint8Array): void { + if (outlen <= 0 || outlen > 64) { + throw new Error("Illegal output length, expected 0 < length <= 64"); + } + if (key && key.length > 64) { + throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64"); + } + + // initialize hash state + for (let i = 0; i < 16; i++) { + this._context.h[i] = Blake2b.BLAKE2B_IV32[i]; + } + const keylen = key ? key.length : 0; + this._context.h[0] ^= 0x01010000 ^ (keylen << 8) ^ outlen; + + // key the hash, if applicable + if (key) { + this.update(key); + // at the end + this._context.c = 128; + } + } + + /** + * Compression. + * Note we're representing 16 uint64s as 32 uint32s + * @param last Is this the last block. + * @internal + */ + private compress(last: boolean): void { + let i = 0; + + // init work variables + for (i = 0; i < 16; i++) { + this._v[i] = this._context.h[i]; + this._v[i + 16] = Blake2b.BLAKE2B_IV32[i]; + } + + // low 64 bits of offset + this._v[24] ^= this._context.t; + this._v[25] ^= this._context.t / 0x100000000; + // high 64 bits not supported, offset may not be higher than 2**53-1 + + // last block flag set ? + if (last) { + this._v[28] = ~this._v[28]; + this._v[29] = ~this._v[29]; + } + + // get little-endian words + for (i = 0; i < 32; i++) { + this._m[i] = this.b2bGet32(this._context.b, 4 * i); + } + + // twelve rounds of mixing + for (i = 0; i < 12; i++) { + this.b2bG(0, 8, 16, 24, Blake2b.SIGMA82[i * 16 + 0], Blake2b.SIGMA82[i * 16 + 1]); + this.b2bG(2, 10, 18, 26, Blake2b.SIGMA82[i * 16 + 2], Blake2b.SIGMA82[i * 16 + 3]); + this.b2bG(4, 12, 20, 28, Blake2b.SIGMA82[i * 16 + 4], Blake2b.SIGMA82[i * 16 + 5]); + this.b2bG(6, 14, 22, 30, Blake2b.SIGMA82[i * 16 + 6], Blake2b.SIGMA82[i * 16 + 7]); + this.b2bG(0, 10, 20, 30, Blake2b.SIGMA82[i * 16 + 8], Blake2b.SIGMA82[i * 16 + 9]); + this.b2bG(2, 12, 22, 24, Blake2b.SIGMA82[i * 16 + 10], Blake2b.SIGMA82[i * 16 + 11]); + this.b2bG(4, 14, 16, 26, Blake2b.SIGMA82[i * 16 + 12], Blake2b.SIGMA82[i * 16 + 13]); + this.b2bG(6, 8, 18, 28, Blake2b.SIGMA82[i * 16 + 14], Blake2b.SIGMA82[i * 16 + 15]); + } + + for (i = 0; i < 16; i++) { + this._context.h[i] = this._context.h[i] ^ this._v[i] ^ this._v[i + 16]; + } + } + + /** + * 64-bit unsigned addition + * Sets v[a,a+1] += v[b,b+1] + * @param v The array. + * @param a The a index. + * @param b The b index. + * @internal + */ + private add64AA(v: Uint32Array, a: number, b: number): void { + const o0 = v[a] + v[b]; + let o1 = v[a + 1] + v[b + 1]; + if (o0 >= 0x100000000) { + o1++; + } + v[a] = o0; + v[a + 1] = o1; + } + + /** + * 64-bit unsigned addition. + * Sets v[a,a+1] += b. + * @param v The array of data to work on. + * @param a The index to use. + * @param b0 Is the low 32 bits. + * @param b1 Represents the high 32 bits. + * @internal + */ + private add64AC(v: Uint32Array, a: number, b0: number, b1: number): void { + let o0 = v[a] + b0; + if (b0 < 0) { + o0 += 0x100000000; + } + let o1 = v[a + 1] + b1; + if (o0 >= 0x100000000) { + o1++; + } + v[a] = o0; + v[a + 1] = o1; + } + + /** + * Little endian read byte 32; + * @param arr The array to read from . + * @param i The index to start reading from. + * @returns The value. + * @internal + */ + private b2bGet32(arr: ArrayLike, i: number): number { + return arr[i] ^ (arr[i + 1] << 8) ^ (arr[i + 2] << 16) ^ (arr[i + 3] << 24); + } + + /** + * G Mixing function. + * The ROTRs are inlined for speed. + * @param a The a value. + * @param b The b value. + * @param c The c value. + * @param d The d value. + * @param ix The ix value. + * @param iy The iy value. + * @internal + */ + private b2bG(a: number, b: number, c: number, d: number, ix: number, iy: number): void { + const x0 = this._m[ix]; + const x1 = this._m[ix + 1]; + const y0 = this._m[iy]; + const y1 = this._m[iy + 1]; + + this.add64AA(this._v, a, b); // v[a,a+1] += v[b,b+1] ... in JS we must store a uint64 as two uint32s + this.add64AC(this._v, a, x0, x1); // v[a, a+1] += x ... x0 is the low 32 bits of x, x1 is the high 32 bits + + // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated to the right by 32 bits + let xor0 = this._v[d] ^ this._v[a]; + let xor1 = this._v[d + 1] ^ this._v[a + 1]; + this._v[d] = xor1; + this._v[d + 1] = xor0; + + this.add64AA(this._v, c, d); + + // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 24 bits + xor0 = this._v[b] ^ this._v[c]; + xor1 = this._v[b + 1] ^ this._v[c + 1]; + this._v[b] = (xor0 >>> 24) ^ (xor1 << 8); + this._v[b + 1] = (xor1 >>> 24) ^ (xor0 << 8); + + this.add64AA(this._v, a, b); + this.add64AC(this._v, a, y0, y1); + + // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated right by 16 bits + xor0 = this._v[d] ^ this._v[a]; + xor1 = this._v[d + 1] ^ this._v[a + 1]; + this._v[d] = (xor0 >>> 16) ^ (xor1 << 16); + this._v[d + 1] = (xor1 >>> 16) ^ (xor0 << 16); + + this.add64AA(this._v, c, d); + + // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 63 bits + xor0 = this._v[b] ^ this._v[c]; + xor1 = this._v[b + 1] ^ this._v[c + 1]; + this._v[b] = (xor1 >>> 31) ^ (xor0 << 1); + this._v[b + 1] = (xor0 >>> 31) ^ (xor1 << 1); + } +} + diff --git a/client/src/helpers/stardust/hexHelper.ts b/client/src/helpers/stardust/hexHelper.ts new file mode 100644 index 000000000..a0c632dee --- /dev/null +++ b/client/src/helpers/stardust/hexHelper.ts @@ -0,0 +1,71 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 +import bigInt, { BigInteger } from "big-integer"; + +/** + * Helper methods for hex conversions. + */ +export class HexHelper { + /** + * Const defining the maximum value for a 256 bit int. + */ + public static readonly BIG_INT_MAX_256_BIT: BigInteger = bigInt( + "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", + 16 + ); + + /** + * Convert the big int 256 bit to hex string. + * @param value The big int value to convert. + * @returns The hex encoded big int. + */ + public static fromBigInt256(value: BigInteger): string { + if (value.gt(HexHelper.BIG_INT_MAX_256_BIT)) { + return HexHelper.addPrefix(HexHelper.BIG_INT_MAX_256_BIT.toString(16)); + } + return HexHelper.addPrefix(value.toString(16)); + } + + /** + * Convert the hex string to a big int. + * @param hex The hex value to convert. + * @returns The big int. + */ + public static toBigInt256(hex: string): BigInteger { + const bi = bigInt(HexHelper.stripPrefix(hex), 16); + + if (bi.greater(HexHelper.BIG_INT_MAX_256_BIT)) { + return HexHelper.BIG_INT_MAX_256_BIT; + } + + return bi; + } + + /** + * Strip the 0x prefix if it exists. + * @param hex The hex value to strip. + * @returns The stripped hex without the prefix. + */ + public static stripPrefix(hex: string): string { + return hex.replace(/^0x/, ""); + } + + /** + * Add the 0x prefix if it does not exist. + * @param hex The hex value to add the prefix to. + * @returns The hex with the prefix. + */ + public static addPrefix(hex: string): string { + return hex.startsWith("0x") ? hex : `0x${hex}`; + } + + /** + * Does the hex string have the prefix. + * @param hex The hex value to check for the prefix. + * @returns True if the hex string has the prefix. + */ + public static hasPrefix(hex: string): boolean { + return hex.startsWith("0x"); + } +} + diff --git a/client/src/helpers/stardust/metadataUtils.ts b/client/src/helpers/stardust/metadataUtils.ts index b19b0d425..1e85a879e 100644 --- a/client/src/helpers/stardust/metadataUtils.ts +++ b/client/src/helpers/stardust/metadataUtils.ts @@ -1,5 +1,4 @@ -import { HexEncodedString } from "@iota/iota.js-stardust"; -import { Converter } from "@iota/util.js-stardust"; +import { HexEncodedString, hexToUtf8 } from "@iota/sdk-wasm/web"; import * as jsonschema from "jsonschema"; /** * Tries to parse hex data into metadata. @@ -10,7 +9,7 @@ import * as jsonschema from "jsonschema"; export function tryParseMetadata(metadataHex: HexEncodedString, schema: jsonschema.Schema): S | null { const validator = new jsonschema.Validator(); try { - const json: unknown = JSON.parse(Converter.hexToUtf8(metadataHex)); + const json: unknown = JSON.parse(hexToUtf8(metadataHex)); const result = validator.validate(json, schema); if (result.valid) { diff --git a/client/src/helpers/stardust/nameHelper.ts b/client/src/helpers/stardust/nameHelper.ts index c63fbe9d5..218a92c9c 100644 --- a/client/src/helpers/stardust/nameHelper.ts +++ b/client/src/helpers/stardust/nameHelper.ts @@ -1,13 +1,4 @@ -import { - ALIAS_OUTPUT_TYPE, ALIAS_UNLOCK_TYPE, BASIC_OUTPUT_TYPE, FOUNDRY_OUTPUT_TYPE, NFT_OUTPUT_TYPE, - NFT_UNLOCK_TYPE, REFERENCE_UNLOCK_TYPE, SIGNATURE_UNLOCK_TYPE, TREASURY_INPUT_TYPE, - TREASURY_OUTPUT_TYPE, UTXO_INPUT_TYPE, ADDRESS_UNLOCK_CONDITION_TYPE, STORAGE_DEPOSIT_RETURN_UNLOCK_CONDITION_TYPE, - TIMELOCK_UNLOCK_CONDITION_TYPE, EXPIRATION_UNLOCK_CONDITION_TYPE, STATE_CONTROLLER_ADDRESS_UNLOCK_CONDITION_TYPE, - GOVERNOR_ADDRESS_UNLOCK_CONDITION_TYPE, IMMUTABLE_ALIAS_UNLOCK_CONDITION_TYPE, SENDER_FEATURE_TYPE, - ISSUER_FEATURE_TYPE, METADATA_FEATURE_TYPE, TAG_FEATURE_TYPE, - ED25519_ADDRESS_TYPE, ALIAS_ADDRESS_TYPE, NFT_ADDRESS_TYPE, - IBlock, TAGGED_DATA_PAYLOAD_TYPE, TRANSACTION_PAYLOAD_TYPE, MILESTONE_PAYLOAD_TYPE -} from "@iota/iota.js-stardust"; +import { AddressType, Block, FeatureType, InputType, OutputType, PayloadType, UnlockConditionType, UnlockType } from "@iota/sdk-wasm/web"; export class NameHelper { /** @@ -16,9 +7,9 @@ export class NameHelper { * @returns The input type name. */ public static getInputTypeName(type: number): string { - if (type === UTXO_INPUT_TYPE) { + if (type === InputType.UTXO) { return "UTXO Input"; - } else if (type === TREASURY_INPUT_TYPE) { + } else if (type === InputType.Treasury) { return "Treasury Input"; } return "Unknown Input"; @@ -31,15 +22,15 @@ export class NameHelper { */ public static getOutputTypeName(type: number): string { switch (type) { - case BASIC_OUTPUT_TYPE: + case OutputType.Basic: return "Basic"; - case ALIAS_OUTPUT_TYPE: + case OutputType.Alias: return "Alias"; - case FOUNDRY_OUTPUT_TYPE: + case OutputType.Foundry: return "Foundry"; - case NFT_OUTPUT_TYPE: + case OutputType.Nft: return "NFT"; - case TREASURY_OUTPUT_TYPE: + case OutputType.Treasury: return "Treasury"; default: return "Unknown"; @@ -53,13 +44,13 @@ export class NameHelper { */ public static getUnlockTypeName(type: number): string { switch (type) { - case ALIAS_UNLOCK_TYPE: + case UnlockType.Alias: return "Alias Unlock"; - case NFT_UNLOCK_TYPE: + case UnlockType.Nft: return "NFT Unlock"; - case SIGNATURE_UNLOCK_TYPE: + case UnlockType.Signature: return "Signature Unlock"; - case REFERENCE_UNLOCK_TYPE: + case UnlockType.Reference: return "Reference Unlock"; default: return "Unknown Unlock"; @@ -72,19 +63,19 @@ export class NameHelper { * @returns The unlock condition type name. */ public static getUnlockConditionTypeName(type: number): string { - if (type === ADDRESS_UNLOCK_CONDITION_TYPE) { + if (type === UnlockConditionType.Address) { return "Address Unlock Condition"; - } else if (type === STORAGE_DEPOSIT_RETURN_UNLOCK_CONDITION_TYPE) { + } else if (type === UnlockConditionType.StorageDepositReturn) { return "Storage Deposit Return Unlock Condition"; - } else if (type === TIMELOCK_UNLOCK_CONDITION_TYPE) { + } else if (type === UnlockConditionType.Timelock) { return "Timelock Unlock Condition"; - } else if (type === EXPIRATION_UNLOCK_CONDITION_TYPE) { + } else if (type === UnlockConditionType.Expiration) { return "Expiration Unlock Condition"; - } else if (type === STATE_CONTROLLER_ADDRESS_UNLOCK_CONDITION_TYPE) { + } else if (type === UnlockConditionType.StateControllerAddress) { return "State Controller Address Unlock Condition"; - } else if (type === GOVERNOR_ADDRESS_UNLOCK_CONDITION_TYPE) { + } else if (type === UnlockConditionType.GovernorAddress) { return "Governor Unlock Condition"; - } else if (type === IMMUTABLE_ALIAS_UNLOCK_CONDITION_TYPE) { + } else if (type === UnlockConditionType.ImmutableAliasAddress) { return "Immutable Alias Unlock Condition"; } return "Unknown Unlock Condition"; @@ -98,13 +89,13 @@ export class NameHelper { */ public static getFeatureTypeName(type: number, isImmutable: boolean): string { let name: string = ""; - if (type === SENDER_FEATURE_TYPE) { + if (type === FeatureType.Sender) { name = "Sender"; - } else if (type === ISSUER_FEATURE_TYPE) { + } else if (type === FeatureType.Issuer) { name = "Issuer"; - } else if (type === METADATA_FEATURE_TYPE) { + } else if (type === FeatureType.Metadata) { name = "Metadata"; - } else if (type === TAG_FEATURE_TYPE) { + } else if (type === FeatureType.Tag) { name = "Tag"; } @@ -120,11 +111,11 @@ export class NameHelper { * @returns The address type name. */ public static getAddressTypeName(type: number): string { - if (type === ED25519_ADDRESS_TYPE) { + if (type === AddressType.Ed25519) { return "Ed25519 address"; - } else if (type === ALIAS_ADDRESS_TYPE) { + } else if (type === AddressType.Alias) { return "Alias address"; - } else if (type === NFT_ADDRESS_TYPE) { + } else if (type === AddressType.Nft) { return "NFT address"; } return "Unknown Address Type"; @@ -135,7 +126,7 @@ export class NameHelper { * @param block The block data. * @returns The payload type string. */ - public static getPayloadType(block: IBlock | undefined): string { + public static getPayloadType(block: Block | undefined): string { let payloadType = "-"; if (!block) { @@ -143,15 +134,18 @@ export class NameHelper { } switch (block.payload?.type) { - case TAGGED_DATA_PAYLOAD_TYPE: + case PayloadType.TaggedData: payloadType = "Data"; break; - case TRANSACTION_PAYLOAD_TYPE: + case PayloadType.Transaction: payloadType = "Transaction"; break; - case MILESTONE_PAYLOAD_TYPE: + case PayloadType.Milestone: payloadType = "Milestone"; break; + case PayloadType.TreasuryTransaction: + payloadType = "Treasury Transaction"; + break; default: payloadType = "No payload"; break; diff --git a/client/src/helpers/stardust/participationUtils.ts b/client/src/helpers/stardust/participationUtils.ts index 28be45781..18d7ec753 100644 --- a/client/src/helpers/stardust/participationUtils.ts +++ b/client/src/helpers/stardust/participationUtils.ts @@ -1,5 +1,5 @@ -import { Blake2b } from "@iota/crypto.js-stardust"; -import { ReadStream } from "@iota/util.js-stardust"; +import { Blake2b } from "./crypto"; +import { ReadStream } from "./readStreamUtils"; /** * The length of the participation event id. diff --git a/client/src/helpers/stardust/readStreamUtils.ts b/client/src/helpers/stardust/readStreamUtils.ts new file mode 100644 index 000000000..2b191034f --- /dev/null +++ b/client/src/helpers/stardust/readStreamUtils.ts @@ -0,0 +1,228 @@ +// Copyright 2020 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 +/* eslint-disable no-bitwise */ +/* eslint-disable no-mixed-operators */ +import type { BigInteger } from "big-integer"; +import { BigIntHelper } from "./bigIntHelper"; +import { Converter } from "./convertUtils"; +import { HexHelper } from "./hexHelper"; + +/** + * Keep track of the read index within a stream. + */ +export class ReadStream { + /** + * The storage. + * @internal + */ + private readonly _storage: Uint8Array; + + /** + * The current read index. + * @internal + */ + private _readIndex: number; + + /** + * Create a new instance of ReadStream. + * @param storage The data to access. + * @param readStartIndex The index to start the reading from. + */ + constructor(storage: Uint8Array, readStartIndex: number = 0) { + this._storage = new Uint8Array(storage); + this._readIndex = readStartIndex; + } + + /** + * Get the length of the storage. + * @returns The storage length. + */ + public length(): number { + return this._storage.byteLength; + } + + /** + * Does the storage have enough data remaining. + * @param remaining The amount of space needed. + * @returns True if it has enough data. + */ + public hasRemaining(remaining: number): boolean { + return this._readIndex + remaining <= this._storage.byteLength; + } + + /** + * How much unused data is there. + * @returns The amount of unused data. + */ + public unused(): number { + return this._storage.byteLength - this._readIndex; + } + + /** + * Get the current read index. + * @returns The current read index. + */ + public getReadIndex(): number { + return this._readIndex; + } + + /** + * Set the current read index. + * @param readIndex The current read index. + */ + public setReadIndex(readIndex: number): void { + this._readIndex = readIndex; + + if (readIndex >= this._storage.length) { + throw new Error( + `You cannot set the readIndex to ${readIndex} as the stream is only ${this._storage.length} in length` + ); + } + } + + /** + * Read fixed length as hex. + * @param name The name of the data we are trying to read. + * @param length The length of the data to read. + * @param moveIndex Move the index pointer on. + * @returns The hex formatted data. + */ + public readFixedHex(name: string, length: number, moveIndex: boolean = true): string { + if (!this.hasRemaining(length)) { + throw new Error(`${name} length ${length} exceeds the remaining data ${this.unused()}`); + } + const hex = Converter.bytesToHex(this._storage, false, this._readIndex, length); + if (moveIndex) { + this._readIndex += length; + } + return HexHelper.addPrefix(hex); + } + + /** + * Read an array of byte from the stream. + * @param name The name of the data we are trying to read. + * @param length The length of the array to read. + * @param moveIndex Move the index pointer on. + * @returns The value. + */ + public readBytes(name: string, length: number, moveIndex: boolean = true): Uint8Array { + if (!this.hasRemaining(length)) { + throw new Error(`${name} length ${length} exceeds the remaining data ${this.unused()}`); + } + const val = this._storage.slice(this._readIndex, this._readIndex + length); + if (moveIndex) { + this._readIndex += length; + } + return val; + } + + /** + * Read a byte from the stream. + * @param name The name of the data we are trying to read. + * @param moveIndex Move the index pointer on. + * @returns The value. + */ + public readUInt8(name: string, moveIndex: boolean = true): number { + if (!this.hasRemaining(1)) { + throw new Error(`${name} length 1 exceeds the remaining data ${this.unused()}`); + } + const val = this._storage[this._readIndex]; + if (moveIndex) { + this._readIndex += 1; + } + return val; + } + + /** + * Read a UInt16 from the stream. + * @param name The name of the data we are trying to read. + * @param moveIndex Move the index pointer on. + * @returns The value. + */ + public readUInt16(name: string, moveIndex: boolean = true): number { + if (!this.hasRemaining(2)) { + throw new Error(`${name} length 2 exceeds the remaining data ${this.unused()}`); + } + const val = this._storage[this._readIndex] | (this._storage[this._readIndex + 1] << 8); + + if (moveIndex) { + this._readIndex += 2; + } + return val; + } + + /** + * Read a UInt32 from the stream. + * @param name The name of the data we are trying to read. + * @param moveIndex Move the index pointer on. + * @returns The value. + */ + public readUInt32(name: string, moveIndex: boolean = true): number { + if (!this.hasRemaining(4)) { + throw new Error(`${name} length 4 exceeds the remaining data ${this.unused()}`); + } + + const val = Number(BigIntHelper.read4(this._storage, this._readIndex)); + + if (moveIndex) { + this._readIndex += 4; + } + return val; + } + + /** + * Read a UInt64 from the stream. + * @param name The name of the data we are trying to read. + * @param moveIndex Move the index pointer on. + * @returns The value. + */ + public readUInt64(name: string, moveIndex: boolean = true): BigInteger { + if (!this.hasRemaining(8)) { + throw new Error(`${name} length 8 exceeds the remaining data ${this.unused()}`); + } + + const val = BigIntHelper.read8(this._storage, this._readIndex); + + if (moveIndex) { + this._readIndex += 8; + } + return val; + } + + /** + * Read a UInt256 from the stream. + * @param name The name of the data we are trying to read. + * @param moveIndex Move the index pointer on. + * @returns The value. + */ + public readUInt256(name: string, moveIndex: boolean = true): BigInteger { + if (!this.hasRemaining(32)) { + throw new Error(`${name} length 32 exceeds the remaining data ${this.unused()}`); + } + + const val = BigIntHelper.read32(this._storage, this._readIndex); + + if (moveIndex) { + this._readIndex += 32; + } + return val; + } + + /** + * Read a boolean from the stream. + * @param name The name of the data we are trying to read. + * @param moveIndex Move the index pointer on. + * @returns The value. + */ + public readBoolean(name: string, moveIndex: boolean = true): boolean { + if (!this.hasRemaining(1)) { + throw new Error(`${name} length 1 exceeds the remaining data ${this.unused()}`); + } + const val = this._storage[this._readIndex]; + if (moveIndex) { + this._readIndex += 1; + } + return val !== 0; + } +} + diff --git a/client/src/helpers/stardust/transactionsHelper.ts b/client/src/helpers/stardust/transactionsHelper.ts index 3529a25c3..313b437f0 100644 --- a/client/src/helpers/stardust/transactionsHelper.ts +++ b/client/src/helpers/stardust/transactionsHelper.ts @@ -1,20 +1,14 @@ /* eslint-disable no-warning-comments */ -import { Blake2b } from "@iota/crypto.js-stardust"; import { - BASIC_OUTPUT_TYPE, IAddressUnlockCondition, IStateControllerAddressUnlockCondition, - IGovernorAddressUnlockCondition, IBlock, - ISignatureUnlock, SIGNATURE_UNLOCK_TYPE, - TRANSACTION_PAYLOAD_TYPE, ADDRESS_UNLOCK_CONDITION_TYPE, ITransactionPayload, - IBasicOutput, UnlockConditionTypes, ITreasuryOutput, IAliasOutput, INftOutput, IFoundryOutput, - TREASURY_OUTPUT_TYPE, STATE_CONTROLLER_ADDRESS_UNLOCK_CONDITION_TYPE, - GOVERNOR_ADDRESS_UNLOCK_CONDITION_TYPE, ALIAS_OUTPUT_TYPE, - NFT_OUTPUT_TYPE, serializeTransactionPayload, FOUNDRY_OUTPUT_TYPE, - IMMUTABLE_ALIAS_UNLOCK_CONDITION_TYPE, IImmutableAliasUnlockCondition, - TransactionHelper, IReferenceUnlock, Ed25519Address, OutputTypes, - STORAGE_DEPOSIT_RETURN_UNLOCK_CONDITION_TYPE, - IRent, UnlockTypes, TAG_FEATURE_TYPE, ITagFeature -} from "@iota/iota.js-stardust"; -import { Converter, HexHelper, WriteStream } from "@iota/util.js-stardust"; + AddressUnlockCondition, + BasicOutput, + Block, CommonOutput, FeatureType, GovernorAddressUnlockCondition, + ImmutableAliasAddressUnlockCondition, InputType, IRent, MilestonePayload, Output, OutputType, PayloadType, + ReferenceUnlock, RegularTransactionEssence, SignatureUnlock, + StateControllerAddressUnlockCondition, + TagFeature, + TransactionPayload, TreasuryOutput, Unlock, UnlockCondition, UnlockConditionType, UnlockType, Utils, UTXOInput +} from "@iota/sdk-wasm/web"; import bigInt from "big-integer"; import { IBech32AddressDetails } from "../../models/api/IBech32AddressDetails"; import { IInput } from "../../models/api/stardust/IInput"; @@ -22,10 +16,11 @@ import { IOutput } from "../../models/api/stardust/IOutput"; import { MAINNET } from "../../models/config/networkType"; import { StardustApiClient } from "../../services/stardust/stardustApiClient"; import { Bech32AddressHelper } from "../stardust/bech32AddressHelper"; +import { HexHelper } from "./hexHelper"; interface TransactionInputsAndOutputsResponse { inputs: IInput[]; - unlocks: UnlockTypes[]; + unlocks: Unlock[]; outputs: IOutput[]; unlockAddresses: IBech32AddressDetails[]; transferTotal: number; @@ -42,21 +37,21 @@ const HEX_PARTICIPATE = "0x5041525449434950415445"; export const STARDUST_GENESIS_MILESTONE = 7669900; export class TransactionsHelper { - public static async getInputsAndOutputs(block: IBlock | undefined, network: string, + public static async getInputsAndOutputs(block: Block | undefined, network: string, _bechHrp: string, apiClient: StardustApiClient ): Promise { const GENESIS_HASH = "0".repeat(64); const inputs: IInput[] = []; - let unlocks: UnlockTypes[] = []; + let unlocks: Unlock[] = []; const outputs: IOutput[] = []; const remainderOutputs: IOutput[] = []; const unlockAddresses: IBech32AddressDetails[] = []; let transferTotal = 0; let sortedOutputs: IOutput[] = []; - if (block?.payload?.type === TRANSACTION_PAYLOAD_TYPE) { - const payload: ITransactionPayload = block.payload; - const transactionId = TransactionsHelper.computeTransactionIdFromTransactionPayload(payload); + if (block?.payload?.type === PayloadType.Transaction) { + const payload: TransactionPayload = block.payload as TransactionPayload; + const transactionId = Utils.transactionId(payload); // Unlocks unlocks = payload.unlocks; @@ -64,80 +59,90 @@ export class TransactionsHelper { // unlock Addresses computed from public keys in unlocks for (let i = 0; i < unlocks.length; i++) { const unlock = payload.unlocks[i]; - let signatureUnlock: ISignatureUnlock; + let signatureUnlock: SignatureUnlock; - if (unlock.type === SIGNATURE_UNLOCK_TYPE) { - signatureUnlock = unlock; + if (unlock.type === UnlockType.Signature) { + signatureUnlock = unlock as SignatureUnlock; } else { let refUnlockIdx = i; // unlock references can be transitive, // so we need to follow the path until we find the signature do { - const referenceUnlock = payload.unlocks[refUnlockIdx] as IReferenceUnlock; - signatureUnlock = payload.unlocks[referenceUnlock.reference] as ISignatureUnlock; + const referenceUnlock = payload.unlocks[refUnlockIdx] as ReferenceUnlock; + signatureUnlock = payload.unlocks[referenceUnlock.reference] as SignatureUnlock; refUnlockIdx = referenceUnlock.reference; } while (!signatureUnlock.signature); } - const hex = Converter.bytesToHex( - new Ed25519Address(Converter.hexToBytes(signatureUnlock.signature.publicKey)).toAddress() - ); unlockAddresses.push( - Bech32AddressHelper.buildAddress(_bechHrp, hex) + Bech32AddressHelper.buildAddress( + _bechHrp, + Utils.hexPublicKeyToBech32Address(signatureUnlock.signature.publicKey, _bechHrp) + ) ); } + const payloadEssence = payload.essence as RegularTransactionEssence; + // Inputs - for (let i = 0; i < payload.essence.inputs.length; i++) { + for (let i = 0; i < payloadEssence.inputs.length; i++) { let outputDetails; let amount; + let isGenesis = false; const address = unlockAddresses[i]; - const input = payload.essence.inputs[i]; - const isGenesis = input.transactionId === GENESIS_HASH; - - const outputId = TransactionHelper.outputIdFromTransactionData( - input.transactionId, - input.transactionOutputIndex - ); + const input = payloadEssence.inputs[i]; + + if (input.type === InputType.UTXO) { + const utxoInput = input as UTXOInput; + isGenesis = utxoInput.transactionId === GENESIS_HASH; + + const outputId = Utils.computeOutputId( + utxoInput.transactionId, + utxoInput.transactionOutputIndex + ); + + const response = await apiClient.outputDetails({ network, outputId }); + const details = response.output; + + if (!response.error && details?.output && details?.metadata) { + outputDetails = { + output: details.output, + metadata: details.metadata + }; + amount = Number(details.output.amount); + } - const response = await apiClient.outputDetails({ network, outputId }); - const details = response.output; - if (!response.error && details?.output && details?.metadata) { - outputDetails = { - output: details.output, - metadata: details.metadata - }; - amount = Number(details.output.amount); + inputs.push({ + ...utxoInput, + // TODO-sdk Rename the field + transactionInputIndex: utxoInput.transactionOutputIndex, + amount, + isGenesis, + outputId, + output: outputDetails, + address + }); } - - inputs.push({ - ...input, - amount, - isGenesis, - outputId, - output: outputDetails, - address - }); } // Outputs - for (let i = 0; i < payload.essence.outputs.length; i++) { - const outputId = TransactionHelper.outputIdFromTransactionData(transactionId, i); + for (let i = 0; i < payloadEssence.outputs.length; i++) { + const outputId = Utils.computeOutputId(transactionId, i); - if (payload.essence.outputs[i].type === TREASURY_OUTPUT_TYPE) { - const output = payload.essence.outputs[i] as ITreasuryOutput; + if (payloadEssence.outputs[i].type === OutputType.Treasury) { + const output = payloadEssence.outputs[i] as TreasuryOutput; outputs.push({ id: outputId, output, - amount: Number(payload.essence.outputs[i].amount) + amount: Number(payloadEssence.outputs[i].amount) }); } else { - const output = payload.essence.outputs[i] as IBasicOutput | - IFoundryOutput | IAliasOutput | INftOutput; + const output = payloadEssence.outputs[i] as CommonOutput; - const address: IBech32AddressDetails = TransactionsHelper - .bechAddressFromAddressUnlockCondition(output.unlockConditions, _bechHrp, output.type); + const address: IBech32AddressDetails = TransactionsHelper.bechAddressFromAddressUnlockCondition( + output.unlockConditions, _bechHrp, output.type + ); const isRemainder = inputs.some(input => input.address.bech32 === address.bech32); @@ -145,7 +150,7 @@ export class TransactionsHelper { remainderOutputs.push({ id: outputId, address, - amount: Number(payload.essence.outputs[i].amount), + amount: Number(payloadEssence.outputs[i].amount), isRemainder, output }); @@ -153,14 +158,14 @@ export class TransactionsHelper { outputs.push({ id: outputId, address, - amount: Number(payload.essence.outputs[i].amount), + amount: Number(payloadEssence.outputs[i].amount), isRemainder, output }); } if (!isRemainder) { - transferTotal += Number(payload.essence.outputs[i].amount); + transferTotal += Number(payloadEssence.outputs[i].amount); } } } @@ -212,40 +217,46 @@ export class TransactionsHelper { return bigEndian.join(""); } - public static computeTransactionIdFromTransactionPayload(payload: ITransactionPayload) { - const tpWriteStream = new WriteStream(); - serializeTransactionPayload(tpWriteStream, payload); - return Converter.bytesToHex(Blake2b.sum256(tpWriteStream.finalBytes()), true); + /** + * Compute BLAKE2b-256 hash for alias. + * @param aliasId Alias id. + * @param outputId Output id. + * @returns The BLAKE2b-256 hash for Alias Id. + */ + public static buildIdHashForAlias(aliasId: string, outputId: string): string { + return !HexHelper.toBigInt256(aliasId).eq(bigInt.zero) ? + aliasId : + Utils.computeAliasId(outputId); } /** - * Compute BLAKE2b-256 hash for alias or nft which has Id 0. - * @param aliasOrNftId Alias or Nft id. + * Compute BLAKE2b-256 hash for nft Id. + * @param nftId Nft id. * @param outputId Output id. - * @returns The BLAKE2b-256 hash for Alias or Nft Id. + * @returns The BLAKE2b-256 hash for Nft Id. */ - public static buildIdHashForAliasOrNft(aliasOrNftId: string, outputId: string): string { - return !HexHelper.toBigInt256(aliasOrNftId).eq(bigInt.zero) ? - aliasOrNftId : - TransactionHelper.resolveIdFromOutputId(outputId); + public static buildIdHashForNft(nftId: string, outputId: string): string { + return !HexHelper.toBigInt256(nftId).eq(bigInt.zero) ? + nftId : + Utils.computeNftId(outputId); } - public static computeStorageRentBalance(outputs: OutputTypes[], rentStructure: IRent): number { + public static computeStorageRentBalance(outputs: Output[], rentStructure: IRent): number { const outputsWithoutSdruc = outputs.filter(output => { - if (output.type === TREASURY_OUTPUT_TYPE) { + if (output.type === OutputType.Treasury) { return false; } - const hasStorageDepositUnlockCondition = output.unlockConditions.some( - uc => uc.type === STORAGE_DEPOSIT_RETURN_UNLOCK_CONDITION_TYPE + const hasStorageDepositUnlockCondition = (output as CommonOutput).unlockConditions.some( + uc => uc.type === UnlockConditionType.StorageDepositReturn ); return !hasStorageDepositUnlockCondition; }); const rentBalance = outputsWithoutSdruc.reduce( - (acc, output) => acc + TransactionHelper.getStorageDeposit(output, rentStructure), + (acc, output) => acc + Number(Utils.computeStorageDeposit(output, rentStructure)), 0 - ); + ); return rentBalance; } @@ -254,11 +265,11 @@ export class TransactionsHelper { * @param output The output to check. * @returns true if participation event output. */ - public static isParticipationEventOutput(output: OutputTypes): boolean { - if (output.type === BASIC_OUTPUT_TYPE) { - const tagFeature = output.features?.find( - feature => feature.type === TAG_FEATURE_TYPE - ) as ITagFeature; + public static isParticipationEventOutput(output: Output): boolean { + if (output.type === OutputType.Basic) { + const tagFeature = (output as BasicOutput).features?.find( + feature => feature.type === FeatureType.Tag + ) as TagFeature; if (tagFeature) { return tagFeature.tag === HEX_PARTICIPATE; @@ -267,6 +278,22 @@ export class TransactionsHelper { return false; } + /** + * Compute a blockId from a milestone payload. + * @param protocolVersion The protocol version to use. + * @param payload The milestone payload. + * @returns The blockId of the block with the milestone payload. + */ + public static blockIdFromMilestonePayload(protocolVersion: number, payload: MilestonePayload): string { + const block = new Block(); + block.protocolVersion = protocolVersion; + block.parents = payload.parents; + block.payload = payload; + block.nonce = "0"; + + return Utils.blockId(block); + } + /** * Check if transaction is from IOTA Stardust Genesis * @param network The network. @@ -278,32 +305,32 @@ export class TransactionsHelper { } private static bechAddressFromAddressUnlockCondition( - unlockConditions: UnlockConditionTypes[], + unlockConditions: UnlockCondition[], _bechHrp: string, outputType: number ): IBech32AddressDetails { let address: IBech32AddressDetails = { bech32: "" }; let unlockCondition; - if (outputType === BASIC_OUTPUT_TYPE || outputType === NFT_OUTPUT_TYPE) { + if (outputType === OutputType.Basic || outputType === OutputType.Nft) { unlockCondition = unlockConditions?.filter( - ot => ot.type === ADDRESS_UNLOCK_CONDITION_TYPE - ).map(ot => ot as IAddressUnlockCondition)[0]; - } else if (outputType === ALIAS_OUTPUT_TYPE) { - if (unlockConditions.some(ot => ot.type === STATE_CONTROLLER_ADDRESS_UNLOCK_CONDITION_TYPE)) { + ot => ot.type === UnlockConditionType.Address + ).map(ot => ot as AddressUnlockCondition)[0]; + } else if (outputType === OutputType.Alias) { + if (unlockConditions.some(ot => ot.type === UnlockConditionType.StateControllerAddress)) { unlockCondition = unlockConditions?.filter( - ot => ot.type === STATE_CONTROLLER_ADDRESS_UNLOCK_CONDITION_TYPE - ).map(ot => ot as IStateControllerAddressUnlockCondition)[0]; + ot => ot.type === UnlockConditionType.StateControllerAddress + ).map(ot => ot as StateControllerAddressUnlockCondition)[0]; } - if (unlockConditions.some(ot => ot.type === GOVERNOR_ADDRESS_UNLOCK_CONDITION_TYPE)) { + if (unlockConditions.some(ot => ot.type === UnlockConditionType.GovernorAddress)) { unlockCondition = unlockConditions?.filter( - ot => ot.type === GOVERNOR_ADDRESS_UNLOCK_CONDITION_TYPE - ).map(ot => ot as IGovernorAddressUnlockCondition)[0]; + ot => ot.type === UnlockConditionType.GovernorAddress + ).map(ot => ot as GovernorAddressUnlockCondition)[0]; } - } else if (outputType === FOUNDRY_OUTPUT_TYPE) { + } else if (outputType === OutputType.Foundry) { unlockCondition = unlockConditions?.filter( - ot => ot.type === IMMUTABLE_ALIAS_UNLOCK_CONDITION_TYPE - ).map(ot => ot as IImmutableAliasUnlockCondition)[0]; + ot => ot.type === UnlockConditionType.ImmutableAliasAddress + ).map(ot => ot as ImmutableAliasAddressUnlockCondition)[0]; } if (unlockCondition?.address) { diff --git a/client/src/helpers/stardust/valueFormatHelper.tsx b/client/src/helpers/stardust/valueFormatHelper.tsx index a0a945068..83a99c4c5 100644 --- a/client/src/helpers/stardust/valueFormatHelper.tsx +++ b/client/src/helpers/stardust/valueFormatHelper.tsx @@ -1,4 +1,5 @@ -import { INodeInfoBaseToken, UnitsHelper } from "@iota/iota.js-stardust"; +import { UnitsHelper } from "@iota/iota.js"; +import { INodeInfoBaseToken } from "@iota/sdk-wasm/web"; import React from "react"; import Tooltip from "../../app/components/Tooltip"; /** @@ -39,9 +40,9 @@ export function formatAmount( * @returns {string} The formatted number as a string, with commas separating thousands. */ export function formatNumberWithCommas( - value: string | number + value: bigint ): string { - return BigInt(value).toLocaleString("en", { useGrouping: true }); + return value.toLocaleString("en", { useGrouping: true }); } /** diff --git a/client/src/index.tsx b/client/src/index.tsx index 16b79a3c3..303a90473 100644 --- a/client/src/index.tsx +++ b/client/src/index.tsx @@ -1,5 +1,8 @@ /* eslint-disable unicorn/prefer-top-level-await */ /* eslint-disable @typescript-eslint/no-unsafe-argument */ +// needed for features from @iota/sdk which use reflection (decorators) +import "reflect-metadata"; +import init from "@iota/sdk-wasm/web"; import React from "react"; import { createRoot } from "react-dom/client"; import { BrowserRouter, Route, RouteComponentProps } from "react-router-dom"; @@ -29,7 +32,10 @@ import { TokenRegistryClient } from "./services/stardust/tokenRegistryClient"; // eslint-disable-next-line @typescript-eslint/no-explicit-any const apiEndpoint = (window as any).env.API_ENDPOINT; -initialiseServices().then(() => { +initialiseServices().then(async () => { + // load the wasm + await init("/iota_sdk_wasm_bg.wasm"); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const container = document.querySelector("#root")!; const root = createRoot(container); diff --git a/client/src/models/api/stardust/IAliasResponse.ts b/client/src/models/api/stardust/IAliasResponse.ts index 96f4c763d..733d84cb1 100644 --- a/client/src/models/api/stardust/IAliasResponse.ts +++ b/client/src/models/api/stardust/IAliasResponse.ts @@ -1,10 +1,10 @@ -import { IOutputResponse } from "@iota/iota.js-stardust"; +import { OutputResponse } from "@iota/sdk-wasm/web"; import { IResponse } from "./IResponse"; export interface IAliasResponse extends IResponse { /** * The alias details response. */ - aliasDetails?: IOutputResponse; + aliasDetails?: OutputResponse; } diff --git a/client/src/models/api/stardust/IBlockChildrenResponse.ts b/client/src/models/api/stardust/IBlockChildrenResponse.ts index 175ba5c2f..f3904f22c 100644 --- a/client/src/models/api/stardust/IBlockChildrenResponse.ts +++ b/client/src/models/api/stardust/IBlockChildrenResponse.ts @@ -1,4 +1,4 @@ -import { HexEncodedString } from "@iota/iota.js-stardust"; +import { HexEncodedString } from "@iota/sdk-wasm/web"; import { IResponse } from "../IResponse"; export interface IBlockChildrenResponse extends IResponse { diff --git a/client/src/models/api/stardust/IInput.ts b/client/src/models/api/stardust/IInput.ts index 98d2aaa9e..b1562d18e 100644 --- a/client/src/models/api/stardust/IInput.ts +++ b/client/src/models/api/stardust/IInput.ts @@ -1,7 +1,15 @@ -import { IOutputResponse, IUTXOInput } from "@iota/iota.js-stardust"; +import { HexEncodedString, OutputResponse } from "@iota/sdk-wasm/web"; import { IBech32AddressDetails } from "../IBech32AddressDetails"; -interface IInputExtension { +export interface IInput { + /** + * The transaction Id. + */ + transactionId: HexEncodedString; + /** + * The input index. + */ + transactionInputIndex: number; /** * The output id. */ @@ -9,7 +17,7 @@ interface IInputExtension { /** * The output used as input. */ - output?: IOutputResponse; + output?: OutputResponse; /** * The transaction address details. */ @@ -24,5 +32,3 @@ interface IInputExtension { isGenesis: boolean; } -export type IInput = IUTXOInput & IInputExtension; - diff --git a/client/src/models/api/stardust/IMilestoneDetailsResponse.ts b/client/src/models/api/stardust/IMilestoneDetailsResponse.ts index 43e170fdd..cdcef1f43 100644 --- a/client/src/models/api/stardust/IMilestoneDetailsResponse.ts +++ b/client/src/models/api/stardust/IMilestoneDetailsResponse.ts @@ -1,4 +1,4 @@ -import { IMilestonePayload } from "@iota/iota.js-stardust"; +import { MilestonePayload } from "@iota/sdk-wasm/web"; import { IResponse } from "../IResponse"; export interface IMilestoneDetailsResponse extends IResponse { @@ -15,6 +15,6 @@ export interface IMilestoneDetailsResponse extends IResponse { /** * The milestone data. */ - milestone?: IMilestonePayload; + milestone?: MilestonePayload; } diff --git a/client/src/models/api/stardust/INodeInfoResponse.ts b/client/src/models/api/stardust/INodeInfoResponse.ts index 7f3b3e629..bb80b4f5f 100644 --- a/client/src/models/api/stardust/INodeInfoResponse.ts +++ b/client/src/models/api/stardust/INodeInfoResponse.ts @@ -1,4 +1,4 @@ -import { INodeInfoBaseToken, IRent } from "@iota/iota.js-stardust"; +import { INodeInfoBaseToken, IRent } from "@iota/sdk-wasm/web"; import { IResponse } from "../IResponse"; /** diff --git a/client/src/models/api/stardust/IOutput.ts b/client/src/models/api/stardust/IOutput.ts index e077aa6b0..1abdec667 100644 --- a/client/src/models/api/stardust/IOutput.ts +++ b/client/src/models/api/stardust/IOutput.ts @@ -1,4 +1,4 @@ -import { OutputTypes } from "@iota/iota.js-stardust"; +import { Output } from "@iota/sdk-wasm/web"; import { IBech32AddressDetails } from "../IBech32AddressDetails"; export interface IOutput { @@ -13,7 +13,7 @@ export interface IOutput { /** * The output. */ - output: OutputTypes; + output: Output; /** * The output amount. */ diff --git a/client/src/models/api/stardust/IOutputDetailsResponse.ts b/client/src/models/api/stardust/IOutputDetailsResponse.ts index cc2a17557..ebb8cf1d6 100644 --- a/client/src/models/api/stardust/IOutputDetailsResponse.ts +++ b/client/src/models/api/stardust/IOutputDetailsResponse.ts @@ -1,9 +1,9 @@ -import { IOutputResponse } from "@iota/iota.js-stardust"; +import { OutputResponse } from "@iota/sdk-wasm/web"; import { IResponse } from "./IResponse"; export interface IOutputDetailsResponse extends IResponse { /** * The output data. */ - output?: IOutputResponse; + output?: OutputResponse; } diff --git a/client/src/models/api/stardust/ISearchResponse.ts b/client/src/models/api/stardust/ISearchResponse.ts index dedef0fce..e7e89c9dd 100644 --- a/client/src/models/api/stardust/ISearchResponse.ts +++ b/client/src/models/api/stardust/ISearchResponse.ts @@ -1,4 +1,4 @@ -import { IBlock, IOutputResponse, IOutputsResponse } from "@iota/iota.js-stardust"; +import { Block, OutputResponse, IOutputsResponse } from "@iota/sdk-wasm/web"; import { IBech32AddressDetails } from "../IBech32AddressDetails"; import { IResponse } from "../IResponse"; import { IAnalyticStats } from "../stats/IAnalyticStats"; @@ -14,12 +14,12 @@ export interface ISearchResponse extends IResponse { /** * Block if it was found. */ - block?: IBlock; + block?: Block; /** * The transaction included block. */ - transactionBlock?: IBlock; + transactionBlock?: Block; /** * Address details. @@ -29,12 +29,12 @@ export interface ISearchResponse extends IResponse { /** * Output if it was found (block will also be populated). */ - output?: IOutputResponse; + output?: OutputResponse; /** * The addres UTXOs. */ - addressOutputs?: IOutputResponse[]; + addressOutputs?: OutputResponse[]; /** * Basic and/or Nft tagged output ids. @@ -59,7 +59,7 @@ export interface ISearchResponse extends IResponse { /** * Alias details. */ - aliasDetails?: IOutputResponse; + aliasDetails?: OutputResponse; /** * Foundry id if it was found. @@ -69,7 +69,7 @@ export interface ISearchResponse extends IResponse { /** * Foundry details. */ - foundryDetails?: IOutputResponse; + foundryDetails?: OutputResponse; /** * Nft id if it was found. @@ -84,7 +84,7 @@ export interface ISearchResponse extends IResponse { /** * Nft details. */ - nftDetails?: IOutputResponse; + nftDetails?: OutputResponse; /** * Foundry outputs. diff --git a/client/src/models/api/stardust/ITransactionDetailsResponse.ts b/client/src/models/api/stardust/ITransactionDetailsResponse.ts index 3516ba264..5e3a3cc1c 100644 --- a/client/src/models/api/stardust/ITransactionDetailsResponse.ts +++ b/client/src/models/api/stardust/ITransactionDetailsResponse.ts @@ -1,9 +1,9 @@ -import { IBlock } from "@iota/iota.js-stardust"; +import { Block } from "@iota/sdk-wasm/web"; import { IResponse } from "../IResponse"; export interface ITransactionDetailsResponse extends IResponse { /** * The transaction included block. */ - block?: IBlock; + block?: Block; } diff --git a/client/src/models/api/stardust/address/IAddressDetailsResponse.ts b/client/src/models/api/stardust/address/IAddressDetailsResponse.ts index 5bf42765d..dd788cbe0 100644 --- a/client/src/models/api/stardust/address/IAddressDetailsResponse.ts +++ b/client/src/models/api/stardust/address/IAddressDetailsResponse.ts @@ -1,9 +1,9 @@ -import { IOutputResponse } from "@iota/iota.js-stardust"; +import { OutputResponse } from "@iota/sdk-wasm/web"; import { IResponse } from "../../IResponse"; export interface IAddressDetailsResponse extends IResponse { /** * The outputs data. */ - outputs?: IOutputResponse[]; + outputs?: OutputResponse[]; } diff --git a/client/src/models/api/stardust/basic/IBasicOutputsResponse.ts b/client/src/models/api/stardust/basic/IBasicOutputsResponse.ts index 6f5df2109..fff2bbb13 100644 --- a/client/src/models/api/stardust/basic/IBasicOutputsResponse.ts +++ b/client/src/models/api/stardust/basic/IBasicOutputsResponse.ts @@ -1,4 +1,4 @@ -import { IOutputsResponse } from "@iota/iota.js-stardust"; +import { IOutputsResponse } from "@iota/sdk-wasm/web"; import { IResponse } from "../../IResponse"; export interface IBasicOutputsResponse extends IResponse { diff --git a/client/src/models/api/stardust/block/IBlockDetailsResponse.ts b/client/src/models/api/stardust/block/IBlockDetailsResponse.ts index ef6f2f51b..e634c1e89 100644 --- a/client/src/models/api/stardust/block/IBlockDetailsResponse.ts +++ b/client/src/models/api/stardust/block/IBlockDetailsResponse.ts @@ -1,4 +1,4 @@ -import { IBlockMetadata } from "@iota/iota.js-stardust"; +import { IBlockMetadata } from "@iota/sdk-wasm/web"; import { IResponse } from "../../IResponse"; export interface IBlockDetailsResponse extends IResponse { diff --git a/client/src/models/api/stardust/block/IBlockResponse.ts b/client/src/models/api/stardust/block/IBlockResponse.ts index ebfaec50b..3de517f29 100644 --- a/client/src/models/api/stardust/block/IBlockResponse.ts +++ b/client/src/models/api/stardust/block/IBlockResponse.ts @@ -1,10 +1,10 @@ -import { IBlock } from "@iota/iota.js-stardust"; +import { Block } from "@iota/sdk-wasm/web"; import { IResponse } from "../../IResponse"; export interface IBlockResponse extends IResponse { /** * The deserialized block. */ - block: IBlock; + block: Block; } diff --git a/client/src/models/api/stardust/feed/IFeedBlockData.ts b/client/src/models/api/stardust/feed/IFeedBlockData.ts index 031e792e4..fba3e7a0a 100644 --- a/client/src/models/api/stardust/feed/IFeedBlockData.ts +++ b/client/src/models/api/stardust/feed/IFeedBlockData.ts @@ -1,4 +1,4 @@ -import { HexEncodedString, IMilestonePayload } from "@iota/iota.js-stardust"; +import { HexEncodedString, MilestonePayload } from "@iota/sdk-wasm/web"; import { IFeedBlockMetadata } from "./IFeedBlockMetadata"; interface IFeedBlockProperties { @@ -50,6 +50,6 @@ export interface IFeedMilestoneData { blockId: string; milestoneId: string; milestoneIndex: number; - payload: IMilestonePayload; + payload: MilestonePayload; timestamp: number; } diff --git a/client/src/models/api/stardust/feed/IFeedBlockMetadata.ts b/client/src/models/api/stardust/feed/IFeedBlockMetadata.ts index fd8c8aeaa..3cd69966f 100644 --- a/client/src/models/api/stardust/feed/IFeedBlockMetadata.ts +++ b/client/src/models/api/stardust/feed/IFeedBlockMetadata.ts @@ -1,4 +1,4 @@ -import { ConflictReason } from "@iota/iota.js-stardust"; +import { ConflictReason } from "@iota/sdk-wasm/web"; export interface IFeedBlockMetadata { /** diff --git a/client/src/models/api/stardust/feed/IFeedUpdate.ts b/client/src/models/api/stardust/feed/IFeedUpdate.ts index 4666ac7ac..cf8fc6f14 100644 --- a/client/src/models/api/stardust/feed/IFeedUpdate.ts +++ b/client/src/models/api/stardust/feed/IFeedUpdate.ts @@ -1,7 +1,7 @@ -import { IMilestonePayload } from "@iota/iota.js-stardust"; +import { Block, MilestonePayload } from "@iota/sdk-wasm/web"; import { IFeedBlockMetadata } from "./IFeedBlockMetadata"; -type IFeedBlockUpdate = string; +type IFeedBlockUpdate = Block; interface IFeedBlockMetadataUpdate { blockId: string; @@ -12,7 +12,7 @@ interface IFeedMilestoneUpdate { blockId: string; milestoneId: string; milestoneIndex: number; - payload: IMilestonePayload; + payload: MilestonePayload; timestamp: number; } diff --git a/client/src/models/api/stardust/foundry/IFoundriesResponse.ts b/client/src/models/api/stardust/foundry/IFoundriesResponse.ts index 0aa0359f6..5adbee027 100644 --- a/client/src/models/api/stardust/foundry/IFoundriesResponse.ts +++ b/client/src/models/api/stardust/foundry/IFoundriesResponse.ts @@ -1,4 +1,4 @@ -import { IOutputsResponse } from "@iota/iota.js-stardust"; +import { IOutputsResponse } from "@iota/sdk-wasm/web"; import { IResponse } from "../IResponse"; export interface IFoundriesResponse extends IResponse { diff --git a/client/src/models/api/stardust/foundry/IFoundryResponse.ts b/client/src/models/api/stardust/foundry/IFoundryResponse.ts index d64431ae0..fc07d8b8a 100644 --- a/client/src/models/api/stardust/foundry/IFoundryResponse.ts +++ b/client/src/models/api/stardust/foundry/IFoundryResponse.ts @@ -1,10 +1,10 @@ -import { IOutputResponse } from "@iota/iota.js-stardust"; +import { OutputResponse } from "@iota/sdk-wasm/web"; import { IResponse } from "../IResponse"; export interface IFoundryResponse extends IResponse { /** * The foundry details response. */ - foundryDetails?: IOutputResponse; + foundryDetails?: OutputResponse; } diff --git a/client/src/models/api/stardust/foundry/IToken.ts b/client/src/models/api/stardust/foundry/IToken.ts index 77538cdfe..4ec594b0b 100644 --- a/client/src/models/api/stardust/foundry/IToken.ts +++ b/client/src/models/api/stardust/foundry/IToken.ts @@ -6,6 +6,6 @@ export interface IToken { /** * The amount of the Native Token. */ - amount: number; + amount: bigint; } diff --git a/client/src/models/api/stardust/nft/INftBase.ts b/client/src/models/api/stardust/nft/INftBase.ts index 9284a3a02..7885f5f44 100644 --- a/client/src/models/api/stardust/nft/INftBase.ts +++ b/client/src/models/api/stardust/nft/INftBase.ts @@ -1,4 +1,4 @@ -import { HexEncodedString } from "@iota/iota.js-stardust"; +import { HexEncodedString } from "@iota/sdk-wasm/web"; export interface INftBase { /** diff --git a/client/src/models/api/stardust/nft/INftDetailsResponse.ts b/client/src/models/api/stardust/nft/INftDetailsResponse.ts index ccf60a95d..19e253a8d 100644 --- a/client/src/models/api/stardust/nft/INftDetailsResponse.ts +++ b/client/src/models/api/stardust/nft/INftDetailsResponse.ts @@ -1,10 +1,10 @@ -import { IOutputResponse } from "@iota/iota.js-stardust"; +import { OutputResponse } from "@iota/sdk-wasm/web"; import { IResponse } from "../IResponse"; export interface INftDetailsResponse extends IResponse { /** * The nft details response. */ - nftDetails?: IOutputResponse; + nftDetails?: OutputResponse; } diff --git a/client/src/models/api/stardust/nft/INftOutputsResponse.ts b/client/src/models/api/stardust/nft/INftOutputsResponse.ts index 99ef62c9a..6154e3bb0 100644 --- a/client/src/models/api/stardust/nft/INftOutputsResponse.ts +++ b/client/src/models/api/stardust/nft/INftOutputsResponse.ts @@ -1,4 +1,4 @@ -import { IOutputsResponse } from "@iota/iota.js-stardust"; +import { IOutputsResponse } from "@iota/sdk-wasm/web"; import { IResponse } from "../../IResponse"; export interface INftOutputsResponse extends IResponse { diff --git a/client/src/models/services/stardust/IFilterSettings.ts b/client/src/models/services/stardust/IFilterSettings.ts index ab635fee1..68f8d5ba3 100644 --- a/client/src/models/services/stardust/IFilterSettings.ts +++ b/client/src/models/services/stardust/IFilterSettings.ts @@ -1,6 +1,7 @@ -import { Magnitudes } from "@iota/iota.js-stardust"; +import { Units } from "@iota/iota.js"; import { FilterField } from "../filterField"; +// This is unused, should be removed (???) export interface IFilterSettings { /** * Value filter for feeds. @@ -15,7 +16,7 @@ export interface IFilterSettings { /** * Value limit units for feeds. */ - valueMinimumMagnitude?: Magnitudes; + valueMinimumMagnitude?: Units; /** * Value limit feeds. @@ -25,7 +26,7 @@ export interface IFilterSettings { /** * Value limit units for feeds. */ - valueMaximumMagnitude?: Magnitudes; + valueMaximumMagnitude?: Units; } diff --git a/client/src/models/tangleStatus.ts b/client/src/models/tangleStatus.ts index 4af68ec13..df3d0adc6 100644 --- a/client/src/models/tangleStatus.ts +++ b/client/src/models/tangleStatus.ts @@ -1,4 +1,4 @@ -import { CONFLICT_REASON_STRINGS, IBlockMetadata } from "@iota/iota.js-stardust"; +import { CONFLICT_REASON_STRINGS, IBlockMetadata } from "@iota/sdk-wasm/web"; export type TangleStatus = "unknown" | diff --git a/client/src/services/currencyService.ts b/client/src/services/currencyService.ts index 3c52a66bf..17cdf96ab 100644 --- a/client/src/services/currencyService.ts +++ b/client/src/services/currencyService.ts @@ -1,4 +1,4 @@ -import { INodeInfoBaseToken } from "@iota/iota.js-stardust"; +import { INodeInfoBaseToken } from "@iota/sdk-wasm/web"; import { ServiceFactory } from "../factories/serviceFactory"; import { TrytesHelper } from "../helpers/trytesHelper"; import { ICurrencySettings } from "../models/services/ICurrencySettings"; diff --git a/client/src/services/nodeInfoService.ts b/client/src/services/nodeInfoService.ts index fd54206f7..dfdfad3f3 100644 --- a/client/src/services/nodeInfoService.ts +++ b/client/src/services/nodeInfoService.ts @@ -1,4 +1,4 @@ -import { INodeInfoBaseToken, IRent } from "@iota/iota.js-stardust"; +import { INodeInfoBaseToken, IRent } from "@iota/sdk-wasm/web"; import { ServiceFactory } from "../factories/serviceFactory"; import { INodeInfoResponse } from "../models/api/stardust/INodeInfoResponse"; import { STARDUST } from "../models/config/protocolVersion"; diff --git a/client/src/services/stardust/stardustApiClient.ts b/client/src/services/stardust/stardustApiClient.ts index 2822f91f4..2651d4303 100644 --- a/client/src/services/stardust/stardustApiClient.ts +++ b/client/src/services/stardust/stardustApiClient.ts @@ -1,4 +1,4 @@ -import { IOutputsResponse } from "@iota/iota.js-stardust"; +import { IOutputsResponse } from "@iota/sdk-wasm/web"; import { FetchHelper } from "../../helpers/fetchHelper"; import { IIdentityStardustResolveRequest } from "../../models/api/IIdentityStardustResolveRequest"; import { IIdentityStardustResolveResponse } from "../../models/api/IIdentityStardustResolveResponse"; diff --git a/client/src/services/stardust/stardustFeedClient.ts b/client/src/services/stardust/stardustFeedClient.ts index 0d2622763..a90752852 100644 --- a/client/src/services/stardust/stardustFeedClient.ts +++ b/client/src/services/stardust/stardustFeedClient.ts @@ -1,15 +1,14 @@ -import { Blake2b } from "@iota/crypto.js-stardust"; import { - BASIC_OUTPUT_TYPE, - deserializeBlock, - IBlock, - milestoneIdFromMilestonePayload, - MILESTONE_PAYLOAD_TYPE, - TAGGED_DATA_PAYLOAD_TYPE, - TRANSACTION_PAYLOAD_TYPE, - TransactionHelper -} from "@iota/iota.js-stardust"; -import { Converter, ReadStream } from "@iota/util.js-stardust"; + BasicOutput, + Block, + MilestonePayload, + OutputType, + PayloadType, + RegularTransactionEssence, + TaggedDataPayload, + TransactionPayload, + Utils +} from "@iota/sdk-wasm/web"; import { io, Socket } from "socket.io-client"; import { ServiceFactory } from "../../factories/serviceFactory"; import { IFeedSubscribeResponse } from "../../models/api/IFeedSubscribeResponse"; @@ -140,7 +139,7 @@ export class StardustFeedClient { } if (update.block) { - const block: IFeedBlockData = this.unmarshalBlock(update.block); + const block: IFeedBlockData = this.buildFeedBlockData(update.block); if (!this.latestBlocks.has(block.blockId)) { this.latestBlocks.set(block.blockId, block); @@ -272,48 +271,47 @@ export class StardustFeedClient { } /** - * Deserialize the block into block data object. - * @param serializedBlock The item source. + * Build the block data object. + * @param block The item source. * @returns The feed item. */ - private unmarshalBlock(serializedBlock: string): IFeedBlockData { - const bytes = Converter.hexToBytes(serializedBlock); - const blockId = Converter.bytesToHex(Blake2b.sum256(bytes), true); + private buildFeedBlockData(block: Block): IFeedBlockData { + const blockId = Utils.blockId(block); let value; let transactionId; let payloadType: "Transaction" | "TaggedData" | "Milestone" | "None" = "None"; const properties: { [key: string]: unknown } = {}; - let block: IBlock | null = null; try { - block = deserializeBlock(new ReadStream(bytes)); - if (block.payload?.type === TRANSACTION_PAYLOAD_TYPE) { - transactionId = Converter.bytesToHex( - TransactionHelper.getTransactionPayloadHash(block.payload), - true - ); + if (block.payload?.type === PayloadType.Transaction) { + const transactionPayload = block.payload as TransactionPayload; + const transactionEssence = transactionPayload.essence as RegularTransactionEssence; + transactionId = Utils.transactionId(transactionPayload); properties.transactionId = transactionId; payloadType = "Transaction"; value = 0; - for (const output of block.payload.essence.outputs) { - if (output.type === BASIC_OUTPUT_TYPE) { - value += Number(output.amount); + for (const output of transactionEssence.outputs) { + if (output.type === OutputType.Basic) { + const basicOutput = output as BasicOutput; + value += Number(basicOutput.amount); } } - if (block.payload.essence.payload) { - properties.tag = block.payload.essence.payload.tag; + if (transactionEssence.payload?.type === PayloadType.TaggedData) { + properties.tag = (transactionEssence.payload as TaggedDataPayload).tag; } - } else if (block.payload?.type === MILESTONE_PAYLOAD_TYPE) { + } else if (block.payload?.type === PayloadType.Milestone) { + const milestonePayload = block.payload as MilestonePayload; payloadType = "Milestone"; - properties.index = block.payload.index; - properties.timestamp = block.payload.timestamp; - properties.milestoneId = milestoneIdFromMilestonePayload(block.payload); - } else if (block.payload?.type === TAGGED_DATA_PAYLOAD_TYPE) { + properties.index = milestonePayload.index; + properties.timestamp = milestonePayload.timestamp; + properties.milestoneId = Utils.milestoneId(milestonePayload); + } else if (block.payload?.type === PayloadType.TaggedData) { + const taggedDataPayload = block.payload as TaggedDataPayload; payloadType = "TaggedData"; - properties.tag = block.payload.tag; + properties.tag = taggedDataPayload.tag; } } catch (err) { console.error(err);