diff --git a/.pnp.cjs b/.pnp.cjs index b2a860bb236..d34e86710ee 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -2476,18 +2476,6 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ - ["@dabh/diagnostics", [\ - ["npm:2.0.2", {\ - "packageLocation": "./.yarn/cache/@dabh-diagnostics-npm-2.0.2-83eb005a83-d0c7ae32da.zip/node_modules/@dabh/diagnostics/",\ - "packageDependencies": [\ - ["@dabh/diagnostics", "npm:2.0.2"],\ - ["colorspace", "npm:1.1.4"],\ - ["enabled", "npm:2.0.0"],\ - ["kuler", "npm:2.0.0"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ ["@dashevo/bench-suite", [\ ["workspace:packages/bench-suite", {\ "packageLocation": "./packages/bench-suite/",\ @@ -2566,54 +2554,26 @@ const RAW_RUNTIME_STATE = ["workspace:packages/js-dapi-client", {\ "packageLocation": "./packages/js-dapi-client/",\ "packageDependencies": [\ - ["@babel/core", "npm:7.26.10"],\ ["@dashevo/dapi-client", "workspace:packages/js-dapi-client"],\ ["@dashevo/dapi-grpc", "workspace:packages/dapi-grpc"],\ ["@dashevo/dash-spv", "workspace:packages/dash-spv"],\ ["@dashevo/dashcore-lib", "npm:0.22.0"],\ ["@dashevo/grpc-common", "workspace:packages/js-grpc-common"],\ ["@dashevo/wasm-dpp", "workspace:packages/wasm-dpp"],\ - ["assert-browserify", "npm:2.0.0"],\ - ["babel-loader", "virtual:8f25fc90e0fb5fd89843707863857591fa8c52f9f33eadced4bf404b1871d91959f7bb86948ae0e1b53ee94d491ef8fde9c0b58b39c9490c0d0fa6c931945f97#npm:9.1.3"],\ - ["browserify-zlib", "npm:0.2.0"],\ - ["bs58", "npm:4.0.1"],\ - ["buffer", "npm:6.0.3"],\ ["cbor", "npm:8.1.0"],\ ["chai", "npm:4.3.10"],\ ["chai-as-promised", "virtual:e2d057e7cc143d3cb9bec864f4a2d862441b5a09f81f8e6c46e7a098cbc89e4d07017cc6e2e2142d5704bb55da853cbec2d025ebc0b30e8696c31380c00f2c7d#npm:7.1.1"],\ ["comment-parser", "npm:0.7.6"],\ - ["core-js", "npm:3.33.2"],\ - ["crypto-browserify", "npm:3.12.1"],\ ["dirty-chai", "virtual:e2d057e7cc143d3cb9bec864f4a2d862441b5a09f81f8e6c46e7a098cbc89e4d07017cc6e2e2142d5704bb55da853cbec2d025ebc0b30e8696c31380c00f2c7d#npm:2.0.1"],\ ["eslint", "virtual:de32c10d523830f1843784ae863166d6ef2e074b6da9615f2b3296a1f90385ed3f59e274e3957326ba7cf3442d82470d9e1ec01e6720989a570c075c95d90dbc#npm:9.39.2"],\ ["events", "npm:3.3.0"],\ ["google-protobuf", "npm:3.19.1"],\ - ["karma", "npm:6.4.3"],\ - ["karma-chai", "virtual:e2d057e7cc143d3cb9bec864f4a2d862441b5a09f81f8e6c46e7a098cbc89e4d07017cc6e2e2142d5704bb55da853cbec2d025ebc0b30e8696c31380c00f2c7d#npm:0.1.0"],\ - ["karma-chrome-launcher", "npm:3.1.0"],\ - ["karma-firefox-launcher", "npm:2.1.2"],\ - ["karma-mocha", "npm:2.0.1"],\ - ["karma-mocha-reporter", "virtual:e2d057e7cc143d3cb9bec864f4a2d862441b5a09f81f8e6c46e7a098cbc89e4d07017cc6e2e2142d5704bb55da853cbec2d025ebc0b30e8696c31380c00f2c7d#npm:2.2.5"],\ - ["karma-webpack", "virtual:8f25fc90e0fb5fd89843707863857591fa8c52f9f33eadced4bf404b1871d91959f7bb86948ae0e1b53ee94d491ef8fde9c0b58b39c9490c0d0fa6c931945f97#npm:5.0.0"],\ - ["lodash", "npm:4.17.23"],\ ["mocha", "npm:11.1.0"],\ - ["node-fetch", "virtual:8f25fc90e0fb5fd89843707863857591fa8c52f9f33eadced4bf404b1871d91959f7bb86948ae0e1b53ee94d491ef8fde9c0b58b39c9490c0d0fa6c931945f97#npm:2.6.7"],\ - ["node-inspect-extracted", "npm:1.0.8"],\ ["nyc", "npm:15.1.0"],\ - ["os-browserify", "npm:0.3.0"],\ - ["path-browserify", "npm:1.0.1"],\ - ["process", "npm:0.11.10"],\ - ["setimmediate", "npm:1.0.5"],\ ["sinon", "npm:18.0.1"],\ ["sinon-chai", "virtual:e2d057e7cc143d3cb9bec864f4a2d862441b5a09f81f8e6c46e7a098cbc89e4d07017cc6e2e2142d5704bb55da853cbec2d025ebc0b30e8696c31380c00f2c7d#npm:3.7.0"],\ - ["stream-browserify", "npm:3.0.0"],\ - ["string_decoder", "npm:1.3.0"],\ - ["url", "npm:0.11.3"],\ - ["util", "npm:0.12.4"],\ - ["wasm-x11-hash", "npm:0.0.2"],\ - ["webpack", "virtual:8f25fc90e0fb5fd89843707863857591fa8c52f9f33eadced4bf404b1871d91959f7bb86948ae0e1b53ee94d491ef8fde9c0b58b39c9490c0d0fa6c931945f97#npm:5.105.0"],\ - ["webpack-cli", "virtual:8f25fc90e0fb5fd89843707863857591fa8c52f9f33eadced4bf404b1871d91959f7bb86948ae0e1b53ee94d491ef8fde9c0b58b39c9490c0d0fa6c931945f97#npm:4.9.1"],\ - ["winston", "npm:3.3.3"]\ + ["undici", "npm:6.25.0"],\ + ["wasm-x11-hash", "npm:0.0.2"]\ ],\ "linkType": "SOFT"\ }]\ @@ -2797,7 +2757,7 @@ const RAW_RUNTIME_STATE = ["eslint", "virtual:de32c10d523830f1843784ae863166d6ef2e074b6da9615f2b3296a1f90385ed3f59e274e3957326ba7cf3442d82470d9e1ec01e6720989a570c075c95d90dbc#npm:9.39.2"],\ ["events", "npm:3.3.0"],\ ["karma", "npm:6.4.3"],\ - ["karma-chai", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:0.1.0"],\ + ["karma-chai", "virtual:98d1afeac78a19485e4cb7428abff692e58b6fc468d8040035b560ed49383fc95857be6b5014af27e53063e6f08b654690c2b945f3443c22dd60c6b083684b3c#npm:0.1.0"],\ ["karma-chrome-launcher", "npm:3.1.0"],\ ["karma-firefox-launcher", "npm:2.1.2"],\ ["karma-mocha", "npm:2.0.1"],\ @@ -2916,49 +2876,23 @@ const RAW_RUNTIME_STATE = ["@dashevo/wallet-lib", "workspace:packages/wallet-lib"],\ ["@dashevo/wasm-dpp", "workspace:packages/wasm-dpp"],\ ["@dashevo/withdrawals-contract", "workspace:packages/withdrawals-contract"],\ - ["assert", "npm:2.0.0"],\ - ["assert-browserify", "npm:2.0.0"],\ - ["browserify-zlib", "npm:0.2.0"],\ - ["buffer", "npm:6.0.3"],\ ["bufferutil", "npm:4.0.6"],\ ["chai", "npm:4.3.10"],\ ["chai-as-promised", "virtual:e2d057e7cc143d3cb9bec864f4a2d862441b5a09f81f8e6c46e7a098cbc89e4d07017cc6e2e2142d5704bb55da853cbec2d025ebc0b30e8696c31380c00f2c7d#npm:7.1.1"],\ - ["crypto-browserify", "npm:3.12.1"],\ ["dash", "workspace:packages/js-dash-sdk"],\ ["dirty-chai", "virtual:e2d057e7cc143d3cb9bec864f4a2d862441b5a09f81f8e6c46e7a098cbc89e4d07017cc6e2e2142d5704bb55da853cbec2d025ebc0b30e8696c31380c00f2c7d#npm:2.0.1"],\ ["dotenv-safe", "npm:8.2.0"],\ ["eslint", "virtual:de32c10d523830f1843784ae863166d6ef2e074b6da9615f2b3296a1f90385ed3f59e274e3957326ba7cf3442d82470d9e1ec01e6720989a570c075c95d90dbc#npm:9.39.2"],\ - ["events", "npm:3.3.0"],\ ["glob", "npm:10.4.1"],\ - ["https-browserify", "npm:1.0.0"],\ ["js-merkle", "npm:0.1.5"],\ - ["karma", "npm:6.4.3"],\ - ["karma-chai", "virtual:e2d057e7cc143d3cb9bec864f4a2d862441b5a09f81f8e6c46e7a098cbc89e4d07017cc6e2e2142d5704bb55da853cbec2d025ebc0b30e8696c31380c00f2c7d#npm:0.1.0"],\ - ["karma-chrome-launcher", "npm:3.1.0"],\ - ["karma-firefox-launcher", "npm:2.1.2"],\ - ["karma-mocha", "npm:2.0.1"],\ - ["karma-mocha-reporter", "virtual:e2d057e7cc143d3cb9bec864f4a2d862441b5a09f81f8e6c46e7a098cbc89e4d07017cc6e2e2142d5704bb55da853cbec2d025ebc0b30e8696c31380c00f2c7d#npm:2.2.5"],\ - ["karma-sourcemap-loader", "npm:0.3.8"],\ - ["karma-webpack", "virtual:01938c2be4835443e5a304e2b117c575220e96e8b7cedeb0f48d79264590b4c4babc6d1fea6367f522b1ca0149d795b42f2ab89c34a6ffe3c20f0a8cbb8b4453#npm:5.0.0"],\ ["localforage", "npm:1.10.0"],\ ["mocha", "npm:11.1.0"],\ - ["net", "npm:1.0.2"],\ ["nodeforage", "npm:1.1.2"],\ - ["os-browserify", "npm:0.3.0"],\ - ["path-browserify", "npm:1.0.1"],\ - ["process", "npm:0.11.10"],\ ["semver", "npm:7.5.3"],\ ["setimmediate", "npm:1.0.5"],\ ["sinon", "npm:18.0.1"],\ ["sinon-chai", "virtual:e2d057e7cc143d3cb9bec864f4a2d862441b5a09f81f8e6c46e7a098cbc89e4d07017cc6e2e2142d5704bb55da853cbec2d025ebc0b30e8696c31380c00f2c7d#npm:3.7.0"],\ - ["stream-browserify", "npm:3.0.0"],\ - ["stream-http", "npm:3.2.0"],\ - ["string_decoder", "npm:1.3.0"],\ - ["tls", "npm:0.0.1"],\ - ["url", "npm:0.11.3"],\ ["utf-8-validate", "npm:5.0.9"],\ - ["util", "npm:0.12.4"],\ - ["webpack", "virtual:01938c2be4835443e5a304e2b117c575220e96e8b7cedeb0f48d79264590b4c4babc6d1fea6367f522b1ca0149d795b42f2ab89c34a6ffe3c20f0a8cbb8b4453#npm:5.105.0"],\ ["ws", "virtual:01938c2be4835443e5a304e2b117c575220e96e8b7cedeb0f48d79264590b4c4babc6d1fea6367f522b1ca0149d795b42f2ab89c34a6ffe3c20f0a8cbb8b4453#npm:8.17.1"]\ ],\ "linkType": "SOFT"\ @@ -3021,48 +2955,22 @@ const RAW_RUNTIME_STATE = ["@dashevo/wallet-lib", "workspace:packages/wallet-lib"],\ ["@dashevo/wasm-dpp", "workspace:packages/wasm-dpp"],\ ["@yarnpkg/pnpify", "npm:4.0.0-rc.42"],\ - ["assert", "npm:2.0.0"],\ - ["browserify-zlib", "npm:0.2.0"],\ - ["buffer", "npm:6.0.3"],\ ["cbor", "npm:8.1.0"],\ ["chai", "npm:4.3.10"],\ ["chai-as-promised", "virtual:e2d057e7cc143d3cb9bec864f4a2d862441b5a09f81f8e6c46e7a098cbc89e4d07017cc6e2e2142d5704bb55da853cbec2d025ebc0b30e8696c31380c00f2c7d#npm:7.1.1"],\ - ["crypto-browserify", "npm:3.12.1"],\ ["crypto-js", "npm:4.2.0"],\ ["dirty-chai", "virtual:e2d057e7cc143d3cb9bec864f4a2d862441b5a09f81f8e6c46e7a098cbc89e4d07017cc6e2e2142d5704bb55da853cbec2d025ebc0b30e8696c31380c00f2c7d#npm:2.0.1"],\ ["dotenv-safe", "npm:8.2.0"],\ ["eslint", "virtual:de32c10d523830f1843784ae863166d6ef2e074b6da9615f2b3296a1f90385ed3f59e274e3957326ba7cf3442d82470d9e1ec01e6720989a570c075c95d90dbc#npm:9.39.2"],\ ["events", "npm:3.3.0"],\ - ["https-browserify", "npm:1.0.0"],\ - ["karma", "npm:6.4.3"],\ - ["karma-chai", "virtual:e2d057e7cc143d3cb9bec864f4a2d862441b5a09f81f8e6c46e7a098cbc89e4d07017cc6e2e2142d5704bb55da853cbec2d025ebc0b30e8696c31380c00f2c7d#npm:0.1.0"],\ - ["karma-chrome-launcher", "npm:3.1.0"],\ - ["karma-firefox-launcher", "npm:2.1.2"],\ - ["karma-mocha", "npm:2.0.1"],\ - ["karma-mocha-reporter", "virtual:e2d057e7cc143d3cb9bec864f4a2d862441b5a09f81f8e6c46e7a098cbc89e4d07017cc6e2e2142d5704bb55da853cbec2d025ebc0b30e8696c31380c00f2c7d#npm:2.2.5"],\ - ["karma-sourcemap-loader", "npm:0.3.8"],\ - ["karma-webpack", "virtual:45f214395bc38640da4dc5e940482d5df0572c5384e0262802601d1973e71077ec8bbd76b77eafa4c0550b706b664abd84d63fd67a5897139f0b2675530fc84f#npm:5.0.0"],\ ["lodash", "npm:4.17.23"],\ ["mocha", "npm:11.1.0"],\ - ["node-inspect-extracted", "npm:1.0.8"],\ ["nyc", "npm:15.1.0"],\ - ["os-browserify", "npm:0.3.0"],\ - ["path-browserify", "npm:1.0.1"],\ ["pbkdf2", "npm:3.1.3"],\ - ["process", "npm:0.11.10"],\ - ["setimmediate", "npm:1.0.5"],\ ["sinon", "npm:18.0.1"],\ ["sinon-chai", "virtual:e2d057e7cc143d3cb9bec864f4a2d862441b5a09f81f8e6c46e7a098cbc89e4d07017cc6e2e2142d5704bb55da853cbec2d025ebc0b30e8696c31380c00f2c7d#npm:3.7.0"],\ - ["stream-browserify", "npm:3.0.0"],\ - ["stream-http", "npm:3.2.0"],\ - ["string_decoder", "npm:1.3.0"],\ ["tsd", "npm:0.28.1"],\ - ["url", "npm:0.11.3"],\ - ["util", "npm:0.12.4"],\ - ["wasm-x11-hash", "npm:0.0.2"],\ - ["webpack", "virtual:45f214395bc38640da4dc5e940482d5df0572c5384e0262802601d1973e71077ec8bbd76b77eafa4c0550b706b664abd84d63fd67a5897139f0b2675530fc84f#npm:5.105.0"],\ - ["webpack-cli", "virtual:45f214395bc38640da4dc5e940482d5df0572c5384e0262802601d1973e71077ec8bbd76b77eafa4c0550b706b664abd84d63fd67a5897139f0b2675530fc84f#npm:4.9.1"],\ - ["winston", "npm:3.3.3"]\ + ["wasm-x11-hash", "npm:0.0.2"]\ ],\ "linkType": "SOFT"\ }]\ @@ -3159,7 +3067,7 @@ const RAW_RUNTIME_STATE = ["eslint", "virtual:de32c10d523830f1843784ae863166d6ef2e074b6da9615f2b3296a1f90385ed3f59e274e3957326ba7cf3442d82470d9e1ec01e6720989a570c075c95d90dbc#npm:9.39.2"],\ ["events", "npm:3.3.0"],\ ["karma", "npm:6.4.3"],\ - ["karma-chai", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:0.1.0"],\ + ["karma-chai", "virtual:98d1afeac78a19485e4cb7428abff692e58b6fc468d8040035b560ed49383fc95857be6b5014af27e53063e6f08b654690c2b945f3443c22dd60c6b083684b3c#npm:0.1.0"],\ ["karma-chrome-launcher", "npm:3.1.0"],\ ["karma-firefox-launcher", "npm:2.1.2"],\ ["karma-mocha", "npm:2.0.1"],\ @@ -3196,7 +3104,7 @@ const RAW_RUNTIME_STATE = ["eslint", "virtual:de32c10d523830f1843784ae863166d6ef2e074b6da9615f2b3296a1f90385ed3f59e274e3957326ba7cf3442d82470d9e1ec01e6720989a570c075c95d90dbc#npm:9.39.2"],\ ["events", "npm:3.3.0"],\ ["karma", "npm:6.4.3"],\ - ["karma-chai", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:0.1.0"],\ + ["karma-chai", "virtual:98d1afeac78a19485e4cb7428abff692e58b6fc468d8040035b560ed49383fc95857be6b5014af27e53063e6f08b654690c2b945f3443c22dd60c6b083684b3c#npm:0.1.0"],\ ["karma-chrome-launcher", "npm:3.1.0"],\ ["karma-firefox-launcher", "npm:2.1.2"],\ ["karma-mocha", "npm:2.0.1"],\ @@ -4422,7 +4330,7 @@ const RAW_RUNTIME_STATE = ["@octokit/request-error", "npm:2.1.0"],\ ["@octokit/types", "npm:6.34.0"],\ ["is-plain-object", "npm:5.0.0"],\ - ["node-fetch", "virtual:8f25fc90e0fb5fd89843707863857591fa8c52f9f33eadced4bf404b1871d91959f7bb86948ae0e1b53ee94d491ef8fde9c0b58b39c9490c0d0fa6c931945f97#npm:2.6.7"],\ + ["node-fetch", "virtual:25a5f5382d53dbf298bf7a1191760bc2e0a523a619eeb0e667b99a8649e8ad183f9e2e0b45f6fb831b92f4078b61622aa567cf79565f6aa5af9597e3c84864f6#npm:2.6.7"],\ ["universal-user-agent", "npm:6.0.0"]\ ],\ "linkType": "HARD"\ @@ -6073,23 +5981,6 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "SOFT"\ }],\ - ["virtual:0249f7ceb5542d6b732af2b44f9fcd16c60be8b8440f0f3abc6a5de67aabcff731bc3bc83f3067ab2f9037661176f001f89208fcea9e8962835fd43d0aabe88a#npm:1.1.0", {\ - "packageLocation": "./.yarn/__virtual__/@webpack-cli-configtest-virtual-7a30f6ad18/0/cache/@webpack-cli-configtest-npm-1.1.0-2b6b2ef3d7-69e7816b5b.zip/node_modules/@webpack-cli/configtest/",\ - "packageDependencies": [\ - ["@types/webpack", null],\ - ["@types/webpack-cli", null],\ - ["@webpack-cli/configtest", "virtual:0249f7ceb5542d6b732af2b44f9fcd16c60be8b8440f0f3abc6a5de67aabcff731bc3bc83f3067ab2f9037661176f001f89208fcea9e8962835fd43d0aabe88a#npm:1.1.0"],\ - ["webpack", "virtual:45f214395bc38640da4dc5e940482d5df0572c5384e0262802601d1973e71077ec8bbd76b77eafa4c0550b706b664abd84d63fd67a5897139f0b2675530fc84f#npm:5.105.0"],\ - ["webpack-cli", "virtual:45f214395bc38640da4dc5e940482d5df0572c5384e0262802601d1973e71077ec8bbd76b77eafa4c0550b706b664abd84d63fd67a5897139f0b2675530fc84f#npm:4.9.1"]\ - ],\ - "packagePeers": [\ - "@types/webpack-cli",\ - "@types/webpack",\ - "webpack-cli",\ - "webpack"\ - ],\ - "linkType": "HARD"\ - }],\ ["virtual:16885aa8448c33477ea2cd730ac3a5bbbcb89a3f570f5364364e7dc5830b16f19367cec64b723cc62ddb3078b4ee0f0ce5d244584279bc98369c8ee9e5959a27#npm:1.1.0", {\ "packageLocation": "./.yarn/__virtual__/@webpack-cli-configtest-virtual-1cf1a90458/0/cache/@webpack-cli-configtest-npm-1.1.0-2b6b2ef3d7-69e7816b5b.zip/node_modules/@webpack-cli/configtest/",\ "packageDependencies": [\ @@ -6107,23 +5998,6 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ - ["virtual:7fc88da9d00679384dc013444a3b1ed8ef8395fcad9d046790a1851d5db985e5ee052061731f87c5475e4bf20a92d69ea1a1a287c0d76d7b1a6bf97010c63532#npm:1.1.0", {\ - "packageLocation": "./.yarn/__virtual__/@webpack-cli-configtest-virtual-4b48f64ff3/0/cache/@webpack-cli-configtest-npm-1.1.0-2b6b2ef3d7-69e7816b5b.zip/node_modules/@webpack-cli/configtest/",\ - "packageDependencies": [\ - ["@types/webpack", null],\ - ["@types/webpack-cli", null],\ - ["@webpack-cli/configtest", "virtual:7fc88da9d00679384dc013444a3b1ed8ef8395fcad9d046790a1851d5db985e5ee052061731f87c5475e4bf20a92d69ea1a1a287c0d76d7b1a6bf97010c63532#npm:1.1.0"],\ - ["webpack", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:5.105.0"],\ - ["webpack-cli", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:4.9.1"]\ - ],\ - "packagePeers": [\ - "@types/webpack-cli",\ - "@types/webpack",\ - "webpack-cli",\ - "webpack"\ - ],\ - "linkType": "HARD"\ - }],\ ["virtual:a5a6463a0bb826fa62fe988272ac511c2dd2d7b75a693754f12e5e1d5d09a8882a0c7fc9cc88d37e0f1a3647214b9bc4031426b2ba0ee449276ccbb9901a0ba8#npm:1.1.0", {\ "packageLocation": "./.yarn/__virtual__/@webpack-cli-configtest-virtual-962a737a82/0/cache/@webpack-cli-configtest-npm-1.1.0-2b6b2ef3d7-69e7816b5b.zip/node_modules/@webpack-cli/configtest/",\ "packageDependencies": [\ @@ -6141,23 +6015,6 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ - ["virtual:b37ef7cf98ceabe8c7b789a7db3f0a5f3444d083afa5f0e3ab570292e74eff241f890fadbf245a134b2ebfcba326b1782124a4dd4f16ca7cdb6091dd9a987c04#npm:1.1.0", {\ - "packageLocation": "./.yarn/__virtual__/@webpack-cli-configtest-virtual-34b876bdf7/0/cache/@webpack-cli-configtest-npm-1.1.0-2b6b2ef3d7-69e7816b5b.zip/node_modules/@webpack-cli/configtest/",\ - "packageDependencies": [\ - ["@types/webpack", null],\ - ["@types/webpack-cli", null],\ - ["@webpack-cli/configtest", "virtual:b37ef7cf98ceabe8c7b789a7db3f0a5f3444d083afa5f0e3ab570292e74eff241f890fadbf245a134b2ebfcba326b1782124a4dd4f16ca7cdb6091dd9a987c04#npm:1.1.0"],\ - ["webpack", "virtual:8f25fc90e0fb5fd89843707863857591fa8c52f9f33eadced4bf404b1871d91959f7bb86948ae0e1b53ee94d491ef8fde9c0b58b39c9490c0d0fa6c931945f97#npm:5.105.0"],\ - ["webpack-cli", "virtual:8f25fc90e0fb5fd89843707863857591fa8c52f9f33eadced4bf404b1871d91959f7bb86948ae0e1b53ee94d491ef8fde9c0b58b39c9490c0d0fa6c931945f97#npm:4.9.1"]\ - ],\ - "packagePeers": [\ - "@types/webpack-cli",\ - "@types/webpack",\ - "webpack-cli",\ - "webpack"\ - ],\ - "linkType": "HARD"\ - }],\ ["virtual:b65947dc409e3c56a3ffe1d9845d7e7551f7c6a754af3941e9848fc9815659e0053c64fd038dddc29d956633aad694f761d0d61fe40b22419d9d10b8b52633c6#npm:1.1.0", {\ "packageLocation": "./.yarn/__virtual__/@webpack-cli-configtest-virtual-1656ebbd4e/0/cache/@webpack-cli-configtest-npm-1.1.0-2b6b2ef3d7-69e7816b5b.zip/node_modules/@webpack-cli/configtest/",\ "packageDependencies": [\ @@ -6201,20 +6058,6 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "SOFT"\ }],\ - ["virtual:0249f7ceb5542d6b732af2b44f9fcd16c60be8b8440f0f3abc6a5de67aabcff731bc3bc83f3067ab2f9037661176f001f89208fcea9e8962835fd43d0aabe88a#npm:1.4.0", {\ - "packageLocation": "./.yarn/__virtual__/@webpack-cli-info-virtual-b6b54dc15e/0/cache/@webpack-cli-info-npm-1.4.0-4a26ccee64-6385b1e2c5.zip/node_modules/@webpack-cli/info/",\ - "packageDependencies": [\ - ["@types/webpack-cli", null],\ - ["@webpack-cli/info", "virtual:0249f7ceb5542d6b732af2b44f9fcd16c60be8b8440f0f3abc6a5de67aabcff731bc3bc83f3067ab2f9037661176f001f89208fcea9e8962835fd43d0aabe88a#npm:1.4.0"],\ - ["envinfo", "npm:7.8.1"],\ - ["webpack-cli", "virtual:45f214395bc38640da4dc5e940482d5df0572c5384e0262802601d1973e71077ec8bbd76b77eafa4c0550b706b664abd84d63fd67a5897139f0b2675530fc84f#npm:4.9.1"]\ - ],\ - "packagePeers": [\ - "@types/webpack-cli",\ - "webpack-cli"\ - ],\ - "linkType": "HARD"\ - }],\ ["virtual:16885aa8448c33477ea2cd730ac3a5bbbcb89a3f570f5364364e7dc5830b16f19367cec64b723cc62ddb3078b4ee0f0ce5d244584279bc98369c8ee9e5959a27#npm:1.4.0", {\ "packageLocation": "./.yarn/__virtual__/@webpack-cli-info-virtual-c12065ef90/0/cache/@webpack-cli-info-npm-1.4.0-4a26ccee64-6385b1e2c5.zip/node_modules/@webpack-cli/info/",\ "packageDependencies": [\ @@ -6229,20 +6072,6 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ - ["virtual:7fc88da9d00679384dc013444a3b1ed8ef8395fcad9d046790a1851d5db985e5ee052061731f87c5475e4bf20a92d69ea1a1a287c0d76d7b1a6bf97010c63532#npm:1.4.0", {\ - "packageLocation": "./.yarn/__virtual__/@webpack-cli-info-virtual-c05860be1d/0/cache/@webpack-cli-info-npm-1.4.0-4a26ccee64-6385b1e2c5.zip/node_modules/@webpack-cli/info/",\ - "packageDependencies": [\ - ["@types/webpack-cli", null],\ - ["@webpack-cli/info", "virtual:7fc88da9d00679384dc013444a3b1ed8ef8395fcad9d046790a1851d5db985e5ee052061731f87c5475e4bf20a92d69ea1a1a287c0d76d7b1a6bf97010c63532#npm:1.4.0"],\ - ["envinfo", "npm:7.8.1"],\ - ["webpack-cli", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:4.9.1"]\ - ],\ - "packagePeers": [\ - "@types/webpack-cli",\ - "webpack-cli"\ - ],\ - "linkType": "HARD"\ - }],\ ["virtual:a5a6463a0bb826fa62fe988272ac511c2dd2d7b75a693754f12e5e1d5d09a8882a0c7fc9cc88d37e0f1a3647214b9bc4031426b2ba0ee449276ccbb9901a0ba8#npm:1.4.0", {\ "packageLocation": "./.yarn/__virtual__/@webpack-cli-info-virtual-8096a86511/0/cache/@webpack-cli-info-npm-1.4.0-4a26ccee64-6385b1e2c5.zip/node_modules/@webpack-cli/info/",\ "packageDependencies": [\ @@ -6257,20 +6086,6 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ - ["virtual:b37ef7cf98ceabe8c7b789a7db3f0a5f3444d083afa5f0e3ab570292e74eff241f890fadbf245a134b2ebfcba326b1782124a4dd4f16ca7cdb6091dd9a987c04#npm:1.4.0", {\ - "packageLocation": "./.yarn/__virtual__/@webpack-cli-info-virtual-5b3c564e68/0/cache/@webpack-cli-info-npm-1.4.0-4a26ccee64-6385b1e2c5.zip/node_modules/@webpack-cli/info/",\ - "packageDependencies": [\ - ["@types/webpack-cli", null],\ - ["@webpack-cli/info", "virtual:b37ef7cf98ceabe8c7b789a7db3f0a5f3444d083afa5f0e3ab570292e74eff241f890fadbf245a134b2ebfcba326b1782124a4dd4f16ca7cdb6091dd9a987c04#npm:1.4.0"],\ - ["envinfo", "npm:7.8.1"],\ - ["webpack-cli", "virtual:8f25fc90e0fb5fd89843707863857591fa8c52f9f33eadced4bf404b1871d91959f7bb86948ae0e1b53ee94d491ef8fde9c0b58b39c9490c0d0fa6c931945f97#npm:4.9.1"]\ - ],\ - "packagePeers": [\ - "@types/webpack-cli",\ - "webpack-cli"\ - ],\ - "linkType": "HARD"\ - }],\ ["virtual:b65947dc409e3c56a3ffe1d9845d7e7551f7c6a754af3941e9848fc9815659e0053c64fd038dddc29d956633aad694f761d0d61fe40b22419d9d10b8b52633c6#npm:1.4.0", {\ "packageLocation": "./.yarn/__virtual__/@webpack-cli-info-virtual-f31931ce84/0/cache/@webpack-cli-info-npm-1.4.0-4a26ccee64-6385b1e2c5.zip/node_modules/@webpack-cli/info/",\ "packageDependencies": [\ @@ -6308,23 +6123,6 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "SOFT"\ }],\ - ["virtual:0249f7ceb5542d6b732af2b44f9fcd16c60be8b8440f0f3abc6a5de67aabcff731bc3bc83f3067ab2f9037661176f001f89208fcea9e8962835fd43d0aabe88a#npm:1.6.0", {\ - "packageLocation": "./.yarn/__virtual__/@webpack-cli-serve-virtual-5bd62e0e2f/0/cache/@webpack-cli-serve-npm-1.6.0-c7b35aa4ef-3fd2e5f365.zip/node_modules/@webpack-cli/serve/",\ - "packageDependencies": [\ - ["@types/webpack-cli", null],\ - ["@types/webpack-dev-server", null],\ - ["@webpack-cli/serve", "virtual:0249f7ceb5542d6b732af2b44f9fcd16c60be8b8440f0f3abc6a5de67aabcff731bc3bc83f3067ab2f9037661176f001f89208fcea9e8962835fd43d0aabe88a#npm:1.6.0"],\ - ["webpack-cli", "virtual:45f214395bc38640da4dc5e940482d5df0572c5384e0262802601d1973e71077ec8bbd76b77eafa4c0550b706b664abd84d63fd67a5897139f0b2675530fc84f#npm:4.9.1"],\ - ["webpack-dev-server", null]\ - ],\ - "packagePeers": [\ - "@types/webpack-cli",\ - "@types/webpack-dev-server",\ - "webpack-cli",\ - "webpack-dev-server"\ - ],\ - "linkType": "HARD"\ - }],\ ["virtual:16885aa8448c33477ea2cd730ac3a5bbbcb89a3f570f5364364e7dc5830b16f19367cec64b723cc62ddb3078b4ee0f0ce5d244584279bc98369c8ee9e5959a27#npm:1.6.0", {\ "packageLocation": "./.yarn/__virtual__/@webpack-cli-serve-virtual-f46be14e99/0/cache/@webpack-cli-serve-npm-1.6.0-c7b35aa4ef-3fd2e5f365.zip/node_modules/@webpack-cli/serve/",\ "packageDependencies": [\ @@ -6342,23 +6140,6 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ - ["virtual:7fc88da9d00679384dc013444a3b1ed8ef8395fcad9d046790a1851d5db985e5ee052061731f87c5475e4bf20a92d69ea1a1a287c0d76d7b1a6bf97010c63532#npm:1.6.0", {\ - "packageLocation": "./.yarn/__virtual__/@webpack-cli-serve-virtual-02793a9ef0/0/cache/@webpack-cli-serve-npm-1.6.0-c7b35aa4ef-3fd2e5f365.zip/node_modules/@webpack-cli/serve/",\ - "packageDependencies": [\ - ["@types/webpack-cli", null],\ - ["@types/webpack-dev-server", null],\ - ["@webpack-cli/serve", "virtual:7fc88da9d00679384dc013444a3b1ed8ef8395fcad9d046790a1851d5db985e5ee052061731f87c5475e4bf20a92d69ea1a1a287c0d76d7b1a6bf97010c63532#npm:1.6.0"],\ - ["webpack-cli", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:4.9.1"],\ - ["webpack-dev-server", null]\ - ],\ - "packagePeers": [\ - "@types/webpack-cli",\ - "@types/webpack-dev-server",\ - "webpack-cli",\ - "webpack-dev-server"\ - ],\ - "linkType": "HARD"\ - }],\ ["virtual:a5a6463a0bb826fa62fe988272ac511c2dd2d7b75a693754f12e5e1d5d09a8882a0c7fc9cc88d37e0f1a3647214b9bc4031426b2ba0ee449276ccbb9901a0ba8#npm:1.6.0", {\ "packageLocation": "./.yarn/__virtual__/@webpack-cli-serve-virtual-29c8ff0174/0/cache/@webpack-cli-serve-npm-1.6.0-c7b35aa4ef-3fd2e5f365.zip/node_modules/@webpack-cli/serve/",\ "packageDependencies": [\ @@ -6376,23 +6157,6 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ - ["virtual:b37ef7cf98ceabe8c7b789a7db3f0a5f3444d083afa5f0e3ab570292e74eff241f890fadbf245a134b2ebfcba326b1782124a4dd4f16ca7cdb6091dd9a987c04#npm:1.6.0", {\ - "packageLocation": "./.yarn/__virtual__/@webpack-cli-serve-virtual-bcf913d932/0/cache/@webpack-cli-serve-npm-1.6.0-c7b35aa4ef-3fd2e5f365.zip/node_modules/@webpack-cli/serve/",\ - "packageDependencies": [\ - ["@types/webpack-cli", null],\ - ["@types/webpack-dev-server", null],\ - ["@webpack-cli/serve", "virtual:b37ef7cf98ceabe8c7b789a7db3f0a5f3444d083afa5f0e3ab570292e74eff241f890fadbf245a134b2ebfcba326b1782124a4dd4f16ca7cdb6091dd9a987c04#npm:1.6.0"],\ - ["webpack-cli", "virtual:8f25fc90e0fb5fd89843707863857591fa8c52f9f33eadced4bf404b1871d91959f7bb86948ae0e1b53ee94d491ef8fde9c0b58b39c9490c0d0fa6c931945f97#npm:4.9.1"],\ - ["webpack-dev-server", null]\ - ],\ - "packagePeers": [\ - "@types/webpack-cli",\ - "@types/webpack-dev-server",\ - "webpack-cli",\ - "webpack-dev-server"\ - ],\ - "linkType": "HARD"\ - }],\ ["virtual:b65947dc409e3c56a3ffe1d9845d7e7551f7c6a754af3941e9848fc9815659e0053c64fd038dddc29d956633aad694f761d0d61fe40b22419d9d10b8b52633c6#npm:1.6.0", {\ "packageLocation": "./.yarn/__virtual__/@webpack-cli-serve-virtual-4711a17f04/0/cache/@webpack-cli-serve-npm-1.6.0-c7b35aa4ef-3fd2e5f365.zip/node_modules/@webpack-cli/serve/",\ "packageDependencies": [\ @@ -7282,19 +7046,6 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ - ["assert-browserify", [\ - ["npm:2.0.0", {\ - "packageLocation": "./.yarn/cache/assert-browserify-npm-2.0.0-8125e483ea-161984368c.zip/node_modules/assert-browserify/",\ - "packageDependencies": [\ - ["assert-browserify", "npm:2.0.0"],\ - ["es6-object-assign", "npm:1.1.0"],\ - ["is-nan", "npm:1.3.2"],\ - ["object-is", "npm:1.1.5"],\ - ["util", "npm:0.12.4"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ ["assertion-error", [\ ["npm:1.1.0", {\ "packageLocation": "./.yarn/cache/assertion-error-npm-1.1.0-66b893015e-fd9429d3a3.zip/node_modules/assertion-error/",\ @@ -7449,34 +7200,6 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ - ["babel-loader", [\ - ["npm:9.1.3", {\ - "packageLocation": "./.yarn/cache/babel-loader-npm-9.1.3-cbf4da21df-7086e67827.zip/node_modules/babel-loader/",\ - "packageDependencies": [\ - ["babel-loader", "npm:9.1.3"]\ - ],\ - "linkType": "SOFT"\ - }],\ - ["virtual:8f25fc90e0fb5fd89843707863857591fa8c52f9f33eadced4bf404b1871d91959f7bb86948ae0e1b53ee94d491ef8fde9c0b58b39c9490c0d0fa6c931945f97#npm:9.1.3", {\ - "packageLocation": "./.yarn/__virtual__/babel-loader-virtual-814c93af3e/0/cache/babel-loader-npm-9.1.3-cbf4da21df-7086e67827.zip/node_modules/babel-loader/",\ - "packageDependencies": [\ - ["@babel/core", "npm:7.26.10"],\ - ["@types/babel__core", null],\ - ["@types/webpack", null],\ - ["babel-loader", "virtual:8f25fc90e0fb5fd89843707863857591fa8c52f9f33eadced4bf404b1871d91959f7bb86948ae0e1b53ee94d491ef8fde9c0b58b39c9490c0d0fa6c931945f97#npm:9.1.3"],\ - ["find-cache-dir", "npm:4.0.0"],\ - ["schema-utils", "npm:4.2.0"],\ - ["webpack", "virtual:8f25fc90e0fb5fd89843707863857591fa8c52f9f33eadced4bf404b1871d91959f7bb86948ae0e1b53ee94d491ef8fde9c0b58b39c9490c0d0fa6c931945f97#npm:5.105.0"]\ - ],\ - "packagePeers": [\ - "@babel/core",\ - "@types/babel__core",\ - "@types/webpack",\ - "webpack"\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ ["babel-plugin-polyfill-corejs2", [\ ["npm:0.4.12", {\ "packageLocation": "./.yarn/cache/babel-plugin-polyfill-corejs2-npm-0.4.12-d572de89f3-38b8cd69f0.zip/node_modules/babel-plugin-polyfill-corejs2/",\ @@ -7949,16 +7672,6 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ - ["browserify-zlib", [\ - ["npm:0.2.0", {\ - "packageLocation": "./.yarn/cache/browserify-zlib-npm-0.2.0-eab4087284-852e72effd.zip/node_modules/browserify-zlib/",\ - "packageDependencies": [\ - ["browserify-zlib", "npm:0.2.0"],\ - ["pako", "npm:1.0.11"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ ["browserslist", [\ ["npm:4.22.1", {\ "packageLocation": "./.yarn/cache/browserslist-npm-4.22.1-cccae6d74e-4a515168e0.zip/node_modules/browserslist/",\ @@ -8841,15 +8554,6 @@ const RAW_RUNTIME_STATE = }]\ ]],\ ["color", [\ - ["npm:3.2.1", {\ - "packageLocation": "./.yarn/cache/color-npm-3.2.1-568cf1014f-bf70438e01.zip/node_modules/color/",\ - "packageDependencies": [\ - ["color", "npm:3.2.1"],\ - ["color-convert", "npm:1.9.3"],\ - ["color-string", "npm:1.6.0"]\ - ],\ - "linkType": "HARD"\ - }],\ ["npm:4.2.3", {\ "packageLocation": "./.yarn/cache/color-npm-4.2.3-4a23227581-b23f5e500a.zip/node_modules/color/",\ "packageDependencies": [\ @@ -8895,15 +8599,6 @@ const RAW_RUNTIME_STATE = }]\ ]],\ ["color-string", [\ - ["npm:1.6.0", {\ - "packageLocation": "./.yarn/cache/color-string-npm-1.6.0-94ed25c258-27c2365153.zip/node_modules/color-string/",\ - "packageDependencies": [\ - ["color-name", "npm:1.1.4"],\ - ["color-string", "npm:1.6.0"],\ - ["simple-swizzle", "npm:0.2.2"]\ - ],\ - "linkType": "HARD"\ - }],\ ["npm:1.9.1", {\ "packageLocation": "./.yarn/cache/color-string-npm-1.9.1-dc020e56be-72aa0b81ee.zip/node_modules/color-string/",\ "packageDependencies": [\ @@ -8939,24 +8634,6 @@ const RAW_RUNTIME_STATE = ["colors", "npm:1.0.3"]\ ],\ "linkType": "HARD"\ - }],\ - ["npm:1.4.0", {\ - "packageLocation": "./.yarn/cache/colors-npm-1.4.0-7e2cf12234-90b2d54651.zip/node_modules/colors/",\ - "packageDependencies": [\ - ["colors", "npm:1.4.0"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ - ["colorspace", [\ - ["npm:1.1.4", {\ - "packageLocation": "./.yarn/cache/colorspace-npm-1.1.4-f01655548a-bb3934ef3c.zip/node_modules/colorspace/",\ - "packageDependencies": [\ - ["color", "npm:3.2.1"],\ - ["colorspace", "npm:1.1.4"],\ - ["text-hex", "npm:1.0.0"]\ - ],\ - "linkType": "HARD"\ }]\ ]],\ ["commander", [\ @@ -9028,15 +8705,6 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ - ["common-path-prefix", [\ - ["npm:3.0.0", {\ - "packageLocation": "./.yarn/cache/common-path-prefix-npm-3.0.0-68b78785c1-09c180e8d8.zip/node_modules/common-path-prefix/",\ - "packageDependencies": [\ - ["common-path-prefix", "npm:3.0.0"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ ["commondir", [\ ["npm:1.0.1", {\ "packageLocation": "./.yarn/cache/commondir-npm-1.0.1-291b790340-4620bc4936.zip/node_modules/commondir/",\ @@ -9363,15 +9031,6 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ - ["core-js", [\ - ["npm:3.33.2", {\ - "packageLocation": "./.yarn/unplugged/core-js-npm-3.33.2-08a6fba407/node_modules/core-js/",\ - "packageDependencies": [\ - ["core-js", "npm:3.33.2"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ ["core-js-compat", [\ ["npm:3.41.0", {\ "packageLocation": "./.yarn/cache/core-js-compat-npm-3.41.0-3a60c76839-a59da111fc.zip/node_modules/core-js-compat/",\ @@ -9582,52 +9241,21 @@ const RAW_RUNTIME_STATE = ["@types/sinon", "npm:9.0.11"],\ ["@types/sinon-chai", "npm:3.2.5"],\ ["@yarnpkg/pnpify", "npm:4.0.0-rc.42"],\ - ["assert", "npm:2.0.0"],\ - ["browserify-zlib", "npm:0.2.0"],\ - ["bs58", "npm:4.0.1"],\ - ["buffer", "npm:6.0.3"],\ ["chai", "npm:4.3.10"],\ ["chai-as-promised", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:7.1.1"],\ ["chance", "npm:1.1.8"],\ - ["crypto-browserify", "npm:3.12.1"],\ ["dash", "workspace:packages/js-dash-sdk"],\ ["dirty-chai", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:2.0.1"],\ ["dotenv-safe", "npm:8.2.0"],\ ["eslint", "virtual:de32c10d523830f1843784ae863166d6ef2e074b6da9615f2b3296a1f90385ed3f59e274e3957326ba7cf3442d82470d9e1ec01e6720989a570c075c95d90dbc#npm:9.39.2"],\ - ["events", "npm:3.3.0"],\ - ["https-browserify", "npm:1.0.0"],\ - ["karma", "npm:6.4.3"],\ - ["karma-chai", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:0.1.0"],\ - ["karma-chrome-launcher", "npm:3.1.0"],\ - ["karma-firefox-launcher", "npm:2.1.2"],\ - ["karma-mocha", "npm:2.0.1"],\ - ["karma-mocha-reporter", "virtual:e2d057e7cc143d3cb9bec864f4a2d862441b5a09f81f8e6c46e7a098cbc89e4d07017cc6e2e2142d5704bb55da853cbec2d025ebc0b30e8696c31380c00f2c7d#npm:2.2.5"],\ - ["karma-webpack", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:5.0.0"],\ ["mocha", "npm:11.1.0"],\ - ["net", "npm:1.0.2"],\ - ["node-inspect-extracted", "npm:1.0.8"],\ ["nodemon", "npm:2.0.20"],\ - ["os-browserify", "npm:0.3.0"],\ - ["path-browserify", "npm:1.0.1"],\ - ["process", "npm:0.11.10"],\ ["rimraf", "npm:3.0.2"],\ ["sinon", "npm:18.0.1"],\ ["sinon-chai", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:3.7.0"],\ - ["stream-browserify", "npm:3.0.0"],\ - ["stream-http", "npm:3.2.0"],\ - ["string_decoder", "npm:1.3.0"],\ - ["terser-webpack-plugin", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:5.3.11"],\ - ["tls", "npm:0.0.1"],\ - ["ts-loader", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:9.5.0"],\ - ["ts-mock-imports", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:1.3.8"],\ ["ts-node", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:10.9.2"],\ ["tsd", "npm:0.28.1"],\ - ["typescript", "patch:typescript@npm%3A5.9.3#optional!builtin::version=5.9.3&hash=5786d5"],\ - ["url", "npm:0.11.3"],\ - ["util", "npm:0.12.4"],\ - ["webpack", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:5.105.0"],\ - ["webpack-cli", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:4.9.1"],\ - ["winston", "npm:3.3.3"]\ + ["typescript", "patch:typescript@npm%3A5.9.3#optional!builtin::version=5.9.3&hash=5786d5"]\ ],\ "linkType": "SOFT"\ }]\ @@ -10507,15 +10135,6 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ - ["enabled", [\ - ["npm:2.0.0", {\ - "packageLocation": "./.yarn/cache/enabled-npm-2.0.0-bf5d96c9d8-9d256d89f4.zip/node_modules/enabled/",\ - "packageDependencies": [\ - ["enabled", "npm:2.0.0"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ ["encodeurl", [\ ["npm:1.0.2", {\ "packageLocation": "./.yarn/cache/encodeurl-npm-1.0.2-f8c8454c41-e50e3d508c.zip/node_modules/encodeurl/",\ @@ -11975,15 +11594,6 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ - ["fecha", [\ - ["npm:4.2.1", {\ - "packageLocation": "./.yarn/cache/fecha-npm-4.2.1-40d84f7733-6cf959d41a.zip/node_modules/fecha/",\ - "packageDependencies": [\ - ["fecha", "npm:4.2.1"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ ["figures", [\ ["npm:3.2.0", {\ "packageLocation": "./.yarn/cache/figures-npm-3.2.0-85d357e955-a3bf94e001.zip/node_modules/figures/",\ @@ -12058,15 +11668,6 @@ const RAW_RUNTIME_STATE = ["pkg-dir", "npm:4.2.0"]\ ],\ "linkType": "HARD"\ - }],\ - ["npm:4.0.0", {\ - "packageLocation": "./.yarn/cache/find-cache-dir-npm-4.0.0-ad2504e37e-52a456a80d.zip/node_modules/find-cache-dir/",\ - "packageDependencies": [\ - ["common-path-prefix", "npm:3.0.0"],\ - ["find-cache-dir", "npm:4.0.0"],\ - ["pkg-dir", "npm:7.0.0"]\ - ],\ - "linkType": "HARD"\ }]\ ]],\ ["find-up", [\ @@ -12095,15 +11696,6 @@ const RAW_RUNTIME_STATE = ["path-exists", "npm:4.0.0"]\ ],\ "linkType": "HARD"\ - }],\ - ["npm:6.3.0", {\ - "packageLocation": "./.yarn/cache/find-up-npm-6.3.0-e5056fc655-4f3bdc30d4.zip/node_modules/find-up/",\ - "packageDependencies": [\ - ["find-up", "npm:6.3.0"],\ - ["locate-path", "npm:7.2.0"],\ - ["path-exists", "npm:5.0.0"]\ - ],\ - "linkType": "HARD"\ }]\ ]],\ ["find-yarn-workspace-root", [\ @@ -12173,15 +11765,6 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ - ["fn.name", [\ - ["npm:1.1.0", {\ - "packageLocation": "./.yarn/cache/fn.name-npm-1.1.0-b472333184-000198af19.zip/node_modules/fn.name/",\ - "packageDependencies": [\ - ["fn.name", "npm:1.1.0"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ ["follow-redirects", [\ ["npm:1.15.6", {\ "packageLocation": "./.yarn/cache/follow-redirects-npm-1.15.6-50635fe51d-70c7612c4c.zip/node_modules/follow-redirects/",\ @@ -14861,14 +14444,14 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "SOFT"\ }],\ - ["virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:0.1.0", {\ - "packageLocation": "./.yarn/__virtual__/karma-chai-virtual-e2e0d5ff8a/0/cache/karma-chai-npm-0.1.0-d1d807f507-7fae0b4ace.zip/node_modules/karma-chai/",\ + ["virtual:98d1afeac78a19485e4cb7428abff692e58b6fc468d8040035b560ed49383fc95857be6b5014af27e53063e6f08b654690c2b945f3443c22dd60c6b083684b3c#npm:0.1.0", {\ + "packageLocation": "./.yarn/__virtual__/karma-chai-virtual-a8d1d9b405/0/cache/karma-chai-npm-0.1.0-d1d807f507-7fae0b4ace.zip/node_modules/karma-chai/",\ "packageDependencies": [\ ["@types/chai", "npm:4.3.20"],\ ["@types/karma", null],\ ["chai", "npm:4.3.10"],\ ["karma", "npm:6.4.3"],\ - ["karma-chai", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:0.1.0"]\ + ["karma-chai", "virtual:98d1afeac78a19485e4cb7428abff692e58b6fc468d8040035b560ed49383fc95857be6b5014af27e53063e6f08b654690c2b945f3443c22dd60c6b083684b3c#npm:0.1.0"]\ ],\ "packagePeers": [\ "@types/chai",\ @@ -14953,16 +14536,6 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ - ["karma-sourcemap-loader", [\ - ["npm:0.3.8", {\ - "packageLocation": "./.yarn/cache/karma-sourcemap-loader-npm-0.3.8-a7560c795e-f641355ec1.zip/node_modules/karma-sourcemap-loader/",\ - "packageDependencies": [\ - ["graceful-fs", "npm:4.2.10"],\ - ["karma-sourcemap-loader", "npm:0.3.8"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ ["karma-webpack", [\ ["npm:5.0.0", {\ "packageLocation": "./.yarn/cache/karma-webpack-npm-5.0.0-d7c66b2a8a-9bd565adbc.zip/node_modules/karma-webpack/",\ @@ -14971,38 +14544,6 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "SOFT"\ }],\ - ["virtual:01938c2be4835443e5a304e2b117c575220e96e8b7cedeb0f48d79264590b4c4babc6d1fea6367f522b1ca0149d795b42f2ab89c34a6ffe3c20f0a8cbb8b4453#npm:5.0.0", {\ - "packageLocation": "./.yarn/__virtual__/karma-webpack-virtual-df47bbf310/0/cache/karma-webpack-npm-5.0.0-d7c66b2a8a-9bd565adbc.zip/node_modules/karma-webpack/",\ - "packageDependencies": [\ - ["@types/webpack", null],\ - ["glob", "npm:7.2.3"],\ - ["karma-webpack", "virtual:01938c2be4835443e5a304e2b117c575220e96e8b7cedeb0f48d79264590b4c4babc6d1fea6367f522b1ca0149d795b42f2ab89c34a6ffe3c20f0a8cbb8b4453#npm:5.0.0"],\ - ["minimatch", "npm:3.1.2"],\ - ["webpack", "virtual:01938c2be4835443e5a304e2b117c575220e96e8b7cedeb0f48d79264590b4c4babc6d1fea6367f522b1ca0149d795b42f2ab89c34a6ffe3c20f0a8cbb8b4453#npm:5.105.0"],\ - ["webpack-merge", "npm:4.2.2"]\ - ],\ - "packagePeers": [\ - "@types/webpack",\ - "webpack"\ - ],\ - "linkType": "HARD"\ - }],\ - ["virtual:45f214395bc38640da4dc5e940482d5df0572c5384e0262802601d1973e71077ec8bbd76b77eafa4c0550b706b664abd84d63fd67a5897139f0b2675530fc84f#npm:5.0.0", {\ - "packageLocation": "./.yarn/__virtual__/karma-webpack-virtual-7645831669/0/cache/karma-webpack-npm-5.0.0-d7c66b2a8a-9bd565adbc.zip/node_modules/karma-webpack/",\ - "packageDependencies": [\ - ["@types/webpack", null],\ - ["glob", "npm:7.2.3"],\ - ["karma-webpack", "virtual:45f214395bc38640da4dc5e940482d5df0572c5384e0262802601d1973e71077ec8bbd76b77eafa4c0550b706b664abd84d63fd67a5897139f0b2675530fc84f#npm:5.0.0"],\ - ["minimatch", "npm:3.1.2"],\ - ["webpack", "virtual:45f214395bc38640da4dc5e940482d5df0572c5384e0262802601d1973e71077ec8bbd76b77eafa4c0550b706b664abd84d63fd67a5897139f0b2675530fc84f#npm:5.105.0"],\ - ["webpack-merge", "npm:4.2.2"]\ - ],\ - "packagePeers": [\ - "@types/webpack",\ - "webpack"\ - ],\ - "linkType": "HARD"\ - }],\ ["virtual:897449be52adaf897095babe74bfcc926f5d083ac9aac6fbc5e260f1f71b7e3ada3f268ac9457d3009b9c6fca51fe685ec21fbed21ec5087df84ab489b719456#npm:5.0.0", {\ "packageLocation": "./.yarn/__virtual__/karma-webpack-virtual-91170ce8e7/0/cache/karma-webpack-npm-5.0.0-d7c66b2a8a-9bd565adbc.zip/node_modules/karma-webpack/",\ "packageDependencies": [\ @@ -15019,22 +14560,6 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ - ["virtual:8f25fc90e0fb5fd89843707863857591fa8c52f9f33eadced4bf404b1871d91959f7bb86948ae0e1b53ee94d491ef8fde9c0b58b39c9490c0d0fa6c931945f97#npm:5.0.0", {\ - "packageLocation": "./.yarn/__virtual__/karma-webpack-virtual-bbb0fdb943/0/cache/karma-webpack-npm-5.0.0-d7c66b2a8a-9bd565adbc.zip/node_modules/karma-webpack/",\ - "packageDependencies": [\ - ["@types/webpack", null],\ - ["glob", "npm:7.2.3"],\ - ["karma-webpack", "virtual:8f25fc90e0fb5fd89843707863857591fa8c52f9f33eadced4bf404b1871d91959f7bb86948ae0e1b53ee94d491ef8fde9c0b58b39c9490c0d0fa6c931945f97#npm:5.0.0"],\ - ["minimatch", "npm:3.1.2"],\ - ["webpack", "virtual:8f25fc90e0fb5fd89843707863857591fa8c52f9f33eadced4bf404b1871d91959f7bb86948ae0e1b53ee94d491ef8fde9c0b58b39c9490c0d0fa6c931945f97#npm:5.105.0"],\ - ["webpack-merge", "npm:4.2.2"]\ - ],\ - "packagePeers": [\ - "@types/webpack",\ - "webpack"\ - ],\ - "linkType": "HARD"\ - }],\ ["virtual:98d1afeac78a19485e4cb7428abff692e58b6fc468d8040035b560ed49383fc95857be6b5014af27e53063e6f08b654690c2b945f3443c22dd60c6b083684b3c#npm:5.0.0", {\ "packageLocation": "./.yarn/__virtual__/karma-webpack-virtual-3f3d78beea/0/cache/karma-webpack-npm-5.0.0-d7c66b2a8a-9bd565adbc.zip/node_modules/karma-webpack/",\ "packageDependencies": [\ @@ -15051,22 +14576,6 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ - ["virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:5.0.0", {\ - "packageLocation": "./.yarn/__virtual__/karma-webpack-virtual-94955efe11/0/cache/karma-webpack-npm-5.0.0-d7c66b2a8a-9bd565adbc.zip/node_modules/karma-webpack/",\ - "packageDependencies": [\ - ["@types/webpack", null],\ - ["glob", "npm:7.2.3"],\ - ["karma-webpack", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:5.0.0"],\ - ["minimatch", "npm:3.1.2"],\ - ["webpack", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:5.105.0"],\ - ["webpack-merge", "npm:4.2.2"]\ - ],\ - "packagePeers": [\ - "@types/webpack",\ - "webpack"\ - ],\ - "linkType": "HARD"\ - }],\ ["virtual:da12f6bb23b671689b7f4f5cfff69cabf980ba04aff1ffd96860c787f7d5d08d32b0db765d9f16463de0d1af2c01fa6987b861cf5df2362e38e0ef415f29b51c#npm:5.0.0", {\ "packageLocation": "./.yarn/__virtual__/karma-webpack-virtual-c873655e3d/0/cache/karma-webpack-npm-5.0.0-d7c66b2a8a-9bd565adbc.zip/node_modules/karma-webpack/",\ "packageDependencies": [\ @@ -15119,15 +14628,6 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ - ["kuler", [\ - ["npm:2.0.0", {\ - "packageLocation": "./.yarn/cache/kuler-npm-2.0.0-19e74c9695-9e10b5a165.zip/node_modules/kuler/",\ - "packageDependencies": [\ - ["kuler", "npm:2.0.0"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ ["language-subtag-registry", [\ ["npm:0.3.23", {\ "packageLocation": "./.yarn/cache/language-subtag-registry-npm-0.3.23-06b360f90f-fe13ed74ab.zip/node_modules/language-subtag-registry/",\ @@ -15351,14 +14851,6 @@ const RAW_RUNTIME_STATE = ["p-locate", "npm:5.0.0"]\ ],\ "linkType": "HARD"\ - }],\ - ["npm:7.2.0", {\ - "packageLocation": "./.yarn/cache/locate-path-npm-7.2.0-0e1169e19b-1c6d269d4e.zip/node_modules/locate-path/",\ - "packageDependencies": [\ - ["locate-path", "npm:7.2.0"],\ - ["p-locate", "npm:6.0.0"]\ - ],\ - "linkType": "HARD"\ }]\ ]],\ ["lodash", [\ @@ -15527,20 +15019,6 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ - ["logform", [\ - ["npm:2.3.0", {\ - "packageLocation": "./.yarn/cache/logform-npm-2.3.0-13155f7f21-1fbe98725e.zip/node_modules/logform/",\ - "packageDependencies": [\ - ["colors", "npm:1.4.0"],\ - ["fecha", "npm:4.2.1"],\ - ["logform", "npm:2.3.0"],\ - ["ms", "npm:2.1.3"],\ - ["safe-stable-stringify", "npm:1.1.1"],\ - ["triple-beam", "npm:1.3.0"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ ["long", [\ ["npm:4.0.0", {\ "packageLocation": "./.yarn/cache/long-npm-4.0.0-ecd96a31ed-8296e2ba7b.zip/node_modules/long/",\ @@ -16589,15 +16067,6 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ - ["net", [\ - ["npm:1.0.2", {\ - "packageLocation": "./.yarn/cache/net-npm-1.0.2-1d5514df5b-d97e215d92.zip/node_modules/net/",\ - "packageDependencies": [\ - ["net", "npm:1.0.2"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ ["nise", [\ ["npm:6.1.3", {\ "packageLocation": "./.yarn/cache/nise-npm-6.1.3-148369f991-a07be16c8b.zip/node_modules/nise/",\ @@ -16640,12 +16109,12 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "SOFT"\ }],\ - ["virtual:8f25fc90e0fb5fd89843707863857591fa8c52f9f33eadced4bf404b1871d91959f7bb86948ae0e1b53ee94d491ef8fde9c0b58b39c9490c0d0fa6c931945f97#npm:2.6.7", {\ - "packageLocation": "./.yarn/__virtual__/node-fetch-virtual-a3f0ba2944/0/cache/node-fetch-npm-2.6.7-777aa2a6df-4bc9245383.zip/node_modules/node-fetch/",\ + ["virtual:25a5f5382d53dbf298bf7a1191760bc2e0a523a619eeb0e667b99a8649e8ad183f9e2e0b45f6fb831b92f4078b61622aa567cf79565f6aa5af9597e3c84864f6#npm:2.6.7", {\ + "packageLocation": "./.yarn/__virtual__/node-fetch-virtual-d3846f8e12/0/cache/node-fetch-npm-2.6.7-777aa2a6df-4bc9245383.zip/node_modules/node-fetch/",\ "packageDependencies": [\ ["@types/encoding", null],\ ["encoding", null],\ - ["node-fetch", "virtual:8f25fc90e0fb5fd89843707863857591fa8c52f9f33eadced4bf404b1871d91959f7bb86948ae0e1b53ee94d491ef8fde9c0b58b39c9490c0d0fa6c931945f97#npm:2.6.7"],\ + ["node-fetch", "virtual:25a5f5382d53dbf298bf7a1191760bc2e0a523a619eeb0e667b99a8649e8ad183f9e2e0b45f6fb831b92f4078b61622aa567cf79565f6aa5af9597e3c84864f6#npm:2.6.7"],\ ["whatwg-url", "npm:5.0.0"]\ ],\ "packagePeers": [\ @@ -16701,15 +16170,6 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ - ["node-inspect-extracted", [\ - ["npm:1.0.8", {\ - "packageLocation": "./.yarn/cache/node-inspect-extracted-npm-1.0.8-53baa7fd4f-4647a29afd.zip/node_modules/node-inspect-extracted/",\ - "packageDependencies": [\ - ["node-inspect-extracted", "npm:1.0.8"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ ["node-preload", [\ ["npm:0.2.1", {\ "packageLocation": "./.yarn/cache/node-preload-npm-0.2.1-5b6aef1c8e-de36ed365b.zip/node_modules/node-preload/",\ @@ -17266,16 +16726,6 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ - ["one-time", [\ - ["npm:1.0.0", {\ - "packageLocation": "./.yarn/cache/one-time-npm-1.0.0-aeaad5e524-64d0160480.zip/node_modules/one-time/",\ - "packageDependencies": [\ - ["fn.name", "npm:1.1.0"],\ - ["one-time", "npm:1.0.0"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ ["onetime", [\ ["npm:5.1.2", {\ "packageLocation": "./.yarn/cache/onetime-npm-5.1.2-3ed148fa42-e9fd0695a0.zip/node_modules/onetime/",\ @@ -17369,15 +16819,6 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ - ["os-browserify", [\ - ["npm:0.3.0", {\ - "packageLocation": "./.yarn/cache/os-browserify-npm-0.3.0-cbc91c79a5-16e37ba3c0.zip/node_modules/os-browserify/",\ - "packageDependencies": [\ - ["os-browserify", "npm:0.3.0"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ ["own-keys", [\ ["npm:1.0.1", {\ "packageLocation": "./.yarn/cache/own-keys-npm-1.0.1-1253f9b344-ab4bb3b863.zip/node_modules/own-keys/",\ @@ -17439,14 +16880,6 @@ const RAW_RUNTIME_STATE = ["yocto-queue", "npm:0.1.0"]\ ],\ "linkType": "HARD"\ - }],\ - ["npm:4.0.0", {\ - "packageLocation": "./.yarn/cache/p-limit-npm-4.0.0-5dccf29b67-01d9d70695.zip/node_modules/p-limit/",\ - "packageDependencies": [\ - ["p-limit", "npm:4.0.0"],\ - ["yocto-queue", "npm:1.0.0"]\ - ],\ - "linkType": "HARD"\ }]\ ]],\ ["p-locate", [\ @@ -17473,14 +16906,6 @@ const RAW_RUNTIME_STATE = ["p-locate", "npm:5.0.0"]\ ],\ "linkType": "HARD"\ - }],\ - ["npm:6.0.0", {\ - "packageLocation": "./.yarn/cache/p-locate-npm-6.0.0-b6cfb720dc-2bfe5234ef.zip/node_modules/p-locate/",\ - "packageDependencies": [\ - ["p-limit", "npm:4.0.0"],\ - ["p-locate", "npm:6.0.0"]\ - ],\ - "linkType": "HARD"\ }]\ ]],\ ["p-map", [\ @@ -17633,15 +17058,6 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ - ["pako", [\ - ["npm:1.0.11", {\ - "packageLocation": "./.yarn/cache/pako-npm-1.0.11-b8f1b69d3e-1ad07210e8.zip/node_modules/pako/",\ - "packageDependencies": [\ - ["pako", "npm:1.0.11"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ ["param-case", [\ ["npm:3.0.4", {\ "packageLocation": "./.yarn/cache/param-case-npm-3.0.4-cfb242ad97-b34227fd0f.zip/node_modules/param-case/",\ @@ -17813,13 +17229,6 @@ const RAW_RUNTIME_STATE = ["path-exists", "npm:4.0.0"]\ ],\ "linkType": "HARD"\ - }],\ - ["npm:5.0.0", {\ - "packageLocation": "./.yarn/cache/path-exists-npm-5.0.0-0bf403c56c-8ca842868c.zip/node_modules/path-exists/",\ - "packageDependencies": [\ - ["path-exists", "npm:5.0.0"]\ - ],\ - "linkType": "HARD"\ }]\ ]],\ ["path-is-absolute", [\ @@ -18061,14 +17470,6 @@ const RAW_RUNTIME_STATE = ["pkg-dir", "npm:4.2.0"]\ ],\ "linkType": "HARD"\ - }],\ - ["npm:7.0.0", {\ - "packageLocation": "./.yarn/cache/pkg-dir-npm-7.0.0-02ff099b31-94298b20a4.zip/node_modules/pkg-dir/",\ - "packageDependencies": [\ - ["find-up", "npm:6.3.0"],\ - ["pkg-dir", "npm:7.0.0"]\ - ],\ - "linkType": "HARD"\ }]\ ]],\ ["plur", [\ @@ -19238,13 +18639,6 @@ const RAW_RUNTIME_STATE = }]\ ]],\ ["safe-stable-stringify", [\ - ["npm:1.1.1", {\ - "packageLocation": "./.yarn/cache/safe-stable-stringify-npm-1.1.1-1c282e1c55-bddfc2334d.zip/node_modules/safe-stable-stringify/",\ - "packageDependencies": [\ - ["safe-stable-stringify", "npm:1.1.1"]\ - ],\ - "linkType": "HARD"\ - }],\ ["npm:2.4.3", {\ "packageLocation": "./.yarn/cache/safe-stable-stringify-npm-2.4.3-d895741b40-a6c192bbef.zip/node_modules/safe-stable-stringify/",\ "packageDependencies": [\ @@ -19289,17 +18683,6 @@ const RAW_RUNTIME_STATE = }]\ ]],\ ["schema-utils", [\ - ["npm:4.2.0", {\ - "packageLocation": "./.yarn/cache/schema-utils-npm-4.2.0-e822c5b02e-808784735e.zip/node_modules/schema-utils/",\ - "packageDependencies": [\ - ["@types/json-schema", "npm:7.0.15"],\ - ["ajv", "npm:8.18.0"],\ - ["ajv-formats", "virtual:4954c4a72ee1ac7afec22da3b17d9a937f807567fbfd843f7fb4d48a0c27456b3fd63f5453a6ffa910bcac753ec013f5554ffe0d1c324703fa4d0658622f21bd#npm:2.1.1"],\ - ["ajv-keywords", "virtual:4954c4a72ee1ac7afec22da3b17d9a937f807567fbfd843f7fb4d48a0c27456b3fd63f5453a6ffa910bcac753ec013f5554ffe0d1c324703fa4d0658622f21bd#npm:5.1.0"],\ - ["schema-utils", "npm:4.2.0"]\ - ],\ - "linkType": "HARD"\ - }],\ ["npm:4.3.0", {\ "packageLocation": "./.yarn/cache/schema-utils-npm-4.3.0-6f0a75e2e2-86c5a7c72a.zip/node_modules/schema-utils/",\ "packageDependencies": [\ @@ -20177,15 +19560,6 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ - ["stack-trace", [\ - ["npm:0.0.10", {\ - "packageLocation": "./.yarn/cache/stack-trace-npm-0.0.10-9460b173e1-7bd633f0e9.zip/node_modules/stack-trace/",\ - "packageDependencies": [\ - ["stack-trace", "npm:0.0.10"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ ["statuses", [\ ["npm:1.5.0", {\ "packageLocation": "./.yarn/cache/statuses-npm-1.5.0-f88f91b2e9-c469b9519d.zip/node_modules/statuses/",\ @@ -20835,8 +20209,8 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ - ["virtual:62941717b655ac142dd4cd1370e0c48afd49b5b0e864a88fae8030cff430b00a6538f10d6ec6916a973bebc3c0274b8dad2e2dfd6263382ab5c42f6550c4185a#npm:5.3.16", {\ - "packageLocation": "./.yarn/__virtual__/terser-webpack-plugin-virtual-50314d7465/0/cache/terser-webpack-plugin-npm-5.3.16-7d59a4385c-09dfbff602.zip/node_modules/terser-webpack-plugin/",\ + ["virtual:da12f6bb23b671689b7f4f5cfff69cabf980ba04aff1ffd96860c787f7d5d08d32b0db765d9f16463de0d1af2c01fa6987b861cf5df2362e38e0ef415f29b51c#npm:5.3.11", {\ + "packageLocation": "./.yarn/__virtual__/terser-webpack-plugin-virtual-94d9a56ac4/0/cache/terser-webpack-plugin-npm-5.3.11-1a5bba0883-a8f7c92c75.zip/node_modules/terser-webpack-plugin/",\ "packageDependencies": [\ ["@jridgewell/trace-mapping", "npm:0.3.25"],\ ["@swc/core", null],\ @@ -20849,9 +20223,9 @@ const RAW_RUNTIME_STATE = ["schema-utils", "npm:4.3.0"],\ ["serialize-javascript", "npm:7.0.4"],\ ["terser", "npm:5.39.0"],\ - ["terser-webpack-plugin", "virtual:62941717b655ac142dd4cd1370e0c48afd49b5b0e864a88fae8030cff430b00a6538f10d6ec6916a973bebc3c0274b8dad2e2dfd6263382ab5c42f6550c4185a#npm:5.3.16"],\ + ["terser-webpack-plugin", "virtual:da12f6bb23b671689b7f4f5cfff69cabf980ba04aff1ffd96860c787f7d5d08d32b0db765d9f16463de0d1af2c01fa6987b861cf5df2362e38e0ef415f29b51c#npm:5.3.11"],\ ["uglify-js", null],\ - ["webpack", "virtual:8f25fc90e0fb5fd89843707863857591fa8c52f9f33eadced4bf404b1871d91959f7bb86948ae0e1b53ee94d491ef8fde9c0b58b39c9490c0d0fa6c931945f97#npm:5.105.0"]\ + ["webpack", "virtual:da12f6bb23b671689b7f4f5cfff69cabf980ba04aff1ffd96860c787f7d5d08d32b0db765d9f16463de0d1af2c01fa6987b861cf5df2362e38e0ef415f29b51c#npm:5.105.0"]\ ],\ "packagePeers": [\ "@swc/core",\ @@ -20865,8 +20239,8 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ - ["virtual:ac08d1802148a23c9b3f7a8749cbaaded258daba072aa6e761629ffa5f56f8f3e419894607861c1572ce1b35ea47b30ac3d38935ced0e4c1e2540eff8deb5e8f#npm:5.3.16", {\ - "packageLocation": "./.yarn/__virtual__/terser-webpack-plugin-virtual-dbe00d6a37/0/cache/terser-webpack-plugin-npm-5.3.16-7d59a4385c-09dfbff602.zip/node_modules/terser-webpack-plugin/",\ + ["virtual:f4ab5f842ae92831564bb9c51df628512e7cbc4b95ade6180c8b4aa79140126a35e1433b1c31a5ad3badd9104d877649be3ca11137a24ac8c31f75ce1bd1b44b#npm:5.3.16", {\ + "packageLocation": "./.yarn/__virtual__/terser-webpack-plugin-virtual-37d6fb1d64/0/cache/terser-webpack-plugin-npm-5.3.16-7d59a4385c-09dfbff602.zip/node_modules/terser-webpack-plugin/",\ "packageDependencies": [\ ["@jridgewell/trace-mapping", "npm:0.3.25"],\ ["@swc/core", null],\ @@ -20879,9 +20253,9 @@ const RAW_RUNTIME_STATE = ["schema-utils", "npm:4.3.0"],\ ["serialize-javascript", "npm:7.0.4"],\ ["terser", "npm:5.39.0"],\ - ["terser-webpack-plugin", "virtual:ac08d1802148a23c9b3f7a8749cbaaded258daba072aa6e761629ffa5f56f8f3e419894607861c1572ce1b35ea47b30ac3d38935ced0e4c1e2540eff8deb5e8f#npm:5.3.16"],\ + ["terser-webpack-plugin", "virtual:f4ab5f842ae92831564bb9c51df628512e7cbc4b95ade6180c8b4aa79140126a35e1433b1c31a5ad3badd9104d877649be3ca11137a24ac8c31f75ce1bd1b44b#npm:5.3.16"],\ ["uglify-js", null],\ - ["webpack", "virtual:45f214395bc38640da4dc5e940482d5df0572c5384e0262802601d1973e71077ec8bbd76b77eafa4c0550b706b664abd84d63fd67a5897139f0b2675530fc84f#npm:5.105.0"]\ + ["webpack", "virtual:da12f6bb23b671689b7f4f5cfff69cabf980ba04aff1ffd96860c787f7d5d08d32b0db765d9f16463de0d1af2c01fa6987b861cf5df2362e38e0ef415f29b51c#npm:5.105.0"]\ ],\ "packagePeers": [\ "@swc/core",\ @@ -20894,201 +20268,42 @@ const RAW_RUNTIME_STATE = "webpack"\ ],\ "linkType": "HARD"\ - }],\ - ["virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:5.3.11", {\ - "packageLocation": "./.yarn/__virtual__/terser-webpack-plugin-virtual-55a46e8527/0/cache/terser-webpack-plugin-npm-5.3.11-1a5bba0883-a8f7c92c75.zip/node_modules/terser-webpack-plugin/",\ + }]\ + ]],\ + ["test-exclude", [\ + ["npm:6.0.0", {\ + "packageLocation": "./.yarn/cache/test-exclude-npm-6.0.0-3fb03d69df-8fccb2cb6c.zip/node_modules/test-exclude/",\ "packageDependencies": [\ - ["@jridgewell/trace-mapping", "npm:0.3.25"],\ - ["@swc/core", null],\ - ["@types/esbuild", null],\ - ["@types/swc__core", null],\ - ["@types/uglify-js", null],\ - ["@types/webpack", null],\ - ["esbuild", null],\ - ["jest-worker", "npm:27.5.1"],\ - ["schema-utils", "npm:4.3.0"],\ - ["serialize-javascript", "npm:7.0.4"],\ - ["terser", "npm:5.39.0"],\ - ["terser-webpack-plugin", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:5.3.11"],\ - ["uglify-js", null],\ - ["webpack", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:5.105.0"]\ - ],\ - "packagePeers": [\ - "@swc/core",\ - "@types/esbuild",\ - "@types/swc__core",\ - "@types/uglify-js",\ - "@types/webpack",\ - "esbuild",\ - "uglify-js",\ - "webpack"\ + ["@istanbuljs/schema", "npm:0.1.3"],\ + ["glob", "npm:7.2.3"],\ + ["minimatch", "npm:3.1.2"],\ + ["test-exclude", "npm:6.0.0"]\ ],\ "linkType": "HARD"\ - }],\ - ["virtual:be62dbe6a90b52c749baac6deb5de07ddeff4f1a8ddad2373494caee7afd79548ac93750b7f72d4d78e33d400acfe238653150a3f2538c2ac37dcb93c4b6f001#npm:5.3.16", {\ - "packageLocation": "./.yarn/__virtual__/terser-webpack-plugin-virtual-b21c422376/0/cache/terser-webpack-plugin-npm-5.3.16-7d59a4385c-09dfbff602.zip/node_modules/terser-webpack-plugin/",\ + }]\ + ]],\ + ["text-decoder", [\ + ["npm:1.2.3", {\ + "packageLocation": "./.yarn/cache/text-decoder-npm-1.2.3-cc7432569a-bcdec33c0f.zip/node_modules/text-decoder/",\ "packageDependencies": [\ - ["@jridgewell/trace-mapping", "npm:0.3.25"],\ - ["@swc/core", null],\ - ["@types/esbuild", null],\ - ["@types/swc__core", null],\ - ["@types/uglify-js", null],\ - ["@types/webpack", null],\ - ["esbuild", null],\ - ["jest-worker", "npm:27.5.1"],\ - ["schema-utils", "npm:4.3.0"],\ - ["serialize-javascript", "npm:7.0.4"],\ - ["terser", "npm:5.39.0"],\ - ["terser-webpack-plugin", "virtual:be62dbe6a90b52c749baac6deb5de07ddeff4f1a8ddad2373494caee7afd79548ac93750b7f72d4d78e33d400acfe238653150a3f2538c2ac37dcb93c4b6f001#npm:5.3.16"],\ - ["uglify-js", null],\ - ["webpack", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:5.105.0"]\ + ["b4a", "npm:1.6.7"],\ + ["text-decoder", "npm:1.2.3"]\ ],\ - "packagePeers": [\ - "@swc/core",\ - "@types/esbuild",\ - "@types/swc__core",\ - "@types/uglify-js",\ - "@types/webpack",\ - "esbuild",\ - "uglify-js",\ - "webpack"\ + "linkType": "HARD"\ + }]\ + ]],\ + ["text-extensions", [\ + ["npm:1.9.0", {\ + "packageLocation": "./.yarn/cache/text-extensions-npm-1.9.0-87655d768f-56a9962c1b.zip/node_modules/text-extensions/",\ + "packageDependencies": [\ + ["text-extensions", "npm:1.9.0"]\ ],\ "linkType": "HARD"\ - }],\ - ["virtual:be6a302f4603f759eab24f466ff96c2ebfdecb1ae05baf7c5d5166535833a454d4fc20106f065d537e3f48f37a7c8fe3c565764f1b782ea734081dc93d0dfac9#npm:5.3.16", {\ - "packageLocation": "./.yarn/__virtual__/terser-webpack-plugin-virtual-221d2b7463/0/cache/terser-webpack-plugin-npm-5.3.16-7d59a4385c-09dfbff602.zip/node_modules/terser-webpack-plugin/",\ - "packageDependencies": [\ - ["@jridgewell/trace-mapping", "npm:0.3.25"],\ - ["@swc/core", null],\ - ["@types/esbuild", null],\ - ["@types/swc__core", null],\ - ["@types/uglify-js", null],\ - ["@types/webpack", null],\ - ["esbuild", null],\ - ["jest-worker", "npm:27.5.1"],\ - ["schema-utils", "npm:4.3.0"],\ - ["serialize-javascript", "npm:7.0.4"],\ - ["terser", "npm:5.39.0"],\ - ["terser-webpack-plugin", "virtual:be6a302f4603f759eab24f466ff96c2ebfdecb1ae05baf7c5d5166535833a454d4fc20106f065d537e3f48f37a7c8fe3c565764f1b782ea734081dc93d0dfac9#npm:5.3.16"],\ - ["uglify-js", null],\ - ["webpack", "virtual:01938c2be4835443e5a304e2b117c575220e96e8b7cedeb0f48d79264590b4c4babc6d1fea6367f522b1ca0149d795b42f2ab89c34a6ffe3c20f0a8cbb8b4453#npm:5.105.0"]\ - ],\ - "packagePeers": [\ - "@swc/core",\ - "@types/esbuild",\ - "@types/swc__core",\ - "@types/uglify-js",\ - "@types/webpack",\ - "esbuild",\ - "uglify-js",\ - "webpack"\ - ],\ - "linkType": "HARD"\ - }],\ - ["virtual:da12f6bb23b671689b7f4f5cfff69cabf980ba04aff1ffd96860c787f7d5d08d32b0db765d9f16463de0d1af2c01fa6987b861cf5df2362e38e0ef415f29b51c#npm:5.3.11", {\ - "packageLocation": "./.yarn/__virtual__/terser-webpack-plugin-virtual-94d9a56ac4/0/cache/terser-webpack-plugin-npm-5.3.11-1a5bba0883-a8f7c92c75.zip/node_modules/terser-webpack-plugin/",\ - "packageDependencies": [\ - ["@jridgewell/trace-mapping", "npm:0.3.25"],\ - ["@swc/core", null],\ - ["@types/esbuild", null],\ - ["@types/swc__core", null],\ - ["@types/uglify-js", null],\ - ["@types/webpack", null],\ - ["esbuild", null],\ - ["jest-worker", "npm:27.5.1"],\ - ["schema-utils", "npm:4.3.0"],\ - ["serialize-javascript", "npm:7.0.4"],\ - ["terser", "npm:5.39.0"],\ - ["terser-webpack-plugin", "virtual:da12f6bb23b671689b7f4f5cfff69cabf980ba04aff1ffd96860c787f7d5d08d32b0db765d9f16463de0d1af2c01fa6987b861cf5df2362e38e0ef415f29b51c#npm:5.3.11"],\ - ["uglify-js", null],\ - ["webpack", "virtual:da12f6bb23b671689b7f4f5cfff69cabf980ba04aff1ffd96860c787f7d5d08d32b0db765d9f16463de0d1af2c01fa6987b861cf5df2362e38e0ef415f29b51c#npm:5.105.0"]\ - ],\ - "packagePeers": [\ - "@swc/core",\ - "@types/esbuild",\ - "@types/swc__core",\ - "@types/uglify-js",\ - "@types/webpack",\ - "esbuild",\ - "uglify-js",\ - "webpack"\ - ],\ - "linkType": "HARD"\ - }],\ - ["virtual:f4ab5f842ae92831564bb9c51df628512e7cbc4b95ade6180c8b4aa79140126a35e1433b1c31a5ad3badd9104d877649be3ca11137a24ac8c31f75ce1bd1b44b#npm:5.3.16", {\ - "packageLocation": "./.yarn/__virtual__/terser-webpack-plugin-virtual-37d6fb1d64/0/cache/terser-webpack-plugin-npm-5.3.16-7d59a4385c-09dfbff602.zip/node_modules/terser-webpack-plugin/",\ - "packageDependencies": [\ - ["@jridgewell/trace-mapping", "npm:0.3.25"],\ - ["@swc/core", null],\ - ["@types/esbuild", null],\ - ["@types/swc__core", null],\ - ["@types/uglify-js", null],\ - ["@types/webpack", null],\ - ["esbuild", null],\ - ["jest-worker", "npm:27.5.1"],\ - ["schema-utils", "npm:4.3.0"],\ - ["serialize-javascript", "npm:7.0.4"],\ - ["terser", "npm:5.39.0"],\ - ["terser-webpack-plugin", "virtual:f4ab5f842ae92831564bb9c51df628512e7cbc4b95ade6180c8b4aa79140126a35e1433b1c31a5ad3badd9104d877649be3ca11137a24ac8c31f75ce1bd1b44b#npm:5.3.16"],\ - ["uglify-js", null],\ - ["webpack", "virtual:da12f6bb23b671689b7f4f5cfff69cabf980ba04aff1ffd96860c787f7d5d08d32b0db765d9f16463de0d1af2c01fa6987b861cf5df2362e38e0ef415f29b51c#npm:5.105.0"]\ - ],\ - "packagePeers": [\ - "@swc/core",\ - "@types/esbuild",\ - "@types/swc__core",\ - "@types/uglify-js",\ - "@types/webpack",\ - "esbuild",\ - "uglify-js",\ - "webpack"\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ - ["test-exclude", [\ - ["npm:6.0.0", {\ - "packageLocation": "./.yarn/cache/test-exclude-npm-6.0.0-3fb03d69df-8fccb2cb6c.zip/node_modules/test-exclude/",\ - "packageDependencies": [\ - ["@istanbuljs/schema", "npm:0.1.3"],\ - ["glob", "npm:7.2.3"],\ - ["minimatch", "npm:3.1.2"],\ - ["test-exclude", "npm:6.0.0"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ - ["text-decoder", [\ - ["npm:1.2.3", {\ - "packageLocation": "./.yarn/cache/text-decoder-npm-1.2.3-cc7432569a-bcdec33c0f.zip/node_modules/text-decoder/",\ - "packageDependencies": [\ - ["b4a", "npm:1.6.7"],\ - ["text-decoder", "npm:1.2.3"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ - ["text-extensions", [\ - ["npm:1.9.0", {\ - "packageLocation": "./.yarn/cache/text-extensions-npm-1.9.0-87655d768f-56a9962c1b.zip/node_modules/text-extensions/",\ - "packageDependencies": [\ - ["text-extensions", "npm:1.9.0"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ - ["text-hex", [\ - ["npm:1.0.0", {\ - "packageLocation": "./.yarn/cache/text-hex-npm-1.0.0-22389e4d56-1138f68adc.zip/node_modules/text-hex/",\ - "packageDependencies": [\ - ["text-hex", "npm:1.0.0"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ - ["text-table", [\ - ["npm:0.2.0", {\ - "packageLocation": "./.yarn/cache/text-table-npm-0.2.0-d92a778b59-4383b5baae.zip/node_modules/text-table/",\ + }]\ + ]],\ + ["text-table", [\ + ["npm:0.2.0", {\ + "packageLocation": "./.yarn/cache/text-table-npm-0.2.0-d92a778b59-4383b5baae.zip/node_modules/text-table/",\ "packageDependencies": [\ ["text-table", "npm:0.2.0"]\ ],\ @@ -21171,15 +20386,6 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ - ["tls", [\ - ["npm:0.0.1", {\ - "packageLocation": "./.yarn/cache/tls-npm-0.0.1-d44eeeb72e-83aee8b284.zip/node_modules/tls/",\ - "packageDependencies": [\ - ["tls", "npm:0.0.1"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ ["tmp", [\ ["npm:0.2.5", {\ "packageLocation": "./.yarn/cache/tmp-npm-0.2.5-e146296d91-dd4b78b323.zip/node_modules/tmp/",\ @@ -21275,15 +20481,6 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ - ["triple-beam", [\ - ["npm:1.3.0", {\ - "packageLocation": "./.yarn/cache/triple-beam-npm-1.3.0-eda4e2a46c-7d7b77d862.zip/node_modules/triple-beam/",\ - "packageDependencies": [\ - ["triple-beam", "npm:1.3.0"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ ["ts-api-utils", [\ ["npm:1.0.3", {\ "packageLocation": "./.yarn/cache/ts-api-utils-npm-1.0.3-992f360d9b-1350a5110e.zip/node_modules/ts-api-utils/",\ @@ -21414,28 +20611,6 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ - ["virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:9.5.0", {\ - "packageLocation": "./.yarn/__virtual__/ts-loader-virtual-43597e08e9/0/cache/ts-loader-npm-9.5.0-9514617263-8ffc6411ec.zip/node_modules/ts-loader/",\ - "packageDependencies": [\ - ["@types/typescript", null],\ - ["@types/webpack", null],\ - ["chalk", "npm:4.1.2"],\ - ["enhanced-resolve", "npm:5.15.0"],\ - ["micromatch", "npm:4.0.8"],\ - ["semver", "npm:7.5.3"],\ - ["source-map", "npm:0.7.4"],\ - ["ts-loader", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:9.5.0"],\ - ["typescript", "patch:typescript@npm%3A5.9.3#optional!builtin::version=5.9.3&hash=5786d5"],\ - ["webpack", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:5.105.0"]\ - ],\ - "packagePeers": [\ - "@types/typescript",\ - "@types/webpack",\ - "typescript",\ - "webpack"\ - ],\ - "linkType": "HARD"\ - }],\ ["virtual:da12f6bb23b671689b7f4f5cfff69cabf980ba04aff1ffd96860c787f7d5d08d32b0db765d9f16463de0d1af2c01fa6987b861cf5df2362e38e0ef415f29b51c#npm:9.5.0", {\ "packageLocation": "./.yarn/__virtual__/ts-loader-virtual-35b23e0e2c/0/cache/ts-loader-npm-9.5.0-9514617263-8ffc6411ec.zip/node_modules/ts-loader/",\ "packageDependencies": [\ @@ -21481,32 +20656,6 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ - ["ts-mock-imports", [\ - ["npm:1.3.8", {\ - "packageLocation": "./.yarn/cache/ts-mock-imports-npm-1.3.8-ce172e5189-82ee2a7256.zip/node_modules/ts-mock-imports/",\ - "packageDependencies": [\ - ["ts-mock-imports", "npm:1.3.8"]\ - ],\ - "linkType": "SOFT"\ - }],\ - ["virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:1.3.8", {\ - "packageLocation": "./.yarn/__virtual__/ts-mock-imports-virtual-ed0dfa7cb7/0/cache/ts-mock-imports-npm-1.3.8-ce172e5189-82ee2a7256.zip/node_modules/ts-mock-imports/",\ - "packageDependencies": [\ - ["@types/sinon", "npm:9.0.11"],\ - ["@types/typescript", null],\ - ["sinon", "npm:18.0.1"],\ - ["ts-mock-imports", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:1.3.8"],\ - ["typescript", "patch:typescript@npm%3A5.9.3#optional!builtin::version=5.9.3&hash=5786d5"]\ - ],\ - "packagePeers": [\ - "@types/sinon",\ - "@types/typescript",\ - "sinon",\ - "typescript"\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ ["ts-node", [\ ["npm:10.9.1", {\ "packageLocation": "./.yarn/cache/ts-node-npm-10.9.1-6c268be7f4-bee56d4dc9.zip/node_modules/ts-node/",\ @@ -22063,6 +21212,15 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["undici", [\ + ["npm:6.25.0", {\ + "packageLocation": "./.yarn/cache/undici-npm-6.25.0-6002e70879-a475e45da3.zip/node_modules/undici/",\ + "packageDependencies": [\ + ["undici", "npm:6.25.0"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["undici-types", [\ ["npm:6.21.0", {\ "packageLocation": "./.yarn/cache/undici-types-npm-6.21.0-eb2b0ed56a-ec8f41aa43.zip/node_modules/undici-types/",\ @@ -22564,82 +21722,6 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "SOFT"\ }],\ - ["virtual:01938c2be4835443e5a304e2b117c575220e96e8b7cedeb0f48d79264590b4c4babc6d1fea6367f522b1ca0149d795b42f2ab89c34a6ffe3c20f0a8cbb8b4453#npm:5.105.0", {\ - "packageLocation": "./.yarn/__virtual__/webpack-virtual-be6a302f46/0/cache/webpack-npm-5.105.0-ff5d0a44ab-95e0a0f04f.zip/node_modules/webpack/",\ - "packageDependencies": [\ - ["@types/eslint-scope", "npm:3.7.7"],\ - ["@types/estree", "npm:1.0.8"],\ - ["@types/json-schema", "npm:7.0.15"],\ - ["@types/webpack-cli", null],\ - ["@webassemblyjs/ast", "npm:1.14.1"],\ - ["@webassemblyjs/wasm-edit", "npm:1.14.1"],\ - ["@webassemblyjs/wasm-parser", "npm:1.14.1"],\ - ["acorn", "npm:8.15.0"],\ - ["acorn-import-phases", "virtual:4007bcbf54b6a1fc892cfdfa87d57c16a3d9d04f40d8627892c15aab1e876c161341a8d50416117b4d1b25d4709d289b42728585c69b09237cab14322e1446c6#npm:1.0.4"],\ - ["browserslist", "npm:4.28.1"],\ - ["chrome-trace-event", "npm:1.0.3"],\ - ["enhanced-resolve", "npm:5.19.0"],\ - ["es-module-lexer", "npm:2.0.0"],\ - ["eslint-scope", "npm:5.1.1"],\ - ["events", "npm:3.3.0"],\ - ["glob-to-regexp", "npm:0.4.1"],\ - ["graceful-fs", "npm:4.2.11"],\ - ["json-parse-even-better-errors", "npm:2.3.1"],\ - ["loader-runner", "npm:4.3.1"],\ - ["mime-types", "npm:2.1.34"],\ - ["neo-async", "npm:2.6.2"],\ - ["schema-utils", "npm:4.3.3"],\ - ["tapable", "npm:2.3.0"],\ - ["terser-webpack-plugin", "virtual:be6a302f4603f759eab24f466ff96c2ebfdecb1ae05baf7c5d5166535833a454d4fc20106f065d537e3f48f37a7c8fe3c565764f1b782ea734081dc93d0dfac9#npm:5.3.16"],\ - ["watchpack", "npm:2.5.1"],\ - ["webpack", "virtual:01938c2be4835443e5a304e2b117c575220e96e8b7cedeb0f48d79264590b4c4babc6d1fea6367f522b1ca0149d795b42f2ab89c34a6ffe3c20f0a8cbb8b4453#npm:5.105.0"],\ - ["webpack-cli", null],\ - ["webpack-sources", "npm:3.3.4"]\ - ],\ - "packagePeers": [\ - "@types/webpack-cli",\ - "webpack-cli"\ - ],\ - "linkType": "HARD"\ - }],\ - ["virtual:45f214395bc38640da4dc5e940482d5df0572c5384e0262802601d1973e71077ec8bbd76b77eafa4c0550b706b664abd84d63fd67a5897139f0b2675530fc84f#npm:5.105.0", {\ - "packageLocation": "./.yarn/__virtual__/webpack-virtual-ac08d18021/0/cache/webpack-npm-5.105.0-ff5d0a44ab-95e0a0f04f.zip/node_modules/webpack/",\ - "packageDependencies": [\ - ["@types/eslint-scope", "npm:3.7.7"],\ - ["@types/estree", "npm:1.0.8"],\ - ["@types/json-schema", "npm:7.0.15"],\ - ["@types/webpack-cli", null],\ - ["@webassemblyjs/ast", "npm:1.14.1"],\ - ["@webassemblyjs/wasm-edit", "npm:1.14.1"],\ - ["@webassemblyjs/wasm-parser", "npm:1.14.1"],\ - ["acorn", "npm:8.15.0"],\ - ["acorn-import-phases", "virtual:4007bcbf54b6a1fc892cfdfa87d57c16a3d9d04f40d8627892c15aab1e876c161341a8d50416117b4d1b25d4709d289b42728585c69b09237cab14322e1446c6#npm:1.0.4"],\ - ["browserslist", "npm:4.28.1"],\ - ["chrome-trace-event", "npm:1.0.3"],\ - ["enhanced-resolve", "npm:5.19.0"],\ - ["es-module-lexer", "npm:2.0.0"],\ - ["eslint-scope", "npm:5.1.1"],\ - ["events", "npm:3.3.0"],\ - ["glob-to-regexp", "npm:0.4.1"],\ - ["graceful-fs", "npm:4.2.11"],\ - ["json-parse-even-better-errors", "npm:2.3.1"],\ - ["loader-runner", "npm:4.3.1"],\ - ["mime-types", "npm:2.1.34"],\ - ["neo-async", "npm:2.6.2"],\ - ["schema-utils", "npm:4.3.3"],\ - ["tapable", "npm:2.3.0"],\ - ["terser-webpack-plugin", "virtual:ac08d1802148a23c9b3f7a8749cbaaded258daba072aa6e761629ffa5f56f8f3e419894607861c1572ce1b35ea47b30ac3d38935ced0e4c1e2540eff8deb5e8f#npm:5.3.16"],\ - ["watchpack", "npm:2.5.1"],\ - ["webpack", "virtual:45f214395bc38640da4dc5e940482d5df0572c5384e0262802601d1973e71077ec8bbd76b77eafa4c0550b706b664abd84d63fd67a5897139f0b2675530fc84f#npm:5.105.0"],\ - ["webpack-cli", "virtual:45f214395bc38640da4dc5e940482d5df0572c5384e0262802601d1973e71077ec8bbd76b77eafa4c0550b706b664abd84d63fd67a5897139f0b2675530fc84f#npm:4.9.1"],\ - ["webpack-sources", "npm:3.3.4"]\ - ],\ - "packagePeers": [\ - "@types/webpack-cli",\ - "webpack-cli"\ - ],\ - "linkType": "HARD"\ - }],\ ["virtual:897449be52adaf897095babe74bfcc926f5d083ac9aac6fbc5e260f1f71b7e3ada3f268ac9457d3009b9c6fca51fe685ec21fbed21ec5087df84ab489b719456#npm:5.105.0", {\ "packageLocation": "./.yarn/__virtual__/webpack-virtual-48ff67a0e8/0/cache/webpack-npm-5.105.0-ff5d0a44ab-95e0a0f04f.zip/node_modules/webpack/",\ "packageDependencies": [\ @@ -22678,44 +21760,6 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ - ["virtual:8f25fc90e0fb5fd89843707863857591fa8c52f9f33eadced4bf404b1871d91959f7bb86948ae0e1b53ee94d491ef8fde9c0b58b39c9490c0d0fa6c931945f97#npm:5.105.0", {\ - "packageLocation": "./.yarn/__virtual__/webpack-virtual-62941717b6/0/cache/webpack-npm-5.105.0-ff5d0a44ab-95e0a0f04f.zip/node_modules/webpack/",\ - "packageDependencies": [\ - ["@types/eslint-scope", "npm:3.7.7"],\ - ["@types/estree", "npm:1.0.8"],\ - ["@types/json-schema", "npm:7.0.15"],\ - ["@types/webpack-cli", null],\ - ["@webassemblyjs/ast", "npm:1.14.1"],\ - ["@webassemblyjs/wasm-edit", "npm:1.14.1"],\ - ["@webassemblyjs/wasm-parser", "npm:1.14.1"],\ - ["acorn", "npm:8.15.0"],\ - ["acorn-import-phases", "virtual:4007bcbf54b6a1fc892cfdfa87d57c16a3d9d04f40d8627892c15aab1e876c161341a8d50416117b4d1b25d4709d289b42728585c69b09237cab14322e1446c6#npm:1.0.4"],\ - ["browserslist", "npm:4.28.1"],\ - ["chrome-trace-event", "npm:1.0.3"],\ - ["enhanced-resolve", "npm:5.19.0"],\ - ["es-module-lexer", "npm:2.0.0"],\ - ["eslint-scope", "npm:5.1.1"],\ - ["events", "npm:3.3.0"],\ - ["glob-to-regexp", "npm:0.4.1"],\ - ["graceful-fs", "npm:4.2.11"],\ - ["json-parse-even-better-errors", "npm:2.3.1"],\ - ["loader-runner", "npm:4.3.1"],\ - ["mime-types", "npm:2.1.34"],\ - ["neo-async", "npm:2.6.2"],\ - ["schema-utils", "npm:4.3.3"],\ - ["tapable", "npm:2.3.0"],\ - ["terser-webpack-plugin", "virtual:62941717b655ac142dd4cd1370e0c48afd49b5b0e864a88fae8030cff430b00a6538f10d6ec6916a973bebc3c0274b8dad2e2dfd6263382ab5c42f6550c4185a#npm:5.3.16"],\ - ["watchpack", "npm:2.5.1"],\ - ["webpack", "virtual:8f25fc90e0fb5fd89843707863857591fa8c52f9f33eadced4bf404b1871d91959f7bb86948ae0e1b53ee94d491ef8fde9c0b58b39c9490c0d0fa6c931945f97#npm:5.105.0"],\ - ["webpack-cli", "virtual:8f25fc90e0fb5fd89843707863857591fa8c52f9f33eadced4bf404b1871d91959f7bb86948ae0e1b53ee94d491ef8fde9c0b58b39c9490c0d0fa6c931945f97#npm:4.9.1"],\ - ["webpack-sources", "npm:3.3.4"]\ - ],\ - "packagePeers": [\ - "@types/webpack-cli",\ - "webpack-cli"\ - ],\ - "linkType": "HARD"\ - }],\ ["virtual:98d1afeac78a19485e4cb7428abff692e58b6fc468d8040035b560ed49383fc95857be6b5014af27e53063e6f08b654690c2b945f3443c22dd60c6b083684b3c#npm:5.105.0", {\ "packageLocation": "./.yarn/__virtual__/webpack-virtual-4f0f9b68e7/0/cache/webpack-npm-5.105.0-ff5d0a44ab-95e0a0f04f.zip/node_modules/webpack/",\ "packageDependencies": [\ @@ -22754,44 +21798,6 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ - ["virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:5.105.0", {\ - "packageLocation": "./.yarn/__virtual__/webpack-virtual-be62dbe6a9/0/cache/webpack-npm-5.105.0-ff5d0a44ab-95e0a0f04f.zip/node_modules/webpack/",\ - "packageDependencies": [\ - ["@types/eslint-scope", "npm:3.7.7"],\ - ["@types/estree", "npm:1.0.8"],\ - ["@types/json-schema", "npm:7.0.15"],\ - ["@types/webpack-cli", null],\ - ["@webassemblyjs/ast", "npm:1.14.1"],\ - ["@webassemblyjs/wasm-edit", "npm:1.14.1"],\ - ["@webassemblyjs/wasm-parser", "npm:1.14.1"],\ - ["acorn", "npm:8.15.0"],\ - ["acorn-import-phases", "virtual:4007bcbf54b6a1fc892cfdfa87d57c16a3d9d04f40d8627892c15aab1e876c161341a8d50416117b4d1b25d4709d289b42728585c69b09237cab14322e1446c6#npm:1.0.4"],\ - ["browserslist", "npm:4.28.1"],\ - ["chrome-trace-event", "npm:1.0.3"],\ - ["enhanced-resolve", "npm:5.19.0"],\ - ["es-module-lexer", "npm:2.0.0"],\ - ["eslint-scope", "npm:5.1.1"],\ - ["events", "npm:3.3.0"],\ - ["glob-to-regexp", "npm:0.4.1"],\ - ["graceful-fs", "npm:4.2.11"],\ - ["json-parse-even-better-errors", "npm:2.3.1"],\ - ["loader-runner", "npm:4.3.1"],\ - ["mime-types", "npm:2.1.34"],\ - ["neo-async", "npm:2.6.2"],\ - ["schema-utils", "npm:4.3.3"],\ - ["tapable", "npm:2.3.0"],\ - ["terser-webpack-plugin", "virtual:be62dbe6a90b52c749baac6deb5de07ddeff4f1a8ddad2373494caee7afd79548ac93750b7f72d4d78e33d400acfe238653150a3f2538c2ac37dcb93c4b6f001#npm:5.3.16"],\ - ["watchpack", "npm:2.5.1"],\ - ["webpack", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:5.105.0"],\ - ["webpack-cli", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:4.9.1"],\ - ["webpack-sources", "npm:3.3.4"]\ - ],\ - "packagePeers": [\ - "@types/webpack-cli",\ - "webpack-cli"\ - ],\ - "linkType": "HARD"\ - }],\ ["virtual:da12f6bb23b671689b7f4f5cfff69cabf980ba04aff1ffd96860c787f7d5d08d32b0db765d9f16463de0d1af2c01fa6987b861cf5df2362e38e0ef415f29b51c#npm:5.105.0", {\ "packageLocation": "./.yarn/__virtual__/webpack-virtual-f4ab5f842a/0/cache/webpack-npm-5.105.0-ff5d0a44ab-95e0a0f04f.zip/node_modules/webpack/",\ "packageDependencies": [\ @@ -22877,47 +21883,6 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "SOFT"\ }],\ - ["virtual:45f214395bc38640da4dc5e940482d5df0572c5384e0262802601d1973e71077ec8bbd76b77eafa4c0550b706b664abd84d63fd67a5897139f0b2675530fc84f#npm:4.9.1", {\ - "packageLocation": "./.yarn/__virtual__/webpack-cli-virtual-0249f7ceb5/0/cache/webpack-cli-npm-4.9.1-1b8a5f360f-14eb69cec6.zip/node_modules/webpack-cli/",\ - "packageDependencies": [\ - ["@discoveryjs/json-ext", "npm:0.5.5"],\ - ["@types/webpack", null],\ - ["@types/webpack-bundle-analyzer", null],\ - ["@types/webpack-cli__generators", null],\ - ["@types/webpack-cli__migrate", null],\ - ["@types/webpack-dev-server", null],\ - ["@webpack-cli/configtest", "virtual:0249f7ceb5542d6b732af2b44f9fcd16c60be8b8440f0f3abc6a5de67aabcff731bc3bc83f3067ab2f9037661176f001f89208fcea9e8962835fd43d0aabe88a#npm:1.1.0"],\ - ["@webpack-cli/generators", null],\ - ["@webpack-cli/info", "virtual:0249f7ceb5542d6b732af2b44f9fcd16c60be8b8440f0f3abc6a5de67aabcff731bc3bc83f3067ab2f9037661176f001f89208fcea9e8962835fd43d0aabe88a#npm:1.4.0"],\ - ["@webpack-cli/migrate", null],\ - ["@webpack-cli/serve", "virtual:0249f7ceb5542d6b732af2b44f9fcd16c60be8b8440f0f3abc6a5de67aabcff731bc3bc83f3067ab2f9037661176f001f89208fcea9e8962835fd43d0aabe88a#npm:1.6.0"],\ - ["colorette", "npm:2.0.20"],\ - ["commander", "npm:7.2.0"],\ - ["execa", "npm:5.1.1"],\ - ["fastest-levenshtein", "npm:1.0.12"],\ - ["import-local", "npm:3.0.3"],\ - ["interpret", "npm:2.2.0"],\ - ["rechoir", "npm:0.7.1"],\ - ["webpack", "virtual:45f214395bc38640da4dc5e940482d5df0572c5384e0262802601d1973e71077ec8bbd76b77eafa4c0550b706b664abd84d63fd67a5897139f0b2675530fc84f#npm:5.105.0"],\ - ["webpack-bundle-analyzer", null],\ - ["webpack-cli", "virtual:45f214395bc38640da4dc5e940482d5df0572c5384e0262802601d1973e71077ec8bbd76b77eafa4c0550b706b664abd84d63fd67a5897139f0b2675530fc84f#npm:4.9.1"],\ - ["webpack-dev-server", null],\ - ["webpack-merge", "npm:5.8.0"]\ - ],\ - "packagePeers": [\ - "@types/webpack-bundle-analyzer",\ - "@types/webpack-cli__generators",\ - "@types/webpack-cli__migrate",\ - "@types/webpack-dev-server",\ - "@types/webpack",\ - "@webpack-cli/generators",\ - "@webpack-cli/migrate",\ - "webpack-bundle-analyzer",\ - "webpack-dev-server",\ - "webpack"\ - ],\ - "linkType": "HARD"\ - }],\ ["virtual:897449be52adaf897095babe74bfcc926f5d083ac9aac6fbc5e260f1f71b7e3ada3f268ac9457d3009b9c6fca51fe685ec21fbed21ec5087df84ab489b719456#npm:4.9.1", {\ "packageLocation": "./.yarn/__virtual__/webpack-cli-virtual-a5a6463a0b/0/cache/webpack-cli-npm-4.9.1-1b8a5f360f-14eb69cec6.zip/node_modules/webpack-cli/",\ "packageDependencies": [\ @@ -22959,47 +21924,6 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ - ["virtual:8f25fc90e0fb5fd89843707863857591fa8c52f9f33eadced4bf404b1871d91959f7bb86948ae0e1b53ee94d491ef8fde9c0b58b39c9490c0d0fa6c931945f97#npm:4.9.1", {\ - "packageLocation": "./.yarn/__virtual__/webpack-cli-virtual-b37ef7cf98/0/cache/webpack-cli-npm-4.9.1-1b8a5f360f-14eb69cec6.zip/node_modules/webpack-cli/",\ - "packageDependencies": [\ - ["@discoveryjs/json-ext", "npm:0.5.5"],\ - ["@types/webpack", null],\ - ["@types/webpack-bundle-analyzer", null],\ - ["@types/webpack-cli__generators", null],\ - ["@types/webpack-cli__migrate", null],\ - ["@types/webpack-dev-server", null],\ - ["@webpack-cli/configtest", "virtual:b37ef7cf98ceabe8c7b789a7db3f0a5f3444d083afa5f0e3ab570292e74eff241f890fadbf245a134b2ebfcba326b1782124a4dd4f16ca7cdb6091dd9a987c04#npm:1.1.0"],\ - ["@webpack-cli/generators", null],\ - ["@webpack-cli/info", "virtual:b37ef7cf98ceabe8c7b789a7db3f0a5f3444d083afa5f0e3ab570292e74eff241f890fadbf245a134b2ebfcba326b1782124a4dd4f16ca7cdb6091dd9a987c04#npm:1.4.0"],\ - ["@webpack-cli/migrate", null],\ - ["@webpack-cli/serve", "virtual:b37ef7cf98ceabe8c7b789a7db3f0a5f3444d083afa5f0e3ab570292e74eff241f890fadbf245a134b2ebfcba326b1782124a4dd4f16ca7cdb6091dd9a987c04#npm:1.6.0"],\ - ["colorette", "npm:2.0.20"],\ - ["commander", "npm:7.2.0"],\ - ["execa", "npm:5.1.1"],\ - ["fastest-levenshtein", "npm:1.0.12"],\ - ["import-local", "npm:3.0.3"],\ - ["interpret", "npm:2.2.0"],\ - ["rechoir", "npm:0.7.1"],\ - ["webpack", "virtual:8f25fc90e0fb5fd89843707863857591fa8c52f9f33eadced4bf404b1871d91959f7bb86948ae0e1b53ee94d491ef8fde9c0b58b39c9490c0d0fa6c931945f97#npm:5.105.0"],\ - ["webpack-bundle-analyzer", null],\ - ["webpack-cli", "virtual:8f25fc90e0fb5fd89843707863857591fa8c52f9f33eadced4bf404b1871d91959f7bb86948ae0e1b53ee94d491ef8fde9c0b58b39c9490c0d0fa6c931945f97#npm:4.9.1"],\ - ["webpack-dev-server", null],\ - ["webpack-merge", "npm:5.8.0"]\ - ],\ - "packagePeers": [\ - "@types/webpack-bundle-analyzer",\ - "@types/webpack-cli__generators",\ - "@types/webpack-cli__migrate",\ - "@types/webpack-dev-server",\ - "@types/webpack",\ - "@webpack-cli/generators",\ - "@webpack-cli/migrate",\ - "webpack-bundle-analyzer",\ - "webpack-dev-server",\ - "webpack"\ - ],\ - "linkType": "HARD"\ - }],\ ["virtual:98d1afeac78a19485e4cb7428abff692e58b6fc468d8040035b560ed49383fc95857be6b5014af27e53063e6f08b654690c2b945f3443c22dd60c6b083684b3c#npm:4.9.1", {\ "packageLocation": "./.yarn/__virtual__/webpack-cli-virtual-b65947dc40/0/cache/webpack-cli-npm-4.9.1-1b8a5f360f-14eb69cec6.zip/node_modules/webpack-cli/",\ "packageDependencies": [\ @@ -23041,47 +21965,6 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ - ["virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:4.9.1", {\ - "packageLocation": "./.yarn/__virtual__/webpack-cli-virtual-7fc88da9d0/0/cache/webpack-cli-npm-4.9.1-1b8a5f360f-14eb69cec6.zip/node_modules/webpack-cli/",\ - "packageDependencies": [\ - ["@discoveryjs/json-ext", "npm:0.5.5"],\ - ["@types/webpack", null],\ - ["@types/webpack-bundle-analyzer", null],\ - ["@types/webpack-cli__generators", null],\ - ["@types/webpack-cli__migrate", null],\ - ["@types/webpack-dev-server", null],\ - ["@webpack-cli/configtest", "virtual:7fc88da9d00679384dc013444a3b1ed8ef8395fcad9d046790a1851d5db985e5ee052061731f87c5475e4bf20a92d69ea1a1a287c0d76d7b1a6bf97010c63532#npm:1.1.0"],\ - ["@webpack-cli/generators", null],\ - ["@webpack-cli/info", "virtual:7fc88da9d00679384dc013444a3b1ed8ef8395fcad9d046790a1851d5db985e5ee052061731f87c5475e4bf20a92d69ea1a1a287c0d76d7b1a6bf97010c63532#npm:1.4.0"],\ - ["@webpack-cli/migrate", null],\ - ["@webpack-cli/serve", "virtual:7fc88da9d00679384dc013444a3b1ed8ef8395fcad9d046790a1851d5db985e5ee052061731f87c5475e4bf20a92d69ea1a1a287c0d76d7b1a6bf97010c63532#npm:1.6.0"],\ - ["colorette", "npm:2.0.20"],\ - ["commander", "npm:7.2.0"],\ - ["execa", "npm:5.1.1"],\ - ["fastest-levenshtein", "npm:1.0.12"],\ - ["import-local", "npm:3.0.3"],\ - ["interpret", "npm:2.2.0"],\ - ["rechoir", "npm:0.7.1"],\ - ["webpack", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:5.105.0"],\ - ["webpack-bundle-analyzer", null],\ - ["webpack-cli", "virtual:ad53cff31b1dbd4927a99e71702e3b8b10338636eaff010987c27c9ccea2d52af36900a9e36a4231cbb6e5464248ccc9c1da5d1d24d9b0f4f95660296b1060a6#npm:4.9.1"],\ - ["webpack-dev-server", null],\ - ["webpack-merge", "npm:5.8.0"]\ - ],\ - "packagePeers": [\ - "@types/webpack-bundle-analyzer",\ - "@types/webpack-cli__generators",\ - "@types/webpack-cli__migrate",\ - "@types/webpack-dev-server",\ - "@types/webpack",\ - "@webpack-cli/generators",\ - "@webpack-cli/migrate",\ - "webpack-bundle-analyzer",\ - "webpack-dev-server",\ - "webpack"\ - ],\ - "linkType": "HARD"\ - }],\ ["virtual:da12f6bb23b671689b7f4f5cfff69cabf980ba04aff1ffd96860c787f7d5d08d32b0db765d9f16463de0d1af2c01fa6987b861cf5df2362e38e0ef415f29b51c#npm:4.9.1", {\ "packageLocation": "./.yarn/__virtual__/webpack-cli-virtual-f4270a75ca/0/cache/webpack-cli-npm-4.9.1-1b8a5f360f-14eb69cec6.zip/node_modules/webpack-cli/",\ "packageDependencies": [\ @@ -23390,36 +22273,6 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ - ["winston", [\ - ["npm:3.3.3", {\ - "packageLocation": "./.yarn/cache/winston-npm-3.3.3-3fa4527b42-60b74f2ea7.zip/node_modules/winston/",\ - "packageDependencies": [\ - ["@dabh/diagnostics", "npm:2.0.2"],\ - ["async", "npm:3.2.4"],\ - ["is-stream", "npm:2.0.1"],\ - ["logform", "npm:2.3.0"],\ - ["one-time", "npm:1.0.0"],\ - ["readable-stream", "npm:3.6.2"],\ - ["stack-trace", "npm:0.0.10"],\ - ["triple-beam", "npm:1.3.0"],\ - ["winston", "npm:3.3.3"],\ - ["winston-transport", "npm:4.4.0"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ - ["winston-transport", [\ - ["npm:4.4.0", {\ - "packageLocation": "./.yarn/cache/winston-transport-npm-4.4.0-e1b3134c1e-f1651e8a87.zip/node_modules/winston-transport/",\ - "packageDependencies": [\ - ["logform", "npm:2.3.0"],\ - ["readable-stream", "npm:2.3.7"],\ - ["triple-beam", "npm:1.3.0"],\ - ["winston-transport", "npm:4.4.0"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ ["word-wrap", [\ ["npm:1.2.4", {\ "packageLocation": "./.yarn/cache/word-wrap-npm-1.2.4-7a75a0d62c-a749c0cf41.zip/node_modules/word-wrap/",\ @@ -23833,13 +22686,6 @@ const RAW_RUNTIME_STATE = ["yocto-queue", "npm:0.1.0"]\ ],\ "linkType": "HARD"\ - }],\ - ["npm:1.0.0", {\ - "packageLocation": "./.yarn/cache/yocto-queue-npm-1.0.0-7b502f1987-2cac84540f.zip/node_modules/yocto-queue/",\ - "packageDependencies": [\ - ["yocto-queue", "npm:1.0.0"]\ - ],\ - "linkType": "HARD"\ }]\ ]],\ ["z-schema", [\ diff --git a/.yarn/cache/@dabh-diagnostics-npm-2.0.2-83eb005a83-d0c7ae32da.zip b/.yarn/cache/@dabh-diagnostics-npm-2.0.2-83eb005a83-d0c7ae32da.zip deleted file mode 100644 index b2c63b64ab9..00000000000 Binary files a/.yarn/cache/@dabh-diagnostics-npm-2.0.2-83eb005a83-d0c7ae32da.zip and /dev/null differ diff --git a/.yarn/cache/assert-browserify-npm-2.0.0-8125e483ea-161984368c.zip b/.yarn/cache/assert-browserify-npm-2.0.0-8125e483ea-161984368c.zip deleted file mode 100644 index e7f28718adf..00000000000 Binary files a/.yarn/cache/assert-browserify-npm-2.0.0-8125e483ea-161984368c.zip and /dev/null differ diff --git a/.yarn/cache/babel-loader-npm-9.1.3-cbf4da21df-7086e67827.zip b/.yarn/cache/babel-loader-npm-9.1.3-cbf4da21df-7086e67827.zip deleted file mode 100644 index 6acd5dfdcbd..00000000000 Binary files a/.yarn/cache/babel-loader-npm-9.1.3-cbf4da21df-7086e67827.zip and /dev/null differ diff --git a/.yarn/cache/browserify-zlib-npm-0.2.0-eab4087284-852e72effd.zip b/.yarn/cache/browserify-zlib-npm-0.2.0-eab4087284-852e72effd.zip deleted file mode 100644 index 68894b1afe0..00000000000 Binary files a/.yarn/cache/browserify-zlib-npm-0.2.0-eab4087284-852e72effd.zip and /dev/null differ diff --git a/.yarn/cache/color-npm-3.2.1-568cf1014f-bf70438e01.zip b/.yarn/cache/color-npm-3.2.1-568cf1014f-bf70438e01.zip deleted file mode 100644 index d88f3408a9d..00000000000 Binary files a/.yarn/cache/color-npm-3.2.1-568cf1014f-bf70438e01.zip and /dev/null differ diff --git a/.yarn/cache/color-string-npm-1.6.0-94ed25c258-27c2365153.zip b/.yarn/cache/color-string-npm-1.6.0-94ed25c258-27c2365153.zip deleted file mode 100644 index 99784a5c586..00000000000 Binary files a/.yarn/cache/color-string-npm-1.6.0-94ed25c258-27c2365153.zip and /dev/null differ diff --git a/.yarn/cache/colors-npm-1.4.0-7e2cf12234-90b2d54651.zip b/.yarn/cache/colors-npm-1.4.0-7e2cf12234-90b2d54651.zip deleted file mode 100644 index dfb00fb99a2..00000000000 Binary files a/.yarn/cache/colors-npm-1.4.0-7e2cf12234-90b2d54651.zip and /dev/null differ diff --git a/.yarn/cache/colorspace-npm-1.1.4-f01655548a-bb3934ef3c.zip b/.yarn/cache/colorspace-npm-1.1.4-f01655548a-bb3934ef3c.zip deleted file mode 100644 index 61c649a0c59..00000000000 Binary files a/.yarn/cache/colorspace-npm-1.1.4-f01655548a-bb3934ef3c.zip and /dev/null differ diff --git a/.yarn/cache/common-path-prefix-npm-3.0.0-68b78785c1-09c180e8d8.zip b/.yarn/cache/common-path-prefix-npm-3.0.0-68b78785c1-09c180e8d8.zip deleted file mode 100644 index 0ba9492af1c..00000000000 Binary files a/.yarn/cache/common-path-prefix-npm-3.0.0-68b78785c1-09c180e8d8.zip and /dev/null differ diff --git a/.yarn/cache/core-js-npm-3.33.2-08a6fba407-d62554d51c.zip b/.yarn/cache/core-js-npm-3.33.2-08a6fba407-d62554d51c.zip deleted file mode 100644 index d4e3e88ae78..00000000000 Binary files a/.yarn/cache/core-js-npm-3.33.2-08a6fba407-d62554d51c.zip and /dev/null differ diff --git a/.yarn/cache/enabled-npm-2.0.0-bf5d96c9d8-9d256d89f4.zip b/.yarn/cache/enabled-npm-2.0.0-bf5d96c9d8-9d256d89f4.zip deleted file mode 100644 index def4625384c..00000000000 Binary files a/.yarn/cache/enabled-npm-2.0.0-bf5d96c9d8-9d256d89f4.zip and /dev/null differ diff --git a/.yarn/cache/fecha-npm-4.2.1-40d84f7733-6cf959d41a.zip b/.yarn/cache/fecha-npm-4.2.1-40d84f7733-6cf959d41a.zip deleted file mode 100644 index 0e7b5f132fe..00000000000 Binary files a/.yarn/cache/fecha-npm-4.2.1-40d84f7733-6cf959d41a.zip and /dev/null differ diff --git a/.yarn/cache/find-cache-dir-npm-4.0.0-ad2504e37e-52a456a80d.zip b/.yarn/cache/find-cache-dir-npm-4.0.0-ad2504e37e-52a456a80d.zip deleted file mode 100644 index 52c003246f7..00000000000 Binary files a/.yarn/cache/find-cache-dir-npm-4.0.0-ad2504e37e-52a456a80d.zip and /dev/null differ diff --git a/.yarn/cache/find-up-npm-6.3.0-e5056fc655-4f3bdc30d4.zip b/.yarn/cache/find-up-npm-6.3.0-e5056fc655-4f3bdc30d4.zip deleted file mode 100644 index 230e977a2f4..00000000000 Binary files a/.yarn/cache/find-up-npm-6.3.0-e5056fc655-4f3bdc30d4.zip and /dev/null differ diff --git a/.yarn/cache/fn.name-npm-1.1.0-b472333184-000198af19.zip b/.yarn/cache/fn.name-npm-1.1.0-b472333184-000198af19.zip deleted file mode 100644 index e6ea9a07c95..00000000000 Binary files a/.yarn/cache/fn.name-npm-1.1.0-b472333184-000198af19.zip and /dev/null differ diff --git a/.yarn/cache/karma-sourcemap-loader-npm-0.3.8-a7560c795e-f641355ec1.zip b/.yarn/cache/karma-sourcemap-loader-npm-0.3.8-a7560c795e-f641355ec1.zip deleted file mode 100644 index 151585760ab..00000000000 Binary files a/.yarn/cache/karma-sourcemap-loader-npm-0.3.8-a7560c795e-f641355ec1.zip and /dev/null differ diff --git a/.yarn/cache/kuler-npm-2.0.0-19e74c9695-9e10b5a165.zip b/.yarn/cache/kuler-npm-2.0.0-19e74c9695-9e10b5a165.zip deleted file mode 100644 index 1c905daa0dc..00000000000 Binary files a/.yarn/cache/kuler-npm-2.0.0-19e74c9695-9e10b5a165.zip and /dev/null differ diff --git a/.yarn/cache/locate-path-npm-7.2.0-0e1169e19b-1c6d269d4e.zip b/.yarn/cache/locate-path-npm-7.2.0-0e1169e19b-1c6d269d4e.zip deleted file mode 100644 index 746a29a206d..00000000000 Binary files a/.yarn/cache/locate-path-npm-7.2.0-0e1169e19b-1c6d269d4e.zip and /dev/null differ diff --git a/.yarn/cache/logform-npm-2.3.0-13155f7f21-1fbe98725e.zip b/.yarn/cache/logform-npm-2.3.0-13155f7f21-1fbe98725e.zip deleted file mode 100644 index abb524703f2..00000000000 Binary files a/.yarn/cache/logform-npm-2.3.0-13155f7f21-1fbe98725e.zip and /dev/null differ diff --git a/.yarn/cache/net-npm-1.0.2-1d5514df5b-d97e215d92.zip b/.yarn/cache/net-npm-1.0.2-1d5514df5b-d97e215d92.zip deleted file mode 100644 index e74ce9a1d62..00000000000 Binary files a/.yarn/cache/net-npm-1.0.2-1d5514df5b-d97e215d92.zip and /dev/null differ diff --git a/.yarn/cache/node-inspect-extracted-npm-1.0.8-53baa7fd4f-4647a29afd.zip b/.yarn/cache/node-inspect-extracted-npm-1.0.8-53baa7fd4f-4647a29afd.zip deleted file mode 100644 index 009610a190d..00000000000 Binary files a/.yarn/cache/node-inspect-extracted-npm-1.0.8-53baa7fd4f-4647a29afd.zip and /dev/null differ diff --git a/.yarn/cache/one-time-npm-1.0.0-aeaad5e524-64d0160480.zip b/.yarn/cache/one-time-npm-1.0.0-aeaad5e524-64d0160480.zip deleted file mode 100644 index 6f01ce4199e..00000000000 Binary files a/.yarn/cache/one-time-npm-1.0.0-aeaad5e524-64d0160480.zip and /dev/null differ diff --git a/.yarn/cache/os-browserify-npm-0.3.0-cbc91c79a5-16e37ba3c0.zip b/.yarn/cache/os-browserify-npm-0.3.0-cbc91c79a5-16e37ba3c0.zip deleted file mode 100644 index b30422a9dc0..00000000000 Binary files a/.yarn/cache/os-browserify-npm-0.3.0-cbc91c79a5-16e37ba3c0.zip and /dev/null differ diff --git a/.yarn/cache/p-limit-npm-4.0.0-5dccf29b67-01d9d70695.zip b/.yarn/cache/p-limit-npm-4.0.0-5dccf29b67-01d9d70695.zip deleted file mode 100644 index f717a5b84aa..00000000000 Binary files a/.yarn/cache/p-limit-npm-4.0.0-5dccf29b67-01d9d70695.zip and /dev/null differ diff --git a/.yarn/cache/p-locate-npm-6.0.0-b6cfb720dc-2bfe5234ef.zip b/.yarn/cache/p-locate-npm-6.0.0-b6cfb720dc-2bfe5234ef.zip deleted file mode 100644 index 645dd51cd97..00000000000 Binary files a/.yarn/cache/p-locate-npm-6.0.0-b6cfb720dc-2bfe5234ef.zip and /dev/null differ diff --git a/.yarn/cache/pako-npm-1.0.11-b8f1b69d3e-1ad07210e8.zip b/.yarn/cache/pako-npm-1.0.11-b8f1b69d3e-1ad07210e8.zip deleted file mode 100644 index c2a311f2587..00000000000 Binary files a/.yarn/cache/pako-npm-1.0.11-b8f1b69d3e-1ad07210e8.zip and /dev/null differ diff --git a/.yarn/cache/path-exists-npm-5.0.0-0bf403c56c-8ca842868c.zip b/.yarn/cache/path-exists-npm-5.0.0-0bf403c56c-8ca842868c.zip deleted file mode 100644 index 9a134355e6f..00000000000 Binary files a/.yarn/cache/path-exists-npm-5.0.0-0bf403c56c-8ca842868c.zip and /dev/null differ diff --git a/.yarn/cache/pkg-dir-npm-7.0.0-02ff099b31-94298b20a4.zip b/.yarn/cache/pkg-dir-npm-7.0.0-02ff099b31-94298b20a4.zip deleted file mode 100644 index 6eb489a6580..00000000000 Binary files a/.yarn/cache/pkg-dir-npm-7.0.0-02ff099b31-94298b20a4.zip and /dev/null differ diff --git a/.yarn/cache/safe-stable-stringify-npm-1.1.1-1c282e1c55-bddfc2334d.zip b/.yarn/cache/safe-stable-stringify-npm-1.1.1-1c282e1c55-bddfc2334d.zip deleted file mode 100644 index c50765dc6be..00000000000 Binary files a/.yarn/cache/safe-stable-stringify-npm-1.1.1-1c282e1c55-bddfc2334d.zip and /dev/null differ diff --git a/.yarn/cache/schema-utils-npm-4.2.0-e822c5b02e-808784735e.zip b/.yarn/cache/schema-utils-npm-4.2.0-e822c5b02e-808784735e.zip deleted file mode 100644 index 6f296a3da9d..00000000000 Binary files a/.yarn/cache/schema-utils-npm-4.2.0-e822c5b02e-808784735e.zip and /dev/null differ diff --git a/.yarn/cache/stack-trace-npm-0.0.10-9460b173e1-7bd633f0e9.zip b/.yarn/cache/stack-trace-npm-0.0.10-9460b173e1-7bd633f0e9.zip deleted file mode 100644 index a0d3185ba25..00000000000 Binary files a/.yarn/cache/stack-trace-npm-0.0.10-9460b173e1-7bd633f0e9.zip and /dev/null differ diff --git a/.yarn/cache/text-hex-npm-1.0.0-22389e4d56-1138f68adc.zip b/.yarn/cache/text-hex-npm-1.0.0-22389e4d56-1138f68adc.zip deleted file mode 100644 index ce4bf0be7e8..00000000000 Binary files a/.yarn/cache/text-hex-npm-1.0.0-22389e4d56-1138f68adc.zip and /dev/null differ diff --git a/.yarn/cache/tls-npm-0.0.1-d44eeeb72e-83aee8b284.zip b/.yarn/cache/tls-npm-0.0.1-d44eeeb72e-83aee8b284.zip deleted file mode 100644 index d14c9e8966d..00000000000 Binary files a/.yarn/cache/tls-npm-0.0.1-d44eeeb72e-83aee8b284.zip and /dev/null differ diff --git a/.yarn/cache/triple-beam-npm-1.3.0-eda4e2a46c-7d7b77d862.zip b/.yarn/cache/triple-beam-npm-1.3.0-eda4e2a46c-7d7b77d862.zip deleted file mode 100644 index 5aab747e47c..00000000000 Binary files a/.yarn/cache/triple-beam-npm-1.3.0-eda4e2a46c-7d7b77d862.zip and /dev/null differ diff --git a/.yarn/cache/ts-mock-imports-npm-1.3.8-ce172e5189-82ee2a7256.zip b/.yarn/cache/ts-mock-imports-npm-1.3.8-ce172e5189-82ee2a7256.zip deleted file mode 100644 index fdcf45840df..00000000000 Binary files a/.yarn/cache/ts-mock-imports-npm-1.3.8-ce172e5189-82ee2a7256.zip and /dev/null differ diff --git a/.yarn/cache/undici-npm-6.25.0-6002e70879-a475e45da3.zip b/.yarn/cache/undici-npm-6.25.0-6002e70879-a475e45da3.zip new file mode 100644 index 00000000000..c2c62d4636a Binary files /dev/null and b/.yarn/cache/undici-npm-6.25.0-6002e70879-a475e45da3.zip differ diff --git a/.yarn/cache/winston-npm-3.3.3-3fa4527b42-60b74f2ea7.zip b/.yarn/cache/winston-npm-3.3.3-3fa4527b42-60b74f2ea7.zip deleted file mode 100644 index df7da775899..00000000000 Binary files a/.yarn/cache/winston-npm-3.3.3-3fa4527b42-60b74f2ea7.zip and /dev/null differ diff --git a/.yarn/cache/winston-transport-npm-4.4.0-e1b3134c1e-f1651e8a87.zip b/.yarn/cache/winston-transport-npm-4.4.0-e1b3134c1e-f1651e8a87.zip deleted file mode 100644 index d319e326b62..00000000000 Binary files a/.yarn/cache/winston-transport-npm-4.4.0-e1b3134c1e-f1651e8a87.zip and /dev/null differ diff --git a/.yarn/cache/yocto-queue-npm-1.0.0-7b502f1987-2cac84540f.zip b/.yarn/cache/yocto-queue-npm-1.0.0-7b502f1987-2cac84540f.zip deleted file mode 100644 index c08ff193b80..00000000000 Binary files a/.yarn/cache/yocto-queue-npm-1.0.0-7b502f1987-2cac84540f.zip and /dev/null differ diff --git a/packages/dapi-grpc/clients/core/v0/web/CorePromiseClient.js b/packages/dapi-grpc/clients/core/v0/web/CorePromiseClient.js index 3f1549d8058..818ef24e84a 100644 --- a/packages/dapi-grpc/clients/core/v0/web/CorePromiseClient.js +++ b/packages/dapi-grpc/clients/core/v0/web/CorePromiseClient.js @@ -1,4 +1,11 @@ -const { promisify } = require('util'); +// Inline promisify shim — avoids requiring Node's `util` module so this file +// can be bundled for browsers without a polyfill. If the codegen template +// is regenerated, restore this shim. +function promisify(fn) { + return (...args) => new Promise((resolve, reject) => { + fn(...args, (err, result) => (err ? reject(err) : resolve(result))); + }); +} const GrpcError = require('@dashevo/grpc-common/lib/server/error/GrpcError'); const { CoreClient } = require('./core_pb_service'); diff --git a/packages/dapi-grpc/clients/platform/v0/web/PlatformPromiseClient.js b/packages/dapi-grpc/clients/platform/v0/web/PlatformPromiseClient.js index 13be28a2d50..fbf39888b2e 100644 --- a/packages/dapi-grpc/clients/platform/v0/web/PlatformPromiseClient.js +++ b/packages/dapi-grpc/clients/platform/v0/web/PlatformPromiseClient.js @@ -1,5 +1,13 @@ const { PlatformClient } = require('./platform_pb_service'); -const { promisify } = require('util'); + +// Inline promisify shim — avoids requiring Node's `util` module so this file +// can be bundled for browsers without a polyfill. If the codegen template +// is regenerated, restore this shim. +function promisify(fn) { + return (...args) => new Promise((resolve, reject) => { + fn(...args, (err, result) => (err ? reject(err) : resolve(result))); + }); +} class PlatformPromiseClient { /** diff --git a/packages/js-dapi-client/.mocharc.yml b/packages/js-dapi-client/.mocharc.yml index bbd673997de..5ae84e7ee03 100644 --- a/packages/js-dapi-client/.mocharc.yml +++ b/packages/js-dapi-client/.mocharc.yml @@ -1,3 +1,3 @@ -require: lib/test/bootstrap.js +require: ./lib/test/bootstrap.js recursive: true timeout: 3000 diff --git a/packages/js-dapi-client/karma.conf.js b/packages/js-dapi-client/karma.conf.js deleted file mode 100644 index 12430bc899e..00000000000 --- a/packages/js-dapi-client/karma.conf.js +++ /dev/null @@ -1,45 +0,0 @@ -const karmaMocha = require('karma-mocha'); -const karmaMochaReporter = require('karma-mocha-reporter'); -const karmaChai = require('karma-chai'); -const karmaChromeLauncher = require('karma-chrome-launcher'); -const karmaFirefoxLauncher = require('karma-firefox-launcher'); -const karmaWebpack = require('karma-webpack'); -const webpackConfig = require('./webpack.config'); - -module.exports = (config) => { - config.set({ - frameworks: ['mocha', 'chai', 'webpack'], - files: [ - 'lib/test/karma/loader.js', - ], - preprocessors: { - 'lib/test/karma/loader.js': ['webpack'], - }, - webpack: { - mode: 'development', - resolve: webpackConfig[0].resolve, - plugins: webpackConfig[0].plugins, - }, - client: { - mocha: { - timeout: 5000, - }, - }, - reporters: ['mocha'], - port: 9876, - colors: true, - logLevel: config.LOG_INFO, - autoWatch: false, - browsers: ['ChromeHeadless', 'FirefoxHeadless'], - singleRun: false, - concurrency: Infinity, - plugins: [ - karmaMocha, - karmaMochaReporter, - karmaChai, - karmaChromeLauncher, - karmaFirefoxLauncher, - karmaWebpack, - ], - }); -}; diff --git a/packages/js-dapi-client/lib/BlockHeadersProvider/BlockHeadersProvider.js b/packages/js-dapi-client/lib/BlockHeadersProvider/BlockHeadersProvider.js index d9ca211bcef..751b0c2212f 100644 --- a/packages/js-dapi-client/lib/BlockHeadersProvider/BlockHeadersProvider.js +++ b/packages/js-dapi-client/lib/BlockHeadersProvider/BlockHeadersProvider.js @@ -1,7 +1,9 @@ -const EventEmitter = require('events'); -const { SpvChain, SPVError } = require('@dashevo/dash-spv'); +import EventEmitter from 'events'; +import dashSpv from '@dashevo/dash-spv'; -const BlockHeadersReader = require('./BlockHeadersReader'); +import BlockHeadersReader from './BlockHeadersReader.js'; + +const { SpvChain, SPVError } = dashSpv; /** * @typedef {BlockHeadersProviderOptions} BlockHeadersProviderOptions @@ -253,4 +255,4 @@ BlockHeadersProvider.EVENTS = EVENTS; BlockHeadersProvider.STATES = STATES; BlockHeadersProvider.defaultOptions = { ...defaultOptions }; -module.exports = BlockHeadersProvider; +export default BlockHeadersProvider; diff --git a/packages/js-dapi-client/lib/BlockHeadersProvider/BlockHeadersReader.js b/packages/js-dapi-client/lib/BlockHeadersProvider/BlockHeadersReader.js index f8d8fe4fc11..06876fd7a60 100644 --- a/packages/js-dapi-client/lib/BlockHeadersProvider/BlockHeadersReader.js +++ b/packages/js-dapi-client/lib/BlockHeadersProvider/BlockHeadersReader.js @@ -1,6 +1,8 @@ -const { EventEmitter } = require('events'); -const { BlockHeader } = require('@dashevo/dashcore-lib'); -const GrpcErrorCodes = require('@dashevo/grpc-common/lib/server/error/GrpcErrorCodes'); +import EventEmitter from 'events'; +import dashcoreLib from '@dashevo/dashcore-lib'; +import GrpcErrorCodes from '@dashevo/grpc-common/lib/server/error/GrpcErrorCodes.js'; + +const { BlockHeader } = dashcoreLib; const EVENTS = { BLOCK_HEADERS: 'BLOCK_HEADERS', @@ -302,4 +304,4 @@ class BlockHeadersReader extends EventEmitter { BlockHeadersReader.EVENTS = EVENTS; -module.exports = BlockHeadersReader; +export default BlockHeadersReader; diff --git a/packages/js-dapi-client/lib/BlockHeadersProvider/createBlockHeadersProviderFromOptions.js b/packages/js-dapi-client/lib/BlockHeadersProvider/createBlockHeadersProviderFromOptions.js index 642da97dc79..06bcd509e46 100644 --- a/packages/js-dapi-client/lib/BlockHeadersProvider/createBlockHeadersProviderFromOptions.js +++ b/packages/js-dapi-client/lib/BlockHeadersProvider/createBlockHeadersProviderFromOptions.js @@ -1,6 +1,6 @@ -const DAPIClientError = require('../errors/DAPIClientError'); -const BlockHeadersProvider = require('./BlockHeadersProvider'); -const ReconnectableStream = require('../transport/ReconnectableStream'); +import DAPIClientError from '../errors/DAPIClientError.js'; +import BlockHeadersProvider from './BlockHeadersProvider.js'; +import ReconnectableStream from '../transport/ReconnectableStream.js'; const validateNumber = (value, name, min = NaN, max = NaN) => { if (typeof value !== 'number') { @@ -91,4 +91,4 @@ function createBlockHeadersProviderFromOptions(options, coreMethods, logger) { return blockHeadersProvider; } -module.exports = createBlockHeadersProviderFromOptions; +export default createBlockHeadersProviderFromOptions; diff --git a/packages/js-dapi-client/lib/DAPIClient.js b/packages/js-dapi-client/lib/DAPIClient.js index 4731c54a2dc..68467ff637a 100644 --- a/packages/js-dapi-client/lib/DAPIClient.js +++ b/packages/js-dapi-client/lib/DAPIClient.js @@ -1,20 +1,20 @@ -const EventEmitter = require('events'); +import EventEmitter from 'events'; -const GrpcTransport = require('./transport/GrpcTransport/GrpcTransport'); -const JsonRpcTransport = require('./transport/JsonRpcTransport/JsonRpcTransport'); +import GrpcTransport from './transport/GrpcTransport/GrpcTransport.js'; +import JsonRpcTransport from './transport/JsonRpcTransport/JsonRpcTransport.js'; -const CoreMethodsFacade = require('./methods/core/CoreMethodsFacade'); -const PlatformMethodsFacade = require('./methods/platform/PlatformMethodsFacade'); +import CoreMethodsFacade from './methods/core/CoreMethodsFacade.js'; +import PlatformMethodsFacade from './methods/platform/PlatformMethodsFacade.js'; -const createDAPIAddressProviderFromOptions = require('./dapiAddressProvider/createDAPIAddressProviderFromOptions'); -const requestJsonRpc = require('./transport/JsonRpcTransport/requestJsonRpc'); -const createGrpcTransportError = require('./transport/GrpcTransport/createGrpcTransportError'); -const createJsonTransportError = require('./transport/JsonRpcTransport/createJsonTransportError'); +import createDAPIAddressProviderFromOptions from './dapiAddressProvider/createDAPIAddressProviderFromOptions.js'; +import requestJsonRpc from './transport/JsonRpcTransport/requestJsonRpc.js'; +import createGrpcTransportError from './transport/GrpcTransport/createGrpcTransportError.js'; +import createJsonTransportError from './transport/JsonRpcTransport/createJsonTransportError.js'; -const BlockHeadersProvider = require('./BlockHeadersProvider/BlockHeadersProvider'); -const createBlockHeadersProviderFromOptions = require('./BlockHeadersProvider/createBlockHeadersProviderFromOptions'); +import BlockHeadersProvider from './BlockHeadersProvider/BlockHeadersProvider.js'; +import createBlockHeadersProviderFromOptions from './BlockHeadersProvider/createBlockHeadersProviderFromOptions.js'; -const logger = require('./logger'); +import logger from './logger/index.js'; const EVENTS = { ERROR: 'error', @@ -120,4 +120,4 @@ DAPIClient.EVENTS = EVENTS; * @property {BlockHeadersProviderOptions} [blockHeadersProviderOptions] */ -module.exports = DAPIClient; +export default DAPIClient; diff --git a/packages/js-dapi-client/lib/SimplifiedMasternodeListProvider/SimplifiedMasternodeListProvider.js b/packages/js-dapi-client/lib/SimplifiedMasternodeListProvider/SimplifiedMasternodeListProvider.js index 3c1c6e20c6b..628952f97b3 100644 --- a/packages/js-dapi-client/lib/SimplifiedMasternodeListProvider/SimplifiedMasternodeListProvider.js +++ b/packages/js-dapi-client/lib/SimplifiedMasternodeListProvider/SimplifiedMasternodeListProvider.js @@ -1,8 +1,9 @@ -const SimplifiedMNList = require('@dashevo/dashcore-lib/lib/deterministicmnlist/SimplifiedMNList'); -const SimplifiedMNListDiff = require('@dashevo/dashcore-lib/lib/deterministicmnlist/SimplifiedMNListDiff'); -const cbor = require('cbor'); +import SimplifiedMNList from '@dashevo/dashcore-lib/lib/deterministicmnlist/SimplifiedMNList.js'; +import SimplifiedMNListDiff from '@dashevo/dashcore-lib/lib/deterministicmnlist/SimplifiedMNListDiff.js'; +import cbor from 'cbor'; -const logger = require('../logger'); +import logger from '../logger/index.js'; +import { bytesToHex } from '../utils/bytes.js'; class SimplifiedMasternodeListProvider { /** @@ -100,11 +101,11 @@ class SimplifiedMasternodeListProvider { let simplifiedMNListDiff; let simplifiedMNListDiffObject; - let simplifiedMNListDiffBuffer; + let simplifiedMNListDiffBytes; try { - simplifiedMNListDiffBuffer = Buffer.from(response.getMasternodeListDiff_asU8()); + simplifiedMNListDiffBytes = new Uint8Array(response.getMasternodeListDiff_asU8()); - simplifiedMNListDiffObject = cbor.decodeFirstSync(simplifiedMNListDiffBuffer); + simplifiedMNListDiffObject = cbor.decodeFirstSync(simplifiedMNListDiffBytes); simplifiedMNListDiff = new SimplifiedMNListDiff( simplifiedMNListDiffObject, @@ -118,7 +119,7 @@ class SimplifiedMasternodeListProvider { network: this.options.network, error: e, simplifiedMNListDiffObject, - simplifiedMNListDiffBytes: simplifiedMNListDiffBuffer.toString('hex'), + simplifiedMNListDiffBytes: bytesToHex(simplifiedMNListDiffBytes), }, ); @@ -218,4 +219,4 @@ class SimplifiedMasternodeListProvider { SimplifiedMasternodeListProvider.NULL_HASH = '0000000000000000000000000000000000000000000000000000000000000000'; -module.exports = SimplifiedMasternodeListProvider; +export default SimplifiedMasternodeListProvider; diff --git a/packages/js-dapi-client/lib/SimplifiedMasternodeListProvider/createMasternodeListStreamFactory.js b/packages/js-dapi-client/lib/SimplifiedMasternodeListProvider/createMasternodeListStreamFactory.js index 67511925dc4..37ebc34deff 100644 --- a/packages/js-dapi-client/lib/SimplifiedMasternodeListProvider/createMasternodeListStreamFactory.js +++ b/packages/js-dapi-client/lib/SimplifiedMasternodeListProvider/createMasternodeListStreamFactory.js @@ -1,13 +1,15 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; + +import GrpcTransport from '../transport/GrpcTransport/GrpcTransport.js'; +import createGrpcTransportError from '../transport/GrpcTransport/createGrpcTransportError.js'; +import ReconnectableStream from '../transport/ReconnectableStream.js'; + const { v0: { MasternodeListRequest, CorePromiseClient, }, -} = require('@dashevo/dapi-grpc'); - -const GrpcTransport = require('../transport/GrpcTransport/GrpcTransport'); -const createGrpcTransportError = require('../transport/GrpcTransport/createGrpcTransportError'); -const ReconnectableStream = require('../transport/ReconnectableStream'); +} = dapiGrpc; /** * Creates continues masternode list stream @@ -46,4 +48,4 @@ function createMasternodeListStreamFactory( ); } -module.exports = createMasternodeListStreamFactory; +export default createMasternodeListStreamFactory; diff --git a/packages/js-dapi-client/lib/dapiAddressProvider/DAPIAddress.js b/packages/js-dapi-client/lib/dapiAddressProvider/DAPIAddress.js index edcebf42b7e..076d9cfe135 100644 --- a/packages/js-dapi-client/lib/dapiAddressProvider/DAPIAddress.js +++ b/packages/js-dapi-client/lib/dapiAddressProvider/DAPIAddress.js @@ -1,4 +1,4 @@ -const DAPIAddressHostMissingError = require('./errors/DAPIAddressHostMissingError'); +import DAPIAddressHostMissingError from './errors/DAPIAddressHostMissingError.js'; class DAPIAddress { /** @@ -171,4 +171,4 @@ DAPIAddress.DEFAULT_PROTOCOL = 'https'; * @property {bool} [selfSigned] */ -module.exports = DAPIAddress; +export default DAPIAddress; diff --git a/packages/js-dapi-client/lib/dapiAddressProvider/ListDAPIAddressProvider.js b/packages/js-dapi-client/lib/dapiAddressProvider/ListDAPIAddressProvider.js index d9133a1ad4c..f78969b2032 100644 --- a/packages/js-dapi-client/lib/dapiAddressProvider/ListDAPIAddressProvider.js +++ b/packages/js-dapi-client/lib/dapiAddressProvider/ListDAPIAddressProvider.js @@ -1,5 +1,6 @@ -const sample = require('lodash/sample'); -const networks = require('@dashevo/dashcore-lib/lib/networks'); +import networks from '@dashevo/dashcore-lib/lib/networks.js'; + +const sample = (arr) => arr[Math.floor(Math.random() * arr.length)]; class ListDAPIAddressProvider { /** @@ -94,4 +95,4 @@ class ListDAPIAddressProvider { } } -module.exports = ListDAPIAddressProvider; +export default ListDAPIAddressProvider; diff --git a/packages/js-dapi-client/lib/dapiAddressProvider/SimplifiedMasternodeListDAPIAddressProvider.js b/packages/js-dapi-client/lib/dapiAddressProvider/SimplifiedMasternodeListDAPIAddressProvider.js index c6607e843eb..a8fb4a82637 100644 --- a/packages/js-dapi-client/lib/dapiAddressProvider/SimplifiedMasternodeListDAPIAddressProvider.js +++ b/packages/js-dapi-client/lib/dapiAddressProvider/SimplifiedMasternodeListDAPIAddressProvider.js @@ -1,4 +1,4 @@ -const DAPIAddress = require('./DAPIAddress'); +import DAPIAddress from './DAPIAddress.js'; class SimplifiedMasternodeListDAPIAddressProvider { /** @@ -72,4 +72,4 @@ class SimplifiedMasternodeListDAPIAddressProvider { } } -module.exports = SimplifiedMasternodeListDAPIAddressProvider; +export default SimplifiedMasternodeListDAPIAddressProvider; diff --git a/packages/js-dapi-client/lib/dapiAddressProvider/createDAPIAddressProviderFromOptions.js b/packages/js-dapi-client/lib/dapiAddressProvider/createDAPIAddressProviderFromOptions.js index 5a02a00b58d..61e8d2f2957 100644 --- a/packages/js-dapi-client/lib/dapiAddressProvider/createDAPIAddressProviderFromOptions.js +++ b/packages/js-dapi-client/lib/dapiAddressProvider/createDAPIAddressProviderFromOptions.js @@ -1,16 +1,16 @@ -const networks = require('@dashevo/dashcore-lib/lib/networks'); +import networks from '@dashevo/dashcore-lib/lib/networks.js'; -const DAPIAddress = require('./DAPIAddress'); +import DAPIAddress from './DAPIAddress.js'; -const ListDAPIAddressProvider = require('./ListDAPIAddressProvider'); +import ListDAPIAddressProvider from './ListDAPIAddressProvider.js'; -const SimplifiedMasternodeListProvider = require('../SimplifiedMasternodeListProvider/SimplifiedMasternodeListProvider'); -const SimplifiedMasternodeListDAPIAddressProvider = require('./SimplifiedMasternodeListDAPIAddressProvider'); -const createMasternodeListStreamFactory = require('../SimplifiedMasternodeListProvider/createMasternodeListStreamFactory'); +import SimplifiedMasternodeListProvider from '../SimplifiedMasternodeListProvider/SimplifiedMasternodeListProvider.js'; +import SimplifiedMasternodeListDAPIAddressProvider from './SimplifiedMasternodeListDAPIAddressProvider.js'; +import createMasternodeListStreamFactory from '../SimplifiedMasternodeListProvider/createMasternodeListStreamFactory.js'; -const DAPIClientError = require('../errors/DAPIClientError'); +import DAPIClientError from '../errors/DAPIClientError.js'; -const networkConfigs = require('../networkConfigs'); +import networkConfigs from '../networkConfigs.js'; /** * @typedef {createDAPIAddressProviderFromOptions} @@ -110,4 +110,4 @@ function createDAPIAddressProviderFromOptions(options) { return null; } -module.exports = createDAPIAddressProviderFromOptions; +export default createDAPIAddressProviderFromOptions; diff --git a/packages/js-dapi-client/lib/dapiAddressProvider/errors/DAPIAddressHostMissingError.js b/packages/js-dapi-client/lib/dapiAddressProvider/errors/DAPIAddressHostMissingError.js index a8feb72082e..a269dbc02ab 100644 --- a/packages/js-dapi-client/lib/dapiAddressProvider/errors/DAPIAddressHostMissingError.js +++ b/packages/js-dapi-client/lib/dapiAddressProvider/errors/DAPIAddressHostMissingError.js @@ -1,4 +1,4 @@ -const DAPIClientError = require('../../errors/DAPIClientError'); +import DAPIClientError from '../../errors/DAPIClientError.js'; class DAPIAddressHostMissingError extends DAPIClientError { constructor() { @@ -6,4 +6,4 @@ class DAPIAddressHostMissingError extends DAPIClientError { } } -module.exports = DAPIAddressHostMissingError; +export default DAPIAddressHostMissingError; diff --git a/packages/js-dapi-client/lib/errors/DAPIClientError.js b/packages/js-dapi-client/lib/errors/DAPIClientError.js index 0d55cc2b212..82904d82eac 100644 --- a/packages/js-dapi-client/lib/errors/DAPIClientError.js +++ b/packages/js-dapi-client/lib/errors/DAPIClientError.js @@ -14,4 +14,4 @@ class DAPIClientError extends Error { } } -module.exports = DAPIClientError; +export default DAPIClientError; diff --git a/packages/js-dapi-client/lib/index.js b/packages/js-dapi-client/lib/index.js index f10beb47695..af12683b9ba 100644 --- a/packages/js-dapi-client/lib/index.js +++ b/packages/js-dapi-client/lib/index.js @@ -1,9 +1,6 @@ -require('../polyfills/fetch-polyfill'); - -const DAPIClient = require('./DAPIClient'); - -const NotFoundError = require('./transport/GrpcTransport/errors/NotFoundError'); -const BlockHeadersProvider = require('./BlockHeadersProvider/BlockHeadersProvider'); +import DAPIClient from './DAPIClient.js'; +import NotFoundError from './transport/GrpcTransport/errors/NotFoundError.js'; +import BlockHeadersProvider from './BlockHeadersProvider/BlockHeadersProvider.js'; DAPIClient.Errors = { NotFoundError, @@ -11,4 +8,5 @@ DAPIClient.Errors = { DAPIClient.BlockHeadersProvider = BlockHeadersProvider; -module.exports = DAPIClient; +export default DAPIClient; +export { NotFoundError, BlockHeadersProvider }; diff --git a/packages/js-dapi-client/lib/logger/index.js b/packages/js-dapi-client/lib/logger/index.js index a06b34c145d..2e03362b5ff 100644 --- a/packages/js-dapi-client/lib/logger/index.js +++ b/packages/js-dapi-client/lib/logger/index.js @@ -1,80 +1,33 @@ -const util = require('util'); -const winston = require('winston'); +const LOG_LEVEL = (typeof process !== 'undefined' && process.env && process.env.LOG_LEVEL) || 'silent'; -// TODO: Refactor to use params instead on envs - -const LOG_LEVEL = process.env.LOG_LEVEL || 'silent'; -const LOG_TO_FILE = process.env.LOG_WALLET_TO_FILE || 'false'; - -// Log levels: -// error 0 -// warn 1 -// info 2 (default) -// verbose 3 -// debug 4 -// silly 5 - -const loggers = {}; - -const createLogger = (formats = [], id = '') => { - const format = winston.format.combine( - { - transform: (info) => { - const args = info[Symbol.for('splat')]; - const result = { ...info }; - if (args) { - result.message = util.format(info.message, ...args); - } - return result; - }, - }, - ...formats, - winston.format.colorize(), - winston.format.printf(({ - level, message, - }) => `${level}: ${message}`), - ); - - const transports = [ - new winston.transports.Console({ - format, - silent: LOG_LEVEL === 'silent', - }), - ]; - - if (LOG_TO_FILE === 'true' && typeof window === 'undefined') { - transports.push( - new winston.transports.File({ - filename: `wallet${id !== '' ? `_${id}` : ''}`, - format, - silent: LOG_LEVEL === 'silent', - }), - ); - } - - return winston.createLogger({ - level: LOG_LEVEL, - transports, - }); +const LEVELS = { + silent: -1, error: 0, warn: 1, info: 2, verbose: 3, debug: 4, silly: 5, }; -const logger = createLogger(); - -logger.getForId = (id) => { - if (!loggers[id]) { - const format = { - transform: (info) => { - const message = `[DAPIClient: ${id}] ${info.message}`; - return { ...info, message }; - }, - }; - - loggers[id] = createLogger([format], id); - } - - return loggers[id]; -}; - -logger.verbose(`Logger uses "${LOG_LEVEL}" level`, { level: LOG_LEVEL }); +const cache = {}; + +function build(level = LOG_LEVEL, prefix = '') { + const threshold = LEVELS[level] != null ? LEVELS[level] : LEVELS.silent; + const noop = () => {}; + const fmt = prefix ? (...a) => [prefix, ...a] : (...a) => a; + + const logger = { + error: threshold >= 0 ? (...a) => console.error(...fmt(...a)) : noop, + warn: threshold >= 1 ? (...a) => console.warn(...fmt(...a)) : noop, + info: threshold >= 2 ? (...a) => console.info(...fmt(...a)) : noop, + verbose: threshold >= 3 ? (...a) => console.debug(...fmt(...a)) : noop, + debug: threshold >= 4 ? (...a) => console.debug(...fmt(...a)) : noop, + silly: threshold >= 5 ? (...a) => console.debug(...fmt(...a)) : noop, + getForId(id, overrideLevel) { + const effective = overrideLevel || level; + const key = `${id}\0${effective}`; + if (!cache[key]) { + cache[key] = build(effective, `[DAPIClient: ${id}]`); + } + return cache[key]; + }, + }; + return logger; +} -module.exports = logger; +export default build(); diff --git a/packages/js-dapi-client/lib/methods/core/CoreMethodsFacade.js b/packages/js-dapi-client/lib/methods/core/CoreMethodsFacade.js index 4aa080cb272..d081b2e1bcc 100644 --- a/packages/js-dapi-client/lib/methods/core/CoreMethodsFacade.js +++ b/packages/js-dapi-client/lib/methods/core/CoreMethodsFacade.js @@ -1,15 +1,15 @@ -const broadcastTransactionFactory = require('./broadcastTransactionFactory'); -const getBestBlockHashFactory = require('./getBestBlockHashFactory'); -const getBestBlockHeightFactory = require('./getBestBlockHeightFactory'); -const getBlockByHashFactory = require('./getBlockByHashFactory'); -const getBlockByHeightFactory = require('./getBlockByHeightFactory'); -const getBlockHashFactory = require('./getBlockHashFactory'); -const getBlockchainStatusFactory = require('./getBlockchainStatusFactory'); -const getMasternodeStatusFactory = require('./getMasternodeStatusFactory'); -const getTransactionFactory = require('./getTransaction/getTransactionFactory'); -const subscribeToTransactionsWithProofsFactory = require('./subscribeToTransactionsWithProofsFactory'); -const subscribeToBlockHeadersWithChainLocksFactory = require('./subscribeToBlockHeadersWithChainLocksFactory'); -const subscribeToToMasternodeListFactory = require('./subscribeToMasternodeListFactory'); +import broadcastTransactionFactory from './broadcastTransactionFactory.js'; +import getBestBlockHashFactory from './getBestBlockHashFactory.js'; +import getBestBlockHeightFactory from './getBestBlockHeightFactory.js'; +import getBlockByHashFactory from './getBlockByHashFactory.js'; +import getBlockByHeightFactory from './getBlockByHeightFactory.js'; +import getBlockHashFactory from './getBlockHashFactory.js'; +import getBlockchainStatusFactory from './getBlockchainStatusFactory.js'; +import getMasternodeStatusFactory from './getMasternodeStatusFactory.js'; +import getTransactionFactory from './getTransaction/getTransactionFactory.js'; +import subscribeToTransactionsWithProofsFactory from './subscribeToTransactionsWithProofsFactory.js'; +import subscribeToBlockHeadersWithChainLocksFactory from './subscribeToBlockHeadersWithChainLocksFactory.js'; +import subscribeToToMasternodeListFactory from './subscribeToMasternodeListFactory.js'; class CoreMethodsFacade { /** @@ -38,4 +38,4 @@ class CoreMethodsFacade { } } -module.exports = CoreMethodsFacade; +export default CoreMethodsFacade; diff --git a/packages/js-dapi-client/lib/methods/core/broadcastTransactionFactory.js b/packages/js-dapi-client/lib/methods/core/broadcastTransactionFactory.js index e4998994e9f..d98e66f82ae 100644 --- a/packages/js-dapi-client/lib/methods/core/broadcastTransactionFactory.js +++ b/packages/js-dapi-client/lib/methods/core/broadcastTransactionFactory.js @@ -1,9 +1,11 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; + const { v0: { CorePromiseClient, BroadcastTransactionRequest, }, -} = require('@dashevo/dapi-grpc'); +} = dapiGrpc; /** * @param {GrpcTransport} grpcTransport @@ -13,7 +15,7 @@ function broadcastTransactionFactory(grpcTransport) { /** * Broadcast Transaction * @typedef {broadcastTransaction} - * @param {Buffer} transaction + * @param {Uint8Array} transaction * @param {DAPIClientOptions & BroadcastTransactionOptions} [options] * @returns {string} */ @@ -42,4 +44,4 @@ function broadcastTransactionFactory(grpcTransport) { * @property {boolean} [bypassLimits=false] */ -module.exports = broadcastTransactionFactory; +export default broadcastTransactionFactory; diff --git a/packages/js-dapi-client/lib/methods/core/getBestBlockHashFactory.js b/packages/js-dapi-client/lib/methods/core/getBestBlockHashFactory.js index ee3f82aa22a..1f6d641283b 100644 --- a/packages/js-dapi-client/lib/methods/core/getBestBlockHashFactory.js +++ b/packages/js-dapi-client/lib/methods/core/getBestBlockHashFactory.js @@ -17,4 +17,4 @@ function getBestBlockHashFactory(jsonRpcTransport) { return getBestBlockHash; } -module.exports = getBestBlockHashFactory; +export default getBestBlockHashFactory; diff --git a/packages/js-dapi-client/lib/methods/core/getBestBlockHeightFactory.js b/packages/js-dapi-client/lib/methods/core/getBestBlockHeightFactory.js index 485010fd33b..15bd0a86600 100644 --- a/packages/js-dapi-client/lib/methods/core/getBestBlockHeightFactory.js +++ b/packages/js-dapi-client/lib/methods/core/getBestBlockHeightFactory.js @@ -1,9 +1,11 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; + const { v0: { GetBestBlockHeightRequest, CorePromiseClient, }, -} = require('@dashevo/dapi-grpc'); +} = dapiGrpc; /** * @@ -31,4 +33,4 @@ function getBestBlockHeightFactory(grpcTransport) { return getBestBlockHeight; } -module.exports = getBestBlockHeightFactory; +export default getBestBlockHeightFactory; diff --git a/packages/js-dapi-client/lib/methods/core/getBlockByHashFactory.js b/packages/js-dapi-client/lib/methods/core/getBlockByHashFactory.js index 72de31354be..8a56f41f40e 100644 --- a/packages/js-dapi-client/lib/methods/core/getBlockByHashFactory.js +++ b/packages/js-dapi-client/lib/methods/core/getBlockByHashFactory.js @@ -1,9 +1,11 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; + const { v0: { GetBlockRequest, CorePromiseClient, }, -} = require('@dashevo/dapi-grpc'); +} = dapiGrpc; /** * @param {GrpcTransport} grpcTransport @@ -15,7 +17,7 @@ function getBlockByHashFactory(grpcTransport) { * @typedef {getBlockByHash} * @param {string} hash * @param {DAPIClientOptions} [options] - * @returns {Promise} + * @returns {Promise} */ async function getBlockByHash(hash, options = {}) { const getBlockRequest = new GetBlockRequest(); @@ -29,10 +31,10 @@ function getBlockByHashFactory(grpcTransport) { ); const blockBinaryArray = response.getBlock(); - return Buffer.from(blockBinaryArray); + return new Uint8Array(blockBinaryArray); } return getBlockByHash; } -module.exports = getBlockByHashFactory; +export default getBlockByHashFactory; diff --git a/packages/js-dapi-client/lib/methods/core/getBlockByHeightFactory.js b/packages/js-dapi-client/lib/methods/core/getBlockByHeightFactory.js index e95a58aeccc..32779a04627 100644 --- a/packages/js-dapi-client/lib/methods/core/getBlockByHeightFactory.js +++ b/packages/js-dapi-client/lib/methods/core/getBlockByHeightFactory.js @@ -1,9 +1,11 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; + const { v0: { GetBlockRequest, CorePromiseClient, }, -} = require('@dashevo/dapi-grpc'); +} = dapiGrpc; /** * @param {GrpcTransport} grpcTransport @@ -15,7 +17,7 @@ function getBlockByHeightFactory(grpcTransport) { * @typedef {getBlockByHeight} * @param {number} height * @param {DAPIClientOptions} [options] - * @returns {Promise} + * @returns {Promise} */ async function getBlockByHeight(height, options = {}) { const getBlockRequest = new GetBlockRequest(); @@ -30,10 +32,10 @@ function getBlockByHeightFactory(grpcTransport) { const blockBinaryArray = response.getBlock(); - return Buffer.from(blockBinaryArray); + return new Uint8Array(blockBinaryArray); } return getBlockByHeight; } -module.exports = getBlockByHeightFactory; +export default getBlockByHeightFactory; diff --git a/packages/js-dapi-client/lib/methods/core/getBlockHashFactory.js b/packages/js-dapi-client/lib/methods/core/getBlockHashFactory.js index 51a6c93ab94..187967cf25e 100644 --- a/packages/js-dapi-client/lib/methods/core/getBlockHashFactory.js +++ b/packages/js-dapi-client/lib/methods/core/getBlockHashFactory.js @@ -17,4 +17,4 @@ function getBlockHashFactory(jsonRpcTransport) { return getBlockHash; } -module.exports = getBlockHashFactory; +export default getBlockHashFactory; diff --git a/packages/js-dapi-client/lib/methods/core/getBlockchainStatusFactory.js b/packages/js-dapi-client/lib/methods/core/getBlockchainStatusFactory.js index 22b1f88e573..cf99fbd3068 100644 --- a/packages/js-dapi-client/lib/methods/core/getBlockchainStatusFactory.js +++ b/packages/js-dapi-client/lib/methods/core/getBlockchainStatusFactory.js @@ -1,10 +1,12 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; + const { v0: { GetBlockchainStatusRequest, GetBlockchainStatusResponse, CorePromiseClient, }, -} = require('@dashevo/dapi-grpc'); +} = dapiGrpc; /** * @param {GrpcTransport} grpcTransport @@ -29,18 +31,18 @@ function getBlockchainStatusFactory(grpcTransport) { const responseObject = response.toObject(); - // Respond with Buffers instead of base64 for binary fields + // Respond with Uint8Arrays instead of base64 for binary fields if (response.getChain()) { if (response.getChain() .getBestBlockHash()) { - responseObject.chain.bestBlockHash = Buffer.from(response.getChain() + responseObject.chain.bestBlockHash = new Uint8Array(response.getChain() .getBestBlockHash()); } if (response.getChain() .getChainWork()) { - responseObject.chain.chainWork = Buffer.from(response.getChain() + responseObject.chain.chainWork = new Uint8Array(response.getChain() .getChainWork()); } } @@ -56,4 +58,4 @@ function getBlockchainStatusFactory(grpcTransport) { return getBlockchainStatus; } -module.exports = getBlockchainStatusFactory; +export default getBlockchainStatusFactory; diff --git a/packages/js-dapi-client/lib/methods/core/getMasternodeStatusFactory.js b/packages/js-dapi-client/lib/methods/core/getMasternodeStatusFactory.js index c0da5feef98..3a178213a5c 100644 --- a/packages/js-dapi-client/lib/methods/core/getMasternodeStatusFactory.js +++ b/packages/js-dapi-client/lib/methods/core/getMasternodeStatusFactory.js @@ -1,10 +1,13 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import { base64ToBytes } from '../../utils/bytes.js'; + const { v0: { GetMasternodeStatusRequest, GetMasternodeStatusResponse, CorePromiseClient, }, -} = require('@dashevo/dapi-grpc'); +} = dapiGrpc; /** * @param {GrpcTransport} grpcTransport @@ -34,7 +37,7 @@ function getMasternodeStatusFactory(grpcTransport) { responseObject.status = Object.keys(GetMasternodeStatusResponse.Status) .find((key) => GetMasternodeStatusResponse.Status[key] === responseObject.status); - responseObject.proTxHash = Buffer.from(responseObject.proTxHash, 'base64'); + responseObject.proTxHash = base64ToBytes(responseObject.proTxHash); return responseObject; } @@ -42,4 +45,4 @@ function getMasternodeStatusFactory(grpcTransport) { return getMasternodeStatus; } -module.exports = getMasternodeStatusFactory; +export default getMasternodeStatusFactory; diff --git a/packages/js-dapi-client/lib/methods/core/getTransaction/GetTransactionResponse.js b/packages/js-dapi-client/lib/methods/core/getTransaction/GetTransactionResponse.js index 9f65b503c39..44e3cdeb7a5 100644 --- a/packages/js-dapi-client/lib/methods/core/getTransaction/GetTransactionResponse.js +++ b/packages/js-dapi-client/lib/methods/core/getTransaction/GetTransactionResponse.js @@ -1,11 +1,11 @@ -const InvalidResponseError = require('../../platform/response/errors/InvalidResponseError'); +import InvalidResponseError from '../../platform/response/errors/InvalidResponseError.js'; class GetTransactionResponse { /** * * @param {object} properties - * @param {Buffer} properties.transaction - * @param {Buffer} properties.blockHash + * @param {Uint8Array} properties.transaction + * @param {Uint8Array} properties.blockHash * @param {number} properties.height * @param {number} properties.confirmations * @param {boolean} properties.isInstantLocked @@ -22,7 +22,7 @@ class GetTransactionResponse { /** * Get transaction - * @returns {Buffer} + * @returns {Uint8Array} */ getTransaction() { return this.transaction; @@ -30,7 +30,7 @@ class GetTransactionResponse { /** * Get block hash - * @returns {Buffer} + * @returns {Uint8Array} */ getBlockHash() { return this.blockHash; @@ -75,8 +75,8 @@ class GetTransactionResponse { } return new GetTransactionResponse({ - transaction: Buffer.from(transactionBinaryArray), - blockHash: Buffer.from(proto.getBlockHash()), + transaction: new Uint8Array(transactionBinaryArray), + blockHash: new Uint8Array(proto.getBlockHash()), height: proto.getHeight(), confirmations: proto.getConfirmations(), isInstantLocked: proto.getIsInstantLocked(), @@ -85,4 +85,4 @@ class GetTransactionResponse { } } -module.exports = GetTransactionResponse; +export default GetTransactionResponse; diff --git a/packages/js-dapi-client/lib/methods/core/getTransaction/getTransactionFactory.js b/packages/js-dapi-client/lib/methods/core/getTransaction/getTransactionFactory.js index a64fc26aa1b..fe0cb9785fd 100644 --- a/packages/js-dapi-client/lib/methods/core/getTransaction/getTransactionFactory.js +++ b/packages/js-dapi-client/lib/methods/core/getTransaction/getTransactionFactory.js @@ -1,12 +1,13 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import GetTransactionResponse from './GetTransactionResponse.js'; +import InvalidResponseError from '../../platform/response/errors/InvalidResponseError.js'; + const { v0: { GetTransactionRequest, CorePromiseClient, }, -} = require('@dashevo/dapi-grpc'); - -const GetTransactionResponse = require('./GetTransactionResponse'); -const InvalidResponseError = require('../../platform/response/errors/InvalidResponseError'); +} = dapiGrpc; /** * @param {GrpcTransport} grpcTransport @@ -18,7 +19,7 @@ function getTransactionFactory(grpcTransport) { * @typedef {getTransaction} * @param {string} id * @param {DAPIClientOptions} [options] - * @returns {Promise} + * @returns {Promise} */ async function getTransaction(id, options = {}) { const getTransactionRequest = new GetTransactionRequest(); @@ -55,4 +56,4 @@ function getTransactionFactory(grpcTransport) { return getTransaction; } -module.exports = getTransactionFactory; +export default getTransactionFactory; diff --git a/packages/js-dapi-client/lib/methods/core/subscribeToBlockHeadersWithChainLocksFactory.js b/packages/js-dapi-client/lib/methods/core/subscribeToBlockHeadersWithChainLocksFactory.js index 397b3ffd939..4e4e0343314 100644 --- a/packages/js-dapi-client/lib/methods/core/subscribeToBlockHeadersWithChainLocksFactory.js +++ b/packages/js-dapi-client/lib/methods/core/subscribeToBlockHeadersWithChainLocksFactory.js @@ -1,11 +1,13 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import DAPIClientError from '../../errors/DAPIClientError.js'; +import { hexToBytes } from '../../utils/bytes.js'; + const { v0: { BlockHeadersWithChainLocksRequest, CorePromiseClient, }, -} = require('@dashevo/dapi-grpc'); - -const DAPIClientError = require('../../errors/DAPIClientError'); +} = dapiGrpc; /** * @param {GrpcTransport} grpcTransport @@ -41,7 +43,7 @@ function subscribeToBlockHeadersWithChainLocksFactory(grpcTransport) { if (options.fromBlockHash) { request.setFromBlockHash( - Buffer.from(options.fromBlockHash, 'hex'), + hexToBytes(options.fromBlockHash), ); } @@ -66,4 +68,4 @@ function subscribeToBlockHeadersWithChainLocksFactory(grpcTransport) { * if set to 0 syncing is continuously sends new data as well */ -module.exports = subscribeToBlockHeadersWithChainLocksFactory; +export default subscribeToBlockHeadersWithChainLocksFactory; diff --git a/packages/js-dapi-client/lib/methods/core/subscribeToMasternodeListFactory.js b/packages/js-dapi-client/lib/methods/core/subscribeToMasternodeListFactory.js index 1d7ba8228a6..b31e7d98967 100644 --- a/packages/js-dapi-client/lib/methods/core/subscribeToMasternodeListFactory.js +++ b/packages/js-dapi-client/lib/methods/core/subscribeToMasternodeListFactory.js @@ -1,9 +1,11 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; + const { v0: { MasternodeListRequest, CorePromiseClient, }, -} = require('@dashevo/dapi-grpc'); +} = dapiGrpc; /** * @param {GrpcTransport} grpcTransport @@ -43,4 +45,4 @@ function subscribeToMasternodeListFactory(grpcTransport) { * @typedef {object} subscribeToMasternodeListOptions */ -module.exports = subscribeToMasternodeListFactory; +export default subscribeToMasternodeListFactory; diff --git a/packages/js-dapi-client/lib/methods/core/subscribeToTransactionsWithProofsFactory.js b/packages/js-dapi-client/lib/methods/core/subscribeToTransactionsWithProofsFactory.js index bf1784291eb..c8aa6f187c5 100644 --- a/packages/js-dapi-client/lib/methods/core/subscribeToTransactionsWithProofsFactory.js +++ b/packages/js-dapi-client/lib/methods/core/subscribeToTransactionsWithProofsFactory.js @@ -1,12 +1,14 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import DAPIClientError from '../../errors/DAPIClientError.js'; +import { hexToBytes } from '../../utils/bytes.js'; + const { v0: { TransactionsWithProofsRequest, CorePromiseClient, BloomFilter: BloomFilterMessage, }, -} = require('@dashevo/dapi-grpc'); - -const DAPIClientError = require('../../errors/DAPIClientError'); +} = dapiGrpc; /** * @param {GrpcTransport} grpcTransport @@ -65,7 +67,7 @@ function subscribeToTransactionsWithProofsFactory(grpcTransport) { if (options.fromBlockHash) { request.setFromBlockHash( - Buffer.from(options.fromBlockHash, 'hex'), + hexToBytes(options.fromBlockHash), ); } @@ -90,4 +92,4 @@ function subscribeToTransactionsWithProofsFactory(grpcTransport) { * if set to 0 syncing is continuously sends new data as well */ -module.exports = subscribeToTransactionsWithProofsFactory; +export default subscribeToTransactionsWithProofsFactory; diff --git a/packages/js-dapi-client/lib/methods/platform/PlatformMethodsFacade.js b/packages/js-dapi-client/lib/methods/platform/PlatformMethodsFacade.js index 8de255abdec..e57ea4494a1 100644 --- a/packages/js-dapi-client/lib/methods/platform/PlatformMethodsFacade.js +++ b/packages/js-dapi-client/lib/methods/platform/PlatformMethodsFacade.js @@ -1,21 +1,21 @@ -const broadcastStateTransitionFactory = require('./broadcastStateTransition/broadcastStateTransitionFactory'); -const getDataContractFactory = require('./getDataContract/getDataContractFactory'); -const getDataContractHistoryFactory = require('./getDataContractHistory/getDataContractHistoryFactory'); -const getDocumentsFactory = require('./getDocuments/getDocumentsFactory'); -const getIdentityFactory = require('./getIdentity/getIdentityFactory'); -const getIdentityByPublicKeyHashFactory = require('./getIdentityByPublicKeyHash/getIdentityByPublicKeyHashFactory'); -const getIdentitiesContractKeysFactory = require('./getIdentitiesContractKeys/getIdentitiesContractKeysFactory'); -const waitForStateTransitionResultFactory = require('./waitForStateTransitionResult/waitForStateTransitionResultFactory'); -const getConsensusParamsFactory = require('./getConsensusParams/getConsensusParamsFactory'); -const getEpochsInfoFactory = require('./getEpochsInfo/getEpochsInfoFactory'); -const getProtocolVersionUpgradeVoteStatusFactory = require('./getProtocolVersionUpgradeVoteStatus/getProtocolVersionUpgradeVoteStatusFactory'); -const getProtocolVersionUpgradeStateFactory = require('./getProtocolVersionUpgradeState/getProtocolVersionUpgradeStateFactory'); -const getIdentityContractNonceFactory = require('./getIdentityContractNonce/getIdentityContractNonceFactory'); -const getIdentityNonceFactory = require('./getIdentityNonce/getIdentityNonceFactory'); -const getIdentityKeysFactory = require('./getIdentityKeys/getIdentityKeysFactory'); -const getTotalCreditsInPlatformFactory = require('./getTotalCreditsInPlatform/getTotalCreditsInPlatformFactory'); -const getStatusFactory = require('./getStatus/getStatusFactory'); -const getIdentityBalanceFactory = require('./getIdentityBalance/getIdentityBalanceFactory'); +import broadcastStateTransitionFactory from './broadcastStateTransition/broadcastStateTransitionFactory.js'; +import getDataContractFactory from './getDataContract/getDataContractFactory.js'; +import getDataContractHistoryFactory from './getDataContractHistory/getDataContractHistoryFactory.js'; +import getDocumentsFactory from './getDocuments/getDocumentsFactory.js'; +import getIdentityFactory from './getIdentity/getIdentityFactory.js'; +import getIdentityByPublicKeyHashFactory from './getIdentityByPublicKeyHash/getIdentityByPublicKeyHashFactory.js'; +import getIdentitiesContractKeysFactory from './getIdentitiesContractKeys/getIdentitiesContractKeysFactory.js'; +import waitForStateTransitionResultFactory from './waitForStateTransitionResult/waitForStateTransitionResultFactory.js'; +import getConsensusParamsFactory from './getConsensusParams/getConsensusParamsFactory.js'; +import getEpochsInfoFactory from './getEpochsInfo/getEpochsInfoFactory.js'; +import getProtocolVersionUpgradeVoteStatusFactory from './getProtocolVersionUpgradeVoteStatus/getProtocolVersionUpgradeVoteStatusFactory.js'; +import getProtocolVersionUpgradeStateFactory from './getProtocolVersionUpgradeState/getProtocolVersionUpgradeStateFactory.js'; +import getIdentityContractNonceFactory from './getIdentityContractNonce/getIdentityContractNonceFactory.js'; +import getIdentityNonceFactory from './getIdentityNonce/getIdentityNonceFactory.js'; +import getIdentityKeysFactory from './getIdentityKeys/getIdentityKeysFactory.js'; +import getTotalCreditsInPlatformFactory from './getTotalCreditsInPlatform/getTotalCreditsInPlatformFactory.js'; +import getStatusFactory from './getStatus/getStatusFactory.js'; +import getIdentityBalanceFactory from './getIdentityBalance/getIdentityBalanceFactory.js'; class PlatformMethodsFacade { /** @@ -45,4 +45,4 @@ class PlatformMethodsFacade { } } -module.exports = PlatformMethodsFacade; +export default PlatformMethodsFacade; diff --git a/packages/js-dapi-client/lib/methods/platform/broadcastStateTransition/BroadcastStateTransitionResponse.js b/packages/js-dapi-client/lib/methods/platform/broadcastStateTransition/BroadcastStateTransitionResponse.js index 3567f2a7427..b4ec0322ee3 100644 --- a/packages/js-dapi-client/lib/methods/platform/broadcastStateTransition/BroadcastStateTransitionResponse.js +++ b/packages/js-dapi-client/lib/methods/platform/broadcastStateTransition/BroadcastStateTransitionResponse.js @@ -7,4 +7,4 @@ class BroadcastStateTransitionResponse { } } -module.exports = BroadcastStateTransitionResponse; +export default BroadcastStateTransitionResponse; diff --git a/packages/js-dapi-client/lib/methods/platform/broadcastStateTransition/broadcastStateTransitionFactory.js b/packages/js-dapi-client/lib/methods/platform/broadcastStateTransition/broadcastStateTransitionFactory.js index f6a715f33b8..c4349023bac 100644 --- a/packages/js-dapi-client/lib/methods/platform/broadcastStateTransition/broadcastStateTransitionFactory.js +++ b/packages/js-dapi-client/lib/methods/platform/broadcastStateTransition/broadcastStateTransitionFactory.js @@ -1,11 +1,13 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import BroadcastStateTransitionResponse from './BroadcastStateTransitionResponse.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; + const { v0: { BroadcastStateTransitionRequest, PlatformPromiseClient, }, -} = require('@dashevo/dapi-grpc'); -const BroadcastStateTransitionResponse = require('./BroadcastStateTransitionResponse'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); +} = dapiGrpc; /** * @param {GrpcTransport} grpcTransport @@ -15,7 +17,7 @@ function broadcastStateTransitionFactory(grpcTransport) { /** * Broadcast State Transaction * @typedef {broadcastStateTransition} - * @param {Buffer} stateTransition + * @param {Uint8Array} stateTransition * @param {DAPIClientOptions} [options] * @returns {Promise} */ @@ -53,4 +55,4 @@ function broadcastStateTransitionFactory(grpcTransport) { return broadcastStateTransition; } -module.exports = broadcastStateTransitionFactory; +export default broadcastStateTransitionFactory; diff --git a/packages/js-dapi-client/lib/methods/platform/getConsensusParams/ConsensusParamsBlock.js b/packages/js-dapi-client/lib/methods/platform/getConsensusParams/ConsensusParamsBlock.js index 31e05d884fb..02bd512958e 100644 --- a/packages/js-dapi-client/lib/methods/platform/getConsensusParams/ConsensusParamsBlock.js +++ b/packages/js-dapi-client/lib/methods/platform/getConsensusParams/ConsensusParamsBlock.js @@ -33,4 +33,4 @@ class ConsensusParamsBlock { } } -module.exports = ConsensusParamsBlock; +export default ConsensusParamsBlock; diff --git a/packages/js-dapi-client/lib/methods/platform/getConsensusParams/ConsensusParamsEvidence.js b/packages/js-dapi-client/lib/methods/platform/getConsensusParams/ConsensusParamsEvidence.js index dd5bd03a6e0..ddb19b6ac18 100644 --- a/packages/js-dapi-client/lib/methods/platform/getConsensusParams/ConsensusParamsEvidence.js +++ b/packages/js-dapi-client/lib/methods/platform/getConsensusParams/ConsensusParamsEvidence.js @@ -33,4 +33,4 @@ class ConsensusParamsEvidence { } } -module.exports = ConsensusParamsEvidence; +export default ConsensusParamsEvidence; diff --git a/packages/js-dapi-client/lib/methods/platform/getConsensusParams/getConsensusParamsFactory.js b/packages/js-dapi-client/lib/methods/platform/getConsensusParams/getConsensusParamsFactory.js index c66ed9874c8..787b5155362 100644 --- a/packages/js-dapi-client/lib/methods/platform/getConsensusParams/getConsensusParamsFactory.js +++ b/packages/js-dapi-client/lib/methods/platform/getConsensusParams/getConsensusParamsFactory.js @@ -1,11 +1,13 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; +import GetConsensusParamsResponse from './getConsensusParamsResponse.js'; + const { v0: { PlatformPromiseClient, GetConsensusParamsRequest, }, -} = require('@dashevo/dapi-grpc'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); -const GetConsensusParamsResponse = require('./getConsensusParamsResponse'); +} = dapiGrpc; const { GetConsensusParamsRequestV0, @@ -66,4 +68,4 @@ function getConsensusParamsFactory(grpcTransport) { return getConsensusParams; } -module.exports = getConsensusParamsFactory; +export default getConsensusParamsFactory; diff --git a/packages/js-dapi-client/lib/methods/platform/getConsensusParams/getConsensusParamsResponse.js b/packages/js-dapi-client/lib/methods/platform/getConsensusParams/getConsensusParamsResponse.js index 0e0dbe25f9a..105eb24a5bd 100644 --- a/packages/js-dapi-client/lib/methods/platform/getConsensusParams/getConsensusParamsResponse.js +++ b/packages/js-dapi-client/lib/methods/platform/getConsensusParams/getConsensusParamsResponse.js @@ -1,6 +1,6 @@ -const InvalidResponseError = require('../response/errors/InvalidResponseError'); -const ConsensusParamsBlock = require('./ConsensusParamsBlock'); -const ConsensusParamsEvidence = require('./ConsensusParamsEvidence'); +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; +import ConsensusParamsBlock from './ConsensusParamsBlock.js'; +import ConsensusParamsEvidence from './ConsensusParamsEvidence.js'; class GetConsensusParamsResponse { /** @@ -58,4 +58,4 @@ class GetConsensusParamsResponse { } } -module.exports = GetConsensusParamsResponse; +export default GetConsensusParamsResponse; diff --git a/packages/js-dapi-client/lib/methods/platform/getDataContract/GetDataContractResponse.js b/packages/js-dapi-client/lib/methods/platform/getDataContract/GetDataContractResponse.js index e1be4b3506e..9ffce5f7032 100644 --- a/packages/js-dapi-client/lib/methods/platform/getDataContract/GetDataContractResponse.js +++ b/packages/js-dapi-client/lib/methods/platform/getDataContract/GetDataContractResponse.js @@ -1,9 +1,9 @@ -const AbstractResponse = require('../response/AbstractResponse'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); +import AbstractResponse from '../response/AbstractResponse.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; class GetDataContractResponse extends AbstractResponse { /** - * @param {Buffer} dataContract + * @param {Uint8Array} dataContract * @param {Metadata} metadata * @param {Proof} [proof] */ @@ -14,7 +14,7 @@ class GetDataContractResponse extends AbstractResponse { } /** - * @returns {Buffer} + * @returns {Uint8Array} */ getDataContract() { return this.dataContract; @@ -33,11 +33,11 @@ class GetDataContractResponse extends AbstractResponse { } return new GetDataContractResponse( - Buffer.from(dataContract), + new Uint8Array(dataContract), metadata, proof, ); } } -module.exports = GetDataContractResponse; +export default GetDataContractResponse; diff --git a/packages/js-dapi-client/lib/methods/platform/getDataContract/getDataContractFactory.js b/packages/js-dapi-client/lib/methods/platform/getDataContract/getDataContractFactory.js index 0966fd05923..7dceeda717b 100644 --- a/packages/js-dapi-client/lib/methods/platform/getDataContract/getDataContractFactory.js +++ b/packages/js-dapi-client/lib/methods/platform/getDataContract/getDataContractFactory.js @@ -1,12 +1,13 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import GetDataContractResponse from './GetDataContractResponse.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; + const { v0: { PlatformPromiseClient, GetDataContractRequest, }, -} = require('@dashevo/dapi-grpc'); - -const GetDataContractResponse = require('./GetDataContractResponse'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); +} = dapiGrpc; /** * @param {GrpcTransport} grpcTransport @@ -16,7 +17,7 @@ function getDataContractFactory(grpcTransport) { /** * Fetch Data Contract by id * @typedef {getDataContract} - * @param {Buffer} contractId + * @param {Uint8Array} contractId * @param {DAPIClientOptions & {prove: boolean}} [options] * @returns {Promise} */ @@ -24,12 +25,12 @@ function getDataContractFactory(grpcTransport) { const { GetDataContractRequestV0 } = GetDataContractRequest; const getDataContractRequest = new GetDataContractRequest(); - // need to convert objects inherited from Buffer to pure buffer as google protobuf + // need to convert objects inherited from Uint8Array to pure Uint8Array as google protobuf // doesn't support extended buffers // https://github.com/protocolbuffers/protobuf/blob/master/js/binary/utils.js#L1049 - if (Buffer.isBuffer(contractId)) { + if (contractId instanceof Uint8Array) { // eslint-disable-next-line no-param-reassign - contractId = Buffer.from(contractId); + contractId = new Uint8Array(contractId); } getDataContractRequest.setV0( @@ -69,4 +70,4 @@ function getDataContractFactory(grpcTransport) { return getDataContract; } -module.exports = getDataContractFactory; +export default getDataContractFactory; diff --git a/packages/js-dapi-client/lib/methods/platform/getDataContractHistory/DataContractHistoryEntry.js b/packages/js-dapi-client/lib/methods/platform/getDataContractHistory/DataContractHistoryEntry.js index b34a49fc98a..a3d6851f2b2 100644 --- a/packages/js-dapi-client/lib/methods/platform/getDataContractHistory/DataContractHistoryEntry.js +++ b/packages/js-dapi-client/lib/methods/platform/getDataContractHistory/DataContractHistoryEntry.js @@ -1,7 +1,7 @@ class DataContractHistoryEntry { /** * @param {bigint} date - timestamp - * @param {Buffer} value - buffer value of the data contract + * @param {Uint8Array} value - byte value of the data contract */ constructor(date, value) { this.date = date; @@ -16,11 +16,11 @@ class DataContractHistoryEntry { } /** - * @returns {Buffer} - raw binary value of the data contract + * @returns {Uint8Array} - raw binary value of the data contract */ getValue() { return this.value; } } -module.exports = DataContractHistoryEntry; +export default DataContractHistoryEntry; diff --git a/packages/js-dapi-client/lib/methods/platform/getDataContractHistory/GetDataContractHistoryResponse.js b/packages/js-dapi-client/lib/methods/platform/getDataContractHistory/GetDataContractHistoryResponse.js index 1dfbb0747c0..b25e61c21b7 100644 --- a/packages/js-dapi-client/lib/methods/platform/getDataContractHistory/GetDataContractHistoryResponse.js +++ b/packages/js-dapi-client/lib/methods/platform/getDataContractHistory/GetDataContractHistoryResponse.js @@ -1,6 +1,6 @@ -const AbstractResponse = require('../response/AbstractResponse'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); -const DataContractHistoryEntry = require('./DataContractHistoryEntry'); +import AbstractResponse from '../response/AbstractResponse.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; +import DataContractHistoryEntry from './DataContractHistoryEntry.js'; class GetDataContractHistoryResponse extends AbstractResponse { /** @@ -46,4 +46,4 @@ class GetDataContractHistoryResponse extends AbstractResponse { } } -module.exports = GetDataContractHistoryResponse; +export default GetDataContractHistoryResponse; diff --git a/packages/js-dapi-client/lib/methods/platform/getDataContractHistory/getDataContractHistoryFactory.js b/packages/js-dapi-client/lib/methods/platform/getDataContractHistory/getDataContractHistoryFactory.js index 1059c74bd58..926838de539 100644 --- a/packages/js-dapi-client/lib/methods/platform/getDataContractHistory/getDataContractHistoryFactory.js +++ b/packages/js-dapi-client/lib/methods/platform/getDataContractHistory/getDataContractHistoryFactory.js @@ -1,14 +1,17 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import wrappersPb from 'google-protobuf/google/protobuf/wrappers_pb.js'; +import GetDataContractHistoryResponse from './GetDataContractHistoryResponse.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; + const { v0: { PlatformPromiseClient, GetDataContractHistoryRequest, }, -} = require('@dashevo/dapi-grpc'); +} = dapiGrpc; -const { UInt32Value } = require('google-protobuf/google/protobuf/wrappers_pb'); +const { UInt32Value } = wrappersPb; -const GetDataContractHistoryResponse = require('./GetDataContractHistoryResponse'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); /** * @param {GrpcTransport} grpcTransport * @returns {getDataContractHistory} @@ -17,7 +20,7 @@ function getDataContractHistoryFactory(grpcTransport) { /** * Fetch Data Contract by id * @typedef {getDataContractHistory} - * @param {Buffer} contractId + * @param {Uint8Array} contractId * @param {bigint} [startAtMs] * @param {number} [limit] * @param {number} [offset] @@ -34,12 +37,12 @@ function getDataContractHistoryFactory(grpcTransport) { const { GetDataContractHistoryRequestV0 } = GetDataContractHistoryRequest; const getDataContractHistoryRequest = new GetDataContractHistoryRequest(); - // need to convert objects inherited from Buffer to pure buffer as google protobuf + // need to convert objects inherited from Uint8Array to pure Uint8Array as google protobuf // doesn't support extended buffers // https://github.com/protocolbuffers/protobuf/blob/master/js/binary/utils.js#L1049 - if (Buffer.isBuffer(contractId)) { + if (contractId instanceof Uint8Array) { // eslint-disable-next-line no-param-reassign - contractId = Buffer.from(contractId); + contractId = new Uint8Array(contractId); } getDataContractHistoryRequest.setV0( @@ -82,4 +85,4 @@ function getDataContractHistoryFactory(grpcTransport) { return getDataContractHistory; } -module.exports = getDataContractHistoryFactory; +export default getDataContractHistoryFactory; diff --git a/packages/js-dapi-client/lib/methods/platform/getDocuments/GetDocumentsResponse.js b/packages/js-dapi-client/lib/methods/platform/getDocuments/GetDocumentsResponse.js index 5340a5d3b0d..5b45ee80a41 100644 --- a/packages/js-dapi-client/lib/methods/platform/getDocuments/GetDocumentsResponse.js +++ b/packages/js-dapi-client/lib/methods/platform/getDocuments/GetDocumentsResponse.js @@ -1,8 +1,8 @@ -const AbstractResponse = require('../response/AbstractResponse'); +import AbstractResponse from '../response/AbstractResponse.js'; class GetDocumentsResponse extends AbstractResponse { /** - * @param {Buffer[]} documents + * @param {Uint8Array[]} documents * @param {Metadata} metadata * @param {Proof} [proof] */ @@ -13,7 +13,7 @@ class GetDocumentsResponse extends AbstractResponse { } /** - * @returns {Buffer[]} + * @returns {Uint8Array[]} */ getDocuments() { return this.documents; @@ -30,11 +30,11 @@ class GetDocumentsResponse extends AbstractResponse { return new GetDocumentsResponse( documents !== undefined - ? documents.getDocumentsList().map((document) => Buffer.from(document)) : [], + ? documents.getDocumentsList().map((document) => new Uint8Array(document)) : [], metadata, proof, ); } } -module.exports = GetDocumentsResponse; +export default GetDocumentsResponse; diff --git a/packages/js-dapi-client/lib/methods/platform/getDocuments/getDocumentsFactory.js b/packages/js-dapi-client/lib/methods/platform/getDocuments/getDocumentsFactory.js index 4c086b21f78..48a8d09a742 100644 --- a/packages/js-dapi-client/lib/methods/platform/getDocuments/getDocumentsFactory.js +++ b/packages/js-dapi-client/lib/methods/platform/getDocuments/getDocumentsFactory.js @@ -1,14 +1,14 @@ -const cbor = require('cbor'); +import cbor from 'cbor'; +import dapiGrpc from '@dashevo/dapi-grpc'; +import GetDocumentsResponse from './GetDocumentsResponse.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; const { v0: { PlatformPromiseClient, GetDocumentsRequest, }, -} = require('@dashevo/dapi-grpc'); - -const GetDocumentsResponse = require('./GetDocumentsResponse'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); +} = dapiGrpc; /** * @param {GrpcTransport} grpcTransport @@ -18,7 +18,7 @@ function getDocumentsFactory(grpcTransport) { /** * Fetch Documents from Drive * @typedef {getDocuments} - * @param {Buffer} contractId - Data Contract ID + * @param {Uint8Array} contractId - Data Contract ID * @param {string} type - Document type * @param {DAPIClientOptions & getDocumentsOptions & {prove: boolean}} [options] * @returns {Promise} @@ -44,15 +44,16 @@ function getDocumentsFactory(grpcTransport) { const { GetDocumentsRequestV0 } = GetDocumentsRequest; const getDocumentsRequest = new GetDocumentsRequest(); - // need to convert Identifier to pure buffer as google protobuf doesn't support extended buffers + // need to convert Identifier to pure Uint8Array as google protobuf doesn't support + // extended buffers // https://github.com/protocolbuffers/protobuf/blob/master/js/binary/utils.js#L1049 - // need to convert objects inherited from Buffer to pure buffer as google protobuf + // need to convert objects inherited from Uint8Array to pure Uint8Array as google protobuf // doesn't support extended buffers // https://github.com/protocolbuffers/protobuf/blob/master/js/binary/utils.js#L1049 - if (Buffer.isBuffer(contractId)) { + if (contractId instanceof Uint8Array) { // eslint-disable-next-line no-param-reassign - contractId = Buffer.from(contractId); + contractId = new Uint8Array(contractId); } getDocumentsRequest.setV0( @@ -107,4 +108,4 @@ function getDocumentsFactory(grpcTransport) { * @property {object} [startAfter] */ -module.exports = getDocumentsFactory; +export default getDocumentsFactory; diff --git a/packages/js-dapi-client/lib/methods/platform/getEpochsInfo/EpochInfo.js b/packages/js-dapi-client/lib/methods/platform/getEpochsInfo/EpochInfo.js index 61bd651c75f..4dc2a6d788e 100644 --- a/packages/js-dapi-client/lib/methods/platform/getEpochsInfo/EpochInfo.js +++ b/packages/js-dapi-client/lib/methods/platform/getEpochsInfo/EpochInfo.js @@ -51,4 +51,4 @@ class EpochInfo { } } -module.exports = EpochInfo; +export default EpochInfo; diff --git a/packages/js-dapi-client/lib/methods/platform/getEpochsInfo/GetEpochsInfoResponse.js b/packages/js-dapi-client/lib/methods/platform/getEpochsInfo/GetEpochsInfoResponse.js index 3db067e1a77..a39765ae22a 100644 --- a/packages/js-dapi-client/lib/methods/platform/getEpochsInfo/GetEpochsInfoResponse.js +++ b/packages/js-dapi-client/lib/methods/platform/getEpochsInfo/GetEpochsInfoResponse.js @@ -1,6 +1,6 @@ -const AbstractResponse = require('../response/AbstractResponse'); -const EpochInfo = require('./EpochInfo'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); +import AbstractResponse from '../response/AbstractResponse.js'; +import EpochInfo from './EpochInfo.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; class GetEpochsInfoResponse extends AbstractResponse { /** @@ -56,4 +56,4 @@ class GetEpochsInfoResponse extends AbstractResponse { } } -module.exports = GetEpochsInfoResponse; +export default GetEpochsInfoResponse; diff --git a/packages/js-dapi-client/lib/methods/platform/getEpochsInfo/getEpochsInfoFactory.js b/packages/js-dapi-client/lib/methods/platform/getEpochsInfo/getEpochsInfoFactory.js index 9982c6f9e6a..bb837b06f71 100644 --- a/packages/js-dapi-client/lib/methods/platform/getEpochsInfo/getEpochsInfoFactory.js +++ b/packages/js-dapi-client/lib/methods/platform/getEpochsInfo/getEpochsInfoFactory.js @@ -1,14 +1,16 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import wrappersPb from 'google-protobuf/google/protobuf/wrappers_pb.js'; +import GetEpochsInfoResponse from './GetEpochsInfoResponse.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; + const { v0: { PlatformPromiseClient, GetEpochsInfoRequest, }, -} = require('@dashevo/dapi-grpc'); - -const { UInt32Value } = require('google-protobuf/google/protobuf/wrappers_pb'); +} = dapiGrpc; -const GetEpochsInfoResponse = require('./GetEpochsInfoResponse'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); +const { UInt32Value } = wrappersPb; /** * @param {GrpcTransport} grpcTransport @@ -65,4 +67,4 @@ function getEpochsInfoFactory(grpcTransport) { return getEpochsInfo; } -module.exports = getEpochsInfoFactory; +export default getEpochsInfoFactory; diff --git a/packages/js-dapi-client/lib/methods/platform/getIdentitiesContractKeys/GetIdentitiesContractKeysResponse.js b/packages/js-dapi-client/lib/methods/platform/getIdentitiesContractKeys/GetIdentitiesContractKeysResponse.js index 4fd843f6f92..c5c104524d6 100644 --- a/packages/js-dapi-client/lib/methods/platform/getIdentitiesContractKeys/GetIdentitiesContractKeysResponse.js +++ b/packages/js-dapi-client/lib/methods/platform/getIdentitiesContractKeys/GetIdentitiesContractKeysResponse.js @@ -1,5 +1,7 @@ -const { Identifier } = require('@dashevo/wasm-dpp'); -const AbstractResponse = require('../response/AbstractResponse'); +import wasmDpp from '@dashevo/wasm-dpp'; +import AbstractResponse from '../response/AbstractResponse.js'; + +const { Identifier } = wasmDpp; class GetIdentitiesContractKeysResponse extends AbstractResponse { /** @@ -34,6 +36,7 @@ class GetIdentitiesContractKeysResponse extends AbstractResponse { const keysEntries = identitiesKeys.getEntriesList(); identitiesKeysMap = keysEntries.reduce((acc, entry) => { + // wasm-dpp Identifier.from requires Node Buffer (not plain Uint8Array) const identityId = Identifier.from(Buffer.from(entry.getIdentityId())).toString(); if (!acc[identityId]) { acc[identityId] = {}; @@ -62,4 +65,4 @@ class GetIdentitiesContractKeysResponse extends AbstractResponse { } } -module.exports = GetIdentitiesContractKeysResponse; +export default GetIdentitiesContractKeysResponse; diff --git a/packages/js-dapi-client/lib/methods/platform/getIdentitiesContractKeys/getIdentitiesContractKeysFactory.js b/packages/js-dapi-client/lib/methods/platform/getIdentitiesContractKeys/getIdentitiesContractKeysFactory.js index 47140bfe0cc..ed5e3c2b077 100644 --- a/packages/js-dapi-client/lib/methods/platform/getIdentitiesContractKeys/getIdentitiesContractKeysFactory.js +++ b/packages/js-dapi-client/lib/methods/platform/getIdentitiesContractKeys/getIdentitiesContractKeysFactory.js @@ -1,13 +1,13 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import GetIdentitiesContractKeysResponse from './GetIdentitiesContractKeysResponse.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; + const { v0: { PlatformPromiseClient, GetIdentitiesContractKeysRequest, }, -} = require('@dashevo/dapi-grpc'); -const { IdentityPublicKey } = require('@dashevo/wasm-dpp'); - -const GetIdentitiesContractKeysResponse = require('./GetIdentitiesContractKeysResponse'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); +} = dapiGrpc; /** * @param {GrpcTransport} grpcTransport @@ -17,8 +17,8 @@ function getIdentitiesContractKeysFactory(grpcTransport) { /** * Fetch the identities by public key hashes * @typedef {getIdentitiesContractKeys} - * @param {Buffer[]} identitiesIds - * @param {Buffer} contractId + * @param {Uint8Array[]} identitiesIds + * @param {Uint8Array} contractId * @param {IdentityPublicKey.PURPOSES[]} keyPurposes * @param {string | null} documentTypeName * @param {DAPIClientOptions & {prove: boolean}} [options] @@ -36,17 +36,16 @@ function getIdentitiesContractKeysFactory(grpcTransport) { // eslint-disable-next-line no-param-reassign identitiesIds = identitiesIds.map((id) => { - if (Buffer.isBuffer(id)) { - // eslint-disable-next-line no-param-reassign - id = Buffer.from(id); + if (id instanceof Uint8Array) { + return new Uint8Array(id); } return id; }); - if (Buffer.isBuffer(contractId)) { + if (contractId instanceof Uint8Array) { // eslint-disable-next-line no-param-reassign - contractId = Buffer.from(contractId); + contractId = new Uint8Array(contractId); } getIdentitiesContractKeysRequest.setV0( @@ -90,4 +89,4 @@ function getIdentitiesContractKeysFactory(grpcTransport) { return getIdentitiesContractKeys; } -module.exports = getIdentitiesContractKeysFactory; +export default getIdentitiesContractKeysFactory; diff --git a/packages/js-dapi-client/lib/methods/platform/getIdentity/GetIdentityResponse.js b/packages/js-dapi-client/lib/methods/platform/getIdentity/GetIdentityResponse.js index 718633fb569..bc170f9ae2d 100644 --- a/packages/js-dapi-client/lib/methods/platform/getIdentity/GetIdentityResponse.js +++ b/packages/js-dapi-client/lib/methods/platform/getIdentity/GetIdentityResponse.js @@ -1,9 +1,9 @@ -const AbstractResponse = require('../response/AbstractResponse'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); +import AbstractResponse from '../response/AbstractResponse.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; class GetIdentityResponse extends AbstractResponse { /** - * @param {Buffer} identity + * @param {Uint8Array} identity * @param {Metadata} metadata * @param {Proof} [proof] */ @@ -14,7 +14,7 @@ class GetIdentityResponse extends AbstractResponse { } /** - * @returns {Buffer} + * @returns {Uint8Array} */ getIdentity() { return this.identity; @@ -33,11 +33,11 @@ class GetIdentityResponse extends AbstractResponse { } return new GetIdentityResponse( - Buffer.from(proto.getV0().getIdentity()), + new Uint8Array(proto.getV0().getIdentity()), metadata, proof, ); } } -module.exports = GetIdentityResponse; +export default GetIdentityResponse; diff --git a/packages/js-dapi-client/lib/methods/platform/getIdentity/getIdentityFactory.js b/packages/js-dapi-client/lib/methods/platform/getIdentity/getIdentityFactory.js index 6179fe0233e..1f0d99a31c3 100644 --- a/packages/js-dapi-client/lib/methods/platform/getIdentity/getIdentityFactory.js +++ b/packages/js-dapi-client/lib/methods/platform/getIdentity/getIdentityFactory.js @@ -1,12 +1,13 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import GetIdentityResponse from './GetIdentityResponse.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; + const { v0: { PlatformPromiseClient, GetIdentityRequest, }, -} = require('@dashevo/dapi-grpc'); - -const GetIdentityResponse = require('./GetIdentityResponse'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); +} = dapiGrpc; /** * @param {GrpcTransport} grpcTransport @@ -16,19 +17,19 @@ function getIdentityFactory(grpcTransport) { /** * Fetch the identity by id * @typedef {getIdentity} - * @param {Buffer} id + * @param {Uint8Array} id * @param {DAPIClientOptions & {prove: boolean}} [options] * @returns {Promise} */ async function getIdentity(id, options = {}) { const { GetIdentityRequestV0 } = GetIdentityRequest; const getIdentityRequest = new GetIdentityRequest(); - // need to convert objects inherited from Buffer to pure buffer as google protobuf + // need to convert objects inherited from Uint8Array to pure Uint8Array as google protobuf // doesn't support extended buffers // https://github.com/protocolbuffers/protobuf/blob/master/js/binary/utils.js#L1049 - if (Buffer.isBuffer(id)) { + if (id instanceof Uint8Array) { // eslint-disable-next-line no-param-reassign - id = Buffer.from(id); + id = new Uint8Array(id); } getIdentityRequest.setV0( @@ -68,4 +69,4 @@ function getIdentityFactory(grpcTransport) { return getIdentity; } -module.exports = getIdentityFactory; +export default getIdentityFactory; diff --git a/packages/js-dapi-client/lib/methods/platform/getIdentityBalance/GetIdentityBalanceResponse.js b/packages/js-dapi-client/lib/methods/platform/getIdentityBalance/GetIdentityBalanceResponse.js index 76c0f4e4a53..afcb1b390cf 100644 --- a/packages/js-dapi-client/lib/methods/platform/getIdentityBalance/GetIdentityBalanceResponse.js +++ b/packages/js-dapi-client/lib/methods/platform/getIdentityBalance/GetIdentityBalanceResponse.js @@ -1,5 +1,5 @@ -const AbstractResponse = require('../response/AbstractResponse'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); +import AbstractResponse from '../response/AbstractResponse.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; class GetIdentityBalanceResponse extends AbstractResponse { /** @@ -40,4 +40,4 @@ class GetIdentityBalanceResponse extends AbstractResponse { } } -module.exports = GetIdentityBalanceResponse; +export default GetIdentityBalanceResponse; diff --git a/packages/js-dapi-client/lib/methods/platform/getIdentityBalance/getIdentityBalanceFactory.js b/packages/js-dapi-client/lib/methods/platform/getIdentityBalance/getIdentityBalanceFactory.js index 93862ccff9a..e8c62749fc5 100644 --- a/packages/js-dapi-client/lib/methods/platform/getIdentityBalance/getIdentityBalanceFactory.js +++ b/packages/js-dapi-client/lib/methods/platform/getIdentityBalance/getIdentityBalanceFactory.js @@ -1,12 +1,13 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import GetIdentityBalanceResponse from './GetIdentityBalanceResponse.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; + const { v0: { PlatformPromiseClient, GetIdentityBalanceRequest, }, -} = require('@dashevo/dapi-grpc'); - -const GetIdentityBalanceResponse = require('./GetIdentityBalanceResponse'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); +} = dapiGrpc; /** * @param {GrpcTransport} grpcTransport @@ -16,19 +17,19 @@ function getIdentityBalanceFactory(grpcTransport) { /** * Fetch the identity balance by id * @typedef {getIdentityBalance} - * @param {Buffer} id + * @param {Uint8Array} id * @param {DAPIClientOptions & {prove: boolean}} [options] * @returns {Promise} */ async function getIdentityBalance(id, options = {}) { const { GetIdentityBalanceRequestV0 } = GetIdentityBalanceRequest; const getIdentityBalanceRequest = new GetIdentityBalanceRequest(); - // need to convert objects inherited from Buffer to pure buffer as google protobuf + // need to convert objects inherited from Uint8Array to pure Uint8Array as google protobuf // doesn't support extended buffers // https://github.com/protocolbuffers/protobuf/blob/master/js/binary/utils.js#L1049 - if (Buffer.isBuffer(id)) { + if (id instanceof Uint8Array) { // eslint-disable-next-line no-param-reassign - id = Buffer.from(id); + id = new Uint8Array(id); } getIdentityBalanceRequest.setV0( @@ -68,4 +69,4 @@ function getIdentityBalanceFactory(grpcTransport) { return getIdentityBalance; } -module.exports = getIdentityBalanceFactory; +export default getIdentityBalanceFactory; diff --git a/packages/js-dapi-client/lib/methods/platform/getIdentityByPublicKeyHash/GetIdentityByPublicKeyHashResponse.js b/packages/js-dapi-client/lib/methods/platform/getIdentityByPublicKeyHash/GetIdentityByPublicKeyHashResponse.js index 86f97aecfe7..174175931e3 100644 --- a/packages/js-dapi-client/lib/methods/platform/getIdentityByPublicKeyHash/GetIdentityByPublicKeyHashResponse.js +++ b/packages/js-dapi-client/lib/methods/platform/getIdentityByPublicKeyHash/GetIdentityByPublicKeyHashResponse.js @@ -1,8 +1,8 @@ -const AbstractResponse = require('../response/AbstractResponse'); +import AbstractResponse from '../response/AbstractResponse.js'; class GetIdentityByPublicKeyHashResponse extends AbstractResponse { /** - * @param {Buffer} identities + * @param {Uint8Array} identities * @param identity * @param {Metadata} metadata * @param {Proof} [proof] @@ -14,7 +14,7 @@ class GetIdentityByPublicKeyHashResponse extends AbstractResponse { } /** - * @returns {Buffer[]} + * @returns {Uint8Array[]} */ getIdentity() { return this.identity; @@ -30,11 +30,11 @@ class GetIdentityByPublicKeyHashResponse extends AbstractResponse { const identity = proto.getV0().getIdentity(); return new GetIdentityByPublicKeyHashResponse( - Buffer.from(identity), + new Uint8Array(identity), metadata, proof, ); } } -module.exports = GetIdentityByPublicKeyHashResponse; +export default GetIdentityByPublicKeyHashResponse; diff --git a/packages/js-dapi-client/lib/methods/platform/getIdentityByPublicKeyHash/getIdentityByPublicKeyHashFactory.js b/packages/js-dapi-client/lib/methods/platform/getIdentityByPublicKeyHash/getIdentityByPublicKeyHashFactory.js index ed3ca1fca7e..dfbcf1ede39 100644 --- a/packages/js-dapi-client/lib/methods/platform/getIdentityByPublicKeyHash/getIdentityByPublicKeyHashFactory.js +++ b/packages/js-dapi-client/lib/methods/platform/getIdentityByPublicKeyHash/getIdentityByPublicKeyHashFactory.js @@ -1,12 +1,13 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import GetIdentityByPublicKeyHashResponse from './GetIdentityByPublicKeyHashResponse.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; + const { v0: { PlatformPromiseClient, GetIdentityByPublicKeyHashRequest, }, -} = require('@dashevo/dapi-grpc'); - -const GetIdentityByPublicKeyHashResponse = require('./GetIdentityByPublicKeyHashResponse'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); +} = dapiGrpc; /** * @param {GrpcTransport} grpcTransport @@ -16,7 +17,7 @@ function getIdentityByPublicKeyHashFactory(grpcTransport) { /** * Fetch the identity by public key hash * @typedef {getIdentityByPublicKeyHash} - * @param {Buffer} publicKeyHash + * @param {Uint8Array} publicKeyHash * @param {DAPIClientOptions & {prove: boolean}} [options] * @returns {Promise} */ @@ -61,4 +62,4 @@ function getIdentityByPublicKeyHashFactory(grpcTransport) { return getIdentityByPublicKeyHash; } -module.exports = getIdentityByPublicKeyHashFactory; +export default getIdentityByPublicKeyHashFactory; diff --git a/packages/js-dapi-client/lib/methods/platform/getIdentityContractNonce/GetIdentityContractNonceResponse.js b/packages/js-dapi-client/lib/methods/platform/getIdentityContractNonce/GetIdentityContractNonceResponse.js index 0cca1d9708e..e65233f929c 100644 --- a/packages/js-dapi-client/lib/methods/platform/getIdentityContractNonce/GetIdentityContractNonceResponse.js +++ b/packages/js-dapi-client/lib/methods/platform/getIdentityContractNonce/GetIdentityContractNonceResponse.js @@ -1,5 +1,5 @@ -const AbstractResponse = require('../response/AbstractResponse'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); +import AbstractResponse from '../response/AbstractResponse.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; const IDENTITY_CONTRACT_NONCE_VALUE_FILTER = BigInt(0xFFFFFFFFFF); @@ -46,4 +46,4 @@ class GetIdentityContractNonceResponse extends AbstractResponse { } } -module.exports = GetIdentityContractNonceResponse; +export default GetIdentityContractNonceResponse; diff --git a/packages/js-dapi-client/lib/methods/platform/getIdentityContractNonce/getIdentityContractNonceFactory.js b/packages/js-dapi-client/lib/methods/platform/getIdentityContractNonce/getIdentityContractNonceFactory.js index 59aec51dc87..337a727f2ca 100644 --- a/packages/js-dapi-client/lib/methods/platform/getIdentityContractNonce/getIdentityContractNonceFactory.js +++ b/packages/js-dapi-client/lib/methods/platform/getIdentityContractNonce/getIdentityContractNonceFactory.js @@ -1,12 +1,13 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import GetIdentityContractNonceResponse from './GetIdentityContractNonceResponse.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; + const { v0: { PlatformPromiseClient, GetIdentityContractNonceRequest, }, -} = require('@dashevo/dapi-grpc'); - -const GetIdentityContractNonceResponse = require('./GetIdentityContractNonceResponse'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); +} = dapiGrpc; /** * @param {GrpcTransport} grpcTransport @@ -16,8 +17,8 @@ function getIdentityContractNonceFactory(grpcTransport) { /** * Fetch the version upgrade votes status * @typedef {getIdentityContractNonce} - * @param {Buffer} identityId - * @param {Buffer} contractId + * @param {Uint8Array} identityId + * @param {Uint8Array} contractId * @param {DAPIClientOptions & {prove: boolean}} [options] * @returns {Promise} */ @@ -29,14 +30,14 @@ function getIdentityContractNonceFactory(grpcTransport) { // eslint-disable-next-line max-len const getIdentityContractNonceRequest = new GetIdentityContractNonceRequest(); - if (Buffer.isBuffer(identityId)) { + if (identityId instanceof Uint8Array) { // eslint-disable-next-line no-param-reassign - identityId = Buffer.from(identityId); + identityId = new Uint8Array(identityId); } - if (Buffer.isBuffer(contractId)) { + if (contractId instanceof Uint8Array) { // eslint-disable-next-line no-param-reassign - contractId = Buffer.from(contractId); + contractId = new Uint8Array(contractId); } getIdentityContractNonceRequest.setV0( @@ -78,4 +79,4 @@ function getIdentityContractNonceFactory(grpcTransport) { return getIdentityContractNonce; } -module.exports = getIdentityContractNonceFactory; +export default getIdentityContractNonceFactory; diff --git a/packages/js-dapi-client/lib/methods/platform/getIdentityKeys/GetIdentityKeysResponse.js b/packages/js-dapi-client/lib/methods/platform/getIdentityKeys/GetIdentityKeysResponse.js index de377cfdfb5..ca59c52eded 100644 --- a/packages/js-dapi-client/lib/methods/platform/getIdentityKeys/GetIdentityKeysResponse.js +++ b/packages/js-dapi-client/lib/methods/platform/getIdentityKeys/GetIdentityKeysResponse.js @@ -1,5 +1,5 @@ -const AbstractResponse = require('../response/AbstractResponse'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); +import AbstractResponse from '../response/AbstractResponse.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; class GetIdentityKeysResponse extends AbstractResponse { /** @@ -49,4 +49,4 @@ class GetIdentityKeysResponse extends AbstractResponse { } } -module.exports = GetIdentityKeysResponse; +export default GetIdentityKeysResponse; diff --git a/packages/js-dapi-client/lib/methods/platform/getIdentityKeys/getIdentityKeysFactory.js b/packages/js-dapi-client/lib/methods/platform/getIdentityKeys/getIdentityKeysFactory.js index 4bc32a03a65..e31f95e78d7 100644 --- a/packages/js-dapi-client/lib/methods/platform/getIdentityKeys/getIdentityKeysFactory.js +++ b/packages/js-dapi-client/lib/methods/platform/getIdentityKeys/getIdentityKeysFactory.js @@ -1,3 +1,8 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import wrappersPb from 'google-protobuf/google/protobuf/wrappers_pb.js'; +import GetIdentityKeysResponse from './GetIdentityKeysResponse.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; + const { v0: { PlatformPromiseClient, @@ -6,15 +11,12 @@ const { SpecificKeys, AllKeys, }, -} = require('@dashevo/dapi-grpc'); +} = dapiGrpc; -const { UInt32Value } = require('google-protobuf/google/protobuf/wrappers_pb'); +const { UInt32Value } = wrappersPb; const { GetIdentityKeysRequestV0 } = GetIdentityKeysRequest; -const GetIdentityKeysResponse = require('./GetIdentityKeysResponse'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); - /** * @param {GrpcTransport} grpcTransport * @returns {getIdentityKeys} @@ -23,16 +25,16 @@ function getIdentityKeysFactory(grpcTransport) { /** * Fetch the version upgrade votes status * @typedef {getIdentityKeys} - * @param {Buffer} identityId + * @param {Uint8Array} identityId * @param {number[]=} keyIds * @param {number} limit * @param {DAPIClientOptions & {prove: boolean}} [options] * @returns {Promise} */ async function getIdentityKeys(identityId, keyIds, limit = 100, options = {}) { - if (Buffer.isBuffer(identityId)) { + if (identityId instanceof Uint8Array) { // eslint-disable-next-line no-param-reassign - identityId = Buffer.from(identityId); + identityId = new Uint8Array(identityId); } const getIdentityKeysRequest = new GetIdentityKeysRequest(); @@ -84,4 +86,4 @@ function getIdentityKeysFactory(grpcTransport) { return getIdentityKeys; } -module.exports = getIdentityKeysFactory; +export default getIdentityKeysFactory; diff --git a/packages/js-dapi-client/lib/methods/platform/getIdentityNonce/GetIdentityNonceResponse.js b/packages/js-dapi-client/lib/methods/platform/getIdentityNonce/GetIdentityNonceResponse.js index daead898b39..fbc4057c0d9 100644 --- a/packages/js-dapi-client/lib/methods/platform/getIdentityNonce/GetIdentityNonceResponse.js +++ b/packages/js-dapi-client/lib/methods/platform/getIdentityNonce/GetIdentityNonceResponse.js @@ -1,5 +1,5 @@ -const AbstractResponse = require('../response/AbstractResponse'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); +import AbstractResponse from '../response/AbstractResponse.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; const IDENTITY_NONCE_VALUE_FILTER = BigInt(0xFFFFFFFFFF); @@ -46,4 +46,4 @@ class GetIdentityNonceResponse extends AbstractResponse { } } -module.exports = GetIdentityNonceResponse; +export default GetIdentityNonceResponse; diff --git a/packages/js-dapi-client/lib/methods/platform/getIdentityNonce/getIdentityNonceFactory.js b/packages/js-dapi-client/lib/methods/platform/getIdentityNonce/getIdentityNonceFactory.js index 217cfe48c34..a2fd8f419f8 100644 --- a/packages/js-dapi-client/lib/methods/platform/getIdentityNonce/getIdentityNonceFactory.js +++ b/packages/js-dapi-client/lib/methods/platform/getIdentityNonce/getIdentityNonceFactory.js @@ -1,12 +1,13 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import GetIdentityNonceResponse from './GetIdentityNonceResponse.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; + const { v0: { PlatformPromiseClient, GetIdentityNonceRequest, }, -} = require('@dashevo/dapi-grpc'); - -const GetIdentityNonceResponse = require('./GetIdentityNonceResponse'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); +} = dapiGrpc; /** * @param {GrpcTransport} grpcTransport @@ -16,7 +17,7 @@ function getIdentityNonceFactory(grpcTransport) { /** * Fetch the version upgrade votes status * @typedef {getIdentityNonce} - * @param {Buffer} identityId + * @param {Uint8Array} identityId * @param {DAPIClientOptions & {prove: boolean}} [options] * @returns {Promise} */ @@ -28,9 +29,9 @@ function getIdentityNonceFactory(grpcTransport) { // eslint-disable-next-line max-len const getIdentityNonceRequest = new GetIdentityNonceRequest(); - if (Buffer.isBuffer(identityId)) { + if (identityId instanceof Uint8Array) { // eslint-disable-next-line no-param-reassign - identityId = Buffer.from(identityId); + identityId = new Uint8Array(identityId); } getIdentityNonceRequest.setV0( @@ -71,4 +72,4 @@ function getIdentityNonceFactory(grpcTransport) { return getIdentityNonce; } -module.exports = getIdentityNonceFactory; +export default getIdentityNonceFactory; diff --git a/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeState/GetProtocolVersionUpgradeStateResponse.js b/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeState/GetProtocolVersionUpgradeStateResponse.js index 0d01b9fa2d4..02024eb5108 100644 --- a/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeState/GetProtocolVersionUpgradeStateResponse.js +++ b/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeState/GetProtocolVersionUpgradeStateResponse.js @@ -1,6 +1,6 @@ -const AbstractResponse = require('../response/AbstractResponse'); -const VersionEntry = require('./VersionEntry'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); +import AbstractResponse from '../response/AbstractResponse.js'; +import VersionEntry from './VersionEntry.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; class GetProtocolVersionUpgradeStateResponse extends AbstractResponse { /** @@ -53,4 +53,4 @@ class GetProtocolVersionUpgradeStateResponse extends AbstractResponse { } } -module.exports = GetProtocolVersionUpgradeStateResponse; +export default GetProtocolVersionUpgradeStateResponse; diff --git a/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeState/VersionEntry.js b/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeState/VersionEntry.js index 7ddfe52c454..e4aedcec109 100644 --- a/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeState/VersionEntry.js +++ b/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeState/VersionEntry.js @@ -23,4 +23,4 @@ class VersionEntry { } } -module.exports = VersionEntry; +export default VersionEntry; diff --git a/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeState/getProtocolVersionUpgradeStateFactory.js b/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeState/getProtocolVersionUpgradeStateFactory.js index 235c8ced930..f5a41cbc930 100644 --- a/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeState/getProtocolVersionUpgradeStateFactory.js +++ b/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeState/getProtocolVersionUpgradeStateFactory.js @@ -1,12 +1,14 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; + +import GetProtocolVersionUpgradeStateResponse from './GetProtocolVersionUpgradeStateResponse.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; + const { v0: { PlatformPromiseClient, GetProtocolVersionUpgradeStateRequest, }, -} = require('@dashevo/dapi-grpc'); - -const GetProtocolVersionUpgradeStateResponse = require('./GetProtocolVersionUpgradeStateResponse'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); +} = dapiGrpc; /** * @param {GrpcTransport} grpcTransport @@ -59,4 +61,4 @@ function getProtocolVersionUpgradeStateFactory(grpcTransport) { return getProtocolVersionUpgradeState; } -module.exports = getProtocolVersionUpgradeStateFactory; +export default getProtocolVersionUpgradeStateFactory; diff --git a/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeVoteStatus/GetProtocolVersionUpgradeVoteStatusResponse.js b/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeVoteStatus/GetProtocolVersionUpgradeVoteStatusResponse.js index a28ec23e6c1..a8bf59ae9a4 100644 --- a/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeVoteStatus/GetProtocolVersionUpgradeVoteStatusResponse.js +++ b/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeVoteStatus/GetProtocolVersionUpgradeVoteStatusResponse.js @@ -1,6 +1,7 @@ -const AbstractResponse = require('../response/AbstractResponse'); -const VersionSignal = require('./VersionSignal'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); +import AbstractResponse from '../response/AbstractResponse.js'; +import VersionSignal from './VersionSignal.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; +import { bytesToHex } from '../../../utils/bytes.js'; class GetProtocolVersionUpgradeVoteStatusResponse extends AbstractResponse { /** @@ -40,7 +41,7 @@ class GetProtocolVersionUpgradeVoteStatusResponse extends AbstractResponse { const versionSignalsList = versions && versions.getVersionSignalsList(); if (versionSignalsList) { versionSignals = versionSignalsList.map((versionSignal) => new VersionSignal( - Buffer.from(versionSignal.getProTxHash()).toString('hex'), + bytesToHex(new Uint8Array(versionSignal.getProTxHash())), versionSignal.getVersion(), )); } @@ -53,4 +54,4 @@ class GetProtocolVersionUpgradeVoteStatusResponse extends AbstractResponse { } } -module.exports = GetProtocolVersionUpgradeVoteStatusResponse; +export default GetProtocolVersionUpgradeVoteStatusResponse; diff --git a/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeVoteStatus/VersionSignal.js b/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeVoteStatus/VersionSignal.js index 7bd4a234f3c..799a025f1fd 100644 --- a/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeVoteStatus/VersionSignal.js +++ b/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeVoteStatus/VersionSignal.js @@ -23,4 +23,4 @@ class VersionSignal { } } -module.exports = VersionSignal; +export default VersionSignal; diff --git a/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeVoteStatus/getProtocolVersionUpgradeVoteStatusFactory.js b/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeVoteStatus/getProtocolVersionUpgradeVoteStatusFactory.js index bc79c54315c..bf15d822c12 100644 --- a/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeVoteStatus/getProtocolVersionUpgradeVoteStatusFactory.js +++ b/packages/js-dapi-client/lib/methods/platform/getProtocolVersionUpgradeVoteStatus/getProtocolVersionUpgradeVoteStatusFactory.js @@ -1,12 +1,15 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; + +import GetProtocolVersionUpgradeVoteStatusResponse from './GetProtocolVersionUpgradeVoteStatusResponse.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; +import { hexToBytes } from '../../../utils/bytes.js'; + const { v0: { PlatformPromiseClient, GetProtocolVersionUpgradeVoteStatusRequest, }, -} = require('@dashevo/dapi-grpc'); - -const GetProtocolVersionUpgradeVoteStatusResponse = require('./GetProtocolVersionUpgradeVoteStatusResponse'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); +} = dapiGrpc; /** * @param {GrpcTransport} grpcTransport @@ -31,7 +34,7 @@ function getProtocolVersionUpgradeVoteStatusFactory(grpcTransport) { getProtocolVersionUpgradeVoteStatusRequest.setV0( new GetProtocolVersionUpgradeVoteStatusRequestV0() - .setStartProTxHash(Buffer.from(startProTxHash, 'hex')) + .setStartProTxHash(hexToBytes(startProTxHash)) .setCount(count) .setProve(!!options.prove), ); @@ -68,4 +71,4 @@ function getProtocolVersionUpgradeVoteStatusFactory(grpcTransport) { return getProtocolVersionUpgradeVoteStatus; } -module.exports = getProtocolVersionUpgradeVoteStatusFactory; +export default getProtocolVersionUpgradeVoteStatusFactory; diff --git a/packages/js-dapi-client/lib/methods/platform/getStatus/ChainStatus.js b/packages/js-dapi-client/lib/methods/platform/getStatus/ChainStatus.js index caa2ca991ef..692a1762b74 100644 --- a/packages/js-dapi-client/lib/methods/platform/getStatus/ChainStatus.js +++ b/packages/js-dapi-client/lib/methods/platform/getStatus/ChainStatus.js @@ -96,4 +96,4 @@ class ChainStatus { } } -module.exports = ChainStatus; +export default ChainStatus; diff --git a/packages/js-dapi-client/lib/methods/platform/getStatus/GetStatusResponse.js b/packages/js-dapi-client/lib/methods/platform/getStatus/GetStatusResponse.js index 1509b69b64a..cbc3f02738e 100644 --- a/packages/js-dapi-client/lib/methods/platform/getStatus/GetStatusResponse.js +++ b/packages/js-dapi-client/lib/methods/platform/getStatus/GetStatusResponse.js @@ -1,9 +1,10 @@ -const VersionStatus = require('./VersionStatus'); -const NodeStatus = require('./NodeStatus'); -const ChainStatus = require('./ChainStatus'); -const TimeStatus = require('./TimeStatus'); -const StateSyncStatus = require('./StateSyncStatus'); -const NetworkStatus = require('./NetworkStatus'); +import VersionStatus from './VersionStatus.js'; +import NodeStatus from './NodeStatus.js'; +import ChainStatus from './ChainStatus.js'; +import TimeStatus from './TimeStatus.js'; +import StateSyncStatus from './StateSyncStatus.js'; +import NetworkStatus from './NetworkStatus.js'; +import { bytesToHex } from '../../../utils/bytes.js'; class GetStatusResponse { /** @@ -92,17 +93,17 @@ class GetStatusResponse { driveNextEpochProtocol, ); - const nodeId = Buffer.from(v0.getNode().getId()).toString('hex'); - const proTxHash = Buffer.from(v0.getNode().getProTxHash()).toString('hex'); + const nodeId = bytesToHex(new Uint8Array(v0.getNode().getId())); + const proTxHash = bytesToHex(new Uint8Array(v0.getNode().getProTxHash())); const node = new NodeStatus(nodeId, proTxHash); const catchingUp = v0.getChain().getCatchingUp(); - const latestBlockHash = Buffer.from(v0.getChain().getLatestBlockHash()).toString('hex'); - const latestAppHash = Buffer.from(v0.getChain().getLatestAppHash()).toString('hex'); + const latestBlockHash = bytesToHex(new Uint8Array(v0.getChain().getLatestBlockHash())); + const latestAppHash = bytesToHex(new Uint8Array(v0.getChain().getLatestAppHash())); const latestBlockHeight = BigInt(v0.getChain().getLatestBlockHeight()); - const earliestBlockHash = Buffer.from(v0.getChain().getEarliestBlockHash()).toString('hex'); - const earliestAppHash = Buffer.from(v0.getChain().getEarliestAppHash()).toString('hex'); + const earliestBlockHash = bytesToHex(new Uint8Array(v0.getChain().getEarliestBlockHash())); + const earliestAppHash = bytesToHex(new Uint8Array(v0.getChain().getEarliestAppHash())); const earliestBlockHeight = BigInt(v0.getChain().getEarliestBlockHeight()); const maxPeerBlockHeight = BigInt(v0.getChain().getMaxPeerBlockHeight()); const coreChainLockedHeight = v0.getChain().getCoreChainLockedHeight(); @@ -163,4 +164,4 @@ class GetStatusResponse { } } -module.exports = GetStatusResponse; +export default GetStatusResponse; diff --git a/packages/js-dapi-client/lib/methods/platform/getStatus/NetworkStatus.js b/packages/js-dapi-client/lib/methods/platform/getStatus/NetworkStatus.js index 0b2f66693a8..3a8d6df540e 100644 --- a/packages/js-dapi-client/lib/methods/platform/getStatus/NetworkStatus.js +++ b/packages/js-dapi-client/lib/methods/platform/getStatus/NetworkStatus.js @@ -32,4 +32,4 @@ class NetworkStatus { } } -module.exports = NetworkStatus; +export default NetworkStatus; diff --git a/packages/js-dapi-client/lib/methods/platform/getStatus/NodeStatus.js b/packages/js-dapi-client/lib/methods/platform/getStatus/NodeStatus.js index 5a73a568a27..0cea8987593 100644 --- a/packages/js-dapi-client/lib/methods/platform/getStatus/NodeStatus.js +++ b/packages/js-dapi-client/lib/methods/platform/getStatus/NodeStatus.js @@ -23,4 +23,4 @@ class NodeStatus { } } -module.exports = NodeStatus; +export default NodeStatus; diff --git a/packages/js-dapi-client/lib/methods/platform/getStatus/StateSyncStatus.js b/packages/js-dapi-client/lib/methods/platform/getStatus/StateSyncStatus.js index 1927d214ade..935630aa6b7 100644 --- a/packages/js-dapi-client/lib/methods/platform/getStatus/StateSyncStatus.js +++ b/packages/js-dapi-client/lib/methods/platform/getStatus/StateSyncStatus.js @@ -86,4 +86,4 @@ class StateSyncStatus { } } -module.exports = StateSyncStatus; +export default StateSyncStatus; diff --git a/packages/js-dapi-client/lib/methods/platform/getStatus/TimeStatus.js b/packages/js-dapi-client/lib/methods/platform/getStatus/TimeStatus.js index 1c26509354b..8658ac828c2 100644 --- a/packages/js-dapi-client/lib/methods/platform/getStatus/TimeStatus.js +++ b/packages/js-dapi-client/lib/methods/platform/getStatus/TimeStatus.js @@ -46,4 +46,4 @@ class TimeStatus { } } -module.exports = TimeStatus; +export default TimeStatus; diff --git a/packages/js-dapi-client/lib/methods/platform/getStatus/VersionStatus.js b/packages/js-dapi-client/lib/methods/platform/getStatus/VersionStatus.js index 8ce56a81f7e..2477666beba 100644 --- a/packages/js-dapi-client/lib/methods/platform/getStatus/VersionStatus.js +++ b/packages/js-dapi-client/lib/methods/platform/getStatus/VersionStatus.js @@ -86,4 +86,4 @@ class VersionStatus { } } -module.exports = VersionStatus; +export default VersionStatus; diff --git a/packages/js-dapi-client/lib/methods/platform/getStatus/getStatusFactory.js b/packages/js-dapi-client/lib/methods/platform/getStatus/getStatusFactory.js index 0c2bd5fec26..c474c8dcd02 100644 --- a/packages/js-dapi-client/lib/methods/platform/getStatus/getStatusFactory.js +++ b/packages/js-dapi-client/lib/methods/platform/getStatus/getStatusFactory.js @@ -1,12 +1,14 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; + +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; +import GetStatusResponse from './GetStatusResponse.js'; + const { v0: { PlatformPromiseClient, GetStatusRequest, }, -} = require('@dashevo/dapi-grpc'); - -const InvalidResponseError = require('../response/errors/InvalidResponseError'); -const GetStatusResponse = require('./GetStatusResponse'); +} = dapiGrpc; /** * @param {GrpcTransport} grpcTransport @@ -63,4 +65,4 @@ function getStatusFactory(grpcTransport) { return getStatus; } -module.exports = getStatusFactory; +export default getStatusFactory; diff --git a/packages/js-dapi-client/lib/methods/platform/getTotalCreditsInPlatform/GetTotalCreditsInPlatformResponse.js b/packages/js-dapi-client/lib/methods/platform/getTotalCreditsInPlatform/GetTotalCreditsInPlatformResponse.js index 5dc64e1bd98..a0879c4ceb6 100644 --- a/packages/js-dapi-client/lib/methods/platform/getTotalCreditsInPlatform/GetTotalCreditsInPlatformResponse.js +++ b/packages/js-dapi-client/lib/methods/platform/getTotalCreditsInPlatform/GetTotalCreditsInPlatformResponse.js @@ -1,5 +1,5 @@ -const AbstractResponse = require('../response/AbstractResponse'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); +import AbstractResponse from '../response/AbstractResponse.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; class GetTotalCreditsInPlatformResponse extends AbstractResponse { /** @@ -43,4 +43,4 @@ class GetTotalCreditsInPlatformResponse extends AbstractResponse { } } -module.exports = GetTotalCreditsInPlatformResponse; +export default GetTotalCreditsInPlatformResponse; diff --git a/packages/js-dapi-client/lib/methods/platform/getTotalCreditsInPlatform/getTotalCreditsInPlatformFactory.js b/packages/js-dapi-client/lib/methods/platform/getTotalCreditsInPlatform/getTotalCreditsInPlatformFactory.js index 1bbbd3f022f..f12c22ada15 100644 --- a/packages/js-dapi-client/lib/methods/platform/getTotalCreditsInPlatform/getTotalCreditsInPlatformFactory.js +++ b/packages/js-dapi-client/lib/methods/platform/getTotalCreditsInPlatform/getTotalCreditsInPlatformFactory.js @@ -1,12 +1,14 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; + +import GetTotalCreditsInPlatformResponse from './GetTotalCreditsInPlatformResponse.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; + const { v0: { PlatformPromiseClient, GetTotalCreditsInPlatformRequest, }, -} = require('@dashevo/dapi-grpc'); - -const GetTotalCreditsInPlatformResponse = require('./GetTotalCreditsInPlatformResponse'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); +} = dapiGrpc; /** * @param {GrpcTransport} grpcTransport @@ -64,4 +66,4 @@ function getTotalCreditsInPlatformFactory(grpcTransport) { return getTotalCreditsInPlatform; } -module.exports = getTotalCreditsInPlatformFactory; +export default getTotalCreditsInPlatformFactory; diff --git a/packages/js-dapi-client/lib/methods/platform/response/AbstractResponse.js b/packages/js-dapi-client/lib/methods/platform/response/AbstractResponse.js index 50a3508bd07..2cffe2d1f7a 100644 --- a/packages/js-dapi-client/lib/methods/platform/response/AbstractResponse.js +++ b/packages/js-dapi-client/lib/methods/platform/response/AbstractResponse.js @@ -1,6 +1,6 @@ -const InvalidResponseError = require('./errors/InvalidResponseError'); -const Metadata = require('./Metadata'); -const Proof = require('./Proof'); +import InvalidResponseError from './errors/InvalidResponseError.js'; +import Metadata from './Metadata.js'; +import Proof from './Proof.js'; /** * @abstract @@ -61,4 +61,4 @@ class AbstractResponse { } } -module.exports = AbstractResponse; +export default AbstractResponse; diff --git a/packages/js-dapi-client/lib/methods/platform/response/Metadata.js b/packages/js-dapi-client/lib/methods/platform/response/Metadata.js index 070134e3935..03e8c89a80f 100644 --- a/packages/js-dapi-client/lib/methods/platform/response/Metadata.js +++ b/packages/js-dapi-client/lib/methods/platform/response/Metadata.js @@ -46,4 +46,4 @@ class Metadata { } } -module.exports = Metadata; +export default Metadata; diff --git a/packages/js-dapi-client/lib/methods/platform/response/Proof.js b/packages/js-dapi-client/lib/methods/platform/response/Proof.js index 56111ac5458..f93b1d5e3dd 100644 --- a/packages/js-dapi-client/lib/methods/platform/response/Proof.js +++ b/packages/js-dapi-client/lib/methods/platform/response/Proof.js @@ -1,9 +1,9 @@ class Proof { /** * @param {object} properties - * @param {Buffer} properties.merkleProof - * @param {Buffer} properties.quorumHash - * @param {Buffer} properties.signature + * @param {Uint8Array} properties.merkleProof + * @param {Uint8Array} properties.quorumHash + * @param {Uint8Array} properties.signature * @param {number} properties.round */ constructor(properties) { @@ -14,21 +14,21 @@ class Proof { } /** - * @returns {Buffer} + * @returns {Uint8Array} */ getGrovedbProof() { return this.merkleProof; } /** - * @returns {Buffer} + * @returns {Uint8Array} */ getQuorumHash() { return this.quorumHash; } /** - * @returns {Buffer} + * @returns {Uint8Array} */ getSignature() { return this.signature; @@ -48,12 +48,12 @@ class Proof { */ static createFromProto(proofProto) { return new Proof({ - merkleProof: Buffer.from(proofProto.getGrovedbProof()), - quorumHash: Buffer.from(proofProto.getQuorumHash()), - signature: Buffer.from(proofProto.getSignature()), + merkleProof: new Uint8Array(proofProto.getGrovedbProof()), + quorumHash: new Uint8Array(proofProto.getQuorumHash()), + signature: new Uint8Array(proofProto.getSignature()), round: proofProto.getRound(), }); } } -module.exports = Proof; +export default Proof; diff --git a/packages/js-dapi-client/lib/methods/platform/response/StoreTreeProofs.js b/packages/js-dapi-client/lib/methods/platform/response/StoreTreeProofs.js index 5a3ad028286..60b69a7a710 100644 --- a/packages/js-dapi-client/lib/methods/platform/response/StoreTreeProofs.js +++ b/packages/js-dapi-client/lib/methods/platform/response/StoreTreeProofs.js @@ -1,10 +1,10 @@ class StoreTreeProofs { /** * @param {object} properties - * @param {Buffer} properties.publicKeyHashesToIdentityIdsProof - * @param {Buffer} properties.identitiesProof - * @param {Buffer} properties.documentsProof - * @param {Buffer} properties.dataContractsProof + * @param {Uint8Array} properties.publicKeyHashesToIdentityIdsProof + * @param {Uint8Array} properties.identitiesProof + * @param {Uint8Array} properties.documentsProof + * @param {Uint8Array} properties.dataContractsProof */ constructor(properties) { this.publicKeyHashesToIdentityIdsProof = properties.publicKeyHashesToIdentityIdsProof; @@ -14,32 +14,32 @@ class StoreTreeProofs { } /** - * @returns {Buffer} + * @returns {Uint8Array} */ getPublicKeyHashesToIdentityIdsProof() { return this.publicKeyHashesToIdentityIdsProof; } /** - * @returns {Buffer} + * @returns {Uint8Array} */ getIdentitiesProof() { return this.identitiesProof; } /** - * @returns {Buffer} + * @returns {Uint8Array} */ getDocumentsProof() { return this.documentsProof; } /** - * @returns {Buffer} + * @returns {Uint8Array} */ getDataContractsProof() { return this.dataContractsProof; } } -module.exports = StoreTreeProofs; +export default StoreTreeProofs; diff --git a/packages/js-dapi-client/lib/methods/platform/response/errors/InvalidResponseError.js b/packages/js-dapi-client/lib/methods/platform/response/errors/InvalidResponseError.js index d547af0d864..d85e77b1b5e 100644 --- a/packages/js-dapi-client/lib/methods/platform/response/errors/InvalidResponseError.js +++ b/packages/js-dapi-client/lib/methods/platform/response/errors/InvalidResponseError.js @@ -1,4 +1,4 @@ -const DAPIClientError = require('../../../../errors/DAPIClientError'); +import DAPIClientError from '../../../../errors/DAPIClientError.js'; class InvalidResponseError extends DAPIClientError { constructor(message) { @@ -6,4 +6,4 @@ class InvalidResponseError extends DAPIClientError { } } -module.exports = InvalidResponseError; +export default InvalidResponseError; diff --git a/packages/js-dapi-client/lib/methods/platform/waitForStateTransitionResult/ErrorResult.js b/packages/js-dapi-client/lib/methods/platform/waitForStateTransitionResult/ErrorResult.js index 55072f849b6..c4544608894 100644 --- a/packages/js-dapi-client/lib/methods/platform/waitForStateTransitionResult/ErrorResult.js +++ b/packages/js-dapi-client/lib/methods/platform/waitForStateTransitionResult/ErrorResult.js @@ -2,7 +2,7 @@ class ErrorResult { /** * @param {number} code * @param {string} message - * @param {Buffer|undefined} data + * @param {Uint8Array|undefined} data */ constructor(code, message, data) { this.code = code; @@ -25,11 +25,11 @@ class ErrorResult { } /** - * @returns {Buffer|undefined} + * @returns {Uint8Array|undefined} */ getData() { return this.data; } } -module.exports = ErrorResult; +export default ErrorResult; diff --git a/packages/js-dapi-client/lib/methods/platform/waitForStateTransitionResult/WaitForStateTransitionResultResponse.js b/packages/js-dapi-client/lib/methods/platform/waitForStateTransitionResult/WaitForStateTransitionResultResponse.js index 836987a2376..4d6e8ea1407 100644 --- a/packages/js-dapi-client/lib/methods/platform/waitForStateTransitionResult/WaitForStateTransitionResultResponse.js +++ b/packages/js-dapi-client/lib/methods/platform/waitForStateTransitionResult/WaitForStateTransitionResultResponse.js @@ -1,7 +1,7 @@ -const AbstractResponse = require('../response/AbstractResponse'); -const Metadata = require('../response/Metadata'); -const Proof = require('../response/Proof'); -const ErrorResult = require('./ErrorResult'); +import AbstractResponse from '../response/AbstractResponse.js'; +import Metadata from '../response/Metadata.js'; +import Proof from '../response/Proof.js'; +import ErrorResult from './ErrorResult.js'; class WaitForStateTransitionResultResponse extends AbstractResponse { /** @@ -38,7 +38,7 @@ class WaitForStateTransitionResultResponse extends AbstractResponse { let data; if (proto.getV0().getError().getData()) { - data = Buffer.from(proto.getV0().getError().getData()); + data = new Uint8Array(proto.getV0().getError().getData()); } error = new ErrorResult( @@ -59,4 +59,4 @@ class WaitForStateTransitionResultResponse extends AbstractResponse { } } -module.exports = WaitForStateTransitionResultResponse; +export default WaitForStateTransitionResultResponse; diff --git a/packages/js-dapi-client/lib/methods/platform/waitForStateTransitionResult/waitForStateTransitionResultFactory.js b/packages/js-dapi-client/lib/methods/platform/waitForStateTransitionResult/waitForStateTransitionResultFactory.js index 62d7466fba2..d185abcf093 100644 --- a/packages/js-dapi-client/lib/methods/platform/waitForStateTransitionResult/waitForStateTransitionResultFactory.js +++ b/packages/js-dapi-client/lib/methods/platform/waitForStateTransitionResult/waitForStateTransitionResultFactory.js @@ -1,12 +1,14 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; + +import WaitForStateTransitionResultResponse from './WaitForStateTransitionResultResponse.js'; +import InvalidResponseError from '../response/errors/InvalidResponseError.js'; + const { v0: { PlatformPromiseClient, WaitForStateTransitionResultRequest, }, -} = require('@dashevo/dapi-grpc'); - -const WaitForStateTransitionResultResponse = require('./WaitForStateTransitionResultResponse'); -const InvalidResponseError = require('../response/errors/InvalidResponseError'); +} = dapiGrpc; /** * @@ -16,7 +18,7 @@ const InvalidResponseError = require('../response/errors/InvalidResponseError'); function waitForStateTransitionResultFactory(grpcTransport) { /** * @typedef waitForStateTransitionResult - * @param {Buffer} stateTransitionHash + * @param {Uint8Array} stateTransitionHash * @param {DAPIClientOptions & getDocumentsOptions & {prove: boolean}} [options] * @returns {Promise} */ @@ -72,4 +74,4 @@ function waitForStateTransitionResultFactory(grpcTransport) { return waitForStateTransitionResult; } -module.exports = waitForStateTransitionResultFactory; +export default waitForStateTransitionResultFactory; diff --git a/packages/js-dapi-client/lib/networkConfigs.js b/packages/js-dapi-client/lib/networkConfigs.js index e45953ac3a1..518736b06d2 100644 --- a/packages/js-dapi-client/lib/networkConfigs.js +++ b/packages/js-dapi-client/lib/networkConfigs.js @@ -1,4 +1,4 @@ -module.exports = { +export default { testnet: { seeds: [ 'seed-1.testnet.networks.dash.org:1443', diff --git a/packages/js-dapi-client/lib/test/bootstrap.js b/packages/js-dapi-client/lib/test/bootstrap.js index 473d16fb1d1..bd148b7d798 100644 --- a/packages/js-dapi-client/lib/test/bootstrap.js +++ b/packages/js-dapi-client/lib/test/bootstrap.js @@ -1,19 +1,21 @@ -require('../../polyfills/fetch-polyfill'); -require('setimmediate'); +import chai from 'chai'; +import sinon from 'sinon'; +import sinonChai from 'sinon-chai'; +import dirtyChai from 'dirty-chai'; +import chaiAsPromised from 'chai-as-promised'; +import loadDpp from '@dashevo/wasm-dpp'; -const { expect, use } = require('chai'); -const sinon = require('sinon'); -const sinonChai = require('sinon-chai'); -const dirtyChai = require('dirty-chai'); -const chaiAsPromised = require('chai-as-promised'); -const { default: loadDpp } = require('@dashevo/wasm-dpp'); +chai.use(sinonChai); +chai.use(chaiAsPromised); +chai.use(dirtyChai); -use(sinonChai); -use(chaiAsPromised); -use(dirtyChai); - -exports.mochaHooks = { - beforeAll: loadDpp, +export const mochaHooks = { + // wasm-dpp is CJS; under NodeNext the default may resolve to the namespace + // object instead of the callable. Unwrap defensively. + beforeAll: async () => { + const load = loadDpp.default ?? loadDpp; + return load(); + }, beforeEach() { if (!this.sinon) { @@ -28,4 +30,4 @@ exports.mochaHooks = { }, }; -global.expect = expect; +global.expect = chai.expect; diff --git a/packages/js-dapi-client/lib/test/fixtures/getHeadersFixture.js b/packages/js-dapi-client/lib/test/fixtures/getHeadersFixture.js index 8c0fc19ce26..bfbed1c6adb 100644 --- a/packages/js-dapi-client/lib/test/fixtures/getHeadersFixture.js +++ b/packages/js-dapi-client/lib/test/fixtures/getHeadersFixture.js @@ -1,4 +1,5 @@ -const { BlockHeader } = require('@dashevo/dashcore-lib'); +import dashcore from '@dashevo/dashcore-lib'; +const { BlockHeader } = dashcore; const headers = [ { @@ -212,4 +213,4 @@ function getHeadersFixture() { .map((header) => new BlockHeader({ ...header, bits: parseInt(header.bits, 16) })); } -module.exports = getHeadersFixture; +export default getHeadersFixture; diff --git a/packages/js-dapi-client/lib/test/fixtures/getMNListDiffsFixture.js b/packages/js-dapi-client/lib/test/fixtures/getMNListDiffsFixture.js index 771d0f81741..f363bf1eb31 100644 --- a/packages/js-dapi-client/lib/test/fixtures/getMNListDiffsFixture.js +++ b/packages/js-dapi-client/lib/test/fixtures/getMNListDiffsFixture.js @@ -90,4 +90,4 @@ function getMNListDiffsFixture() { ]; } -module.exports = getMNListDiffsFixture; +export default getMNListDiffsFixture; diff --git a/packages/js-dapi-client/lib/test/fixtures/getMetadataFixture.js b/packages/js-dapi-client/lib/test/fixtures/getMetadataFixture.js index 6ce49e99854..c67b7eb2dd5 100644 --- a/packages/js-dapi-client/lib/test/fixtures/getMetadataFixture.js +++ b/packages/js-dapi-client/lib/test/fixtures/getMetadataFixture.js @@ -15,4 +15,4 @@ function getMetadataFixture() { }; } -module.exports = getMetadataFixture; +export default getMetadataFixture; diff --git a/packages/js-dapi-client/lib/test/fixtures/getProofFixture.js b/packages/js-dapi-client/lib/test/fixtures/getProofFixture.js index 274b9f8a70f..2bf7e9eec64 100644 --- a/packages/js-dapi-client/lib/test/fixtures/getProofFixture.js +++ b/packages/js-dapi-client/lib/test/fixtures/getProofFixture.js @@ -1,17 +1,19 @@ +import { hexToBytes, base64ToBytes } from '../../utils/bytes.js'; + /** * @returns {{ - * merkleProof: Buffer, - * signature: Buffer, - * quorumHash: Buffer + * merkleProof: Uint8Array, + * signature: Uint8Array, + * quorumHash: Uint8Array * }} */ function getProofFixture() { return { - quorumHash: Buffer.from('AQEBAQEBAQEBAQEB', 'base64'), - signature: Buffer.from('AgICAgICAgICAgIC', 'base64'), - merkleProof: Buffer.from('0100000001f0faf5f55674905a68eba1be2f946e667c1cb5010101', 'hex'), + quorumHash: base64ToBytes('AQEBAQEBAQEBAQEB'), + signature: base64ToBytes('AgICAgICAgICAgIC'), + merkleProof: hexToBytes('0100000001f0faf5f55674905a68eba1be2f946e667c1cb5010101'), round: 42, }; } -module.exports = getProofFixture; +export default getProofFixture; diff --git a/packages/js-dapi-client/lib/test/fixtures/getStatusFixture.js b/packages/js-dapi-client/lib/test/fixtures/getStatusFixture.js index 1336e117372..e4bdc5be9e0 100644 --- a/packages/js-dapi-client/lib/test/fixtures/getStatusFixture.js +++ b/packages/js-dapi-client/lib/test/fixtures/getStatusFixture.js @@ -1,3 +1,5 @@ +import { base64ToBytes } from '../../utils/bytes.js'; + /** * */ @@ -22,16 +24,16 @@ function getStatusFixture() { }, }, node: { - id: new Uint8Array(Buffer.from('QbMI9zfKnjn2e1UxWJAxmKiMUW4=', 'base64')), - proTxHash: new Uint8Array(Buffer.from('s7V0hXG2D+mtEScV1qUXJdblpSqcOvX9NqFyTPUNhi8=', 'base64')), + id: base64ToBytes('QbMI9zfKnjn2e1UxWJAxmKiMUW4='), + proTxHash: base64ToBytes('s7V0hXG2D+mtEScV1qUXJdblpSqcOvX9NqFyTPUNhi8='), }, chain: { catchingUp: false, - latestBlockHash: new Uint8Array(Buffer.from('mVDwGtY2oJSaLLgv3WpLp2dFDyFEtqhD4z1gl2OJceY=', 'base64')), - latestAppHash: new Uint8Array(Buffer.from('jHgEBK8aZ74TUKcUGN58EFzUNvNsLboOgYe6eH/JetU=', 'base64')), + latestBlockHash: base64ToBytes('mVDwGtY2oJSaLLgv3WpLp2dFDyFEtqhD4z1gl2OJceY='), + latestAppHash: base64ToBytes('jHgEBK8aZ74TUKcUGN58EFzUNvNsLboOgYe6eH/JetU='), latestBlockHeight: '94461', - earliestBlockHash: new Uint8Array(Buffer.from('CPoCwn7AOQujAeT8fj1+rbNQyBk+PmKgk2iXBuOiC/o=', 'base64')), - earliestAppHash: new Uint8Array(Buffer.from('vwzLnKBxugGubmegwJD5eAPSbVbWddzVExeBy8rI7I8=', 'base64')), + earliestBlockHash: base64ToBytes('CPoCwn7AOQujAeT8fj1+rbNQyBk+PmKgk2iXBuOiC/o='), + earliestAppHash: base64ToBytes('vwzLnKBxugGubmegwJD5eAPSbVbWddzVExeBy8rI7I8='), earliestBlockHeight: '1', maxPeerBlockHeight: '94461', coreChainLockedHeight: 1187358, @@ -60,4 +62,4 @@ function getStatusFixture() { }; } -module.exports = getStatusFixture; +export default getStatusFixture; diff --git a/packages/js-dapi-client/lib/test/karma/bootstrap.js b/packages/js-dapi-client/lib/test/karma/bootstrap.js deleted file mode 100644 index 3a2cda9bdb3..00000000000 --- a/packages/js-dapi-client/lib/test/karma/bootstrap.js +++ /dev/null @@ -1,37 +0,0 @@ -require('../../../polyfills/fetch-polyfill'); -require('setimmediate'); - -const { expect, use } = require('chai'); -const sinon = require('sinon'); -const sinonChai = require('sinon-chai'); -const dirtyChai = require('dirty-chai'); -const chaiAsPromised = require('chai-as-promised'); -const { default: loadDpp } = require('@dashevo/wasm-dpp'); - -use(sinonChai); -use(chaiAsPromised); -use(dirtyChai); - -before(async () => { - await loadDpp(); -}); - -beforeEach(function beforeEach() { - if (!this.sinon) { - this.sinon = sinon.createSandbox(); - } else { - this.sinon.restore(); - } -}); - -afterEach(function afterEach() { - this.sinon.restore(); -}); - -before(function before() { - if (!this.sinon) { - this.sinon = sinon.createSandbox(); - } -}); - -global.expect = expect; diff --git a/packages/js-dapi-client/lib/test/karma/loader.js b/packages/js-dapi-client/lib/test/karma/loader.js deleted file mode 100644 index f4731dcbe32..00000000000 --- a/packages/js-dapi-client/lib/test/karma/loader.js +++ /dev/null @@ -1,7 +0,0 @@ -// This file is used for compiling tests with webpack into one file for using with karma -require('./bootstrap'); - -// noinspection JSUnresolvedFunction -const testsContext = require.context('../../../test', true, /^(?!.*functional).*\.js$/); - -testsContext.keys().forEach(testsContext); diff --git a/packages/js-dapi-client/lib/test/mocks/BlockHeadersWithChainLocksStreamMock.js b/packages/js-dapi-client/lib/test/mocks/BlockHeadersWithChainLocksStreamMock.js index af846163968..fd39cb08f69 100644 --- a/packages/js-dapi-client/lib/test/mocks/BlockHeadersWithChainLocksStreamMock.js +++ b/packages/js-dapi-client/lib/test/mocks/BlockHeadersWithChainLocksStreamMock.js @@ -1,4 +1,4 @@ -const EventEmitter = require('events'); +import EventEmitter from 'events'; class BlockHeadersWithChainLocksStreamMock extends EventEmitter { constructor(sinon) { @@ -51,4 +51,4 @@ class BlockHeadersWithChainLocksStreamMock extends EventEmitter { } } -module.exports = BlockHeadersWithChainLocksStreamMock; +export default BlockHeadersWithChainLocksStreamMock; diff --git a/packages/js-dapi-client/lib/test/mocks/mockHeadersChain.js b/packages/js-dapi-client/lib/test/mocks/mockHeadersChain.js index 2ae0a911a27..b03891937e4 100644 --- a/packages/js-dapi-client/lib/test/mocks/mockHeadersChain.js +++ b/packages/js-dapi-client/lib/test/mocks/mockHeadersChain.js @@ -1,6 +1,8 @@ -const X11 = require('wasm-x11-hash'); -const { BlockHeader, configure } = require('@dashevo/dashcore-lib'); -const { genesis } = require('@dashevo/dash-spv'); +import X11 from 'wasm-x11-hash'; +import dashcore from '@dashevo/dashcore-lib'; +const { BlockHeader, configure } = dashcore; +import { genesis } from '@dashevo/dash-spv'; +import { hexToBytes } from '../../utils/bytes.js'; const getRoot = (network) => { switch (network) { @@ -38,8 +40,8 @@ const mockHeadersChain = async (network, length, root) => { for (let i = 0; i < length - 1; i += 1) { const header = new BlockHeader({ version: prevHeader.version, - prevHash: Buffer.from(prevHeader.hash, 'hex').reverse(), - merkleRoot: Buffer.alloc(32), + prevHash: hexToBytes(prevHeader.hash).reverse(), + merkleRoot: new Uint8Array(32), time: prevHeader.time + BLOCK_TIME, bits: prevHeader.bits, nonce: 3861367235, @@ -52,4 +54,4 @@ const mockHeadersChain = async (network, length, root) => { return chain; }; -module.exports = mockHeadersChain; +export default mockHeadersChain; diff --git a/packages/js-dapi-client/lib/transport/GrpcTransport/GrpcTransport.js b/packages/js-dapi-client/lib/transport/GrpcTransport/GrpcTransport.js index 5a25bf5e2e1..172bd25802a 100644 --- a/packages/js-dapi-client/lib/transport/GrpcTransport/GrpcTransport.js +++ b/packages/js-dapi-client/lib/transport/GrpcTransport/GrpcTransport.js @@ -1,11 +1,11 @@ -const GrpcErrorCodes = require('@dashevo/grpc-common/lib/server/error/GrpcErrorCodes'); -const logger = require('../../logger'); +import GrpcErrorCodes from '@dashevo/grpc-common/lib/server/error/GrpcErrorCodes.js'; +import logger from '../../logger/index.js'; -const MaxRetriesReachedError = require('../errors/response/MaxRetriesReachedError'); -const NoAvailableAddressesForRetryError = require('../errors/response/NoAvailableAddressesForRetryError'); -const NoAvailableAddressesError = require('../errors/NoAvailableAddressesError'); -const TimeoutError = require('./errors/TimeoutError'); -const RetriableResponseError = require('../errors/response/RetriableResponseError'); +import MaxRetriesReachedError from '../errors/response/MaxRetriesReachedError.js'; +import NoAvailableAddressesForRetryError from '../errors/response/NoAvailableAddressesForRetryError.js'; +import NoAvailableAddressesError from '../errors/NoAvailableAddressesError.js'; +import TimeoutError from './errors/TimeoutError.js'; +import RetriableResponseError from '../errors/response/RetriableResponseError.js'; class GrpcTransport { /** @@ -156,4 +156,4 @@ class GrpcTransport { } } -module.exports = GrpcTransport; +export default GrpcTransport; diff --git a/packages/js-dapi-client/lib/transport/GrpcTransport/createGrpcTransportError.js b/packages/js-dapi-client/lib/transport/GrpcTransport/createGrpcTransportError.js index e5cae56b753..217809761b0 100644 --- a/packages/js-dapi-client/lib/transport/GrpcTransport/createGrpcTransportError.js +++ b/packages/js-dapi-client/lib/transport/GrpcTransport/createGrpcTransportError.js @@ -1,19 +1,20 @@ -const cbor = require('cbor'); - -const GrpcErrorCodes = require('@dashevo/grpc-common/lib/server/error/GrpcErrorCodes'); -const { parseMetadata } = require('@dashevo/dapi-grpc'); - -const { - deserializeConsensusError, -} = require('@dashevo/wasm-dpp'); -const { default: loadWasmDpp } = require('@dashevo/wasm-dpp'); -const NotFoundError = require('./errors/NotFoundError'); -const TimeoutError = require('./errors/TimeoutError'); -const ResponseError = require('../errors/response/ResponseError'); -const ServerError = require('../errors/response/ServerError'); -const InvalidRequestError = require('../errors/response/InvalidRequestError'); -const InvalidRequestDPPError = require('../errors/response/InvalidRequestDPPError'); -const InternalServerError = require('./errors/InternalServerError'); +import cbor from 'cbor'; + +import GrpcErrorCodes from '@dashevo/grpc-common/lib/server/error/GrpcErrorCodes.js'; +import dapiGrpc from '@dashevo/dapi-grpc'; + +import wasmDpp from '@dashevo/wasm-dpp'; +import NotFoundError from './errors/NotFoundError.js'; +import TimeoutError from './errors/TimeoutError.js'; +import ResponseError from '../errors/response/ResponseError.js'; +import ServerError from '../errors/response/ServerError.js'; +import InvalidRequestError from '../errors/response/InvalidRequestError.js'; +import InvalidRequestDPPError from '../errors/response/InvalidRequestDPPError.js'; +import InternalServerError from './errors/InternalServerError.js'; +import { base64ToBytes } from '../../utils/bytes.js'; + +const { parseMetadata } = dapiGrpc; +const { deserializeConsensusError, default: loadWasmDpp } = wasmDpp; const INVALID_REQUEST_CODES = [ GrpcErrorCodes.INVALID_ARGUMENT, @@ -57,10 +58,13 @@ async function createGrpcTransportError(grpcError, dapiAddress) { const metadata = parseMetadata(grpcError.metadata) || {}; - // Error data + // Error data — grpc-js passes raw bytes; grpc-web passes a base64 string. + // Original Buffer.from(x, 'base64') silently passed through bytes; reproduce that. const driveErrorData = metadata['drive-error-data-bin']; if (driveErrorData) { - const encodedData = Buffer.from(driveErrorData, 'base64'); + const encodedData = typeof driveErrorData === 'string' + ? base64ToBytes(driveErrorData) + : new Uint8Array(driveErrorData); data = cbor.decode(encodedData); } @@ -70,10 +74,12 @@ async function createGrpcTransportError(grpcError, dapiAddress) { code = Number(driveErrorCode); } - // Error stack + // Error stack — same dual-format handling as driveErrorData above. const driveErrorStack = metadata['stack-bin']; if (driveErrorStack) { - const encodedStack = Buffer.from(driveErrorStack, 'base64'); + const encodedStack = typeof driveErrorStack === 'string' + ? base64ToBytes(driveErrorStack) + : new Uint8Array(driveErrorStack); data.stack = cbor.decode(encodedStack); } @@ -124,7 +130,10 @@ async function createGrpcTransportError(grpcError, dapiAddress) { throw new Error(`Can't deserialize consensus error ${code}: serialized data is missing`); } - const consensusErrorBytes = Buffer.from(consensusErrorString, 'base64'); + // grpc-js passes raw bytes; grpc-web passes a base64 string. Handle both. + const consensusErrorBytes = typeof consensusErrorString === 'string' + ? base64ToBytes(consensusErrorString) + : new Uint8Array(consensusErrorString); const consensusError = deserializeConsensusError(consensusErrorBytes); delete data.serializedError; @@ -140,4 +149,4 @@ async function createGrpcTransportError(grpcError, dapiAddress) { ); } -module.exports = createGrpcTransportError; +export default createGrpcTransportError; diff --git a/packages/js-dapi-client/lib/transport/GrpcTransport/errors/InternalServerError.js b/packages/js-dapi-client/lib/transport/GrpcTransport/errors/InternalServerError.js index 74ec7058517..bec33c8b901 100644 --- a/packages/js-dapi-client/lib/transport/GrpcTransport/errors/InternalServerError.js +++ b/packages/js-dapi-client/lib/transport/GrpcTransport/errors/InternalServerError.js @@ -1,4 +1,4 @@ -const RetriableResponseError = require('../../errors/response/RetriableResponseError'); +import RetriableResponseError from '../../errors/response/RetriableResponseError.js'; class InternalServerError extends RetriableResponseError { /** @@ -17,4 +17,4 @@ class InternalServerError extends RetriableResponseError { } } -module.exports = InternalServerError; +export default InternalServerError; diff --git a/packages/js-dapi-client/lib/transport/GrpcTransport/errors/NotFoundError.js b/packages/js-dapi-client/lib/transport/GrpcTransport/errors/NotFoundError.js index 12a93f43849..59f8ad9c46e 100644 --- a/packages/js-dapi-client/lib/transport/GrpcTransport/errors/NotFoundError.js +++ b/packages/js-dapi-client/lib/transport/GrpcTransport/errors/NotFoundError.js @@ -1,6 +1,6 @@ -const grpcErrorCodes = require('@dashevo/grpc-common/lib/server/error/GrpcErrorCodes'); +import grpcErrorCodes from '@dashevo/grpc-common/lib/server/error/GrpcErrorCodes.js'; -const ResponseError = require('../../errors/response/ResponseError'); +import ResponseError from '../../errors/response/ResponseError.js'; class NotFoundError extends ResponseError { /** @@ -14,4 +14,4 @@ class NotFoundError extends ResponseError { } } -module.exports = NotFoundError; +export default NotFoundError; diff --git a/packages/js-dapi-client/lib/transport/GrpcTransport/errors/TimeoutError.js b/packages/js-dapi-client/lib/transport/GrpcTransport/errors/TimeoutError.js index 57d4d572777..1c0aee1a496 100644 --- a/packages/js-dapi-client/lib/transport/GrpcTransport/errors/TimeoutError.js +++ b/packages/js-dapi-client/lib/transport/GrpcTransport/errors/TimeoutError.js @@ -1,6 +1,6 @@ -const grpcErrorCodes = require('@dashevo/grpc-common/lib/server/error/GrpcErrorCodes'); +import grpcErrorCodes from '@dashevo/grpc-common/lib/server/error/GrpcErrorCodes.js'; -const RetriableResponseError = require('../../errors/response/RetriableResponseError'); +import RetriableResponseError from '../../errors/response/RetriableResponseError.js'; class TimeoutError extends RetriableResponseError { /** @@ -13,4 +13,4 @@ class TimeoutError extends RetriableResponseError { } } -module.exports = TimeoutError; +export default TimeoutError; diff --git a/packages/js-dapi-client/lib/transport/JsonRpcTransport/JsonRpcTransport.js b/packages/js-dapi-client/lib/transport/JsonRpcTransport/JsonRpcTransport.js index a76afe2aeb1..eb54f19f95d 100644 --- a/packages/js-dapi-client/lib/transport/JsonRpcTransport/JsonRpcTransport.js +++ b/packages/js-dapi-client/lib/transport/JsonRpcTransport/JsonRpcTransport.js @@ -1,9 +1,9 @@ -const logger = require('../../logger'); +import logger from '../../logger/index.js'; -const MaxRetriesReachedError = require('../errors/response/MaxRetriesReachedError'); -const NoAvailableAddressesForRetryError = require('../errors/response/NoAvailableAddressesForRetryError'); -const NoAvailableAddressesError = require('../errors/NoAvailableAddressesError'); -const RetriableResponseError = require('../errors/response/RetriableResponseError'); +import MaxRetriesReachedError from '../errors/response/MaxRetriesReachedError.js'; +import NoAvailableAddressesForRetryError from '../errors/response/NoAvailableAddressesForRetryError.js'; +import NoAvailableAddressesError from '../errors/NoAvailableAddressesError.js'; +import RetriableResponseError from '../errors/response/RetriableResponseError.js'; class JsonRpcTransport { /** @@ -127,4 +127,4 @@ class JsonRpcTransport { } } -module.exports = JsonRpcTransport; +export default JsonRpcTransport; diff --git a/packages/js-dapi-client/lib/transport/JsonRpcTransport/createJsonTransportError.js b/packages/js-dapi-client/lib/transport/JsonRpcTransport/createJsonTransportError.js index e037f8e042b..9d9f3a02779 100644 --- a/packages/js-dapi-client/lib/transport/JsonRpcTransport/createJsonTransportError.js +++ b/packages/js-dapi-client/lib/transport/JsonRpcTransport/createJsonTransportError.js @@ -1,8 +1,8 @@ -const WrongHttpCodeError = require('./errors/WrongHttpCodeError'); -const JsonRpcError = require('./errors/JsonRpcError'); -const ServerError = require('../errors/response/ServerError'); -const ResponseError = require('../errors/response/ResponseError'); -const RetriableResponseError = require('../errors/response/RetriableResponseError'); +import WrongHttpCodeError from './errors/WrongHttpCodeError.js'; +import JsonRpcError from './errors/JsonRpcError.js'; +import ServerError from '../errors/response/ServerError.js'; +import ResponseError from '../errors/response/ResponseError.js'; +import RetriableResponseError from '../errors/response/RetriableResponseError.js'; /** * @typedef {createJsonTransportError} @@ -63,4 +63,4 @@ function createJsonTransportError(error, dapiAddress) { ); } -module.exports = createJsonTransportError; +export default createJsonTransportError; diff --git a/packages/js-dapi-client/lib/transport/JsonRpcTransport/errors/JsonRpcError.js b/packages/js-dapi-client/lib/transport/JsonRpcTransport/errors/JsonRpcError.js index 747a472c8a5..c6ac7dff61e 100644 --- a/packages/js-dapi-client/lib/transport/JsonRpcTransport/errors/JsonRpcError.js +++ b/packages/js-dapi-client/lib/transport/JsonRpcTransport/errors/JsonRpcError.js @@ -1,4 +1,4 @@ -const DAPIClientError = require('../../../errors/DAPIClientError'); +import DAPIClientError from '../../../errors/DAPIClientError.js'; class JsonRpcError extends DAPIClientError { /** @@ -53,4 +53,4 @@ class JsonRpcError extends DAPIClientError { } } -module.exports = JsonRpcError; +export default JsonRpcError; diff --git a/packages/js-dapi-client/lib/transport/JsonRpcTransport/errors/WrongHttpCodeError.js b/packages/js-dapi-client/lib/transport/JsonRpcTransport/errors/WrongHttpCodeError.js index 041d74869d4..e4fc7788602 100644 --- a/packages/js-dapi-client/lib/transport/JsonRpcTransport/errors/WrongHttpCodeError.js +++ b/packages/js-dapi-client/lib/transport/JsonRpcTransport/errors/WrongHttpCodeError.js @@ -1,4 +1,4 @@ -const DAPIClientError = require('../../../errors/DAPIClientError'); +import DAPIClientError from '../../../errors/DAPIClientError.js'; class WrongHttpCodeError extends DAPIClientError { /** @@ -35,4 +35,4 @@ class WrongHttpCodeError extends DAPIClientError { } } -module.exports = WrongHttpCodeError; +export default WrongHttpCodeError; diff --git a/packages/js-dapi-client/lib/transport/JsonRpcTransport/requestJsonRpc.js b/packages/js-dapi-client/lib/transport/JsonRpcTransport/requestJsonRpc.js index ddbdf797088..91879d6b08a 100644 --- a/packages/js-dapi-client/lib/transport/JsonRpcTransport/requestJsonRpc.js +++ b/packages/js-dapi-client/lib/transport/JsonRpcTransport/requestJsonRpc.js @@ -1,6 +1,5 @@ -const https = require('https'); -const JsonRpcError = require('./errors/JsonRpcError'); -const WrongHttpCodeError = require('./errors/WrongHttpCodeError'); +import JsonRpcError from './errors/JsonRpcError.js'; +import WrongHttpCodeError from './errors/WrongHttpCodeError.js'; /** * @typedef {requestJsonRpc} * @param {string} protocol @@ -47,17 +46,21 @@ async function requestJsonRpc(protocol, host, port, selfSigned, method, params, Object.assign(requestOptions, { signal: controller.signal }); } - // For NodeJS Client + // Self-signed HTTPS: Node 18+ built-in fetch is backed by undici, which + // accepts a `dispatcher` for per-request TLS settings. Browsers can't + // bypass TLS verification, so the flag is a no-op there. eval('require') + // hides undici from bundler static analysis so it isn't pulled into + // browser bundles. if (typeof process !== 'undefined' && process.versions != null && process.versions.node != null && protocol === 'https' && selfSigned) { - requestOptions.agent = new https.Agent({ - rejectUnauthorized: false, - }); + // eslint-disable-next-line no-eval, global-require + const { Agent } = eval('require')('undici'); + requestOptions.dispatcher = new Agent({ connect: { rejectUnauthorized: false } }); } - // eslint-disable-next-line + const response = await fetch(url, requestOptions); if (typeof requestTimeoutId !== 'undefined') { @@ -77,4 +80,4 @@ async function requestJsonRpc(protocol, host, port, selfSigned, method, params, return data.result; } -module.exports = requestJsonRpc; +export default requestJsonRpc; diff --git a/packages/js-dapi-client/lib/transport/ReconnectableStream.js b/packages/js-dapi-client/lib/transport/ReconnectableStream.js index 460bdd4da47..0d93a89baf4 100644 --- a/packages/js-dapi-client/lib/transport/ReconnectableStream.js +++ b/packages/js-dapi-client/lib/transport/ReconnectableStream.js @@ -1,6 +1,6 @@ -const EventEmitter = require('events'); -const GrpcErrorCodes = require('@dashevo/grpc-common/lib/server/error/GrpcErrorCodes'); -const wait = require('../utils/wait'); +import EventEmitter from 'events'; +import GrpcErrorCodes from '@dashevo/grpc-common/lib/server/error/GrpcErrorCodes.js'; +import wait from '../utils/wait.js'; /** * @typedef ReconnectableStreamOptions @@ -315,4 +315,4 @@ class ReconnectableStream extends EventEmitter { ReconnectableStream.EVENTS = EVENTS; -module.exports = ReconnectableStream; +export default ReconnectableStream; diff --git a/packages/js-dapi-client/lib/transport/errors/NoAvailableAddressesError.js b/packages/js-dapi-client/lib/transport/errors/NoAvailableAddressesError.js index d6356322f5d..999b98c9012 100644 --- a/packages/js-dapi-client/lib/transport/errors/NoAvailableAddressesError.js +++ b/packages/js-dapi-client/lib/transport/errors/NoAvailableAddressesError.js @@ -1,4 +1,4 @@ -const DAPIClientError = require('../../errors/DAPIClientError'); +import DAPIClientError from '../../errors/DAPIClientError.js'; class NoAvailableAddressesError extends DAPIClientError { constructor() { @@ -6,4 +6,4 @@ class NoAvailableAddressesError extends DAPIClientError { } } -module.exports = NoAvailableAddressesError; +export default NoAvailableAddressesError; diff --git a/packages/js-dapi-client/lib/transport/errors/response/InvalidRequestDPPError.js b/packages/js-dapi-client/lib/transport/errors/response/InvalidRequestDPPError.js index e0cc9162c22..c64557032ac 100644 --- a/packages/js-dapi-client/lib/transport/errors/response/InvalidRequestDPPError.js +++ b/packages/js-dapi-client/lib/transport/errors/response/InvalidRequestDPPError.js @@ -1,4 +1,4 @@ -const ResponseError = require('./ResponseError'); +import ResponseError from './ResponseError.js'; class InvalidRequestDPPError extends ResponseError { /** @@ -21,4 +21,4 @@ class InvalidRequestDPPError extends ResponseError { } } -module.exports = InvalidRequestDPPError; +export default InvalidRequestDPPError; diff --git a/packages/js-dapi-client/lib/transport/errors/response/InvalidRequestError.js b/packages/js-dapi-client/lib/transport/errors/response/InvalidRequestError.js index a93c98c3078..7be0eaf1f55 100644 --- a/packages/js-dapi-client/lib/transport/errors/response/InvalidRequestError.js +++ b/packages/js-dapi-client/lib/transport/errors/response/InvalidRequestError.js @@ -1,7 +1,7 @@ -const ResponseError = require('./ResponseError'); +import ResponseError from './ResponseError.js'; class InvalidRequestError extends ResponseError { } -module.exports = InvalidRequestError; +export default InvalidRequestError; diff --git a/packages/js-dapi-client/lib/transport/errors/response/MaxRetriesReachedError.js b/packages/js-dapi-client/lib/transport/errors/response/MaxRetriesReachedError.js index 5b26aee31f6..e20e1c54653 100644 --- a/packages/js-dapi-client/lib/transport/errors/response/MaxRetriesReachedError.js +++ b/packages/js-dapi-client/lib/transport/errors/response/MaxRetriesReachedError.js @@ -1,4 +1,4 @@ -const ResponseError = require('./ResponseError'); +import ResponseError from './ResponseError.js'; class MaxRetriesReachedError extends ResponseError { /** @@ -23,4 +23,4 @@ class MaxRetriesReachedError extends ResponseError { } } -module.exports = MaxRetriesReachedError; +export default MaxRetriesReachedError; diff --git a/packages/js-dapi-client/lib/transport/errors/response/NoAvailableAddressesForRetryError.js b/packages/js-dapi-client/lib/transport/errors/response/NoAvailableAddressesForRetryError.js index ac9455faea2..8d3d536bead 100644 --- a/packages/js-dapi-client/lib/transport/errors/response/NoAvailableAddressesForRetryError.js +++ b/packages/js-dapi-client/lib/transport/errors/response/NoAvailableAddressesForRetryError.js @@ -1,4 +1,4 @@ -const ResponseError = require('./ResponseError'); +import ResponseError from './ResponseError.js'; class NoAvailableAddressesForRetryError extends ResponseError { /** @@ -23,4 +23,4 @@ class NoAvailableAddressesForRetryError extends ResponseError { } } -module.exports = NoAvailableAddressesForRetryError; +export default NoAvailableAddressesForRetryError; diff --git a/packages/js-dapi-client/lib/transport/errors/response/ResponseError.js b/packages/js-dapi-client/lib/transport/errors/response/ResponseError.js index b45256bc06a..61dd677701d 100644 --- a/packages/js-dapi-client/lib/transport/errors/response/ResponseError.js +++ b/packages/js-dapi-client/lib/transport/errors/response/ResponseError.js @@ -1,4 +1,4 @@ -const DAPIClientError = require('../../../errors/DAPIClientError'); +import DAPIClientError from '../../../errors/DAPIClientError.js'; class ResponseError extends DAPIClientError { /** @@ -37,4 +37,4 @@ class ResponseError extends DAPIClientError { } } -module.exports = ResponseError; +export default ResponseError; diff --git a/packages/js-dapi-client/lib/transport/errors/response/RetriableResponseError.js b/packages/js-dapi-client/lib/transport/errors/response/RetriableResponseError.js index d15537763a6..71c2d63a4d4 100644 --- a/packages/js-dapi-client/lib/transport/errors/response/RetriableResponseError.js +++ b/packages/js-dapi-client/lib/transport/errors/response/RetriableResponseError.js @@ -1,7 +1,7 @@ -const ResponseError = require('./ResponseError'); +import ResponseError from './ResponseError.js'; class RetriableResponseError extends ResponseError { } -module.exports = RetriableResponseError; +export default RetriableResponseError; diff --git a/packages/js-dapi-client/lib/transport/errors/response/ServerError.js b/packages/js-dapi-client/lib/transport/errors/response/ServerError.js index 0af6ec6c03a..d8d8eadce6f 100644 --- a/packages/js-dapi-client/lib/transport/errors/response/ServerError.js +++ b/packages/js-dapi-client/lib/transport/errors/response/ServerError.js @@ -1,7 +1,7 @@ -const RetriableResponseError = require('./RetriableResponseError'); +import RetriableResponseError from './RetriableResponseError.js'; class ServerError extends RetriableResponseError { } -module.exports = ServerError; +export default ServerError; diff --git a/packages/js-dapi-client/lib/utils/bytes.js b/packages/js-dapi-client/lib/utils/bytes.js new file mode 100644 index 00000000000..a50dd70389c --- /dev/null +++ b/packages/js-dapi-client/lib/utils/bytes.js @@ -0,0 +1,54 @@ +export function hexToBytes(hex) { + if (typeof hex !== 'string') { + throw new TypeError('hex must be a string'); + } + if (hex.length % 2 !== 0) { + throw new Error('hex must have even length'); + } + const out = new Uint8Array(hex.length / 2); + for (let i = 0; i < out.length; i += 1) { + out[i] = parseInt(hex.substr(i * 2, 2), 16); + } + return out; +} + +export function bytesToHex(bytes) { + return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join(''); +} + +export function base64ToBytes(b64) { + const bin = atob(b64); + const out = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; i += 1) { + out[i] = bin.charCodeAt(i); + } + return out; +} + +export function bytesToBase64(bytes) { + let bin = ''; + for (let i = 0; i < bytes.length; i += 1) { + bin += String.fromCharCode(bytes[i]); + } + return btoa(bin); +} + +export function concatBytes(arrays) { + let total = 0; + for (const a of arrays) total += a.length; + const out = new Uint8Array(total); + let offset = 0; + for (const a of arrays) { + out.set(a, offset); + offset += a.length; + } + return out; +} + +export function bytesEqual(a, b) { + if (a.length !== b.length) return false; + for (let i = 0; i < a.length; i += 1) { + if (a[i] !== b[i]) return false; + } + return true; +} diff --git a/packages/js-dapi-client/lib/utils/wait.js b/packages/js-dapi-client/lib/utils/wait.js index 3494def469a..4ad8718c945 100644 --- a/packages/js-dapi-client/lib/utils/wait.js +++ b/packages/js-dapi-client/lib/utils/wait.js @@ -7,4 +7,4 @@ async function wait(ms) { return new Promise((resolve) => { setTimeout(resolve, ms); }); } -module.exports = wait; +export default wait; diff --git a/packages/js-dapi-client/package.json b/packages/js-dapi-client/package.json index 2bccc23c235..7fef7031c33 100644 --- a/packages/js-dapi-client/package.json +++ b/packages/js-dapi-client/package.json @@ -2,7 +2,14 @@ "name": "@dashevo/dapi-client", "version": "3.1.0-dev.1", "description": "Client library used to access Dash DAPI endpoints", - "main": "lib/index.js", + "type": "module", + "exports": { + ".": "./lib/index.js", + "./lib/*": "./lib/*" + }, + "engines": { + "node": ">=18.18" + }, "contributors": [ { "name": "Ivan Shumkov", @@ -31,67 +38,33 @@ "@dashevo/dashcore-lib": "~0.22.0", "@dashevo/grpc-common": "workspace:*", "@dashevo/wasm-dpp": "workspace:*", - "bs58": "^4.0.1", "cbor": "^8.0.0", + "events": "^3.3.0", "google-protobuf": "^3.12.2", - "lodash": "^4.17.23", - "node-fetch": "^2.6.7", - "node-inspect-extracted": "^1.0.8", - "wasm-x11-hash": "~0.0.2", - "winston": "^3.2.1" + "undici": "^6.0.0", + "wasm-x11-hash": "~0.0.2" }, "devDependencies": { - "@babel/core": "^7.26.10", - "assert-browserify": "^2.0.0", - "babel-loader": "^9.1.3", - "browserify-zlib": "^0.2.0", - "buffer": "^6.0.3", "chai": "^4.3.10", "chai-as-promised": "^7.1.1", "comment-parser": "^0.7.6", - "core-js": "^3.33.1", - "crypto-browserify": "^3.12.1", "dirty-chai": "^2.0.1", "eslint": "^9.18.0", - "events": "^3.3.0", - "karma": "^6.4.3", - "karma-chai": "^0.1.0", - "karma-chrome-launcher": "^3.1.0", - "karma-firefox-launcher": "^2.1.2", - "karma-mocha": "^2.0.1", - "karma-mocha-reporter": "^2.2.5", - "karma-webpack": "^5.0.0", "mocha": "^11.1.0", "nyc": "^15.1.0", - "os-browserify": "^0.3.0", - "path-browserify": "^1.0.1", - "process": "^0.11.10", - "setimmediate": "^1.0.5", "sinon": "^18.0.1", - "sinon-chai": "^3.7.0", - "stream-browserify": "^3.0.0", - "string_decoder": "^1.3.0", - "url": "^0.11.3", - "util": "^0.12.4", - "webpack": "^5.104.0", - "webpack-cli": "^4.9.1" + "sinon-chai": "^3.7.0" }, "files": [ "docs", - "lib", - "polyfills", - "dist" + "lib" ], "scripts": { - "build:web": "webpack", "lint": "eslint .", - "test": "yarn run test:coverage && yarn run test:browsers", + "test": "yarn run test:coverage", "test:unit": "mocha './test/unit/**/*.spec.js'", "test:integration": "mocha './test/integration/**/*.spec.js'", - "test:node": "NODE_ENV=test mocha", - "test:browsers": "karma start ./karma.conf.js --single-run", - "test:coverage": "NODE_ENV=test nyc --check-coverage --stmts=98 --branch=98 --funcs=98 --lines=89 yarn run mocha 'test/unit/**/*.spec.js' 'test/integration/**/*.spec.js'", - "prepublishOnly": "yarn run build:web" + "test:coverage": "NODE_ENV=test nyc --check-coverage --stmts=98 --branch=98 --funcs=98 --lines=89 yarn run mocha 'test/unit/**/*.spec.js' 'test/integration/**/*.spec.js'" }, "ultra": { "concurrent": [ diff --git a/packages/js-dapi-client/polyfills/fetch-polyfill.js b/packages/js-dapi-client/polyfills/fetch-polyfill.js deleted file mode 100644 index 8fa8ac2ffce..00000000000 --- a/packages/js-dapi-client/polyfills/fetch-polyfill.js +++ /dev/null @@ -1,10 +0,0 @@ -/* eslint-disable */ - -const { default: fetch, Headers, Request, Response } = require('node-fetch'); - -if (typeof window === 'undefined') { - globalThis.fetch = fetch; - globalThis.Headers = Headers; - globalThis.Request = Request; - globalThis.Response = Response; -} diff --git a/packages/js-dapi-client/test/integration/BlockHeadersProvider/BlockHeadersProvider.spec.js b/packages/js-dapi-client/test/integration/BlockHeadersProvider/BlockHeadersProvider.spec.js index cc731c751aa..616862c3d1b 100644 --- a/packages/js-dapi-client/test/integration/BlockHeadersProvider/BlockHeadersProvider.spec.js +++ b/packages/js-dapi-client/test/integration/BlockHeadersProvider/BlockHeadersProvider.spec.js @@ -1,8 +1,8 @@ -const { expect } = require('chai'); +import { expect } from 'chai'; -const BlockHeadersProvider = require('../../../lib/BlockHeadersProvider/BlockHeadersProvider'); -const BlockHeadersWithChainLocksStreamMock = require('../../../lib/test/mocks/BlockHeadersWithChainLocksStreamMock'); -const mockHeadersChain = require('../../../lib/test/mocks/mockHeadersChain'); +import BlockHeadersProvider from '../../../lib/BlockHeadersProvider/BlockHeadersProvider.js'; +import BlockHeadersWithChainLocksStreamMock from '../../../lib/test/mocks/BlockHeadersWithChainLocksStreamMock.js'; +import mockHeadersChain from '../../../lib/test/mocks/mockHeadersChain.js'; describe('BlockHeadersProvider - integration', function describe() { this.timeout(6000); diff --git a/packages/js-dapi-client/test/integration/DAPIClient.spec.js b/packages/js-dapi-client/test/integration/DAPIClient.spec.js index be852d3dbe1..e0f7f653c8c 100644 --- a/packages/js-dapi-client/test/integration/DAPIClient.spec.js +++ b/packages/js-dapi-client/test/integration/DAPIClient.spec.js @@ -1,6 +1,6 @@ -const DAPIClient = require('../../lib/DAPIClient'); +import DAPIClient from '../../lib/DAPIClient.js'; -const BlockHeadersProvider = require('../../lib/BlockHeadersProvider/BlockHeadersProvider'); +import BlockHeadersProvider from '../../lib/BlockHeadersProvider/BlockHeadersProvider.js'; describe('DAPIClient - integration', () => { let dapiClient; diff --git a/packages/js-dapi-client/test/integration/SMLProvider/SimplifiedMasternodeListProvider.spec.js b/packages/js-dapi-client/test/integration/SMLProvider/SimplifiedMasternodeListProvider.spec.js index aeb50c773bd..12c29fe00af 100644 --- a/packages/js-dapi-client/test/integration/SMLProvider/SimplifiedMasternodeListProvider.spec.js +++ b/packages/js-dapi-client/test/integration/SMLProvider/SimplifiedMasternodeListProvider.spec.js @@ -1,11 +1,11 @@ -const SimplifiedMNList = require('@dashevo/dashcore-lib/lib/deterministicmnlist/SimplifiedMNList'); +import SimplifiedMNList from '@dashevo/dashcore-lib/lib/deterministicmnlist/SimplifiedMNList.js'; -const SimplifiedMasternodeListProvider = require('../../../lib/SimplifiedMasternodeListProvider/SimplifiedMasternodeListProvider'); -const DAPIAddress = require('../../../lib/dapiAddressProvider/DAPIAddress'); +import SimplifiedMasternodeListProvider from '../../../lib/SimplifiedMasternodeListProvider/SimplifiedMasternodeListProvider.js'; +import DAPIAddress from '../../../lib/dapiAddressProvider/DAPIAddress.js'; -const getMNListDiffsFixture = require('../../../lib/test/fixtures/getMNListDiffsFixture'); +import getMNListDiffsFixture from '../../../lib/test/fixtures/getMNListDiffsFixture.js'; -const wait = require('../../../lib/utils/wait'); +import wait from '../../../lib/utils/wait.js'; // TODO: Update test to new implementation describe.skip('SimplifiedMasternodeListProvider', () => { diff --git a/packages/js-dapi-client/test/integration/methods/core/CoreMethodsFacade.spec.js b/packages/js-dapi-client/test/integration/methods/core/CoreMethodsFacade.spec.js index d7eeecc6875..ee8723ec442 100644 --- a/packages/js-dapi-client/test/integration/methods/core/CoreMethodsFacade.spec.js +++ b/packages/js-dapi-client/test/integration/methods/core/CoreMethodsFacade.spec.js @@ -1,4 +1,7 @@ -const { EventEmitter } = require('events'); +import EventEmitter from 'events'; +import dapiGrpc from '@dashevo/dapi-grpc'; +import BloomFilter from '@dashevo/dashcore-lib/lib/bloomfilter.js'; +import CoreMethodsFacade from '../../../../lib/methods/core/CoreMethodsFacade.js'; const { v0: { @@ -8,11 +11,7 @@ const { GetBlockchainStatusResponse, GetMasternodeStatusResponse, }, -} = require('@dashevo/dapi-grpc'); - -const BloomFilter = require('@dashevo/dashcore-lib/lib/bloomfilter'); - -const CoreMethodsFacade = require('../../../../lib/methods/core/CoreMethodsFacade'); +} = dapiGrpc; describe('CoreMethodsFacade', () => { let jsonRpcTransportMock; @@ -36,7 +35,7 @@ describe('CoreMethodsFacade', () => { response.setTransactionId('4f46066bd50cc2684484407696b7949e82bd906ea92c040f59a97cba47ed8176'); grpcTransportMock.request.resolves(response); - const transaction = Buffer.from('transaction'); + const transaction = new TextEncoder().encode('transaction'); await coreMethods.broadcastTransaction(transaction); expect(grpcTransportMock.request).to.be.calledOnce(); @@ -57,7 +56,7 @@ describe('CoreMethodsFacade', () => { describe('#getBlockByHash', () => { it('should get block by hash', async () => { - const block = Buffer.from('block'); + const block = new TextEncoder().encode('block'); const response = new GetBlockResponse(); response.setBlock(block); grpcTransportMock.request.resolves(response); @@ -70,7 +69,7 @@ describe('CoreMethodsFacade', () => { describe('#getBlockByHeight', () => { it('should get block by height', async () => { - const block = Buffer.from('block'); + const block = new TextEncoder().encode('block'); const response = new GetBlockResponse(); response.setBlock(block); grpcTransportMock.request.resolves(response); @@ -124,10 +123,10 @@ describe('CoreMethodsFacade', () => { describe('#getTransaction', () => { it('should get transaction', async () => { - const transaction = Buffer.from('transaction'); + const transaction = new TextEncoder().encode('transaction'); const response = new GetTransactionResponse(); response.setTransaction(transaction); - response.setBlockHash(Buffer.from('blockHash')); + response.setBlockHash(new TextEncoder().encode('blockHash')); response.setHeight(1); response.setConfirmations(2); diff --git a/packages/js-dapi-client/test/integration/methods/platform/PlatformMethodsFacade.spec.js b/packages/js-dapi-client/test/integration/methods/platform/PlatformMethodsFacade.spec.js index fbb1f32ed5c..473b89d03c1 100644 --- a/packages/js-dapi-client/test/integration/methods/platform/PlatformMethodsFacade.spec.js +++ b/packages/js-dapi-client/test/integration/methods/platform/PlatformMethodsFacade.spec.js @@ -1,3 +1,12 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import wasmDpp from '@dashevo/wasm-dpp'; + +import getDataContractFixture from '@dashevo/wasm-dpp/lib/test/fixtures/getDataContractFixture.js'; +import getIdentityFixture from '@dashevo/wasm-dpp/lib/test/fixtures/getIdentityFixture.js'; + +import PlatformMethodsFacade from '../../../../lib/methods/platform/PlatformMethodsFacade.js'; +import { hexToBytes, bytesToHex } from '../../../../lib/utils/bytes.js'; + const { v0: { ResponseMetadata, @@ -17,14 +26,9 @@ const { WaitForStateTransitionResultResponse, KeyPurpose, }, -} = require('@dashevo/dapi-grpc'); - -const { DashPlatformProtocol } = require('@dashevo/wasm-dpp'); - -const getDataContractFixture = require('@dashevo/wasm-dpp/lib/test/fixtures/getDataContractFixture'); -const getIdentityFixture = require('@dashevo/wasm-dpp/lib/test/fixtures/getIdentityFixture'); +} = dapiGrpc; -const PlatformMethodsFacade = require('../../../../lib/methods/platform/PlatformMethodsFacade'); +const { DashPlatformProtocol } = wasmDpp; const { WaitForStateTransitionResultResponseV0 } = WaitForStateTransitionResultResponse; const { GetIdentityResponseV0 } = GetIdentityResponse; @@ -164,8 +168,8 @@ describe('PlatformMethodsFacade', () => { grpcTransportMock.request.resolves(response); await platformMethods.getIdentitiesContractKeys([ - Buffer.alloc(32).fill(1), - ], Buffer.alloc(32).fill(2), [KeyPurpose.ENCRYPTION]); + new Uint8Array(32).fill(1), + ], new Uint8Array(32).fill(2), [KeyPurpose.ENCRYPTION]); expect(grpcTransportMock.request).to.be.calledOnce(); }); @@ -182,7 +186,7 @@ describe('PlatformMethodsFacade', () => { grpcTransportMock.request.resolves(response); await platformMethods.waitForStateTransitionResult( - Buffer.from('6f49655a2906852a38e473dd47574fb70b8b7c4e5cee9ea8e7da3f07b970c421', 'hex'), + hexToBytes('6f49655a2906852a38e473dd47574fb70b8b7c4e5cee9ea8e7da3f07b970c421'), false, ); @@ -218,8 +222,8 @@ describe('PlatformMethodsFacade', () => { describe('#getProtocolVersionUpgradeVoteStatus', () => { it('should get version upgrade votes status', async () => { - const startProTxHash = Buffer.alloc(32).fill('a').toString('hex'); - const proTxHash = Buffer.alloc(32).fill('b').toString('hex'); + const startProTxHash = bytesToHex(new Uint8Array(32).fill(0x61)); + const proTxHash = bytesToHex(new Uint8Array(32).fill(0x62)); const { VersionSignal, VersionSignals } = GetProtocolVersionUpgradeVoteStatusResponseV0; @@ -277,7 +281,7 @@ describe('PlatformMethodsFacade', () => { grpcTransportMock.request.resolves(response); - await platformMethods.getIdentityContractNonce(Buffer.alloc(32), Buffer.alloc(32)); + await platformMethods.getIdentityContractNonce(new Uint8Array(32), new Uint8Array(32)); expect(grpcTransportMock.request).to.be.calledOnce(); }); @@ -295,7 +299,7 @@ describe('PlatformMethodsFacade', () => { grpcTransportMock.request.resolves(response); - await platformMethods.getIdentityNonce(Buffer.alloc(32), Buffer.alloc(32)); + await platformMethods.getIdentityNonce(new Uint8Array(32), new Uint8Array(32)); expect(grpcTransportMock.request).to.be.calledOnce(); }); @@ -309,13 +313,13 @@ describe('PlatformMethodsFacade', () => { response.setV0( new GetIdentityKeysResponseV0() - .setKeys(new Keys().setKeysBytesList([Buffer.alloc(41), Buffer.alloc(46)])) + .setKeys(new Keys().setKeysBytesList([new Uint8Array(41), new Uint8Array(46)])) .setMetadata(new ResponseMetadata()), ); grpcTransportMock.request.resolves(response); - await platformMethods.getIdentityKeys(Buffer.alloc(32), [0, 1], 100, {}); + await platformMethods.getIdentityKeys(new Uint8Array(32), [0, 1], 100, {}); expect(grpcTransportMock.request).to.be.calledOnce(); }); diff --git a/packages/js-dapi-client/test/unit/BlockHeadersProvider/BlockHeadersProvider.spec.js b/packages/js-dapi-client/test/unit/BlockHeadersProvider/BlockHeadersProvider.spec.js index 533653210d2..93547c7bc06 100644 --- a/packages/js-dapi-client/test/unit/BlockHeadersProvider/BlockHeadersProvider.spec.js +++ b/packages/js-dapi-client/test/unit/BlockHeadersProvider/BlockHeadersProvider.spec.js @@ -1,11 +1,13 @@ -const EventEmitter = require('events'); -const { expect } = require('chai'); +import EventEmitter from 'events'; +import { expect } from 'chai'; -const { SPVError } = require('@dashevo/dash-spv'); +import dashSpv from '@dashevo/dash-spv'; -const BlockHeadersProvider = require('../../../lib/BlockHeadersProvider/BlockHeadersProvider'); -const BlockHeadersReader = require('../../../lib/BlockHeadersProvider/BlockHeadersReader'); -const getHeadersFixture = require('../../../lib/test/fixtures/getHeadersFixture'); +import BlockHeadersProvider from '../../../lib/BlockHeadersProvider/BlockHeadersProvider.js'; +import BlockHeadersReader from '../../../lib/BlockHeadersProvider/BlockHeadersReader.js'; +import getHeadersFixture from '../../../lib/test/fixtures/getHeadersFixture.js'; + +const { SPVError } = dashSpv; describe('BlockHeadersProvider - unit', () => { let blockHeadersProvider; diff --git a/packages/js-dapi-client/test/unit/BlockHeadersProvider/BlockHeadersReader.spec.js b/packages/js-dapi-client/test/unit/BlockHeadersProvider/BlockHeadersReader.spec.js index dca2784a9c0..bf9d0a594e2 100644 --- a/packages/js-dapi-client/test/unit/BlockHeadersProvider/BlockHeadersReader.spec.js +++ b/packages/js-dapi-client/test/unit/BlockHeadersProvider/BlockHeadersReader.spec.js @@ -1,8 +1,8 @@ -const { expect } = require('chai'); -const GrpcErrorCodes = require('@dashevo/grpc-common/lib/server/error/GrpcErrorCodes'); -const BlockHeadersReader = require('../../../lib/BlockHeadersProvider/BlockHeadersReader'); -const getHeadersFixture = require('../../../lib/test/fixtures/getHeadersFixture'); -const BlockHeadersWithChainLocksStreamMock = require('../../../lib/test/mocks/BlockHeadersWithChainLocksStreamMock'); +import { expect } from 'chai'; +import GrpcErrorCodes from '@dashevo/grpc-common/lib/server/error/GrpcErrorCodes.js'; +import BlockHeadersReader from '../../../lib/BlockHeadersProvider/BlockHeadersReader.js'; +import getHeadersFixture from '../../../lib/test/fixtures/getHeadersFixture.js'; +import BlockHeadersWithChainLocksStreamMock from '../../../lib/test/mocks/BlockHeadersWithChainLocksStreamMock.js'; const sleepOneTick = () => new Promise((resolve) => { if (typeof setImmediate === 'undefined') { diff --git a/packages/js-dapi-client/test/unit/BlockHeadersProvider/createBlockHeadersProviderFromOptions.spec.js b/packages/js-dapi-client/test/unit/BlockHeadersProvider/createBlockHeadersProviderFromOptions.spec.js index 995a965e836..4baa5db1428 100644 --- a/packages/js-dapi-client/test/unit/BlockHeadersProvider/createBlockHeadersProviderFromOptions.spec.js +++ b/packages/js-dapi-client/test/unit/BlockHeadersProvider/createBlockHeadersProviderFromOptions.spec.js @@ -1,5 +1,5 @@ -const BlockHeadersProvider = require('../../../lib/BlockHeadersProvider/BlockHeadersProvider'); -const createBlockHeadersProviderFromOptions = require('../../../lib/BlockHeadersProvider/createBlockHeadersProviderFromOptions'); +import BlockHeadersProvider from '../../../lib/BlockHeadersProvider/BlockHeadersProvider.js'; +import createBlockHeadersProviderFromOptions from '../../../lib/BlockHeadersProvider/createBlockHeadersProviderFromOptions.js'; describe('#createBlockHeadersProviderFromOptions', () => { const coreMethodsMock = {}; diff --git a/packages/js-dapi-client/test/unit/DAPIClient.spec.js b/packages/js-dapi-client/test/unit/DAPIClient.spec.js index cee8f160f5b..ce1a5f34ce2 100644 --- a/packages/js-dapi-client/test/unit/DAPIClient.spec.js +++ b/packages/js-dapi-client/test/unit/DAPIClient.spec.js @@ -1,9 +1,9 @@ -const DAPIClient = require('../../lib/DAPIClient'); -const CoreMethodsFacade = require('../../lib/methods/core/CoreMethodsFacade'); -const PlatformMethodsFacade = require('../../lib/methods/platform/PlatformMethodsFacade'); -const SimplifiedMasternodeListDAPIAddressProvider = require('../../lib/dapiAddressProvider/SimplifiedMasternodeListDAPIAddressProvider'); -const ListDAPIAddressProvider = require('../../lib/dapiAddressProvider/ListDAPIAddressProvider'); -const BlockHeadersProvider = require('../../lib/BlockHeadersProvider/BlockHeadersProvider'); +import DAPIClient from '../../lib/DAPIClient.js'; +import CoreMethodsFacade from '../../lib/methods/core/CoreMethodsFacade.js'; +import PlatformMethodsFacade from '../../lib/methods/platform/PlatformMethodsFacade.js'; +import SimplifiedMasternodeListDAPIAddressProvider from '../../lib/dapiAddressProvider/SimplifiedMasternodeListDAPIAddressProvider.js'; +import ListDAPIAddressProvider from '../../lib/dapiAddressProvider/ListDAPIAddressProvider.js'; +import BlockHeadersProvider from '../../lib/BlockHeadersProvider/BlockHeadersProvider.js'; describe('DAPIClient', () => { let options; diff --git a/packages/js-dapi-client/test/unit/dapiAddressProvider/DAPIAddress.spec.js b/packages/js-dapi-client/test/unit/dapiAddressProvider/DAPIAddress.spec.js index 2cc07090a2c..314fc57c99c 100644 --- a/packages/js-dapi-client/test/unit/dapiAddressProvider/DAPIAddress.spec.js +++ b/packages/js-dapi-client/test/unit/dapiAddressProvider/DAPIAddress.spec.js @@ -1,7 +1,5 @@ -const DAPIAddress = require('../../../lib/dapiAddressProvider/DAPIAddress'); -const DAPIAddressHostMissingError = require( - '../../../lib/dapiAddressProvider/errors/DAPIAddressHostMissingError', -); +import DAPIAddress from '../../../lib/dapiAddressProvider/DAPIAddress.js'; +import DAPIAddressHostMissingError from '../../../lib/dapiAddressProvider/errors/DAPIAddressHostMissingError.js'; describe('DAPIAddress', () => { let host; diff --git a/packages/js-dapi-client/test/unit/dapiAddressProvider/ListDAPIAddressProvider.spec.js b/packages/js-dapi-client/test/unit/dapiAddressProvider/ListDAPIAddressProvider.spec.js index 8b887a4ad78..6d9ca20b884 100644 --- a/packages/js-dapi-client/test/unit/dapiAddressProvider/ListDAPIAddressProvider.spec.js +++ b/packages/js-dapi-client/test/unit/dapiAddressProvider/ListDAPIAddressProvider.spec.js @@ -1,5 +1,5 @@ -const ListDAPIAddressProvider = require('../../../lib/dapiAddressProvider/ListDAPIAddressProvider'); -const DAPIAddress = require('../../../lib/dapiAddressProvider/DAPIAddress'); +import ListDAPIAddressProvider from '../../../lib/dapiAddressProvider/ListDAPIAddressProvider.js'; +import DAPIAddress from '../../../lib/dapiAddressProvider/DAPIAddress.js'; describe('ListDAPIAddressProvider', () => { let listDAPIAddressProvider; diff --git a/packages/js-dapi-client/test/unit/dapiAddressProvider/SimplifiedMasternodeListDAPIAddressProvider.spec.js b/packages/js-dapi-client/test/unit/dapiAddressProvider/SimplifiedMasternodeListDAPIAddressProvider.spec.js index f130795e44e..06a72885e42 100644 --- a/packages/js-dapi-client/test/unit/dapiAddressProvider/SimplifiedMasternodeListDAPIAddressProvider.spec.js +++ b/packages/js-dapi-client/test/unit/dapiAddressProvider/SimplifiedMasternodeListDAPIAddressProvider.spec.js @@ -1,8 +1,8 @@ -const SimplifiedMNListEntry = require('@dashevo/dashcore-lib/lib/deterministicmnlist/SimplifiedMNListEntry'); +import SimplifiedMNListEntry from '@dashevo/dashcore-lib/lib/deterministicmnlist/SimplifiedMNListEntry.js'; -const DAPIAddress = require('../../../lib/dapiAddressProvider/DAPIAddress'); +import DAPIAddress from '../../../lib/dapiAddressProvider/DAPIAddress.js'; -const SimplifiedMasternodeListDAPIAddressProvider = require('../../../lib/dapiAddressProvider/SimplifiedMasternodeListDAPIAddressProvider'); +import SimplifiedMasternodeListDAPIAddressProvider from '../../../lib/dapiAddressProvider/SimplifiedMasternodeListDAPIAddressProvider.js'; describe('SimplifiedMasternodeListDAPIAddressProvider', () => { let smlDAPIAddressProvider; diff --git a/packages/js-dapi-client/test/unit/dapiAddressProvider/createDAPIAddressProviderFromOptions.spec.js b/packages/js-dapi-client/test/unit/dapiAddressProvider/createDAPIAddressProviderFromOptions.spec.js index 52710eec1bb..b0ed3142259 100644 --- a/packages/js-dapi-client/test/unit/dapiAddressProvider/createDAPIAddressProviderFromOptions.spec.js +++ b/packages/js-dapi-client/test/unit/dapiAddressProvider/createDAPIAddressProviderFromOptions.spec.js @@ -1,12 +1,10 @@ -const createDAPIAddressProviderFromOptions = require( - '../../../lib/dapiAddressProvider/createDAPIAddressProviderFromOptions', -); -const ListDAPIAddressProvider = require('../../../lib/dapiAddressProvider/ListDAPIAddressProvider'); -const SimplifiedMasternodeListDAPIAddressProvider = require('../../../lib/dapiAddressProvider/SimplifiedMasternodeListDAPIAddressProvider'); +import createDAPIAddressProviderFromOptions from '../../../lib/dapiAddressProvider/createDAPIAddressProviderFromOptions.js'; +import ListDAPIAddressProvider from '../../../lib/dapiAddressProvider/ListDAPIAddressProvider.js'; +import SimplifiedMasternodeListDAPIAddressProvider from '../../../lib/dapiAddressProvider/SimplifiedMasternodeListDAPIAddressProvider.js'; -const networkConfigs = require('../../../lib/networkConfigs'); +import networkConfigs from '../../../lib/networkConfigs.js'; -const DAPIClientError = require('../../../lib/errors/DAPIClientError'); +import DAPIClientError from '../../../lib/errors/DAPIClientError.js'; describe('createDAPIAddressProviderFromOptions', () => { describe('dapiAddressProvider', () => { diff --git a/packages/js-dapi-client/test/unit/methods/core/broadcastTransactionFactory.spec.js b/packages/js-dapi-client/test/unit/methods/core/broadcastTransactionFactory.spec.js index 1b7ef038185..7bd0bb1a32e 100644 --- a/packages/js-dapi-client/test/unit/methods/core/broadcastTransactionFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/core/broadcastTransactionFactory.spec.js @@ -1,14 +1,13 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import broadcastTransactionFactory from '../../../../lib/methods/core/broadcastTransactionFactory.js'; + const { v0: { CorePromiseClient, BroadcastTransactionRequest, BroadcastTransactionResponse, }, -} = require('@dashevo/dapi-grpc'); - -const broadcastTransactionFactory = require( - '../../../../lib/methods/core/broadcastTransactionFactory', -); +} = dapiGrpc; describe('broadcastTransactionFactory', () => { let broadcastTransaction; @@ -25,7 +24,7 @@ describe('broadcastTransactionFactory', () => { grpcTransportMock, ); - transaction = Buffer.from('transaction'); + transaction = new TextEncoder().encode('transaction'); id = '4f46066bd50cc2684484407696b7949e82bd906ea92c040f59a97cba47ed8176'; }); diff --git a/packages/js-dapi-client/test/unit/methods/core/getBestBlockHashFactory.spec.js b/packages/js-dapi-client/test/unit/methods/core/getBestBlockHashFactory.spec.js index 28a2a20281e..7e416ec8362 100644 --- a/packages/js-dapi-client/test/unit/methods/core/getBestBlockHashFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/core/getBestBlockHashFactory.spec.js @@ -1,4 +1,4 @@ -const getBestBlockHashFactory = require('../../../../lib/methods/core/getBestBlockHashFactory'); +import getBestBlockHashFactory from '../../../../lib/methods/core/getBestBlockHashFactory.js'; describe('getBestBlockHashFactory', () => { let getBestBlockHash; diff --git a/packages/js-dapi-client/test/unit/methods/core/getBlockByHashFactory.spec.js b/packages/js-dapi-client/test/unit/methods/core/getBlockByHashFactory.spec.js index d9548cf6b69..35fe2e9e577 100644 --- a/packages/js-dapi-client/test/unit/methods/core/getBlockByHashFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/core/getBlockByHashFactory.spec.js @@ -1,12 +1,13 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import getBlockByHashFactory from '../../../../lib/methods/core/getBlockByHashFactory.js'; + const { v0: { GetBlockRequest, GetBlockResponse, CorePromiseClient, }, -} = require('@dashevo/dapi-grpc'); - -const getBlockByHashFactory = require('../../../../lib/methods/core/getBlockByHashFactory'); +} = dapiGrpc; describe('getBlockByHashFactory', () => { let getBlockByHash; @@ -14,7 +15,7 @@ describe('getBlockByHashFactory', () => { let block; beforeEach(function beforeEach() { - block = Buffer.from('block'); + block = new TextEncoder().encode('block'); const response = new GetBlockResponse(); response.setBlock(block); @@ -36,7 +37,7 @@ describe('getBlockByHashFactory', () => { const request = new GetBlockRequest(); request.setHash(hash); - expect(result).to.be.instanceof(Buffer); + expect(result).to.be.instanceof(Uint8Array); expect(result).to.deep.equal(block); expect(grpcTransportMock.request).to.be.calledOnceWithExactly( CorePromiseClient, diff --git a/packages/js-dapi-client/test/unit/methods/core/getBlockByHeightFactory.spec.js b/packages/js-dapi-client/test/unit/methods/core/getBlockByHeightFactory.spec.js index 5a6ad896648..4546d609532 100644 --- a/packages/js-dapi-client/test/unit/methods/core/getBlockByHeightFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/core/getBlockByHeightFactory.spec.js @@ -1,12 +1,13 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import getBlockByHeightFactory from '../../../../lib/methods/core/getBlockByHeightFactory.js'; + const { v0: { GetBlockRequest, GetBlockResponse, CorePromiseClient, }, -} = require('@dashevo/dapi-grpc'); - -const getBlockByHeightFactory = require('../../../../lib/methods/core/getBlockByHeightFactory'); +} = dapiGrpc; describe('getBlockByHeightFactory', () => { let getBlockByHeight; @@ -14,7 +15,7 @@ describe('getBlockByHeightFactory', () => { let block; beforeEach(function beforeEach() { - block = Buffer.from('block'); + block = new TextEncoder().encode('block'); const response = new GetBlockResponse(); response.setBlock(block); @@ -36,7 +37,7 @@ describe('getBlockByHeightFactory', () => { const request = new GetBlockRequest(); request.setHeight(height); - expect(result).to.be.instanceof(Buffer); + expect(result).to.be.instanceof(Uint8Array); expect(result).to.deep.equal(block); expect(grpcTransportMock.request).to.be.calledOnceWithExactly( CorePromiseClient, diff --git a/packages/js-dapi-client/test/unit/methods/core/getBlockHashFactory.spec.js b/packages/js-dapi-client/test/unit/methods/core/getBlockHashFactory.spec.js index 9d14ff6de78..74011973a07 100644 --- a/packages/js-dapi-client/test/unit/methods/core/getBlockHashFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/core/getBlockHashFactory.spec.js @@ -1,4 +1,4 @@ -const getBlockHashFactory = require('../../../../lib/methods/core/getBlockHashFactory'); +import getBlockHashFactory from '../../../../lib/methods/core/getBlockHashFactory.js'; describe('getBlockHashFactory', () => { let getBlockHash; diff --git a/packages/js-dapi-client/test/unit/methods/core/getBlockchainStatusFactory.spec.js b/packages/js-dapi-client/test/unit/methods/core/getBlockchainStatusFactory.spec.js index bceb20a0ec6..52bed5f7aff 100644 --- a/packages/js-dapi-client/test/unit/methods/core/getBlockchainStatusFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/core/getBlockchainStatusFactory.spec.js @@ -1,12 +1,14 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import getBlockchainStatusFactory from '../../../../lib/methods/core/getBlockchainStatusFactory.js'; +import { base64ToBytes } from '../../../../lib/utils/bytes.js'; + const { v0: { GetBlockchainStatusRequest, GetBlockchainStatusResponse, CorePromiseClient, }, -} = require('@dashevo/dapi-grpc'); - -const getBlockchainStatusFactory = require('../../../../lib/methods/core/getBlockchainStatusFactory'); +} = dapiGrpc; describe('getBlockchainStatusFactory', () => { let getBlockchainStatus; @@ -25,7 +27,7 @@ describe('getBlockchainStatusFactory', () => { response.setStatus(GetBlockchainStatusResponse.Status.READY); const chain = new GetBlockchainStatusResponse.Chain(); - chain.setBestBlockHash(Buffer.from('bestBlockHash')); + chain.setBestBlockHash(new TextEncoder().encode('bestBlockHash')); response.setChain(chain); @@ -53,7 +55,8 @@ describe('getBlockchainStatusFactory', () => { status: 'READY', }; - expectedResult.chain.bestBlockHash = Buffer.from(expectedResult.chain.bestBlockHash, 'base64'); + // toObject returns bestBlockHash as base64 string; production code converts to Uint8Array + expectedResult.chain.bestBlockHash = base64ToBytes(expectedResult.chain.bestBlockHash); expect(result).to.deep.equal(expectedResult); }); diff --git a/packages/js-dapi-client/test/unit/methods/core/getMasternodeStatusFactory.spec.js b/packages/js-dapi-client/test/unit/methods/core/getMasternodeStatusFactory.spec.js index fdd1b569e53..594e9aff501 100644 --- a/packages/js-dapi-client/test/unit/methods/core/getMasternodeStatusFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/core/getMasternodeStatusFactory.spec.js @@ -1,12 +1,13 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import getMasternodeStatusFactory from '../../../../lib/methods/core/getMasternodeStatusFactory.js'; + const { v0: { GetMasternodeStatusRequest, GetMasternodeStatusResponse, CorePromiseClient, }, -} = require('@dashevo/dapi-grpc'); - -const getMasternodeStatusFactory = require('../../../../lib/methods/core/getMasternodeStatusFactory'); +} = dapiGrpc; describe('getMasternodeStatusFactory', () => { let getMasternodeStatus; @@ -45,7 +46,7 @@ describe('getMasternodeStatusFactory', () => { const expectedResult = { ...response.toObject(), - proTxHash: Buffer.alloc(0), + proTxHash: new Uint8Array(0), status: 'READY', }; diff --git a/packages/js-dapi-client/test/unit/methods/core/getTransaction/GetTransactionResponse.spec.js b/packages/js-dapi-client/test/unit/methods/core/getTransaction/GetTransactionResponse.spec.js index 294e9a6d253..8ddab2c8679 100644 --- a/packages/js-dapi-client/test/unit/methods/core/getTransaction/GetTransactionResponse.spec.js +++ b/packages/js-dapi-client/test/unit/methods/core/getTransaction/GetTransactionResponse.spec.js @@ -1,10 +1,12 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import GetTransactionResponse from '../../../../../lib/methods/core/getTransaction/GetTransactionResponse.js'; +import InvalidResponseError from '../../../../../lib/methods/platform/response/errors/InvalidResponseError.js'; + const { v0: { GetTransactionResponse: ProtoGetTransactionResponse, }, -} = require('@dashevo/dapi-grpc'); -const GetTransactionResponse = require('../../../../../lib/methods/core/getTransaction/GetTransactionResponse'); -const InvalidResponseError = require('../../../../../lib/methods/platform/response/errors/InvalidResponseError'); +} = dapiGrpc; describe('GetTransactionResponse', () => { let getTransactionResponse; @@ -13,8 +15,8 @@ describe('GetTransactionResponse', () => { beforeEach(() => { response = { - transaction: Buffer.from('transaction'), - blockHash: Buffer.from('blockHash'), + transaction: new TextEncoder().encode('transaction'), + blockHash: new TextEncoder().encode('blockHash'), height: 10, confirmations: 42, instantLocked: true, @@ -72,8 +74,8 @@ describe('GetTransactionResponse', () => { const instance = GetTransactionResponse.createFromProto(proto); expect(instance).to.be.an.instanceOf(GetTransactionResponse); - expect(instance.transaction).to.deep.equal(Buffer.from(proto.getTransaction())); - expect(instance.blockHash).to.deep.equal(Buffer.from(proto.getBlockHash())); + expect(instance.transaction).to.deep.equal(new Uint8Array(proto.getTransaction())); + expect(instance.blockHash).to.deep.equal(new Uint8Array(proto.getBlockHash())); expect(instance.height).to.deep.equal(proto.getHeight()); expect(instance.confirmations).to.deep.equal(proto.getConfirmations()); expect(instance.instantLocked).to.deep.equal(proto.getIsInstantLocked()); diff --git a/packages/js-dapi-client/test/unit/methods/core/getTransaction/getTransactionFactory.spec.js b/packages/js-dapi-client/test/unit/methods/core/getTransaction/getTransactionFactory.spec.js index cbbe9312186..7d4b399decd 100644 --- a/packages/js-dapi-client/test/unit/methods/core/getTransaction/getTransactionFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/core/getTransaction/getTransactionFactory.spec.js @@ -1,13 +1,14 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import getTransactionFactory from '../../../../../lib/methods/core/getTransaction/getTransactionFactory.js'; +import GetTransactionResponse from '../../../../../lib/methods/core/getTransaction/GetTransactionResponse.js'; + const { v0: { GetTransactionRequest, GetTransactionResponse: ProtoGetTransactionResponse, CorePromiseClient, }, -} = require('@dashevo/dapi-grpc'); - -const getTransactionFactory = require('../../../../../lib/methods/core/getTransaction/getTransactionFactory'); -const GetTransactionResponse = require('../../../../../lib/methods/core/getTransaction/GetTransactionResponse'); +} = dapiGrpc; describe('getTransactionFactory', () => { let getTransaction; @@ -20,8 +21,8 @@ describe('getTransactionFactory', () => { let isInstantLocked; beforeEach(function beforeEach() { - transaction = Buffer.from('transaction'); - blockHash = Buffer.from('blockHash'); + transaction = new TextEncoder().encode('transaction'); + blockHash = new TextEncoder().encode('blockHash'); height = 42; confirmations = 3; isChainLocked = true; diff --git a/packages/js-dapi-client/test/unit/methods/core/subscribeToBlockHeadersWithChainLocksFactory.spec.js b/packages/js-dapi-client/test/unit/methods/core/subscribeToBlockHeadersWithChainLocksFactory.spec.js index 32ce15e4a45..59f4164f198 100644 --- a/packages/js-dapi-client/test/unit/methods/core/subscribeToBlockHeadersWithChainLocksFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/core/subscribeToBlockHeadersWithChainLocksFactory.spec.js @@ -1,14 +1,15 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import EventEmitter from 'events'; +import subscribeToBlockHeadersWithChainLocksFactory from '../../../../lib/methods/core/subscribeToBlockHeadersWithChainLocksFactory.js'; +import DAPIClientError from '../../../../lib/errors/DAPIClientError.js'; +import { hexToBytes } from '../../../../lib/utils/bytes.js'; + const { v0: { CorePromiseClient, BlockHeadersWithChainLocksRequest, }, -} = require('@dashevo/dapi-grpc'); -const { EventEmitter } = require('events'); - -const subscribeToBlockHeadersWithChainLocksFactory = require('../../../../lib/methods/core/subscribeToBlockHeadersWithChainLocksFactory'); - -const DAPIClientError = require('../../../../lib/errors/DAPIClientError'); +} = dapiGrpc; describe('subscribeToBlockHeadersWithChainLocks', () => { let subscribeToBlockHeadersWithChainLocks; @@ -50,7 +51,7 @@ describe('subscribeToBlockHeadersWithChainLocks', () => { const request = new BlockHeadersWithChainLocksRequest(); request.setFromBlockHeight(1); - request.setFromBlockHash(Buffer.from(options.fromBlockHash, 'hex')); + request.setFromBlockHash(hexToBytes(options.fromBlockHash)); request.setCount(options.count); expect(grpcTransportMock.request).to.be.calledWith( diff --git a/packages/js-dapi-client/test/unit/methods/core/subscribeToTransactionsWithProofsFactory.spec.js b/packages/js-dapi-client/test/unit/methods/core/subscribeToTransactionsWithProofsFactory.spec.js index 7fb33af14a8..18ba865c88f 100644 --- a/packages/js-dapi-client/test/unit/methods/core/subscribeToTransactionsWithProofsFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/core/subscribeToTransactionsWithProofsFactory.spec.js @@ -1,4 +1,9 @@ -const BloomFilter = require('@dashevo/dashcore-lib/lib/bloomfilter'); +import BloomFilter from '@dashevo/dashcore-lib/lib/bloomfilter.js'; +import dapiGrpc from '@dashevo/dapi-grpc'; +import EventEmitter from 'events'; +import subscribeToTransactionsWithProofsFactory from '../../../../lib/methods/core/subscribeToTransactionsWithProofsFactory.js'; +import DAPIClientError from '../../../../lib/errors/DAPIClientError.js'; +import { hexToBytes } from '../../../../lib/utils/bytes.js'; const { v0: { @@ -6,13 +11,7 @@ const { CorePromiseClient, TransactionsWithProofsRequest, }, -} = require('@dashevo/dapi-grpc'); - -const { EventEmitter } = require('events'); - -const subscribeToTransactionsWithProofsFactory = require('../../../../lib/methods/core/subscribeToTransactionsWithProofsFactory'); - -const DAPIClientError = require('../../../../lib/errors/DAPIClientError'); +} = dapiGrpc; describe('subscribeToTransactionsWithProofsFactory', () => { let subscribeToTransactionsWithProofs; @@ -54,7 +53,7 @@ describe('subscribeToTransactionsWithProofsFactory', () => { request.setBloomFilter(bloomFilterMessage); request.setFromBlockHeight(options.fromBlockHeight); request.setCount(options.count); - request.setFromBlockHash(Buffer.from(options.fromBlockHash, 'hex')); + request.setFromBlockHash(hexToBytes(options.fromBlockHash)); expect(grpcTransportMock.request).to.be.calledOnceWithExactly( CorePromiseClient, diff --git a/packages/js-dapi-client/test/unit/methods/platform/broadcaseStateTransition/broadcastStateTransitionFactory.spec.js b/packages/js-dapi-client/test/unit/methods/platform/broadcaseStateTransition/broadcastStateTransitionFactory.spec.js index f95878fb668..2f5ce704efd 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/broadcaseStateTransition/broadcastStateTransitionFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/broadcaseStateTransition/broadcastStateTransitionFactory.spec.js @@ -1,16 +1,17 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import wasmDpp from '@dashevo/wasm-dpp'; +import getDataContractFixture from '@dashevo/wasm-dpp/lib/test/fixtures/getDataContractFixture.js'; +import broadcastStateTransitionFactory from '../../../../../lib/methods/platform/broadcastStateTransition/broadcastStateTransitionFactory.js'; +import BroadcastStateTransitionResponse from '../../../../../lib/methods/platform/broadcastStateTransition/BroadcastStateTransitionResponse.js'; + const { v0: { BroadcastStateTransitionRequest, PlatformPromiseClient, }, -} = require('@dashevo/dapi-grpc'); - -const { DashPlatformProtocol } = require('@dashevo/wasm-dpp'); - -const getDataContractFixture = require('@dashevo/wasm-dpp/lib/test/fixtures/getDataContractFixture'); +} = dapiGrpc; -const broadcastStateTransitionFactory = require('../../../../../lib/methods/platform/broadcastStateTransition/broadcastStateTransitionFactory'); -const BroadcastStateTransitionResponse = require('../../../../../lib/methods/platform/broadcastStateTransition/BroadcastStateTransitionResponse'); +const { DashPlatformProtocol } = wasmDpp; describe('broadcastStateTransitionFactory', () => { let grpcTransportMock; diff --git a/packages/js-dapi-client/test/unit/methods/platform/getConsensusParams/ConsensusParamsBlock.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getConsensusParams/ConsensusParamsBlock.spec.js index 245c0bceaac..ce73bb5f12c 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getConsensusParams/ConsensusParamsBlock.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getConsensusParams/ConsensusParamsBlock.spec.js @@ -1,4 +1,4 @@ -const ConsensusParamsBlock = require('../../../../../lib/methods/platform/getConsensusParams/ConsensusParamsBlock'); +import ConsensusParamsBlock from '../../../../../lib/methods/platform/getConsensusParams/ConsensusParamsBlock.js'; describe('ConsensusParamsBlock', () => { let consensusParamsBlock; diff --git a/packages/js-dapi-client/test/unit/methods/platform/getConsensusParams/ConsensusParamsEvidence.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getConsensusParams/ConsensusParamsEvidence.spec.js index 70c6074dc4c..d2411b1845f 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getConsensusParams/ConsensusParamsEvidence.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getConsensusParams/ConsensusParamsEvidence.spec.js @@ -1,4 +1,4 @@ -const ConsensusParamsEvidence = require('../../../../../lib/methods/platform/getConsensusParams/ConsensusParamsEvidence'); +import ConsensusParamsEvidence from '../../../../../lib/methods/platform/getConsensusParams/ConsensusParamsEvidence.js'; describe('ConsensusParamsEvidence', () => { let consensusParamsEvidence; diff --git a/packages/js-dapi-client/test/unit/methods/platform/getConsensusParams/getConsensusParamsFactory.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getConsensusParams/getConsensusParamsFactory.spec.js index 77ab7d32b4b..7ac775eb8e3 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getConsensusParams/getConsensusParamsFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getConsensusParams/getConsensusParamsFactory.spec.js @@ -1,12 +1,14 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import getConsensusParamsFactory from '../../../../../lib/methods/platform/getConsensusParams/getConsensusParamsFactory.js'; +import InvalidResponseError from '../../../../../lib/methods/platform/response/errors/InvalidResponseError.js'; + const { v0: { PlatformPromiseClient, GetConsensusParamsResponse, GetConsensusParamsRequest, }, -} = require('@dashevo/dapi-grpc'); -const getConsensusParamsFactory = require('../../../../../lib/methods/platform/getConsensusParams/getConsensusParamsFactory'); -const InvalidResponseError = require('../../../../../lib/methods/platform/response/errors/InvalidResponseError'); +} = dapiGrpc; const { GetConsensusParamsRequestV0, diff --git a/packages/js-dapi-client/test/unit/methods/platform/getConsensusParams/getConsensusParamsResponse.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getConsensusParams/getConsensusParamsResponse.spec.js index 4a0a8083111..abe00f808f4 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getConsensusParams/getConsensusParamsResponse.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getConsensusParams/getConsensusParamsResponse.spec.js @@ -1,12 +1,14 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import GetConsensusParamsResponse from '../../../../../lib/methods/platform/getConsensusParams/getConsensusParamsResponse.js'; +import InvalidResponseError from '../../../../../lib/methods/platform/response/errors/InvalidResponseError.js'; +import ConsensusParamsBlock from '../../../../../lib/methods/platform/getConsensusParams/ConsensusParamsBlock.js'; +import ConsensusParamsEvidence from '../../../../../lib/methods/platform/getConsensusParams/ConsensusParamsEvidence.js'; + const { v0: { GetConsensusParamsResponse: GetConsensusParamsResponseProto, }, -} = require('@dashevo/dapi-grpc'); -const GetConsensusParamsResponse = require('../../../../../lib/methods/platform/getConsensusParams/getConsensusParamsResponse'); -const InvalidResponseError = require('../../../../../lib/methods/platform/response/errors/InvalidResponseError'); -const ConsensusParamsBlock = require('../../../../../lib/methods/platform/getConsensusParams/ConsensusParamsBlock'); -const ConsensusParamsEvidence = require('../../../../../lib/methods/platform/getConsensusParams/ConsensusParamsEvidence'); +} = dapiGrpc; const { ConsensusParamsBlock: ConsensusParamsBlockProto, diff --git a/packages/js-dapi-client/test/unit/methods/platform/getDataContract/GetDataContractResponse.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getDataContract/GetDataContractResponse.spec.js index 7ac39250489..8c4fdbe0c38 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getDataContract/GetDataContractResponse.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getDataContract/GetDataContractResponse.spec.js @@ -1,18 +1,19 @@ -const getDataContractFixture = require('@dashevo/wasm-dpp/lib/test/fixtures/getDataContractFixture'); +import getDataContractFixture from '@dashevo/wasm-dpp/lib/test/fixtures/getDataContractFixture.js'; +import dapiGrpc from '@dashevo/dapi-grpc'; +import GetDataContractResponseClass from '../../../../../lib/methods/platform/getDataContract/GetDataContractResponse.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; +import getProofFixture from '../../../../../lib/test/fixtures/getProofFixture.js'; +import InvalidResponseError from '../../../../../lib/methods/platform/response/errors/InvalidResponseError.js'; +import Proof from '../../../../../lib/methods/platform/response/Proof.js'; +import Metadata from '../../../../../lib/methods/platform/response/Metadata.js'; + const { v0: { GetDataContractResponse, ResponseMetadata, Proof: ProofResponse, }, -} = require('@dashevo/dapi-grpc'); - -const GetDataContractResponseClass = require('../../../../../lib/methods/platform/getDataContract/GetDataContractResponse'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); -const getProofFixture = require('../../../../../lib/test/fixtures/getProofFixture'); -const InvalidResponseError = require('../../../../../lib/methods/platform/response/errors/InvalidResponseError'); -const Proof = require('../../../../../lib/methods/platform/response/Proof'); -const Metadata = require('../../../../../lib/methods/platform/response/Metadata'); +} = dapiGrpc; describe('GetDataContractResponse', () => { let getDataContractResponse; @@ -41,7 +42,7 @@ describe('GetDataContractResponse', () => { it('should return proof', () => { getDataContractResponse = new GetDataContractResponseClass( - Buffer.alloc(0), + new Uint8Array(0), new Metadata(metadataFixture), new Proof(proofFixture), ); @@ -49,7 +50,7 @@ describe('GetDataContractResponse', () => { const dataContract = getDataContractResponse.getDataContract(); const proof = getDataContractResponse.getProof(); - expect(dataContract).to.deep.equal(Buffer.alloc(0)); + expect(dataContract).to.deep.equal(new Uint8Array(0)); expect(proof).to.be.an.instanceOf(Proof); expect(proof.getGrovedbProof()).to.deep.equal(proofFixture.merkleProof); expect(proof.getQuorumHash()).to.deep.equal(proofFixture.quorumHash); @@ -113,7 +114,7 @@ describe('GetDataContractResponse', () => { getDataContractResponse = GetDataContractResponseClass.createFromProto(proto); expect(getDataContractResponse).to.be.an.instanceOf(GetDataContractResponseClass); - expect(getDataContractResponse.getDataContract()).to.deep.equal(Buffer.alloc(0)); + expect(getDataContractResponse.getDataContract()).to.deep.equal(new Uint8Array(0)); expect(getDataContractResponse.getMetadata().getHeight()) .to.deep.equal(BigInt(metadataFixture.height)); diff --git a/packages/js-dapi-client/test/unit/methods/platform/getDataContract/getDataContractFactory.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getDataContract/getDataContractFactory.spec.js index 4d725d0256f..77d8cee747c 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getDataContract/getDataContractFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getDataContract/getDataContractFactory.spec.js @@ -1,3 +1,10 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import getDataContractFixture from '@dashevo/wasm-dpp/lib/test/fixtures/getDataContractFixture.js'; +import getDataContractFactory from '../../../../../lib/methods/platform/getDataContract/getDataContractFactory.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; +import getProofFixture from '../../../../../lib/test/fixtures/getProofFixture.js'; +import ProofClass from '../../../../../lib/methods/platform/response/Proof.js'; + const { v0: { PlatformPromiseClient, @@ -6,14 +13,7 @@ const { ResponseMetadata, Proof, }, -} = require('@dashevo/dapi-grpc'); - -const getDataContractFixture = require('@dashevo/wasm-dpp/lib/test/fixtures/getDataContractFixture'); - -const getDataContractFactory = require('../../../../../lib/methods/platform/getDataContract/getDataContractFactory'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); -const getProofFixture = require('../../../../../lib/test/fixtures/getProofFixture'); -const ProofClass = require('../../../../../lib/methods/platform/response/Proof'); +} = dapiGrpc; describe('getDataContractFactory', () => { let grpcTransportMock; @@ -118,7 +118,7 @@ describe('getDataContractFactory', () => { options, ]); - expect(result.getDataContract()).to.deep.equal(Buffer.alloc(0)); + expect(result.getDataContract()).to.deep.equal(new Uint8Array(0)); expect(result.getProof()).to.be.an.instanceOf(ProofClass); expect(result.getProof().getGrovedbProof()).to.deep.equal(proofFixture.merkleProof); @@ -146,7 +146,7 @@ describe('getDataContractFactory', () => { const request = new GetDataContractRequest(); request.setV0( new GetDataContractRequestV0() - .setId(contractId.toBuffer()) + .setId(new Uint8Array(contractId.toBuffer())) .setProve(false), ); diff --git a/packages/js-dapi-client/test/unit/methods/platform/getDataContractHistory/GetDataContractHistoryResponse.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getDataContractHistory/GetDataContractHistoryResponse.spec.js index 90da73d3739..406eb2a3677 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getDataContractHistory/GetDataContractHistoryResponse.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getDataContractHistory/GetDataContractHistoryResponse.spec.js @@ -1,18 +1,19 @@ -const getDataContractFixture = require('@dashevo/wasm-dpp/lib/test/fixtures/getDataContractFixture'); +import getDataContractFixture from '@dashevo/wasm-dpp/lib/test/fixtures/getDataContractFixture.js'; +import dapiGrpc from '@dashevo/dapi-grpc'; +import GetDataContractHistoryResponseClass from '../../../../../lib/methods/platform/getDataContractHistory/GetDataContractHistoryResponse.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; +import getProofFixture from '../../../../../lib/test/fixtures/getProofFixture.js'; +import InvalidResponseError from '../../../../../lib/methods/platform/response/errors/InvalidResponseError.js'; +import Proof from '../../../../../lib/methods/platform/response/Proof.js'; +import Metadata from '../../../../../lib/methods/platform/response/Metadata.js'; + const { v0: { GetDataContractHistoryResponse, ResponseMetadata, Proof: ProofResponse, }, -} = require('@dashevo/dapi-grpc'); - -const GetDataContractHistoryResponseClass = require('../../../../../lib/methods/platform/getDataContractHistory/GetDataContractHistoryResponse'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); -const getProofFixture = require('../../../../../lib/test/fixtures/getProofFixture'); -const InvalidResponseError = require('../../../../../lib/methods/platform/response/errors/InvalidResponseError'); -const Proof = require('../../../../../lib/methods/platform/response/Proof'); -const Metadata = require('../../../../../lib/methods/platform/response/Metadata'); +} = dapiGrpc; describe('GetDataContractHistoryResponse', () => { let getDataContractHistoryResponse; diff --git a/packages/js-dapi-client/test/unit/methods/platform/getDataContractHistory/getDataContractHistoryFactory.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getDataContractHistory/getDataContractHistoryFactory.spec.js index b8597e45c22..41779069062 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getDataContractHistory/getDataContractHistoryFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getDataContractHistory/getDataContractHistoryFactory.spec.js @@ -1,4 +1,12 @@ -const { UInt32Value } = require('google-protobuf/google/protobuf/wrappers_pb'); +import wrappersPb from 'google-protobuf/google/protobuf/wrappers_pb.js'; +import dapiGrpc from '@dashevo/dapi-grpc'; +import getDataContractFixture from '@dashevo/wasm-dpp/lib/test/fixtures/getDataContractFixture.js'; +import getDataContractHistoryFactory from '../../../../../lib/methods/platform/getDataContractHistory/getDataContractHistoryFactory.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; +import getProofFixture from '../../../../../lib/test/fixtures/getProofFixture.js'; +import ProofClass from '../../../../../lib/methods/platform/response/Proof.js'; + +const { UInt32Value } = wrappersPb; const { v0: { @@ -8,25 +16,16 @@ const { ResponseMetadata, Proof, }, -} = require('@dashevo/dapi-grpc'); +} = dapiGrpc; const { - v0: { - GetDataContractHistoryResponse: { - GetDataContractHistoryResponseV0: { - DataContractHistory, - DataContractHistoryEntry, - }, + GetDataContractHistoryResponse: { + GetDataContractHistoryResponseV0: { + DataContractHistory, + DataContractHistoryEntry, }, }, -} = require('@dashevo/dapi-grpc'); - -const getDataContractFixture = require('@dashevo/wasm-dpp/lib/test/fixtures/getDataContractFixture'); - -const getDataContractHistoryFactory = require('../../../../../lib/methods/platform/getDataContractHistory/getDataContractHistoryFactory'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); -const getProofFixture = require('../../../../../lib/test/fixtures/getProofFixture'); -const ProofClass = require('../../../../../lib/methods/platform/response/Proof'); +} = dapiGrpc.v0; describe('getDataContractHistoryFactory', () => { let grpcTransportMock; @@ -190,7 +189,7 @@ describe('getDataContractHistoryFactory', () => { const request = new GetDataContractHistoryRequest(); request.setV0( new GetDataContractHistoryRequestV0() - .setId(contractId.toBuffer()) + .setId(new Uint8Array(contractId.toBuffer())) .setLimit(new UInt32Value([10])) .setOffset(new UInt32Value([0])) .setStartAtMs('0') diff --git a/packages/js-dapi-client/test/unit/methods/platform/getDocuments/GetDocumentsResponse.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getDocuments/GetDocumentsResponse.spec.js index 777ceb112ff..7ab0a121f60 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getDocuments/GetDocumentsResponse.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getDocuments/GetDocumentsResponse.spec.js @@ -1,18 +1,19 @@ -const getDocumentsFixture = require('@dashevo/wasm-dpp/lib/test/fixtures/getDocumentsFixture'); +import getDocumentsFixture from '@dashevo/wasm-dpp/lib/test/fixtures/getDocumentsFixture.js'; +import dapiGrpc from '@dashevo/dapi-grpc'; +import GetDocumentsResponseClass from '../../../../../lib/methods/platform/getDocuments/GetDocumentsResponse.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; +import InvalidResponseError from '../../../../../lib/methods/platform/response/errors/InvalidResponseError.js'; +import getProofFixture from '../../../../../lib/test/fixtures/getProofFixture.js'; +import Proof from '../../../../../lib/methods/platform/response/Proof.js'; +import Metadata from '../../../../../lib/methods/platform/response/Metadata.js'; + const { v0: { GetDocumentsResponse, ResponseMetadata, Proof: ProofResponse, }, -} = require('@dashevo/dapi-grpc'); - -const GetDocumentsResponseClass = require('../../../../../lib/methods/platform/getDocuments/GetDocumentsResponse'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); -const InvalidResponseError = require('../../../../../lib/methods/platform/response/errors/InvalidResponseError'); -const getProofFixture = require('../../../../../lib/test/fixtures/getProofFixture'); -const Proof = require('../../../../../lib/methods/platform/response/Proof'); -const Metadata = require('../../../../../lib/methods/platform/response/Metadata'); +} = dapiGrpc; describe('GetDocumentsResponse', () => { let getDocumentsResponse; @@ -28,7 +29,7 @@ describe('GetDocumentsResponse', () => { proofFixture = getProofFixture(); serializedDocuments = documentsFixture - .map((document) => Buffer.from(JSON.stringify(document))); + .map((document) => new TextEncoder().encode(JSON.stringify(document))); const { GetDocumentsResponseV0 } = GetDocumentsResponse; proto = new GetDocumentsResponse(); diff --git a/packages/js-dapi-client/test/unit/methods/platform/getDocuments/getDocumentsFactory.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getDocuments/getDocumentsFactory.spec.js index 02f99ae7fca..f2e2a87afda 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getDocuments/getDocumentsFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getDocuments/getDocumentsFactory.spec.js @@ -1,5 +1,15 @@ -const cbor = require('cbor'); -const { Identifier } = require('@dashevo/wasm-dpp'); +import cbor from 'cbor'; +import wasmDpp from '@dashevo/wasm-dpp'; +import dapiGrpc from '@dashevo/dapi-grpc'; +import getDocumentsFixture from '@dashevo/wasm-dpp/lib/test/fixtures/getDocumentsFixture.js'; +import generateRandomIdentifier from '@dashevo/wasm-dpp/lib/test/utils/generateRandomIdentifierAsync.js'; +import getDocumentsFactory from '../../../../../lib/methods/platform/getDocuments/getDocumentsFactory.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; +import getProofFixture from '../../../../../lib/test/fixtures/getProofFixture.js'; +import Proof from '../../../../../lib/methods/platform/response/Proof.js'; +import { hexToBytes } from '../../../../../lib/utils/bytes.js'; + +const { Identifier } = wasmDpp; const { v0: { @@ -9,15 +19,7 @@ const { ResponseMetadata, Proof: ProofResponse, }, -} = require('@dashevo/dapi-grpc'); - -const getDocumentsFixture = require('@dashevo/wasm-dpp/lib/test/fixtures/getDocumentsFixture'); - -const generateRandomIdentifier = require('@dashevo/wasm-dpp/lib/test/utils/generateRandomIdentifierAsync'); -const getDocumentsFactory = require('../../../../../lib/methods/platform/getDocuments/getDocumentsFactory'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); -const getProofFixture = require('../../../../../lib/test/fixtures/getProofFixture'); -const Proof = require('../../../../../lib/methods/platform/response/Proof'); +} = dapiGrpc; describe('getDocumentsFactory', () => { let grpcTransportMock; @@ -53,7 +55,7 @@ describe('getDocumentsFactory', () => { documentsFixture = await getDocumentsFixture(); serializedDocuments = documentsFixture - .map((document) => Buffer.from(JSON.stringify(document))); + .map((document) => new TextEncoder().encode(JSON.stringify(document))); const metadata = new ResponseMetadata(); metadata.setHeight(metadataFixture.height); @@ -91,7 +93,7 @@ describe('getDocumentsFactory', () => { const request = new GetDocumentsRequest(); request.setV0( new GetDocumentsRequestV0() - .setDataContractId(contractIdBuffer) + .setDataContractId(new Uint8Array(contractIdBuffer)) .setDocumentType(type) .setLimit(options.limit) .setWhere(cbor.encode(options.where)) @@ -132,7 +134,7 @@ describe('getDocumentsFactory', () => { const request = new GetDocumentsRequest(); request.setV0( new GetDocumentsRequestV0() - .setDataContractId(contractIdBuffer) + .setDataContractId(new Uint8Array(contractIdBuffer)) .setDocumentType(type) .setLimit(options.limit) .setWhere(cbor.encode(options.where)) @@ -174,7 +176,7 @@ describe('getDocumentsFactory', () => { const request = new GetDocumentsRequest(); request.setV0( new GetDocumentsRequestV0() - .setDataContractId(contractIdBuffer) + .setDataContractId(new Uint8Array(contractIdBuffer)) .setDocumentType(type) .setLimit(options.limit) .setWhere(cbor.encode(options.where)) diff --git a/packages/js-dapi-client/test/unit/methods/platform/getEpochsInfo/GetEpochsInfoResponse.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getEpochsInfo/GetEpochsInfoResponse.spec.js index bb0c1e44b1f..cfd7d10745d 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getEpochsInfo/GetEpochsInfoResponse.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getEpochsInfo/GetEpochsInfoResponse.spec.js @@ -1,18 +1,19 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import GetEpochsInfoResponseClass from '../../../../../lib/methods/platform/getEpochsInfo/GetEpochsInfoResponse.js'; +import EpochInfoClass from '../../../../../lib/methods/platform/getEpochsInfo/EpochInfo.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; +import InvalidResponseError from '../../../../../lib/methods/platform/response/errors/InvalidResponseError.js'; +import getProofFixture from '../../../../../lib/test/fixtures/getProofFixture.js'; +import Proof from '../../../../../lib/methods/platform/response/Proof.js'; +import Metadata from '../../../../../lib/methods/platform/response/Metadata.js'; + const { v0: { GetEpochsInfoResponse, ResponseMetadata, Proof: ProofResponse, }, -} = require('@dashevo/dapi-grpc'); - -const GetEpochsInfoResponseClass = require('../../../../../lib/methods/platform/getEpochsInfo/GetEpochsInfoResponse'); -const EpochInfoClass = require('../../../../../lib/methods/platform/getEpochsInfo/EpochInfo'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); -const InvalidResponseError = require('../../../../../lib/methods/platform/response/errors/InvalidResponseError'); -const getProofFixture = require('../../../../../lib/test/fixtures/getProofFixture'); -const Proof = require('../../../../../lib/methods/platform/response/Proof'); -const Metadata = require('../../../../../lib/methods/platform/response/Metadata'); +} = dapiGrpc; describe('GetEpochsInfoResponse', () => { let getEpochsInfoResponse; diff --git a/packages/js-dapi-client/test/unit/methods/platform/getEpochsInfo/getEpochsInfoFactory.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getEpochsInfo/getEpochsInfoFactory.spec.js index 6e099599fa3..bbfaa0517d8 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getEpochsInfo/getEpochsInfoFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getEpochsInfo/getEpochsInfoFactory.spec.js @@ -1,3 +1,11 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import wrappersPb from 'google-protobuf/google/protobuf/wrappers_pb.js'; +import getEpochsInfoFactory from '../../../../../lib/methods/platform/getEpochsInfo/getEpochsInfoFactory.js'; +import EpochInfo from '../../../../../lib/methods/platform/getEpochsInfo/EpochInfo.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; +import getProofFixture from '../../../../../lib/test/fixtures/getProofFixture.js'; +import Proof from '../../../../../lib/methods/platform/response/Proof.js'; + const { v0: { PlatformPromiseClient, @@ -6,15 +14,9 @@ const { ResponseMetadata, Proof: ProofResponse, }, -} = require('@dashevo/dapi-grpc'); - -const { UInt32Value } = require('google-protobuf/google/protobuf/wrappers_pb'); +} = dapiGrpc; -const getEpochsInfoFactory = require('../../../../../lib/methods/platform/getEpochsInfo/getEpochsInfoFactory'); -const EpochInfo = require('../../../../../lib/methods/platform/getEpochsInfo/EpochInfo'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); -const getProofFixture = require('../../../../../lib/test/fixtures/getProofFixture'); -const Proof = require('../../../../../lib/methods/platform/response/Proof'); +const { UInt32Value } = wrappersPb; describe('getEpochsInfoFactory', () => { let grpcTransportMock; diff --git a/packages/js-dapi-client/test/unit/methods/platform/getIdentitiesContractKeys/GetIdentitiesContractKeysResponse.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getIdentitiesContractKeys/GetIdentitiesContractKeysResponse.spec.js index 920ba2c8bf2..ce429764208 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getIdentitiesContractKeys/GetIdentitiesContractKeysResponse.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getIdentitiesContractKeys/GetIdentitiesContractKeysResponse.spec.js @@ -1,5 +1,13 @@ -const generateRandomIdentifier = require('@dashevo/wasm-dpp/lib/test/utils/generateRandomIdentifierAsync'); -const getIdentityFixture = require('@dashevo/wasm-dpp/lib/test/fixtures/getIdentityFixture'); +import generateRandomIdentifier from '@dashevo/wasm-dpp/lib/test/utils/generateRandomIdentifierAsync.js'; +import getIdentityFixture from '@dashevo/wasm-dpp/lib/test/fixtures/getIdentityFixture.js'; +import dapiGrpc from '@dashevo/dapi-grpc'; +import GetIdentitiesContractKeysResponseClass from '../../../../../lib/methods/platform/getIdentitiesContractKeys/GetIdentitiesContractKeysResponse.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; +import InvalidResponseError from '../../../../../lib/methods/platform/response/errors/InvalidResponseError.js'; +import getProofFixture from '../../../../../lib/test/fixtures/getProofFixture.js'; +import Proof from '../../../../../lib/methods/platform/response/Proof.js'; +import Metadata from '../../../../../lib/methods/platform/response/Metadata.js'; + const { v0: { GetIdentitiesContractKeysResponse, @@ -7,14 +15,7 @@ const { KeyPurpose, Proof: ProofResponse, }, -} = require('@dashevo/dapi-grpc'); - -const GetIdentitiesContractKeysResponseClass = require('../../../../../lib/methods/platform/getIdentitiesContractKeys/GetIdentitiesContractKeysResponse'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); -const InvalidResponseError = require('../../../../../lib/methods/platform/response/errors/InvalidResponseError'); -const getProofFixture = require('../../../../../lib/test/fixtures/getProofFixture'); -const Proof = require('../../../../../lib/methods/platform/response/Proof'); -const Metadata = require('../../../../../lib/methods/platform/response/Metadata'); +} = dapiGrpc; describe('GetIdentitiesContractKeysResponse', () => { let getIdentitiesContractKeysResponse; diff --git a/packages/js-dapi-client/test/unit/methods/platform/getIdentitiesContractKeys/getIdentitiesContractKeysFactory.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getIdentitiesContractKeys/getIdentitiesContractKeysFactory.spec.js index 1dbb6f6be1a..4c3d76e7b03 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getIdentitiesContractKeys/getIdentitiesContractKeysFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getIdentitiesContractKeys/getIdentitiesContractKeysFactory.spec.js @@ -1,3 +1,11 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import generateRandomIdentifier from '@dashevo/wasm-dpp/lib/test/utils/generateRandomIdentifierAsync.js'; +import getIdentityFixture from '@dashevo/wasm-dpp/lib/test/fixtures/getIdentityFixture.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; +import getProofFixture from '../../../../../lib/test/fixtures/getProofFixture.js'; +import getIdentitiesContractKeysFactory from '../../../../../lib/methods/platform/getIdentitiesContractKeys/getIdentitiesContractKeysFactory.js'; +import Proof from '../../../../../lib/methods/platform/response/Proof.js'; + const { v0: { PlatformPromiseClient, @@ -7,17 +15,7 @@ const { ResponseMetadata, Proof: ProofResponse, }, -} = require('@dashevo/dapi-grpc'); -const generateRandomIdentifier = require('@dashevo/wasm-dpp/lib/test/utils/generateRandomIdentifierAsync'); - -const getIdentityFixture = require('@dashevo/wasm-dpp/lib/test/fixtures/getIdentityFixture'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); -const getProofFixture = require('../../../../../lib/test/fixtures/getProofFixture'); - -const getIdentitiesContractKeysFactory = require( - '../../../../../lib/methods/platform/getIdentitiesContractKeys/getIdentitiesContractKeysFactory', -); -const Proof = require('../../../../../lib/methods/platform/response/Proof'); +} = dapiGrpc; describe('getIdentitiesContractKeysFactory', () => { let grpcTransportMock; @@ -113,9 +111,9 @@ describe('getIdentitiesContractKeysFactory', () => { new GetIdentitiesContractKeysRequestV0() .setProve(!!options.prove) .setIdentitiesIdsList( - [Buffer.from(identityFixtureA.getId()), Buffer.from(identityFixtureB.getId())], + [new Uint8Array(identityFixtureA.getId()), new Uint8Array(identityFixtureB.getId())], ) - .setContractId(Buffer.from(contractId)) + .setContractId(new Uint8Array(contractId)) .setPurposesList([KeyPurpose.ENCRYPTION, KeyPurpose.DECRYPTION]) .setDocumentTypeName('contactRequest'), ); diff --git a/packages/js-dapi-client/test/unit/methods/platform/getIdentity/GetIdentityResponse.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getIdentity/GetIdentityResponse.spec.js index 788184965fa..a340631d8f7 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getIdentity/GetIdentityResponse.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getIdentity/GetIdentityResponse.spec.js @@ -1,18 +1,19 @@ -const getIdentityFixture = require('@dashevo/wasm-dpp/lib/test/fixtures/getIdentityFixture'); +import getIdentityFixture from '@dashevo/wasm-dpp/lib/test/fixtures/getIdentityFixture.js'; +import dapiGrpc from '@dashevo/dapi-grpc'; +import GetIdentityResponseClass from '../../../../../lib/methods/platform/getIdentity/GetIdentityResponse.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; +import InvalidResponseError from '../../../../../lib/methods/platform/response/errors/InvalidResponseError.js'; +import getProofFixture from '../../../../../lib/test/fixtures/getProofFixture.js'; +import Proof from '../../../../../lib/methods/platform/response/Proof.js'; +import Metadata from '../../../../../lib/methods/platform/response/Metadata.js'; + const { v0: { GetIdentityResponse, ResponseMetadata, Proof: ProofResponse, }, -} = require('@dashevo/dapi-grpc'); - -const GetIdentityResponseClass = require('../../../../../lib/methods/platform/getIdentity/GetIdentityResponse'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); -const InvalidResponseError = require('../../../../../lib/methods/platform/response/errors/InvalidResponseError'); -const getProofFixture = require('../../../../../lib/test/fixtures/getProofFixture'); -const Proof = require('../../../../../lib/methods/platform/response/Proof'); -const Metadata = require('../../../../../lib/methods/platform/response/Metadata'); +} = dapiGrpc; describe('GetIdentityResponse', () => { let getIdentityResponse; @@ -58,7 +59,7 @@ describe('GetIdentityResponse', () => { it('should return proof', () => { getIdentityResponse = new GetIdentityResponseClass( - Buffer.alloc(0), + new Uint8Array(0), new Metadata(metadataFixture), new Proof(proofFixture), ); @@ -66,7 +67,7 @@ describe('GetIdentityResponse', () => { const identity = getIdentityResponse.getIdentity(); const proof = getIdentityResponse.getProof(); - expect(identity).to.deep.equal(Buffer.alloc(0)); + expect(identity).to.deep.equal(new Uint8Array(0)); expect(proof).to.be.an.instanceOf(Proof); expect(proof.getGrovedbProof()).to.deep.equal(proofFixture.merkleProof); expect(proof.getQuorumHash()).to.deep.equal(proofFixture.quorumHash); @@ -104,7 +105,7 @@ describe('GetIdentityResponse', () => { getIdentityResponse = GetIdentityResponseClass.createFromProto(proto); - expect(getIdentityResponse.getIdentity()).to.deep.equal(Buffer.alloc(0)); + expect(getIdentityResponse.getIdentity()).to.deep.equal(new Uint8Array(0)); expect(getIdentityResponse.getMetadata().getHeight()) .to.deep.equal(BigInt(metadataFixture.height)); diff --git a/packages/js-dapi-client/test/unit/methods/platform/getIdentity/getIdentityFactory.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getIdentity/getIdentityFactory.spec.js index 711ff8b16c3..4ed6448a487 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getIdentity/getIdentityFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getIdentity/getIdentityFactory.spec.js @@ -1,3 +1,10 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import getIdentityFixture from '@dashevo/wasm-dpp/lib/test/fixtures/getIdentityFixture.js'; +import getIdentityFactory from '../../../../../lib/methods/platform/getIdentity/getIdentityFactory.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; +import getProofFixture from '../../../../../lib/test/fixtures/getProofFixture.js'; +import Proof from '../../../../../lib/methods/platform/response/Proof.js'; + const { v0: { PlatformPromiseClient, @@ -6,14 +13,7 @@ const { ResponseMetadata, Proof: ProofResponse, }, -} = require('@dashevo/dapi-grpc'); - -const getIdentityFixture = require('@dashevo/wasm-dpp/lib/test/fixtures/getIdentityFixture'); - -const getIdentityFactory = require('../../../../../lib/methods/platform/getIdentity/getIdentityFactory'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); -const getProofFixture = require('../../../../../lib/test/fixtures/getProofFixture'); -const Proof = require('../../../../../lib/methods/platform/response/Proof'); +} = dapiGrpc; describe('getIdentityFactory', () => { let grpcTransportMock; @@ -72,7 +72,7 @@ describe('getIdentityFactory', () => { const request = new GetIdentityRequest(); request.setV0( new GetIdentityRequestV0() - .setId(identityId.toBuffer()) + .setId(new Uint8Array(identityId.toBuffer())) .setProve(false), ); @@ -107,7 +107,7 @@ describe('getIdentityFactory', () => { const request = new GetIdentityRequest(); request.setV0( new GetIdentityRequestV0() - .setId(identityId.toBuffer()) + .setId(new Uint8Array(identityId.toBuffer())) .setProve(true), ); @@ -118,7 +118,7 @@ describe('getIdentityFactory', () => { options, ); - expect(result.getIdentity()).to.deep.equal(Buffer.alloc(0)); + expect(result.getIdentity()).to.deep.equal(new Uint8Array(0)); expect(result.getMetadata().getHeight()) .to.deep.equal(BigInt(metadataFixture.height)); @@ -145,7 +145,7 @@ describe('getIdentityFactory', () => { const request = new GetIdentityRequest(); request.setV0( new GetIdentityRequestV0() - .setId(identityId.toBuffer()) + .setId(new Uint8Array(identityId.toBuffer())) .setProve(false), ); diff --git a/packages/js-dapi-client/test/unit/methods/platform/getIdentityBalance/GetIdentityBalanceResponse.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getIdentityBalance/GetIdentityBalanceResponse.spec.js index 51d5d1ccce3..acff90b7138 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getIdentityBalance/GetIdentityBalanceResponse.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getIdentityBalance/GetIdentityBalanceResponse.spec.js @@ -1,17 +1,18 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import GetIdentityBalanceResponseClass from '../../../../../lib/methods/platform/getIdentityBalance/GetIdentityBalanceResponse.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; +import InvalidResponseError from '../../../../../lib/methods/platform/response/errors/InvalidResponseError.js'; +import getProofFixture from '../../../../../lib/test/fixtures/getProofFixture.js'; +import Proof from '../../../../../lib/methods/platform/response/Proof.js'; +import Metadata from '../../../../../lib/methods/platform/response/Metadata.js'; + const { v0: { GetIdentityBalanceResponse, ResponseMetadata, Proof: ProofResponse, }, -} = require('@dashevo/dapi-grpc'); - -const GetIdentityBalanceResponseClass = require('../../../../../lib/methods/platform/getIdentityBalance/GetIdentityBalanceResponse'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); -const InvalidResponseError = require('../../../../../lib/methods/platform/response/errors/InvalidResponseError'); -const getProofFixture = require('../../../../../lib/test/fixtures/getProofFixture'); -const Proof = require('../../../../../lib/methods/platform/response/Proof'); -const Metadata = require('../../../../../lib/methods/platform/response/Metadata'); +} = dapiGrpc; describe('GetIdentityBalanceResponse', () => { let getIdentityBalanceResponse; diff --git a/packages/js-dapi-client/test/unit/methods/platform/getIdentityBalance/getIdentityBalanceFactory.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getIdentityBalance/getIdentityBalanceFactory.spec.js index daffa9f3cbc..ef6b724c524 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getIdentityBalance/getIdentityBalanceFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getIdentityBalance/getIdentityBalanceFactory.spec.js @@ -1,3 +1,9 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import getIdentityBalanceFactory from '../../../../../lib/methods/platform/getIdentityBalance/getIdentityBalanceFactory.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; +import getProofFixture from '../../../../../lib/test/fixtures/getProofFixture.js'; +import Proof from '../../../../../lib/methods/platform/response/Proof.js'; + const { v0: { PlatformPromiseClient, @@ -6,15 +12,10 @@ const { ResponseMetadata, Proof: ProofResponse, }, -} = require('@dashevo/dapi-grpc'); +} = dapiGrpc; const { GetIdentityBalanceResponseV0 } = GetIdentityBalanceResponse; -const getIdentityBalanceFactory = require('../../../../../lib/methods/platform/getIdentityBalance/getIdentityBalanceFactory'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); -const getProofFixture = require('../../../../../lib/test/fixtures/getProofFixture'); -const Proof = require('../../../../../lib/methods/platform/response/Proof'); - describe('getIdentityBalanceFactory', () => { let grpcTransportMock; let getIdentityBalance; @@ -29,7 +30,7 @@ describe('getIdentityBalanceFactory', () => { beforeEach(async function beforeEach() { balance = BigInt(1337); - identityId = Buffer.alloc(32).fill(0); + identityId = new Uint8Array(32); metadataFixture = getMetadataFixture(); proofFixture = getProofFixture(); diff --git a/packages/js-dapi-client/test/unit/methods/platform/getIdentityByPublicKeyHash/GetIdentityByPublicKeyHashResponse.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getIdentityByPublicKeyHash/GetIdentityByPublicKeyHashResponse.spec.js index 18545b0f54c..63aee92fc83 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getIdentityByPublicKeyHash/GetIdentityByPublicKeyHashResponse.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getIdentityByPublicKeyHash/GetIdentityByPublicKeyHashResponse.spec.js @@ -1,18 +1,19 @@ -const getIdentityFixture = require('@dashevo/wasm-dpp/lib/test/fixtures/getIdentityFixture'); +import getIdentityFixture from '@dashevo/wasm-dpp/lib/test/fixtures/getIdentityFixture.js'; +import dapiGrpc from '@dashevo/dapi-grpc'; +import GetIdentityByPublicKeyHashResponseClass from '../../../../../lib/methods/platform/getIdentityByPublicKeyHash/GetIdentityByPublicKeyHashResponse.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; +import InvalidResponseError from '../../../../../lib/methods/platform/response/errors/InvalidResponseError.js'; +import getProofFixture from '../../../../../lib/test/fixtures/getProofFixture.js'; +import Proof from '../../../../../lib/methods/platform/response/Proof.js'; +import Metadata from '../../../../../lib/methods/platform/response/Metadata.js'; + const { v0: { GetIdentityByPublicKeyHashResponse, ResponseMetadata, Proof: ProofResponse, }, -} = require('@dashevo/dapi-grpc'); - -const GetIdentityByPublicKeyHashResponseClass = require('../../../../../lib/methods/platform/getIdentityByPublicKeyHash/GetIdentityByPublicKeyHashResponse'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); -const InvalidResponseError = require('../../../../../lib/methods/platform/response/errors/InvalidResponseError'); -const getProofFixture = require('../../../../../lib/test/fixtures/getProofFixture'); -const Proof = require('../../../../../lib/methods/platform/response/Proof'); -const Metadata = require('../../../../../lib/methods/platform/response/Metadata'); +} = dapiGrpc; describe('GetIdentityByPublicKeyHashResponse', () => { let getIdentityResponse; @@ -118,7 +119,7 @@ describe('GetIdentityByPublicKeyHashResponse', () => { expect(getIdentityResponse).to.be.an.instanceOf( GetIdentityByPublicKeyHashResponseClass, ); - expect(getIdentityResponse.getIdentity()).to.deep.equal(Buffer.alloc(0)); + expect(getIdentityResponse.getIdentity()).to.deep.equal(new Uint8Array(0)); expect(getIdentityResponse.getMetadata().getHeight()) .to.deep.equal(BigInt(metadataFixture.height)); diff --git a/packages/js-dapi-client/test/unit/methods/platform/getIdentityByPublicKeyHash/getIdentityByPublicKeyHashFactory.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getIdentityByPublicKeyHash/getIdentityByPublicKeyHashFactory.spec.js index 1a8514b375c..08c80e80493 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getIdentityByPublicKeyHash/getIdentityByPublicKeyHashFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getIdentityByPublicKeyHash/getIdentityByPublicKeyHashFactory.spec.js @@ -1,3 +1,10 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import getIdentityFixture from '@dashevo/wasm-dpp/lib/test/fixtures/getIdentityFixture.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; +import getProofFixture from '../../../../../lib/test/fixtures/getProofFixture.js'; +import getIdentityByPublicKeyHashFactory from '../../../../../lib/methods/platform/getIdentityByPublicKeyHash/getIdentityByPublicKeyHashFactory.js'; +import Proof from '../../../../../lib/methods/platform/response/Proof.js'; + const { v0: { PlatformPromiseClient, @@ -6,16 +13,7 @@ const { ResponseMetadata, Proof: ProofResponse, }, -} = require('@dashevo/dapi-grpc'); - -const getIdentityFixture = require('@dashevo/wasm-dpp/lib/test/fixtures/getIdentityFixture'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); -const getProofFixture = require('../../../../../lib/test/fixtures/getProofFixture'); - -const getIdentityByPublicKeyHashFactory = require( - '../../../../../lib/methods/platform/getIdentityByPublicKeyHash/getIdentityByPublicKeyHashFactory', -); -const Proof = require('../../../../../lib/methods/platform/response/Proof'); +} = dapiGrpc; describe('getIdentityByPublicKeyHashFactory', () => { let grpcTransportMock; @@ -121,7 +119,7 @@ describe('getIdentityByPublicKeyHashFactory', () => { request, options, ); - expect(result.getIdentity()).to.deep.equal(Buffer.alloc(0)); + expect(result.getIdentity()).to.deep.equal(new Uint8Array(0)); expect(result.getMetadata().getHeight()) .to.deep.equal(BigInt(metadataFixture.height)); diff --git a/packages/js-dapi-client/test/unit/methods/platform/getIdentityContractNonce/GetIdentityContractNonce.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getIdentityContractNonce/GetIdentityContractNonce.spec.js index 1d8065f2875..2a7a8ae0be3 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getIdentityContractNonce/GetIdentityContractNonce.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getIdentityContractNonce/GetIdentityContractNonce.spec.js @@ -1,17 +1,18 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import GetIdentityContractNonceResponseClass from '../../../../../lib/methods/platform/getIdentityContractNonce/GetIdentityContractNonceResponse.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; +import InvalidResponseError from '../../../../../lib/methods/platform/response/errors/InvalidResponseError.js'; +import getProofFixture from '../../../../../lib/test/fixtures/getProofFixture.js'; +import Proof from '../../../../../lib/methods/platform/response/Proof.js'; +import Metadata from '../../../../../lib/methods/platform/response/Metadata.js'; + const { v0: { GetIdentityContractNonceResponse, ResponseMetadata, Proof: ProofResponse, }, -} = require('@dashevo/dapi-grpc'); - -const GetIdentityContractNonceResponseClass = require('../../../../../lib/methods/platform/getIdentityContractNonce/GetIdentityContractNonceResponse'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); -const InvalidResponseError = require('../../../../../lib/methods/platform/response/errors/InvalidResponseError'); -const getProofFixture = require('../../../../../lib/test/fixtures/getProofFixture'); -const Proof = require('../../../../../lib/methods/platform/response/Proof'); -const Metadata = require('../../../../../lib/methods/platform/response/Metadata'); +} = dapiGrpc; describe('GetIdentityContractNonceResponse', () => { let getIdentityContractNonceResponse; @@ -56,7 +57,7 @@ describe('GetIdentityContractNonceResponse', () => { it('should return proof', () => { getIdentityContractNonceResponse = new GetIdentityContractNonceResponseClass( - Buffer.alloc(0), + new Uint8Array(0), new Metadata(metadataFixture), new Proof(proofFixture), ); @@ -64,7 +65,7 @@ describe('GetIdentityContractNonceResponse', () => { const identityContractNonce = getIdentityContractNonceResponse.getIdentityContractNonce(); const proof = getIdentityContractNonceResponse.getProof(); - expect(identityContractNonce).to.deep.equal(Buffer.alloc(0)); + expect(identityContractNonce).to.deep.equal(new Uint8Array(0)); expect(proof).to.be.an.instanceOf(Proof); expect(proof.getGrovedbProof()).to.deep.equal(proofFixture.merkleProof); expect(proof.getQuorumHash()).to.deep.equal(proofFixture.quorumHash); diff --git a/packages/js-dapi-client/test/unit/methods/platform/getIdentityContractNonce/getIdentityContractNonceFactory.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getIdentityContractNonce/getIdentityContractNonceFactory.spec.js index 966820157a5..743b6b12216 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getIdentityContractNonce/getIdentityContractNonceFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getIdentityContractNonce/getIdentityContractNonceFactory.spec.js @@ -1,3 +1,9 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import getIdentityContractNonceFactory from '../../../../../lib/methods/platform/getIdentityContractNonce/getIdentityContractNonceFactory.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; +import getProofFixture from '../../../../../lib/test/fixtures/getProofFixture.js'; +import Proof from '../../../../../lib/methods/platform/response/Proof.js'; + const { v0: { PlatformPromiseClient, @@ -6,12 +12,7 @@ const { ResponseMetadata, Proof: ProofResponse, }, -} = require('@dashevo/dapi-grpc'); - -const getIdentityContractNonceFactory = require('../../../../../lib/methods/platform/getIdentityContractNonce/getIdentityContractNonceFactory'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); -const getProofFixture = require('../../../../../lib/test/fixtures/getProofFixture'); -const Proof = require('../../../../../lib/methods/platform/response/Proof'); +} = dapiGrpc; describe('getIdentityContractNonceFactory', () => { let grpcTransportMock; @@ -27,8 +28,8 @@ describe('getIdentityContractNonceFactory', () => { beforeEach(async function beforeEach() { nonce = BigInt(1); - identityId = Buffer.alloc(32).fill(0); - contractId = Buffer.alloc(32).fill(1); + identityId = new Uint8Array(32); + contractId = new Uint8Array(32).fill(1); metadataFixture = getMetadataFixture(); proofFixture = getProofFixture(); diff --git a/packages/js-dapi-client/test/unit/methods/platform/getIdentityKeys/GetIdentityKeys.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getIdentityKeys/GetIdentityKeys.spec.js index 84e88aee243..dc3b1872886 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getIdentityKeys/GetIdentityKeys.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getIdentityKeys/GetIdentityKeys.spec.js @@ -1,17 +1,18 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import GetIdentityKeysResponseClass from '../../../../../lib/methods/platform/getIdentityKeys/GetIdentityKeysResponse.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; +import InvalidResponseError from '../../../../../lib/methods/platform/response/errors/InvalidResponseError.js'; +import getProofFixture from '../../../../../lib/test/fixtures/getProofFixture.js'; +import Proof from '../../../../../lib/methods/platform/response/Proof.js'; +import Metadata from '../../../../../lib/methods/platform/response/Metadata.js'; + const { v0: { GetIdentityKeysResponse, ResponseMetadata, Proof: ProofResponse, }, -} = require('@dashevo/dapi-grpc'); - -const GetIdentityKeysResponseClass = require('../../../../../lib/methods/platform/getIdentityKeys/GetIdentityKeysResponse'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); -const InvalidResponseError = require('../../../../../lib/methods/platform/response/errors/InvalidResponseError'); -const getProofFixture = require('../../../../../lib/test/fixtures/getProofFixture'); -const Proof = require('../../../../../lib/methods/platform/response/Proof'); -const Metadata = require('../../../../../lib/methods/platform/response/Metadata'); +} = dapiGrpc; describe('GetIdentityKeysResponse', () => { let getIdentityKeysResponse; @@ -22,7 +23,7 @@ describe('GetIdentityKeysResponse', () => { beforeEach(async () => { metadataFixture = getMetadataFixture(); - keys = [Buffer.alloc(41).fill(1), Buffer.alloc(48).fill(2), Buffer.alloc(55).fill(3)]; + keys = [new Uint8Array(41).fill(1), new Uint8Array(48).fill(2), new Uint8Array(55).fill(3)]; proofFixture = getProofFixture(); const { GetIdentityKeysResponseV0 } = GetIdentityKeysResponse; @@ -58,7 +59,7 @@ describe('GetIdentityKeysResponse', () => { it('should return proof', () => { getIdentityKeysResponse = new GetIdentityKeysResponseClass( - Buffer.alloc(0), + new Uint8Array(0), new Metadata(metadataFixture), new Proof(proofFixture), ); @@ -66,7 +67,7 @@ describe('GetIdentityKeysResponse', () => { const identityKeys = getIdentityKeysResponse.getIdentityKeys(); const proof = getIdentityKeysResponse.getProof(); - expect(identityKeys).to.deep.equal(Buffer.alloc(0)); + expect(identityKeys).to.deep.equal(new Uint8Array(0)); expect(proof).to.be.an.instanceOf(Proof); expect(proof.getGrovedbProof()).to.deep.equal(proofFixture.merkleProof); expect(proof.getQuorumHash()).to.deep.equal(proofFixture.quorumHash); diff --git a/packages/js-dapi-client/test/unit/methods/platform/getIdentityKeys/getIdentityKeysFactory.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getIdentityKeys/getIdentityKeysFactory.spec.js index f9873c97a62..38899e14998 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getIdentityKeys/getIdentityKeysFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getIdentityKeys/getIdentityKeysFactory.spec.js @@ -1,3 +1,10 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import wrappersPb from 'google-protobuf/google/protobuf/wrappers_pb.js'; +import getIdentityKeysFactory from '../../../../../lib/methods/platform/getIdentityKeys/getIdentityKeysFactory.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; +import getProofFixture from '../../../../../lib/test/fixtures/getProofFixture.js'; +import Proof from '../../../../../lib/methods/platform/response/Proof.js'; + const { v0: { PlatformPromiseClient, @@ -9,17 +16,13 @@ const { SpecificKeys, AllKeys, }, -} = require('@dashevo/dapi-grpc'); -const { UInt32Value } = require('google-protobuf/google/protobuf/wrappers_pb'); +} = dapiGrpc; + +const { UInt32Value } = wrappersPb; const { GetIdentityKeysResponseV0 } = GetIdentityKeysResponse; const { Keys } = GetIdentityKeysResponseV0; -const getIdentityKeysFactory = require('../../../../../lib/methods/platform/getIdentityKeys/getIdentityKeysFactory'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); -const getProofFixture = require('../../../../../lib/test/fixtures/getProofFixture'); -const Proof = require('../../../../../lib/methods/platform/response/Proof'); - describe('getIdentityKeysFactory', () => { let grpcTransportMock; let getIdentityKeys; @@ -35,11 +38,11 @@ describe('getIdentityKeysFactory', () => { let proofResponse; beforeEach(async function beforeEach() { - keys = [Buffer.alloc(41), Buffer.alloc(46)]; + keys = [new Uint8Array(41), new Uint8Array(46)]; keyIds = [0, 1]; limit = 100; - identityId = Buffer.alloc(32).fill(0); + identityId = new Uint8Array(32); metadataFixture = getMetadataFixture(); proofFixture = getProofFixture(); diff --git a/packages/js-dapi-client/test/unit/methods/platform/getIdentityNonce/GetIdentityNonce.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getIdentityNonce/GetIdentityNonce.spec.js index b79e8a27014..56ed74b7edd 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getIdentityNonce/GetIdentityNonce.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getIdentityNonce/GetIdentityNonce.spec.js @@ -1,17 +1,18 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import GetIdentityNonceResponseClass from '../../../../../lib/methods/platform/getIdentityNonce/GetIdentityNonceResponse.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; +import InvalidResponseError from '../../../../../lib/methods/platform/response/errors/InvalidResponseError.js'; +import getProofFixture from '../../../../../lib/test/fixtures/getProofFixture.js'; +import Proof from '../../../../../lib/methods/platform/response/Proof.js'; +import Metadata from '../../../../../lib/methods/platform/response/Metadata.js'; + const { v0: { GetIdentityNonceResponse, ResponseMetadata, Proof: ProofResponse, }, -} = require('@dashevo/dapi-grpc'); - -const GetIdentityNonceResponseClass = require('../../../../../lib/methods/platform/getIdentityNonce/GetIdentityNonceResponse'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); -const InvalidResponseError = require('../../../../../lib/methods/platform/response/errors/InvalidResponseError'); -const getProofFixture = require('../../../../../lib/test/fixtures/getProofFixture'); -const Proof = require('../../../../../lib/methods/platform/response/Proof'); -const Metadata = require('../../../../../lib/methods/platform/response/Metadata'); +} = dapiGrpc; describe('GetIdentityNonceResponse', () => { let getIdentityNonceResponse; @@ -56,7 +57,7 @@ describe('GetIdentityNonceResponse', () => { it('should return proof', () => { getIdentityNonceResponse = new GetIdentityNonceResponseClass( - Buffer.alloc(0), + new Uint8Array(0), new Metadata(metadataFixture), new Proof(proofFixture), ); @@ -64,7 +65,7 @@ describe('GetIdentityNonceResponse', () => { const IdentityNonce = getIdentityNonceResponse.getIdentityNonce(); const proof = getIdentityNonceResponse.getProof(); - expect(IdentityNonce).to.deep.equal(Buffer.alloc(0)); + expect(IdentityNonce).to.deep.equal(new Uint8Array(0)); expect(proof).to.be.an.instanceOf(Proof); expect(proof.getGrovedbProof()).to.deep.equal(proofFixture.merkleProof); expect(proof.getQuorumHash()).to.deep.equal(proofFixture.quorumHash); diff --git a/packages/js-dapi-client/test/unit/methods/platform/getIdentityNonce/getIdentityNonceFactory.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getIdentityNonce/getIdentityNonceFactory.spec.js index 564b7326da3..aeb7535e5b2 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getIdentityNonce/getIdentityNonceFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getIdentityNonce/getIdentityNonceFactory.spec.js @@ -1,3 +1,9 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import getIdentityNonceFactory from '../../../../../lib/methods/platform/getIdentityNonce/getIdentityNonceFactory.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; +import getProofFixture from '../../../../../lib/test/fixtures/getProofFixture.js'; +import Proof from '../../../../../lib/methods/platform/response/Proof.js'; + const { v0: { PlatformPromiseClient, @@ -6,12 +12,7 @@ const { ResponseMetadata, Proof: ProofResponse, }, -} = require('@dashevo/dapi-grpc'); - -const getIdentityNonceFactory = require('../../../../../lib/methods/platform/getIdentityNonce/getIdentityNonceFactory'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); -const getProofFixture = require('../../../../../lib/test/fixtures/getProofFixture'); -const Proof = require('../../../../../lib/methods/platform/response/Proof'); +} = dapiGrpc; describe('getIdentityNonceFactory', () => { let grpcTransportMock; @@ -26,7 +27,7 @@ describe('getIdentityNonceFactory', () => { beforeEach(async function beforeEach() { nonce = BigInt(1); - identityId = Buffer.alloc(32).fill(0); + identityId = new Uint8Array(32); metadataFixture = getMetadataFixture(); proofFixture = getProofFixture(); diff --git a/packages/js-dapi-client/test/unit/methods/platform/getProtocolVersionUpgradeState/GetProtocolVersionUpgradeStateResponse.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getProtocolVersionUpgradeState/GetProtocolVersionUpgradeStateResponse.spec.js index e837ff1d0b8..369973f335e 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getProtocolVersionUpgradeState/GetProtocolVersionUpgradeStateResponse.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getProtocolVersionUpgradeState/GetProtocolVersionUpgradeStateResponse.spec.js @@ -1,18 +1,20 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; + +import GetProtocolVersionUpgradeStateResponseClass from '../../../../../lib/methods/platform/getProtocolVersionUpgradeState/GetProtocolVersionUpgradeStateResponse.js'; +import VersionEntryClass from '../../../../../lib/methods/platform/getProtocolVersionUpgradeState/VersionEntry.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; +import InvalidResponseError from '../../../../../lib/methods/platform/response/errors/InvalidResponseError.js'; +import getProofFixture from '../../../../../lib/test/fixtures/getProofFixture.js'; +import Proof from '../../../../../lib/methods/platform/response/Proof.js'; +import Metadata from '../../../../../lib/methods/platform/response/Metadata.js'; + const { v0: { GetProtocolVersionUpgradeStateResponse, ResponseMetadata, Proof: ProofResponse, }, -} = require('@dashevo/dapi-grpc'); - -const GetProtocolVersionUpgradeStateResponseClass = require('../../../../../lib/methods/platform/getProtocolVersionUpgradeState/GetProtocolVersionUpgradeStateResponse'); -const VersionEntryClass = require('../../../../../lib/methods/platform/getProtocolVersionUpgradeState/VersionEntry'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); -const InvalidResponseError = require('../../../../../lib/methods/platform/response/errors/InvalidResponseError'); -const getProofFixture = require('../../../../../lib/test/fixtures/getProofFixture'); -const Proof = require('../../../../../lib/methods/platform/response/Proof'); -const Metadata = require('../../../../../lib/methods/platform/response/Metadata'); +} = dapiGrpc; describe('GetProtocolVersionUpgradeStateResponse', () => { let getProtocolVersionUpgradeState; @@ -122,9 +124,9 @@ describe('GetProtocolVersionUpgradeStateResponse', () => { const proof = getProtocolVersionUpgradeState.getProof(); expect(proof).to.be.an.instanceOf(Proof); - expect(proof.getGrovedbProof()).to.deep.equal(proofFixture.merkleProof); - expect(proof.getQuorumHash()).to.deep.equal(proofFixture.quorumHash); - expect(proof.getSignature()).to.deep.equal(proofFixture.signature); + expect(proof.getGrovedbProof()).to.deep.equal(new Uint8Array(proofFixture.merkleProof)); + expect(proof.getQuorumHash()).to.deep.equal(new Uint8Array(proofFixture.quorumHash)); + expect(proof.getSignature()).to.deep.equal(new Uint8Array(proofFixture.signature)); expect(proof.getRound()).to.deep.equal(proofFixture.round); }); diff --git a/packages/js-dapi-client/test/unit/methods/platform/getProtocolVersionUpgradeState/getProtocolVersionUpgradeStateFactory.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getProtocolVersionUpgradeState/getProtocolVersionUpgradeStateFactory.spec.js index 06760cff863..4d1c1471cca 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getProtocolVersionUpgradeState/getProtocolVersionUpgradeStateFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getProtocolVersionUpgradeState/getProtocolVersionUpgradeStateFactory.spec.js @@ -1,3 +1,11 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; + +import getProtocolVersionUpgradeStateFactory from '../../../../../lib/methods/platform/getProtocolVersionUpgradeState/getProtocolVersionUpgradeStateFactory.js'; +import VersionEntry from '../../../../../lib/methods/platform/getProtocolVersionUpgradeState/VersionEntry.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; +import getProofFixture from '../../../../../lib/test/fixtures/getProofFixture.js'; +import Proof from '../../../../../lib/methods/platform/response/Proof.js'; + const { v0: { PlatformPromiseClient, @@ -6,13 +14,7 @@ const { ResponseMetadata, Proof: ProofResponse, }, -} = require('@dashevo/dapi-grpc'); - -const getProtocolVersionUpgradeStateFactory = require('../../../../../lib/methods/platform/getProtocolVersionUpgradeState/getProtocolVersionUpgradeStateFactory'); -const VersionEntry = require('../../../../../lib/methods/platform/getProtocolVersionUpgradeState/VersionEntry'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); -const getProofFixture = require('../../../../../lib/test/fixtures/getProofFixture'); -const Proof = require('../../../../../lib/methods/platform/response/Proof'); +} = dapiGrpc; describe('getProtocolVersionUpgradeStateFactory', () => { let grpcTransportMock; @@ -134,9 +136,9 @@ describe('getProtocolVersionUpgradeStateFactory', () => { .to.deep.equal(metadataFixture.protocolVersion); expect(result.getProof()).to.be.an.instanceOf(Proof); - expect(result.getProof().getGrovedbProof()).to.deep.equal(proofFixture.merkleProof); - expect(result.getProof().getQuorumHash()).to.deep.equal(proofFixture.quorumHash); - expect(result.getProof().getSignature()).to.deep.equal(proofFixture.signature); + expect(result.getProof().getGrovedbProof()).to.deep.equal(new Uint8Array(proofFixture.merkleProof)); + expect(result.getProof().getQuorumHash()).to.deep.equal(new Uint8Array(proofFixture.quorumHash)); + expect(result.getProof().getSignature()).to.deep.equal(new Uint8Array(proofFixture.signature)); expect(result.getProof().getRound()).to.deep.equal(proofFixture.round); }); diff --git a/packages/js-dapi-client/test/unit/methods/platform/getProtocolVersionUpgradeVoteStatus/GetProtocolVersionUpgradeVoteStatusResponse.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getProtocolVersionUpgradeVoteStatus/GetProtocolVersionUpgradeVoteStatusResponse.spec.js index b6e6f887bd4..cdb3e38c81b 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getProtocolVersionUpgradeVoteStatus/GetProtocolVersionUpgradeVoteStatusResponse.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getProtocolVersionUpgradeVoteStatus/GetProtocolVersionUpgradeVoteStatusResponse.spec.js @@ -1,18 +1,21 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; + +import GetProtocolVersionUpgradeVoteStatusResponseClass from '../../../../../lib/methods/platform/getProtocolVersionUpgradeVoteStatus/GetProtocolVersionUpgradeVoteStatusResponse.js'; +import VersionSignalClass from '../../../../../lib/methods/platform/getProtocolVersionUpgradeVoteStatus/VersionSignal.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; +import InvalidResponseError from '../../../../../lib/methods/platform/response/errors/InvalidResponseError.js'; +import getProofFixture from '../../../../../lib/test/fixtures/getProofFixture.js'; +import Proof from '../../../../../lib/methods/platform/response/Proof.js'; +import Metadata from '../../../../../lib/methods/platform/response/Metadata.js'; +import { bytesToHex, hexToBytes } from '../../../../../lib/utils/bytes.js'; + const { v0: { GetProtocolVersionUpgradeVoteStatusResponse, ResponseMetadata, Proof: ProofResponse, }, -} = require('@dashevo/dapi-grpc'); - -const GetProtocolVersionUpgradeVoteStatusResponseClass = require('../../../../../lib/methods/platform/getProtocolVersionUpgradeVoteStatus/GetProtocolVersionUpgradeVoteStatusResponse'); -const VersionSignalClass = require('../../../../../lib/methods/platform/getProtocolVersionUpgradeVoteStatus/VersionSignal'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); -const InvalidResponseError = require('../../../../../lib/methods/platform/response/errors/InvalidResponseError'); -const getProofFixture = require('../../../../../lib/test/fixtures/getProofFixture'); -const Proof = require('../../../../../lib/methods/platform/response/Proof'); -const Metadata = require('../../../../../lib/methods/platform/response/Metadata'); +} = dapiGrpc; describe('GetProtocolVersionUpgradeVoteStatusResponse', () => { let getProtocolVersionUpgradeVoteStatus; @@ -23,7 +26,7 @@ describe('GetProtocolVersionUpgradeVoteStatusResponse', () => { beforeEach(async () => { metadataFixture = getMetadataFixture(); - versionSignalFixture = new VersionSignalClass(Buffer.alloc(32).toString('hex'), 1); + versionSignalFixture = new VersionSignalClass(bytesToHex(new Uint8Array(32)), 1); proofFixture = getProofFixture(); const { @@ -42,7 +45,7 @@ describe('GetProtocolVersionUpgradeVoteStatusResponse', () => { new GetProtocolVersionUpgradeVoteStatusResponseV0() .setVersions(new VersionSignals() .setVersionSignalsList([new VersionSignal() - .setProTxHash(Buffer.from(versionSignalFixture.getProTxHash(), 'hex')) + .setProTxHash(hexToBytes(versionSignalFixture.getProTxHash())) .setVersion(versionSignalFixture.getVersion()), ])) .setMetadata(metadata), @@ -125,9 +128,9 @@ describe('GetProtocolVersionUpgradeVoteStatusResponse', () => { const proof = getProtocolVersionUpgradeVoteStatus.getProof(); expect(proof).to.be.an.instanceOf(Proof); - expect(proof.getGrovedbProof()).to.deep.equal(proofFixture.merkleProof); - expect(proof.getQuorumHash()).to.deep.equal(proofFixture.quorumHash); - expect(proof.getSignature()).to.deep.equal(proofFixture.signature); + expect(proof.getGrovedbProof()).to.deep.equal(new Uint8Array(proofFixture.merkleProof)); + expect(proof.getQuorumHash()).to.deep.equal(new Uint8Array(proofFixture.quorumHash)); + expect(proof.getSignature()).to.deep.equal(new Uint8Array(proofFixture.signature)); expect(proof.getRound()).to.deep.equal(proofFixture.round); }); diff --git a/packages/js-dapi-client/test/unit/methods/platform/getProtocolVersionUpgradeVoteStatus/getProtocolVersionUpgradeVoteStatusFactory.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getProtocolVersionUpgradeVoteStatus/getProtocolVersionUpgradeVoteStatusFactory.spec.js index ff36627aa02..779cab9b3a8 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getProtocolVersionUpgradeVoteStatus/getProtocolVersionUpgradeVoteStatusFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getProtocolVersionUpgradeVoteStatus/getProtocolVersionUpgradeVoteStatusFactory.spec.js @@ -1,3 +1,12 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; + +import getProtocolVersionUpgradeVoteStatusFactory from '../../../../../lib/methods/platform/getProtocolVersionUpgradeVoteStatus/getProtocolVersionUpgradeVoteStatusFactory.js'; +import VersionSignal from '../../../../../lib/methods/platform/getProtocolVersionUpgradeVoteStatus/VersionSignal.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; +import getProofFixture from '../../../../../lib/test/fixtures/getProofFixture.js'; +import Proof from '../../../../../lib/methods/platform/response/Proof.js'; +import { bytesToHex, hexToBytes } from '../../../../../lib/utils/bytes.js'; + const { v0: { PlatformPromiseClient, @@ -6,13 +15,7 @@ const { ResponseMetadata, Proof: ProofResponse, }, -} = require('@dashevo/dapi-grpc'); - -const getProtocolVersionUpgradeVoteStatusFactory = require('../../../../../lib/methods/platform/getProtocolVersionUpgradeVoteStatus/getProtocolVersionUpgradeVoteStatusFactory'); -const VersionSignal = require('../../../../../lib/methods/platform/getProtocolVersionUpgradeVoteStatus/VersionSignal'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); -const getProofFixture = require('../../../../../lib/test/fixtures/getProofFixture'); -const Proof = require('../../../../../lib/methods/platform/response/Proof'); +} = dapiGrpc; describe('getProtocolVersionUpgradeVoteStatusFactory', () => { let grpcTransportMock; @@ -26,8 +29,8 @@ describe('getProtocolVersionUpgradeVoteStatusFactory', () => { let startProTxHash; beforeEach(async function beforeEach() { - startProTxHash = Buffer.alloc(32).fill('a').toString('hex'); - versionSignalFixture = new VersionSignal(Buffer.alloc(32).toString('hex'), 1); + startProTxHash = bytesToHex(new Uint8Array(32).fill(0x61)); + versionSignalFixture = new VersionSignal(bytesToHex(new Uint8Array(32)), 1); metadataFixture = getMetadataFixture(); proofFixture = getProofFixture(); @@ -50,7 +53,7 @@ describe('getProtocolVersionUpgradeVoteStatusFactory', () => { new GetProtocolVersionUpgradeVoteStatusResponseV0() .setVersions(new VersionSignals() .setVersionSignalsList([new VersionSignalProto() - .setProTxHash(Buffer.from(versionSignalFixture.getProTxHash(), 'hex')) + .setProTxHash(hexToBytes(versionSignalFixture.getProTxHash())) .setVersion(versionSignalFixture.getVersion())])) .setMetadata(metadata), ); @@ -84,7 +87,7 @@ describe('getProtocolVersionUpgradeVoteStatusFactory', () => { const request = new GetProtocolVersionUpgradeVoteStatusRequest(); request.setV0( new GetProtocolVersionUpgradeVoteStatusRequestV0() - .setStartProTxHash(Buffer.from(startProTxHash, 'hex')) + .setStartProTxHash(hexToBytes(startProTxHash)) .setCount(1) .setProve(!!options.prove), ); @@ -124,7 +127,7 @@ describe('getProtocolVersionUpgradeVoteStatusFactory', () => { const request = new GetProtocolVersionUpgradeVoteStatusRequest(); request.setV0( new GetProtocolVersionUpgradeVoteStatusRequestV0() - .setStartProTxHash(Buffer.from(startProTxHash, 'hex')) + .setStartProTxHash(hexToBytes(startProTxHash)) .setCount(1) .setProve(!!options.ascending), ); @@ -148,9 +151,9 @@ describe('getProtocolVersionUpgradeVoteStatusFactory', () => { .to.deep.equal(metadataFixture.protocolVersion); expect(result.getProof()).to.be.an.instanceOf(Proof); - expect(result.getProof().getGrovedbProof()).to.deep.equal(proofFixture.merkleProof); - expect(result.getProof().getQuorumHash()).to.deep.equal(proofFixture.quorumHash); - expect(result.getProof().getSignature()).to.deep.equal(proofFixture.signature); + expect(result.getProof().getGrovedbProof()).to.deep.equal(new Uint8Array(proofFixture.merkleProof)); + expect(result.getProof().getQuorumHash()).to.deep.equal(new Uint8Array(proofFixture.quorumHash)); + expect(result.getProof().getSignature()).to.deep.equal(new Uint8Array(proofFixture.signature)); expect(result.getProof().getRound()).to.deep.equal(proofFixture.round); }); @@ -165,7 +168,7 @@ describe('getProtocolVersionUpgradeVoteStatusFactory', () => { const request = new GetProtocolVersionUpgradeVoteStatusRequest(); request.setV0( new GetProtocolVersionUpgradeVoteStatusRequestV0() - .setStartProTxHash(Buffer.from(startProTxHash, 'hex')) + .setStartProTxHash(hexToBytes(startProTxHash)) .setCount(1) .setProve(!!options.ascending), ); diff --git a/packages/js-dapi-client/test/unit/methods/platform/getStatus/GetStatusResponse.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getStatus/GetStatusResponse.spec.js index 0639f6a3830..9b576c9d895 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getStatus/GetStatusResponse.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getStatus/GetStatusResponse.spec.js @@ -1,17 +1,20 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; + +import GetStatusResponseClass from '../../../../../lib/methods/platform/getStatus/GetStatusResponse.js'; +import getStatusFixture from '../../../../../lib/test/fixtures/getStatusFixture.js'; +import VersionStatus from '../../../../../lib/methods/platform/getStatus/VersionStatus.js'; +import NodeStatus from '../../../../../lib/methods/platform/getStatus/NodeStatus.js'; +import ChainStatus from '../../../../../lib/methods/platform/getStatus/ChainStatus.js'; +import NetworkStatus from '../../../../../lib/methods/platform/getStatus/NetworkStatus.js'; +import StateSyncStatus from '../../../../../lib/methods/platform/getStatus/StateSyncStatus.js'; +import TimeStatus from '../../../../../lib/methods/platform/getStatus/TimeStatus.js'; +import { bytesToHex } from '../../../../../lib/utils/bytes.js'; + const { v0: { GetStatusResponse, }, -} = require('@dashevo/dapi-grpc'); - -const GetStatusResponseClass = require('../../../../../lib/methods/platform/getStatus/GetStatusResponse'); -const getStatusFixture = require('../../../../../lib/test/fixtures/getStatusFixture'); -const VersionStatus = require('../../../../../lib/methods/platform/getStatus/VersionStatus'); -const NodeStatus = require('../../../../../lib/methods/platform/getStatus/NodeStatus'); -const ChainStatus = require('../../../../../lib/methods/platform/getStatus/ChainStatus'); -const NetworkStatus = require('../../../../../lib/methods/platform/getStatus/NetworkStatus'); -const StateSyncStatus = require('../../../../../lib/methods/platform/getStatus/StateSyncStatus'); -const TimeStatus = require('../../../../../lib/methods/platform/getStatus/TimeStatus'); +} = dapiGrpc; describe('GetStatusResponse', () => { let getStatusResponse; @@ -90,17 +93,17 @@ describe('GetStatusResponse', () => { ); const node = new NodeStatus( - Buffer.from(statusFixture.node.id).toString('hex'), - Buffer.from(statusFixture.node.proTxHash).toString('hex'), + bytesToHex(statusFixture.node.id), + bytesToHex(statusFixture.node.proTxHash), ); const chain = new ChainStatus( statusFixture.chain.catchingUp, - Buffer.from(statusFixture.chain.latestBlockHash).toString('hex'), - Buffer.from(statusFixture.chain.latestAppHash).toString('hex'), + bytesToHex(statusFixture.chain.latestBlockHash), + bytesToHex(statusFixture.chain.latestAppHash), BigInt(statusFixture.chain.latestBlockHeight), - Buffer.from(statusFixture.chain.earliestBlockHash).toString('hex'), - Buffer.from(statusFixture.chain.earliestAppHash).toString('hex'), + bytesToHex(statusFixture.chain.earliestBlockHash), + bytesToHex(statusFixture.chain.earliestAppHash), BigInt(statusFixture.chain.earliestBlockHeight), BigInt(statusFixture.chain.maxPeerBlockHeight), statusFixture.chain.coreChainLockedHeight, @@ -219,22 +222,22 @@ describe('GetStatusResponse', () => { .to.equal(statusFixture.version.protocol.drive.nextEpoch); expect(nodeStatus).to.be.an.instanceOf(NodeStatus); - expect(nodeStatus.getNodeId()).to.equal(Buffer.from(statusFixture.node.id).toString('hex')); - expect(nodeStatus.getProTxHash()).to.equal(Buffer.from(statusFixture.node.proTxHash).toString('hex')); + expect(nodeStatus.getNodeId()).to.equal(bytesToHex(statusFixture.node.id)); + expect(nodeStatus.getProTxHash()).to.equal(bytesToHex(statusFixture.node.proTxHash)); expect(chainStatus).to.be.an.instanceOf(ChainStatus); expect(chainStatus.isCatchingUp()) .to.equal(statusFixture.chain.catchingUp); expect(chainStatus.getLatestBlockHash()) - .to.equal(Buffer.from(statusFixture.chain.latestBlockHash).toString('hex')); + .to.equal(bytesToHex(statusFixture.chain.latestBlockHash)); expect(chainStatus.getLatestAppHash()) - .to.equal(Buffer.from(statusFixture.chain.latestAppHash).toString('hex')); + .to.equal(bytesToHex(statusFixture.chain.latestAppHash)); expect(chainStatus.getLatestBlockHeight()) .to.equal(BigInt(statusFixture.chain.latestBlockHeight)); expect(chainStatus.getEarliestBlockHash()) - .to.equal(Buffer.from(statusFixture.chain.earliestBlockHash).toString('hex')); + .to.equal(bytesToHex(statusFixture.chain.earliestBlockHash)); expect(chainStatus.getEarliestAppHash()) - .to.equal(Buffer.from(statusFixture.chain.earliestAppHash).toString('hex')); + .to.equal(bytesToHex(statusFixture.chain.earliestAppHash)); expect(chainStatus.getEarliestBlockHeight()) .to.equal(BigInt(statusFixture.chain.earliestBlockHeight)); expect(chainStatus.getMaxPeerBlockHeight()) @@ -297,22 +300,22 @@ describe('GetStatusResponse', () => { .to.equal(statusFixture.version.protocol.drive.latest); expect(nodeStatus).to.be.an.instanceOf(NodeStatus); - expect(nodeStatus.getNodeId()).to.equal(Buffer.from(statusFixture.node.id).toString('hex')); - expect(nodeStatus.getProTxHash()).to.equal(Buffer.from(statusFixture.node.proTxHash).toString('hex')); + expect(nodeStatus.getNodeId()).to.equal(bytesToHex(statusFixture.node.id)); + expect(nodeStatus.getProTxHash()).to.equal(bytesToHex(statusFixture.node.proTxHash)); expect(chainStatus).to.be.an.instanceOf(ChainStatus); expect(chainStatus.isCatchingUp()) .to.equal(statusFixture.chain.catchingUp); expect(chainStatus.getLatestBlockHash()) - .to.equal(Buffer.from(statusFixture.chain.latestBlockHash).toString('hex')); + .to.equal(bytesToHex(statusFixture.chain.latestBlockHash)); expect(chainStatus.getLatestAppHash()) - .to.equal(Buffer.from(statusFixture.chain.latestAppHash).toString('hex')); + .to.equal(bytesToHex(statusFixture.chain.latestAppHash)); expect(chainStatus.getLatestBlockHeight()) .to.equal(BigInt(statusFixture.chain.latestBlockHeight)); expect(chainStatus.getEarliestBlockHash()) - .to.equal(Buffer.from(statusFixture.chain.earliestBlockHash).toString('hex')); + .to.equal(bytesToHex(statusFixture.chain.earliestBlockHash)); expect(chainStatus.getEarliestAppHash()) - .to.equal(Buffer.from(statusFixture.chain.earliestAppHash).toString('hex')); + .to.equal(bytesToHex(statusFixture.chain.earliestAppHash)); expect(chainStatus.getEarliestBlockHeight()) .to.equal(BigInt(statusFixture.chain.earliestBlockHeight)); expect(chainStatus.getMaxPeerBlockHeight()) diff --git a/packages/js-dapi-client/test/unit/methods/platform/getStatus/getStatusFactory.spec.js b/packages/js-dapi-client/test/unit/methods/platform/getStatus/getStatusFactory.spec.js index 40c91a9e4f5..20d718fb2dd 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/getStatus/getStatusFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/getStatus/getStatusFactory.spec.js @@ -1,19 +1,22 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; + +import getStatusFixture from '../../../../../lib/test/fixtures/getStatusFixture.js'; +import getStatusFactory from '../../../../../lib/methods/platform/getStatus/getStatusFactory.js'; +import VersionStatus from '../../../../../lib/methods/platform/getStatus/VersionStatus.js'; +import NodeStatus from '../../../../../lib/methods/platform/getStatus/NodeStatus.js'; +import ChainStatus from '../../../../../lib/methods/platform/getStatus/ChainStatus.js'; +import NetworkStatus from '../../../../../lib/methods/platform/getStatus/NetworkStatus.js'; +import StateSyncStatus from '../../../../../lib/methods/platform/getStatus/StateSyncStatus.js'; +import TimeStatus from '../../../../../lib/methods/platform/getStatus/TimeStatus.js'; +import { bytesToHex } from '../../../../../lib/utils/bytes.js'; + const { v0: { PlatformPromiseClient, GetStatusRequest, GetStatusResponse, }, -} = require('@dashevo/dapi-grpc'); - -const getStatusFixture = require('../../../../../lib/test/fixtures/getStatusFixture'); -const getStatusFactory = require('../../../../../lib/methods/platform/getStatus/getStatusFactory'); -const VersionStatus = require('../../../../../lib/methods/platform/getStatus/VersionStatus'); -const NodeStatus = require('../../../../../lib/methods/platform/getStatus/NodeStatus'); -const ChainStatus = require('../../../../../lib/methods/platform/getStatus/ChainStatus'); -const NetworkStatus = require('../../../../../lib/methods/platform/getStatus/NetworkStatus'); -const StateSyncStatus = require('../../../../../lib/methods/platform/getStatus/StateSyncStatus'); -const TimeStatus = require('../../../../../lib/methods/platform/getStatus/TimeStatus'); +} = dapiGrpc; describe('getStatusFactory', () => { let grpcTransportMock; @@ -131,22 +134,22 @@ describe('getStatusFactory', () => { .to.equal(statusFixture.version.protocol.drive.nextEpoch); expect(nodeStatus).to.be.an.instanceOf(NodeStatus); - expect(nodeStatus.getNodeId()).to.equal(Buffer.from(statusFixture.node.id).toString('hex')); - expect(nodeStatus.getProTxHash()).to.equal(Buffer.from(statusFixture.node.proTxHash).toString('hex')); + expect(nodeStatus.getNodeId()).to.equal(bytesToHex(statusFixture.node.id)); + expect(nodeStatus.getProTxHash()).to.equal(bytesToHex(statusFixture.node.proTxHash)); expect(chainStatus).to.be.an.instanceOf(ChainStatus); expect(chainStatus.isCatchingUp()) .to.equal(statusFixture.chain.catchingUp); expect(chainStatus.getLatestBlockHash()) - .to.equal(Buffer.from(statusFixture.chain.latestBlockHash).toString('hex')); + .to.equal(bytesToHex(statusFixture.chain.latestBlockHash)); expect(chainStatus.getLatestAppHash()) - .to.equal(Buffer.from(statusFixture.chain.latestAppHash).toString('hex')); + .to.equal(bytesToHex(statusFixture.chain.latestAppHash)); expect(chainStatus.getLatestBlockHeight()) .to.equal(BigInt(statusFixture.chain.latestBlockHeight)); expect(chainStatus.getEarliestBlockHash()) - .to.equal(Buffer.from(statusFixture.chain.earliestBlockHash).toString('hex')); + .to.equal(bytesToHex(statusFixture.chain.earliestBlockHash)); expect(chainStatus.getEarliestAppHash()) - .to.equal(Buffer.from(statusFixture.chain.earliestAppHash).toString('hex')); + .to.equal(bytesToHex(statusFixture.chain.earliestAppHash)); expect(chainStatus.getEarliestBlockHeight()) .to.equal(BigInt(statusFixture.chain.earliestBlockHeight)); expect(chainStatus.getMaxPeerBlockHeight()) @@ -227,22 +230,22 @@ describe('getStatusFactory', () => { .to.equal(statusFixture.version.protocol.drive.latest); expect(nodeStatus).to.be.an.instanceOf(NodeStatus); - expect(nodeStatus.getNodeId()).to.equal(Buffer.from(statusFixture.node.id).toString('hex')); + expect(nodeStatus.getNodeId()).to.equal(bytesToHex(statusFixture.node.id)); expect(nodeStatus.getProTxHash()).to.be.null(); expect(chainStatus).to.be.an.instanceOf(ChainStatus); expect(chainStatus.isCatchingUp()) .to.equal(statusFixture.chain.catchingUp); expect(chainStatus.getLatestBlockHash()) - .to.equal(Buffer.from(statusFixture.chain.latestBlockHash).toString('hex')); + .to.equal(bytesToHex(statusFixture.chain.latestBlockHash)); expect(chainStatus.getLatestAppHash()) - .to.equal(Buffer.from(statusFixture.chain.latestAppHash).toString('hex')); + .to.equal(bytesToHex(statusFixture.chain.latestAppHash)); expect(chainStatus.getLatestBlockHeight()) .to.equal(BigInt(statusFixture.chain.latestBlockHeight)); expect(chainStatus.getEarliestBlockHash()) - .to.equal(Buffer.from(statusFixture.chain.earliestBlockHash).toString('hex')); + .to.equal(bytesToHex(statusFixture.chain.earliestBlockHash)); expect(chainStatus.getEarliestAppHash()) - .to.equal(Buffer.from(statusFixture.chain.earliestAppHash).toString('hex')); + .to.equal(bytesToHex(statusFixture.chain.earliestAppHash)); expect(chainStatus.getEarliestBlockHeight()) .to.equal(BigInt(statusFixture.chain.earliestBlockHeight)); expect(chainStatus.getMaxPeerBlockHeight()) diff --git a/packages/js-dapi-client/test/unit/methods/platform/waitForStateTransitionResult/waitForStateTransitionResultFactory.spec.js b/packages/js-dapi-client/test/unit/methods/platform/waitForStateTransitionResult/waitForStateTransitionResultFactory.spec.js index 3f7d22932f7..7d0efa2bb3b 100644 --- a/packages/js-dapi-client/test/unit/methods/platform/waitForStateTransitionResult/waitForStateTransitionResultFactory.spec.js +++ b/packages/js-dapi-client/test/unit/methods/platform/waitForStateTransitionResult/waitForStateTransitionResultFactory.spec.js @@ -1,3 +1,9 @@ +import dapiGrpc from '@dashevo/dapi-grpc'; +import cbor from 'cbor'; + +import waitForStateTransitionResultFactory from '../../../../../lib/methods/platform/waitForStateTransitionResult/waitForStateTransitionResultFactory.js'; +import getMetadataFixture from '../../../../../lib/test/fixtures/getMetadataFixture.js'; + const { v0: { PlatformPromiseClient, @@ -7,11 +13,9 @@ const { Proof, ResponseMetadata, }, -} = require('@dashevo/dapi-grpc'); -const cbor = require('cbor'); +} = dapiGrpc; -const waitForStateTransitionResultFactory = require('../../../../../lib/methods/platform/waitForStateTransitionResult/waitForStateTransitionResultFactory'); -const getMetadataFixture = require('../../../../../lib/test/fixtures/getMetadataFixture'); +const encoder = new TextEncoder(); describe('waitForStateTransitionResultFactory', () => { let grpcTransportMock; @@ -22,7 +26,7 @@ describe('waitForStateTransitionResultFactory', () => { let metadataFixture; beforeEach(function beforeEach() { - hash = Buffer.from('hash'); + hash = encoder.encode('hash'); metadataFixture = getMetadataFixture(); const metadata = new ResponseMetadata(); @@ -86,9 +90,9 @@ describe('waitForStateTransitionResultFactory', () => { it('should return response with proof', async () => { const proof = new Proof(); - proof.setGrovedbProof(Buffer.from('merkleProof')); - proof.setQuorumHash(Buffer.from('quorumHash')); - proof.setSignature(Buffer.from('signature')); + proof.setGrovedbProof(encoder.encode('merkleProof')); + proof.setQuorumHash(encoder.encode('quorumHash')); + proof.setSignature(encoder.encode('signature')); proof.setRound(42); response.getV0().setProof(proof); @@ -108,14 +112,14 @@ describe('waitForStateTransitionResultFactory', () => { expect(result.getError()).to.equal(undefined); expect(result.getProof()).to.be.deep.equal({ - merkleProof: Buffer.from('merkleProof'), - quorumHash: Buffer.from('quorumHash'), - signature: Buffer.from('signature'), + merkleProof: encoder.encode('merkleProof'), + quorumHash: encoder.encode('quorumHash'), + signature: encoder.encode('signature'), round: 42, }); - expect(result.getProof().getSignature()).to.deep.equal(Buffer.from('signature')); - expect(result.getProof().getGrovedbProof()).to.deep.equal(Buffer.from('merkleProof')); - expect(result.getProof().getQuorumHash()).to.deep.equal(Buffer.from('quorumHash')); + expect(result.getProof().getSignature()).to.deep.equal(encoder.encode('signature')); + expect(result.getProof().getGrovedbProof()).to.deep.equal(encoder.encode('merkleProof')); + expect(result.getProof().getQuorumHash()).to.deep.equal(encoder.encode('quorumHash')); expect(result.getProof().getRound()).to.deep.equal(42); const { WaitForStateTransitionResultRequestV0 } = WaitForStateTransitionResultRequest; @@ -161,7 +165,7 @@ describe('waitForStateTransitionResultFactory', () => { expect(result.getError()).to.be.deep.equal({ code: 2, message: 'Some error', - data: Buffer.from(data), + data: new Uint8Array(data), }); const { WaitForStateTransitionResultRequestV0 } = WaitForStateTransitionResultRequest; diff --git a/packages/js-dapi-client/test/unit/transport/GrpcTransport/GrpcTransport.spec.js b/packages/js-dapi-client/test/unit/transport/GrpcTransport/GrpcTransport.spec.js index 53e55f4911e..bc69e36af41 100644 --- a/packages/js-dapi-client/test/unit/transport/GrpcTransport/GrpcTransport.spec.js +++ b/packages/js-dapi-client/test/unit/transport/GrpcTransport/GrpcTransport.spec.js @@ -1,15 +1,15 @@ -const GrpcErrorCodes = require('@dashevo/grpc-common/lib/server/error/GrpcErrorCodes'); - -const GrpcError = require('@dashevo/grpc-common/lib/server/error/GrpcError'); -const GrpcTransport = require('../../../../lib/transport/GrpcTransport/GrpcTransport'); -const DAPIAddress = require('../../../../lib/dapiAddressProvider/DAPIAddress'); - -const MaxRetriesReachedError = require('../../../../lib/transport/errors/response/MaxRetriesReachedError'); -const NoAvailableAddressesForRetryError = require('../../../../lib/transport/errors/response/NoAvailableAddressesForRetryError'); -const NoAvailableAddressesError = require('../../../../lib/transport/errors/NoAvailableAddressesError'); -const ResponseError = require('../../../../lib/transport/errors/response/ResponseError'); -const TimeoutError = require('../../../../lib/transport/GrpcTransport/errors/TimeoutError'); -const RetriableResponseError = require('../../../../lib/transport/errors/response/RetriableResponseError'); +import GrpcErrorCodes from '@dashevo/grpc-common/lib/server/error/GrpcErrorCodes.js'; + +import GrpcError from '@dashevo/grpc-common/lib/server/error/GrpcError.js'; +import GrpcTransport from '../../../../lib/transport/GrpcTransport/GrpcTransport.js'; +import DAPIAddress from '../../../../lib/dapiAddressProvider/DAPIAddress.js'; + +import MaxRetriesReachedError from '../../../../lib/transport/errors/response/MaxRetriesReachedError.js'; +import NoAvailableAddressesForRetryError from '../../../../lib/transport/errors/response/NoAvailableAddressesForRetryError.js'; +import NoAvailableAddressesError from '../../../../lib/transport/errors/NoAvailableAddressesError.js'; +import ResponseError from '../../../../lib/transport/errors/response/ResponseError.js'; +import TimeoutError from '../../../../lib/transport/GrpcTransport/errors/TimeoutError.js'; +import RetriableResponseError from '../../../../lib/transport/errors/response/RetriableResponseError.js'; describe('GrpcTransport', () => { let grpcTransport; diff --git a/packages/js-dapi-client/test/unit/transport/GrpcTransport/createGrpcTransportError.spec.js b/packages/js-dapi-client/test/unit/transport/GrpcTransport/createGrpcTransportError.spec.js index b3731276d12..7a7ff091ecc 100644 --- a/packages/js-dapi-client/test/unit/transport/GrpcTransport/createGrpcTransportError.spec.js +++ b/packages/js-dapi-client/test/unit/transport/GrpcTransport/createGrpcTransportError.spec.js @@ -1,20 +1,22 @@ -const { Metadata, parseMetadata } = require('@dashevo/dapi-grpc'); -const GrpcError = require('@dashevo/grpc-common/lib/server/error/GrpcError'); -const GrpcErrorCodes = require('@dashevo/grpc-common/lib/server/error/GrpcErrorCodes'); - -const { - ProtocolVersionParsingError, -} = require('@dashevo/wasm-dpp'); - -const cbor = require('cbor'); -const createGrpcTransportError = require('../../../../lib/transport/GrpcTransport/createGrpcTransportError'); -const DAPIAddress = require('../../../../lib/dapiAddressProvider/DAPIAddress'); -const NotFoundError = require('../../../../lib/transport/GrpcTransport/errors/NotFoundError'); -const InvalidRequestError = require('../../../../lib/transport/errors/response/InvalidRequestError'); -const InternalServerError = require('../../../../lib/transport/GrpcTransport/errors/InternalServerError'); -const ServerError = require('../../../../lib/transport/errors/response/ServerError'); -const InvalidRequestDPPError = require('../../../../lib/transport/errors/response/InvalidRequestDPPError'); -const ResponseError = require('../../../../lib/transport/errors/response/ResponseError'); +import dapiGrpc from '@dashevo/dapi-grpc'; +import GrpcError from '@dashevo/grpc-common/lib/server/error/GrpcError.js'; +import GrpcErrorCodes from '@dashevo/grpc-common/lib/server/error/GrpcErrorCodes.js'; + +import wasmDpp from '@dashevo/wasm-dpp'; + +import cbor from 'cbor'; +import createGrpcTransportError from '../../../../lib/transport/GrpcTransport/createGrpcTransportError.js'; +import DAPIAddress from '../../../../lib/dapiAddressProvider/DAPIAddress.js'; +import NotFoundError from '../../../../lib/transport/GrpcTransport/errors/NotFoundError.js'; +import InvalidRequestError from '../../../../lib/transport/errors/response/InvalidRequestError.js'; +import InternalServerError from '../../../../lib/transport/GrpcTransport/errors/InternalServerError.js'; +import ServerError from '../../../../lib/transport/errors/response/ServerError.js'; +import InvalidRequestDPPError from '../../../../lib/transport/errors/response/InvalidRequestDPPError.js'; +import ResponseError from '../../../../lib/transport/errors/response/ResponseError.js'; +import { bytesToBase64 } from '../../../../lib/utils/bytes.js'; + +const { Metadata, parseMetadata } = dapiGrpc; +const { ProtocolVersionParsingError } = wasmDpp; describe('createGrpcTransportError', () => { let dapiAddress; @@ -28,13 +30,13 @@ describe('createGrpcTransportError', () => { }; metadata = new Metadata(); - // grpc-js expects Buffer + // grpc-js expects bytes let driveErrorDataBin = cbor.encode(errorData); // and grpc-web expects base64 string // TODO: remove when we switch to single grpc implementation for both Node and Web if (typeof window !== 'undefined') { - driveErrorDataBin = driveErrorDataBin.toString('base64'); + driveErrorDataBin = bytesToBase64(driveErrorDataBin); } metadata.set('drive-error-data-bin', driveErrorDataBin); @@ -107,13 +109,13 @@ describe('createGrpcTransportError', () => { 'Internal error', ); - // grpc-js expects Buffer + // grpc-js expects bytes let stackBin = cbor.encode(errorWithStack.stack); // and grpc-web expects string // TODO: remove when we switch to single grpc implementation for both Node and Web if (typeof window !== 'undefined') { - stackBin = stackBin.toString('base64'); + stackBin = bytesToBase64(stackBin); } metadata.set('stack-bin', stackBin); @@ -154,13 +156,13 @@ describe('createGrpcTransportError', () => { }); it('should return InvalidRequestDPPError', async () => { - // grpc-js expects Buffer + // grpc-js expects bytes let serializedError = new ProtocolVersionParsingError('test').serialize(); // and grpc-web expects string // TODO: remove when we switch to single grpc implementation for both Node and Web if (typeof window !== 'undefined') { - serializedError = serializedError.toString('base64'); + serializedError = bytesToBase64(serializedError); } metadata.set('dash-serialized-consensus-error-bin', serializedError); diff --git a/packages/js-dapi-client/test/unit/transport/JsonRpcTransport/JsonRpcTransport.spec.js b/packages/js-dapi-client/test/unit/transport/JsonRpcTransport/JsonRpcTransport.spec.js index 7f4e77a7021..fd363d19fe2 100644 --- a/packages/js-dapi-client/test/unit/transport/JsonRpcTransport/JsonRpcTransport.spec.js +++ b/packages/js-dapi-client/test/unit/transport/JsonRpcTransport/JsonRpcTransport.spec.js @@ -1,12 +1,12 @@ -const JsonRpcTransport = require('../../../../lib/transport/JsonRpcTransport/JsonRpcTransport'); -const DAPIAddress = require('../../../../lib/dapiAddressProvider/DAPIAddress'); - -const MaxRetriesReachedError = require('../../../../lib/transport/errors/response/MaxRetriesReachedError'); -const NoAvailableAddressesForRetryError = require('../../../../lib/transport/errors/response/NoAvailableAddressesForRetryError'); -const NoAvailableAddressesError = require('../../../../lib/transport/errors/NoAvailableAddressesError'); -const ResponseError = require('../../../../lib/transport/errors/response/ResponseError'); -const JsonRpcError = require('../../../../lib/transport/JsonRpcTransport/errors/JsonRpcError'); -const RetriableResponseError = require('../../../../lib/transport/errors/response/RetriableResponseError'); +import JsonRpcTransport from '../../../../lib/transport/JsonRpcTransport/JsonRpcTransport.js'; +import DAPIAddress from '../../../../lib/dapiAddressProvider/DAPIAddress.js'; + +import MaxRetriesReachedError from '../../../../lib/transport/errors/response/MaxRetriesReachedError.js'; +import NoAvailableAddressesForRetryError from '../../../../lib/transport/errors/response/NoAvailableAddressesForRetryError.js'; +import NoAvailableAddressesError from '../../../../lib/transport/errors/NoAvailableAddressesError.js'; +import ResponseError from '../../../../lib/transport/errors/response/ResponseError.js'; +import JsonRpcError from '../../../../lib/transport/JsonRpcTransport/errors/JsonRpcError.js'; +import RetriableResponseError from '../../../../lib/transport/errors/response/RetriableResponseError.js'; describe('JsonRpcTransport', () => { let jsonRpcTransport; diff --git a/packages/js-dapi-client/test/unit/transport/JsonRpcTransport/createJsonTransportError.spec.js b/packages/js-dapi-client/test/unit/transport/JsonRpcTransport/createJsonTransportError.spec.js index 15eab4e4d06..7578a53f184 100644 --- a/packages/js-dapi-client/test/unit/transport/JsonRpcTransport/createJsonTransportError.spec.js +++ b/packages/js-dapi-client/test/unit/transport/JsonRpcTransport/createJsonTransportError.spec.js @@ -1,10 +1,10 @@ -const DAPIAddress = require('../../../../lib/dapiAddressProvider/DAPIAddress'); -const WrongHttpCodeError = require('../../../../lib/transport/JsonRpcTransport/errors/WrongHttpCodeError'); -const createJsonTransportError = require('../../../../lib/transport/JsonRpcTransport/createJsonTransportError'); -const ServerError = require('../../../../lib/transport/errors/response/ServerError'); -const JsonRpcError = require('../../../../lib/transport/JsonRpcTransport/errors/JsonRpcError'); -const ResponseError = require('../../../../lib/transport/errors/response/ResponseError'); -const RetriableResponseError = require('../../../../lib/transport/errors/response/RetriableResponseError'); +import DAPIAddress from '../../../../lib/dapiAddressProvider/DAPIAddress.js'; +import WrongHttpCodeError from '../../../../lib/transport/JsonRpcTransport/errors/WrongHttpCodeError.js'; +import createJsonTransportError from '../../../../lib/transport/JsonRpcTransport/createJsonTransportError.js'; +import ServerError from '../../../../lib/transport/errors/response/ServerError.js'; +import JsonRpcError from '../../../../lib/transport/JsonRpcTransport/errors/JsonRpcError.js'; +import ResponseError from '../../../../lib/transport/errors/response/ResponseError.js'; +import RetriableResponseError from '../../../../lib/transport/errors/response/RetriableResponseError.js'; describe('createJsonTransportError', () => { let dapiAddress; diff --git a/packages/js-dapi-client/test/unit/transport/JsonRpcTransport/requestJsonRpc.spec.js b/packages/js-dapi-client/test/unit/transport/JsonRpcTransport/requestJsonRpc.spec.js index fb056544927..c681416b08d 100644 --- a/packages/js-dapi-client/test/unit/transport/JsonRpcTransport/requestJsonRpc.spec.js +++ b/packages/js-dapi-client/test/unit/transport/JsonRpcTransport/requestJsonRpc.spec.js @@ -1,6 +1,6 @@ -const requestJsonRpc = require('../../../../lib/transport/JsonRpcTransport/requestJsonRpc'); -const JsonRpcError = require('../../../../lib/transport/JsonRpcTransport/errors/JsonRpcError'); -const WrongHttpCodeError = require('../../../../lib/transport/JsonRpcTransport/errors/WrongHttpCodeError'); +import requestJsonRpc from '../../../../lib/transport/JsonRpcTransport/requestJsonRpc.js'; +import JsonRpcError from '../../../../lib/transport/JsonRpcTransport/errors/JsonRpcError.js'; +import WrongHttpCodeError from '../../../../lib/transport/JsonRpcTransport/errors/WrongHttpCodeError.js'; describe('requestJsonRpc', () => { let protocol; @@ -73,7 +73,7 @@ describe('requestJsonRpc', () => { expect(result).to.equal('passed'); }); - it('should make https rpc request with self-signed certificate and return result', async () => { + it('should pass an undici Agent that skips TLS verification when selfSigned is true', async () => { protocol = 'https'; selfSigned = true; @@ -96,6 +96,39 @@ describe('requestJsonRpc', () => { ); expect(result).to.equal('passed'); + + // Verify fetch was actually given a dispatcher that disables TLS verification. + // Without this, the selfSigned flag would be silently inert in Node. + // eslint-disable-next-line + const [, requestOptions] = fetch.firstCall.args; + expect(requestOptions.dispatcher).to.exist(); + }); + + it('should not pass a dispatcher when selfSigned is false', async () => { + protocol = 'https'; + selfSigned = false; + + // eslint-disable-next-line + fetch.resolves(new Response( + JSON.stringify({ result: 'passed', error: null }), + { + status: 200, + }, + )); + + await requestJsonRpc( + protocol, + host, + port, + selfSigned, + 'httpsRequest', + params, + { timeout }, + ); + + // eslint-disable-next-line + const [, requestOptions] = fetch.firstCall.args; + expect(requestOptions.dispatcher).to.equal(undefined); }); it('should throw WrongHttpCodeError if response status is not 200', async () => { diff --git a/packages/js-dapi-client/test/unit/transport/ReconnectableStream.spec.js b/packages/js-dapi-client/test/unit/transport/ReconnectableStream.spec.js index c946312a074..d3cd2419542 100644 --- a/packages/js-dapi-client/test/unit/transport/ReconnectableStream.spec.js +++ b/packages/js-dapi-client/test/unit/transport/ReconnectableStream.spec.js @@ -1,9 +1,9 @@ -const EventEmitter = require('events'); -const { expect } = require('chai'); +import EventEmitter from 'events'; +import { expect } from 'chai'; -const ReconnectableStream = require('../../../lib/transport/ReconnectableStream'); -const wait = require('../../../lib/utils/wait'); -const logger = require('../../../lib/logger'); +import ReconnectableStream from '../../../lib/transport/ReconnectableStream.js'; +import wait from '../../../lib/utils/wait.js'; +import logger from '../../../lib/logger/index.js'; describe('ReconnectableStream', () => { let reconnectableStream; diff --git a/packages/js-dapi-client/webpack.config.js b/packages/js-dapi-client/webpack.config.js deleted file mode 100644 index 0ea2b4d7eef..00000000000 --- a/packages/js-dapi-client/webpack.config.js +++ /dev/null @@ -1,52 +0,0 @@ -const path = require('path'); -const webpack = require('webpack'); - -const commonJSConfig = { - entry: ['core-js/stable', './lib/DAPIClient.js'], - mode: 'production', - resolve: { - fallback: { - fs: false, - http: false, - https: false, - ws: false, - crypto: require.resolve('crypto-browserify'), - buffer: require.resolve('buffer/'), - assert: require.resolve('assert-browserify'), - util: require.resolve('util/'), - os: require.resolve('os-browserify/browser'), - stream: require.resolve('stream-browserify'), - path: require.resolve('path-browserify'), - url: require.resolve('url/'), - events: require.resolve('events/'), - string_decoder: require.resolve('string_decoder/'), - zlib: require.resolve('browserify-zlib'), - process: require.resolve('process/browser'), - }, - }, - plugins: [ - new webpack.ProvidePlugin({ - Buffer: [require.resolve('buffer/'), 'Buffer'], - process: require.resolve('process/browser'), - }), - ], - module: { - rules: [ - { - test: /\.js$/, - exclude: /(node_modules)/, - use: { - loader: 'babel-loader', - }, - }, - ], - }, - output: { - path: path.resolve(__dirname, 'dist'), - filename: 'dapi-client.min.js', - library: 'DAPIClient', - libraryTarget: 'umd', - }, -}; - -module.exports = [commonJSConfig]; diff --git a/packages/js-dash-sdk/karma/karma.conf.js b/packages/js-dash-sdk/karma/karma.conf.js deleted file mode 100644 index fcdd34a9473..00000000000 --- a/packages/js-dash-sdk/karma/karma.conf.js +++ /dev/null @@ -1,16 +0,0 @@ -const options = require('./options'); - -module.exports = (config) => { - config.set({ - ...options, - logLevel: config.LOG_INFO, - files: [ - '../src/**/*.spec.ts', - '../src/test/karma/bootstrap.ts', - ], - preprocessors: { - '../src/**/*.spec.ts': ['webpack'], - '../src/test/karma/bootstrap.ts': ['webpack'], - }, - }); -}; diff --git a/packages/js-dash-sdk/karma/karma.functional.conf.js b/packages/js-dash-sdk/karma/karma.functional.conf.js deleted file mode 100644 index 94c82c0ae2d..00000000000 --- a/packages/js-dash-sdk/karma/karma.functional.conf.js +++ /dev/null @@ -1,16 +0,0 @@ -const options = require('./options'); - -module.exports = (config) => { - config.set({ - ...options, - logLevel: config.LOG_INFO, - files: [ - '../src/test/karma/bootstrap.ts', - '../tests/functional/sdk.js', - ], - preprocessors: { - '../src/test/karma/bootstrap.ts': ['webpack'], - '../tests/functional/sdk.js': ['webpack'], - }, - }); -}; diff --git a/packages/js-dash-sdk/karma/options.js b/packages/js-dash-sdk/karma/options.js deleted file mode 100644 index 0a068894e94..00000000000 --- a/packages/js-dash-sdk/karma/options.js +++ /dev/null @@ -1,59 +0,0 @@ -/* eslint-disable import-x/no-extraneous-dependencies */ -const webpack = require('webpack'); -const dotenvSafe = require('dotenv-safe'); - -const karmaMocha = require('karma-mocha'); -const karmaMochaReporter = require('karma-mocha-reporter'); -const karmaChai = require('karma-chai'); -const karmaChromeLauncher = require('karma-chrome-launcher'); -const karmaFirefoxLauncher = require('karma-firefox-launcher'); -const karmaWebpack = require('karma-webpack'); -const webpackBaseConfig = require('../webpack.base.config'); - -let env = {}; -if (process.env.LOAD_ENV) { - const dotenvResult = dotenvSafe.config(); - if (dotenvResult.error) { - throw dotenvResult.error; - } - env = dotenvResult.parsed; -} - -module.exports = { - frameworks: ['mocha', 'chai', 'webpack'], - webpack: { - ...webpackBaseConfig, - mode: 'development', - plugins: [ - ...webpackBaseConfig.plugins, - new webpack.EnvironmentPlugin( - env, - ), - ], - }, - reporters: ['mocha'], - port: 9876, - colors: true, - autoWatch: false, - browsers: ['ChromeHeadlessInsecure'], - singleRun: false, - concurrency: Infinity, - browserNoActivityTimeout: 7 * 60 * 1000, // 30000 default - browserDisconnectTimeout: 3 * 2000, // 2000 default - pingTimeout: 3 * 5000, // 5000 default - plugins: [ - karmaMocha, - karmaMochaReporter, - karmaChai, - karmaChromeLauncher, - karmaFirefoxLauncher, - karmaWebpack, - ], - customLaunchers: { - ChromeHeadlessInsecure: { - base: 'ChromeHeadless', - flags: ['--allow-insecure-localhost'], - displayName: 'Chrome w/o security', - }, - }, -}; diff --git a/packages/js-dash-sdk/package.json b/packages/js-dash-sdk/package.json index db94a9c923b..b7b5db7f476 100644 --- a/packages/js-dash-sdk/package.json +++ b/packages/js-dash-sdk/package.json @@ -2,20 +2,23 @@ "name": "dash", "version": "6.1.0-dev.1", "description": "Dash library for JavaScript/TypeScript ecosystem (Wallet, DAPI, Primitives, BLS, ...)", + "type": "module", "main": "build/index.js", - "unpkg": "dist/dash.min.js", - "browser": "dist/dash.min.js", + "exports": { + ".": "./build/index.js", + "./*": "./build/*" + }, "types": "build/index.d.ts", + "engines": { + "node": ">=18.18" + }, "scripts": { - "start:dev": "nodemon --exec 'yarn run build && yarn run test:unit'", "start:ts": "tsc -p tsconfig.build.json --watch", - "build": "yarn run build:ts && webpack --stats-error-details", + "build": "yarn run build:ts", "build:ts": "tsc -p tsconfig.build.json", "lint": "eslint .", "lint:fix": "eslint . --fix", - "test": "yarn run test:types && yarn run test:unit && yarn run test:browsers", - "test:browsers": "karma start ./karma/karma.conf.js --single-run", - "test:browsers:functional": "LOAD_ENV=true karma start ./karma/karma.functional.conf.js --single-run", + "test": "yarn run test:types && yarn run test:unit", "test:unit": "tsc -p tsconfig.mocha.json && mocha build/**/*.spec.js", "test:functional": "yarn run build:ts && LOAD_ENV=true mocha --recursive tests/functional/**/*.js", "test:types": "yarn pnpify tsd", @@ -48,10 +51,7 @@ "@dashevo/masternode-reward-shares-contract": "workspace:*", "@dashevo/wallet-lib": "workspace:*", "@dashevo/wasm-dpp": "workspace:*", - "@dashevo/withdrawals-contract": "workspace:*", - "bs58": "^4.0.1", - "node-inspect-extracted": "^1.0.8", - "winston": "^3.2.1" + "@dashevo/withdrawals-contract": "workspace:*" }, "devDependencies": { "@types/chai": "^4.3.11", @@ -61,47 +61,19 @@ "@types/sinon": "^9.0.4", "@types/sinon-chai": "^3.2.4", "@yarnpkg/pnpify": "^4.0.0-rc.42", - "assert": "^2.0.0", - "browserify-zlib": "^0.2.0", - "buffer": "^6.0.3", "chai": "^4.3.10", "chai-as-promised": "^7.1.1", "chance": "^1.1.6", - "crypto-browserify": "^3.12.1", "dirty-chai": "^2.0.1", "dotenv-safe": "^8.2.0", "eslint": "^9.18.0", - "events": "^3.3.0", - "https-browserify": "^1.0.0", - "karma": "^6.4.3", - "karma-chai": "^0.1.0", - "karma-chrome-launcher": "^3.1.0", - "karma-firefox-launcher": "^2.1.2", - "karma-mocha": "^2.0.1", - "karma-mocha-reporter": "^2.2.5", - "karma-webpack": "^5.0.0", "mocha": "^11.1.0", - "net": "^1.0.2", "nodemon": "^2.0.20", - "os-browserify": "^0.3.0", - "path-browserify": "^1.0.1", - "process": "^0.11.10", "rimraf": "^3.0.2", "sinon": "^18.0.1", "sinon-chai": "^3.7.0", - "stream-browserify": "^3.0.0", - "stream-http": "^3.2.0", - "string_decoder": "^1.3.0", - "terser-webpack-plugin": "^5.3.11", - "tls": "^0.0.1", - "ts-loader": "^9.5.0", - "ts-mock-imports": "^1.3.0", "ts-node": "^10.9.2", "tsd": "^0.28.1", - "typescript": "^5.7.3", - "url": "^0.11.3", - "util": "^0.12.4", - "webpack": "^5.104.0", - "webpack-cli": "^4.9.1" + "typescript": "^5.7.3" } } diff --git a/packages/js-dash-sdk/src/SDK/Client/Client.spec.ts b/packages/js-dash-sdk/src/SDK/Client/Client.spec.ts index ce4d8578ba2..acdaa1196b5 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Client.spec.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Client.spec.ts @@ -1,20 +1,22 @@ import { expect } from 'chai'; -import { Transaction, BlockHeader, PrivateKey } from '@dashevo/dashcore-lib'; -import { IdentityPublicKey, IdentityPublicKeyWithWitness, StateTransitionTypes } from '@dashevo/wasm-dpp'; -import { Client } from './index'; +import dashcore from '@dashevo/dashcore-lib'; +const { Transaction, BlockHeader, PrivateKey } = dashcore; +import wasmDpp from '@dashevo/wasm-dpp'; +const { IdentityPublicKey, IdentityPublicKeyWithWitness, StateTransitionTypes } = wasmDpp; +import { Client } from './index.js'; import 'mocha'; -import { createFakeInstantLock } from '../../utils/createFakeIntantLock'; +import { createFakeInstantLock } from '../../utils/createFakeIntantLock.js'; -import { StateTransitionBroadcastError } from '../../errors/StateTransitionBroadcastError'; +import { StateTransitionBroadcastError } from '../../errors/StateTransitionBroadcastError.js'; -import { createIdentityFixtureInAccount } from '../../test/fixtures/createIdentityFixtureInAccount'; +import { createIdentityFixtureInAccount } from '../../test/fixtures/createIdentityFixtureInAccount.js'; -import { createAndAttachTransportMocksToClient } from '../../test/mocks/createAndAttachTransportMocksToClient'; -import { createTransactionInAccount } from '../../test/fixtures/createTransactionFixtureInAccount'; +import { createAndAttachTransportMocksToClient } from '../../test/mocks/createAndAttachTransportMocksToClient.js'; +import { createTransactionInAccount } from '../../test/fixtures/createTransactionFixtureInAccount.js'; -const getDocumentsFixture = require('@dashevo/wasm-dpp/lib/test/fixtures/getDocumentsFixture'); -const getDataContractFixture = require('@dashevo/wasm-dpp/lib/test/fixtures/getDataContractFixture'); +import getDocumentsFixture from '@dashevo/wasm-dpp/lib/test/fixtures/getDocumentsFixture.js'; +import getDataContractFixture from '@dashevo/wasm-dpp/lib/test/fixtures/getDataContractFixture.js'; const blockHeaderFixture = '00000020e2bddfb998d7be4cc4c6b126f04d6e4bd201687523ded527987431707e0200005520320b4e263bec33e08944656f7ce17efbc2c60caab7c8ed8a73d413d02d3a169d555ecdd6021e56d000000203000500010000000000000000000000000000000000000000000000000000000000000000ffffffff050219250102ffffffff0240c3609a010000001976a914ecfd5aaebcbb8f4791e716e188b20d4f0183265c88ac40c3609a010000001976a914ecfd5aaebcbb8f4791e716e188b20d4f0183265c88ac0000000046020019250000476416132511031b71167f4bb7658eab5c3957d79636767f83e0e18e2b9ed7f8000000000000000000000000000000000000000000000000000000000000000003000600000000000000fd4901010019250000010001d02e9ee1b14c022ad6895450f3375a8e9a87f214912d4332fa997996d2000000320000000000000032000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'; const privateKeyFixture = '9b67f852093bc61cea0eeca38599dbfba0de28574d2ed9b99d10d33dc1bde7b2'; @@ -38,9 +40,12 @@ describe('Dash - Client', function suite() { client = new Client({ network: 'testnet', + // wallet-lib's WalletOptions type is too narrow under NodeNext; + // it doesn't expose HDPrivateKey / mnemonic. Cast to bypass. + // eslint-disable-next-line @typescript-eslint/no-explicit-any wallet: { HDPrivateKey: testHDKey, - }, + } as any, }); ({ @@ -89,10 +94,11 @@ describe('Dash - Client', function suite() { it('should initiate wallet-lib with a mnemonic', async () => { client = new Client({ + // eslint-disable-next-line @typescript-eslint/no-explicit-any wallet: { mnemonic: testMnemonic, offlineMode: true, - }, + } as any, }); expect(client.wallet).to.exist; expect(client.wallet!.offlineMode).to.be.equal(true); @@ -109,11 +115,12 @@ describe('Dash - Client', function suite() { // eslint-disable-next-line new Client({ network: 'testnet', + // eslint-disable-next-line @typescript-eslint/no-explicit-any wallet: { mnemonic: testMnemonic, offlineMode: true, network: 'mainnet', - }, + } as any, }); expect.fail('should throw an error'); diff --git a/packages/js-dash-sdk/src/SDK/Client/Client.ts b/packages/js-dash-sdk/src/SDK/Client/Client.ts index b3f4df7ae54..56b43c46c55 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Client.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Client.ts @@ -1,14 +1,21 @@ import { EventEmitter } from 'events'; import { Account, Wallet } from '@dashevo/wallet-lib'; -import DAPIClientTransport from '@dashevo/wallet-lib/src/transport/DAPIClientTransport/DAPIClientTransport'; -import { Network } from '@dashevo/dashcore-lib'; +import DAPIClientTransport from '@dashevo/wallet-lib/src/transport/DAPIClientTransport/DAPIClientTransport.js'; +import dashcore from '@dashevo/dashcore-lib'; +const { Network } = dashcore; +import type { Network as NetworkType } from '@dashevo/dashcore-lib'; +type Network = NetworkType; import DAPIClient from '@dashevo/dapi-client'; -import { contractId as dpnsContractId } from '@dashevo/dpns-contract/lib/systemIds'; -import { contractId as dashpayContractId } from '@dashevo/dashpay-contract/lib/systemIds'; -import { contractId as masternodeRewardSharesContractId } from '@dashevo/masternode-reward-shares-contract/lib/systemIds'; -import { contractId as withdrawalsContractId } from '@dashevo/withdrawals-contract/lib/systemIds'; -import { Platform } from './Platform'; -import { ClientApps, ClientAppsOptions } from './ClientApps'; +import dpnsSystemIds from '@dashevo/dpns-contract/lib/systemIds.js'; +const { contractId: dpnsContractId } = dpnsSystemIds; +import dashpaySystemIds from '@dashevo/dashpay-contract/lib/systemIds.js'; +const { contractId: dashpayContractId } = dashpaySystemIds; +import masternodeRewardSharesSystemIds from '@dashevo/masternode-reward-shares-contract/lib/systemIds.js'; +const { contractId: masternodeRewardSharesContractId } = masternodeRewardSharesSystemIds; +import withdrawalsSystemIds from '@dashevo/withdrawals-contract/lib/systemIds.js'; +const { contractId: withdrawalsContractId } = withdrawalsSystemIds; +import { Platform } from './Platform/index.js'; +import { ClientApps, ClientAppsOptions } from './ClientApps.js'; export interface WalletOptions extends Wallet.IWalletOptions { defaultAccountIndex?: number; @@ -102,8 +109,10 @@ export class Client extends EventEmitter { // Initialize a wallet if `wallet` option is preset if (this.options.wallet !== undefined) { - if (this.options.wallet.network !== undefined - && this.options.wallet.network !== this.network) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const walletOpts = this.options.wallet as any; + if (walletOpts.network !== undefined + && walletOpts.network !== this.network) { throw new Error('Wallet and Client networks are different'); } diff --git a/packages/js-dash-sdk/src/SDK/Client/ClientApps.spec.ts b/packages/js-dash-sdk/src/SDK/Client/ClientApps.spec.ts index 0a1aed20d98..6af53edfd24 100644 --- a/packages/js-dash-sdk/src/SDK/Client/ClientApps.spec.ts +++ b/packages/js-dash-sdk/src/SDK/Client/ClientApps.spec.ts @@ -1,6 +1,7 @@ -import { Identifier } from '@dashevo/wasm-dpp'; +import wasmDpp from '@dashevo/wasm-dpp'; +const { Identifier } = wasmDpp; import { expect } from 'chai'; -import { ClientApps } from './ClientApps'; +import { ClientApps } from './ClientApps.js'; import 'mocha'; describe('ClientApps', () => { diff --git a/packages/js-dash-sdk/src/SDK/Client/ClientApps.ts b/packages/js-dash-sdk/src/SDK/Client/ClientApps.ts index c429aa394e6..9a1c68c2e8a 100644 --- a/packages/js-dash-sdk/src/SDK/Client/ClientApps.ts +++ b/packages/js-dash-sdk/src/SDK/Client/ClientApps.ts @@ -1,4 +1,7 @@ -import { Identifier } from '@dashevo/wasm-dpp'; +import wasmDpp from '@dashevo/wasm-dpp'; +const { Identifier } = wasmDpp; +import type { Identifier as IdentifierType } from '@dashevo/wasm-dpp'; +type Identifier = IdentifierType; /** * Interface for ClientApps diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/Fetcher/Fetcher.spec.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/Fetcher/Fetcher.spec.ts index 42cd2a07663..a18938a9875 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/Fetcher/Fetcher.spec.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/Fetcher/Fetcher.spec.ts @@ -1,6 +1,7 @@ -import { Identifier } from '@dashevo/wasm-dpp'; +import wasmDpp from '@dashevo/wasm-dpp'; +const { Identifier } = wasmDpp; import { expect } from 'chai'; -import Fetcher from './index'; +import Fetcher from './index.js'; describe('Dash - Fetcher', () => { let fetcher: Fetcher; diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/Fetcher/Fetcher.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/Fetcher/Fetcher.ts index 47817e81169..d95157d12f8 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/Fetcher/Fetcher.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/Fetcher/Fetcher.ts @@ -1,15 +1,18 @@ import DAPIClient from '@dashevo/dapi-client'; -import { Identifier } from '@dashevo/wasm-dpp/dist'; -import { GetDataContractResponse } from '@dashevo/dapi-client/lib/methods/platform/getDataContract/GetDataContractResponse'; -import { GetIdentityResponse } from '@dashevo/dapi-client/lib/methods/platform/getIdentity/GetIdentityResponse'; - -import NotFoundError from '@dashevo/dapi-client/lib/transport/GrpcTransport/errors/NotFoundError'; -import { GetDocumentsResponse } from '@dashevo/dapi-client/lib/methods/platform/getDocuments/GetDocumentsResponse'; +import wasmDpp from '@dashevo/wasm-dpp'; +const { Identifier } = wasmDpp; +import type { Identifier as IdentifierType } from '@dashevo/wasm-dpp'; +type Identifier = IdentifierType; +import { GetDataContractResponse } from '@dashevo/dapi-client/lib/methods/platform/getDataContract/GetDataContractResponse.js'; +import { GetIdentityResponse } from '@dashevo/dapi-client/lib/methods/platform/getIdentity/GetIdentityResponse.js'; + +import NotFoundError from '@dashevo/dapi-client/lib/transport/GrpcTransport/errors/NotFoundError.js'; +import { GetDocumentsResponse } from '@dashevo/dapi-client/lib/methods/platform/getDocuments/GetDocumentsResponse.js'; import { GetDataContractHistoryResponse, -} from '@dashevo/dapi-client/lib/methods/platform/getDataContractHistory/GetDataContractHistoryResponse'; -import withRetry from './withRetry'; -import { QueryOptions } from '../types'; +} from '@dashevo/dapi-client/lib/methods/platform/getDataContractHistory/GetDataContractHistoryResponse.js'; +import withRetry from './withRetry.js'; +import { QueryOptions } from '../types.js'; type FetcherOptions = { /** diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/Fetcher/index.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/Fetcher/index.ts index d0ed4633228..ae8a6d4094f 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/Fetcher/index.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/Fetcher/index.ts @@ -1,3 +1,3 @@ -import Fetcher from './Fetcher'; +import Fetcher from './Fetcher.js'; export default Fetcher; diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/Fetcher/withRetry.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/Fetcher/withRetry.ts index 031601620ed..6c21ccb8ff4 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/Fetcher/withRetry.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/Fetcher/withRetry.ts @@ -1,5 +1,5 @@ -import { fibonacci } from '../../../../utils/fibonacci'; -import { wait } from '../../../../utils/wait'; +import { fibonacci } from '../../../../utils/fibonacci.js'; +import { wait } from '../../../../utils/wait.js'; /** * Maximum number of retry attempts diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/IStateTransitionResult.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/IStateTransitionResult.ts index 08e562082b4..75ac6e81b20 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/IStateTransitionResult.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/IStateTransitionResult.ts @@ -1,5 +1,5 @@ -import { Metadata } from '@dashevo/dapi-client/lib/methods/platform/response/Metadata'; -import { IPlatformStateProof } from './IPlatformStateProof'; +import { Metadata } from '@dashevo/dapi-client/lib/methods/platform/response/Metadata.js'; +import { IPlatformStateProof } from './IPlatformStateProof.js'; export interface IStateTransitionResult { metadata: Metadata, diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/NonceManager/NonceManager.spec.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/NonceManager/NonceManager.spec.ts index 9b3eed06618..24a9f26d23f 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/NonceManager/NonceManager.spec.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/NonceManager/NonceManager.spec.ts @@ -1,6 +1,7 @@ -import { Identifier } from '@dashevo/wasm-dpp'; +import wasmDpp from '@dashevo/wasm-dpp'; +const { Identifier } = wasmDpp; import { expect } from 'chai'; -import NonceManager, { NONCE_FETCH_INTERVAL } from './NonceManager'; +import NonceManager, { NONCE_FETCH_INTERVAL } from './NonceManager.js'; describe('Dash - NonceManager', () => { let nonceManager: NonceManager; diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/NonceManager/NonceManager.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/NonceManager/NonceManager.ts index 3b522566c70..a1527df2243 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/NonceManager/NonceManager.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/NonceManager/NonceManager.ts @@ -1,5 +1,8 @@ import DAPIClient from '@dashevo/dapi-client'; -import { Identifier } from '@dashevo/wasm-dpp'; +import wasmDpp from '@dashevo/wasm-dpp'; +const { Identifier } = wasmDpp; +import type { Identifier as IdentifierType } from '@dashevo/wasm-dpp'; +type Identifier = IdentifierType; type NonceState = { value: bigint, diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/Platform.spec.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/Platform.spec.ts index e5cfa443305..52c022b7e59 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/Platform.spec.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/Platform.spec.ts @@ -1,8 +1,8 @@ import { expect } from 'chai'; // import { getLatestProtocolVersion } from '@dashevo/wasm-dpp'; -import { Platform } from './index'; +import { Platform } from './index.js'; import 'mocha'; -import Client from '../Client'; +import Client from '../Client.js'; describe('Dash - Platform', () => { it('should provide expected class', () => { diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/Platform.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/Platform.ts index 873fe62c53d..88e830c54f8 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/Platform.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/Platform.ts @@ -1,42 +1,43 @@ -import loadWasmDpp, { DashPlatformProtocol, getLatestProtocolVersion } from '@dashevo/wasm-dpp'; +import loadWasmDpp from '@dashevo/wasm-dpp'; +const { DashPlatformProtocol, getLatestProtocolVersion } = loadWasmDpp; import type { DPPModule } from '@dashevo/wasm-dpp'; import crypto from 'crypto'; -import Client from '../Client'; -import { IStateTransitionResult } from './IStateTransitionResult'; - -import createAssetLockTransaction from './createAssetLockTransaction'; - -import broadcastDocument from './methods/documents/broadcast'; -import createDocument from './methods/documents/create'; -import getDocument from './methods/documents/get'; - -import publishContract from './methods/contracts/publish'; -import updateContract from './methods/contracts/update'; -import createContract from './methods/contracts/create'; -import getContract from './methods/contracts/get'; -import getContractHistory from './methods/contracts/history'; - -import getIdentity from './methods/identities/get'; -import registerIdentity from './methods/identities/register'; -import topUpIdentity from './methods/identities/topUp'; -import creditTransferIdentity from './methods/identities/creditTransfer'; -import creditWithdrawal from './methods/identities/creditWithdrawal'; -import updateIdentity from './methods/identities/update'; -import createIdentityCreateTransition from './methods/identities/internal/createIdentityCreateTransition'; -import createIdentityTopUpTransition from './methods/identities/internal/createIdentityTopUpTransition'; -import createAssetLockProof from './methods/identities/internal/createAssetLockProof'; -import waitForCoreChainLockedHeight from './methods/identities/internal/waitForCoreChainLockedHeight'; - -import registerName from './methods/names/register'; -import resolveName from './methods/names/resolve'; -import resolveNameByRecord from './methods/names/resolveByRecord'; -import searchName from './methods/names/search'; -import broadcastStateTransition from './broadcastStateTransition'; - -import logger, { ConfigurableLogger } from '../../../logger'; -import Fetcher from './Fetcher'; -import NonceManager from './NonceManager/NonceManager'; +import Client from '../Client.js'; +import { IStateTransitionResult } from './IStateTransitionResult.js'; + +import createAssetLockTransaction from './createAssetLockTransaction.js'; + +import broadcastDocument from './methods/documents/broadcast.js'; +import createDocument from './methods/documents/create.js'; +import getDocument from './methods/documents/get.js'; + +import publishContract from './methods/contracts/publish.js'; +import updateContract from './methods/contracts/update.js'; +import createContract from './methods/contracts/create.js'; +import getContract from './methods/contracts/get.js'; +import getContractHistory from './methods/contracts/history.js'; + +import getIdentity from './methods/identities/get.js'; +import registerIdentity from './methods/identities/register.js'; +import topUpIdentity from './methods/identities/topUp.js'; +import creditTransferIdentity from './methods/identities/creditTransfer.js'; +import creditWithdrawal from './methods/identities/creditWithdrawal.js'; +import updateIdentity from './methods/identities/update.js'; +import createIdentityCreateTransition from './methods/identities/internal/createIdentityCreateTransition.js'; +import createIdentityTopUpTransition from './methods/identities/internal/createIdentityTopUpTransition.js'; +import createAssetLockProof from './methods/identities/internal/createAssetLockProof.js'; +import waitForCoreChainLockedHeight from './methods/identities/internal/waitForCoreChainLockedHeight.js'; + +import registerName from './methods/names/register.js'; +import resolveName from './methods/names/resolve.js'; +import resolveNameByRecord from './methods/names/resolveByRecord.js'; +import searchName from './methods/names/search.js'; +import broadcastStateTransition from './broadcastStateTransition.js'; + +import logger, { ConfigurableLogger } from '../../../logger/index.js'; +import Fetcher from './Fetcher/index.js'; +import NonceManager from './NonceManager/NonceManager.js'; /** * Interface for PlatformOpts @@ -246,6 +247,10 @@ export class Platform { // // Slash is missing before `dist` and TS compilation in consumers is breaking static async initializeDppModule(): Promise { - return loadWasmDpp(); + // wasm-dpp is CJS; under NodeNext the default import may resolve to the + // module namespace object instead of the callable. Unwrap defensively. + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const load = (loadWasmDpp as any).default ?? loadWasmDpp; + return load(); } } diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/StateRepository.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/StateRepository.ts index 646fe148660..cb4f6494054 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/StateRepository.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/StateRepository.ts @@ -1,5 +1,14 @@ -import { DataContract, Identity, Identifier } from '@dashevo/wasm-dpp'; -import Client from '../Client'; +import wasmDpp from '@dashevo/wasm-dpp'; +const { DataContract, Identity, Identifier } = wasmDpp; +import type { + DataContract as DataContractType, + Identity as IdentityType, + Identifier as IdentifierType, +} from '@dashevo/wasm-dpp'; +type DataContract = DataContractType; +type Identity = IdentityType; +type Identifier = IdentifierType; +import Client from '../Client.js'; class StateRepository { private readonly client: Client; diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/broadcastStateTransition.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/broadcastStateTransition.ts index 9fb3d04e1f3..df14f766680 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/broadcastStateTransition.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/broadcastStateTransition.ts @@ -1,14 +1,11 @@ import crypto from 'crypto'; -import { Platform } from './Platform'; -import { StateTransitionBroadcastError } from '../../../errors/StateTransitionBroadcastError'; -import { IStateTransitionResult } from './IStateTransitionResult'; - -const ResponseError = require('@dashevo/dapi-client/lib/transport/errors/response/ResponseError'); -const InvalidRequestDPPError = require('@dashevo/dapi-client/lib/transport/errors/response/InvalidRequestDPPError'); - -const createGrpcTransportError = require('@dashevo/dapi-client/lib/transport/GrpcTransport/createGrpcTransportError'); - -const GrpcError = require('@dashevo/grpc-common/lib/server/error/GrpcError'); +import ResponseError from '@dashevo/dapi-client/lib/transport/errors/response/ResponseError.js'; +import InvalidRequestDPPError from '@dashevo/dapi-client/lib/transport/errors/response/InvalidRequestDPPError.js'; +import createGrpcTransportError from '@dashevo/dapi-client/lib/transport/GrpcTransport/createGrpcTransportError.js'; +import GrpcError from '@dashevo/grpc-common/lib/server/error/GrpcError.js'; +import { Platform } from './Platform.js'; +import { StateTransitionBroadcastError } from '../../../errors/StateTransitionBroadcastError.js'; +import { IStateTransitionResult } from './IStateTransitionResult.js'; /** * @param {Platform} platform diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/createAssetLockTransaction.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/createAssetLockTransaction.ts index 6350677dff5..5f276bc973a 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/createAssetLockTransaction.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/createAssetLockTransaction.ts @@ -1,8 +1,19 @@ -import { - PrivateKey, Transaction, Script, Address, Opcode, +import dashcore from '@dashevo/dashcore-lib'; +const { + PrivateKey, + Transaction, + Script, + Address, + Opcode, +} = dashcore; +import type { + PrivateKey as PrivateKeyType, + Transaction as TransactionType, } from '@dashevo/dashcore-lib'; +type PrivateKey = PrivateKeyType; +type Transaction = TransactionType; import { utils } from '@dashevo/wallet-lib'; -import { Platform } from './Platform'; +import { Platform } from './Platform.js'; // We're creating a new transaction every time and the index is always 0 const ASSET_LOCK_OUTPUT_INDEX = 0; diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/index.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/index.ts index be13241c9eb..397383c0cf6 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/index.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/index.ts @@ -1 +1 @@ -export { Platform, PlatformOpts } from './Platform'; +export { Platform, PlatformOpts } from './Platform.js'; diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/create.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/create.ts index 8b40c79b141..0f3dc403ef5 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/create.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/create.ts @@ -1,4 +1,4 @@ -import { Platform } from '../../Platform'; +import { Platform } from '../../Platform.js'; /** * Create and prepare contracts for the platform diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/get.spec.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/get.spec.ts index dad46135ac3..14a26bc249c 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/get.spec.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/get.spec.ts @@ -2,16 +2,16 @@ import { expect } from 'chai'; import loadDpp from '@dashevo/wasm-dpp'; -import getDataContractFixture from '@dashevo/wasm-dpp/lib/test/fixtures/getDataContractFixture'; +import getDataContractFixture from '@dashevo/wasm-dpp/lib/test/fixtures/getDataContractFixture.js'; -import getResponseMetadataFixture from '../../../../../test/fixtures/getResponseMetadataFixture'; -import get from './get'; -import identitiesFixtures from '../../../../../../tests/fixtures/identities.json'; +import getResponseMetadataFixture from '../../../../../test/fixtures/getResponseMetadataFixture.js'; +import get from './get.js'; +import identitiesFixtures from '../../../../../../tests/fixtures/identities.json' with { type: 'json' }; import 'mocha'; -import { ClientApps } from '../../../ClientApps'; +import { ClientApps } from '../../../ClientApps.js'; -const GetDataContractResponse = require('@dashevo/dapi-client/lib/methods/platform/getDataContract/GetDataContractResponse'); -const NotFoundError = require('@dashevo/dapi-client/lib/transport/GrpcTransport/errors/NotFoundError'); +import GetDataContractResponse from '@dashevo/dapi-client/lib/methods/platform/getDataContract/GetDataContractResponse.js'; +import NotFoundError from '@dashevo/dapi-client/lib/transport/GrpcTransport/errors/NotFoundError.js'; let client; let fetcher; @@ -38,7 +38,9 @@ let apps; describe('Client - Platform - Contracts - .get()', () => { before(async function before() { - await loadDpp(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const load = (loadDpp as any).default ?? loadDpp; + await load(); dataContractFixture = await getDataContractFixture(); metadataFixture = getResponseMetadataFixture(); diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/get.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/get.ts index 1a08b3d78a0..9170d92dcb8 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/get.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/get.ts @@ -1,8 +1,10 @@ -import { Identifier } from '@dashevo/wasm-dpp'; -import { GetDataContractResponse } from '@dashevo/dapi-client/lib/methods/platform/getDataContract/GetDataContractResponse'; -import { Platform } from '../../Platform'; - -const NotFoundError = require('@dashevo/dapi-client/lib/transport/GrpcTransport/errors/NotFoundError'); +import wasmDpp from '@dashevo/wasm-dpp'; +const { Identifier } = wasmDpp; +import type { Identifier as IdentifierType } from '@dashevo/wasm-dpp'; +type Identifier = IdentifierType; +import GetDataContractResponse from '@dashevo/dapi-client/lib/methods/platform/getDataContract/GetDataContractResponse.js'; +import NotFoundError from '@dashevo/dapi-client/lib/transport/GrpcTransport/errors/NotFoundError.js'; +import { Platform } from '../../Platform.js'; declare type ContractIdentifier = string | Identifier; diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/history.spec.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/history.spec.ts index ca874e34ba3..00e716a15fc 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/history.spec.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/history.spec.ts @@ -2,17 +2,17 @@ import { expect } from 'chai'; import loadDpp from '@dashevo/wasm-dpp'; -import getDataContractFixture from '@dashevo/wasm-dpp/lib/test/fixtures/getDataContractFixture'; +import getDataContractFixture from '@dashevo/wasm-dpp/lib/test/fixtures/getDataContractFixture.js'; -import getResponseMetadataFixture from '../../../../../test/fixtures/getResponseMetadataFixture'; -import history from './history'; -import identitiesFixtures from '../../../../../../tests/fixtures/identities.json'; +import getResponseMetadataFixture from '../../../../../test/fixtures/getResponseMetadataFixture.js'; +import history from './history.js'; +import identitiesFixtures from '../../../../../../tests/fixtures/identities.json' with { type: 'json' }; import 'mocha'; -import { ClientApps } from '../../../ClientApps'; +import { ClientApps } from '../../../ClientApps.js'; -const DataContractHistoryEntry = require('@dashevo/dapi-client/lib/methods/platform/getDataContractHistory/DataContractHistoryEntry'); -const GetDataContractHistoryResponse = require('@dashevo/dapi-client/lib/methods/platform/getDataContractHistory/GetDataContractHistoryResponse'); -const NotFoundError = require('@dashevo/dapi-client/lib/transport/GrpcTransport/errors/NotFoundError'); +import DataContractHistoryEntry from '@dashevo/dapi-client/lib/methods/platform/getDataContractHistory/DataContractHistoryEntry.js'; +import GetDataContractHistoryResponse from '@dashevo/dapi-client/lib/methods/platform/getDataContractHistory/GetDataContractHistoryResponse.js'; +import NotFoundError from '@dashevo/dapi-client/lib/transport/GrpcTransport/errors/NotFoundError.js'; let client; let fetcher; @@ -39,7 +39,9 @@ let apps; describe('Client - Platform - Contracts - .history()', () => { before(async function before() { - await loadDpp(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const load = (loadDpp as any).default ?? loadDpp; + await load(); dataContractFixture = await getDataContractFixture(); metadataFixture = getResponseMetadataFixture(); diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/history.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/history.ts index 55d2d9985ef..7b12125c012 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/history.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/history.ts @@ -1,10 +1,14 @@ -import { DataContract, Identifier } from '@dashevo/wasm-dpp'; -import { - GetDataContractHistoryResponse, -} from '@dashevo/dapi-client/lib/methods/platform/getDataContractHistory/GetDataContractHistoryResponse'; -import { Platform } from '../../Platform'; - -const NotFoundError = require('@dashevo/dapi-client/lib/transport/GrpcTransport/errors/NotFoundError'); +import wasmDpp from '@dashevo/wasm-dpp'; +const { DataContract, Identifier } = wasmDpp; +import type { + DataContract as DataContractType, + Identifier as IdentifierType, +} from '@dashevo/wasm-dpp'; +type DataContract = DataContractType; +type Identifier = IdentifierType; +import GetDataContractHistoryResponse from '@dashevo/dapi-client/lib/methods/platform/getDataContractHistory/GetDataContractHistoryResponse.js'; +import NotFoundError from '@dashevo/dapi-client/lib/transport/GrpcTransport/errors/NotFoundError.js'; +import { Platform } from '../../Platform.js'; declare type ContractIdentifier = string | Identifier; diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/publish.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/publish.ts index 7eb12f7c053..16fb9dc19a4 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/publish.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/publish.ts @@ -1,7 +1,16 @@ -import { Identity, DataContract, DataContractCreateTransition } from '@dashevo/wasm-dpp'; -import { Platform } from '../../Platform'; -import broadcastStateTransition from '../../broadcastStateTransition'; -import { signStateTransition } from '../../signStateTransition'; +import wasmDpp from '@dashevo/wasm-dpp'; +const { Identity, DataContract, DataContractCreateTransition } = wasmDpp; +import type { + Identity as IdentityType, + DataContract as DataContractType, + DataContractCreateTransition as DataContractCreateTransitionType, +} from '@dashevo/wasm-dpp'; +type Identity = IdentityType; +type DataContract = DataContractType; +type DataContractCreateTransition = DataContractCreateTransitionType; +import { Platform } from '../../Platform.js'; +import broadcastStateTransition from '../../broadcastStateTransition.js'; +import { signStateTransition } from '../../signStateTransition.js'; /** * Publish contract onto the platform diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/update.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/update.ts index 7da552988ba..6f06eefa581 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/update.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/contracts/update.ts @@ -1,6 +1,6 @@ -import { Platform } from '../../Platform'; -import broadcastStateTransition from '../../broadcastStateTransition'; -import { signStateTransition } from '../../signStateTransition'; +import { Platform } from '../../Platform.js'; +import broadcastStateTransition from '../../broadcastStateTransition.js'; +import { signStateTransition } from '../../signStateTransition.js'; /** * Publish contract onto the platform diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/documents/broadcast.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/documents/broadcast.ts index 4a6a7a06026..fa055dc47d0 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/documents/broadcast.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/documents/broadcast.ts @@ -1,7 +1,10 @@ -import { ExtendedDocument } from '@dashevo/wasm-dpp'; -import { Platform } from '../../Platform'; -import broadcastStateTransition from '../../broadcastStateTransition'; -import { signStateTransition } from '../../signStateTransition'; +import wasmDpp from '@dashevo/wasm-dpp'; +const { ExtendedDocument } = wasmDpp; +import type { ExtendedDocument as ExtendedDocumentType } from '@dashevo/wasm-dpp'; +type ExtendedDocument = ExtendedDocumentType; +import { Platform } from '../../Platform.js'; +import broadcastStateTransition from '../../broadcastStateTransition.js'; +import { signStateTransition } from '../../signStateTransition.js'; /** * Broadcast document onto the platform diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/documents/create.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/documents/create.ts index 25595a76b55..290f407d113 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/documents/create.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/documents/create.ts @@ -1,5 +1,8 @@ -import { ExtendedDocument } from '@dashevo/wasm-dpp'; -import { Platform } from '../../Platform'; +import wasmDpp from '@dashevo/wasm-dpp'; +const { ExtendedDocument } = wasmDpp; +import type { ExtendedDocument as ExtendedDocumentType } from '@dashevo/wasm-dpp'; +type ExtendedDocument = ExtendedDocumentType; +import { Platform } from '../../Platform.js'; declare interface CreateOpts { [name:string]: any; diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/documents/get.spec.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/documents/get.spec.ts index f4dc8ed2829..3d9e77677e2 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/documents/get.spec.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/documents/get.spec.ts @@ -1,12 +1,12 @@ -import getDataContractFixture from '@dashevo/wasm-dpp/lib/test/fixtures/getDataContractFixture'; -import generateRandomIdentifier from '@dashevo/wasm-dpp/lib/test/utils/generateRandomIdentifierAsync'; -import getDocumentsFixture from '@dashevo/wasm-dpp/lib/test/fixtures/getDocumentsFixture'; +import getDataContractFixture from '@dashevo/wasm-dpp/lib/test/fixtures/getDataContractFixture.js'; +import generateRandomIdentifier from '@dashevo/wasm-dpp/lib/test/utils/generateRandomIdentifierAsync.js'; +import getDocumentsFixture from '@dashevo/wasm-dpp/lib/test/fixtures/getDocumentsFixture.js'; import { expect } from 'chai'; -import getResponseMetadataFixture from '../../../../../test/fixtures/getResponseMetadataFixture'; +import getResponseMetadataFixture from '../../../../../test/fixtures/getResponseMetadataFixture.js'; -import get from './get'; +import get from './get.js'; -const GetDocumentsResponse = require('@dashevo/dapi-client/lib/methods/platform/getDocuments/GetDocumentsResponse'); +import GetDocumentsResponse from '@dashevo/dapi-client/lib/methods/platform/getDocuments/GetDocumentsResponse.js'; describe('Client - Platform - Documents - .get()', () => { let platform; diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/documents/get.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/documents/get.ts index f2540c20304..7059fe7caee 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/documents/get.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/documents/get.ts @@ -1,8 +1,9 @@ -import { Identifier, ExtendedDocument, Metadata } from '@dashevo/wasm-dpp'; -import { GetDocumentsResponse } from '@dashevo/dapi-client/lib/methods/platform/getDocuments/GetDocumentsResponse'; -import NotFoundError from '@dashevo/dapi-client/lib/transport/GrpcTransport/errors/NotFoundError'; -import { Platform } from '../../Platform'; -import { QueryOptions, WhereCondition } from '../../types'; +import wasmDpp from '@dashevo/wasm-dpp'; +const { Identifier, ExtendedDocument, Metadata } = wasmDpp; +import { GetDocumentsResponse } from '@dashevo/dapi-client/lib/methods/platform/getDocuments/GetDocumentsResponse.js'; +import NotFoundError from '@dashevo/dapi-client/lib/transport/GrpcTransport/errors/NotFoundError.js'; +import { Platform } from '../../Platform.js'; +import { QueryOptions, WhereCondition } from '../../types.js'; /** * Prefetch contract diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/creditTransfer.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/creditTransfer.ts index 71c0f196584..fad54cd0c09 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/creditTransfer.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/creditTransfer.ts @@ -1,7 +1,14 @@ -import { Identifier, Identity } from '@dashevo/wasm-dpp'; -import broadcastStateTransition from '../../broadcastStateTransition'; -import { Platform } from '../../Platform'; -import { signStateTransition } from '../../signStateTransition'; +import wasmDpp from '@dashevo/wasm-dpp'; +const { Identifier, Identity } = wasmDpp; +import type { + Identifier as IdentifierType, + Identity as IdentityType, +} from '@dashevo/wasm-dpp'; +type Identifier = IdentifierType; +type Identity = IdentityType; +import broadcastStateTransition from '../../broadcastStateTransition.js'; +import { Platform } from '../../Platform.js'; +import { signStateTransition } from '../../signStateTransition.js'; export async function creditTransfer( this: Platform, diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/creditWithdrawal.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/creditWithdrawal.ts index 359c569b4b7..6187a34b283 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/creditWithdrawal.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/creditWithdrawal.ts @@ -1,10 +1,16 @@ -import { Identity } from '@dashevo/wasm-dpp'; -import { Address, Script } from '@dashevo/dashcore-lib'; -import { Metadata } from '@dashevo/dapi-client/lib/methods/platform/response/Metadata'; -import broadcastStateTransition from '../../broadcastStateTransition'; -import { Platform } from '../../Platform'; -import { signStateTransition } from '../../signStateTransition'; -import { nearestGreaterFibonacci } from '../../../../../utils/fibonacci'; +import wasmDpp from '@dashevo/wasm-dpp'; +const { Identity } = wasmDpp; +import type { Identity as IdentityType } from '@dashevo/wasm-dpp'; +type Identity = IdentityType; +import dashcore from '@dashevo/dashcore-lib'; +const { Address, Script } = dashcore; +import type { Address as AddressType } from '@dashevo/dashcore-lib'; +type Address = AddressType; +import { Metadata } from '@dashevo/dapi-client/lib/methods/platform/response/Metadata.js'; +import broadcastStateTransition from '../../broadcastStateTransition.js'; +import { Platform } from '../../Platform.js'; +import { signStateTransition } from '../../signStateTransition.js'; +import { nearestGreaterFibonacci } from '../../../../../utils/fibonacci.js'; export const STATUSES = { PENDING: 0, diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/get.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/get.ts index 8c572f79bac..5c652b8c634 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/get.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/get.ts @@ -1,8 +1,10 @@ -import { Identifier, Metadata } from '@dashevo/wasm-dpp'; -import { GetIdentityResponse } from '@dashevo/dapi-client/lib/methods/platform/getIdentity/GetIdentityResponse'; -import { Platform } from '../../Platform'; - -const NotFoundError = require('@dashevo/dapi-client/lib/transport/GrpcTransport/errors/NotFoundError'); +import wasmDpp from '@dashevo/wasm-dpp'; +const { Identifier, Metadata } = wasmDpp; +import type { Identifier as IdentifierType } from '@dashevo/wasm-dpp'; +type Identifier = IdentifierType; +import GetIdentityResponse from '@dashevo/dapi-client/lib/methods/platform/getIdentity/GetIdentityResponse.js'; +import NotFoundError from '@dashevo/dapi-client/lib/transport/GrpcTransport/errors/NotFoundError.js'; +import { Platform } from '../../Platform.js'; /** * Get an identity from the platform diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/internal/createAssetLockProof.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/internal/createAssetLockProof.ts index 891d4ac0809..d33174fae15 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/internal/createAssetLockProof.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/internal/createAssetLockProof.ts @@ -1,7 +1,11 @@ -import { Transaction } from '@dashevo/dashcore-lib'; -import { Platform } from '../../../Platform'; - -const { InstantLockTimeoutError, TxMetadataTimeoutError } = require('@dashevo/wallet-lib/src/errors'); +import dashcore from '@dashevo/dashcore-lib'; +const { Transaction } = dashcore; +import type { Transaction as TransactionType } from '@dashevo/dashcore-lib'; +type Transaction = TransactionType; +import walletLibErrors from '@dashevo/wallet-lib/src/errors/index.js'; +import { Platform } from '../../../Platform.js'; + +const { InstantLockTimeoutError, TxMetadataTimeoutError } = walletLibErrors; /** * Creates a funding transaction for the platform identity diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.ts index 83ece7d2377..ee9daa83669 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.ts @@ -1,6 +1,10 @@ -import { PrivateKey } from '@dashevo/dashcore-lib'; -import { IdentityPublicKey } from '@dashevo/wasm-dpp'; -import { Platform } from '../../../Platform'; +import dashcore from '@dashevo/dashcore-lib'; +const { PrivateKey } = dashcore; +import type { PrivateKey as PrivateKeyType } from '@dashevo/dashcore-lib'; +type PrivateKey = PrivateKeyType; +import wasmDpp from '@dashevo/wasm-dpp'; +const { IdentityPublicKey } = wasmDpp; +import { Platform } from '../../../Platform.js'; /** * Creates a funding transaction for the platform identity diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/internal/createIdentityTopUpTransition.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/internal/createIdentityTopUpTransition.ts index dfc0a26bddd..7db253c56c7 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/internal/createIdentityTopUpTransition.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/internal/createIdentityTopUpTransition.ts @@ -1,6 +1,10 @@ -import { PrivateKey } from '@dashevo/dashcore-lib'; -import { IdentityPublicKey } from '@dashevo/wasm-dpp'; -import { Platform } from '../../../Platform'; +import dashcore from '@dashevo/dashcore-lib'; +const { PrivateKey } = dashcore; +import type { PrivateKey as PrivateKeyType } from '@dashevo/dashcore-lib'; +type PrivateKey = PrivateKeyType; +import wasmDpp from '@dashevo/wasm-dpp'; +const { IdentityPublicKey } = wasmDpp; +import { Platform } from '../../../Platform.js'; /** * Creates a funding transaction for the platform identity diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/internal/waitForCoreChainLockedHeight.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/internal/waitForCoreChainLockedHeight.ts index 21c60199540..c674ecfbf93 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/internal/waitForCoreChainLockedHeight.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/internal/waitForCoreChainLockedHeight.ts @@ -1,4 +1,4 @@ -import { Platform } from '../../../Platform'; +import { Platform } from '../../../Platform.js'; export async function waitForCoreChainLockedHeight( this : Platform, diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/register.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/register.ts index 432f70773e3..7be1ddbc85a 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/register.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/register.ts @@ -1,5 +1,5 @@ -import { Platform } from '../../Platform'; -import broadcastStateTransition from '../../broadcastStateTransition'; +import { Platform } from '../../Platform.js'; +import broadcastStateTransition from '../../broadcastStateTransition.js'; /** * Register identities to the platform diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/topUp.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/topUp.ts index 44b576fc0a7..d043e6f912c 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/topUp.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/topUp.ts @@ -1,7 +1,10 @@ -import { Identifier } from '@dashevo/wasm-dpp'; -import { Platform } from '../../Platform'; +import wasmDpp from '@dashevo/wasm-dpp'; +const { Identifier } = wasmDpp; +import type { Identifier as IdentifierType } from '@dashevo/wasm-dpp'; +type Identifier = IdentifierType; +import { Platform } from '../../Platform.js'; -import broadcastStateTransition from '../../broadcastStateTransition'; +import broadcastStateTransition from '../../broadcastStateTransition.js'; /** * Register identities to the platform diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/update.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/update.ts index 941e75d303b..7d898560120 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/update.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/identities/update.ts @@ -1,8 +1,15 @@ -import { Identity, IdentityPublicKey } from '@dashevo/wasm-dpp'; -import { Platform } from '../../Platform'; -import { signStateTransition } from '../../signStateTransition'; - -import broadcastStateTransition from '../../broadcastStateTransition'; +import wasmDpp from '@dashevo/wasm-dpp'; +const { Identity, IdentityPublicKey } = wasmDpp; +import type { + Identity as IdentityType, + IdentityPublicKey as IdentityPublicKeyType, +} from '@dashevo/wasm-dpp'; +type Identity = IdentityType; +type IdentityPublicKey = IdentityPublicKeyType; +import { Platform } from '../../Platform.js'; +import { signStateTransition } from '../../signStateTransition.js'; + +import broadcastStateTransition from '../../broadcastStateTransition.js'; /** * Update platform identities diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/register.spec.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/register.spec.ts index 17404c0fb07..1e98c7d96a8 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/register.spec.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/register.spec.ts @@ -1,21 +1,11 @@ import { expect } from 'chai'; -import { ImportMock } from 'ts-mock-imports'; -import generateRandomIdentifier from '@dashevo/wasm-dpp/lib/test/utils/generateRandomIdentifierAsync'; +import generateRandomIdentifier from '@dashevo/wasm-dpp/lib/test/utils/generateRandomIdentifierAsync.js'; -import cryptoModule from 'crypto'; - -import register from './register'; -import { ClientApps } from '../../../ClientApps'; +import register from './register.js'; +import { ClientApps } from '../../../ClientApps.js'; describe('Platform', () => { - let randomBytesMock; - - before(() => { - randomBytesMock = ImportMock.mockFunction(cryptoModule, 'randomBytes', Buffer.alloc(32)); - }); - after(() => { - randomBytesMock.restore(); - }); + const randomBytesStub = (size: number) => Buffer.alloc(size); describe('Names', () => { describe('#register', () => { @@ -54,7 +44,7 @@ describe('Platform', () => { await register.call(platformMock, 'Dash', { identity: identityId, - }, identityMock); + }, identityMock, randomBytesStub); expect(platformMock.documents.create.getCall(0).args[0]).to.deep.equal('dpns.preorder'); expect(platformMock.documents.create.getCall(0).args[1]).to.deep.equal(identityMock); @@ -87,7 +77,7 @@ describe('Platform', () => { await register.call(platformMock, 'User.dash', { identity: identityId, - }, identityMock); + }, identityMock, randomBytesStub); expect(platformMock.documents.create.getCall(0).args[0]).to.deep.equal('dpns.preorder'); expect(platformMock.documents.create.getCall(0).args[1]).to.deep.equal(identityMock); @@ -120,7 +110,7 @@ describe('Platform', () => { try { await register.call(platformMock, 'user.dash', { identity: await generateRandomIdentifier(), - }, identityMock); + }, identityMock, randomBytesStub); } catch (e: any) { expect(e.message).to.equal('DPNS is required to register a new name.'); } diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/register.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/register.ts index 07f6576e782..1033db39f0f 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/register.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/register.ts @@ -1,9 +1,13 @@ -import { Identifier } from '@dashevo/wasm-dpp'; -import { Platform } from '../../Platform'; -import convertToHomographSafeChars from '../../../../../utils/convertToHomographSafeChars'; +import crypto from 'crypto'; +import wasmDpp from '@dashevo/wasm-dpp'; +const { Identifier } = wasmDpp; +import type { Identifier as IdentifierType } from '@dashevo/wasm-dpp'; +type Identifier = IdentifierType; +import { hash } from '@dashevo/wasm-dpp/lib/utils/hash.js'; +import { Platform } from '../../Platform.js'; +import convertToHomographSafeChars from '../../../../../utils/convertToHomographSafeChars.js'; -const crypto = require('crypto'); -const { hash } = require('@dashevo/wasm-dpp/lib/utils/hash'); +type RandomBytesFn = (size: number) => Buffer; /** * Register names to the platform @@ -13,6 +17,7 @@ const { hash } = require('@dashevo/wasm-dpp/lib/utils/hash'); * @param {Object} records - records object having only one of the following items * @param {string} [records.identity] * @param identity - identity + * @param randomBytes - injectable source of preorder-salt randomness (defaults to crypto.randomBytes); tests use this seam * * @returns registered domain document */ @@ -26,6 +31,7 @@ export async function register( getId(): Identifier; getPublicKeyById(number: number):any; }, + randomBytes: RandomBytesFn = crypto.randomBytes, ): Promise { await this.initialize(); @@ -44,7 +50,7 @@ export async function register( const [label] = nameLabels; const normalizedLabel = convertToHomographSafeChars(label); - const preorderSalt = crypto.randomBytes(32); + const preorderSalt = randomBytes(32); const isSecondLevelDomain = normalizedParentDomainName.length > 0; diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/resolve.spec.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/resolve.spec.ts index 73605ba30f4..ebfe82362eb 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/resolve.spec.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/resolve.spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import resolve from './resolve'; +import resolve from './resolve.js'; describe('Platform', () => { describe('Names', () => { diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/resolve.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/resolve.ts index 7e210bf060e..14baaac1719 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/resolve.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/resolve.ts @@ -1,5 +1,5 @@ -import convertToHomographSafeChars from '../../../../../utils/convertToHomographSafeChars'; -import { Platform } from '../../Platform'; +import convertToHomographSafeChars from '../../../../../utils/convertToHomographSafeChars.js'; +import { Platform } from '../../Platform.js'; /** * This method will allow you to resolve a DPNS record from its humanized name. diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/resolveByRecord.spec.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/resolveByRecord.spec.ts index 82e4ccec596..1bde7ac23c0 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/resolveByRecord.spec.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/resolveByRecord.spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import resolveByRecord from './resolveByRecord'; +import resolveByRecord from './resolveByRecord.js'; describe('Platform', () => { describe('Names', () => { diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/resolveByRecord.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/resolveByRecord.ts index 0bcd4b2a75c..ecbfbcc4158 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/resolveByRecord.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/resolveByRecord.ts @@ -1,5 +1,6 @@ -import { Identifier } from '@dashevo/wasm-dpp'; -import { Platform } from '../../Platform'; +import wasmDpp from '@dashevo/wasm-dpp'; +const { Identifier } = wasmDpp; +import { Platform } from '../../Platform.js'; /** * @param record - the exact name of the record to resolve diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/search.spec.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/search.spec.ts index 86310f9da36..a38137367a2 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/search.spec.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/search.spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import search from './search'; +import search from './search.js'; describe('Platform', () => { describe('Names', () => { diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/search.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/search.ts index e162bc1ba19..4ca8ad45d53 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/search.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/methods/names/search.ts @@ -1,6 +1,6 @@ -import { Platform } from '../../Platform'; +import { Platform } from '../../Platform.js'; -import convertToHomographSafeChars from '../../../../../utils/convertToHomographSafeChars'; +import convertToHomographSafeChars from '../../../../../utils/convertToHomographSafeChars.js'; /** * diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/signStateTransition.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/signStateTransition.ts index f8cee3bef06..22d49a31a8f 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/signStateTransition.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/signStateTransition.ts @@ -1,4 +1,4 @@ -import { Platform } from './Platform'; +import { Platform } from './Platform.js'; /** * diff --git a/packages/js-dash-sdk/src/SDK/Client/Platform/types.ts b/packages/js-dash-sdk/src/SDK/Client/Platform/types.ts index 2490655e63e..48c8bcaa148 100644 --- a/packages/js-dash-sdk/src/SDK/Client/Platform/types.ts +++ b/packages/js-dash-sdk/src/SDK/Client/Platform/types.ts @@ -1,4 +1,11 @@ -import { Identifier, ExtendedDocument } from '@dashevo/wasm-dpp'; +import wasmDpp from '@dashevo/wasm-dpp'; +const { Identifier, ExtendedDocument } = wasmDpp; +import type { + Identifier as IdentifierType, + ExtendedDocument as ExtendedDocumentType, +} from '@dashevo/wasm-dpp'; +type Identifier = IdentifierType; +type ExtendedDocument = ExtendedDocumentType; /** * @param {WhereCondition[]} [where] - where diff --git a/packages/js-dash-sdk/src/SDK/Client/index.ts b/packages/js-dash-sdk/src/SDK/Client/index.ts index 82e03984991..2f09732ebe7 100644 --- a/packages/js-dash-sdk/src/SDK/Client/index.ts +++ b/packages/js-dash-sdk/src/SDK/Client/index.ts @@ -1 +1 @@ -export { Client } from './Client'; +export { Client } from './Client.js'; diff --git a/packages/js-dash-sdk/src/SDK/Core/Core.d.ts b/packages/js-dash-sdk/src/SDK/Core/Core.d.ts index 6f73a27d18c..223ccd12967 100644 --- a/packages/js-dash-sdk/src/SDK/Core/Core.d.ts +++ b/packages/js-dash-sdk/src/SDK/Core/Core.d.ts @@ -1,18 +1,4 @@ -import { - Transaction as _Transaction, - Address as _Address, - Block as _Block, - UnspentOutput as _UnspentOutput, - HDPublicKey as _HDPublicKey, - HDPrivateKey as _HDPrivateKey, - Mnemonic as _Mnemonic, - Network as _Network, - Input as _Input, - Output as _Output, - Script as _Script, - PublicKey as _PublicKey, - PrivateKey as _PrivateKey -} from '@dashevo/dashcore-lib'; +import { Transaction as _Transaction, Address as _Address, Block as _Block, UnspentOutput as _UnspentOutput, HDPublicKey as _HDPublicKey, HDPrivateKey as _HDPrivateKey, Mnemonic as _Mnemonic, Network as _Network, Input as _Input, Output as _Output, Script as _Script, PublicKey as _PublicKey, PrivateKey as _PrivateKey } from '@dashevo/dashcore-lib'; export declare namespace Core { export type Transaction = _Transaction; diff --git a/packages/js-dash-sdk/src/SDK/Core/index.ts b/packages/js-dash-sdk/src/SDK/Core/index.ts index 2a354a9ef87..dc69827f1d6 100644 --- a/packages/js-dash-sdk/src/SDK/Core/index.ts +++ b/packages/js-dash-sdk/src/SDK/Core/index.ts @@ -1 +1 @@ -export { Core } from './Core'; +export { Core } from './Core.js'; diff --git a/packages/js-dash-sdk/src/SDK/Platform/Platform.ts b/packages/js-dash-sdk/src/SDK/Platform/Platform.ts index 538c89b9b10..cf141282f87 100644 --- a/packages/js-dash-sdk/src/SDK/Platform/Platform.ts +++ b/packages/js-dash-sdk/src/SDK/Platform/Platform.ts @@ -1,7 +1,7 @@ // TODO remove default exports // eslint-disable-next-line no-restricted-exports import * as _DashPlatformProtocol from '@dashevo/wasm-dpp'; -import { Platform as PlatformClient } from '../Client/Platform/Platform'; +import { Platform as PlatformClient } from '../Client/Platform/Platform.js'; export namespace Platform { export const DashPlatformProtocol = _DashPlatformProtocol; diff --git a/packages/js-dash-sdk/src/SDK/Platform/index.ts b/packages/js-dash-sdk/src/SDK/Platform/index.ts index 7ebf91b1944..8a195d41e17 100644 --- a/packages/js-dash-sdk/src/SDK/Platform/index.ts +++ b/packages/js-dash-sdk/src/SDK/Platform/index.ts @@ -1 +1 @@ -export { Platform } from './Platform'; +export { Platform } from './Platform.js'; diff --git a/packages/js-dash-sdk/src/SDK/SDK.spec.ts b/packages/js-dash-sdk/src/SDK/SDK.spec.ts index 7ef2680b8bd..248cbfcc6c8 100644 --- a/packages/js-dash-sdk/src/SDK/SDK.spec.ts +++ b/packages/js-dash-sdk/src/SDK/SDK.spec.ts @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import SDK from './index'; +import SDK from './index.js'; import 'mocha'; describe('Dash', () => { diff --git a/packages/js-dash-sdk/src/SDK/SDK.ts b/packages/js-dash-sdk/src/SDK/SDK.ts index b368f112a41..15b4b28c8a6 100644 --- a/packages/js-dash-sdk/src/SDK/SDK.ts +++ b/packages/js-dash-sdk/src/SDK/SDK.ts @@ -10,11 +10,11 @@ import { utils as _WalletLibUtils, plugins as _WalletLibPlugins, } from '@dashevo/wallet-lib'; -import { Client as _Client } from './Client'; -import { Core as _Core } from './Core'; -import { Platform as _Platform } from './Platform'; +import { Client as _Client } from './Client/index.js'; +import { Core as _Core } from './Core/index.js'; +import { Platform as _Platform } from './Platform/index.js'; -import { StateTransitionBroadcastError } from '../errors/StateTransitionBroadcastError'; +import { StateTransitionBroadcastError } from '../errors/StateTransitionBroadcastError.js'; export namespace SDK { export const DAPIClient = _DAPIClient; diff --git a/packages/js-dash-sdk/src/SDK/index.ts b/packages/js-dash-sdk/src/SDK/index.ts index 5831254b57f..ae02f9d74d9 100644 --- a/packages/js-dash-sdk/src/SDK/index.ts +++ b/packages/js-dash-sdk/src/SDK/index.ts @@ -1,3 +1,3 @@ // TODO remove default export // eslint-disable-next-line no-restricted-exports -export { SDK as default } from './SDK'; +export { SDK as default } from './SDK.js'; diff --git a/packages/js-dash-sdk/src/bls/getBlsAdapter.ts b/packages/js-dash-sdk/src/bls/getBlsAdapter.ts index e306ff78e21..87a1ece188a 100644 --- a/packages/js-dash-sdk/src/bls/getBlsAdapter.ts +++ b/packages/js-dash-sdk/src/bls/getBlsAdapter.ts @@ -1,7 +1,9 @@ -import loadBLS from '@dashevo/bls'; -import { Buffer } from 'buffer'; +import * as blsModule from '@dashevo/bls'; export default async (): Promise => { + // @dashevo/bls exposes a callable factory; types declare it as a namespace. + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const loadBLS = ((blsModule as any).default ?? blsModule) as () => Promise; const bls = await loadBLS(); return { diff --git a/packages/js-dash-sdk/src/index.ts b/packages/js-dash-sdk/src/index.ts index a2f96f0e7f3..074a30961fa 100644 --- a/packages/js-dash-sdk/src/index.ts +++ b/packages/js-dash-sdk/src/index.ts @@ -1,3 +1,19 @@ -import SDK from './SDK'; +// eslint-disable-next-line no-restricted-exports +import SDK from './SDK/index.js'; -export = SDK; +export const { + DAPIClient, + Client, + Core, + Platform, + Wallet, + Account, + KeyChain, + WalletLib, + PlatformProtocol, + Essentials, + Errors, +} = SDK; + +// eslint-disable-next-line no-restricted-exports +export default SDK; diff --git a/packages/js-dash-sdk/src/logger/index.ts b/packages/js-dash-sdk/src/logger/index.ts index d0b0bd763d9..e452171631d 100644 --- a/packages/js-dash-sdk/src/logger/index.ts +++ b/packages/js-dash-sdk/src/logger/index.ts @@ -1,64 +1,47 @@ -import { Logger, Logform } from 'winston'; +/* eslint-disable @typescript-eslint/no-explicit-any */ +const LOG_LEVEL = (typeof process !== 'undefined' && process.env && process.env.LOG_LEVEL) || 'info'; -export type ConfigurableLogger = Logger & { - getForId: (id: string) => ConfigurableLogger +const LEVELS: Record = { + silent: -1, error: 0, warn: 1, info: 2, verbose: 3, debug: 4, silly: 5, }; -const util = require('util'); -const winston = require('winston'); - -const LOG_LEVEL = process.env.LOG_LEVEL || 'info'; - -// Log levels: -// error 0 -// warn 1 -// info 2 (default) -// verbose 3 -// debug 4 -// silly 5 - -const createLogger = (formats: Logform.Format[] = []): ConfigurableLogger => winston.createLogger({ - level: LOG_LEVEL, - transports: [ - new winston.transports.Console({ - format: winston.format.combine( - { - transform: (info) => { - const args = info[Symbol.for('splat')]; - const result = { ...info }; - if (args) { - result.message = util.format(info.message, ...args); - } - return result; - }, - }, - ...formats, - winston.format.colorize(), - winston.format.printf(({ - level, message, - }) => `${level}: ${message}`), - ), - }), - ], -}); - -const logger = createLogger(); - -const loggers = {}; -logger.getForId = (id: string): ConfigurableLogger => { - if (!loggers[id]) { - const format = { - transform: (info) => { - const message = `[SDK: ${id}] ${info.message}`; - return { ...info, message }; - }, - }; - - loggers[id] = createLogger([format]); - } - - return loggers[id]; -}; +export interface ConfigurableLogger { + error: (...args: any[]) => void; + warn: (...args: any[]) => void; + info: (...args: any[]) => void; + verbose: (...args: any[]) => void; + debug: (...args: any[]) => void; + silly: (...args: any[]) => void; + getForId: (id: string) => ConfigurableLogger; +} + +const cache: Record = {}; + +function build(level: string = LOG_LEVEL, prefix: string = ''): ConfigurableLogger { + const threshold = LEVELS[level] != null ? LEVELS[level] : LEVELS.silent; + const noop = () => { /* no-op */ }; + const fmt = prefix + ? (...a: any[]) => [prefix, ...a] + : (...a: any[]) => a; + + const logger: ConfigurableLogger = { + error: threshold >= 0 ? (...a: any[]) => console.error(...fmt(...a)) : noop, + warn: threshold >= 1 ? (...a: any[]) => console.warn(...fmt(...a)) : noop, + info: threshold >= 2 ? (...a: any[]) => console.info(...fmt(...a)) : noop, + verbose: threshold >= 3 ? (...a: any[]) => console.debug(...fmt(...a)) : noop, + debug: threshold >= 4 ? (...a: any[]) => console.debug(...fmt(...a)) : noop, + silly: threshold >= 5 ? (...a: any[]) => console.debug(...fmt(...a)) : noop, + getForId(id: string): ConfigurableLogger { + if (!cache[id]) { + cache[id] = build(level, `[SDK: ${id}]`); + } + return cache[id]; + }, + }; + return logger; +} + +const logger = build(); logger.verbose(`[SDK] Logger uses "${LOG_LEVEL}" level`, { level: LOG_LEVEL }); diff --git a/packages/js-dash-sdk/src/test/bootstrap.js b/packages/js-dash-sdk/src/test/bootstrap.js index 92594921ab8..17fd6403c33 100644 --- a/packages/js-dash-sdk/src/test/bootstrap.js +++ b/packages/js-dash-sdk/src/test/bootstrap.js @@ -1,10 +1,14 @@ -const path = require('path'); -const dotenvSafe = require('dotenv-safe'); -const sinon = require('sinon'); -const sinonChai = require('sinon-chai'); -const { use } = require('chai'); -const dirtyChai = require('dirty-chai'); -const chaiAsPromised = require('chai-as-promised'); +import path from 'path'; +import { fileURLToPath } from 'url'; +import dotenvSafe from 'dotenv-safe'; +import sinon from 'sinon'; +import sinonChai from 'sinon-chai'; +import { use } from 'chai'; +import dirtyChai from 'dirty-chai'; +import chaiAsPromised from 'chai-as-promised'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); if (process.env.LOAD_ENV === 'true') { dotenvSafe.config({ @@ -16,7 +20,7 @@ use(dirtyChai); use(sinonChai); use(chaiAsPromised); -exports.mochaHooks = { +export const mochaHooks = { beforeEach() { if (!this.sinon) { this.sinon = sinon.createSandbox(); diff --git a/packages/js-dash-sdk/src/test/fixtures/createIdentityFixtureInAccount.ts b/packages/js-dash-sdk/src/test/fixtures/createIdentityFixtureInAccount.ts index 986e6e10d7e..5abca904b7d 100644 --- a/packages/js-dash-sdk/src/test/fixtures/createIdentityFixtureInAccount.ts +++ b/packages/js-dash-sdk/src/test/fixtures/createIdentityFixtureInAccount.ts @@ -1,9 +1,11 @@ -import loadWasmDpp, { IdentityPublicKey } from '@dashevo/wasm-dpp'; - -const getIdentityFixture = require('@dashevo/wasm-dpp/lib/test/fixtures/getIdentityFixture'); +import loadWasmDpp from '@dashevo/wasm-dpp'; +const { IdentityPublicKey } = loadWasmDpp; +import getIdentityFixture from '@dashevo/wasm-dpp/lib/test/fixtures/getIdentityFixture.js'; export async function createIdentityFixtureInAccount(account) { - await loadWasmDpp(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const load = (loadWasmDpp as any).default ?? loadWasmDpp; + await load(); const identityFixture = await getIdentityFixture(); const identityFixtureIndex = 0; diff --git a/packages/js-dash-sdk/src/test/fixtures/createTransactionFixtureInAccount.ts b/packages/js-dash-sdk/src/test/fixtures/createTransactionFixtureInAccount.ts index 6536fd5638b..2fff01f37bf 100644 --- a/packages/js-dash-sdk/src/test/fixtures/createTransactionFixtureInAccount.ts +++ b/packages/js-dash-sdk/src/test/fixtures/createTransactionFixtureInAccount.ts @@ -1,4 +1,5 @@ -import { Transaction } from '@dashevo/dashcore-lib'; +import dashcore from '@dashevo/dashcore-lib'; +const { Transaction } = dashcore; export async function createTransactionInAccount(account) { // add fake tx to the wallet so it will be able to create transactions diff --git a/packages/js-dash-sdk/src/test/fixtures/getResponseMetadataFixture.ts b/packages/js-dash-sdk/src/test/fixtures/getResponseMetadataFixture.ts index fe3cdc6ed63..7b182a85581 100644 --- a/packages/js-dash-sdk/src/test/fixtures/getResponseMetadataFixture.ts +++ b/packages/js-dash-sdk/src/test/fixtures/getResponseMetadataFixture.ts @@ -1,4 +1,4 @@ -const Metadata = require('@dashevo/dapi-client/lib/methods/platform/response/Metadata'); +import Metadata from '@dashevo/dapi-client/lib/methods/platform/response/Metadata.js'; function getResponseMetadataFixture() { const metadata = { diff --git a/packages/js-dash-sdk/src/test/karma/bootstrap.ts b/packages/js-dash-sdk/src/test/karma/bootstrap.ts deleted file mode 100644 index 8394d5402c1..00000000000 --- a/packages/js-dash-sdk/src/test/karma/bootstrap.ts +++ /dev/null @@ -1,22 +0,0 @@ -import sinon from 'sinon'; -import { use } from 'chai'; - -import dirtyChai from 'dirty-chai'; -import sinonChai from 'sinon-chai'; -import chaiAsPromised from 'chai-as-promised'; - -use(dirtyChai); -use(sinonChai); -use(chaiAsPromised); - -beforeEach(function beforeEach() { - if (!this.sinon) { - this.sinon = sinon.createSandbox(); - } else { - this.sinon.restore(); - } -}); - -afterEach(function afterEach() { - this.sinon.restore(); -}); diff --git a/packages/js-dash-sdk/src/test/mocks/createAndAttachTransportMocksToClient.ts b/packages/js-dash-sdk/src/test/mocks/createAndAttachTransportMocksToClient.ts index 85d46ada220..a5012a58dbf 100644 --- a/packages/js-dash-sdk/src/test/mocks/createAndAttachTransportMocksToClient.ts +++ b/packages/js-dash-sdk/src/test/mocks/createAndAttachTransportMocksToClient.ts @@ -1,19 +1,21 @@ -import { Transaction } from '@dashevo/dashcore-lib'; +import dashcore from '@dashevo/dashcore-lib'; +const { Transaction } = dashcore; import DAPIClient from '@dashevo/dapi-client'; -import { StateTransitionTypes } from '@dashevo/wasm-dpp'; +import wasmDpp from '@dashevo/wasm-dpp'; +const { StateTransitionTypes } = wasmDpp; -import { createFakeInstantLock } from '../../utils/createFakeIntantLock'; -import getResponseMetadataFixture from '../fixtures/getResponseMetadataFixture'; -import { createDapiClientMock } from './createDapiClientMock'; +import { createFakeInstantLock } from '../../utils/createFakeIntantLock.js'; +import getResponseMetadataFixture from '../fixtures/getResponseMetadataFixture.js'; +import { createDapiClientMock } from './createDapiClientMock.js'; -import { wait } from '../../utils/wait'; +import { wait } from '../../utils/wait.js'; -const GetIdentityResponse = require('@dashevo/dapi-client/lib/methods/platform/getIdentity/GetIdentityResponse'); -const NotFoundError = require('@dashevo/dapi-client/lib/transport/GrpcTransport/errors/NotFoundError'); +import GetIdentityResponse from '@dashevo/dapi-client/lib/methods/platform/getIdentity/GetIdentityResponse.js'; +import NotFoundError from '@dashevo/dapi-client/lib/transport/GrpcTransport/errors/NotFoundError.js'; -const TxStreamMock = require('@dashevo/wallet-lib/src/test/mocks/TxStreamMock'); -const TxStreamDataResponseMock = require('@dashevo/wallet-lib/src/test/mocks/TxStreamDataResponseMock'); -const TransportMock = require('@dashevo/wallet-lib/src/test/mocks/TransportMock'); +import TxStreamMock from '@dashevo/wallet-lib/src/test/mocks/TxStreamMock.js'; +import TxStreamDataResponseMock from '@dashevo/wallet-lib/src/test/mocks/TxStreamDataResponseMock.js'; +import TransportMock from '@dashevo/wallet-lib/src/test/mocks/TransportMock.js'; function makeTxStreamEmitISLocksForTransactions(transportMock, txStreamMock) { transportMock.sendTransaction.callsFake((txString) => { diff --git a/packages/js-dash-sdk/src/utils/createFakeIntantLock.ts b/packages/js-dash-sdk/src/utils/createFakeIntantLock.ts index ade82da25c6..bb2fb8fdd43 100644 --- a/packages/js-dash-sdk/src/utils/createFakeIntantLock.ts +++ b/packages/js-dash-sdk/src/utils/createFakeIntantLock.ts @@ -1,4 +1,7 @@ -import { InstantLock } from '@dashevo/dashcore-lib'; +import dashcore from '@dashevo/dashcore-lib'; +const { InstantLock } = dashcore; +import type { InstantLock as InstantLockType } from '@dashevo/dashcore-lib'; +type InstantLock = InstantLockType; export function createFakeInstantLock(transactionHash: string): InstantLock { return new InstantLock({ diff --git a/packages/js-dash-sdk/tests/functional/sdk.js b/packages/js-dash-sdk/tests/functional/sdk.js index c8e303223a5..1a6c30c3373 100644 --- a/packages/js-dash-sdk/tests/functional/sdk.js +++ b/packages/js-dash-sdk/tests/functional/sdk.js @@ -1,15 +1,10 @@ -const { expect } = require('chai'); - -const { Identifier } = require('@dashevo/wasm-dpp'); - -const { contractId: dpnsContractIdString } = require('@dashevo/dpns-contract/lib/systemIds'); - -const { - Networks, -} = require('@dashevo/dashcore-lib'); - -// eslint-disable-next-line -const Dash = require(typeof process === 'undefined' ? '../../src/index.ts' : '../../'); +import { expect } from 'chai'; +import wasmDpp from '@dashevo/wasm-dpp'; +const { Identifier } = wasmDpp; +import { contractId as dpnsContractIdString } from '@dashevo/dpns-contract/lib/systemIds.js'; +import dashcore from '@dashevo/dashcore-lib'; +const { Networks } = dashcore; +import Dash from '../../build/index.js'; describe('SDK', function suite() { this.timeout(700000); diff --git a/packages/js-dash-sdk/tsconfig.json b/packages/js-dash-sdk/tsconfig.json index 6166a1cae01..f3bd677fe0e 100644 --- a/packages/js-dash-sdk/tsconfig.json +++ b/packages/js-dash-sdk/tsconfig.json @@ -1,15 +1,16 @@ { "compilerOptions": { "target": "es2020", - "module": "commonjs", - "lib": ["es6", "dom"], + "module": "nodenext", + "moduleResolution": "nodenext", + "lib": ["es2020", "dom"], "skipLibCheck": true, "strict": true, "allowUmdGlobalAccess": true, "noImplicitAny": false, "esModuleInterop": true, "resolveJsonModule": true, - "allowJs": true, + "allowJs": true }, "include": [ "src/**/*" diff --git a/packages/js-dash-sdk/tsconfig.mocha.json b/packages/js-dash-sdk/tsconfig.mocha.json index 9f9e701cdf5..0884e155893 100644 --- a/packages/js-dash-sdk/tsconfig.mocha.json +++ b/packages/js-dash-sdk/tsconfig.mocha.json @@ -1,10 +1,12 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "target": "es6", + "target": "es2020", + "module": "nodenext", + "moduleResolution": "nodenext", "skipLibCheck": true, "esModuleInterop": true, - "outDir": "./build", + "outDir": "./build" }, - "include": ["src/**/*.spec.ts", "src/test/**/*.ts"], + "include": ["src/**/*.spec.ts", "src/test/**/*.ts"] } diff --git a/packages/js-dash-sdk/tsconfig.tsd.json b/packages/js-dash-sdk/tsconfig.tsd.json index 6d2501261de..e9217be86d0 100644 --- a/packages/js-dash-sdk/tsconfig.tsd.json +++ b/packages/js-dash-sdk/tsconfig.tsd.json @@ -1,7 +1,9 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "target": "es6", + "target": "es2020", + "module": "nodenext", + "moduleResolution": "nodenext" }, "include": ["test-d/**/*.ts"] } diff --git a/packages/js-dash-sdk/webpack.base.config.js b/packages/js-dash-sdk/webpack.base.config.js deleted file mode 100644 index bacc3e3c0cf..00000000000 --- a/packages/js-dash-sdk/webpack.base.config.js +++ /dev/null @@ -1,59 +0,0 @@ -const path = require('path'); -const webpack = require('webpack'); -const TerserPlugin = require('terser-webpack-plugin'); - -const baseConfig = { - entry: './src/index.ts', - devtool: 'eval', - module: { - rules: [ - { - test: /\.ts$/, - use: 'ts-loader', - exclude: /node_modules/, - }, - ], - }, - optimization: { - minimize: true, - minimizer: [new TerserPlugin({ - terserOptions: { - keep_classnames: true, // fixes empty string in `object.constructor.name` - }, - })], - }, - resolve: { - extensions: ['.ts', '.js', '.json'], - fallback: { - fs: false, - util: require.resolve('util/'), - crypto: require.resolve('crypto-browserify'), - http: require.resolve('stream-http'), - https: require.resolve('https-browserify'), - buffer: require.resolve('buffer/'), - url: require.resolve('url/'), - assert: require.resolve('assert/'), - stream: require.resolve('stream-browserify'), - path: require.resolve('path-browserify'), - os: require.resolve('os-browserify/browser'), - zlib: require.resolve('browserify-zlib'), - events: require.resolve('events/'), - string_decoder: require.resolve('string_decoder/'), - tls: require.resolve('tls/'), - net: require.resolve('net/'), - process: require.resolve('process/browser'), - // Browser build have to use native WebSocket - ws: require.resolve('./build-utils/ws'), - }, - }, - plugins: [ - new webpack.ProvidePlugin({ - Buffer: [require.resolve('buffer/'), 'Buffer'], - process: require.resolve('process/browser'), - }), - ], - output: { - path: path.resolve(__dirname, 'dist'), - }, -}; -module.exports = baseConfig; diff --git a/packages/js-dash-sdk/webpack.config.js b/packages/js-dash-sdk/webpack.config.js deleted file mode 100644 index 057b1bf6473..00000000000 --- a/packages/js-dash-sdk/webpack.config.js +++ /dev/null @@ -1,22 +0,0 @@ -const path = require('path'); -const webpackBaseConfig = require('./webpack.base.config'); - -const webConfig = { - ...webpackBaseConfig, - entry: './build/index.js', - devtool: 'source-map', - mode: 'production', - target: 'web', - output: { - path: path.resolve(__dirname, 'dist'), - library: { - name: 'Dash', - type: 'umd', - }, - filename: 'dash.min.js', - // fixes ReferenceError: window is not defined - globalObject: "(typeof self !== 'undefined' ? self : this)", - }, -}; - -module.exports = [webConfig]; diff --git a/packages/platform-test-suite/.mocharc.yml b/packages/platform-test-suite/.mocharc.yml index 47667ea3d26..47e98389958 100644 --- a/packages/platform-test-suite/.mocharc.yml +++ b/packages/platform-test-suite/.mocharc.yml @@ -1,6 +1,6 @@ exit: true timeout: 650000 -require: +import: - ./lib/test/bootstrap.js parallel: true jobs: 2 diff --git a/packages/platform-test-suite/karma.conf.js b/packages/platform-test-suite/karma.conf.js deleted file mode 100644 index 05128836f99..00000000000 --- a/packages/platform-test-suite/karma.conf.js +++ /dev/null @@ -1,131 +0,0 @@ -const webpack = require('webpack'); -const dotenvResult = require('dotenv-safe').config(); -const glob = require('glob'); - -const karmaMocha = require('karma-mocha'); -const karmaMochaReporter = require('karma-mocha-reporter'); -const karmaChai = require('karma-chai'); -const karmaChromeLauncher = require('karma-chrome-launcher'); -const karmaFirefoxLauncher = require('karma-firefox-launcher'); -const karmaSourcemapLoader = require('karma-sourcemap-loader'); -const karmaWebpack = require('karma-webpack'); - -if (dotenvResult.error) { - throw dotenvResult.error; -} - -// TODO: Fix test to be running in Browser -const testFilesPattern = './test/**/!(proofs|waitForStateTransitionResult).spec.js'; -const processors = ['webpack', 'sourcemap']; -let testFiles = [ - testFilesPattern, -]; -let testPreprocessors = { - [testFilesPattern]: processors, -}; - -const batchTotal = parseInt(process.env.BROWSER_TEST_BATCH_TOTAL, 10); -const batchIndex = parseInt(process.env.BROWSER_TEST_BATCH_INDEX, 10); - -if (batchTotal !== 0) { - const files = glob.sync(testFilesPattern); - const batchSize = Math.ceil(files.length / batchTotal); - - const batches = []; - for (let i = 0; i < files.length; i += batchSize) { - batches.push(files.slice(i, i + batchSize)); - } - - testFiles = batches[batchIndex] || []; - - testPreprocessors = testFiles.reduce((acc, path) => { - acc[path] = processors; - - return acc; - }, {}); -} - -process.env.FAUCET_ADDRESS = process.env[`FAUCET_${batchIndex + 1}_ADDRESS`]; -process.env.FAUCET_PRIVATE_KEY = process.env[`FAUCET_${batchIndex + 1}_PRIVATE_KEY`]; - -module.exports = (config) => { - config.set({ - client: { - mocha: { - timeout: 650000, - bail: true, - }, - }, - browserNoActivityTimeout: 900000, - browserDisconnectTimeout: 900000, - frameworks: ['mocha', 'chai', 'webpack'], - files: [ - 'lib/test/karma/bootstrap.js', - ...testFiles, - ], - preprocessors: { - 'lib/test/karma/bootstrap.js': ['webpack', 'sourcemap'], - ...testPreprocessors, - }, - webpack: { - mode: 'development', - devtool: 'inline-source-map', - plugins: [ - new webpack.ProvidePlugin({ - Buffer: [require.resolve('buffer/'), 'Buffer'], - process: require.resolve('process/browser'), - }), - new webpack.EnvironmentPlugin( - { - ...dotenvResult.parsed, - FAUCET_ADDRESS: process.env.FAUCET_ADDRESS, - FAUCET_PRIVATE_KEY: process.env.FAUCET_PRIVATE_KEY, - }, - ), - ], - resolve: { - fallback: { - fs: false, - path: false, - net: false, - os: false, - http: false, - https: false, - assert: require.resolve('assert/'), - url: require.resolve('url/'), - string_decoder: require.resolve('string_decoder/'), - stream: require.resolve('stream-browserify'), - buffer: require.resolve('buffer/'), - crypto: require.resolve('crypto-browserify'), - events: require.resolve('events/'), - util: require.resolve('util/'), - process: require.resolve('process/browser'), - }, - extensions: ['.ts', '.js', '.json'], - }, - }, - reporters: ['mocha'], - port: 9876, - colors: true, - logLevel: config.LOG_INFO, - browsers: ['ChromeHeadlessInsecure'], - singleRun: true, - concurrency: Infinity, - plugins: [ - karmaMocha, - karmaMochaReporter, - karmaChai, - karmaChromeLauncher, - karmaFirefoxLauncher, - karmaSourcemapLoader, - karmaWebpack, - ], - customLaunchers: { - ChromeHeadlessInsecure: { - base: 'ChromeHeadless', - flags: ['--allow-insecure-localhost'], - displayName: 'Chrome w/o security', - }, - }, - }); -}; diff --git a/packages/platform-test-suite/lib/parseRootTreeProof.js b/packages/platform-test-suite/lib/parseRootTreeProof.js index 2863b4734a3..4699b611d87 100644 --- a/packages/platform-test-suite/lib/parseRootTreeProof.js +++ b/packages/platform-test-suite/lib/parseRootTreeProof.js @@ -1,6 +1,6 @@ -const BufferReader = require('@dashevo/dashcore-lib/lib/encoding/bufferreader'); +import BufferReader from '@dashevo/dashcore-lib/lib/encoding/bufferreader.js'; -module.exports = function parseRootTreeBuffer(rootTreeProofBuffer) { +export default function parseRootTreeBuffer(rootTreeProofBuffer) { /* amount of subtrees to proof It is equal to 1 because at the moment our proof won't be a simultaneous proof for more @@ -19,4 +19,4 @@ module.exports = function parseRootTreeBuffer(rootTreeProofBuffer) { } return hashes; -}; +} diff --git a/packages/platform-test-suite/lib/parseStoreTreeProof.js b/packages/platform-test-suite/lib/parseStoreTreeProof.js index f6b8a48048c..46a75b20fef 100644 --- a/packages/platform-test-suite/lib/parseStoreTreeProof.js +++ b/packages/platform-test-suite/lib/parseStoreTreeProof.js @@ -1,6 +1,6 @@ const hashLength = 32; -module.exports = function getStoreProofData(storeProof) { +export default function getStoreProofData(storeProof) { const buf = storeProof; const hashes = []; const keyValueHashes = []; @@ -58,4 +58,4 @@ module.exports = function getStoreProofData(storeProof) { return { hashes, keyValueHashes, values, keyValues, }; -}; +} diff --git a/packages/platform-test-suite/lib/test/bootstrap.js b/packages/platform-test-suite/lib/test/bootstrap.js index f4e9d46724b..ab73fb39cf7 100644 --- a/packages/platform-test-suite/lib/test/bootstrap.js +++ b/packages/platform-test-suite/lib/test/bootstrap.js @@ -1,10 +1,13 @@ -const path = require('path'); -const dotenvSafe = require('dotenv-safe'); -const { expect, use } = require('chai'); -const dirtyChai = require('dirty-chai'); -const chaiAsPromised = require('chai-as-promised'); -const sinon = require('sinon'); -const sinonChai = require('sinon-chai'); +import path from 'path'; +import { fileURLToPath } from 'url'; +import dotenvSafe from 'dotenv-safe'; +import { expect, use } from 'chai'; +import dirtyChai from 'dirty-chai'; +import chaiAsPromised from 'chai-as-promised'; +import sinon from 'sinon'; +import sinonChai from 'sinon-chai'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); use(chaiAsPromised); use(dirtyChai); @@ -25,7 +28,7 @@ if (process.env.MOCHA_WORKER_ID) { process.env.FAUCET_ADDRESS = process.env[`FAUCET_${faucetIndex}_ADDRESS`]; process.env.FAUCET_PRIVATE_KEY = process.env[`FAUCET_${faucetIndex}_PRIVATE_KEY`]; -exports.mochaHooks = { +export const mochaHooks = { beforeEach() { if (!this.sinon) { this.sinon = sinon.createSandbox(); diff --git a/packages/platform-test-suite/lib/test/createClientWithFundedWallet.js b/packages/platform-test-suite/lib/test/createClientWithFundedWallet.js index 42e4686b5b8..e1b8ff8a4ff 100644 --- a/packages/platform-test-suite/lib/test/createClientWithFundedWallet.js +++ b/packages/platform-test-suite/lib/test/createClientWithFundedWallet.js @@ -1,14 +1,13 @@ -const Dash = require('dash'); +import Dash from 'dash'; -const fundWallet = require('@dashevo/wallet-lib/src/utils/fundWallet'); +import fundWallet from '@dashevo/wallet-lib/src/utils/fundWallet.js'; -const { - contractId: dpnsContractId, -} = require('@dashevo/dpns-contract/lib/systemIds'); +import dpnsSystemIds from '@dashevo/dpns-contract/lib/systemIds.js'; +const { contractId: dpnsContractId } = dpnsSystemIds; -const getDAPISeeds = require('./getDAPISeeds'); +import getDAPISeeds from './getDAPISeeds.js'; -const createFaucetClient = require('./createFaucetClient'); +import createFaucetClient from './createFaucetClient.js'; let faucetClient; @@ -76,4 +75,4 @@ async function createClientWithFundedWallet(amount, HDPrivateKey = undefined) { return client; } -module.exports = createClientWithFundedWallet; +export default createClientWithFundedWallet; diff --git a/packages/platform-test-suite/lib/test/createClientWithoutWallet.js b/packages/platform-test-suite/lib/test/createClientWithoutWallet.js index 4df556792c0..8412c43b54e 100644 --- a/packages/platform-test-suite/lib/test/createClientWithoutWallet.js +++ b/packages/platform-test-suite/lib/test/createClientWithoutWallet.js @@ -1,8 +1,8 @@ -const Dash = require('dash'); +import Dash from 'dash'; +import dpnsSystemIds from '@dashevo/dpns-contract/lib/systemIds.js'; +const { contractId } = dpnsSystemIds; -const { contractId } = require('@dashevo/dpns-contract/lib/systemIds'); - -const getDAPISeeds = require('./getDAPISeeds'); +import getDAPISeeds from './getDAPISeeds.js'; function createClientWithoutWallet() { const dapiAddresses = (process.env.DAPI_ADDRESSES || '') @@ -24,4 +24,4 @@ function createClientWithoutWallet() { }); } -module.exports = createClientWithoutWallet; +export default createClientWithoutWallet; diff --git a/packages/platform-test-suite/lib/test/createFaucetClient.js b/packages/platform-test-suite/lib/test/createFaucetClient.js index 575b7551e2e..09c128d203a 100644 --- a/packages/platform-test-suite/lib/test/createFaucetClient.js +++ b/packages/platform-test-suite/lib/test/createFaucetClient.js @@ -1,23 +1,21 @@ -const Dash = require('dash'); +import Dash from 'dash'; +import dpnsSystemIds from '@dashevo/dpns-contract/lib/systemIds.js'; +const { contractId } = dpnsSystemIds; + +import getDAPISeeds from './getDAPISeeds.js'; let storageAdapter; if (typeof window === 'undefined') { - // eslint-disable-next-line global-require - const { NodeForage } = require('nodeforage'); + const { NodeForage } = await import('nodeforage'); storageAdapter = new NodeForage({ dir: process.env.FAUCET_WALLET_STORAGE_DIR || process.cwd(), name: `faucet-wallet-${process.env.FAUCET_ADDRESS}`, }); } else { - // eslint-disable-next-line global-require - storageAdapter = require('localforage'); + storageAdapter = (await import('localforage')).default; } -const { contractId } = require('@dashevo/dpns-contract/lib/systemIds'); - -const getDAPISeeds = require('./getDAPISeeds'); - let faucetClient; function createFaucetClient() { @@ -60,4 +58,4 @@ function createFaucetClient() { return faucetClient; } -module.exports = createFaucetClient; +export default createFaucetClient; diff --git a/packages/platform-test-suite/lib/test/fixtures/getDataContractFixture.js b/packages/platform-test-suite/lib/test/fixtures/getDataContractFixture.js index 8fdb9d0a8bd..a46bb1809d4 100644 --- a/packages/platform-test-suite/lib/test/fixtures/getDataContractFixture.js +++ b/packages/platform-test-suite/lib/test/fixtures/getDataContractFixture.js @@ -1,7 +1,7 @@ -const Dash = require('dash'); +import Dash from 'dash'; -const crypto = require('crypto'); -const generateRandomIdentifier = require('../utils/generateRandomIdentifier'); +import crypto from 'crypto'; +import generateRandomIdentifier from '../utils/generateRandomIdentifier.js'; const { Platform, @@ -14,7 +14,7 @@ let randomOwnerId = null; * @param {Identifier} [ownerId] * @return {Promise} */ -module.exports = async function getDataContractFixture( +export default async function getDataContractFixture( identityNonce, ownerId = randomOwnerId, ) { @@ -152,4 +152,4 @@ module.exports = async function getDataContractFixture( }; return factory.create(ownerId, BigInt(identityNonce), documents, config); -}; +} diff --git a/packages/platform-test-suite/lib/test/fixtures/getIdentityFixture.js b/packages/platform-test-suite/lib/test/fixtures/getIdentityFixture.js index 736507220ce..7a935610437 100644 --- a/packages/platform-test-suite/lib/test/fixtures/getIdentityFixture.js +++ b/packages/platform-test-suite/lib/test/fixtures/getIdentityFixture.js @@ -1,6 +1,6 @@ -const Dash = require('dash'); +import Dash from 'dash'; -const generateRandomIdentifier = require('../utils/generateRandomIdentifier'); +import generateRandomIdentifier from '../utils/generateRandomIdentifier.js'; const { Platform, @@ -9,7 +9,7 @@ const { /** * @return {Identity} */ -module.exports = async function getIdentityFixture() { +export default async function getIdentityFixture() { const { Identity, IdentityPublicKey } = await Platform .initializeDppModule(); @@ -30,4 +30,4 @@ module.exports = async function getIdentityFixture() { identity.setBalance(BigInt(10000)); return identity; -}; +} diff --git a/packages/platform-test-suite/lib/test/getDAPISeeds.js b/packages/platform-test-suite/lib/test/getDAPISeeds.js index 1112fd10496..d18c9803774 100644 --- a/packages/platform-test-suite/lib/test/getDAPISeeds.js +++ b/packages/platform-test-suite/lib/test/getDAPISeeds.js @@ -1,4 +1,4 @@ -const DAPIAddress = require('@dashevo/dapi-client/lib/dapiAddressProvider/DAPIAddress'); +import DAPIAddress from '@dashevo/dapi-client/lib/dapiAddressProvider/DAPIAddress.js'; function getDAPISeeds() { return process.env.DAPI_SEED @@ -10,4 +10,4 @@ function getDAPISeeds() { }); } -module.exports = getDAPISeeds; +export default getDAPISeeds; diff --git a/packages/platform-test-suite/lib/test/karma/bootstrap.js b/packages/platform-test-suite/lib/test/karma/bootstrap.js deleted file mode 100644 index d76c466bdbc..00000000000 --- a/packages/platform-test-suite/lib/test/karma/bootstrap.js +++ /dev/null @@ -1,26 +0,0 @@ -const { expect, use } = require('chai'); -const dirtyChai = require('dirty-chai'); -const chaiAsPromised = require('chai-as-promised'); -const sinon = require('sinon'); -const sinonChai = require('sinon-chai'); -require('setimmediate'); - -use(chaiAsPromised); -use(dirtyChai); -use(sinonChai); - -exports.mochaHooks = { - beforeEach() { - if (!this.sinon) { - this.sinon = sinon.createSandbox(); - } else { - this.sinon.restore(); - } - }, - - afterEach() { - this.sinon.restore(); - }, -}; - -global.expect = expect; diff --git a/packages/platform-test-suite/lib/test/testProofStructure.js b/packages/platform-test-suite/lib/test/testProofStructure.js index f80ad001b1f..906aa6c05a2 100644 --- a/packages/platform-test-suite/lib/test/testProofStructure.js +++ b/packages/platform-test-suite/lib/test/testProofStructure.js @@ -19,4 +19,4 @@ function testProofStructure(expect, proof, proofExist = true) { expect(proof.round).to.be.greaterThanOrEqual(0); } -module.exports = testProofStructure; +export default testProofStructure; diff --git a/packages/platform-test-suite/lib/test/throwGrpcErrorWithMetadata.js b/packages/platform-test-suite/lib/test/throwGrpcErrorWithMetadata.js index a04af511902..2bdede447c5 100644 --- a/packages/platform-test-suite/lib/test/throwGrpcErrorWithMetadata.js +++ b/packages/platform-test-suite/lib/test/throwGrpcErrorWithMetadata.js @@ -1,4 +1,4 @@ -const { inspect } = require('util'); +import { inspect } from 'util'; /** * @param {Error} e @@ -11,4 +11,4 @@ function throwGrpcErrorWithMetadata(e) { throw e; } -module.exports = throwGrpcErrorWithMetadata; +export default throwGrpcErrorWithMetadata; diff --git a/packages/platform-test-suite/lib/test/utils/generateRandomIdentifier.js b/packages/platform-test-suite/lib/test/utils/generateRandomIdentifier.js index 6979c0e139b..0f4c4385000 100644 --- a/packages/platform-test-suite/lib/test/utils/generateRandomIdentifier.js +++ b/packages/platform-test-suite/lib/test/utils/generateRandomIdentifier.js @@ -1,5 +1,5 @@ -const crypto = require('crypto'); -const Dash = require('dash'); +import crypto from 'crypto'; +import Dash from 'dash'; const { Platform } = Dash; @@ -13,4 +13,4 @@ async function generateRandomIdentifier() { return new Identifier(crypto.randomBytes(32)); } -module.exports = generateRandomIdentifier; +export default generateRandomIdentifier; diff --git a/packages/platform-test-suite/lib/test/waitForBalanceToChange.js b/packages/platform-test-suite/lib/test/waitForBalanceToChange.js index db8a733e8a1..335cac27323 100644 --- a/packages/platform-test-suite/lib/test/waitForBalanceToChange.js +++ b/packages/platform-test-suite/lib/test/waitForBalanceToChange.js @@ -1,4 +1,4 @@ -const wait = require('../wait'); +import wait from '../wait.js'; const MAX_TIME_TO_WAIT_MS = 20000; const ITERATION_TIME_MS = 500; @@ -20,4 +20,4 @@ async function waitForBalanceToChange(walletAccount) { } } -module.exports = waitForBalanceToChange; +export default waitForBalanceToChange; diff --git a/packages/platform-test-suite/lib/wait.js b/packages/platform-test-suite/lib/wait.js index 13247577b15..e5c4b4b2d6e 100644 --- a/packages/platform-test-suite/lib/wait.js +++ b/packages/platform-test-suite/lib/wait.js @@ -1,3 +1,3 @@ -module.exports = function wait(ms) { +export default function wait(ms) { return new Promise((res) => { setTimeout(res, ms); }); -}; +} diff --git a/packages/platform-test-suite/lib/waitForBlocks.js b/packages/platform-test-suite/lib/waitForBlocks.js index e1f826418ba..4a38b3022cb 100644 --- a/packages/platform-test-suite/lib/waitForBlocks.js +++ b/packages/platform-test-suite/lib/waitForBlocks.js @@ -1,4 +1,4 @@ -const wait = require('./wait'); +import wait from './wait.js'; /** * @@ -6,7 +6,7 @@ const wait = require('./wait'); * @param {number} numberOfBlocks * @return {Promise} */ -module.exports = async function waitForBlocks(dapiClient, numberOfBlocks) { +export default async function waitForBlocks(dapiClient, numberOfBlocks) { let currentBlockHeight = await dapiClient.core.getBestBlockHeight(); const desiredBlockHeight = currentBlockHeight + numberOfBlocks; @@ -17,4 +17,4 @@ module.exports = async function waitForBlocks(dapiClient, numberOfBlocks) { await wait(5000); } } while (currentBlockHeight < desiredBlockHeight); -}; +} diff --git a/packages/platform-test-suite/lib/waitForSTPropagated.js b/packages/platform-test-suite/lib/waitForSTPropagated.js index 1c691550b7b..89d24625faa 100644 --- a/packages/platform-test-suite/lib/waitForSTPropagated.js +++ b/packages/platform-test-suite/lib/waitForSTPropagated.js @@ -1,4 +1,4 @@ -const wait = require('./wait'); +import wait from './wait.js'; /** * @returns {Promise} @@ -13,4 +13,4 @@ async function waitForSTPropagated() { await wait(interval); } -module.exports = waitForSTPropagated; +export default waitForSTPropagated; diff --git a/packages/platform-test-suite/package.json b/packages/platform-test-suite/package.json index 6a8007aa56a..b9b29909cbc 100644 --- a/packages/platform-test-suite/package.json +++ b/packages/platform-test-suite/package.json @@ -3,12 +3,15 @@ "private": true, "version": "3.1.0-dev.1", "description": "Dash Network end-to-end tests", + "type": "module", + "engines": { + "node": ">=18.18" + }, "scripts": { "test": "yarn exec bin/test.sh", "lint": "eslint .", "test:e2e": "NODE_ENV=test mocha 'test/e2e/**/*.spec.js'", - "test:functional": "NODE_ENV=test mocha 'test/functional/**/*.spec.js'", - "test:browsers": "karma start ./karma.conf.js" + "test:functional": "NODE_ENV=test mocha 'test/functional/**/*.spec.js'" }, "bin": { "test": "bin/test.sh" @@ -31,48 +34,22 @@ "@dashevo/wallet-lib": "workspace:*", "@dashevo/wasm-dpp": "workspace:*", "@dashevo/withdrawals-contract": "workspace:*", - "assert": "^2.0.0", - "assert-browserify": "^2.0.0", - "browserify-zlib": "^0.2.0", - "buffer": "^6.0.3", "bufferutil": "^4.0.6", "chai": "^4.3.10", "chai-as-promised": "^7.1.1", - "crypto-browserify": "^3.12.1", "dash": "workspace:*", "dirty-chai": "^2.0.1", "dotenv-safe": "^8.2.0", - "events": "^3.3.0", "glob": "^10.3.4", - "https-browserify": "^1.0.0", "js-merkle": "^0.1.5", - "karma": "^6.4.3", - "karma-chai": "^0.1.0", - "karma-chrome-launcher": "^3.1.0", - "karma-firefox-launcher": "^2.1.2", - "karma-mocha": "^2.0.1", - "karma-mocha-reporter": "^2.2.5", - "karma-sourcemap-loader": "^0.3.7", - "karma-webpack": "^5.0.0", "localforage": "^1.10.0", "mocha": "^11.1.0", - "net": "^1.0.2", "nodeforage": "^1.1.2", - "os-browserify": "^0.3.0", - "path-browserify": "^1.0.1", - "process": "^0.11.10", "semver": "^7.5.3", "setimmediate": "^1.0.5", "sinon": "^18.0.1", "sinon-chai": "^3.7.0", - "stream-browserify": "^3.0.0", - "stream-http": "^3.2.0", - "string_decoder": "^1.3.0", - "tls": "^0.0.1", - "url": "^0.11.3", "utf-8-validate": "^5.0.9", - "util": "^0.12.4", - "webpack": "^5.104.0", "ws": "^8.17.1" }, "devDependencies": { diff --git a/packages/platform-test-suite/test/e2e/contacts.spec.js b/packages/platform-test-suite/test/e2e/contacts.spec.js index 664b927495d..23b8572b40f 100644 --- a/packages/platform-test-suite/test/e2e/contacts.spec.js +++ b/packages/platform-test-suite/test/e2e/contacts.spec.js @@ -1,4 +1,7 @@ -const Dash = require('dash'); +import Dash from 'dash'; + +import createClientWithFundedWallet from '../../lib/test/createClientWithFundedWallet.js'; +import waitForSTPropagated from '../../lib/waitForSTPropagated.js'; const { PlatformProtocol: { @@ -8,9 +11,6 @@ const { }, } = Dash; -const createClientWithFundedWallet = require('../../lib/test/createClientWithFundedWallet'); -const waitForSTPropagated = require('../../lib/waitForSTPropagated'); - describe('e2e', () => { describe('Contacts', function contacts() { this.timeout(950000); diff --git a/packages/platform-test-suite/test/e2e/dpns.spec.js b/packages/platform-test-suite/test/e2e/dpns.spec.js index 786f583f873..60647f8aee4 100644 --- a/packages/platform-test-suite/test/e2e/dpns.spec.js +++ b/packages/platform-test-suite/test/e2e/dpns.spec.js @@ -1,11 +1,10 @@ -const crypto = require('crypto'); +import crypto from 'crypto'; -const { - contractId: dpnsContractId, -} = require('@dashevo/dpns-contract/lib/systemIds'); +import dpnsSystemIds from '@dashevo/dpns-contract/lib/systemIds.js'; +const { contractId: dpnsContractId } = dpnsSystemIds; -const createClientWithFundedWallet = require('../../lib/test/createClientWithFundedWallet'); -const waitForSTPropagated = require('../../lib/waitForSTPropagated'); +import createClientWithFundedWallet from '../../lib/test/createClientWithFundedWallet.js'; +import waitForSTPropagated from '../../lib/waitForSTPropagated.js'; const getRandomDomain = () => crypto.randomBytes(10).toString('hex'); diff --git a/packages/platform-test-suite/test/e2e/wallet.spec.js b/packages/platform-test-suite/test/e2e/wallet.spec.js index 241ba81204b..0c2ac440be4 100644 --- a/packages/platform-test-suite/test/e2e/wallet.spec.js +++ b/packages/platform-test-suite/test/e2e/wallet.spec.js @@ -1,9 +1,9 @@ -const Dash = require('dash'); +import Dash from 'dash'; -const getDAPISeeds = require('../../lib/test/getDAPISeeds'); +import getDAPISeeds from '../../lib/test/getDAPISeeds.js'; -const createClientWithFundedWallet = require('../../lib/test/createClientWithFundedWallet'); -const waitForBalanceToChange = require('../../lib/test/waitForBalanceToChange'); +import createClientWithFundedWallet from '../../lib/test/createClientWithFundedWallet.js'; +import waitForBalanceToChange from '../../lib/test/waitForBalanceToChange.js'; const { EVENTS } = Dash.WalletLib; diff --git a/packages/platform-test-suite/test/e2e/withdrawals.spec.js b/packages/platform-test-suite/test/e2e/withdrawals.spec.js index b7afc0fb2c7..fdb59ac0d65 100644 --- a/packages/platform-test-suite/test/e2e/withdrawals.spec.js +++ b/packages/platform-test-suite/test/e2e/withdrawals.spec.js @@ -1,10 +1,10 @@ -const { expect } = require('chai'); +import { expect } from 'chai'; -const wait = require('@dashevo/dapi-client/lib/utils/wait'); -const { STATUSES: WITHDRAWAL_STATUSES } = require('dash/build/SDK/Client/Platform/methods/identities/creditWithdrawal'); +import wait from '@dashevo/dapi-client/lib/utils/wait.js'; +import { STATUSES as WITHDRAWAL_STATUSES } from 'dash/build/SDK/Client/Platform/methods/identities/creditWithdrawal.js'; -const createClientWithFundedWallet = require('../../lib/test/createClientWithFundedWallet'); -const waitForSTPropagated = require('../../lib/waitForSTPropagated'); +import createClientWithFundedWallet from '../../lib/test/createClientWithFundedWallet.js'; +import waitForSTPropagated from '../../lib/waitForSTPropagated.js'; // TODO: temporary disabled due to flakiness. These tests aren't important for now, since we are // going to release v1.0.0 with withdrawals disabled. diff --git a/packages/platform-test-suite/test/functional/core/broadcastTransaction.spec.js b/packages/platform-test-suite/test/functional/core/broadcastTransaction.spec.js index 8f991426804..19529cfa684 100644 --- a/packages/platform-test-suite/test/functional/core/broadcastTransaction.spec.js +++ b/packages/platform-test-suite/test/functional/core/broadcastTransaction.spec.js @@ -1,6 +1,6 @@ -const Dash = require('dash'); +import Dash from 'dash'; -const createClientWithFundedWallet = require('../../../lib/test/createClientWithFundedWallet'); +import createClientWithFundedWallet from '../../../lib/test/createClientWithFundedWallet.js'; const { Core: { PrivateKey } } = Dash; diff --git a/packages/platform-test-suite/test/functional/core/getBlock.spec.js b/packages/platform-test-suite/test/functional/core/getBlock.spec.js index 8a1de774d7d..91435dc9070 100644 --- a/packages/platform-test-suite/test/functional/core/getBlock.spec.js +++ b/packages/platform-test-suite/test/functional/core/getBlock.spec.js @@ -1,6 +1,6 @@ -const Dash = require('dash'); +import Dash from 'dash'; -const createClientWithoutWallet = require('../../../lib/test/createClientWithoutWallet'); +import createClientWithoutWallet from '../../../lib/test/createClientWithoutWallet.js'; const { Core: { Block }, Essentials: { Buffer } } = Dash; diff --git a/packages/platform-test-suite/test/functional/core/getBlockHash.spec.js b/packages/platform-test-suite/test/functional/core/getBlockHash.spec.js index b7df1e3b884..23952d9f52b 100644 --- a/packages/platform-test-suite/test/functional/core/getBlockHash.spec.js +++ b/packages/platform-test-suite/test/functional/core/getBlockHash.spec.js @@ -1,4 +1,4 @@ -const createClientWithoutWallet = require('../../../lib/test/createClientWithoutWallet'); +import createClientWithoutWallet from '../../../lib/test/createClientWithoutWallet.js'; describe('Core', () => { describe('getBlockHash', () => { diff --git a/packages/platform-test-suite/test/functional/core/getBlockchainStatus.spec.js b/packages/platform-test-suite/test/functional/core/getBlockchainStatus.spec.js index 780e2da5887..0809b07a44b 100644 --- a/packages/platform-test-suite/test/functional/core/getBlockchainStatus.spec.js +++ b/packages/platform-test-suite/test/functional/core/getBlockchainStatus.spec.js @@ -1,6 +1,8 @@ -const { Essentials: { Buffer } } = require('dash'); +import Dash from 'dash'; -const createClientWithoutWallet = require('../../../lib/test/createClientWithoutWallet'); +import createClientWithoutWallet from '../../../lib/test/createClientWithoutWallet.js'; + +const { Essentials: { Buffer } } = Dash; describe('Core', () => { describe('getBlockchainStatus', function main() { diff --git a/packages/platform-test-suite/test/functional/core/getMasternodeStatus.spec.js b/packages/platform-test-suite/test/functional/core/getMasternodeStatus.spec.js index eb473c739ca..c6c81bcc60d 100644 --- a/packages/platform-test-suite/test/functional/core/getMasternodeStatus.spec.js +++ b/packages/platform-test-suite/test/functional/core/getMasternodeStatus.spec.js @@ -1,6 +1,8 @@ -const { Essentials: { Buffer } } = require('dash'); +import Dash from 'dash'; -const createClientWithoutWallet = require('../../../lib/test/createClientWithoutWallet'); +import createClientWithoutWallet from '../../../lib/test/createClientWithoutWallet.js'; + +const { Essentials: { Buffer } } = Dash; describe.skip('Core', () => { describe('getMasternodeStatus', function main() { diff --git a/packages/platform-test-suite/test/functional/core/getTransaction.spec.js b/packages/platform-test-suite/test/functional/core/getTransaction.spec.js index 0c9088d00a3..afdf8a76cbe 100644 --- a/packages/platform-test-suite/test/functional/core/getTransaction.spec.js +++ b/packages/platform-test-suite/test/functional/core/getTransaction.spec.js @@ -1,7 +1,7 @@ -const Dash = require('dash'); +import Dash from 'dash'; -const wait = require('../../../lib/wait'); -const createClientWithFundedWallet = require('../../../lib/test/createClientWithFundedWallet'); +import wait from '../../../lib/wait.js'; +import createClientWithFundedWallet from '../../../lib/test/createClientWithFundedWallet.js'; const { Core: { Transaction, PrivateKey }, DAPIClient: { diff --git a/packages/platform-test-suite/test/functional/dapi/subscribeToBlockHeadersWithChainLocksHandlerFactory.spec.js b/packages/platform-test-suite/test/functional/dapi/subscribeToBlockHeadersWithChainLocksHandlerFactory.spec.js index 1ee274c38e1..78b6078fd2e 100644 --- a/packages/platform-test-suite/test/functional/dapi/subscribeToBlockHeadersWithChainLocksHandlerFactory.spec.js +++ b/packages/platform-test-suite/test/functional/dapi/subscribeToBlockHeadersWithChainLocksHandlerFactory.spec.js @@ -1,9 +1,9 @@ -const EventEmitter = require('events'); -const Dash = require('dash'); +import EventEmitter from 'events'; +import Dash from 'dash'; -const GrpcErrorCodes = require('@dashevo/grpc-common/lib/server/error/GrpcErrorCodes'); -const getDAPISeeds = require('../../../lib/test/getDAPISeeds'); -const createClientWithFundedWallet = require('../../../lib/test/createClientWithFundedWallet'); +import GrpcErrorCodes from '@dashevo/grpc-common/lib/server/error/GrpcErrorCodes.js'; +import getDAPISeeds from '../../../lib/test/getDAPISeeds.js'; +import createClientWithFundedWallet from '../../../lib/test/createClientWithFundedWallet.js'; const { Core: { @@ -137,19 +137,6 @@ describe('subscribeToBlockHeadersWithChainLocksHandlerFactory', () => { expect(streamError).to.not.exist(); expect(streamEnded).to.be.true(); - // TODO: Implement getBlockHeaders in dapi-client so we can compare block hashes - // const fetchedBlocks = []; - // - // for (let i = 1; i <= headersAmount; i++) { - // const rawBlock = await dapiClient.core.getBlockByHeight(i); - // const block = new Block(rawBlock); - // - // fetchedBlocks.push(block); - // } - // - // expect(historicalBlockHeaders.map((header) => header.hash)) - // .to.deep.equal(fetchedBlocks.map((block) => block.header.hash)); - expect(historicalBlockHeaders.length).to.equal(headersAmount); expect(bestChainLock.height).to.exist(); }); @@ -225,21 +212,6 @@ describe('subscribeToBlockHeadersWithChainLocksHandlerFactory', () => { expect(streamError).to.not.exist(); - // TODO: Implement getBlockHeaders in dapi-client to compare block hashes - // const fetchedHistoricalBlocks = []; - // - // for (let i = bestBlockHeight - historicalBlocksToGet + 1; i <= bestBlockHeight; i++) { - // const rawBlock = await dapiClient.core.getBlockByHeight(i); - // const block = new Block(rawBlock); - // - // fetchedHistoricalBlocks.push(block); - // } - // - // for (let i = 0; i < historicalBlocksToGet; i++) { - // expect(fetchedHistoricalBlocks[i].header.hash).to.equal( - // [...blockHeadersHashesFromStream][i]); - // } - expect(obtainedFreshBlock).to.be.true(); expect(latestChainLock).to.exist(); }); diff --git a/packages/platform-test-suite/test/functional/platform/DataContract.spec.js b/packages/platform-test-suite/test/functional/platform/DataContract.spec.js index 18cf12f1132..7e1e00c9b76 100644 --- a/packages/platform-test-suite/test/functional/platform/DataContract.spec.js +++ b/packages/platform-test-suite/test/functional/platform/DataContract.spec.js @@ -1,9 +1,9 @@ -const Dash = require('dash'); +import Dash from 'dash'; -const getDataContractFixture = require('../../../lib/test/fixtures/getDataContractFixture'); +import getDataContractFixture from '../../../lib/test/fixtures/getDataContractFixture.js'; -const createClientWithFundedWallet = require('../../../lib/test/createClientWithFundedWallet'); -const waitForSTPropagated = require('../../../lib/waitForSTPropagated'); +import createClientWithFundedWallet from '../../../lib/test/createClientWithFundedWallet.js'; +import waitForSTPropagated from '../../../lib/waitForSTPropagated.js'; const { Errors: { diff --git a/packages/platform-test-suite/test/functional/platform/Document.spec.js b/packages/platform-test-suite/test/functional/platform/Document.spec.js index f30c7b4feb4..c7370fbdcc6 100644 --- a/packages/platform-test-suite/test/functional/platform/Document.spec.js +++ b/packages/platform-test-suite/test/functional/platform/Document.spec.js @@ -1,13 +1,13 @@ -const Dash = require('dash'); -const { expect } = require('chai'); +import Dash from 'dash'; +import { expect } from 'chai'; -const { signStateTransition } = require('dash/build/SDK/Client/Platform/signStateTransition'); +import { signStateTransition } from 'dash/build/SDK/Client/Platform/signStateTransition.js'; -const getIdentityFixture = require('../../../lib/test/fixtures/getIdentityFixture'); -const getDataContractFixture = require('../../../lib/test/fixtures/getDataContractFixture'); +import getIdentityFixture from '../../../lib/test/fixtures/getIdentityFixture.js'; +import getDataContractFixture from '../../../lib/test/fixtures/getDataContractFixture.js'; -const createClientWithFundedWallet = require('../../../lib/test/createClientWithFundedWallet'); -const waitForSTPropagated = require('../../../lib/waitForSTPropagated'); +import createClientWithFundedWallet from '../../../lib/test/createClientWithFundedWallet.js'; +import waitForSTPropagated from '../../../lib/waitForSTPropagated.js'; const { Errors: { diff --git a/packages/platform-test-suite/test/functional/platform/Epoch.spec.js b/packages/platform-test-suite/test/functional/platform/Epoch.spec.js index 3d712b446d8..7281bf279c6 100644 --- a/packages/platform-test-suite/test/functional/platform/Epoch.spec.js +++ b/packages/platform-test-suite/test/functional/platform/Epoch.spec.js @@ -1,4 +1,4 @@ -const createClientWithoutWallet = require('../../../lib/test/createClientWithoutWallet'); +import createClientWithoutWallet from '../../../lib/test/createClientWithoutWallet.js'; describe('Platform', () => { describe('Epoch', () => { diff --git a/packages/platform-test-suite/test/functional/platform/Identity.spec.js b/packages/platform-test-suite/test/functional/platform/Identity.spec.js index c719b46fdee..ebbd3a775f4 100644 --- a/packages/platform-test-suite/test/functional/platform/Identity.spec.js +++ b/packages/platform-test-suite/test/functional/platform/Identity.spec.js @@ -1,11 +1,11 @@ -const Dash = require('dash'); +import Dash from 'dash'; -const { createFakeInstantLock } = require('dash/build/utils/createFakeIntantLock'); +import { createFakeInstantLock } from 'dash/build/utils/createFakeIntantLock.js'; -const { hash, sha256 } = require('@dashevo/wasm-dpp/lib/utils/hash'); -const getDataContractFixture = require('../../../lib/test/fixtures/getDataContractFixture'); -const createClientWithFundedWallet = require('../../../lib/test/createClientWithFundedWallet'); -const waitForSTPropagated = require('../../../lib/waitForSTPropagated'); +import { hash, sha256 } from '@dashevo/wasm-dpp/lib/utils/hash.js'; +import getDataContractFixture from '../../../lib/test/fixtures/getDataContractFixture.js'; +import createClientWithFundedWallet from '../../../lib/test/createClientWithFundedWallet.js'; +import waitForSTPropagated from '../../../lib/waitForSTPropagated.js'; const { Essentials: { diff --git a/packages/platform-test-suite/test/functional/platform/ProtocolVersion.spec.js b/packages/platform-test-suite/test/functional/platform/ProtocolVersion.spec.js index 5a550ab288c..7c90009b471 100644 --- a/packages/platform-test-suite/test/functional/platform/ProtocolVersion.spec.js +++ b/packages/platform-test-suite/test/functional/platform/ProtocolVersion.spec.js @@ -1,4 +1,4 @@ -const createClientWithoutWallet = require('../../../lib/test/createClientWithoutWallet'); +import createClientWithoutWallet from '../../../lib/test/createClientWithoutWallet.js'; describe('Platform', () => { describe('ProtocolVersion', () => { diff --git a/packages/platform-test-suite/test/functional/platform/getStatus.spec.js b/packages/platform-test-suite/test/functional/platform/getStatus.spec.js index e3c2dbd3d9d..f3cfc3a5f79 100644 --- a/packages/platform-test-suite/test/functional/platform/getStatus.spec.js +++ b/packages/platform-test-suite/test/functional/platform/getStatus.spec.js @@ -1,4 +1,4 @@ -const createClientWithoutWallet = require('../../../lib/test/createClientWithoutWallet'); +import createClientWithoutWallet from '../../../lib/test/createClientWithoutWallet.js'; describe('Platform', () => { describe('getStatus', () => { diff --git a/packages/platform-test-suite/test/functional/platform/proofs.spec.js b/packages/platform-test-suite/test/functional/platform/proofs.spec.js index 5b56d181779..3350d022049 100644 --- a/packages/platform-test-suite/test/functional/platform/proofs.spec.js +++ b/packages/platform-test-suite/test/functional/platform/proofs.spec.js @@ -1,14 +1,14 @@ -const Dash = require('dash'); -const { MerkleProof, MerkleTree } = require('js-merkle'); -const { - contractId: dpnsContractId, - ownerId: dpnsOwnerId, -} = require('@dashevo/dpns-contract/lib/systemIds'); - -const generateRandomIdentifier = require('../../../lib/test/utils/generateRandomIdentifier'); -const testProofStructure = require('../../../lib/test/testProofStructure'); -// const parseStoreTreeProof = require('../../../lib/parseStoreTreeProof'); -const createClientWithFundedWallet = require('../../../lib/test/createClientWithFundedWallet'); +import Dash from 'dash'; +import { MerkleProof, MerkleTree } from 'js-merkle'; +import { + contractId as dpnsContractId, + ownerId as dpnsOwnerId, +} from '@dashevo/dpns-contract/lib/systemIds.js'; + +import generateRandomIdentifier from '../../../lib/test/utils/generateRandomIdentifier.js'; +import testProofStructure from '../../../lib/test/testProofStructure.js'; +// import parseStoreTreeProof from '../../../lib/parseStoreTreeProof.js'; +import createClientWithFundedWallet from '../../../lib/test/createClientWithFundedWallet.js'; const { Core: { @@ -51,46 +51,9 @@ describe('Platform', () => { const dataContractResponseWithProof = await dashClient.getDAPIClient() .platform.getDataContract(contractId, { prove: true }); - // const dataContractResponse = await dashClient.getDAPIClient().platform.getDataContract( - // contractId, - // ); - - // const dataContract = await dashClient.platform.dpp - // .dataContract.createFromBuffer(dataContractResponse.getDataContract()); - const fullProof = dataContractResponseWithProof.getProof(); testProofStructure(expect, fullProof); - - // const dataContractsProofBuffer = fullProof.storeTreeProofs.getDataContractsProof(); - // - // const parsedStoreTreeProof = parseStoreTreeProof(dataContractsProofBuffer); - // - // expect(parsedStoreTreeProof.values.length).to.be.equal(1); - // - // const restoredDataContract = await dashClient.platform.dpp - // .dataContract.createFromBuffer(parsedStoreTreeProof.values[0]); - // - // expect(restoredDataContract.toObject()).to.be.deep.equal(dataContract.toObject()); - // - // const { rootHash: dataContractsLeafRoot } = executeProof(dataContractsProofBuffer); - // - // const verificationResult = verifyProof( - // dataContractsProofBuffer, - // [contractId], - // dataContractsLeafRoot, - // ); - // - // // We pass one key - // expect(verificationResult.length).to.be.equal(1); - // - // const recoveredDataContractBuffer = verificationResult[0]; - // expect(recoveredDataContractBuffer).to.be.an.instanceof(Uint8Array); - // - // const recoveredDataContract = await dashClient.platform.dpp - // .dataContract.createFromBuffer(recoveredDataContractBuffer); - // - // expect(recoveredDataContract.toObject()).to.be.deep.equal(dataContract.toObject()); }); // TODO(rs-drive-abci): restore. @@ -105,21 +68,6 @@ describe('Platform', () => { const fullProof = dataContractWithProof.proof; testProofStructure(expect, fullProof); - - // const dataContractsProofBuffer = fullProof.storeTreeProofs.getDataContractsProof(); - // - // const { rootHash: dataContractsLeafRoot } = executeProof(dataContractsProofBuffer); - // - // const verificationResult = verifyProof( - // dataContractsProofBuffer, - // [dataContractId], - // dataContractsLeafRoot, - // ); - // - // // We pass one key - // expect(verificationResult.length).to.be.equal(1); - // // Data contract doesn't exist, so result is null - // expect(verificationResult[0]).to.be.null(); }); }); @@ -140,8 +88,6 @@ describe('Platform', () => { identityAtKey8 = await dashClient.platform.identities.register(230000); - // await waitForBalanceToChange(walletAccount); - nonIncludedIdentityPubKeyHash = new PrivateKey().toPublicKey().hash; // Public key hashes @@ -158,38 +104,6 @@ describe('Platform', () => { const fullProof = identityProof.proof; testProofStructure(expect, fullProof); - - // const identitiesProofBuffer = fullProof.storeTreeProofs.getIdentitiesProof(); - // - // const parsedStoreTreeProof = parseStoreTreeProof(identitiesProofBuffer); - // - // const parsedIdentity = dashClient.platform.dpp - // .identity.createFromBuffer(parsedStoreTreeProof.values[0]); - // expect(identity.getId()).to.be.deep.equal(parsedIdentity.getId()); - // - // const { rootHash: identityLeafRoot } = executeProof(identitiesProofBuffer); - // - // const verificationResult = verifyProof( - // identitiesProofBuffer, - // [identity.getId()], - // identityLeafRoot, - // ); - // - // // We pass one key - // expect(verificationResult.length).to.be.equal(1); - // // Identity with id at index 0 doesn't exist - // const recoveredIdentityBuffer = verificationResult[0]; - // expect(recoveredIdentityBuffer).to.be.an.instanceof(Uint8Array); - // - // const recoveredIdentity = dashClient.platform.dpp - // .identity.createFromBuffer(recoveredIdentityBuffer); - // - // // Deep equal won't work in this case, because identity returned by the register - // const actualIdentity = identity.toObject(); - // // Because the actual identity state is before the registration, and the - // // balance wasn't added to it yet - // actualIdentity.balance = recoveredIdentity.toObject().balance; - // expect(recoveredIdentity.toObject()).to.be.deep.equal(actualIdentity); }); it('should be able to verify proof that identity does not exist', async () => { @@ -202,34 +116,6 @@ describe('Platform', () => { const fullProof = identityProof.proof; testProofStructure(expect, fullProof); - - // const identitiesProofBuffer = fullProof.storeTreeProofs.getIdentitiesProof(); - // - // // const rootTreeProof = parseRootTreeProof(fullProof.rootTreeProof); - // const parsedStoreTreeProof = parseStoreTreeProof(identitiesProofBuffer); - // - // const identitiesFromProof = parsedStoreTreeProof.values; - // - // const valueIds = identitiesFromProof.map((identityValue) => dashClient.platform.dpp - // .identity.createFromBuffer(identityValue).getId().toString('hex')); - // - // // The proof will contain left and right values to the empty place - // expect(valueIds.indexOf(fakeIdentityId.toString('hex'))).to.be.equal(-1); - // - // const { rootHash: identityLeafRoot } = executeProof(identitiesProofBuffer); - // - // const identityIdsToProve = [fakeIdentityId]; - // - // const verificationResult = verifyProof( - // identitiesProofBuffer, - // identityIdsToProve, - // identityLeafRoot, - // ); - // - // // We pass one key - // expect(verificationResult.length).to.be.equal(1); - // // Identity with id at index 0 doesn't exist - // expect(verificationResult[0]).to.be.null(); }); // eslint-disable-next max-len @@ -248,116 +134,6 @@ describe('Platform', () => { const fullProof = identityProof.proof; testProofStructure(expect, fullProof); - - // const identitiesProofBuffer = fullProof.storeTreeProofs.getIdentitiesProof(); - // const publicKeyHashesProofBuffer = fullProof.storeTreeProofs - // .getPublicKeyHashesToIdentityIdsProof(); - // - // /* Parsing values from the proof */ - // - // const parsedIdentitiesStoreTreeProof = parseStoreTreeProof(identitiesProofBuffer); - // - // // Existing identities should be in the identitiesProof, as it also serves - // // as an inclusion proof - // const restoredIdentities = parsedIdentitiesStoreTreeProof.values.map( - // (identityBuffer) => dashClient.platform.dpp.identity.createFromBuffer( - // identityBuffer, - // ), - // ); - // - // /* Figuring out what was found */ - // - // const foundIdentityIds = []; - // const notFoundPublicKeyHashes = []; - // - // // Scanning through public keys to figure out what identities were found - // for (const publicKeyHash of publicKeyHashes) { - // const foundIdentity = restoredIdentities - // .find( - // (restoredIdentity) => restoredIdentity.getPublicKeyById(0) - // .hash().toString('hex') === publicKeyHash.toString('hex'), - // ); - // if (foundIdentity) { - // foundIdentityIds.push(foundIdentity.getId()); - // } else { - // notFoundPublicKeyHashes.push(publicKeyHash); - // } - // } - // - // // We expect to find 2 identities out of 3 keys - // expect(foundIdentityIds.length).to.be.equal(2); - // expect(notFoundPublicKeyHashes.length).to.be.equal(1); - // - // // Note that identities in the proof won't necessary preserve the order in which they - // // were requested. This happens due to the proof structure: sorting values in the - // // proof would result in a different root hash. - // expect(foundIdentityIds.findIndex( - // (identityId) => identityId.toString('hex') === - // identityAtKey6.getId().toString('hex'), - // )).to.be.greaterThan(-1); - // expect(foundIdentityIds.findIndex( - // (identityId) => identityId.toString('hex') === - // identityAtKey8.getId().toString('hex'), - // )).to.be.greaterThan(-1); - // - // expect(notFoundPublicKeyHashes[0]).to.be.deep.equal(nonIncludedIdentityPubKeyHash); - // - // // Non-existing public key hash should be included into the identityIdsProof, - // // as it serves as a non-inclusion proof for the public keys - // - // /* Extracting root */ - // - // // While extracting the root isn't specifically useful for this test, - // // it is needed to fit those roots into the root tree later. - // const { rootHash: identityLeafRoot } = executeProof(identitiesProofBuffer); - // const { rootHash: identityIdsLeafRoot } = executeProof(publicKeyHashesProofBuffer); - // - // /* Inclusion proof */ - // - // // Note that you first has to parse values from the - // // proof and find identity ids you were looking for - // const inclusionVerificationResult = verifyProof( - // identitiesProofBuffer, - // foundIdentityIds, - // identityLeafRoot, - // ); - // - // expect(inclusionVerificationResult.length).to.be.equal(2); - // - // const firstRecoveredIdentityBuffer = inclusionVerificationResult[0]; - // const secondRecoveredIdentityBuffer = inclusionVerificationResult[1]; - // expect(firstRecoveredIdentityBuffer).to.be.an.instanceof(Uint8Array); - // expect(secondRecoveredIdentityBuffer).to.be.an.instanceof(Uint8Array); - // - // const firstRecoveredIdentity = dashClient.platform.dpp - // .identity.createFromBuffer(firstRecoveredIdentityBuffer); - // - // const secondRecoveredIdentity = dashClient.platform.dpp - // .identity.createFromBuffer(secondRecoveredIdentityBuffer); - // - // // Deep equal won't work in this case, because identity returned by the register - // const actualIdentityAtKey6 = identityAtKey6.toObject(); - // const actualIdentityAtKey8 = identityAtKey8.toObject(); - // // Because the actual identity state is before the registration, and the - // // balance wasn't added to it yet - // actualIdentityAtKey6.balance = firstRecoveredIdentity.toObject().balance; - // actualIdentityAtKey8.balance = secondRecoveredIdentity.toObject().balance; - // - // expect(firstRecoveredIdentity.toObject()).to.be.deep.equal(actualIdentityAtKey6); - // expect(secondRecoveredIdentity.toObject()).to.be.deep.equal(actualIdentityAtKey8); - // - // /* Non-inclusion proof */ - // - // const nonInclusionVerificationResult = verifyProof( - // publicKeyHashesProofBuffer, - // notFoundPublicKeyHashes, - // identityIdsLeafRoot, - // ); - // - // expect(nonInclusionVerificationResult.length).to.be.equal(1); - // - // const nonIncludedIdentityId = nonInclusionVerificationResult[0]; - // expect(nonIncludedIdentityId).to.be.null(); }); }); }); @@ -367,20 +143,6 @@ describe('Platform', () => { it('should be correct for all endpoints', async () => { // This test requests all endpoints instead of having multiple test for each endpoint // on purpose. - // - // The reason being is that when verifying merkle proof, you usually need some value to - // compare it to, and platform doesn't provide one. There are two ways to verify that - // the root tree proof is working: either by knowing its root in advance, or by - // verifying it's signature that is also included in the response. - // Verifying signature requires verifying the header chain, which is not - // currently implemented in the JS SDK (Although it is implemented in Java and iOS SDK). - // So we left with only one option: to know the proof in advance. - // Platform doesn't give it directly, but we can reconstruct it from - // store tree leaves. This if fine in this case because this test doesn't test - // store tree proofs (every endpoint has its own separate store tree proof test). - // By making requests to all endpoints we can recover all leaves hashes, and construct - // the original root tree from it. Then we can get the root from that tree and use it - // as a reference root when verifying the root tree proof. const dapiClient = await dashClient.getDAPIClient(); const identityId = Identifier.from(dpnsOwnerId); diff --git a/packages/platform-test-suite/test/functional/platform/waitForStateTransitionResult.spec.js b/packages/platform-test-suite/test/functional/platform/waitForStateTransitionResult.spec.js index 16452cdca1b..94b0d35ddb1 100644 --- a/packages/platform-test-suite/test/functional/platform/waitForStateTransitionResult.spec.js +++ b/packages/platform-test-suite/test/functional/platform/waitForStateTransitionResult.spec.js @@ -1,10 +1,10 @@ -const crypto = require('crypto'); +import crypto from 'crypto'; -const { MerkleProof } = require('js-merkle'); +import { MerkleProof } from 'js-merkle'; -const createClientWithFundedWallet = require('../../../lib/test/createClientWithFundedWallet'); +import createClientWithFundedWallet from '../../../lib/test/createClientWithFundedWallet.js'; -const parseStoreTreeProof = require('../../../lib/parseStoreTreeProof'); +import parseStoreTreeProof from '../../../lib/parseStoreTreeProof.js'; // TODO: Fix test to be running in Browser diff --git a/packages/wallet-lib/fixtures/DummyWorker.js b/packages/wallet-lib/fixtures/DummyWorker.js index e5c4c054892..21397e49a50 100644 --- a/packages/wallet-lib/fixtures/DummyWorker.js +++ b/packages/wallet-lib/fixtures/DummyWorker.js @@ -1,4 +1,4 @@ -const Worker = require('../src/plugins/Worker'); +import Worker from '../src/plugins/Worker.js'; class DummyWorker extends Worker { constructor() { @@ -15,4 +15,4 @@ class DummyWorker extends Worker { console.log('Dummy worker successfully did nothing'); } } -module.exports = DummyWorker; +export default DummyWorker; diff --git a/packages/wallet-lib/fixtures/plugins/FaultyWorker.js b/packages/wallet-lib/fixtures/plugins/FaultyWorker.js index 1a65f0db92f..f32cbfc333f 100644 --- a/packages/wallet-lib/fixtures/plugins/FaultyWorker.js +++ b/packages/wallet-lib/fixtures/plugins/FaultyWorker.js @@ -1,4 +1,4 @@ -const Worker = require('../../src/plugins/Worker'); +import Worker from '../../src/plugins/Worker.js'; class FaultyWorker extends Worker { constructor() { @@ -19,4 +19,4 @@ class FaultyWorker extends Worker { } } -module.exports = FaultyWorker; +export default FaultyWorker; diff --git a/packages/wallet-lib/fixtures/plugins/WorkingWorker.js b/packages/wallet-lib/fixtures/plugins/WorkingWorker.js index 80d52494a1d..7d25f89599b 100644 --- a/packages/wallet-lib/fixtures/plugins/WorkingWorker.js +++ b/packages/wallet-lib/fixtures/plugins/WorkingWorker.js @@ -1,4 +1,4 @@ -const Worker = require('../../src/plugins/Worker'); +import Worker from '../../src/plugins/Worker.js'; class WorkingWorker extends Worker { constructor() { @@ -22,4 +22,4 @@ class WorkingWorker extends Worker { storage.workingWorkerPass += 1; } } -module.exports = WorkingWorker; +export default WorkingWorker; diff --git a/packages/wallet-lib/fixtures/strategies/craftedGenerousMinerStrategy.js b/packages/wallet-lib/fixtures/strategies/craftedGenerousMinerStrategy.js index e7823cdaa8a..0b9df25a230 100644 --- a/packages/wallet-lib/fixtures/strategies/craftedGenerousMinerStrategy.js +++ b/packages/wallet-lib/fixtures/strategies/craftedGenerousMinerStrategy.js @@ -1,7 +1,7 @@ -const TransactionEstimator = require('../../src/utils/coinSelections/TransactionEstimator.js'); -const { sortAndVerifyUTXOS } = require('../../src/utils/coinSelections/helpers'); +import TransactionEstimator from '../../src/utils/coinSelections/TransactionEstimator.js'; +import { sortAndVerifyUTXOS } from '../../src/utils/coinSelections/helpers/index.js'; -module.exports = function craftedGenerousMinerStrategy(utxosList, outputsList, deductFee = false, feeCategory = 'normal') { +export default function craftedGenerousMinerStrategy(utxosList, outputsList, deductFee = false, feeCategory = 'normal') { const txEstimator = new TransactionEstimator(feeCategory); // We add our outputs, theses will change only in case deductfee being true @@ -48,4 +48,4 @@ module.exports = function craftedGenerousMinerStrategy(utxosList, outputsList, d estimatedFee, utxosValue: txEstimator.getInValue(), }; -}; +} diff --git a/packages/wallet-lib/fixtures/wallets/2a331817b9d6bf85100ef0/getFixtureAccountWithStorage.js b/packages/wallet-lib/fixtures/wallets/2a331817b9d6bf85100ef0/getFixtureAccountWithStorage.js index 89579f3c9e4..68b9dc4ea01 100644 --- a/packages/wallet-lib/fixtures/wallets/2a331817b9d6bf85100ef0/getFixtureAccountWithStorage.js +++ b/packages/wallet-lib/fixtures/wallets/2a331817b9d6bf85100ef0/getFixtureAccountWithStorage.js @@ -1,13 +1,13 @@ -const walletStoreMock = require('./wallet-store.json'); -const chainStoreMock = require('./chain-store.json'); -const Storage = require('../../../src/types/Storage/Storage'); -const { KeyChainStore, DerivableKeyChain } = require('../../../src/index'); -const createPathsForTransactions = require("../../../src/types/Account/methods/createPathsForTransactions"); -const addPathsToStore = require("../../../src/types/Account/methods/addPathsToStore"); -const generateNewPaths = require("../../../src/types/Account/methods/generateNewPaths"); -const addDefaultPaths = require("../../../src/types/Account/methods/addDefaultPaths"); +import walletStoreMock from './wallet-store.json' with { type: 'json' }; +import chainStoreMock from './chain-store.json' with { type: 'json' }; +import Storage from '../../../src/types/Storage/Storage.js'; +import { KeyChainStore, DerivableKeyChain } from '../../../src/index.js'; +import createPathsForTransactions from '../../../src/types/Account/methods/createPathsForTransactions.js'; +import addPathsToStore from '../../../src/types/Account/methods/addPathsToStore.js'; +import generateNewPaths from '../../../src/types/Account/methods/generateNewPaths.js'; +import addDefaultPaths from '../../../src/types/Account/methods/addDefaultPaths.js'; -module.exports = (opts = {}) => { +export default (opts = {}) => { const { walletId } = walletStoreMock; const mockedAccount = { diff --git a/packages/wallet-lib/fixtures/wallets/apart-trip-dignity/categorizeTransactions.expectedResults.js b/packages/wallet-lib/fixtures/wallets/apart-trip-dignity/categorizeTransactions.expectedResults.js index 10e736a112f..8ba3e41f564 100644 --- a/packages/wallet-lib/fixtures/wallets/apart-trip-dignity/categorizeTransactions.expectedResults.js +++ b/packages/wallet-lib/fixtures/wallets/apart-trip-dignity/categorizeTransactions.expectedResults.js @@ -1,4 +1,4 @@ -const transactionsWithMetadataFixtures = require("./transactions-with-metadata.json"); +import transactionsWithMetadataFixtures from './transactions-with-metadata.json' with { type: 'json' }; const expectedResultTx1 = { from: [ {address: 'ygrRyPRf9vSHnP1ieoRRvY9THtFbTMc66e', addressType: "unknown"}, @@ -291,7 +291,7 @@ const expectedResultTx11 = { feeImpact: 394 }; -module.exports = [ +export default [ expectedResultTx1, expectedResultTx2, expectedResultTx3, diff --git a/packages/wallet-lib/fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage.js b/packages/wallet-lib/fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage.js index f5568b19bb8..dc88ce5db37 100644 --- a/packages/wallet-lib/fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage.js +++ b/packages/wallet-lib/fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage.js @@ -1,13 +1,13 @@ -const walletStoreMock = require('./wallet-store.json'); -const chainStoreMock = require('./chain-store.json'); -const Storage = require('../../../src/types/Storage/Storage'); -const { KeyChainStore, DerivableKeyChain } = require('../../../src/index'); -const createPathsForTransactions = require('../../../src/types/Account/methods/createPathsForTransactions'); -const addPathsToStore = require("../../../src/types/Account/methods/addPathsToStore"); -const generateNewPaths = require("../../../src/types/Account/methods/generateNewPaths"); -const addDefaultPaths = require("../../../src/types/Account/methods/addDefaultPaths"); +import walletStoreMock from './wallet-store.json' with { type: 'json' }; +import chainStoreMock from './chain-store.json' with { type: 'json' }; +import Storage from '../../../src/types/Storage/Storage.js'; +import { KeyChainStore, DerivableKeyChain } from '../../../src/index.js'; +import createPathsForTransactions from '../../../src/types/Account/methods/createPathsForTransactions.js'; +import addPathsToStore from '../../../src/types/Account/methods/addPathsToStore.js'; +import generateNewPaths from '../../../src/types/Account/methods/generateNewPaths.js'; +import addDefaultPaths from '../../../src/types/Account/methods/addDefaultPaths.js'; -module.exports = (opts = {}) => { +export default (opts = {}) => { const { walletId } = walletStoreMock; const mockedWallet = { diff --git a/packages/wallet-lib/karma/karma.conf.js b/packages/wallet-lib/karma/karma.conf.js deleted file mode 100644 index 0a2ac6fdcfb..00000000000 --- a/packages/wallet-lib/karma/karma.conf.js +++ /dev/null @@ -1,14 +0,0 @@ -const options = require('./options'); - -module.exports = (config) => { - config.set({ - ...options, - files: [ - '../src/test/karma/loader.js', - ], - preprocessors: { - '../src/test/karma/loader.js': ['webpack', 'sourcemap'], - }, - logLevel: config.LOG_INFO, - }); -}; diff --git a/packages/wallet-lib/karma/karma.functional.conf.js b/packages/wallet-lib/karma/karma.functional.conf.js deleted file mode 100644 index 1756c0010e3..00000000000 --- a/packages/wallet-lib/karma/karma.functional.conf.js +++ /dev/null @@ -1,14 +0,0 @@ -const options = require('./options'); - -module.exports = (config) => { - config.set({ - ...options, - logLevel: config.LOG_INFO, - files: [ - '../tests/functional/**.spec.js', - ], - preprocessors: { - '../tests/functional/**.spec.js': ['webpack', 'sourcemap'], - }, - }); -}; diff --git a/packages/wallet-lib/karma/options.js b/packages/wallet-lib/karma/options.js deleted file mode 100644 index f772d0a099d..00000000000 --- a/packages/wallet-lib/karma/options.js +++ /dev/null @@ -1,66 +0,0 @@ -/* eslint-disable import-x/no-extraneous-dependencies */ -const webpack = require('webpack'); -const dotenvSafe = require('dotenv-safe'); - -const karmaMocha = require('karma-mocha'); -const karmaMochaReporter = require('karma-mocha-reporter'); -const karmaChai = require('karma-chai'); -const karmaChromeLauncher = require('karma-chrome-launcher'); -const karmaFirefoxLauncher = require('karma-firefox-launcher'); -const karmaSourcemapLoader = require('karma-sourcemap-loader'); -const karmaWebpack = require('karma-webpack'); - -const webpackConfig = require('../webpack.config'); - -let env = {}; -if (process.env.LOAD_ENV) { - const dotenvResult = dotenvSafe.config(); - if (dotenvResult.error) { - throw dotenvResult.error; - } - env = dotenvResult.parsed; -} - -module.exports = { - client: { - mocha: { - bail: true, - }, - }, - frameworks: ['mocha', 'chai', 'webpack'], - webpack: { - mode: 'development', - devtool: 'inline-source-map', - plugins: [ - ...webpackConfig.plugins, - new webpack.EnvironmentPlugin( - env, - ), - ], - resolve: webpackConfig.resolve, - }, - reporters: ['mocha'], - port: 9876, - colors: true, - autoWatch: false, - browsers: ['ChromeHeadlessInsecure'], - singleRun: false, - concurrency: Infinity, - browserNoActivityTimeout: 10 * 60 * 1000, - plugins: [ - karmaMocha, - karmaMochaReporter, - karmaChai, - karmaChromeLauncher, - karmaFirefoxLauncher, - karmaSourcemapLoader, - karmaWebpack, - ], - customLaunchers: { - ChromeHeadlessInsecure: { - base: 'ChromeHeadless', - flags: ['--allow-insecure-localhost'], - displayName: 'Chrome w/o security', - }, - }, -}; diff --git a/packages/wallet-lib/package.json b/packages/wallet-lib/package.json index cf06fef775b..65a1379d0e8 100644 --- a/packages/wallet-lib/package.json +++ b/packages/wallet-lib/package.json @@ -2,21 +2,24 @@ "name": "@dashevo/wallet-lib", "version": "10.1.0-dev.1", "description": "Light wallet library for Dash", + "type": "module", "main": "src/index.js", - "unpkg": "dist/wallet-lib.min.js", "types": "src/index.d.ts", + "exports": { + ".": "./src/index.js", + "./src/*": "./src/*" + }, + "engines": { + "node": ">=18.18" + }, "scripts": { - "build:web": "webpack --stats-error-details", "lint": "eslint .", "lint:fix": "eslint . --fix", "test:unit": "nyc yarn mocha 'src/**/*.spec.js'", "test:functional": "LOAD_ENV=true nyc yarn run mocha 'tests/functional/*.js'", "test:integration": "nyc yarn run mocha 'tests/integration/**/*.spec.js'", - "test:browsers": "karma start ./karma/karma.conf.js --single-run", - "test:browsers:functional": "LOAD_ENV=true karma start ./karma/karma.functional.conf.js --single-run", "test:types": "yarn pnpify tsd", - "test": "yarn run test:types && yarn run test:unit && yarn run test:integration && yarn run test:browsers", - "prepublishOnly": "yarn run build:web" + "test": "yarn run test:types && yarn run test:unit && yarn run test:integration" }, "ultra": { "concurrent": [ @@ -24,7 +27,6 @@ ] }, "files": [ - "dist", "docs", "examples", "src" @@ -53,47 +55,21 @@ "cbor": "^8.0.0", "crypto-js": "^4.2.0", "lodash": "^4.17.23", - "pbkdf2": "^3.1.3", - "setimmediate": "^1.0.5", - "winston": "^3.2.1" + "pbkdf2": "^3.1.3" }, "devDependencies": { "@dashevo/dash-spv": "workspace:*", - "assert": "^2.0.0", - "browserify-zlib": "^0.2.0", - "buffer": "^6.0.3", "chai": "^4.3.10", "chai-as-promised": "^7.1.1", - "crypto-browserify": "^3.12.1", "dirty-chai": "^2.0.1", "dotenv-safe": "^8.2.0", "eslint": "^9.18.0", "events": "^3.3.0", - "https-browserify": "^1.0.0", - "karma": "^6.4.3", - "karma-chai": "^0.1.0", - "karma-chrome-launcher": "^3.1.0", - "karma-firefox-launcher": "^2.1.2", - "karma-mocha": "^2.0.1", - "karma-mocha-reporter": "^2.2.5", - "karma-sourcemap-loader": "^0.3.7", - "karma-webpack": "^5.0.0", "mocha": "^11.1.0", - "node-inspect-extracted": "^1.0.8", "nyc": "^15.1.0", - "os-browserify": "^0.3.0", - "path-browserify": "^1.0.1", - "process": "^0.11.10", "sinon": "^18.0.1", "sinon-chai": "^3.7.0", - "stream-browserify": "^3.0.0", - "stream-http": "^3.2.0", - "string_decoder": "^1.3.0", "tsd": "^0.28.1", - "url": "^0.11.3", - "util": "^0.12.4", - "wasm-x11-hash": "~0.0.2", - "webpack": "^5.104.0", - "webpack-cli": "^4.9.1" + "wasm-x11-hash": "~0.0.2" } } diff --git a/packages/wallet-lib/src/CONSTANTS.js b/packages/wallet-lib/src/CONSTANTS.js index a367f1269cf..4af46546561 100644 --- a/packages/wallet-lib/src/CONSTANTS.js +++ b/packages/wallet-lib/src/CONSTANTS.js @@ -115,4 +115,39 @@ const CONSTANTS = { BLOOM_FALSE_POSITIVE_RATE: 0.0001, NULL_HASH: '0000000000000000000000000000000000000000000000000000000000000000', }; -module.exports = CONSTANTS; +export const { + BIP45, + BIP44, + DUFFS_PER_DASH, + BIP44_ADDRESS_GAP, + SECURE_TRANSACTION_CONFIRMATIONS_NB, + BIP32__ROOT_PATH, + BIP44_LIVENET_ROOT_PATH, + BIP44_TESTNET_ROOT_PATH, + DIP9_LIVENET_ROOT_PATH, + DIP9_TESTNET_ROOT_PATH, + UTXO_SELECTION_MAX_SINGLE_UTXO_FACTOR, + UTXO_SELECTION_MIN_TX_AMOUNT_VS_UTXO_FACTOR, + UTXO_SELECTION_MAX_FEE_VS_TX_AMOUNT_FACTOR, + UTXO_SELECTION_MAX_FEE_VS_SINGLE_UTXO_FEE_FACTOR, + MAX_STANDARD_TX_SIZE, + MAX_P2SH_SIGOPS, + COINBASE_MATURITY, + UTXO_CHAINED_SPENDING_LIMIT_FOR_TX, + FEES, + UNCONFIRMED_TRANSACTION_STATUS_CODE, + WALLET_TYPES, + INJECTION_LISTS, + TRANSACTION_HISTORY_TYPES, + STORAGE, + TXIN_OUTPOINT_TXID_BYTES, + TXIN_OUTPOINT_INDEX_BYTES, + TXIN_SEQUENCE_BYTES, + TXOUT_DUFFS_VALUE_BYTES, + VERSION_BYTES, + N_LOCKTIME_BYTES, + BLOOM_FALSE_POSITIVE_RATE, + NULL_HASH, +} = CONSTANTS; + +export default CONSTANTS; \ No newline at end of file diff --git a/packages/wallet-lib/src/EVENTS.js b/packages/wallet-lib/src/EVENTS.js index 804bcf44e6e..a8be052f07f 100644 --- a/packages/wallet-lib/src/EVENTS.js +++ b/packages/wallet-lib/src/EVENTS.js @@ -1,30 +1,59 @@ -module.exports = { - PREFETCHED: 'prefetched', - CREATED: 'created', - STARTED: 'started', - READY: 'ready', - CONFIRMED_BALANCE_CHANGED: 'confirmed_balance_changed', - UNCONFIRMED_BALANCE_CHANGED: 'unconfirmed_balance_changed', - BLOCKHEIGHT_CHANGED: 'blockheight_changed', - BLOCK: 'block', - TRANSACTION: 'transaction', - BLOCKHEADER: 'blockheader', - FETCHED_ADDRESS: 'FETCHED/ADDRESS', - ERROR_UPDATE_ADDRESS: 'ERROR/UPDATE_ADDRESS', - FETCHED_TRANSACTION: 'FETCHED/TRANSACTION', - FETCHED_UNCONFIRMED_TRANSACTION: 'FETCHED/UNCONFIRMED_TRANSACTION', - FETCHED_CONFIRMED_TRANSACTION: 'FETCHED/CONFIRMED_TRANSACTION', - CONFIRMED_TRANSACTION: 'CONFIRMED_TRANSACTION', - GENERATED_ADDRESS: 'GENERATED_ADDRESS', - DISCOVERY_STARTED: 'DISCOVERY_STARTED', - CONFIGURED: 'CONFIGURED', - INITIALIZED: 'INITIALIZED', - SAVE_STATE_FAILED: 'SAVE_STATE_FAILED', - SAVE_STATE_SUCCESS: 'SAVE_STATE_SUCCESS', - REHYDRATE_STATE_FAILED: 'REHYDRATE_STATE_FAILED', - REHYDRATE_STATE_SUCCESS: 'REHYDRATE_STATE_SUCCESS', - INSTANT_LOCK: 'INSTANT_LOCK', - TX_METADATA: 'TX_METADATA', - HEADERS_SYNC_PROGRESS: 'HEADERS_SYNC_PROGRESS', - TRANSACTIONS_SYNC_PROGRESS: 'TRANSACTIONS_SYNC_PROGRESS', +export const PREFETCHED = 'prefetched'; +export const CREATED = 'created'; +export const STARTED = 'started'; +export const READY = 'ready'; +export const CONFIRMED_BALANCE_CHANGED = 'confirmed_balance_changed'; +export const UNCONFIRMED_BALANCE_CHANGED = 'unconfirmed_balance_changed'; +export const BLOCKHEIGHT_CHANGED = 'blockheight_changed'; +export const BLOCK = 'block'; +export const TRANSACTION = 'transaction'; +export const BLOCKHEADER = 'blockheader'; +export const FETCHED_ADDRESS = 'FETCHED/ADDRESS'; +export const ERROR_UPDATE_ADDRESS = 'ERROR/UPDATE_ADDRESS'; +export const FETCHED_TRANSACTION = 'FETCHED/TRANSACTION'; +export const FETCHED_UNCONFIRMED_TRANSACTION = 'FETCHED/UNCONFIRMED_TRANSACTION'; +export const FETCHED_CONFIRMED_TRANSACTION = 'FETCHED/CONFIRMED_TRANSACTION'; +export const CONFIRMED_TRANSACTION = 'CONFIRMED_TRANSACTION'; +export const GENERATED_ADDRESS = 'GENERATED_ADDRESS'; +export const DISCOVERY_STARTED = 'DISCOVERY_STARTED'; +export const CONFIGURED = 'CONFIGURED'; +export const INITIALIZED = 'INITIALIZED'; +export const SAVE_STATE_FAILED = 'SAVE_STATE_FAILED'; +export const SAVE_STATE_SUCCESS = 'SAVE_STATE_SUCCESS'; +export const REHYDRATE_STATE_FAILED = 'REHYDRATE_STATE_FAILED'; +export const REHYDRATE_STATE_SUCCESS = 'REHYDRATE_STATE_SUCCESS'; +export const INSTANT_LOCK = 'INSTANT_LOCK'; +export const TX_METADATA = 'TX_METADATA'; +export const HEADERS_SYNC_PROGRESS = 'HEADERS_SYNC_PROGRESS'; +export const TRANSACTIONS_SYNC_PROGRESS = 'TRANSACTIONS_SYNC_PROGRESS'; + +export default { + PREFETCHED, + CREATED, + STARTED, + READY, + CONFIRMED_BALANCE_CHANGED, + UNCONFIRMED_BALANCE_CHANGED, + BLOCKHEIGHT_CHANGED, + BLOCK, + TRANSACTION, + BLOCKHEADER, + FETCHED_ADDRESS, + ERROR_UPDATE_ADDRESS, + FETCHED_TRANSACTION, + FETCHED_UNCONFIRMED_TRANSACTION, + FETCHED_CONFIRMED_TRANSACTION, + CONFIRMED_TRANSACTION, + GENERATED_ADDRESS, + DISCOVERY_STARTED, + CONFIGURED, + INITIALIZED, + SAVE_STATE_FAILED, + SAVE_STATE_SUCCESS, + REHYDRATE_STATE_FAILED, + REHYDRATE_STATE_SUCCESS, + INSTANT_LOCK, + TX_METADATA, + HEADERS_SYNC_PROGRESS, + TRANSACTIONS_SYNC_PROGRESS, }; diff --git a/packages/wallet-lib/src/adapters/InMem.js b/packages/wallet-lib/src/adapters/InMem.js index f17cb5606ae..5e79e56ba1b 100644 --- a/packages/wallet-lib/src/adapters/InMem.js +++ b/packages/wallet-lib/src/adapters/InMem.js @@ -17,4 +17,4 @@ class InMem { return this.keys[key] || null; } } -module.exports = InMem; +export default InMem; \ No newline at end of file diff --git a/packages/wallet-lib/src/adapters/inMem.spec.js b/packages/wallet-lib/src/adapters/inMem.spec.js index 122a74421bb..a2a96487839 100644 --- a/packages/wallet-lib/src/adapters/inMem.spec.js +++ b/packages/wallet-lib/src/adapters/inMem.spec.js @@ -1,5 +1,5 @@ -const { expect } = require('chai'); -const InMem = require('./InMem'); +import { expect } from 'chai'; +import InMem from './InMem.js'; const inMem = new InMem(); diff --git a/packages/wallet-lib/src/errors/BlockHeaderNotInStore.js b/packages/wallet-lib/src/errors/BlockHeaderNotInStore.js index 182fe8e767b..8dd177891b9 100644 --- a/packages/wallet-lib/src/errors/BlockHeaderNotInStore.js +++ b/packages/wallet-lib/src/errors/BlockHeaderNotInStore.js @@ -1,8 +1,8 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class BlockHeaderNotInStore extends WalletLibError { constructor(identifier) { super(`Blockheader is not in store: ${identifier}`); } } -module.exports = BlockHeaderNotInStore; +export default BlockHeaderNotInStore; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/CoinSelectionUnsufficientUTXOS.js b/packages/wallet-lib/src/errors/CoinSelectionUnsufficientUTXOS.js index df5f0c91f6a..c06dda03896 100644 --- a/packages/wallet-lib/src/errors/CoinSelectionUnsufficientUTXOS.js +++ b/packages/wallet-lib/src/errors/CoinSelectionUnsufficientUTXOS.js @@ -1,4 +1,4 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class CoinSelectionUnsufficientUTXOS extends WalletLibError { constructor(info) { @@ -10,4 +10,4 @@ class CoinSelectionUnsufficientUTXOS extends WalletLibError { super(getErrorMessageOf(info)); } } -module.exports = CoinSelectionUnsufficientUTXOS; +export default CoinSelectionUnsufficientUTXOS; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/CreateTransactionError.js b/packages/wallet-lib/src/errors/CreateTransactionError.js index 8eef2c63a7f..d030e910be2 100644 --- a/packages/wallet-lib/src/errors/CreateTransactionError.js +++ b/packages/wallet-lib/src/errors/CreateTransactionError.js @@ -1,5 +1,5 @@ -const WalletLibError = require('./WalletLibError'); -const CoinSelectionUnsufficientUTXOS = require('./CoinSelectionUnsufficientUTXOS'); +import WalletLibError from './WalletLibError.js'; +import CoinSelectionUnsufficientUTXOS from './CoinSelectionUnsufficientUTXOS.js'; class CreateTransactionError extends WalletLibError { constructor(e) { @@ -10,4 +10,4 @@ class CreateTransactionError extends WalletLibError { } } } -module.exports = CreateTransactionError; +export default CreateTransactionError; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/IndentityIdReplaceError.js b/packages/wallet-lib/src/errors/IndentityIdReplaceError.js index 82bfce3bb0b..af4b1bfef55 100644 --- a/packages/wallet-lib/src/errors/IndentityIdReplaceError.js +++ b/packages/wallet-lib/src/errors/IndentityIdReplaceError.js @@ -1,6 +1,6 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class IdentityIdReplaceError extends WalletLibError { } -module.exports = IdentityIdReplaceError; +export default IdentityIdReplaceError; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/InjectionErrorCannotInject.js b/packages/wallet-lib/src/errors/InjectionErrorCannotInject.js index 26ad1077ada..320984376f2 100644 --- a/packages/wallet-lib/src/errors/InjectionErrorCannotInject.js +++ b/packages/wallet-lib/src/errors/InjectionErrorCannotInject.js @@ -1,4 +1,4 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class InjectionErrorCannotInject extends WalletLibError { constructor(pluginName, reason) { @@ -9,4 +9,4 @@ class InjectionErrorCannotInject extends WalletLibError { } } -module.exports = InjectionErrorCannotInject; +export default InjectionErrorCannotInject; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/InjectionErrorCannotInjectUnknownDependency.js b/packages/wallet-lib/src/errors/InjectionErrorCannotInjectUnknownDependency.js index 203c5a43869..0b5e89b4610 100644 --- a/packages/wallet-lib/src/errors/InjectionErrorCannotInjectUnknownDependency.js +++ b/packages/wallet-lib/src/errors/InjectionErrorCannotInjectUnknownDependency.js @@ -1,4 +1,4 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class InjectionErrorCannotInjectUnknownDependency extends WalletLibError { constructor(pluginName, dependencyName) { @@ -9,4 +9,4 @@ class InjectionErrorCannotInjectUnknownDependency extends WalletLibError { } } -module.exports = InjectionErrorCannotInjectUnknownDependency; +export default InjectionErrorCannotInjectUnknownDependency; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/InjectionToPluginUnallowed.js b/packages/wallet-lib/src/errors/InjectionToPluginUnallowed.js index 6d6767f0d32..7b1f0bd9ed3 100644 --- a/packages/wallet-lib/src/errors/InjectionToPluginUnallowed.js +++ b/packages/wallet-lib/src/errors/InjectionToPluginUnallowed.js @@ -1,4 +1,4 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class InjectionToPluginUnallowed extends WalletLibError { constructor(currentPluginName, injectingPluginName) { @@ -6,4 +6,4 @@ class InjectionToPluginUnallowed extends WalletLibError { } } -module.exports = InjectionToPluginUnallowed; +export default InjectionToPluginUnallowed; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/InstantLockTimeoutError.js b/packages/wallet-lib/src/errors/InstantLockTimeoutError.js index a2f69ee6959..59046cd0bdd 100644 --- a/packages/wallet-lib/src/errors/InstantLockTimeoutError.js +++ b/packages/wallet-lib/src/errors/InstantLockTimeoutError.js @@ -1,4 +1,4 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class InstantLockTimeoutError extends WalletLibError { /** @@ -9,4 +9,4 @@ class InstantLockTimeoutError extends WalletLibError { } } -module.exports = InstantLockTimeoutError; +export default InstantLockTimeoutError; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/InvalidAddress.js b/packages/wallet-lib/src/errors/InvalidAddress.js index fd347b5c936..ac565431101 100644 --- a/packages/wallet-lib/src/errors/InvalidAddress.js +++ b/packages/wallet-lib/src/errors/InvalidAddress.js @@ -1,8 +1,8 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class InvalidAddress extends WalletLibError { constructor(address) { super(`Address Invalid : ${address} `); } } -module.exports = InvalidAddress; +export default InvalidAddress; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/InvalidAddressObject.js b/packages/wallet-lib/src/errors/InvalidAddressObject.js index b073e539493..96544b38538 100644 --- a/packages/wallet-lib/src/errors/InvalidAddressObject.js +++ b/packages/wallet-lib/src/errors/InvalidAddressObject.js @@ -1,5 +1,5 @@ -const is = require('../utils/is'); -const WalletLibError = require('./WalletLibError'); +import is from '../utils/is.js'; +import WalletLibError from './WalletLibError.js'; class InvalidAddressObject extends WalletLibError { constructor(addressObject) { @@ -30,4 +30,4 @@ class InvalidAddressObject extends WalletLibError { super(getErrorMessageOf(evaluateAddressObjectError(addressObject))); } } -module.exports = InvalidAddressObject; +export default InvalidAddressObject; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/InvalidDashcoreTransaction.js b/packages/wallet-lib/src/errors/InvalidDashcoreTransaction.js index 0beca37db34..b8ffa1fe67d 100644 --- a/packages/wallet-lib/src/errors/InvalidDashcoreTransaction.js +++ b/packages/wallet-lib/src/errors/InvalidDashcoreTransaction.js @@ -1,4 +1,4 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class InvalidDashcoreTransaction extends WalletLibError { constructor(tx, reason = 'A Dashcore Transaction object or valid rawTransaction is required') { @@ -6,4 +6,4 @@ class InvalidDashcoreTransaction extends WalletLibError { } } -module.exports = InvalidDashcoreTransaction; +export default InvalidDashcoreTransaction; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/InvalidOutput.js b/packages/wallet-lib/src/errors/InvalidOutput.js index f2ad02425ef..7929b590d2b 100644 --- a/packages/wallet-lib/src/errors/InvalidOutput.js +++ b/packages/wallet-lib/src/errors/InvalidOutput.js @@ -1,7 +1,8 @@ -const { has } = require('lodash'); -const is = require('../utils/is'); +import lodash from 'lodash'; +const { has } = lodash; +import is from '../utils/is.js'; -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class InvalidOutput extends WalletLibError { constructor(output) { @@ -34,4 +35,4 @@ class InvalidOutput extends WalletLibError { super(getErrorMessageOf(evaluateUTXOObjectError(output))); } } -module.exports = InvalidOutput; +export default InvalidOutput; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/InvalidRawTransaction.js b/packages/wallet-lib/src/errors/InvalidRawTransaction.js index 1a9b72f12ba..ec07f549155 100644 --- a/packages/wallet-lib/src/errors/InvalidRawTransaction.js +++ b/packages/wallet-lib/src/errors/InvalidRawTransaction.js @@ -1,4 +1,4 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class InvalidTransaction extends WalletLibError { constructor() { @@ -6,4 +6,4 @@ class InvalidTransaction extends WalletLibError { } } -module.exports = InvalidTransaction; +export default InvalidTransaction; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/InvalidStorageAdapter.js b/packages/wallet-lib/src/errors/InvalidStorageAdapter.js index 4b49480ff6e..960df38c037 100644 --- a/packages/wallet-lib/src/errors/InvalidStorageAdapter.js +++ b/packages/wallet-lib/src/errors/InvalidStorageAdapter.js @@ -1,8 +1,8 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class InvalidStorageAdapter extends WalletLibError { constructor(reason) { super(`Invalid Storage Adapter : ${reason}`); } } -module.exports = InvalidStorageAdapter; +export default InvalidStorageAdapter; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/InvalidStrategy.js b/packages/wallet-lib/src/errors/InvalidStrategy.js index fbffca99740..0fe144103ad 100644 --- a/packages/wallet-lib/src/errors/InvalidStrategy.js +++ b/packages/wallet-lib/src/errors/InvalidStrategy.js @@ -1,4 +1,4 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class InvalidStrategy extends WalletLibError { constructor(arg) { @@ -6,4 +6,4 @@ class InvalidStrategy extends WalletLibError { super(`Unable to import strategy. Expected 'str' or 'fn' got ${type}`); } } -module.exports = InvalidStrategy; +export default InvalidStrategy; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/InvalidTransactionObject.js b/packages/wallet-lib/src/errors/InvalidTransactionObject.js index 7d5ec0c552d..95af32f98f0 100644 --- a/packages/wallet-lib/src/errors/InvalidTransactionObject.js +++ b/packages/wallet-lib/src/errors/InvalidTransactionObject.js @@ -1,7 +1,8 @@ -const { has } = require('lodash'); -const is = require('../utils/is'); +import lodash from 'lodash'; +const { has } = lodash; +import is from '../utils/is.js'; -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class InvalidTransactionObject extends WalletLibError { constructor(transactionObj) { @@ -34,4 +35,4 @@ class InvalidTransactionObject extends WalletLibError { super(getErrorMessageOf(evaluateTransactionObjectError(transactionObj))); } } -module.exports = InvalidTransactionObject; +export default InvalidTransactionObject; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/InvalidUTXO.js b/packages/wallet-lib/src/errors/InvalidUTXO.js index 690d1625fa9..9d7c35919d3 100644 --- a/packages/wallet-lib/src/errors/InvalidUTXO.js +++ b/packages/wallet-lib/src/errors/InvalidUTXO.js @@ -1,4 +1,4 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class InvalidUTXO extends WalletLibError { constructor() { @@ -6,4 +6,4 @@ class InvalidUTXO extends WalletLibError { super(message); } } -module.exports = InvalidUTXO; +export default InvalidUTXO; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/MempoolPropagationTimeoutError.js b/packages/wallet-lib/src/errors/MempoolPropagationTimeoutError.js index 07fb2738cb0..5940a080346 100644 --- a/packages/wallet-lib/src/errors/MempoolPropagationTimeoutError.js +++ b/packages/wallet-lib/src/errors/MempoolPropagationTimeoutError.js @@ -1,4 +1,4 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class MempoolPropagationTimeoutError extends WalletLibError { /** @@ -9,4 +9,4 @@ class MempoolPropagationTimeoutError extends WalletLibError { } } -module.exports = MempoolPropagationTimeoutError; +export default MempoolPropagationTimeoutError; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/PluginFailedOnStart.js b/packages/wallet-lib/src/errors/PluginFailedOnStart.js index 132b9ea802e..455e3cd9f50 100644 --- a/packages/wallet-lib/src/errors/PluginFailedOnStart.js +++ b/packages/wallet-lib/src/errors/PluginFailedOnStart.js @@ -1,4 +1,4 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class PluginFailedOnStart extends WalletLibError { constructor(pluginType, pluginName, error) { @@ -12,4 +12,4 @@ class PluginFailedOnStart extends WalletLibError { } } -module.exports = PluginFailedOnStart; +export default PluginFailedOnStart; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/PluginInjectionError.js b/packages/wallet-lib/src/errors/PluginInjectionError.js index 07f764bdcdb..1c74f2a6748 100644 --- a/packages/wallet-lib/src/errors/PluginInjectionError.js +++ b/packages/wallet-lib/src/errors/PluginInjectionError.js @@ -1,4 +1,4 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class PluginInjectionError extends WalletLibError { constructor(error) { @@ -12,4 +12,4 @@ class PluginInjectionError extends WalletLibError { } } -module.exports = PluginInjectionError; +export default PluginInjectionError; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/StorageUnableToAddTransaction.js b/packages/wallet-lib/src/errors/StorageUnableToAddTransaction.js index 6f1e6056ea7..a512de0f29a 100644 --- a/packages/wallet-lib/src/errors/StorageUnableToAddTransaction.js +++ b/packages/wallet-lib/src/errors/StorageUnableToAddTransaction.js @@ -1,4 +1,4 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class StorageUnableToAddTransaction extends WalletLibError { constructor(tx) { @@ -6,4 +6,4 @@ class StorageUnableToAddTransaction extends WalletLibError { super(getErrorMessageOf(tx)); } } -module.exports = StorageUnableToAddTransaction; +export default StorageUnableToAddTransaction; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/TransactionMetadataNotInStore.js b/packages/wallet-lib/src/errors/TransactionMetadataNotInStore.js index 4a915d480e3..01e9d2715a4 100644 --- a/packages/wallet-lib/src/errors/TransactionMetadataNotInStore.js +++ b/packages/wallet-lib/src/errors/TransactionMetadataNotInStore.js @@ -1,4 +1,4 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class TransactionMetadataNotInStore extends WalletLibError { constructor(txid) { @@ -6,4 +6,4 @@ class TransactionMetadataNotInStore extends WalletLibError { } } -module.exports = TransactionMetadataNotInStore; +export default TransactionMetadataNotInStore; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/TransactionNotInStore.js b/packages/wallet-lib/src/errors/TransactionNotInStore.js index 399ff46672b..8e71bbc3f2c 100644 --- a/packages/wallet-lib/src/errors/TransactionNotInStore.js +++ b/packages/wallet-lib/src/errors/TransactionNotInStore.js @@ -1,4 +1,4 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class TransactionNotInStore extends WalletLibError { constructor(txid) { @@ -6,4 +6,4 @@ class TransactionNotInStore extends WalletLibError { } } -module.exports = TransactionNotInStore; +export default TransactionNotInStore; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/TransporterGenericError.js b/packages/wallet-lib/src/errors/TransporterGenericError.js index 0e169f2aa3b..e99a65bef22 100644 --- a/packages/wallet-lib/src/errors/TransporterGenericError.js +++ b/packages/wallet-lib/src/errors/TransporterGenericError.js @@ -1,8 +1,8 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class TransporterGenericError extends WalletLibError { constructor(act, reason) { super(`Unable to ${act}, reason: ${reason}`); } } -module.exports = TransporterGenericError; +export default TransporterGenericError; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/TxMetadataTimeoutError.js b/packages/wallet-lib/src/errors/TxMetadataTimeoutError.js index 5c99ed4f5fb..0e2cbf2dad8 100644 --- a/packages/wallet-lib/src/errors/TxMetadataTimeoutError.js +++ b/packages/wallet-lib/src/errors/TxMetadataTimeoutError.js @@ -1,4 +1,4 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class TxMetadataTimeoutError extends WalletLibError { /** @@ -9,4 +9,4 @@ class TxMetadataTimeoutError extends WalletLibError { } } -module.exports = TxMetadataTimeoutError; +export default TxMetadataTimeoutError; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/UnknownPlugin.js b/packages/wallet-lib/src/errors/UnknownPlugin.js index 06e61238296..051b5a7c94e 100644 --- a/packages/wallet-lib/src/errors/UnknownPlugin.js +++ b/packages/wallet-lib/src/errors/UnknownPlugin.js @@ -1,4 +1,4 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class UnknownPlugin extends WalletLibError { constructor(pluginName) { @@ -7,4 +7,4 @@ class UnknownPlugin extends WalletLibError { } } -module.exports = UnknownPlugin; +export default UnknownPlugin; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/UnknownStrategy.js b/packages/wallet-lib/src/errors/UnknownStrategy.js index a7f72cba9fa..de66477868f 100644 --- a/packages/wallet-lib/src/errors/UnknownStrategy.js +++ b/packages/wallet-lib/src/errors/UnknownStrategy.js @@ -1,4 +1,4 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class UnknownStrategy extends WalletLibError { constructor(strategyName) { @@ -7,4 +7,4 @@ class UnknownStrategy extends WalletLibError { } } -module.exports = UnknownStrategy; +export default UnknownStrategy; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/UnknownWorker.js b/packages/wallet-lib/src/errors/UnknownWorker.js index c4812474ab5..fc35d70a4bb 100644 --- a/packages/wallet-lib/src/errors/UnknownWorker.js +++ b/packages/wallet-lib/src/errors/UnknownWorker.js @@ -1,4 +1,4 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class UnknownWorker extends WalletLibError { constructor(workerName) { @@ -7,4 +7,4 @@ class UnknownWorker extends WalletLibError { } } -module.exports = UnknownWorker; +export default UnknownWorker; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/ValidTransportLayerRequired.js b/packages/wallet-lib/src/errors/ValidTransportLayerRequired.js index fbfd43c4d0b..44ace3a2d7a 100644 --- a/packages/wallet-lib/src/errors/ValidTransportLayerRequired.js +++ b/packages/wallet-lib/src/errors/ValidTransportLayerRequired.js @@ -1,8 +1,8 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class ValidTransportLayerRequired extends WalletLibError { constructor(method) { super(`A transport layer is needed to perform a ${method}`); } } -module.exports = ValidTransportLayerRequired; +export default ValidTransportLayerRequired; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/WalletLibError.js b/packages/wallet-lib/src/errors/WalletLibError.js index 7ccb3b32bbe..6ea5df6f0dd 100644 --- a/packages/wallet-lib/src/errors/WalletLibError.js +++ b/packages/wallet-lib/src/errors/WalletLibError.js @@ -19,4 +19,4 @@ class WalletLibError extends Error { } } -module.exports = WalletLibError; +export default WalletLibError; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/WorkerFailedOnExecute.js b/packages/wallet-lib/src/errors/WorkerFailedOnExecute.js index b7f4162129d..20d324262ed 100644 --- a/packages/wallet-lib/src/errors/WorkerFailedOnExecute.js +++ b/packages/wallet-lib/src/errors/WorkerFailedOnExecute.js @@ -1,4 +1,4 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class WorkerFailedOnExecute extends WalletLibError { /** @@ -19,4 +19,4 @@ class WorkerFailedOnExecute extends WalletLibError { } } -module.exports = WorkerFailedOnExecute; +export default WorkerFailedOnExecute; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/WorkerFailedOnStart.js b/packages/wallet-lib/src/errors/WorkerFailedOnStart.js index 6585ea9d1a4..153036e1021 100644 --- a/packages/wallet-lib/src/errors/WorkerFailedOnStart.js +++ b/packages/wallet-lib/src/errors/WorkerFailedOnStart.js @@ -1,4 +1,4 @@ -const WalletLibError = require('./WalletLibError'); +import WalletLibError from './WalletLibError.js'; class WorkerFailedOnStart extends WalletLibError { /** @@ -19,4 +19,4 @@ class WorkerFailedOnStart extends WalletLibError { } } -module.exports = WorkerFailedOnStart; +export default WorkerFailedOnStart; \ No newline at end of file diff --git a/packages/wallet-lib/src/errors/index.js b/packages/wallet-lib/src/errors/index.js index e9f7407e248..2acd1de3bfa 100644 --- a/packages/wallet-lib/src/errors/index.js +++ b/packages/wallet-lib/src/errors/index.js @@ -1,39 +1,40 @@ -const CreateTransactionError = require('./CreateTransactionError'); -const CoinSelectionUnsufficientUTXOS = require('./CoinSelectionUnsufficientUTXOS'); -const InjectionErrorCannotInject = require('./InjectionErrorCannotInject'); -const InjectionErrorCannotInjectUnknownDependency = require('./InjectionErrorCannotInjectUnknownDependency'); -const InjectionToPluginUnallowed = require('./InjectionToPluginUnallowed'); +import CreateTransactionError from './CreateTransactionError.js'; +import CoinSelectionUnsufficientUTXOS from './CoinSelectionUnsufficientUTXOS.js'; +import InjectionErrorCannotInject from './InjectionErrorCannotInject.js'; +import InjectionErrorCannotInjectUnknownDependency from './InjectionErrorCannotInjectUnknownDependency.js'; +import InjectionToPluginUnallowed from './InjectionToPluginUnallowed.js'; -const PluginFailedOnStart = require('./PluginFailedOnStart'); -const WorkerFailedOnStart = require('./WorkerFailedOnStart'); -const WorkerFailedOnExecute = require('./WorkerFailedOnExecute'); +import PluginFailedOnStart from './PluginFailedOnStart.js'; +import WorkerFailedOnStart from './WorkerFailedOnStart.js'; +import WorkerFailedOnExecute from './WorkerFailedOnExecute.js'; -const InvalidAddress = require('./InvalidAddress'); -const InvalidAddressObject = require('./InvalidAddressObject'); -const InvalidOutput = require('./InvalidOutput'); -const InvalidDashcoreTransaction = require('./InvalidDashcoreTransaction'); -const InvalidRawTransaction = require('./InvalidRawTransaction'); -const InvalidStrategy = require('./InvalidStrategy'); -const InvalidStorageAdapter = require('./InvalidStorageAdapter'); +import InvalidAddress from './InvalidAddress.js'; +import InvalidAddressObject from './InvalidAddressObject.js'; +import InvalidOutput from './InvalidOutput.js'; +import InvalidDashcoreTransaction from './InvalidDashcoreTransaction.js'; +import InvalidRawTransaction from './InvalidRawTransaction.js'; +import InvalidStrategy from './InvalidStrategy.js'; +import InvalidStorageAdapter from './InvalidStorageAdapter.js'; -const InvalidTransactionObject = require('./InvalidTransactionObject'); -const InvalidUTXO = require('./InvalidUTXO'); -const StorageUnableToAddTransaction = require('./StorageUnableToAddTransaction'); -const TransactionNotInStore = require('./TransactionNotInStore'); -const TransactionMetadataNotInStore = require('./TransactionMetadataNotInStore'); -const BlockHeaderNotInStore = require('./BlockHeaderNotInStore'); +import InvalidTransactionObject from './InvalidTransactionObject.js'; +import InvalidUTXO from './InvalidUTXO.js'; +import StorageUnableToAddTransaction from './StorageUnableToAddTransaction.js'; +import TransactionNotInStore from './TransactionNotInStore.js'; +import TransactionMetadataNotInStore from './TransactionMetadataNotInStore.js'; +import BlockHeaderNotInStore from './BlockHeaderNotInStore.js'; -const UnknownWorker = require('./UnknownWorker'); -const UnknownPlugin = require('./UnknownPlugin'); +import UnknownWorker from './UnknownWorker.js'; +import UnknownPlugin from './UnknownPlugin.js'; +import UnknownStrategy from './UnknownStrategy.js'; -const ValidTransportLayerRequired = require('./ValidTransportLayerRequired'); -const WalletLibError = require('./WalletLibError'); +import ValidTransportLayerRequired from './ValidTransportLayerRequired.js'; +import WalletLibError from './WalletLibError.js'; -const PluginInjectionError = require('./PluginInjectionError'); -const InstantLockTimeoutError = require('./InstantLockTimeoutError'); -const TxMetadataTimeoutError = require('./TxMetadataTimeoutError'); +import PluginInjectionError from './PluginInjectionError.js'; +import InstantLockTimeoutError from './InstantLockTimeoutError.js'; +import TxMetadataTimeoutError from './TxMetadataTimeoutError.js'; -module.exports = { +export { BlockHeaderNotInStore, CreateTransactionError, CoinSelectionUnsufficientUTXOS, @@ -56,6 +57,39 @@ module.exports = { TransactionNotInStore, TransactionMetadataNotInStore, UnknownPlugin, + UnknownStrategy, + UnknownWorker, + ValidTransportLayerRequired, + WalletLibError, + PluginInjectionError, + InstantLockTimeoutError, + TxMetadataTimeoutError, +}; + +export default { + BlockHeaderNotInStore, + CreateTransactionError, + CoinSelectionUnsufficientUTXOS, + InjectionErrorCannotInject, + InjectionErrorCannotInjectUnknownDependency, + InjectionToPluginUnallowed, + InvalidAddress, + InvalidAddressObject, + InvalidOutput, + InvalidStrategy, + InvalidDashcoreTransaction, + InvalidRawTransaction, + InvalidStorageAdapter, + InvalidTransactionObject, + InvalidUTXO, + PluginFailedOnStart, + WorkerFailedOnStart, + WorkerFailedOnExecute, + StorageUnableToAddTransaction, + TransactionNotInStore, + TransactionMetadataNotInStore, + UnknownPlugin, + UnknownStrategy, UnknownWorker, ValidTransportLayerRequired, WalletLibError, diff --git a/packages/wallet-lib/src/index.js b/packages/wallet-lib/src/index.js index 71610cdc033..31a8f356e85 100644 --- a/packages/wallet-lib/src/index.js +++ b/packages/wallet-lib/src/index.js @@ -1,21 +1,32 @@ -// Default winston transport requires setImmediate to work, so -// polyfill included here. Making it work with webpack is rather tricky, so it is used as per -// documentation: https://github.com/YuzuJS/setImmediate#usage -require('setimmediate'); -const Account = require('./types/Account/Account'); -const ChainStore = require('./types/ChainStore/ChainStore'); -const Identities = require('./types/Identities/Identities'); -const DerivableKeyChain = require('./types/DerivableKeyChain/DerivableKeyChain'); -const KeyChainStore = require('./types/KeyChainStore/KeyChainStore'); -const Storage = require('./types/Storage/Storage'); -const Wallet = require('./types/Wallet/Wallet'); -const WalletStore = require('./types/WalletStore/WalletStore'); -const EVENTS = require('./EVENTS'); -const CONSTANTS = require('./CONSTANTS'); -const utils = require('./utils'); -const plugins = require('./plugins'); +import Account from './types/Account/Account.js'; +import ChainStore from './types/ChainStore/ChainStore.js'; +import Identities from './types/Identities/Identities.js'; +import DerivableKeyChain from './types/DerivableKeyChain/DerivableKeyChain.js'; +import KeyChainStore from './types/KeyChainStore/KeyChainStore.js'; +import Storage from './types/Storage/Storage.js'; +import Wallet from './types/Wallet/Wallet.js'; +import WalletStore from './types/WalletStore/WalletStore.js'; +import EVENTS from './EVENTS.js'; +import CONSTANTS from './CONSTANTS.js'; +import utils from './utils/index.js'; +import plugins from './plugins/index.js'; -module.exports = { +export { + Account, + ChainStore, + Identities, + DerivableKeyChain, + KeyChainStore, + Storage, + Wallet, + WalletStore, + EVENTS, + CONSTANTS, + utils, + plugins, +}; + +export default { Account, ChainStore, Identities, diff --git a/packages/wallet-lib/src/logger/index.js b/packages/wallet-lib/src/logger/index.js index c7fa9cffbf5..1f2bd14b16b 100644 --- a/packages/wallet-lib/src/logger/index.js +++ b/packages/wallet-lib/src/logger/index.js @@ -1,76 +1,38 @@ -const util = require('util'); -const winston = require('winston'); +// Minimal console-based logger; mirrors the previous winston API +// (error/warn/info/verbose/debug/silly + getForWallet) without external deps. -const LOG_LEVEL = process.env.LOG_LEVEL || 'info'; -const LOG_TO_FILE = process.env.LOG_WALLET_TO_FILE || 'false'; +const LOG_LEVEL = (typeof process !== 'undefined' && process.env && process.env.LOG_LEVEL) || 'info'; -// Log levels: -// error 0 -// warn 1 -// info 2 (default) -// verbose 3 -// debug 4 -// silly 5 - -const loggers = {}; - -const createLogger = (formats = [], walletId = '') => { - const format = winston.format.combine( - { - transform: (info) => { - const args = info[Symbol.for('splat')]; - const result = { ...info }; - if (args) { - result.message = util.format(info.message, ...args); - } - return result; - }, - }, - ...formats, - winston.format.colorize(), - winston.format.printf(({ - level, message, - }) => `${level}: ${message}`), - ); - - const transports = [ - new winston.transports.Console({ - format, - }), - ]; - - if (LOG_TO_FILE === 'true' && typeof window === 'undefined') { - transports.push( - new winston.transports.File({ - filename: `wallet${walletId !== '' ? `_${walletId}` : ''}`, - format, - }), - ); - } - - return winston.createLogger({ - level: LOG_LEVEL, - transports, - }); +const LEVELS = { + silent: -1, error: 0, warn: 1, info: 2, verbose: 3, debug: 4, silly: 5, }; -const logger = createLogger(); - -logger.getForWallet = (walletId) => { - if (!loggers[walletId]) { - const format = { - transform: (info) => { - const message = `[Wallet: ${walletId}] ${info.message}`; - return { ...info, message }; - }, - }; - - loggers[walletId] = createLogger([format], walletId); - } +const cache = {}; + +function build(level = LOG_LEVEL, prefix = '') { + const threshold = LEVELS[level] != null ? LEVELS[level] : LEVELS.info; + const noop = () => {}; + const fmt = prefix ? (...a) => [prefix, ...a] : (...a) => a; + + const logger = { + error: threshold >= 0 ? (...a) => console.error(...fmt(...a)) : noop, + warn: threshold >= 1 ? (...a) => console.warn(...fmt(...a)) : noop, + info: threshold >= 2 ? (...a) => console.info(...fmt(...a)) : noop, + verbose: threshold >= 3 ? (...a) => console.debug(...fmt(...a)) : noop, + debug: threshold >= 4 ? (...a) => console.debug(...fmt(...a)) : noop, + silly: threshold >= 5 ? (...a) => console.debug(...fmt(...a)) : noop, + getForWallet(walletId) { + if (!cache[walletId]) { + cache[walletId] = build(level, `[Wallet: ${walletId}]`); + } + return cache[walletId]; + }, + }; + return logger; +} - return loggers[walletId]; -}; +const logger = build(); -logger.verbose(`Logger uses "${LOG_LEVEL}" level`, { level: LOG_LEVEL }); +logger.verbose(`Logger uses "${LOG_LEVEL}" level`); -module.exports = logger; +export default logger; diff --git a/packages/wallet-lib/src/plugins/Plugins/ChainPlugin.js b/packages/wallet-lib/src/plugins/Plugins/ChainPlugin.js index 66edb59a25b..37827d01c91 100644 --- a/packages/wallet-lib/src/plugins/Plugins/ChainPlugin.js +++ b/packages/wallet-lib/src/plugins/Plugins/ChainPlugin.js @@ -1,6 +1,6 @@ -const logger = require('../../logger'); -const { StandardPlugin } = require('..'); -const { dashToDuffs } = require('../../utils'); +import logger from '../../logger/index.js'; +import { StandardPlugin } from '../index.js'; +import { dashToDuffs } from '../../utils/index.js'; const defaultOpts = { firstExecutionRequired: true, @@ -57,4 +57,4 @@ class ChainPlugin extends StandardPlugin { } } -module.exports = ChainPlugin; +export default ChainPlugin; \ No newline at end of file diff --git a/packages/wallet-lib/src/plugins/StandardPlugin.js b/packages/wallet-lib/src/plugins/StandardPlugin.js index 6a5c5a22bb8..5be86a975b4 100644 --- a/packages/wallet-lib/src/plugins/StandardPlugin.js +++ b/packages/wallet-lib/src/plugins/StandardPlugin.js @@ -1,7 +1,9 @@ -const _ = require('lodash'); -const EventEmitter = require('events'); -const { InjectionToPluginUnallowed } = require('../errors'); -const { SAFE_FUNCTIONS, SAFE_PROPERTIES } = require('../CONSTANTS').INJECTION_LISTS; +import _ from 'lodash'; +import EventEmitter from 'events'; +import { InjectionToPluginUnallowed } from '../errors/index.js'; +import { INJECTION_LISTS } from '../CONSTANTS.js'; + +const { SAFE_FUNCTIONS, SAFE_PROPERTIES } = INJECTION_LISTS; const defaultOpts = { executeOnStart: false, @@ -73,4 +75,4 @@ class StandardPlugin extends EventEmitter { } } -module.exports = StandardPlugin; +export default StandardPlugin; \ No newline at end of file diff --git a/packages/wallet-lib/src/plugins/StandardPlugin.spec.js b/packages/wallet-lib/src/plugins/StandardPlugin.spec.js index b6794a6b0a1..73586bf0c73 100644 --- a/packages/wallet-lib/src/plugins/StandardPlugin.spec.js +++ b/packages/wallet-lib/src/plugins/StandardPlugin.spec.js @@ -1,6 +1,6 @@ -const { expect } = require('chai'); -const { EventEmitter } = require('events'); -const StandardPluginSpec = require('./StandardPlugin'); +import { expect } from 'chai'; +import { EventEmitter } from 'events'; +import StandardPluginSpec from './StandardPlugin.js'; describe('Plugins - StandardPlugin', function suite() { this.timeout(60000); diff --git a/packages/wallet-lib/src/plugins/Worker.js b/packages/wallet-lib/src/plugins/Worker.js index 9cab6050519..3e721e9dcd3 100644 --- a/packages/wallet-lib/src/plugins/Worker.js +++ b/packages/wallet-lib/src/plugins/Worker.js @@ -1,5 +1,5 @@ -const _ = require('lodash'); -const StandardPlugin = require('./StandardPlugin'); +import _ from 'lodash'; +import StandardPlugin from './StandardPlugin.js'; // eslint-disable-next-line no-underscore-dangle const _defaultOpts = { @@ -143,4 +143,4 @@ class Worker extends StandardPlugin { } } -module.exports = Worker; +export default Worker; \ No newline at end of file diff --git a/packages/wallet-lib/src/plugins/Worker.spec.js b/packages/wallet-lib/src/plugins/Worker.spec.js index bc5ded7c6eb..71e060b43b5 100644 --- a/packages/wallet-lib/src/plugins/Worker.spec.js +++ b/packages/wallet-lib/src/plugins/Worker.spec.js @@ -1,7 +1,7 @@ -const { expect } = require('chai'); -const { EventEmitter } = require('events'); -const WorkerSpec = require('./Worker'); -const FaultyWorker = require('../../fixtures/plugins/FaultyWorker'); +import { expect } from 'chai'; +import { EventEmitter } from 'events'; +import WorkerSpec from './Worker.js'; +import FaultyWorker from '../../fixtures/plugins/FaultyWorker.js'; describe('Plugins - Worker', function suite() { this.timeout(60000); diff --git a/packages/wallet-lib/src/plugins/Workers/BlockHeadersSyncWorker/BlockHeadersSyncWorker.js b/packages/wallet-lib/src/plugins/Workers/BlockHeadersSyncWorker/BlockHeadersSyncWorker.js index 76f7e02658c..bcfadcd27b1 100644 --- a/packages/wallet-lib/src/plugins/Workers/BlockHeadersSyncWorker/BlockHeadersSyncWorker.js +++ b/packages/wallet-lib/src/plugins/Workers/BlockHeadersSyncWorker/BlockHeadersSyncWorker.js @@ -1,7 +1,7 @@ -const BlockHeadersProvider = require('@dashevo/dapi-client/lib/BlockHeadersProvider/BlockHeadersProvider'); -const Worker = require('../../Worker'); -const logger = require('../../../logger'); -const EVENTS = require('../../../EVENTS'); +import BlockHeadersProvider from '@dashevo/dapi-client/lib/BlockHeadersProvider/BlockHeadersProvider.js'; +import Worker from '../../Worker.js'; +import logger from '../../../logger/index.js'; +import EVENTS from '../../../EVENTS.js'; const PROGRESS_UPDATE_INTERVAL = 1000; @@ -391,4 +391,4 @@ class BlockHeadersSyncWorker extends Worker { BlockHeadersSyncWorker.MAX_HEADERS_TO_KEEP = MAX_HEADERS_TO_KEEP; BlockHeadersSyncWorker.STATES = STATES; -module.exports = BlockHeadersSyncWorker; +export default BlockHeadersSyncWorker; \ No newline at end of file diff --git a/packages/wallet-lib/src/plugins/Workers/BlockHeadersSyncWorker/BlockHeadersSyncWorker.spec.js b/packages/wallet-lib/src/plugins/Workers/BlockHeadersSyncWorker/BlockHeadersSyncWorker.spec.js index 69f0da74cf6..8d0abd76d44 100644 --- a/packages/wallet-lib/src/plugins/Workers/BlockHeadersSyncWorker/BlockHeadersSyncWorker.spec.js +++ b/packages/wallet-lib/src/plugins/Workers/BlockHeadersSyncWorker/BlockHeadersSyncWorker.spec.js @@ -1,19 +1,20 @@ /* eslint-disable no-unused-expressions */ -const EventEmitter = require('events'); -const DAPIClient = require('@dashevo/dapi-client'); -const { Block } = require('@dashevo/dashcore-lib'); -const { expect } = require('chai'); -const logger = require('../../../logger'); +import EventEmitter from 'events'; +import DAPIClient from '@dashevo/dapi-client'; +import dashcore from '@dashevo/dashcore-lib'; +const { Block } = dashcore; +import { expect } from 'chai'; +import logger from '../../../logger/index.js'; const { BlockHeadersProvider } = DAPIClient; -const BlockHeadersSyncWorker = require('./BlockHeadersSyncWorker'); +import BlockHeadersSyncWorker from './BlockHeadersSyncWorker.js'; -const { waitOneTick } = require('../../../test/utils'); +import { waitOneTick } from '../../../test/utils.js'; -const EVENTS = require('../../../EVENTS'); -const { mockHeadersChain } = require('../../../test/mocks/dashcore/block'); +import EVENTS from '../../../EVENTS.js'; +import { mockHeadersChain } from '../../../test/mocks/dashcore/block.js'; describe('BlockHeadersSyncWorker', () => { let blockHeadersSyncWorker; diff --git a/packages/wallet-lib/src/plugins/Workers/IdentitySyncWorker.js b/packages/wallet-lib/src/plugins/Workers/IdentitySyncWorker.js index f9ed5183b6a..c2ffddc8ecf 100644 --- a/packages/wallet-lib/src/plugins/Workers/IdentitySyncWorker.js +++ b/packages/wallet-lib/src/plugins/Workers/IdentitySyncWorker.js @@ -1,7 +1,8 @@ -const { default: loadDpp, Identity } = require('@dashevo/wasm-dpp'); -const GrpcErrorCodes = require('@dashevo/grpc-common/lib/server/error/GrpcErrorCodes'); +import loadDpp from '@dashevo/wasm-dpp'; +const { Identity } = loadDpp; +import GrpcErrorCodes from '@dashevo/grpc-common/lib/server/error/GrpcErrorCodes.js'; -const Worker = require('../Worker'); +import Worker from '../Worker.js'; /** * @property {number} gapLimit @@ -27,8 +28,11 @@ class IdentitySyncWorker extends Worker { // eslint-disable-next-line async onStart() { - // Load DPP to make sure Identity and decodeProtocolEntity are available - await loadDpp(); + // Load DPP to make sure Identity and decodeProtocolEntity are available. + // wasm-dpp is CJS; under NodeNext the default import may resolve to the + // module namespace object instead of the callable. Unwrap defensively. + const load = loadDpp.default ?? loadDpp; + await load(); } async execute() { @@ -116,4 +120,4 @@ class IdentitySyncWorker extends Worker { } } -module.exports = IdentitySyncWorker; +export default IdentitySyncWorker; \ No newline at end of file diff --git a/packages/wallet-lib/src/plugins/Workers/TransactionsSyncWorker/TransactionsReader.js b/packages/wallet-lib/src/plugins/Workers/TransactionsSyncWorker/TransactionsReader.js index f398e535af4..50d4e06da1d 100644 --- a/packages/wallet-lib/src/plugins/Workers/TransactionsSyncWorker/TransactionsReader.js +++ b/packages/wallet-lib/src/plugins/Workers/TransactionsSyncWorker/TransactionsReader.js @@ -1,14 +1,14 @@ -const { EventEmitter } = require('events'); -const GrpcErrorCodes = require('@dashevo/grpc-common/lib/server/error/GrpcErrorCodes'); -const { +import { EventEmitter } from 'events'; +import GrpcErrorCodes from '@dashevo/grpc-common/lib/server/error/GrpcErrorCodes.js'; +import { createBloomFilter, parseRawTransactions, parseRawMerkleBlock, parseRawInstantLocks, getTxHashesFromMerkleBlock, -} = require('./utils'); +} from './utils.js'; -const logger = require('../../../logger'); +import logger from '../../../logger/index.js'; const EVENTS = { HISTORICAL_TRANSACTIONS: 'HISTORICAL_TRANSACTIONS', @@ -500,4 +500,4 @@ class TransactionsReader extends EventEmitter { TransactionsReader.EVENTS = EVENTS; -module.exports = TransactionsReader; +export default TransactionsReader; \ No newline at end of file diff --git a/packages/wallet-lib/src/plugins/Workers/TransactionsSyncWorker/TransactionsReader.spec.js b/packages/wallet-lib/src/plugins/Workers/TransactionsSyncWorker/TransactionsReader.spec.js index 3044588b4d5..c2692993a24 100644 --- a/packages/wallet-lib/src/plugins/Workers/TransactionsSyncWorker/TransactionsReader.spec.js +++ b/packages/wallet-lib/src/plugins/Workers/TransactionsSyncWorker/TransactionsReader.spec.js @@ -1,12 +1,13 @@ -const { expect } = require('chai'); -const { Transaction, PrivateKey } = require('@dashevo/dashcore-lib'); - -const TransactionsReader = require('./TransactionsReader'); -const TxStreamMock = require('../../../test/mocks/TxStreamMock'); -const { createBloomFilter } = require('./utils'); -const { mockMerkleBlock } = require('../../../test/mocks/dashcore/block'); -const { mockInstantLock } = require('../../../test/mocks/dashcore/instantlock'); -const { waitOneTick } = require('../../../test/utils'); +import { expect } from 'chai'; +import dashcore from '@dashevo/dashcore-lib'; +const { Transaction, PrivateKey } = dashcore; + +import TransactionsReader from './TransactionsReader.js'; +import TxStreamMock from '../../../test/mocks/TxStreamMock.js'; +import { createBloomFilter } from './utils.js'; +import { mockMerkleBlock } from '../../../test/mocks/dashcore/block.js'; +import { mockInstantLock } from '../../../test/mocks/dashcore/instantlock.js'; +import { waitOneTick } from '../../../test/utils.js'; describe('TransactionsReader - unit', () => { let options; diff --git a/packages/wallet-lib/src/plugins/Workers/TransactionsSyncWorker/TransactionsSyncWorker.js b/packages/wallet-lib/src/plugins/Workers/TransactionsSyncWorker/TransactionsSyncWorker.js index df00b61c994..3e87e1175f4 100644 --- a/packages/wallet-lib/src/plugins/Workers/TransactionsSyncWorker/TransactionsSyncWorker.js +++ b/packages/wallet-lib/src/plugins/Workers/TransactionsSyncWorker/TransactionsSyncWorker.js @@ -1,10 +1,10 @@ -const BlockHeadersProvider = require('@dashevo/dapi-client/lib/BlockHeadersProvider/BlockHeadersProvider'); -const ReconnectableStream = require('@dashevo/dapi-client/lib/transport/ReconnectableStream'); -const Worker = require('../../Worker'); -const logger = require('../../../logger'); -const TransactionsReader = require('./TransactionsReader'); -const { getAddressesToSync, getTxHashesFromMerkleBlock } = require('./utils'); -const EVENTS = require('../../../EVENTS'); +import BlockHeadersProvider from '@dashevo/dapi-client/lib/BlockHeadersProvider/BlockHeadersProvider.js'; +import ReconnectableStream from '@dashevo/dapi-client/lib/transport/ReconnectableStream.js'; +import Worker from '../../Worker.js'; +import logger from '../../../logger/index.js'; +import TransactionsReader from './TransactionsReader.js'; +import { getAddressesToSync, getTxHashesFromMerkleBlock } from './utils.js'; +import EVENTS from '../../../EVENTS.js'; const STATES = { IDLE: 'STATE_IDLE', @@ -687,4 +687,4 @@ class TransactionsSyncWorker extends Worker { TransactionsSyncWorker.STATES = STATES; -module.exports = TransactionsSyncWorker; +export default TransactionsSyncWorker; \ No newline at end of file diff --git a/packages/wallet-lib/src/plugins/Workers/TransactionsSyncWorker/TransactionsSyncWorker.spec.js b/packages/wallet-lib/src/plugins/Workers/TransactionsSyncWorker/TransactionsSyncWorker.spec.js index aacd3b137db..d5d5a9a31db 100644 --- a/packages/wallet-lib/src/plugins/Workers/TransactionsSyncWorker/TransactionsSyncWorker.spec.js +++ b/packages/wallet-lib/src/plugins/Workers/TransactionsSyncWorker/TransactionsSyncWorker.spec.js @@ -1,12 +1,13 @@ -const { expect } = require('chai'); -const EventEmitter = require('events'); -const { Transaction } = require('@dashevo/dashcore-lib'); -const TransactionsSyncWorker = require('./TransactionsSyncWorker'); -const TransactionsReader = require('./TransactionsReader'); -const { waitOneTick } = require('../../../test/utils'); -const { mockMerkleBlock } = require('../../../test/mocks/dashcore/block'); -const EVENTS = require('../../../EVENTS'); -const logger = require('../../../logger'); +import { expect } from 'chai'; +import EventEmitter from 'events'; +import dashcore from '@dashevo/dashcore-lib'; +const { Transaction } = dashcore; +import TransactionsSyncWorker from './TransactionsSyncWorker.js'; +import TransactionsReader from './TransactionsReader.js'; +import { waitOneTick } from '../../../test/utils.js'; +import { mockMerkleBlock } from '../../../test/mocks/dashcore/block.js'; +import EVENTS from '../../../EVENTS.js'; +import logger from '../../../logger/index.js'; describe('TransactionsSyncWorker', () => { let transactionsSyncWorker; diff --git a/packages/wallet-lib/src/plugins/Workers/TransactionsSyncWorker/utils.js b/packages/wallet-lib/src/plugins/Workers/TransactionsSyncWorker/utils.js index 0648a2393dc..d5e357f3326 100644 --- a/packages/wallet-lib/src/plugins/Workers/TransactionsSyncWorker/utils.js +++ b/packages/wallet-lib/src/plugins/Workers/TransactionsSyncWorker/utils.js @@ -1,7 +1,12 @@ +import dashcore from '@dashevo/dashcore-lib'; const { - BloomFilter, Address, MerkleBlock, Transaction, InstantLock, -} = require('@dashevo/dashcore-lib'); -const { BLOOM_FALSE_POSITIVE_RATE } = require('../../../CONSTANTS'); + BloomFilter, + Address, + MerkleBlock, + Transaction, + InstantLock, +} = dashcore; +import { BLOOM_FALSE_POSITIVE_RATE } from '../../../CONSTANTS.js'; /** * @param {string[]} addresses @@ -104,7 +109,17 @@ const getTxHashesFromMerkleBlock = (merkleBlock) => merkleBlock return set; }, new Set()); -module.exports = { +export { + createBloomFilter, + filterTransactionsForAddresses, + parseRawTransactions, + parseRawMerkleBlock, + parseRawInstantLocks, + getAddressesToSync, + getTxHashesFromMerkleBlock, +}; + +export default { createBloomFilter, filterTransactionsForAddresses, parseRawTransactions, diff --git a/packages/wallet-lib/src/plugins/Workers/TransactionsSyncWorker/utils.spec.js b/packages/wallet-lib/src/plugins/Workers/TransactionsSyncWorker/utils.spec.js index f996e0835f2..3539dbc9609 100644 --- a/packages/wallet-lib/src/plugins/Workers/TransactionsSyncWorker/utils.spec.js +++ b/packages/wallet-lib/src/plugins/Workers/TransactionsSyncWorker/utils.spec.js @@ -1,12 +1,14 @@ -const { expect } = require('chai'); +import { expect } from 'chai'; +import dashcore from '@dashevo/dashcore-lib'; const { - PrivateKey, Transaction, -} = require('@dashevo/dashcore-lib'); + PrivateKey, + Transaction, +} = dashcore; -const { mockUtxo } = require('../../../test/mocks/dashcore/transaction'); +import { mockUtxo } from '../../../test/mocks/dashcore/transaction.js'; -const utils = require('./utils'); +import utils from './utils.js'; describe('TransactionsSyncWorker - utils', () => { describe('#filterTransactionsForAddresses()', () => { diff --git a/packages/wallet-lib/src/plugins/index.js b/packages/wallet-lib/src/plugins/index.js index ebad2cfcf18..fbfb5b9b1c1 100644 --- a/packages/wallet-lib/src/plugins/index.js +++ b/packages/wallet-lib/src/plugins/index.js @@ -1,6 +1,11 @@ -const Worker = require('./Worker'); -const StandardPlugin = require('./StandardPlugin'); +import Worker from './Worker.js'; +import StandardPlugin from './StandardPlugin.js'; -module.exports = { +export { + StandardPlugin, + Worker, +}; + +export default { StandardPlugin, Worker, }; diff --git a/packages/wallet-lib/src/test/bootstrap.js b/packages/wallet-lib/src/test/bootstrap.js index a47d8123f59..4ec2db84c31 100644 --- a/packages/wallet-lib/src/test/bootstrap.js +++ b/packages/wallet-lib/src/test/bootstrap.js @@ -1,11 +1,13 @@ -const { use } = require('chai'); -const { expect } = require('chai'); -const dotenvSafe = require('dotenv-safe'); -const path = require('path'); -const sinon = require('sinon'); -const sinonChai = require('sinon-chai'); -const dirtyChai = require('dirty-chai'); -const chaiAsPromised = require('chai-as-promised'); +import { use, expect } from 'chai'; +import dotenvSafe from 'dotenv-safe'; +import path from 'path'; +import sinon from 'sinon'; +import sinonChai from 'sinon-chai'; +import dirtyChai from 'dirty-chai'; +import chaiAsPromised from 'chai-as-promised'; +import { fileURLToPath } from 'url'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); use(sinonChai); use(dirtyChai); @@ -17,7 +19,7 @@ if (process.env.LOAD_ENV === 'true') { }); } -exports.mochaHooks = { +export const mochaHooks = { beforeEach() { if (!this.sinon) { this.sinon = sinon.createSandbox(); diff --git a/packages/wallet-lib/src/test/karma/bootstrap.js b/packages/wallet-lib/src/test/karma/bootstrap.js deleted file mode 100644 index 12348a3e0f5..00000000000 --- a/packages/wallet-lib/src/test/karma/bootstrap.js +++ /dev/null @@ -1,30 +0,0 @@ -const { expect, use } = require('chai'); -const sinon = require('sinon'); -const chaiAsPromised = require('chai-as-promised'); -const sinonChai = require('sinon-chai'); -const dirtyChai = require('dirty-chai'); -require('setimmediate'); - -use(chaiAsPromised); -use(sinonChai); -use(dirtyChai); - -beforeEach(function beforeEach() { - if (!this.sinon) { - this.sinon = sinon.createSandbox(); - } else { - this.sinon.restore(); - } -}); - -afterEach(function afterEach() { - this.sinon.restore(); -}); - -before(function before() { - if (!this.sinon) { - this.sinon = sinon.createSandbox(); - } -}); - -global.expect = expect; diff --git a/packages/wallet-lib/src/test/karma/loader.js b/packages/wallet-lib/src/test/karma/loader.js deleted file mode 100644 index 03aaa20c9cc..00000000000 --- a/packages/wallet-lib/src/test/karma/loader.js +++ /dev/null @@ -1,8 +0,0 @@ -// This file is used for compiling tests with webpack into one file for using with karma -require('./bootstrap'); - -const testsContext = require.context('../../../src', true, /spec.js$/); -const integrationTestsContext = require.context('../../../tests/integration', true, /spec.js$/); - -testsContext.keys().forEach(testsContext); -integrationTestsContext.keys().forEach(integrationTestsContext); diff --git a/packages/wallet-lib/src/test/mocks/BlockHeadersStreamMock.js b/packages/wallet-lib/src/test/mocks/BlockHeadersStreamMock.js index 8ed3d1b91de..8e67a7b4a16 100644 --- a/packages/wallet-lib/src/test/mocks/BlockHeadersStreamMock.js +++ b/packages/wallet-lib/src/test/mocks/BlockHeadersStreamMock.js @@ -1,4 +1,4 @@ -const EventEmitter = require('events'); +import EventEmitter from 'events'; class BlockHeadersStreamMock extends EventEmitter { constructor() { @@ -51,4 +51,4 @@ BlockHeadersStreamMock.EVENTS = { error: 'error', }; -module.exports = BlockHeadersStreamMock; +export default BlockHeadersStreamMock; \ No newline at end of file diff --git a/packages/wallet-lib/src/test/mocks/LocalForageAdapterMock.js b/packages/wallet-lib/src/test/mocks/LocalForageAdapterMock.js index 818dcc61a00..8b1de748611 100644 --- a/packages/wallet-lib/src/test/mocks/LocalForageAdapterMock.js +++ b/packages/wallet-lib/src/test/mocks/LocalForageAdapterMock.js @@ -17,4 +17,4 @@ class LocalForageAdapterMock { return this.keys[key] ? JSON.parse(this.keys[key]) : null; } } -module.exports = LocalForageAdapterMock; +export default LocalForageAdapterMock; \ No newline at end of file diff --git a/packages/wallet-lib/src/test/mocks/TransportMock.js b/packages/wallet-lib/src/test/mocks/TransportMock.js index d4ea750e076..d4660e9644f 100644 --- a/packages/wallet-lib/src/test/mocks/TransportMock.js +++ b/packages/wallet-lib/src/test/mocks/TransportMock.js @@ -1,6 +1,6 @@ -const EventEmitter = require('events'); -const NotFoundError = require('@dashevo/dapi-client/lib/transport/GrpcTransport/errors/NotFoundError'); -const getBlockchainStatus = require('../../transport/FixtureTransport/methods/getBlockchainStatus'); +import EventEmitter from 'events'; +import NotFoundError from '@dashevo/dapi-client/lib/transport/GrpcTransport/errors/NotFoundError.js'; +import getBlockchainStatus from '../../transport/FixtureTransport/methods/getBlockchainStatus.js'; class TransportMock extends EventEmitter { constructor(sinon, transactionStreamMock) { @@ -53,4 +53,4 @@ class TransportMock extends EventEmitter { } } -module.exports = TransportMock; +export default TransportMock; \ No newline at end of file diff --git a/packages/wallet-lib/src/test/mocks/TxStreamDataResponseMock.js b/packages/wallet-lib/src/test/mocks/TxStreamDataResponseMock.js index e75feda32ee..27623628460 100644 --- a/packages/wallet-lib/src/test/mocks/TxStreamDataResponseMock.js +++ b/packages/wallet-lib/src/test/mocks/TxStreamDataResponseMock.js @@ -43,4 +43,4 @@ class TxStreamDataResponseMock { } } -module.exports = TxStreamDataResponseMock; +export default TxStreamDataResponseMock; \ No newline at end of file diff --git a/packages/wallet-lib/src/test/mocks/TxStreamMock.js b/packages/wallet-lib/src/test/mocks/TxStreamMock.js index 6545aaf6b14..8a3e12a503c 100644 --- a/packages/wallet-lib/src/test/mocks/TxStreamMock.js +++ b/packages/wallet-lib/src/test/mocks/TxStreamMock.js @@ -1,6 +1,6 @@ -const EventEmitter = require('events'); -const TxStreamDataResponseMock = require('./TxStreamDataResponseMock'); -const { waitOneTick } = require('../utils'); +import EventEmitter from 'events'; +import TxStreamDataResponseMock from './TxStreamDataResponseMock.js'; +import { waitOneTick } from '../utils.js'; class TxStreamMock extends EventEmitter { constructor(sinon) { @@ -79,4 +79,4 @@ TxStreamMock.EVENTS = { error: 'error', }; -module.exports = TxStreamMock; +export default TxStreamMock; \ No newline at end of file diff --git a/packages/wallet-lib/src/test/mocks/createAndAttachTransportMocksToWallet.js b/packages/wallet-lib/src/test/mocks/createAndAttachTransportMocksToWallet.js index ce1b504c856..21e8988b03e 100644 --- a/packages/wallet-lib/src/test/mocks/createAndAttachTransportMocksToWallet.js +++ b/packages/wallet-lib/src/test/mocks/createAndAttachTransportMocksToWallet.js @@ -1,9 +1,9 @@ -const DAPIClient = require('@dashevo/dapi-client'); +import DAPIClient from '@dashevo/dapi-client'; -const TxStreamMock = require('./TxStreamMock'); -const TransportMock = require('./TransportMock'); +import TxStreamMock from './TxStreamMock.js'; +import TransportMock from './TransportMock.js'; -module.exports = async function createAndAttachTransportMocksToWallet(wallet, sinon) { +export default async function createAndAttachTransportMocksToWallet(wallet, sinon) { const txStreamMock = new TxStreamMock(); const transportMock = new TransportMock(sinon, txStreamMock); diff --git a/packages/wallet-lib/src/test/mocks/createTransactionInAccount.js b/packages/wallet-lib/src/test/mocks/createTransactionInAccount.js index fbe1884b034..f6bca9649e7 100644 --- a/packages/wallet-lib/src/test/mocks/createTransactionInAccount.js +++ b/packages/wallet-lib/src/test/mocks/createTransactionInAccount.js @@ -1,4 +1,5 @@ -const { Transaction } = require('@dashevo/dashcore-lib'); +import dashcore from '@dashevo/dashcore-lib'; +const { Transaction } = dashcore; /** * Creates a mocked transaction in the wallet that can be used to perform various tests @@ -27,4 +28,4 @@ async function createTransactionInAccount(account) { return walletTransaction; } -module.exports = createTransactionInAccount; +export default createTransactionInAccount; \ No newline at end of file diff --git a/packages/wallet-lib/src/test/mocks/dashcore/block.js b/packages/wallet-lib/src/test/mocks/dashcore/block.js index f2becaf7970..40e4ba6f66a 100644 --- a/packages/wallet-lib/src/test/mocks/dashcore/block.js +++ b/packages/wallet-lib/src/test/mocks/dashcore/block.js @@ -1,6 +1,7 @@ -const X11 = require('wasm-x11-hash'); -const { BlockHeader, MerkleBlock, configure } = require('@dashevo/dashcore-lib'); -const { genesis } = require('@dashevo/dash-spv'); +import X11 from 'wasm-x11-hash'; +import dashcore from '@dashevo/dashcore-lib'; +const { BlockHeader, MerkleBlock, configure } = dashcore; +import { genesis } from '@dashevo/dash-spv'; const getRoot = (network) => { switch (network) { @@ -82,7 +83,13 @@ const mockMerkleBlock = (txHashes, prevHeader, network = 'livenet') => { }); }; -module.exports = { +export { + mockHeadersChain, + mockHeader, + mockMerkleBlock, +}; + +export default { mockHeadersChain, mockHeader, mockMerkleBlock, diff --git a/packages/wallet-lib/src/test/mocks/dashcore/instantlock.js b/packages/wallet-lib/src/test/mocks/dashcore/instantlock.js index 0b30a89dfaa..160012c68da 100644 --- a/packages/wallet-lib/src/test/mocks/dashcore/instantlock.js +++ b/packages/wallet-lib/src/test/mocks/dashcore/instantlock.js @@ -1,4 +1,5 @@ -const { InstantLock } = require('@dashevo/dashcore-lib'); +import dashcore from '@dashevo/dashcore-lib'; +const { InstantLock } = dashcore; function mockInstantLock(transactionHash) { return new InstantLock({ @@ -15,6 +16,10 @@ function mockInstantLock(transactionHash) { }); } -module.exports = { +export { + mockInstantLock, +}; + +export default { mockInstantLock, }; diff --git a/packages/wallet-lib/src/test/mocks/dashcore/transaction.js b/packages/wallet-lib/src/test/mocks/dashcore/transaction.js index 47ac8bfc472..e69b028a377 100644 --- a/packages/wallet-lib/src/test/mocks/dashcore/transaction.js +++ b/packages/wallet-lib/src/test/mocks/dashcore/transaction.js @@ -1,5 +1,6 @@ -const crypto = require('crypto'); -const { Transaction, Script, PrivateKey } = require('@dashevo/dashcore-lib'); +import crypto from 'crypto'; +import dashcore from '@dashevo/dashcore-lib'; +const { Transaction, Script, PrivateKey } = dashcore; /** * @@ -31,4 +32,5 @@ const transaction = { mockUtxo, }; -module.exports = transaction; +export default transaction; +export { mockUtxo }; \ No newline at end of file diff --git a/packages/wallet-lib/src/test/mocks/mockBlockHeadersProvider.js b/packages/wallet-lib/src/test/mocks/mockBlockHeadersProvider.js index 19078915dab..af4dad5048e 100644 --- a/packages/wallet-lib/src/test/mocks/mockBlockHeadersProvider.js +++ b/packages/wallet-lib/src/test/mocks/mockBlockHeadersProvider.js @@ -1,4 +1,4 @@ -const DAPIClient = require('@dashevo/dapi-client'); +import DAPIClient from '@dashevo/dapi-client'; const { BlockHeadersProvider, @@ -37,4 +37,4 @@ const mockBlockHeadersProvider = (sinon, historicalStreams, continuousStream, he ); }; -module.exports = mockBlockHeadersProvider; +export default mockBlockHeadersProvider; \ No newline at end of file diff --git a/packages/wallet-lib/src/test/mocks/mockStorage.js b/packages/wallet-lib/src/test/mocks/mockStorage.js index 5c987b101a9..0f9ed78a355 100644 --- a/packages/wallet-lib/src/test/mocks/mockStorage.js +++ b/packages/wallet-lib/src/test/mocks/mockStorage.js @@ -1,5 +1,5 @@ -const Storage = require('../../types/Storage/Storage'); -const LocalForageAdapterMock = require('./LocalForageAdapterMock'); +import Storage from '../../types/Storage/Storage.js'; +import LocalForageAdapterMock from './LocalForageAdapterMock.js'; const defaultOptions = { withAdapter: false, @@ -27,4 +27,4 @@ const mockStorage = async (opts = {}) => { return storage; }; -module.exports = mockStorage; +export default mockStorage; \ No newline at end of file diff --git a/packages/wallet-lib/src/test/utils.js b/packages/wallet-lib/src/test/utils.js index e8bb2602869..ad00dde6347 100644 --- a/packages/wallet-lib/src/test/utils.js +++ b/packages/wallet-lib/src/test/utils.js @@ -8,7 +8,7 @@ const waitOneTick = () => new Promise((resolve) => { const wait = (timeout) => new Promise(((resolve) => { setTimeout(resolve, timeout); })); -module.exports = { +export { waitOneTick, wait, }; diff --git a/packages/wallet-lib/src/transport/AbstractTransport.js b/packages/wallet-lib/src/transport/AbstractTransport.js index 76633f5d534..3a8c572e5ae 100644 --- a/packages/wallet-lib/src/transport/AbstractTransport.js +++ b/packages/wallet-lib/src/transport/AbstractTransport.js @@ -1,7 +1,7 @@ -const EventEmitter = require('events'); +import EventEmitter from 'events'; -const EVENTS = require('../EVENTS'); -const logger = require('../logger'); +import EVENTS from '../EVENTS.js'; +import logger from '../logger/index.js'; /** * @abstract @@ -61,4 +61,4 @@ class AbstractTransport extends EventEmitter { } } -module.exports = AbstractTransport; +export default AbstractTransport; \ No newline at end of file diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/DAPIClientTransport.js b/packages/wallet-lib/src/transport/DAPIClientTransport/DAPIClientTransport.js index 7e8f6f2663c..4a97e430ee3 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/DAPIClientTransport.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/DAPIClientTransport.js @@ -1,4 +1,4 @@ -const AbstractTransport = require('../AbstractTransport'); +import AbstractTransport from '../AbstractTransport.js'; /** * @implements {Transport} @@ -11,19 +11,33 @@ class DAPIClientTransport extends AbstractTransport { } } -DAPIClientTransport.prototype.disconnect = require('./methods/disconnect'); -DAPIClientTransport.prototype.getBestBlock = require('./methods/getBestBlock'); -DAPIClientTransport.prototype.getBestBlockHeader = require('./methods/getBestBlockHeader'); -DAPIClientTransport.prototype.getBestBlockHash = require('./methods/getBestBlockHash'); -DAPIClientTransport.prototype.getBestBlockHeight = require('./methods/getBestBlockHeight'); -DAPIClientTransport.prototype.getBlockByHash = require('./methods/getBlockByHash'); -DAPIClientTransport.prototype.getBlockByHeight = require('./methods/getBlockByHeight'); -DAPIClientTransport.prototype.getBlockHeaderByHash = require('./methods/getBlockHeaderByHash'); -DAPIClientTransport.prototype.getBlockHeaderByHeight = require('./methods/getBlockHeaderByHeight'); -DAPIClientTransport.prototype.getBlockchainStatus = require('./methods/getBlockchainStatus'); -DAPIClientTransport.prototype.getTransaction = require('./methods/getTransaction'); -DAPIClientTransport.prototype.sendTransaction = require('./methods/sendTransaction'); -DAPIClientTransport.prototype.getIdentityByPublicKeyHash = require('./methods/getIdentityByPublicKeyHash'); -DAPIClientTransport.prototype.subscribeToTransactionsWithProofs = require('./methods/subscribeToTransactionsWithProofs'); +import _DAPIClientTransport_disconnect from './methods/disconnect.js'; +DAPIClientTransport.prototype.disconnect = _DAPIClientTransport_disconnect; +import _DAPIClientTransport_getBestBlock from './methods/getBestBlock.js'; +DAPIClientTransport.prototype.getBestBlock = _DAPIClientTransport_getBestBlock; +import _DAPIClientTransport_getBestBlockHeader from './methods/getBestBlockHeader.js'; +DAPIClientTransport.prototype.getBestBlockHeader = _DAPIClientTransport_getBestBlockHeader; +import _DAPIClientTransport_getBestBlockHash from './methods/getBestBlockHash.js'; +DAPIClientTransport.prototype.getBestBlockHash = _DAPIClientTransport_getBestBlockHash; +import _DAPIClientTransport_getBestBlockHeight from './methods/getBestBlockHeight.js'; +DAPIClientTransport.prototype.getBestBlockHeight = _DAPIClientTransport_getBestBlockHeight; +import _DAPIClientTransport_getBlockByHash from './methods/getBlockByHash.js'; +DAPIClientTransport.prototype.getBlockByHash = _DAPIClientTransport_getBlockByHash; +import _DAPIClientTransport_getBlockByHeight from './methods/getBlockByHeight.js'; +DAPIClientTransport.prototype.getBlockByHeight = _DAPIClientTransport_getBlockByHeight; +import _DAPIClientTransport_getBlockHeaderByHash from './methods/getBlockHeaderByHash.js'; +DAPIClientTransport.prototype.getBlockHeaderByHash = _DAPIClientTransport_getBlockHeaderByHash; +import _DAPIClientTransport_getBlockHeaderByHeight from './methods/getBlockHeaderByHeight.js'; +DAPIClientTransport.prototype.getBlockHeaderByHeight = _DAPIClientTransport_getBlockHeaderByHeight; +import _DAPIClientTransport_getBlockchainStatus from './methods/getBlockchainStatus.js'; +DAPIClientTransport.prototype.getBlockchainStatus = _DAPIClientTransport_getBlockchainStatus; +import _DAPIClientTransport_getTransaction from './methods/getTransaction.js'; +DAPIClientTransport.prototype.getTransaction = _DAPIClientTransport_getTransaction; +import _DAPIClientTransport_sendTransaction from './methods/sendTransaction.js'; +DAPIClientTransport.prototype.sendTransaction = _DAPIClientTransport_sendTransaction; +import _DAPIClientTransport_getIdentityByPublicKeyHash from './methods/getIdentityByPublicKeyHash.js'; +DAPIClientTransport.prototype.getIdentityByPublicKeyHash = _DAPIClientTransport_getIdentityByPublicKeyHash; +import _DAPIClientTransport_subscribeToTransactionsWithProofs from './methods/subscribeToTransactionsWithProofs.js'; +DAPIClientTransport.prototype.subscribeToTransactionsWithProofs = _DAPIClientTransport_subscribeToTransactionsWithProofs; -module.exports = DAPIClientTransport; +export default DAPIClientTransport; \ No newline at end of file diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/disconnect.js b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/disconnect.js index 9bb5812019e..60e5e620203 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/disconnect.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/disconnect.js @@ -1,6 +1,6 @@ -const logger = require('../../../logger'); +import logger from '../../../logger/index.js'; -module.exports = async function disconnect() { +export default async function disconnect() { logger.silly('DAPIClientTransport.disconnect'); return this.client.disconnect(); diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlock.js b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlock.js index 8ea7095c52f..96321c35db3 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlock.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlock.js @@ -1,6 +1,6 @@ -const logger = require('../../../logger'); +import logger from '../../../logger/index.js'; -module.exports = async function getBestBlock() { +export default async function getBestBlock() { logger.silly('DAPIClientTransport.getBestBlock'); return this.getBlockByHash(await this.getBestBlockHash()); diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlock.spec.js b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlock.spec.js index 0026b712808..c917e344d97 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlock.spec.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlock.spec.js @@ -1,7 +1,8 @@ -const { expect } = require('chai'); -const { Block } = require('@dashevo/dashcore-lib'); +import { expect } from 'chai'; +import dashcore from '@dashevo/dashcore-lib'; +const { Block } = dashcore; -const DAPIClientTransport = require('../DAPIClientTransport'); +import DAPIClientTransport from '../DAPIClientTransport.js'; describe('transports - DAPIClientTransport - .getBestBlock', function suite() { let bestBlockHash; diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlockHash.js b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlockHash.js index 6fdd38fa737..0102668862b 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlockHash.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlockHash.js @@ -1,6 +1,6 @@ -const logger = require('../../../logger'); +import logger from '../../../logger/index.js'; -module.exports = async function getBestBlockHash() { +export default async function getBestBlockHash() { logger.silly('DAPIClientTransport.getBestBlockHash'); return this.client.core.getBestBlockHash(); diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlockHash.spec.js b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlockHash.spec.js index d75034a4462..405e8a6bc08 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlockHash.spec.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlockHash.spec.js @@ -1,6 +1,6 @@ -const { expect } = require('chai'); +import { expect } from 'chai'; -const DAPIClientTransport = require('../DAPIClientTransport'); +import DAPIClientTransport from '../DAPIClientTransport.js'; describe('transports - DAPIClientTransport - .getBestBlockHash', function suite() { let fixture; diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlockHeader.js b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlockHeader.js index 2a81ceb492c..2d08be2eb75 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlockHeader.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlockHeader.js @@ -1,6 +1,6 @@ -const logger = require('../../../logger'); +import logger from '../../../logger/index.js'; -module.exports = async function getBestBlockHeader() { +export default async function getBestBlockHeader() { logger.silly('DAPIClientTransport.getBestBlockHeader'); return this.getBlockHeaderByHash(await this.getBestBlockHash()); diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlockHeader.spec.js b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlockHeader.spec.js index bf034065eee..2d43ba7c306 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlockHeader.spec.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlockHeader.spec.js @@ -1,7 +1,8 @@ -const { expect } = require('chai'); -const { Block } = require('@dashevo/dashcore-lib'); +import { expect } from 'chai'; +import dashcore from '@dashevo/dashcore-lib'; +const { Block } = dashcore; -const DAPIClientTransport = require('../DAPIClientTransport'); +import DAPIClientTransport from '../DAPIClientTransport.js'; describe('transports - DAPIClientTransport - .getBestBlockHeader', function suite() { let bestBlockHash; diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlockHeight.js b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlockHeight.js index e36257f6d15..70710a833be 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlockHeight.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlockHeight.js @@ -1,6 +1,6 @@ -const logger = require('../../../logger'); +import logger from '../../../logger/index.js'; -module.exports = async function getBestBlockHeight() { +export default async function getBestBlockHeight() { logger.silly('DAPIClientTransport.getBestBlockHeight'); return this.client.core.getBestBlockHeight(); diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlockHeight.spec.js b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlockHeight.spec.js index 81d6d505da6..0a866ee5545 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlockHeight.spec.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBestBlockHeight.spec.js @@ -1,8 +1,8 @@ -const { expect } = require('chai'); +import { expect } from 'chai'; -const DAPIClientTransport = require('../DAPIClientTransport'); +import DAPIClientTransport from '../DAPIClientTransport.js'; -const getBlockchainStatus = require('../../FixtureTransport/methods/getBlockchainStatus'); +import getBlockchainStatus from '../../FixtureTransport/methods/getBlockchainStatus.js'; describe('transports - DAPIClientTransport - .getBestBlockHeight', function suite() { let fixture; diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockByHash.js b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockByHash.js index 260fd6fe72f..27a077a2752 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockByHash.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockByHash.js @@ -1,7 +1,8 @@ -const { Block } = require('@dashevo/dashcore-lib'); -const logger = require('../../../logger'); +import dashcore from '@dashevo/dashcore-lib'; +const { Block } = dashcore; +import logger from '../../../logger/index.js'; -module.exports = async function getBlockByHash(blockHash) { +export default async function getBlockByHash(blockHash) { logger.silly(`DAPIClient.getBlockByHash[${blockHash}]`); return new Block(await this.client.core.getBlockByHash(blockHash)); diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockByHash.spec.js b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockByHash.spec.js index bd0a3db723d..3e7f5c255c4 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockByHash.spec.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockByHash.spec.js @@ -1,6 +1,6 @@ -const { expect } = require('chai'); +import { expect } from 'chai'; -const DAPIClientTransport = require('../DAPIClientTransport'); +import DAPIClientTransport from '../DAPIClientTransport.js'; describe('transports - DAPIClientTransport - .getBlockByHash', function suite() { let fixture; diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockByHeight.js b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockByHeight.js index 67323259e2b..52eb1f06b4e 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockByHeight.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockByHeight.js @@ -1,7 +1,8 @@ -const { Block } = require('@dashevo/dashcore-lib'); -const logger = require('../../../logger'); +import dashcore from '@dashevo/dashcore-lib'; +const { Block } = dashcore; +import logger from '../../../logger/index.js'; -module.exports = async function getBlockByHeight(height) { +export default async function getBlockByHeight(height) { logger.silly(`DAPIClient.getBlockByHeight[${height}]`); return new Block(await this.client.core.getBlockByHeight(height)); diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockByHeight.spec.js b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockByHeight.spec.js index de384167ff3..669e3abc56b 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockByHeight.spec.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockByHeight.spec.js @@ -1,6 +1,6 @@ -const { expect } = require('chai'); +import { expect } from 'chai'; -const DAPIClientTransport = require('../DAPIClientTransport'); +import DAPIClientTransport from '../DAPIClientTransport.js'; describe('transports - DAPIClientTransport - .getBlockByHeight', function suite() { let fixture; diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockHeaderByHash.js b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockHeaderByHash.js index 270d79f0b86..6239142a74c 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockHeaderByHash.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockHeaderByHash.js @@ -1,6 +1,6 @@ -const logger = require('../../../logger'); +import logger from '../../../logger/index.js'; -module.exports = async function getBlockHeaderByHash(blockHash) { +export default async function getBlockHeaderByHash(blockHash) { logger.silly(`DAPIClient.getBlockHeaderByHash[${blockHash}]`); return (await this.getBlockByHash(blockHash)).header; diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockHeaderByHash.spec.js b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockHeaderByHash.spec.js index 1c42d4f0f68..98251b1c6b6 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockHeaderByHash.spec.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockHeaderByHash.spec.js @@ -1,6 +1,6 @@ -const { expect } = require('chai'); +import { expect } from 'chai'; -const DAPIClientTransport = require('../DAPIClientTransport'); +import DAPIClientTransport from '../DAPIClientTransport.js'; describe('transports - DAPIClientTransport .getBlockHeaderByHash', function suite() { let fixture; diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockHeaderByHeight.js b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockHeaderByHeight.js index 8be7557c412..cac57da57a4 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockHeaderByHeight.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockHeaderByHeight.js @@ -1,6 +1,6 @@ -const logger = require('../../../logger'); +import logger from '../../../logger/index.js'; -module.exports = async function getBlockHeaderByHeight(blockHeight) { +export default async function getBlockHeaderByHeight(blockHeight) { logger.silly(`DAPIClient.getBlockHeaderByHeight[${blockHeight}]`); return (await this.getBlockByHeight(blockHeight)).header; }; diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockHeaderByHeight.spec.js b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockHeaderByHeight.spec.js index 80679fbc016..d4acc73f5b8 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockHeaderByHeight.spec.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockHeaderByHeight.spec.js @@ -1,6 +1,6 @@ -const { expect } = require('chai'); +import { expect } from 'chai'; -const DAPIClientTransport = require('../DAPIClientTransport'); +import DAPIClientTransport from '../DAPIClientTransport.js'; describe('transports - DAPIClientTransport .getBlockHeaderByHash', function suite() { diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockchainStatus.js b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockchainStatus.js index 44faa64ada8..da72db62acd 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockchainStatus.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockchainStatus.js @@ -1,6 +1,6 @@ -const logger = require('../../../logger'); +import logger from '../../../logger/index.js'; -module.exports = async function getBlockchainStatus() { +export default async function getBlockchainStatus() { logger.silly('DAPIClientTransport.getBlockchainStatus'); return this.client.core.getBlockchainStatus(); diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockchainStatus.spec.js b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockchainStatus.spec.js index 705462a5187..2d3c569a591 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockchainStatus.spec.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getBlockchainStatus.spec.js @@ -1,6 +1,6 @@ -const { expect } = require('chai'); +import { expect } from 'chai'; -const DAPIClientTransport = require('../DAPIClientTransport'); +import DAPIClientTransport from '../DAPIClientTransport.js'; describe('transports - DAPIClientTransport - .getBlockchainStatus', function suite() { let fixture; diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getIdentityByPublicKeyHash.js b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getIdentityByPublicKeyHash.js index 00fa5e1286c..6aa690bed6a 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getIdentityByPublicKeyHash.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getIdentityByPublicKeyHash.js @@ -2,7 +2,7 @@ * @param {Buffer} publicKeyHash * @return {Promise} */ -module.exports = async function getIdentityByPublicKeyHash(publicKeyHash) { +export default async function getIdentityByPublicKeyHash(publicKeyHash) { const response = await this.client.platform.getIdentityByPublicKeyHash( publicKeyHash, ); diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getTransaction.js b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getTransaction.js index 936076c91b4..a6a5d3b604f 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getTransaction.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getTransaction.js @@ -1,13 +1,14 @@ -const { Transaction } = require('@dashevo/dashcore-lib'); -const NotFoundError = require('@dashevo/dapi-client/lib/transport/GrpcTransport/errors/NotFoundError'); -const { is } = require('../../../utils'); -const logger = require('../../../logger'); +import dashcore from '@dashevo/dashcore-lib'; +const { Transaction } = dashcore; +import NotFoundError from '@dashevo/dapi-client/lib/transport/GrpcTransport/errors/NotFoundError.js'; +import { is } from '../../../utils/index.js'; +import logger from '../../../logger/index.js'; /** * @param {string} txid * @returns {Promise} */ -module.exports = async function getTransaction(txid) { +export default async function getTransaction(txid) { logger.silly(`DAPIClient.getTransaction[${txid}]`); if (!is.txid(txid)) { throw new Error(`Received an invalid txid to fetch : ${txid}`); diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getTransaction.spec.js b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getTransaction.spec.js index bb2dea976fc..986ff6558bf 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getTransaction.spec.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/getTransaction.spec.js @@ -1,8 +1,8 @@ -const { expect } = require('chai'); +import { expect } from 'chai'; -const DAPIClientTransport = require('../DAPIClientTransport'); -const NotFoundError = require('@dashevo/dapi-client/lib/transport/GrpcTransport/errors/NotFoundError'); -const GetTransactionResponse = require('@dashevo/dapi-client/lib/methods/core/getTransaction/GetTransactionResponse'); +import DAPIClientTransport from '../DAPIClientTransport.js'; +import NotFoundError from '@dashevo/dapi-client/lib/transport/GrpcTransport/errors/NotFoundError.js'; +import GetTransactionResponse from '@dashevo/dapi-client/lib/methods/core/getTransaction/GetTransactionResponse.js'; describe('transports - DAPIClientTransport .getTransaction', function suite() { let fixture; diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/sendTransaction.js b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/sendTransaction.js index b81da5d505f..a6cb0c62c11 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/sendTransaction.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/sendTransaction.js @@ -1,7 +1,7 @@ -const { is } = require('../../../utils'); -const logger = require('../../../logger'); +import { is } from '../../../utils/index.js'; +import logger from '../../../logger/index.js'; -module.exports = async function sendTransaction(serializedTransaction) { +export default async function sendTransaction(serializedTransaction) { logger.silly('DAPIClientTransport.sendTransaction'); if (!is.string(serializedTransaction)) throw new Error('Received an invalid rawtx'); return this.client.core.broadcastTransaction(Buffer.from(serializedTransaction, 'hex')); diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/subscribeToAddressesTransactions.js b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/subscribeToAddressesTransactions.js index d28726f17ba..477c9d4d772 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/subscribeToAddressesTransactions.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/subscribeToAddressesTransactions.js @@ -1,5 +1,5 @@ -const EVENTS = require('../../../EVENTS'); -const logger = require('../../../logger'); +import EVENTS from '../../../EVENTS.js'; +import logger from '../../../logger/index.js'; // Artifact from previous optimisation made in SyncWorker plugin // Kept for reminder when Bloomfilters @@ -56,7 +56,7 @@ function startExecutor() { }, fastFetchThreshold); } -module.exports = async function subscribeToAddressesTransactions(addressList) { +export default async function subscribeToAddressesTransactions(addressList) { logger.silly(`DAPIClient.subscribeToAddressesTransactions[${addressList}]`); if (!Array.isArray(addressList)) throw new Error('Expected array of addresses'); diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/subscribeToTransactionsWithProofs.js b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/subscribeToTransactionsWithProofs.js index 0f33a7b74f6..77ddd0a090a 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/methods/subscribeToTransactionsWithProofs.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/methods/subscribeToTransactionsWithProofs.js @@ -1,9 +1,11 @@ +import dashcore from '@dashevo/dashcore-lib'; const { - BloomFilter, Address, -} = require('@dashevo/dashcore-lib'); -const logger = require('../../../logger'); + BloomFilter, + Address, +} = dashcore; +import logger from '../../../logger/index.js'; -const { BLOOM_FALSE_POSITIVE_RATE } = require('../../../CONSTANTS'); +import { BLOOM_FALSE_POSITIVE_RATE } from '../../../CONSTANTS.js'; /** * From a given addressList will create and submit a bloomfilter to DAPI @@ -16,7 +18,7 @@ const { BLOOM_FALSE_POSITIVE_RATE } = require('../../../CONSTANTS'); * @return {Promise} */ -module.exports = async function subscribeToTransactionsWithProofs( +export default async function subscribeToTransactionsWithProofs( addressList, opts = { fromBlockHeight: 1, count: 0 }, ) { diff --git a/packages/wallet-lib/src/transport/DAPIClientTransport/utils/getHeightFromMerkleBlockBuffer.js b/packages/wallet-lib/src/transport/DAPIClientTransport/utils/getHeightFromMerkleBlockBuffer.js index e067ca82619..a5bf741d61a 100644 --- a/packages/wallet-lib/src/transport/DAPIClientTransport/utils/getHeightFromMerkleBlockBuffer.js +++ b/packages/wallet-lib/src/transport/DAPIClientTransport/utils/getHeightFromMerkleBlockBuffer.js @@ -1,6 +1,7 @@ +import dashcore from '@dashevo/dashcore-lib'; const { MerkleBlock, -} = require('@dashevo/dashcore-lib'); +} = dashcore; const getHeightFromMerkleBlockBuffer = async (client, merkleBlockBuffer) => { // FIXME: MerkleBlock do not accept hex. @@ -16,4 +17,4 @@ const getHeightFromMerkleBlockBuffer = async (client, merkleBlockBuffer) => { return prevBlockHeight + 1; } }; -module.exports = getHeightFromMerkleBlockBuffer; +export default getHeightFromMerkleBlockBuffer; \ No newline at end of file diff --git a/packages/wallet-lib/src/transport/FixtureTransport/FixtureTransport.js b/packages/wallet-lib/src/transport/FixtureTransport/FixtureTransport.js index d6c98b0c652..1a4a4d8573f 100644 --- a/packages/wallet-lib/src/transport/FixtureTransport/FixtureTransport.js +++ b/packages/wallet-lib/src/transport/FixtureTransport/FixtureTransport.js @@ -1,5 +1,5 @@ -const blocksData = require('./data/blocks/blocks'); -const AbstractTransport = require('../AbstractTransport'); +import blocksData from './data/blocks/blocks.js'; +import AbstractTransport from '../AbstractTransport.js'; const bestBlockDataHeight = 21546; @@ -55,17 +55,29 @@ class FixtureTransport extends AbstractTransport { } } -FixtureTransport.prototype.getBestBlock = require('./methods/getBestBlock'); -FixtureTransport.prototype.getBestBlockHash = require('./methods/getBestBlockHash'); -FixtureTransport.prototype.getBestBlockHeader = require('./methods/getBestBlockHeader'); -FixtureTransport.prototype.getBestBlockHeight = require('./methods/getBestBlockHeight'); -FixtureTransport.prototype.getBlockByHash = require('./methods/getBlockByHash'); -FixtureTransport.prototype.getBlockByHeight = require('./methods/getBlockByHeight'); -FixtureTransport.prototype.getBlockHeaderByHash = require('./methods/getBlockHeaderByHash'); -FixtureTransport.prototype.getBlockHeaderByHeight = require('./methods/getBlockHeaderByHeight'); -FixtureTransport.prototype.getBlockchainStatus = require('./methods/getBlockchainStatus'); -FixtureTransport.prototype.getTransaction = require('./methods/getTransaction'); -FixtureTransport.prototype.sendTransaction = require('./methods/sendTransaction'); -FixtureTransport.prototype.subscribeToAddressesTransactions = require('./methods/subscribeToAddressesTransactions'); +import _FixtureTransport_getBestBlock from './methods/getBestBlock.js'; +FixtureTransport.prototype.getBestBlock = _FixtureTransport_getBestBlock; +import _FixtureTransport_getBestBlockHash from './methods/getBestBlockHash.js'; +FixtureTransport.prototype.getBestBlockHash = _FixtureTransport_getBestBlockHash; +import _FixtureTransport_getBestBlockHeader from './methods/getBestBlockHeader.js'; +FixtureTransport.prototype.getBestBlockHeader = _FixtureTransport_getBestBlockHeader; +import _FixtureTransport_getBestBlockHeight from './methods/getBestBlockHeight.js'; +FixtureTransport.prototype.getBestBlockHeight = _FixtureTransport_getBestBlockHeight; +import _FixtureTransport_getBlockByHash from './methods/getBlockByHash.js'; +FixtureTransport.prototype.getBlockByHash = _FixtureTransport_getBlockByHash; +import _FixtureTransport_getBlockByHeight from './methods/getBlockByHeight.js'; +FixtureTransport.prototype.getBlockByHeight = _FixtureTransport_getBlockByHeight; +import _FixtureTransport_getBlockHeaderByHash from './methods/getBlockHeaderByHash.js'; +FixtureTransport.prototype.getBlockHeaderByHash = _FixtureTransport_getBlockHeaderByHash; +import _FixtureTransport_getBlockHeaderByHeight from './methods/getBlockHeaderByHeight.js'; +FixtureTransport.prototype.getBlockHeaderByHeight = _FixtureTransport_getBlockHeaderByHeight; +import _FixtureTransport_getBlockchainStatus from './methods/getBlockchainStatus.js'; +FixtureTransport.prototype.getBlockchainStatus = _FixtureTransport_getBlockchainStatus; +import _FixtureTransport_getTransaction from './methods/getTransaction.js'; +FixtureTransport.prototype.getTransaction = _FixtureTransport_getTransaction; +import _FixtureTransport_sendTransaction from './methods/sendTransaction.js'; +FixtureTransport.prototype.sendTransaction = _FixtureTransport_sendTransaction; +import _FixtureTransport_subscribeToAddressesTransactions from './methods/subscribeToAddressesTransactions.js'; +FixtureTransport.prototype.subscribeToAddressesTransactions = _FixtureTransport_subscribeToAddressesTransactions; -module.exports = FixtureTransport; +export default FixtureTransport; \ No newline at end of file diff --git a/packages/wallet-lib/src/transport/FixtureTransport/data/blocks/blocks.js b/packages/wallet-lib/src/transport/FixtureTransport/data/blocks/blocks.js index 44b57db171c..1361edeb32f 100644 --- a/packages/wallet-lib/src/transport/FixtureTransport/data/blocks/blocks.js +++ b/packages/wallet-lib/src/transport/FixtureTransport/data/blocks/blocks.js @@ -27,6 +27,11 @@ const hashes = Object.entries(heights).reduce((obj, [height, hash]) => { return obj; }, {}); -module.exports = { +export { + heights, + hashes, +}; + +export default { heights, hashes, }; diff --git a/packages/wallet-lib/src/transport/FixtureTransport/methods/getBestBlock.js b/packages/wallet-lib/src/transport/FixtureTransport/methods/getBestBlock.js index f9525010f63..4e001e5fe68 100644 --- a/packages/wallet-lib/src/transport/FixtureTransport/methods/getBestBlock.js +++ b/packages/wallet-lib/src/transport/FixtureTransport/methods/getBestBlock.js @@ -1,6 +1,6 @@ -const logger = require('../../../logger'); +import logger from '../../../logger/index.js'; -module.exports = async function getBestBlock() { +export default async function getBestBlock() { logger.silly('FakeNet.getBestBlock'); return this.getBlockByHash(await this.getBestBlockHash()); }; diff --git a/packages/wallet-lib/src/transport/FixtureTransport/methods/getBestBlockHash.js b/packages/wallet-lib/src/transport/FixtureTransport/methods/getBestBlockHash.js index 3036e32b8fe..a5b816c9100 100644 --- a/packages/wallet-lib/src/transport/FixtureTransport/methods/getBestBlockHash.js +++ b/packages/wallet-lib/src/transport/FixtureTransport/methods/getBestBlockHash.js @@ -1,3 +1,3 @@ -module.exports = async function getBestBlockHash() { +export default async function getBestBlockHash() { return this.blockHash; }; diff --git a/packages/wallet-lib/src/transport/FixtureTransport/methods/getBestBlockHeader.js b/packages/wallet-lib/src/transport/FixtureTransport/methods/getBestBlockHeader.js index 5b66ae8f700..6fc951aca08 100644 --- a/packages/wallet-lib/src/transport/FixtureTransport/methods/getBestBlockHeader.js +++ b/packages/wallet-lib/src/transport/FixtureTransport/methods/getBestBlockHeader.js @@ -1,6 +1,6 @@ -const logger = require('../../../logger'); +import logger from '../../../logger/index.js'; -module.exports = async function getBestBlockHeader() { +export default async function getBestBlockHeader() { logger.silly('FakeNet.getBestBlockHeader'); return this.getBlockHeaderByHash(await this.getBestBlockHash()); }; diff --git a/packages/wallet-lib/src/transport/FixtureTransport/methods/getBestBlockHeight.js b/packages/wallet-lib/src/transport/FixtureTransport/methods/getBestBlockHeight.js index 496671395fb..8e8fef4f528 100644 --- a/packages/wallet-lib/src/transport/FixtureTransport/methods/getBestBlockHeight.js +++ b/packages/wallet-lib/src/transport/FixtureTransport/methods/getBestBlockHeight.js @@ -1,3 +1,3 @@ -module.exports = async function getBestBlockHeight() { +export default async function getBestBlockHeight() { return this.height; }; diff --git a/packages/wallet-lib/src/transport/FixtureTransport/methods/getBlockByHash.js b/packages/wallet-lib/src/transport/FixtureTransport/methods/getBlockByHash.js index 1865926fd8e..c9bda96a149 100644 --- a/packages/wallet-lib/src/transport/FixtureTransport/methods/getBlockByHash.js +++ b/packages/wallet-lib/src/transport/FixtureTransport/methods/getBlockByHash.js @@ -1,9 +1,14 @@ -const { Block } = require('@dashevo/dashcore-lib'); -const fs = require('fs'); -const blocks = require('../data/blocks/blocks'); +import dashcore from '@dashevo/dashcore-lib'; +const { Block } = dashcore; +import fs from 'fs'; +import path from 'path'; +import { fileURLToPath } from 'url'; +import blocks from '../data/blocks/blocks.js'; -module.exports = async function getBlockByHash(hash) { +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + +export default async function getBlockByHash(hash) { const height = blocks.hashes[hash]; const blockfile = JSON.parse(fs.readFileSync(`${__dirname}/../data/blocks/${height}.json`)); return new Block(Buffer.from(blockfile.block, 'hex')); -}; +} diff --git a/packages/wallet-lib/src/transport/FixtureTransport/methods/getBlockByHeight.js b/packages/wallet-lib/src/transport/FixtureTransport/methods/getBlockByHeight.js index 37b4adf26e2..bc813443add 100644 --- a/packages/wallet-lib/src/transport/FixtureTransport/methods/getBlockByHeight.js +++ b/packages/wallet-lib/src/transport/FixtureTransport/methods/getBlockByHeight.js @@ -1,4 +1,4 @@ -module.exports = async function getBlockByHeight(height) { +export default async function getBlockByHeight(height) { const hash = this.blocks.heights[height]; return this.getBlockByHash(hash); }; diff --git a/packages/wallet-lib/src/transport/FixtureTransport/methods/getBlockHeaderByHash.js b/packages/wallet-lib/src/transport/FixtureTransport/methods/getBlockHeaderByHash.js index 24574389fc2..8439637782b 100644 --- a/packages/wallet-lib/src/transport/FixtureTransport/methods/getBlockHeaderByHash.js +++ b/packages/wallet-lib/src/transport/FixtureTransport/methods/getBlockHeaderByHash.js @@ -1,3 +1,3 @@ -module.exports = async function getBlockHeaderByHash(blockHash) { +export default async function getBlockHeaderByHash(blockHash) { return (await this.getBlockByHash(blockHash)).header; }; diff --git a/packages/wallet-lib/src/transport/FixtureTransport/methods/getBlockHeaderByHeight.js b/packages/wallet-lib/src/transport/FixtureTransport/methods/getBlockHeaderByHeight.js index c7d7c80dde3..423423e8f69 100644 --- a/packages/wallet-lib/src/transport/FixtureTransport/methods/getBlockHeaderByHeight.js +++ b/packages/wallet-lib/src/transport/FixtureTransport/methods/getBlockHeaderByHeight.js @@ -1,3 +1,3 @@ -module.exports = async function getBlockHeaderByHeight(blockHeight) { +export default async function getBlockHeaderByHeight(blockHeight) { return (await this.getBlockByHeight(blockHeight)).header; }; diff --git a/packages/wallet-lib/src/transport/FixtureTransport/methods/getBlockchainStatus.js b/packages/wallet-lib/src/transport/FixtureTransport/methods/getBlockchainStatus.js index eb36aa8e0ad..3015e030f11 100644 --- a/packages/wallet-lib/src/transport/FixtureTransport/methods/getBlockchainStatus.js +++ b/packages/wallet-lib/src/transport/FixtureTransport/methods/getBlockchainStatus.js @@ -1,4 +1,4 @@ -module.exports = async function getBlockchainStatus() { +export default async function getBlockchainStatus() { const { height, relayFee, network } = this; return { diff --git a/packages/wallet-lib/src/transport/FixtureTransport/methods/getTransaction.js b/packages/wallet-lib/src/transport/FixtureTransport/methods/getTransaction.js index 531ff9115bb..786f7deaef7 100644 --- a/packages/wallet-lib/src/transport/FixtureTransport/methods/getTransaction.js +++ b/packages/wallet-lib/src/transport/FixtureTransport/methods/getTransaction.js @@ -1,7 +1,12 @@ -const { Transaction } = require('@dashevo/dashcore-lib'); -const fs = require('fs'); +import dashcore from '@dashevo/dashcore-lib'; +const { Transaction } = dashcore; +import fs from 'fs'; +import path from 'path'; +import { fileURLToPath } from 'url'; -module.exports = async function getTransaction(transactionHash) { +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + +export default async function getTransaction(transactionHash) { const txFile = JSON.parse(fs.readFileSync(`${__dirname}/../data/transactions/${transactionHash}.json`)); return new Transaction(Buffer.from(txFile.transaction, 'hex')); -}; +} diff --git a/packages/wallet-lib/src/transport/FixtureTransport/methods/sendTransaction.js b/packages/wallet-lib/src/transport/FixtureTransport/methods/sendTransaction.js index c481f0dac07..f1e46127352 100644 --- a/packages/wallet-lib/src/transport/FixtureTransport/methods/sendTransaction.js +++ b/packages/wallet-lib/src/transport/FixtureTransport/methods/sendTransaction.js @@ -1,3 +1,3 @@ -module.exports = async function sendTransaction() { +export default async function sendTransaction() { throw new Error('Not yet handled'); }; diff --git a/packages/wallet-lib/src/transport/FixtureTransport/methods/subscribeToAddressesTransactions.js b/packages/wallet-lib/src/transport/FixtureTransport/methods/subscribeToAddressesTransactions.js index c43dc843bd5..a9f7a5d6cf1 100644 --- a/packages/wallet-lib/src/transport/FixtureTransport/methods/subscribeToAddressesTransactions.js +++ b/packages/wallet-lib/src/transport/FixtureTransport/methods/subscribeToAddressesTransactions.js @@ -1,5 +1,5 @@ -const EVENTS = require('../../../EVENTS'); -const logger = require('../../../logger'); +import EVENTS from '../../../EVENTS.js'; +import logger from '../../../logger/index.js'; // Artifact from previous optimisation made in SyncWorker plugin // Kept for reminder when Bloomfilters @@ -49,7 +49,7 @@ function startExecutor() { this.state.executors.addresses = setInterval(() => executor.call(self), fastFetchThreshold); } -module.exports = async function subscribeToAddressesTransactions(addressList) { +export default async function subscribeToAddressesTransactions(addressList) { logger.silly(`FakeNet.subscribeToAddressesTransactions[${addressList}]`); if (!Array.isArray(addressList)) throw new Error('Expected array of addresses'); const { executors, subscriptions, addressesTransactionsMap } = this.state; diff --git a/packages/wallet-lib/src/transport/Transport.d.ts b/packages/wallet-lib/src/transport/Transport.d.ts index 9a9697c8975..dfff635b60f 100644 --- a/packages/wallet-lib/src/transport/Transport.d.ts +++ b/packages/wallet-lib/src/transport/Transport.d.ts @@ -1,4 +1,4 @@ -import {Block, BlockHeader, Transaction} from "@dashevo/dashcore-lib"; +import { Block, BlockHeader, Transaction } from '@dashevo/dashcore-lib'; export declare interface Transport { announce(eventName: string, args: any[]): void diff --git a/packages/wallet-lib/src/transport/createTransportFromOptions.js b/packages/wallet-lib/src/transport/createTransportFromOptions.js index 52ffbde993a..d1c58963dd3 100644 --- a/packages/wallet-lib/src/transport/createTransportFromOptions.js +++ b/packages/wallet-lib/src/transport/createTransportFromOptions.js @@ -1,8 +1,8 @@ -const DAPIClient = require('@dashevo/dapi-client'); +import DAPIClient from '@dashevo/dapi-client'; -const _ = require('lodash'); +import _ from 'lodash'; -const DAPIClientTransport = require('./DAPIClientTransport/DAPIClientTransport'); +import DAPIClientTransport from './DAPIClientTransport/DAPIClientTransport.js'; /** * @@ -20,4 +20,4 @@ function createTransportFromOptions(options) { return new DAPIClientTransport(client); } -module.exports = createTransportFromOptions; +export default createTransportFromOptions; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/Account.d.ts b/packages/wallet-lib/src/types/Account/Account.d.ts index 974440babe9..604fb7b25f8 100644 --- a/packages/wallet-lib/src/types/Account/Account.d.ts +++ b/packages/wallet-lib/src/types/Account/Account.d.ts @@ -13,7 +13,7 @@ import { Plugins, RawTransaction, TransactionsMap, WalletObj, StatusInfo } from "../types"; import { KeyChainStore } from "../KeyChainStore/KeyChainStore" -import { InstantLock } from "@dashevo/dashcore-lib"; +import { InstantLock } from '@dashevo/dashcore-lib'; import { Identities, Wallet} from "../../index"; import { Transport } from "../../transport/Transport"; import { BlockHeader } from "@dashevo/dashcore-lib/typings/block/BlockHeader"; diff --git a/packages/wallet-lib/src/types/Account/Account.js b/packages/wallet-lib/src/types/Account/Account.js index b8240f621b2..7c7ba07ad04 100644 --- a/packages/wallet-lib/src/types/Account/Account.js +++ b/packages/wallet-lib/src/types/Account/Account.js @@ -1,15 +1,15 @@ -const _ = require('lodash'); -const EventEmitter = require('events'); -const logger = require('../../logger'); -const { WALLET_TYPES, BIP44_ADDRESS_GAP } = require('../../CONSTANTS'); -const { is } = require('../../utils'); -const EVENTS = require('../../EVENTS'); -const Wallet = require('../Wallet/Wallet'); -const { simpleDescendingAccumulator } = require('../../utils/coinSelections/strategies'); -const { +import _ from 'lodash'; +import EventEmitter from 'events'; +import logger from '../../logger/index.js'; +import { WALLET_TYPES, BIP44_ADDRESS_GAP } from '../../CONSTANTS.js'; +import { is } from '../../utils/index.js'; +import EVENTS from '../../EVENTS.js'; +import Wallet from '../Wallet/Wallet.js'; +import { simpleDescendingAccumulator } from '../../utils/coinSelections/strategies/index.js'; +import { TxMetadataTimeoutError, InstantLockTimeoutError, -} = require('../../errors'); +} from '../../errors/index.js'; function getNextUnusedAccountIndexForWallet(wallet) { if (wallet && wallet.accounts) { @@ -43,12 +43,12 @@ const defaultOptions = { }; /* eslint-disable no-underscore-dangle */ -const _initializeAccount = require('./_initializeAccount'); -const _addAccountToWallet = require('./_addAccountToWallet'); -const _loadStrategy = require('./_loadStrategy'); +import _initializeAccount from './_initializeAccount.js'; +import _addAccountToWallet from './_addAccountToWallet.js'; +import _loadStrategy from './_loadStrategy.js'; -const getNetwork = require('./_getNetwork'); -const getBIP44Path = require('./_getBIP44Path'); +import getNetwork from './_getNetwork.js'; +import getBIP44Path from './_getBIP44Path.js'; class Account extends EventEmitter { constructor(wallet, opts = defaultOptions) { @@ -401,39 +401,73 @@ class Account extends EventEmitter { } } -Account.prototype.broadcastTransaction = require('./methods/broadcastTransaction'); -Account.prototype.connect = require('./methods/connect'); -Account.prototype.createTransaction = require('./methods/createTransaction'); -Account.prototype.decode = require('./methods/decode'); -Account.prototype.decrypt = require('./methods/decrypt'); -Account.prototype.disconnect = require('./methods/disconnect'); -Account.prototype.encode = require('./methods/encode'); -Account.prototype.encrypt = require('./methods/encrypt'); -Account.prototype.fetchStatus = require('./methods/fetchStatus'); -Account.prototype.forceRefreshAccount = require('./methods/forceRefreshAccount'); -Account.prototype.generateAddress = require('./methods/generateAddress'); -Account.prototype.getAddress = require('./methods/getAddress'); -Account.prototype.getAddresses = require('./methods/getAddresses'); -Account.prototype.getBlockHeader = require('./methods/getBlockHeader'); -Account.prototype.getConfirmedBalance = require('./methods/getConfirmedBalance'); -Account.prototype.getPlugin = require('./methods/getPlugin'); -Account.prototype.getPrivateKeys = require('./methods/getPrivateKeys'); -Account.prototype.getTotalBalance = require('./methods/getTotalBalance'); -Account.prototype.getTransaction = require('./methods/getTransaction'); -Account.prototype.getTransactionHistory = require('./methods/getTransactionHistory'); -Account.prototype.getTransactions = require('./methods/getTransactions'); -Account.prototype.getUnconfirmedBalance = require('./methods/getUnconfirmedBalance'); -Account.prototype.getUnusedAddress = require('./methods/getUnusedAddress'); -Account.prototype.getUnusedIdentityIndex = require('./methods/getUnusedIdentityIndex'); -Account.prototype.getUTXOS = require('./methods/getUTXOS'); -Account.prototype.getWorker = require('./methods/getWorker'); -Account.prototype.hasPlugins = require('./methods/hasPlugins'); -Account.prototype.injectPlugin = require('./methods/injectPlugin'); -Account.prototype.importTransactions = require('./methods/importTransactions'); -Account.prototype.createPathsForTransactions = require('./methods/createPathsForTransactions'); -Account.prototype.generateNewPaths = require('./methods/generateNewPaths'); -Account.prototype.addPathsToStore = require('./methods/addPathsToStore'); -Account.prototype.addDefaultPaths = require('./methods/addDefaultPaths'); -Account.prototype.sign = require('./methods/sign'); - -module.exports = Account; +import _Account_broadcastTransaction from './methods/broadcastTransaction.js'; +Account.prototype.broadcastTransaction = _Account_broadcastTransaction; +import _Account_connect from './methods/connect.js'; +Account.prototype.connect = _Account_connect; +import _Account_createTransaction from './methods/createTransaction.js'; +Account.prototype.createTransaction = _Account_createTransaction; +import _Account_decode from './methods/decode.js'; +Account.prototype.decode = _Account_decode; +import _Account_decrypt from './methods/decrypt.js'; +Account.prototype.decrypt = _Account_decrypt; +import _Account_disconnect from './methods/disconnect.js'; +Account.prototype.disconnect = _Account_disconnect; +import _Account_encode from './methods/encode.js'; +Account.prototype.encode = _Account_encode; +import _Account_encrypt from './methods/encrypt.js'; +Account.prototype.encrypt = _Account_encrypt; +import _Account_fetchStatus from './methods/fetchStatus.js'; +Account.prototype.fetchStatus = _Account_fetchStatus; +import _Account_forceRefreshAccount from './methods/forceRefreshAccount.js'; +Account.prototype.forceRefreshAccount = _Account_forceRefreshAccount; +import _Account_generateAddress from './methods/generateAddress.js'; +Account.prototype.generateAddress = _Account_generateAddress; +import _Account_getAddress from './methods/getAddress.js'; +Account.prototype.getAddress = _Account_getAddress; +import _Account_getAddresses from './methods/getAddresses.js'; +Account.prototype.getAddresses = _Account_getAddresses; +import _Account_getBlockHeader from './methods/getBlockHeader.js'; +Account.prototype.getBlockHeader = _Account_getBlockHeader; +import _Account_getConfirmedBalance from './methods/getConfirmedBalance.js'; +Account.prototype.getConfirmedBalance = _Account_getConfirmedBalance; +import _Account_getPlugin from './methods/getPlugin.js'; +Account.prototype.getPlugin = _Account_getPlugin; +import _Account_getPrivateKeys from './methods/getPrivateKeys.js'; +Account.prototype.getPrivateKeys = _Account_getPrivateKeys; +import _Account_getTotalBalance from './methods/getTotalBalance.js'; +Account.prototype.getTotalBalance = _Account_getTotalBalance; +import _Account_getTransaction from './methods/getTransaction.js'; +Account.prototype.getTransaction = _Account_getTransaction; +import _Account_getTransactionHistory from './methods/getTransactionHistory.js'; +Account.prototype.getTransactionHistory = _Account_getTransactionHistory; +import _Account_getTransactions from './methods/getTransactions.js'; +Account.prototype.getTransactions = _Account_getTransactions; +import _Account_getUnconfirmedBalance from './methods/getUnconfirmedBalance.js'; +Account.prototype.getUnconfirmedBalance = _Account_getUnconfirmedBalance; +import _Account_getUnusedAddress from './methods/getUnusedAddress.js'; +Account.prototype.getUnusedAddress = _Account_getUnusedAddress; +import _Account_getUnusedIdentityIndex from './methods/getUnusedIdentityIndex.js'; +Account.prototype.getUnusedIdentityIndex = _Account_getUnusedIdentityIndex; +import _Account_getUTXOS from './methods/getUTXOS.js'; +Account.prototype.getUTXOS = _Account_getUTXOS; +import _Account_getWorker from './methods/getWorker.js'; +Account.prototype.getWorker = _Account_getWorker; +import _Account_hasPlugins from './methods/hasPlugins.js'; +Account.prototype.hasPlugins = _Account_hasPlugins; +import _Account_injectPlugin from './methods/injectPlugin.js'; +Account.prototype.injectPlugin = _Account_injectPlugin; +import _Account_importTransactions from './methods/importTransactions.js'; +Account.prototype.importTransactions = _Account_importTransactions; +import _Account_createPathsForTransactions from './methods/createPathsForTransactions.js'; +Account.prototype.createPathsForTransactions = _Account_createPathsForTransactions; +import _Account_generateNewPaths from './methods/generateNewPaths.js'; +Account.prototype.generateNewPaths = _Account_generateNewPaths; +import _Account_addPathsToStore from './methods/addPathsToStore.js'; +Account.prototype.addPathsToStore = _Account_addPathsToStore; +import _Account_addDefaultPaths from './methods/addDefaultPaths.js'; +Account.prototype.addDefaultPaths = _Account_addDefaultPaths; +import _Account_sign from './methods/sign.js'; +Account.prototype.sign = _Account_sign; + +export default Account; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/Account.spec.js b/packages/wallet-lib/src/types/Account/Account.spec.js index 8d56e1943f4..7e31421b3cb 100644 --- a/packages/wallet-lib/src/types/Account/Account.spec.js +++ b/packages/wallet-lib/src/types/Account/Account.spec.js @@ -1,16 +1,16 @@ -const { expect } = require('chai'); -const Dashcore = require('@dashevo/dashcore-lib'); -const knifeMnemonic = require('../../../fixtures/knifeeasily'); -const fluidMnemonic = require('../../../fixtures/fluidDepth'); -const cR4t6ePrivateKey = require('../../../fixtures/cR4t6e_pk'); -const { WALLET_TYPES } = require('../../CONSTANTS'); -const { Account, EVENTS } = require('../../index'); -const EventEmitter = require('events'); -const inMem = require('../../adapters/InMem'); -const Storage = require('../Storage/Storage'); -const {mock} = require("sinon"); -const KeyChainStore = require("../KeyChainStore/KeyChainStore"); -const DerivableKeyChain = require("../DerivableKeyChain/DerivableKeyChain"); +import { expect } from 'chai'; +import Dashcore from '@dashevo/dashcore-lib'; +import knifeMnemonic from '../../../fixtures/knifeeasily.json' with { type: 'json' }; +import fluidMnemonic from '../../../fixtures/fluidDepth.json' with { type: 'json' }; +import cR4t6ePrivateKey from '../../../fixtures/cR4t6e_pk.json' with { type: 'json' }; +import { WALLET_TYPES } from '../../CONSTANTS.js'; +import { Account, EVENTS } from '../../index.js'; +import EventEmitter from 'events'; +import inMem from '../../adapters/InMem.js'; +import Storage from '../Storage/Storage.js'; +import {mock} from 'sinon'; +import KeyChainStore from '../KeyChainStore/KeyChainStore.js'; +import DerivableKeyChain from '../DerivableKeyChain/DerivableKeyChain.js'; const blockHeader = new Dashcore.BlockHeader.fromObject({ hash: '00000ac3a0c9df709260e41290d6902e5a4a073099f11fe8c1ce80aadc4bb331', version: 2, diff --git a/packages/wallet-lib/src/types/Account/_addAccountToWallet.js b/packages/wallet-lib/src/types/Account/_addAccountToWallet.js index 935b0c90b48..a63d4747b0d 100644 --- a/packages/wallet-lib/src/types/Account/_addAccountToWallet.js +++ b/packages/wallet-lib/src/types/Account/_addAccountToWallet.js @@ -12,4 +12,4 @@ const _addAccountToWallet = function addAccountToWallet(account, wallet) { wallet.accounts.push(account); } }; -module.exports = _addAccountToWallet; +export default _addAccountToWallet; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/_addAccountToWallet.spec.js b/packages/wallet-lib/src/types/Account/_addAccountToWallet.spec.js index e3e7d6181d7..7a3cb24b93c 100644 --- a/packages/wallet-lib/src/types/Account/_addAccountToWallet.spec.js +++ b/packages/wallet-lib/src/types/Account/_addAccountToWallet.spec.js @@ -1,5 +1,5 @@ -const { expect } = require('chai'); -const addAccountToWallet = require('./_addAccountToWallet'); +import { expect } from 'chai'; +import addAccountToWallet from './_addAccountToWallet.js'; describe('Account - addAccountToWallet', function suite() { this.timeout(10000); diff --git a/packages/wallet-lib/src/types/Account/_getBIP44Path.js b/packages/wallet-lib/src/types/Account/_getBIP44Path.js index b26d039ce84..2db5ceeb8e0 100644 --- a/packages/wallet-lib/src/types/Account/_getBIP44Path.js +++ b/packages/wallet-lib/src/types/Account/_getBIP44Path.js @@ -1,14 +1,14 @@ -const Dashcore = require('@dashevo/dashcore-lib'); -const { +import Dashcore from '@dashevo/dashcore-lib'; +import { BIP44_LIVENET_ROOT_PATH, BIP44_TESTNET_ROOT_PATH, -} = require('../../CONSTANTS'); +} from '../../CONSTANTS.js'; /** * Will return a root account path * @param network - default : 'testnet' * @param accountIndex - default : 0 * @return {string} - BIP44 Path to account */ -module.exports = function getBIP44Path(network, accountIndex = 0) { +export default function getBIP44Path(network, accountIndex = 0) { return (network === Dashcore.Networks.livenet.toString()) ? `${BIP44_LIVENET_ROOT_PATH}/${accountIndex}'` : `${BIP44_TESTNET_ROOT_PATH}/${accountIndex}'`; diff --git a/packages/wallet-lib/src/types/Account/_getBIP44Path.spec.js b/packages/wallet-lib/src/types/Account/_getBIP44Path.spec.js index c744d5a677c..4b23e8f0d5c 100644 --- a/packages/wallet-lib/src/types/Account/_getBIP44Path.spec.js +++ b/packages/wallet-lib/src/types/Account/_getBIP44Path.spec.js @@ -1,5 +1,5 @@ -const { expect } = require('chai'); -const Dashcore = require('@dashevo/dashcore-lib'); +import { expect } from 'chai'; +import Dashcore from '@dashevo/dashcore-lib'; describe('Account - getBIP44Path', () => { diff --git a/packages/wallet-lib/src/types/Account/_getNetwork.js b/packages/wallet-lib/src/types/Account/_getNetwork.js index b3d0ce6a0b5..6cff934b793 100644 --- a/packages/wallet-lib/src/types/Account/_getNetwork.js +++ b/packages/wallet-lib/src/types/Account/_getNetwork.js @@ -1,5 +1,5 @@ -const Dashcore = require('@dashevo/dashcore-lib'); +import Dashcore from '@dashevo/dashcore-lib'; -module.exports = function getNetwork(network) { +export default function getNetwork(network) { return Dashcore.Networks[network].toString() || Dashcore.Networks.testnet.toString(); }; diff --git a/packages/wallet-lib/src/types/Account/_getNetwork.spec.js b/packages/wallet-lib/src/types/Account/_getNetwork.spec.js index 237c2517800..0ed35778b2e 100644 --- a/packages/wallet-lib/src/types/Account/_getNetwork.spec.js +++ b/packages/wallet-lib/src/types/Account/_getNetwork.spec.js @@ -1,5 +1,5 @@ -const { expect } = require('chai'); -const Dashcore = require('@dashevo/dashcore-lib'); +import { expect } from 'chai'; +import Dashcore from '@dashevo/dashcore-lib'; describe('Account - getNetwork', () => { diff --git a/packages/wallet-lib/src/types/Account/_initializeAccount.js b/packages/wallet-lib/src/types/Account/_initializeAccount.js index 65c69b7a207..e2f069b523b 100644 --- a/packages/wallet-lib/src/types/Account/_initializeAccount.js +++ b/packages/wallet-lib/src/types/Account/_initializeAccount.js @@ -1,6 +1,6 @@ -const logger = require('../../logger'); -const EVENTS = require('../../EVENTS'); -const preparePlugins = require('./_preparePlugins'); +import logger from '../../logger/index.js'; +import EVENTS from '../../EVENTS.js'; +import preparePlugins from './_preparePlugins.js'; // eslint-disable-next-line no-underscore-dangle async function _initializeAccount(account, userUnsafePlugins) { @@ -67,4 +67,4 @@ async function _initializeAccount(account, userUnsafePlugins) { }); } -module.exports = _initializeAccount; +export default _initializeAccount; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/_loadStrategy.js b/packages/wallet-lib/src/types/Account/_loadStrategy.js index 8675ec1c60f..3ceef21b08f 100644 --- a/packages/wallet-lib/src/types/Account/_loadStrategy.js +++ b/packages/wallet-lib/src/types/Account/_loadStrategy.js @@ -1,7 +1,7 @@ -const _ = require('lodash'); -const { is } = require('../../utils'); -const { InvalidStrategy, UnknownStrategy } = require('../../errors'); -const buildInStrategies = require('../../utils/coinSelections/strategies'); +import _ from 'lodash'; +import { is } from '../../utils/index.js'; +import { InvalidStrategy, UnknownStrategy } from '../../errors/index.js'; +import buildInStrategies from '../../utils/coinSelections/strategies/index.js'; const fromString = function fromString(strategyName) { if (!_.has(buildInStrategies, strategyName)) return new UnknownStrategy(`Unknown strategy ${strategyName}`); @@ -18,4 +18,4 @@ const _loadStrategy = function _loadStrategy(arg) { throw new InvalidStrategy(arg); }; -module.exports = _loadStrategy; +export default _loadStrategy; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/_preparePlugins.js b/packages/wallet-lib/src/types/Account/_preparePlugins.js index 18138186e52..9007ce68cc8 100644 --- a/packages/wallet-lib/src/types/Account/_preparePlugins.js +++ b/packages/wallet-lib/src/types/Account/_preparePlugins.js @@ -1,6 +1,6 @@ -const Worker = require('../../plugins/Worker'); +import Worker from '../../plugins/Worker.js'; -const sortPlugins = require('./_sortPlugins'); +import sortPlugins from './_sortPlugins.js'; const preparePlugins = function preparePlugins(account, userUnsafePlugins) { return new Promise((resolve, reject) => { @@ -41,4 +41,4 @@ const preparePlugins = function preparePlugins(account, userUnsafePlugins) { }); }; -module.exports = preparePlugins; +export default preparePlugins; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/_sortPlugins.js b/packages/wallet-lib/src/types/Account/_sortPlugins.js index d35cde739c8..588ae3a2191 100644 --- a/packages/wallet-lib/src/types/Account/_sortPlugins.js +++ b/packages/wallet-lib/src/types/Account/_sortPlugins.js @@ -1,9 +1,10 @@ -const { each, findIndex } = require('lodash'); -const TransactionsSyncWorker = require('../../plugins/Workers/TransactionsSyncWorker/TransactionsSyncWorker'); -const BlockHeadersSyncWorker = require('../../plugins/Workers/BlockHeadersSyncWorker/BlockHeadersSyncWorker'); -const ChainPlugin = require('../../plugins/Plugins/ChainPlugin'); -const IdentitySyncWorker = require('../../plugins/Workers/IdentitySyncWorker'); -const { WALLET_TYPES } = require('../../CONSTANTS'); +import lodash from 'lodash'; +const { each, findIndex } = lodash; +import TransactionsSyncWorker from '../../plugins/Workers/TransactionsSyncWorker/TransactionsSyncWorker.js'; +import BlockHeadersSyncWorker from '../../plugins/Workers/BlockHeadersSyncWorker/BlockHeadersSyncWorker.js'; +import ChainPlugin from '../../plugins/Plugins/ChainPlugin.js'; +import IdentitySyncWorker from '../../plugins/Workers/IdentitySyncWorker.js'; +import { WALLET_TYPES } from '../../CONSTANTS.js'; const initPlugin = (UnsafePlugin) => { const isInit = !(typeof UnsafePlugin === 'function'); @@ -139,4 +140,4 @@ const sortPlugins = (account, userUnsafePlugins) => { } return sortUserPlugins(plugins, userUnsafePlugins, account.allowSensitiveOperations); }; -module.exports = sortPlugins; +export default sortPlugins; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/_sortPlugins.spec.js b/packages/wallet-lib/src/types/Account/_sortPlugins.spec.js index 1e697406934..6a0730c5c3f 100644 --- a/packages/wallet-lib/src/types/Account/_sortPlugins.spec.js +++ b/packages/wallet-lib/src/types/Account/_sortPlugins.spec.js @@ -1,13 +1,13 @@ -const {expect} = require('chai'); -const {WALLET_TYPES} = require('../../CONSTANTS'); -const sortPlugins = require('./_sortPlugins'); +import {expect} from 'chai'; +import {WALLET_TYPES} from '../../CONSTANTS.js'; +import sortPlugins from './_sortPlugins.js'; -const TransactionsSyncWorker = require('../../plugins/Workers/TransactionsSyncWorker/TransactionsSyncWorker'); -const BlockHeadersSyncWorker = require('../../plugins/Workers/BlockHeadersSyncWorker/BlockHeadersSyncWorker'); -const ChainPlugin = require('../../plugins/Plugins/ChainPlugin'); -const IdentitySyncWorker = require('../../plugins/Workers/IdentitySyncWorker'); +import TransactionsSyncWorker from '../../plugins/Workers/TransactionsSyncWorker/TransactionsSyncWorker.js'; +import BlockHeadersSyncWorker from '../../plugins/Workers/BlockHeadersSyncWorker/BlockHeadersSyncWorker.js'; +import ChainPlugin from '../../plugins/Plugins/ChainPlugin.js'; +import IdentitySyncWorker from '../../plugins/Workers/IdentitySyncWorker.js'; -const Worker = require('./../../plugins/Worker'); +import Worker from './../../plugins/Worker.js'; class dummyWorker extends Worker { constructor() { diff --git a/packages/wallet-lib/src/types/Account/methods/addDefaultPaths.js b/packages/wallet-lib/src/types/Account/methods/addDefaultPaths.js index f9428ce0158..ffe72362081 100644 --- a/packages/wallet-lib/src/types/Account/methods/addDefaultPaths.js +++ b/packages/wallet-lib/src/types/Account/methods/addDefaultPaths.js @@ -10,4 +10,4 @@ function addDefaultPaths() { this.addPathsToStore(defaultPaths, true); } -module.exports = addDefaultPaths; +export default addDefaultPaths; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/addPathsToStore.js b/packages/wallet-lib/src/types/Account/methods/addPathsToStore.js index d8bd5e5146c..d20b7820712 100644 --- a/packages/wallet-lib/src/types/Account/methods/addPathsToStore.js +++ b/packages/wallet-lib/src/types/Account/methods/addPathsToStore.js @@ -17,4 +17,4 @@ function addPathsToStore(paths, refreshUTXOState = true) { }); } -module.exports = addPathsToStore; +export default addPathsToStore; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/broadcastTransaction.js b/packages/wallet-lib/src/types/Account/methods/broadcastTransaction.js index 814b311e594..eb3e899fea7 100644 --- a/packages/wallet-lib/src/types/Account/methods/broadcastTransaction.js +++ b/packages/wallet-lib/src/types/Account/methods/broadcastTransaction.js @@ -1,13 +1,13 @@ -const Dashcore = require('@dashevo/dashcore-lib'); -const { is } = require('../../../utils'); -const { +import Dashcore from '@dashevo/dashcore-lib'; +import { is } from '../../../utils/index.js'; +import { ValidTransportLayerRequired, InvalidRawTransaction, InvalidDashcoreTransaction, -} = require('../../../errors'); -const EVENTS = require('../../../EVENTS'); -const MempoolPropagationTimeoutError = require('../../../errors/MempoolPropagationTimeoutError'); -const sleep = require('../../../utils/sleep'); +} from '../../../errors/index.js'; +import EVENTS from '../../../EVENTS.js'; +import MempoolPropagationTimeoutError from '../../../errors/MempoolPropagationTimeoutError.js'; +import sleep from '../../../utils/sleep.js'; const MEMPOOL_PROPAGATION_TIMEOUT = 360000; @@ -197,4 +197,4 @@ async function broadcastTransaction(transaction, options = { return transaction.hash; } -module.exports = broadcastTransaction; +export default broadcastTransaction; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/broadcastTransaction.spec.js b/packages/wallet-lib/src/types/Account/methods/broadcastTransaction.spec.js index 3f10f097e35..e3c9d7ed63c 100644 --- a/packages/wallet-lib/src/types/Account/methods/broadcastTransaction.spec.js +++ b/packages/wallet-lib/src/types/Account/methods/broadcastTransaction.spec.js @@ -1,13 +1,15 @@ -const { expect } = require('chai'); -const EventEmitter = require('events'); -const Dashcore = require('@dashevo/dashcore-lib'); - -const broadcastTransaction = require('./broadcastTransaction'); -const EVENTS = require('../../../EVENTS'); -const validRawTxs = require('../../../../fixtures/rawtx').valid; -const invalidRawTxs = require('../../../../fixtures/rawtx').invalid; -const MempoolPropagationTimeoutError = require('../../../errors/MempoolPropagationTimeoutError'); -const ChainStore = require('../../ChainStore/ChainStore'); +import { expect } from 'chai'; +import EventEmitter from 'events'; +import Dashcore from '@dashevo/dashcore-lib'; + +import broadcastTransaction from './broadcastTransaction.js'; +import EVENTS from '../../../EVENTS.js'; +import rawTxs from '../../../../fixtures/rawtx.json' with { type: 'json' }; + +const validRawTxs = rawTxs.valid; +const invalidRawTxs = rawTxs.invalid; +import MempoolPropagationTimeoutError from '../../../errors/MempoolPropagationTimeoutError.js'; +import ChainStore from '../../ChainStore/ChainStore.js'; const { PrivateKey } = Dashcore; describe('Account - broadcastTransaction', function suite() { diff --git a/packages/wallet-lib/src/types/Account/methods/connect.js b/packages/wallet-lib/src/types/Account/methods/connect.js index 725a98d5a2a..c88649c0c1a 100644 --- a/packages/wallet-lib/src/types/Account/methods/connect.js +++ b/packages/wallet-lib/src/types/Account/methods/connect.js @@ -2,7 +2,7 @@ * This method will connect to all streams and workers available * @return {Boolean} */ -module.exports = function connect() { +export default function connect() { if (this.transport && this.transport.connect) { this.transport.connect(); } diff --git a/packages/wallet-lib/src/types/Account/methods/connect.spec.js b/packages/wallet-lib/src/types/Account/methods/connect.spec.js index 20200747c59..b1a53998b42 100644 --- a/packages/wallet-lib/src/types/Account/methods/connect.spec.js +++ b/packages/wallet-lib/src/types/Account/methods/connect.spec.js @@ -1,6 +1,6 @@ -const { expect } = require('chai'); -const connect = require('./connect'); -const DummyWorker = require('../../../../fixtures/DummyWorker'); +import { expect } from 'chai'; +import connect from './connect.js'; +import DummyWorker from '../../../../fixtures/DummyWorker.js'; let transportConnected = false; const emitted = []; diff --git a/packages/wallet-lib/src/types/Account/methods/createPathsForTransactions.js b/packages/wallet-lib/src/types/Account/methods/createPathsForTransactions.js index 22fb045aae8..d8d7d5ab126 100644 --- a/packages/wallet-lib/src/types/Account/methods/createPathsForTransactions.js +++ b/packages/wallet-lib/src/types/Account/methods/createPathsForTransactions.js @@ -1,4 +1,4 @@ -const sortTransactions = require('../../../utils/sortTransactions'); +import sortTransactions from '../../../utils/sortTransactions.js'; /** * Function goes through all transactions, and ensures address gap @@ -35,4 +35,4 @@ function createPathsForTransactions() { }); } -module.exports = createPathsForTransactions; +export default createPathsForTransactions; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/createTransaction.js b/packages/wallet-lib/src/types/Account/methods/createTransaction.js index 71334ed4be5..e0a83a218b8 100644 --- a/packages/wallet-lib/src/types/Account/methods/createTransaction.js +++ b/packages/wallet-lib/src/types/Account/methods/createTransaction.js @@ -1,11 +1,16 @@ /* eslint-disable no-underscore-dangle */ -const _ = require('lodash'); +import _ from 'lodash'; +import dashcore from '@dashevo/dashcore-lib'; const { - Transaction, PrivateKey, HDPrivateKey, crypto, Script, -} = require('@dashevo/dashcore-lib'); -const { CreateTransactionError } = require('../../../errors'); -const { dashToDuffs, coinSelection, is } = require('../../../utils'); -const _loadStrategy = require('../_loadStrategy'); + Transaction, + PrivateKey, + HDPrivateKey, + crypto, + Script, +} = dashcore; +import { CreateTransactionError } from '../../../errors/index.js'; +import { dashToDuffs, coinSelection, is } from '../../../utils/index.js'; +import _loadStrategy from '../_loadStrategy.js'; const parseUtxos = (utxos) => { // We do not allow mixmatch types (output, object together) utxo list @@ -128,4 +133,4 @@ function createTransaction(opts = {}) { } } -module.exports = createTransaction; +export default createTransaction; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/createTransaction.spec.js b/packages/wallet-lib/src/types/Account/methods/createTransaction.spec.js index 23b457fb988..5c63fd089ff 100644 --- a/packages/wallet-lib/src/types/Account/methods/createTransaction.spec.js +++ b/packages/wallet-lib/src/types/Account/methods/createTransaction.spec.js @@ -1,20 +1,21 @@ -const _ = require('lodash'); -const { expect } = require('chai'); -const { HDPrivateKey, Transaction } = require('@dashevo/dashcore-lib'); +import _ from 'lodash'; +import { expect } from 'chai'; +import dashcore from '@dashevo/dashcore-lib'; +const { HDPrivateKey, Transaction } = dashcore; -const createTransaction = require('./createTransaction'); -const FixtureTransport = require('../../../transport/FixtureTransport/FixtureTransport'); +import createTransaction from './createTransaction.js'; +import FixtureTransport from '../../../transport/FixtureTransport/FixtureTransport.js'; -const getUTXOS = require('./getUTXOS'); -const getPrivateKeys = require('./getPrivateKeys'); -const getUnusedAddress = require('./getUnusedAddress'); +import getUTXOS from './getUTXOS.js'; +import getPrivateKeys from './getPrivateKeys.js'; +import getUnusedAddress from './getUnusedAddress.js'; -const getFixtureHDAccountWithStorage = require('../../../../fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage'); +import getFixtureHDAccountWithStorage from '../../../../fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage.js'; -const addressesFixtures = require('../../../../fixtures/addresses.json'); -const fixtureUTXOS = require('../../../transport/FixtureTransport/data/utxos/yQ1fb64aeLfgqFKyeV9Hg9KTaTq5ehHm22.json'); +import addressesFixtures from '../../../../fixtures/addresses.json' with { type: 'json' }; +import fixtureUTXOS from '../../../transport/FixtureTransport/data/utxos/yQ1fb64aeLfgqFKyeV9Hg9KTaTq5ehHm22.json' with { type: 'json' }; -const craftedGenerousMinerStrategy = require('../../../../fixtures/strategies/craftedGenerousMinerStrategy'); +import craftedGenerousMinerStrategy from '../../../../fixtures/strategies/craftedGenerousMinerStrategy.js'; describe('Account - createTransaction', function suite() { this.timeout(10000); diff --git a/packages/wallet-lib/src/types/Account/methods/decode.js b/packages/wallet-lib/src/types/Account/methods/decode.js index bc0b692a54c..19a07f9c386 100644 --- a/packages/wallet-lib/src/types/Account/methods/decode.js +++ b/packages/wallet-lib/src/types/Account/methods/decode.js @@ -1,4 +1,4 @@ -const cbor = require('cbor'); +import cbor from 'cbor'; /** * Allow to decode an input @@ -13,4 +13,4 @@ const decode = function decode(method, data) { return cbor.decodeFirstSync(data); } }; -module.exports = decode; +export default decode; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/decode.spec.js b/packages/wallet-lib/src/types/Account/methods/decode.spec.js index 50b23e10594..eb9bf251940 100644 --- a/packages/wallet-lib/src/types/Account/methods/decode.spec.js +++ b/packages/wallet-lib/src/types/Account/methods/decode.spec.js @@ -1,6 +1,6 @@ -const { expect } = require('chai'); -const cbor = require('cbor'); -const decode = require('./decode'); +import { expect } from 'chai'; +import cbor from 'cbor'; +import decode from './decode.js'; describe('Account - decode', function suite() { this.timeout(10000); diff --git a/packages/wallet-lib/src/types/Account/methods/decrypt.js b/packages/wallet-lib/src/types/Account/methods/decrypt.js index 108ab58c589..ecb197da563 100644 --- a/packages/wallet-lib/src/types/Account/methods/decrypt.js +++ b/packages/wallet-lib/src/types/Account/methods/decrypt.js @@ -1,4 +1,4 @@ -const CryptoJS = require('crypto-js'); +import CryptoJS from 'crypto-js'; const { AES } = CryptoJS; /** @@ -16,4 +16,4 @@ const decrypt = function decrypt(method, data, secret, encoding = '') { return (encoding === 'hex') ? decrypted.toString(CryptoJS.enc.Hex) : decrypted.toString(CryptoJS.enc.Utf8); } }; -module.exports = decrypt; +export default decrypt; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/decrypt.spec.js b/packages/wallet-lib/src/types/Account/methods/decrypt.spec.js index 5f42bf099f3..0e4c2ead0a4 100644 --- a/packages/wallet-lib/src/types/Account/methods/decrypt.spec.js +++ b/packages/wallet-lib/src/types/Account/methods/decrypt.spec.js @@ -1,6 +1,6 @@ -const { expect } = require('chai'); -const cbor = require('cbor'); -const decrypt = require('./decrypt'); +import { expect } from 'chai'; +import cbor from 'cbor'; +import decrypt from './decrypt.js'; const jsonObject = { string: 'string', diff --git a/packages/wallet-lib/src/types/Account/methods/disconnect.js b/packages/wallet-lib/src/types/Account/methods/disconnect.js index c60edef6af6..d5a3d2e9a74 100644 --- a/packages/wallet-lib/src/types/Account/methods/disconnect.js +++ b/packages/wallet-lib/src/types/Account/methods/disconnect.js @@ -4,7 +4,7 @@ * You want to use this method at the end of your life cycle of this lib. * @return {Promise} */ -module.exports = async function disconnect() { +export default async function disconnect() { this.isDisconnecting = true; if (this.transport && this.transport.disconnect) { await this.transport.disconnect(); diff --git a/packages/wallet-lib/src/types/Account/methods/disconnect.spec.js b/packages/wallet-lib/src/types/Account/methods/disconnect.spec.js index 8d924759413..d15aaf7edb5 100644 --- a/packages/wallet-lib/src/types/Account/methods/disconnect.spec.js +++ b/packages/wallet-lib/src/types/Account/methods/disconnect.spec.js @@ -1,7 +1,7 @@ -const { expect } = require('chai'); -const connect = require('./connect'); -const disconnect = require('./disconnect'); -const DummyWorker = require('../../../../fixtures/DummyWorker'); +import { expect } from 'chai'; +import connect from './connect.js'; +import disconnect from './disconnect.js'; +import DummyWorker from '../../../../fixtures/DummyWorker.js'; let transportConnected = false; const emitted = []; diff --git a/packages/wallet-lib/src/types/Account/methods/encode.js b/packages/wallet-lib/src/types/Account/methods/encode.js index e1991f84bcc..d5055935e52 100644 --- a/packages/wallet-lib/src/types/Account/methods/encode.js +++ b/packages/wallet-lib/src/types/Account/methods/encode.js @@ -1,4 +1,4 @@ -const cbor = require('cbor'); +import cbor from 'cbor'; /** * Allow to canonical encode an input @@ -12,4 +12,4 @@ const encode = function encode(method, data) { return cbor.encodeCanonical(data); } }; -module.exports = encode; +export default encode; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/encode.spec.js b/packages/wallet-lib/src/types/Account/methods/encode.spec.js index e8f2c2fc660..96d2904740e 100644 --- a/packages/wallet-lib/src/types/Account/methods/encode.spec.js +++ b/packages/wallet-lib/src/types/Account/methods/encode.spec.js @@ -1,6 +1,6 @@ -const { expect } = require('chai'); -const cbor = require('cbor'); -const encode = require('./encode'); +import { expect } from 'chai'; +import cbor from 'cbor'; +import encode from './encode.js'; describe('Account - encode', function suite() { this.timeout(10000); diff --git a/packages/wallet-lib/src/types/Account/methods/encrypt.js b/packages/wallet-lib/src/types/Account/methods/encrypt.js index b66e66c2874..ebb2ae39b11 100644 --- a/packages/wallet-lib/src/types/Account/methods/encrypt.js +++ b/packages/wallet-lib/src/types/Account/methods/encrypt.js @@ -1,4 +1,4 @@ -const AES = require('crypto-js/aes'); +import AES from 'crypto-js/aes.js'; const encrypt = function encrypt(method, data, secret) { const str = typeof data === 'string' ? data : data.toString(); @@ -7,4 +7,4 @@ const encrypt = function encrypt(method, data, secret) { return AES.encrypt(str, secret).toString(); } }; -module.exports = encrypt; +export default encrypt; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/encrypt.spec.js b/packages/wallet-lib/src/types/Account/methods/encrypt.spec.js index facc317ea96..54fe26e7a4d 100644 --- a/packages/wallet-lib/src/types/Account/methods/encrypt.spec.js +++ b/packages/wallet-lib/src/types/Account/methods/encrypt.spec.js @@ -1,6 +1,6 @@ -const { expect } = require('chai'); -const CryptoJS = require('crypto-js'); -const { Wallet } = require('../../../index'); +import { expect } from 'chai'; +import CryptoJS from 'crypto-js'; +import { Wallet } from '../../../index.js'; const derivationPath = "m/44'/1'/0'/0"; diff --git a/packages/wallet-lib/src/types/Account/methods/fetchStatus.js b/packages/wallet-lib/src/types/Account/methods/fetchStatus.js index 9299f3d6e51..3d722f3192f 100644 --- a/packages/wallet-lib/src/types/Account/methods/fetchStatus.js +++ b/packages/wallet-lib/src/types/Account/methods/fetchStatus.js @@ -1,4 +1,4 @@ -const { ValidTransportLayerRequired } = require('../../../errors'); +import { ValidTransportLayerRequired } from '../../../errors/index.js'; /** * @return {Promise} status @@ -11,4 +11,4 @@ async function fetchStatus() { return this.transport.getBlockchainStatus(); } -module.exports = fetchStatus; +export default fetchStatus; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/fetchStatus.spec.js b/packages/wallet-lib/src/types/Account/methods/fetchStatus.spec.js index 6c9d2de1b5a..b4d5f585ceb 100644 --- a/packages/wallet-lib/src/types/Account/methods/fetchStatus.spec.js +++ b/packages/wallet-lib/src/types/Account/methods/fetchStatus.spec.js @@ -1,5 +1,5 @@ -const { expect } = require('chai'); -const Dashcore = require('@dashevo/dashcore-lib'); +import { expect } from 'chai'; +import Dashcore from '@dashevo/dashcore-lib'; describe('Account - fetchStatus', () => { diff --git a/packages/wallet-lib/src/types/Account/methods/forceRefreshAccount.js b/packages/wallet-lib/src/types/Account/methods/forceRefreshAccount.js index d7b231fd5cf..b6d93efa914 100644 --- a/packages/wallet-lib/src/types/Account/methods/forceRefreshAccount.js +++ b/packages/wallet-lib/src/types/Account/methods/forceRefreshAccount.js @@ -13,4 +13,4 @@ function forceRefreshAccount() { }); return true; } -module.exports = forceRefreshAccount; +export default forceRefreshAccount; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/forceRefreshAccount.spec.js b/packages/wallet-lib/src/types/Account/methods/forceRefreshAccount.spec.js index 4c942fe9d36..955a6f5566d 100644 --- a/packages/wallet-lib/src/types/Account/methods/forceRefreshAccount.spec.js +++ b/packages/wallet-lib/src/types/Account/methods/forceRefreshAccount.spec.js @@ -1,5 +1,5 @@ -const { expect } = require('chai'); -const Dashcore = require('@dashevo/dashcore-lib'); +import { expect } from 'chai'; +import Dashcore from '@dashevo/dashcore-lib'; describe('Account - forceRefreshAccount', () => { diff --git a/packages/wallet-lib/src/types/Account/methods/generateAddress.js b/packages/wallet-lib/src/types/Account/methods/generateAddress.js index 6d19109c108..9aebec2fc06 100644 --- a/packages/wallet-lib/src/types/Account/methods/generateAddress.js +++ b/packages/wallet-lib/src/types/Account/methods/generateAddress.js @@ -1,6 +1,6 @@ -const EVENTS = require('../../../EVENTS'); -const { WALLET_TYPES } = require('../../../CONSTANTS'); -const { is } = require('../../../utils'); +import EVENTS from '../../../EVENTS.js'; +import { WALLET_TYPES } from '../../../CONSTANTS.js'; +import { is } from '../../../utils/index.js'; /** * Generate an address from a path and import it to the store @@ -91,4 +91,4 @@ function generateAddress(path, isWatchedAddress = true) { return addressData; } -module.exports = generateAddress; +export default generateAddress; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/generateAddress.spec.js b/packages/wallet-lib/src/types/Account/methods/generateAddress.spec.js index 79c73c2598e..1a51f7ef86e 100644 --- a/packages/wallet-lib/src/types/Account/methods/generateAddress.spec.js +++ b/packages/wallet-lib/src/types/Account/methods/generateAddress.spec.js @@ -1,5 +1,5 @@ -const { expect } = require('chai'); -const Dashcore = require('@dashevo/dashcore-lib'); +import { expect } from 'chai'; +import Dashcore from '@dashevo/dashcore-lib'; describe('Account - generateAddress', () => { diff --git a/packages/wallet-lib/src/types/Account/methods/generateNewPaths.js b/packages/wallet-lib/src/types/Account/methods/generateNewPaths.js index b43ad7362f6..a9adbbc702a 100644 --- a/packages/wallet-lib/src/types/Account/methods/generateNewPaths.js +++ b/packages/wallet-lib/src/types/Account/methods/generateNewPaths.js @@ -18,4 +18,4 @@ function generateNewPaths(addresses) { return issuedPaths; } -module.exports = generateNewPaths; +export default generateNewPaths; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/getAddress.js b/packages/wallet-lib/src/types/Account/methods/getAddress.js index b4400635a07..77efa6df2a9 100644 --- a/packages/wallet-lib/src/types/Account/methods/getAddress.js +++ b/packages/wallet-lib/src/types/Account/methods/getAddress.js @@ -1,4 +1,4 @@ -const { WALLET_TYPES } = require('../../../CONSTANTS'); +import { WALLET_TYPES } from '../../../CONSTANTS.js'; /** * Get a specific address based on the index and type of address. @@ -23,4 +23,4 @@ function getAddress(addressIndex = 0, addressType = 'external') { ...chainStore.getAddress(address), }; } -module.exports = getAddress; +export default getAddress; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/getAddress.spec.js b/packages/wallet-lib/src/types/Account/methods/getAddress.spec.js index e002c622f26..46c4dfe771d 100644 --- a/packages/wallet-lib/src/types/Account/methods/getAddress.spec.js +++ b/packages/wallet-lib/src/types/Account/methods/getAddress.spec.js @@ -1,5 +1,5 @@ -const { expect } = require('chai'); -const Dashcore = require('@dashevo/dashcore-lib'); +import { expect } from 'chai'; +import Dashcore from '@dashevo/dashcore-lib'; describe('Account - getAddress', () => { diff --git a/packages/wallet-lib/src/types/Account/methods/getAddresses.js b/packages/wallet-lib/src/types/Account/methods/getAddresses.js index 6d957f63d61..6ab98066e8d 100644 --- a/packages/wallet-lib/src/types/Account/methods/getAddresses.js +++ b/packages/wallet-lib/src/types/Account/methods/getAddresses.js @@ -1,4 +1,4 @@ -const { WALLET_TYPES } = require('../../../CONSTANTS'); +import { WALLET_TYPES } from '../../../CONSTANTS.js'; /** * Get all the addresses from the store from a given type @@ -34,4 +34,4 @@ function getAddresses(addressType = 'external') { return typedAddresses; } -module.exports = getAddresses; +export default getAddresses; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/getAddresses.spec.js b/packages/wallet-lib/src/types/Account/methods/getAddresses.spec.js index a3512b5ca7c..5899c4bbe29 100644 --- a/packages/wallet-lib/src/types/Account/methods/getAddresses.spec.js +++ b/packages/wallet-lib/src/types/Account/methods/getAddresses.spec.js @@ -1,5 +1,5 @@ -const { expect } = require('chai'); -const Dashcore = require('@dashevo/dashcore-lib'); +import { expect } from 'chai'; +import Dashcore from '@dashevo/dashcore-lib'; describe('Account - getAddresses', () => { diff --git a/packages/wallet-lib/src/types/Account/methods/getBlockHeader.js b/packages/wallet-lib/src/types/Account/methods/getBlockHeader.js index 638beff2b65..325ff5946bf 100644 --- a/packages/wallet-lib/src/types/Account/methods/getBlockHeader.js +++ b/packages/wallet-lib/src/types/Account/methods/getBlockHeader.js @@ -1,4 +1,4 @@ -const { is } = require('../../../utils'); +import { is } from '../../../utils/index.js'; /** * Get a getBlockHeader from a provided block hash or block height @@ -17,4 +17,4 @@ async function getBlockHeader(identifier) { return blockHeader; } -module.exports = getBlockHeader; +export default getBlockHeader; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/getConfirmedBalance.js b/packages/wallet-lib/src/types/Account/methods/getConfirmedBalance.js index 158ca50f02e..22194c923a8 100644 --- a/packages/wallet-lib/src/types/Account/methods/getConfirmedBalance.js +++ b/packages/wallet-lib/src/types/Account/methods/getConfirmedBalance.js @@ -1,4 +1,4 @@ -const { duffsToDash, calculateDuffBalance } = require('../../../utils'); +import { duffsToDash, calculateDuffBalance } from '../../../utils/index.js'; /** * Return the confirmed balance of an account. @@ -17,4 +17,4 @@ function getConfirmedBalance(displayDuffs = true) { return (displayDuffs) ? totalSat : duffsToDash(totalSat); } -module.exports = getConfirmedBalance; +export default getConfirmedBalance; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/getConfirmedBalance.spec.js b/packages/wallet-lib/src/types/Account/methods/getConfirmedBalance.spec.js index 0c0c0e0d294..4f72a8e3830 100644 --- a/packages/wallet-lib/src/types/Account/methods/getConfirmedBalance.spec.js +++ b/packages/wallet-lib/src/types/Account/methods/getConfirmedBalance.spec.js @@ -1,8 +1,8 @@ -const { expect } = require('chai'); -const getTotalBalance = require('./getTotalBalance'); -const getConfirmedBalance = require('./getConfirmedBalance'); -const getUnconfirmedBalance = require('./getUnconfirmedBalance'); -const getFixtureHDAccountWithStorage = require("../../../../fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage"); +import { expect } from 'chai'; +import getTotalBalance from './getTotalBalance.js'; +import getConfirmedBalance from './getConfirmedBalance.js'; +import getUnconfirmedBalance from './getUnconfirmedBalance.js'; +import getFixtureHDAccountWithStorage from '../../../../fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage.js'; let mockedAccount; diff --git a/packages/wallet-lib/src/types/Account/methods/getPlugin.js b/packages/wallet-lib/src/types/Account/methods/getPlugin.js index 001e3467fff..3f4485473ef 100644 --- a/packages/wallet-lib/src/types/Account/methods/getPlugin.js +++ b/packages/wallet-lib/src/types/Account/methods/getPlugin.js @@ -1,6 +1,6 @@ -const { +import { UnknownPlugin, -} = require('../../../errors'); +} from '../../../errors/index.js'; /** * Get a plugin by name * @param {string} pluginName @@ -14,4 +14,4 @@ function getPlugin(pluginName) { } throw new UnknownPlugin(loweredPluginName); } -module.exports = getPlugin; +export default getPlugin; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/getPlugin.spec.js b/packages/wallet-lib/src/types/Account/methods/getPlugin.spec.js index 1b77525575e..50ebb8b66a5 100644 --- a/packages/wallet-lib/src/types/Account/methods/getPlugin.spec.js +++ b/packages/wallet-lib/src/types/Account/methods/getPlugin.spec.js @@ -1,5 +1,5 @@ -const { expect } = require('chai'); -const Dashcore = require('@dashevo/dashcore-lib'); +import { expect } from 'chai'; +import Dashcore from '@dashevo/dashcore-lib'; describe('Account - getPlugin', () => { diff --git a/packages/wallet-lib/src/types/Account/methods/getPrivateKeys.js b/packages/wallet-lib/src/types/Account/methods/getPrivateKeys.js index f7a068f8e17..7f938f9a177 100644 --- a/packages/wallet-lib/src/types/Account/methods/getPrivateKeys.js +++ b/packages/wallet-lib/src/types/Account/methods/getPrivateKeys.js @@ -23,4 +23,4 @@ function getPrivateKeys(addressList) { return privKeys; } -module.exports = getPrivateKeys; +export default getPrivateKeys; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/getPrivateKeys.spec.js b/packages/wallet-lib/src/types/Account/methods/getPrivateKeys.spec.js index 2143aab6f90..f27bf5a9504 100644 --- a/packages/wallet-lib/src/types/Account/methods/getPrivateKeys.spec.js +++ b/packages/wallet-lib/src/types/Account/methods/getPrivateKeys.spec.js @@ -1,5 +1,5 @@ -const { expect } = require('chai'); -const Dashcore = require('@dashevo/dashcore-lib'); +import { expect } from 'chai'; +import Dashcore from '@dashevo/dashcore-lib'; describe('Account - getPrivateKeys', () => { diff --git a/packages/wallet-lib/src/types/Account/methods/getTotalBalance.js b/packages/wallet-lib/src/types/Account/methods/getTotalBalance.js index 9c0161549d6..84a85dd3c98 100644 --- a/packages/wallet-lib/src/types/Account/methods/getTotalBalance.js +++ b/packages/wallet-lib/src/types/Account/methods/getTotalBalance.js @@ -1,4 +1,4 @@ -const { duffsToDash, calculateDuffBalance } = require('../../../utils'); +import { duffsToDash, calculateDuffBalance } from '../../../utils/index.js'; /** * Return the total balance of an account (confirmed + unconfirmed). @@ -18,4 +18,4 @@ function getTotalBalance(displayDuffs = true) { return (displayDuffs) ? totalSat : duffsToDash(totalSat); } -module.exports = getTotalBalance; +export default getTotalBalance; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/getTotalBalance.spec.js b/packages/wallet-lib/src/types/Account/methods/getTotalBalance.spec.js index 443e93a2fa9..e46932716df 100644 --- a/packages/wallet-lib/src/types/Account/methods/getTotalBalance.spec.js +++ b/packages/wallet-lib/src/types/Account/methods/getTotalBalance.spec.js @@ -1,8 +1,8 @@ -const { expect } = require('chai'); -const getTotalBalance = require('./getTotalBalance'); -const getConfirmedBalance = require('./getConfirmedBalance'); -const getUnconfirmedBalance = require('./getUnconfirmedBalance'); -const getFixtureHDAccountWithStorage = require("../../../../fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage"); +import { expect } from 'chai'; +import getTotalBalance from './getTotalBalance.js'; +import getConfirmedBalance from './getConfirmedBalance.js'; +import getUnconfirmedBalance from './getUnconfirmedBalance.js'; +import getFixtureHDAccountWithStorage from '../../../../fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage.js'; let mockedAccount; describe('Account - getTotalBalance', function suite() { diff --git a/packages/wallet-lib/src/types/Account/methods/getTransaction.js b/packages/wallet-lib/src/types/Account/methods/getTransaction.js index da7a097052d..ae45664c7b5 100644 --- a/packages/wallet-lib/src/types/Account/methods/getTransaction.js +++ b/packages/wallet-lib/src/types/Account/methods/getTransaction.js @@ -1,4 +1,4 @@ -const EVENTS = require('../../../EVENTS'); +import EVENTS from '../../../EVENTS.js'; /** * Get a transaction from a provided txid @@ -56,4 +56,4 @@ async function getTransaction(txid = null) { return { transaction, metadata }; } -module.exports = getTransaction; +export default getTransaction; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/getTransaction.spec.js b/packages/wallet-lib/src/types/Account/methods/getTransaction.spec.js index afcf859a884..ecb225a4300 100644 --- a/packages/wallet-lib/src/types/Account/methods/getTransaction.spec.js +++ b/packages/wallet-lib/src/types/Account/methods/getTransaction.spec.js @@ -1,6 +1,6 @@ -const { expect } = require('chai'); -const getTransaction = require('./getTransaction'); -const getFixtureHDAccountWithStorage = require("../../../../fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage"); +import { expect } from 'chai'; +import getTransaction from './getTransaction.js'; +import getFixtureHDAccountWithStorage from '../../../../fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage.js'; let mockedAccount; let fetchTransactionInfoCalledNb = 0; diff --git a/packages/wallet-lib/src/types/Account/methods/getTransactionHistory.js b/packages/wallet-lib/src/types/Account/methods/getTransactionHistory.js index 0acc49c7d3f..a05008473b3 100644 --- a/packages/wallet-lib/src/types/Account/methods/getTransactionHistory.js +++ b/packages/wallet-lib/src/types/Account/methods/getTransactionHistory.js @@ -1,8 +1,9 @@ -const { each } = require('lodash'); -const { +import lodash from 'lodash'; +const { each } = lodash; +import { categorizeTransactions, // calculateTransactionFees, -} = require('../../../utils'); +} from '../../../utils/index.js'; const sortbyTimeDescending = (a, b) => (b.time - a.time); const sortByHeightDescending = (a, b) => (b.height - a.height); @@ -81,4 +82,4 @@ function getTransactionHistory() { return transactionHistory.sort(sortbyTimeDescending); } -module.exports = getTransactionHistory; +export default getTransactionHistory; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/getTransactionHistory.spec.js b/packages/wallet-lib/src/types/Account/methods/getTransactionHistory.spec.js index 7caae444622..b6200bcdf3a 100644 --- a/packages/wallet-lib/src/types/Account/methods/getTransactionHistory.spec.js +++ b/packages/wallet-lib/src/types/Account/methods/getTransactionHistory.spec.js @@ -1,10 +1,10 @@ -const {expect} = require('chai'); -const getTransactions = require('./getTransactions'); -const getTransactionHistory = require('./getTransactionHistory'); -const getTotalBalance = require('./getTotalBalance'); +import {expect} from 'chai'; +import getTransactions from './getTransactions.js'; +import getTransactionHistory from './getTransactionHistory.js'; +import getTotalBalance from './getTotalBalance.js'; -const getFixtureHDAccountWithStorage = require('../../../../fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage'); -const getFixturePrivateAccountWithStorage = require('../../../../fixtures/wallets/2a331817b9d6bf85100ef0/getFixtureAccountWithStorage'); +import getFixtureHDAccountWithStorage from '../../../../fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage.js'; +import getFixturePrivateAccountWithStorage from '../../../../fixtures/wallets/2a331817b9d6bf85100ef0/getFixtureAccountWithStorage.js'; const mockedHDAccount = getFixtureHDAccountWithStorage(); diff --git a/packages/wallet-lib/src/types/Account/methods/getTransactions.js b/packages/wallet-lib/src/types/Account/methods/getTransactions.js index 4fa66aea933..2dcd5a83099 100644 --- a/packages/wallet-lib/src/types/Account/methods/getTransactions.js +++ b/packages/wallet-lib/src/types/Account/methods/getTransactions.js @@ -2,7 +2,7 @@ * Get transaction from the store * @return {[Transaction]} transactions - All transaction in the store */ -module.exports = function getTransactions() { +export default function getTransactions() { const chainStore = this.storage.getChainStore(this.network); const walletStore = this.storage.getWalletStore(this.walletId); const transactions = {}; diff --git a/packages/wallet-lib/src/types/Account/methods/getTransactions.spec.js b/packages/wallet-lib/src/types/Account/methods/getTransactions.spec.js index defa1d59220..d318c77c491 100644 --- a/packages/wallet-lib/src/types/Account/methods/getTransactions.spec.js +++ b/packages/wallet-lib/src/types/Account/methods/getTransactions.spec.js @@ -1,7 +1,7 @@ -const { expect } = require('chai'); -const getTransactions = require('./getTransactions'); +import { expect } from 'chai'; +import getTransactions from './getTransactions.js'; -const getFixtureHDAccountWithStorage = require('../../../../fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage'); +import getFixtureHDAccountWithStorage from '../../../../fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage.js'; const mockedHDSelf = { ...getFixtureHDAccountWithStorage(), diff --git a/packages/wallet-lib/src/types/Account/methods/getUTXOS.js b/packages/wallet-lib/src/types/Account/methods/getUTXOS.js index d36208f97c8..fca0688e0c1 100644 --- a/packages/wallet-lib/src/types/Account/methods/getUTXOS.js +++ b/packages/wallet-lib/src/types/Account/methods/getUTXOS.js @@ -1,6 +1,7 @@ /* eslint-disable no-continue, no-restricted-syntax */ -const { Address, Transaction } = require('@dashevo/dashcore-lib'); -const { COINBASE_MATURITY } = require('../../../CONSTANTS'); +import dashcore from '@dashevo/dashcore-lib'; +const { Address, Transaction } = dashcore; +import { COINBASE_MATURITY } from '../../../CONSTANTS.js'; /** * Return all the utxos @@ -65,4 +66,4 @@ function getUTXOS(options = { return utxos.sort((a, b) => b.satoshis - a.satoshis); } -module.exports = getUTXOS; +export default getUTXOS; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/getUTXOS.spec.js b/packages/wallet-lib/src/types/Account/methods/getUTXOS.spec.js index 906c907ac18..6f1891d0798 100644 --- a/packages/wallet-lib/src/types/Account/methods/getUTXOS.spec.js +++ b/packages/wallet-lib/src/types/Account/methods/getUTXOS.spec.js @@ -1,7 +1,7 @@ -const { expect } = require('chai'); -const Dashcore = require('@dashevo/dashcore-lib'); -const getUTXOS = require('./getUTXOS'); -const getFixtureHDAccountWithStorage = require("../../../../fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage"); +import { expect } from 'chai'; +import Dashcore from '@dashevo/dashcore-lib'; +import getUTXOS from './getUTXOS.js'; +import getFixtureHDAccountWithStorage from '../../../../fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage.js'; describe('Account - getUTXOS', function suite() { this.timeout(10000); diff --git a/packages/wallet-lib/src/types/Account/methods/getUnconfirmedBalance.js b/packages/wallet-lib/src/types/Account/methods/getUnconfirmedBalance.js index 9833525b4b1..cfbc264b28f 100644 --- a/packages/wallet-lib/src/types/Account/methods/getUnconfirmedBalance.js +++ b/packages/wallet-lib/src/types/Account/methods/getUnconfirmedBalance.js @@ -1,4 +1,4 @@ -const { duffsToDash, calculateDuffBalance } = require('../../../utils'); +import { duffsToDash, calculateDuffBalance } from '../../../utils/index.js'; /** * Return the total balance of unconfirmed utxo @@ -17,4 +17,4 @@ function getUnconfirmedBalance(displayDuffs = true) { return (displayDuffs) ? totalSat : duffsToDash(totalSat); } -module.exports = getUnconfirmedBalance; +export default getUnconfirmedBalance; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/getUnconfirmedBalance.spec.js b/packages/wallet-lib/src/types/Account/methods/getUnconfirmedBalance.spec.js index 1494975803b..667fee6a72e 100644 --- a/packages/wallet-lib/src/types/Account/methods/getUnconfirmedBalance.spec.js +++ b/packages/wallet-lib/src/types/Account/methods/getUnconfirmedBalance.spec.js @@ -1,8 +1,8 @@ -const { expect } = require('chai'); -const getTotalBalance = require('./getTotalBalance'); -const getConfirmedBalance = require('./getConfirmedBalance'); -const getUnconfirmedBalance = require('./getUnconfirmedBalance'); -const getFixtureHDAccountWithStorage = require("../../../../fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage"); +import { expect } from 'chai'; +import getTotalBalance from './getTotalBalance.js'; +import getConfirmedBalance from './getConfirmedBalance.js'; +import getUnconfirmedBalance from './getUnconfirmedBalance.js'; +import getFixtureHDAccountWithStorage from '../../../../fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage.js'; let mockedAccount; describe('Account - getUnconfirmedBalance', function suite() { diff --git a/packages/wallet-lib/src/types/Account/methods/getUnusedAddress.js b/packages/wallet-lib/src/types/Account/methods/getUnusedAddress.js index 50d24f89672..027650c3a46 100644 --- a/packages/wallet-lib/src/types/Account/methods/getUnusedAddress.js +++ b/packages/wallet-lib/src/types/Account/methods/getUnusedAddress.js @@ -58,4 +58,4 @@ function getUnusedAddress(type = 'external', skip = 0) { return unused; } -module.exports = getUnusedAddress; +export default getUnusedAddress; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/getUnusedAddress.spec.js b/packages/wallet-lib/src/types/Account/methods/getUnusedAddress.spec.js index fb1be0ba5b1..3d348628afb 100644 --- a/packages/wallet-lib/src/types/Account/methods/getUnusedAddress.spec.js +++ b/packages/wallet-lib/src/types/Account/methods/getUnusedAddress.spec.js @@ -1,6 +1,6 @@ -const { expect } = require('chai'); -const getUnusedAddress = require('./getUnusedAddress'); -const getFixtureHDAccountWithStorage = require('../../../../fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage'); +import { expect } from 'chai'; +import getUnusedAddress from './getUnusedAddress.js'; +import getFixtureHDAccountWithStorage from '../../../../fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage.js'; const mockedHDSelf = { ...getFixtureHDAccountWithStorage(), diff --git a/packages/wallet-lib/src/types/Account/methods/getUnusedIdentityIndex.js b/packages/wallet-lib/src/types/Account/methods/getUnusedIdentityIndex.js index 0e32b274e18..06170289695 100644 --- a/packages/wallet-lib/src/types/Account/methods/getUnusedIdentityIndex.js +++ b/packages/wallet-lib/src/types/Account/methods/getUnusedIdentityIndex.js @@ -13,4 +13,4 @@ async function getUnusedIdentityIndex() { return firstMissingIndex > -1 ? firstMissingIndex : identityIds.length; } -module.exports = getUnusedIdentityIndex; +export default getUnusedIdentityIndex; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/getWorker.js b/packages/wallet-lib/src/types/Account/methods/getWorker.js index 3b856a29732..49c482bf0a6 100644 --- a/packages/wallet-lib/src/types/Account/methods/getWorker.js +++ b/packages/wallet-lib/src/types/Account/methods/getWorker.js @@ -1,6 +1,6 @@ -const { +import { UnknownWorker, -} = require('../../../errors'); +} from '../../../errors/index.js'; /** * Get a worker by it's name * @param {string} workerName @@ -15,4 +15,4 @@ function getWorker(workerName) { throw new UnknownWorker(loweredWorkerName); } -module.exports = getWorker; +export default getWorker; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Account/methods/hasPlugins.js b/packages/wallet-lib/src/types/Account/methods/hasPlugins.js index 1f2bac0acca..695e11725b3 100644 --- a/packages/wallet-lib/src/types/Account/methods/hasPlugins.js +++ b/packages/wallet-lib/src/types/Account/methods/hasPlugins.js @@ -1,11 +1,11 @@ -const _ = require('lodash'); +import _ from 'lodash'; /** * To any Plugins (StandardPlugins, Worker,...) will lookup in account for it's presence. * * @param {[Plugin]} searchedPlugins - Array of constructor or single plugin constructor * @return {{found:Boolean, results:[{name: string}]}} search - results with presents plugin */ -module.exports = function hasPlugins(searchedPlugins = []) { +export default function hasPlugins(searchedPlugins = []) { const search = { found: false, results: [], diff --git a/packages/wallet-lib/src/types/Account/methods/importTransactions.js b/packages/wallet-lib/src/types/Account/methods/importTransactions.js index 40306e597eb..827a0d20791 100644 --- a/packages/wallet-lib/src/types/Account/methods/importTransactions.js +++ b/packages/wallet-lib/src/types/Account/methods/importTransactions.js @@ -4,7 +4,7 @@ * @param transactionsWithMayBeMetadata * @returns {{ addressesGenerated: number, mostRecentHeight: number }} */ -module.exports = function importTransactions(transactionsWithMayBeMetadata) { +export default function importTransactions(transactionsWithMayBeMetadata) { const { storage, network, diff --git a/packages/wallet-lib/src/types/Account/methods/injectPlugin.js b/packages/wallet-lib/src/types/Account/methods/injectPlugin.js index a20c8b03c25..2d0c6f2cbb2 100644 --- a/packages/wallet-lib/src/types/Account/methods/injectPlugin.js +++ b/packages/wallet-lib/src/types/Account/methods/injectPlugin.js @@ -1,10 +1,10 @@ -const _ = require('lodash'); -const { +import _ from 'lodash'; +import { InjectionErrorCannotInject, - InjectionErrorCannotInjectUnknownDependency: InjectionErrorCannotInjectUnknownDep, -} = require('../../../errors'); -const { is } = require('../../../utils'); -const logger = require('../../../logger'); + InjectionErrorCannotInjectUnknownDependency as InjectionErrorCannotInjectUnknownDep, +} from '../../../errors/index.js'; +import { is } from '../../../utils/index.js'; +import logger from '../../../logger/index.js'; /** * Will try to inject a given plugin. If needed, it will construct the object first (new). * @param {Plugin} UnsafePlugin - Either a child object, or it's parent class to inject @@ -12,7 +12,7 @@ const logger = require('../../../logger'); * @param {Boolean} [awaitOnInjection=true] - When true, wait for onInjected resolve first * @return {Promise<*>} plugin - instance of the plugin */ -module.exports = async function injectPlugin( +export default async function injectPlugin( UnsafePlugin, allowSensitiveOperations = false, awaitOnInjection = true, diff --git a/packages/wallet-lib/src/types/Account/methods/injectPlugin.spec.js b/packages/wallet-lib/src/types/Account/methods/injectPlugin.spec.js index 3d5558c62ea..3f56c7da005 100644 --- a/packages/wallet-lib/src/types/Account/methods/injectPlugin.spec.js +++ b/packages/wallet-lib/src/types/Account/methods/injectPlugin.spec.js @@ -1,9 +1,9 @@ -const { expect } = require('chai'); -const EventEmitter = require('events'); -const FaultyWorker = require('../../../../fixtures/plugins/FaultyWorker'); -const WorkingWorker = require('../../../../fixtures/plugins/WorkingWorker'); -const injectPlugin = require('./injectPlugin'); -const expectThrowsAsync = require('../../../utils/expectThrowsAsync'); +import { expect } from 'chai'; +import EventEmitter from 'events'; +import FaultyWorker from '../../../../fixtures/plugins/FaultyWorker.js'; +import WorkingWorker from '../../../../fixtures/plugins/WorkingWorker.js'; +import injectPlugin from './injectPlugin.js'; +import expectThrowsAsync from '../../../utils/expectThrowsAsync.js'; describe('Account - injectPlugin', function suite() { this.timeout(12000); diff --git a/packages/wallet-lib/src/types/Account/methods/sign.js b/packages/wallet-lib/src/types/Account/methods/sign.js index de584004e02..c42da620c66 100644 --- a/packages/wallet-lib/src/types/Account/methods/sign.js +++ b/packages/wallet-lib/src/types/Account/methods/sign.js @@ -1,4 +1,5 @@ -const { PrivateKey, HDPrivateKey } = require('@dashevo/dashcore-lib'); +import dashcore from '@dashevo/dashcore-lib'; +const { PrivateKey, HDPrivateKey } = dashcore; /** * To any object passed (Transaction, ST,..), will try to sign the message given passed keys. * @param {Transaction} object - The object to sign @@ -8,7 +9,7 @@ const { PrivateKey, HDPrivateKey } = require('@dashevo/dashcore-lib'); */ // TODO move options to as last param // eslint-disable-next-line default-param-last -module.exports = function sign(object, privateKeys = [], sigType) { +export default function sign(object, privateKeys = [], sigType) { const { network } = this; if (object.inputs && (!privateKeys || !privateKeys.length)) { diff --git a/packages/wallet-lib/src/types/Account/methods/sign.spec.js b/packages/wallet-lib/src/types/Account/methods/sign.spec.js index 71a3031abf2..20455e0db9f 100644 --- a/packages/wallet-lib/src/types/Account/methods/sign.spec.js +++ b/packages/wallet-lib/src/types/Account/methods/sign.spec.js @@ -1,6 +1,6 @@ -const { expect } = require('chai'); -const Dashcore = require('@dashevo/dashcore-lib'); -const { Wallet } = require('../../../index'); +import { expect } from 'chai'; +import Dashcore from '@dashevo/dashcore-lib'; +import { Wallet } from '../../../index.js'; const transactions = {"4e2a8b05a805fcee959b8ecfd5557e196a9b8490dd280d6f599b391d650407c8":{"hash":"4e2a8b05a805fcee959b8ecfd5557e196a9b8490dd280d6f599b391d650407c8","version":2,"inputs":[{"prevTxId":"1a38feca081f5c03a4fedbb62eda8706b2b43d5fc13c60b0c84e0d2c67877a4c","outputIndex":1,"sequenceNumber":4294967294,"script":"4730440220297261672847b242b46f860a827d4ef6d392471739937fd19c9e5337dd8abcfc02206f2d3fc3485e8163ac470f67dcad52c650356dc797cae8832e50afd881eba257012103a65caff6ca4c0415a3ac182dfc2a6d3a4dceb98e8b831e71501df38aa156f2c1","scriptString":"71 0x30440220297261672847b242b46f860a827d4ef6d392471739937fd19c9e5337dd8abcfc02206f2d3fc3485e8163ac470f67dcad52c650356dc797cae8832e50afd881eba25701 33 0x03a65caff6ca4c0415a3ac182dfc2a6d3a4dceb98e8b831e71501df38aa156f2c1"}],"outputs":[{"satoshis":187719774,"script":"76a91489e98f97403bb0b5674f27177452c4e8980ac42488ac"},{"satoshis":12312280000,"script":"76a91427da1075bef6c1e932f5caab1ded021f2acb65e188ac"}],"nLockTime":13621}}; const mnemonic = 'wrist ladder salute build walk other scrap stumble true hotel layer treat'; diff --git a/packages/wallet-lib/src/types/ChainStore/ChainStore.js b/packages/wallet-lib/src/types/ChainStore/ChainStore.js index 11788f8aff5..6247dc3e893 100644 --- a/packages/wallet-lib/src/types/ChainStore/ChainStore.js +++ b/packages/wallet-lib/src/types/ChainStore/ChainStore.js @@ -1,9 +1,11 @@ -const EventEmitter = require('events'); +import EventEmitter from 'events'; +import dashcore from '@dashevo/dashcore-lib'; const { - Transaction, BlockHeader, -} = require('@dashevo/dashcore-lib'); -const CONSTANTS = require('../../CONSTANTS'); + Transaction, + BlockHeader, +} = dashcore; +import CONSTANTS from '../../CONSTANTS.js'; const SCHEMA = { lastSyncedHeaderHeight: 'number', @@ -130,20 +132,31 @@ class ChainStore extends EventEmitter { ChainStore.prototype.SCHEMA = SCHEMA; -ChainStore.prototype.considerTransaction = require('./methods/considerTransaction'); - -ChainStore.prototype.exportState = require('./methods/exportState'); -ChainStore.prototype.importState = require('./methods/importState'); - -ChainStore.prototype.getAddress = require('./methods/getAddress'); -ChainStore.prototype.getAddresses = require('./methods/getAddresses'); - -ChainStore.prototype.getBlockHeader = require('./methods/getBlockHeader'); -ChainStore.prototype.getInstantLock = require('./methods/getInstantLock'); -ChainStore.prototype.getTransaction = require('./methods/getTransaction'); - -ChainStore.prototype.importAddress = require('./methods/importAddress'); -ChainStore.prototype.importInstantLock = require('./methods/importInstantLock'); -ChainStore.prototype.importTransaction = require('./methods/importTransaction'); - -module.exports = ChainStore; +import _ChainStore_considerTransaction from './methods/considerTransaction.js'; +ChainStore.prototype.considerTransaction = _ChainStore_considerTransaction; + +import _ChainStore_exportState from './methods/exportState.js'; +ChainStore.prototype.exportState = _ChainStore_exportState; +import _ChainStore_importState from './methods/importState.js'; +ChainStore.prototype.importState = _ChainStore_importState; + +import _ChainStore_getAddress from './methods/getAddress.js'; +ChainStore.prototype.getAddress = _ChainStore_getAddress; +import _ChainStore_getAddresses from './methods/getAddresses.js'; +ChainStore.prototype.getAddresses = _ChainStore_getAddresses; + +import _ChainStore_getBlockHeader from './methods/getBlockHeader.js'; +ChainStore.prototype.getBlockHeader = _ChainStore_getBlockHeader; +import _ChainStore_getInstantLock from './methods/getInstantLock.js'; +ChainStore.prototype.getInstantLock = _ChainStore_getInstantLock; +import _ChainStore_getTransaction from './methods/getTransaction.js'; +ChainStore.prototype.getTransaction = _ChainStore_getTransaction; + +import _ChainStore_importAddress from './methods/importAddress.js'; +ChainStore.prototype.importAddress = _ChainStore_importAddress; +import _ChainStore_importInstantLock from './methods/importInstantLock.js'; +ChainStore.prototype.importInstantLock = _ChainStore_importInstantLock; +import _ChainStore_importTransaction from './methods/importTransaction.js'; +ChainStore.prototype.importTransaction = _ChainStore_importTransaction; + +export default ChainStore; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/ChainStore/ChainStore.spec.js b/packages/wallet-lib/src/types/ChainStore/ChainStore.spec.js index 8892823c9ed..f470f3f8012 100644 --- a/packages/wallet-lib/src/types/ChainStore/ChainStore.spec.js +++ b/packages/wallet-lib/src/types/ChainStore/ChainStore.spec.js @@ -1,8 +1,9 @@ -const { Transaction } = require('@dashevo/dashcore-lib'); -const { expect } = require('chai'); -const ChainStore = require('./ChainStore'); -const fixtures1 = require('../../../fixtures/wallets/2a331817b9d6bf85100ef0/chain-store.json'); -const { mockHeadersChain } = require("../../test/mocks/dashcore/block"); +import dashcore from '@dashevo/dashcore-lib'; +const { Transaction } = dashcore; +import { expect } from 'chai'; +import ChainStore from './ChainStore.js'; +import fixtures1 from '../../../fixtures/wallets/2a331817b9d6bf85100ef0/chain-store.json' with { type: 'json' }; +import { mockHeadersChain } from '../../test/mocks/dashcore/block.js'; describe('ChainStore - class', () => { let testnetChainStore; diff --git a/packages/wallet-lib/src/types/ChainStore/methods/considerTransaction.js b/packages/wallet-lib/src/types/ChainStore/methods/considerTransaction.js index 2ee163b9f96..7bce4ebb5b5 100644 --- a/packages/wallet-lib/src/types/ChainStore/methods/considerTransaction.js +++ b/packages/wallet-lib/src/types/ChainStore/methods/considerTransaction.js @@ -1,5 +1,6 @@ -const { Transaction } = require('@dashevo/dashcore-lib'); -const EVENTS = require('../../../EVENTS'); +import dashcore from '@dashevo/dashcore-lib'; +const { Transaction } = dashcore; +import EVENTS from '../../../EVENTS.js'; const { Output } = Transaction; @@ -93,4 +94,4 @@ function considerTransaction(transactionHash) { return processedAddressesForTx; } -module.exports = considerTransaction; +export default considerTransaction; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/ChainStore/methods/exportState.js b/packages/wallet-lib/src/types/ChainStore/methods/exportState.js index 81235800693..4fb7e45e6ba 100644 --- a/packages/wallet-lib/src/types/ChainStore/methods/exportState.js +++ b/packages/wallet-lib/src/types/ChainStore/methods/exportState.js @@ -1,4 +1,4 @@ -const { STORAGE } = require('../../../CONSTANTS'); +import { STORAGE } from '../../../CONSTANTS.js'; function exportState() { const { state } = this; @@ -55,4 +55,4 @@ function exportState() { return serializedState; } -module.exports = exportState; +export default exportState; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/ChainStore/methods/getAddress.js b/packages/wallet-lib/src/types/ChainStore/methods/getAddress.js index 1076c9ed22d..294e8a136a7 100644 --- a/packages/wallet-lib/src/types/ChainStore/methods/getAddress.js +++ b/packages/wallet-lib/src/types/ChainStore/methods/getAddress.js @@ -2,4 +2,4 @@ function getAddress(address) { return this.state.addresses.get(address.toString()); } -module.exports = getAddress; +export default getAddress; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/ChainStore/methods/getAddresses.js b/packages/wallet-lib/src/types/ChainStore/methods/getAddresses.js index 6d6b94bcf74..3f893794f84 100644 --- a/packages/wallet-lib/src/types/ChainStore/methods/getAddresses.js +++ b/packages/wallet-lib/src/types/ChainStore/methods/getAddresses.js @@ -2,4 +2,4 @@ function getAddresses() { return this.state.addresses; } -module.exports = getAddresses; +export default getAddresses; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/ChainStore/methods/getBlockHeader.js b/packages/wallet-lib/src/types/ChainStore/methods/getBlockHeader.js index be7d9c57925..6774c38baaf 100644 --- a/packages/wallet-lib/src/types/ChainStore/methods/getBlockHeader.js +++ b/packages/wallet-lib/src/types/ChainStore/methods/getBlockHeader.js @@ -2,4 +2,4 @@ function getBlockHeader(blockHeaderHash) { return this.state.blockHeaders.get(blockHeaderHash); } -module.exports = getBlockHeader; +export default getBlockHeader; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/ChainStore/methods/getInstantLock.js b/packages/wallet-lib/src/types/ChainStore/methods/getInstantLock.js index 523380658f6..c7b1f13970c 100644 --- a/packages/wallet-lib/src/types/ChainStore/methods/getInstantLock.js +++ b/packages/wallet-lib/src/types/ChainStore/methods/getInstantLock.js @@ -2,4 +2,4 @@ function getInstantLock(transactionHash) { return this.state.instantLocks.get(transactionHash); } -module.exports = getInstantLock; +export default getInstantLock; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/ChainStore/methods/getTransaction.js b/packages/wallet-lib/src/types/ChainStore/methods/getTransaction.js index 7f97e871321..d51428b64c2 100644 --- a/packages/wallet-lib/src/types/ChainStore/methods/getTransaction.js +++ b/packages/wallet-lib/src/types/ChainStore/methods/getTransaction.js @@ -2,4 +2,4 @@ function getTransaction(transactionHash) { return this.state.transactions.get(transactionHash); } -module.exports = getTransaction; +export default getTransaction; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/ChainStore/methods/importAddress.js b/packages/wallet-lib/src/types/ChainStore/methods/importAddress.js index 4f1a64a73cb..f615d68a35c 100644 --- a/packages/wallet-lib/src/types/ChainStore/methods/importAddress.js +++ b/packages/wallet-lib/src/types/ChainStore/methods/importAddress.js @@ -1,4 +1,4 @@ -const sortTransactions = require('../../../utils/sortTransactions'); +import sortTransactions from '../../../utils/sortTransactions.js'; function importAddress(address, reconsiderTransactions = true) { if (this.state.addresses.has(address.toString())) { @@ -29,4 +29,4 @@ function importAddress(address, reconsiderTransactions = true) { } } -module.exports = importAddress; +export default importAddress; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/ChainStore/methods/importInstantLock.js b/packages/wallet-lib/src/types/ChainStore/methods/importInstantLock.js index c39d5d493ce..59f6da2a625 100644 --- a/packages/wallet-lib/src/types/ChainStore/methods/importInstantLock.js +++ b/packages/wallet-lib/src/types/ChainStore/methods/importInstantLock.js @@ -2,4 +2,4 @@ function importInstantLock(instantLock) { this.state.instantLocks.set(instantLock.txid, instantLock); } -module.exports = importInstantLock; +export default importInstantLock; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/ChainStore/methods/importState.js b/packages/wallet-lib/src/types/ChainStore/methods/importState.js index 4f927bce475..18133b9e866 100644 --- a/packages/wallet-lib/src/types/ChainStore/methods/importState.js +++ b/packages/wallet-lib/src/types/ChainStore/methods/importState.js @@ -1,4 +1,4 @@ -const castStorageItemsTypes = require('../../../utils/castStorageItemsTypes'); +import castStorageItemsTypes from '../../../utils/castStorageItemsTypes.js'; function importState(rawState) { const stateToImport = { ...rawState }; @@ -38,4 +38,4 @@ function importState(rawState) { }); } -module.exports = importState; +export default importState; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/ChainStore/methods/importTransaction.js b/packages/wallet-lib/src/types/ChainStore/methods/importTransaction.js index e4fbe1f3daf..5689c09efe5 100644 --- a/packages/wallet-lib/src/types/ChainStore/methods/importTransaction.js +++ b/packages/wallet-lib/src/types/ChainStore/methods/importTransaction.js @@ -1,5 +1,6 @@ -const { Transaction } = require('@dashevo/dashcore-lib'); -const is = require('../../../utils/is'); +import dashcore from '@dashevo/dashcore-lib'; +const { Transaction } = dashcore; +import is from '../../../utils/is.js'; function importTransaction(transaction, metadata = {}) { // Even if transaction is a transaction object, if manglized, @@ -30,4 +31,4 @@ function importTransaction(transaction, metadata = {}) { return normalizedTransaction; } -module.exports = importTransaction; +export default importTransaction; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/DerivableKeyChain/DerivableKeyChain.d.ts b/packages/wallet-lib/src/types/DerivableKeyChain/DerivableKeyChain.d.ts index 6ddaa4bff4b..6e0bce13d4c 100644 --- a/packages/wallet-lib/src/types/DerivableKeyChain/DerivableKeyChain.d.ts +++ b/packages/wallet-lib/src/types/DerivableKeyChain/DerivableKeyChain.d.ts @@ -1,5 +1,5 @@ import {PrivateKey, Network} from "../types"; -import {HDPrivateKey, HDPublicKey, Address} from "@dashevo/dashcore-lib"; +import { HDPrivateKey, HDPublicKey, Address } from '@dashevo/dashcore-lib'; import {Transaction} from "@dashevo/dashcore-lib/typings/transaction/Transaction"; export declare namespace DerivableKeyChain { diff --git a/packages/wallet-lib/src/types/DerivableKeyChain/DerivableKeyChain.js b/packages/wallet-lib/src/types/DerivableKeyChain/DerivableKeyChain.js index 9191f40d7e2..345fb3b8c10 100644 --- a/packages/wallet-lib/src/types/DerivableKeyChain/DerivableKeyChain.js +++ b/packages/wallet-lib/src/types/DerivableKeyChain/DerivableKeyChain.js @@ -1,7 +1,8 @@ -const { Networks, HDPrivateKey, HDPublicKey } = require('@dashevo/dashcore-lib'); -const { PrivateKey, PublicKey } = require('@dashevo/dashcore-lib'); -const { doubleSha256 } = require('../../utils/crypto'); -const { mnemonicToHDPrivateKey } = require('../../utils/mnemonic'); +import dashcore from '@dashevo/dashcore-lib'; +const { Networks, HDPrivateKey, HDPublicKey } = dashcore; +const { PrivateKey, PublicKey } = dashcore; +import { doubleSha256 } from '../../utils/crypto.js'; +import { mnemonicToHDPrivateKey } from '../../utils/mnemonic.js'; function generateKeyChainId(key) { const keyChainIdSuffix = doubleSha256(key.toString()).toString('hex').slice(0, 10); @@ -90,18 +91,31 @@ class DerivableKeyChain { this.maybeLookAhead(); } } -DerivableKeyChain.prototype.getForPath = require('./methods/getForPath'); -DerivableKeyChain.prototype.getForAddress = require('./methods/getForAddress'); -DerivableKeyChain.prototype.getDIP15ExtendedKey = require('./methods/getDIP15ExtendedKey'); -DerivableKeyChain.prototype.getFirstUnusedAddress = require('./methods/getFirstUnusedAddress'); -DerivableKeyChain.prototype.getHardenedBIP44HDKey = require('./methods/getHardenedBIP44HDKey'); -DerivableKeyChain.prototype.getHardenedDIP9FeatureHDKey = require('./methods/getHardenedDIP9FeatureHDKey'); -DerivableKeyChain.prototype.getHardenedDIP15AccountKey = require('./methods/getHardenedDIP15AccountKey'); -DerivableKeyChain.prototype.getRootKey = require('./methods/getRootKey'); -DerivableKeyChain.prototype.getWatchedAddresses = require('./methods/getWatchedAddresses'); -DerivableKeyChain.prototype.getIssuedPaths = require('./methods/getIssuedPaths'); -DerivableKeyChain.prototype.maybeLookAhead = require('./methods/maybeLookAhead'); -DerivableKeyChain.prototype.markAddressAsUsed = require('./methods/markAddressAsUsed'); -DerivableKeyChain.prototype.sign = require('./methods/sign'); +import _DerivableKeyChain_getForPath from './methods/getForPath.js'; +DerivableKeyChain.prototype.getForPath = _DerivableKeyChain_getForPath; +import _DerivableKeyChain_getForAddress from './methods/getForAddress.js'; +DerivableKeyChain.prototype.getForAddress = _DerivableKeyChain_getForAddress; +import _DerivableKeyChain_getDIP15ExtendedKey from './methods/getDIP15ExtendedKey.js'; +DerivableKeyChain.prototype.getDIP15ExtendedKey = _DerivableKeyChain_getDIP15ExtendedKey; +import _DerivableKeyChain_getFirstUnusedAddress from './methods/getFirstUnusedAddress.js'; +DerivableKeyChain.prototype.getFirstUnusedAddress = _DerivableKeyChain_getFirstUnusedAddress; +import _DerivableKeyChain_getHardenedBIP44HDKey from './methods/getHardenedBIP44HDKey.js'; +DerivableKeyChain.prototype.getHardenedBIP44HDKey = _DerivableKeyChain_getHardenedBIP44HDKey; +import _DerivableKeyChain_getHardenedDIP9FeatureHDKey from './methods/getHardenedDIP9FeatureHDKey.js'; +DerivableKeyChain.prototype.getHardenedDIP9FeatureHDKey = _DerivableKeyChain_getHardenedDIP9FeatureHDKey; +import _DerivableKeyChain_getHardenedDIP15AccountKey from './methods/getHardenedDIP15AccountKey.js'; +DerivableKeyChain.prototype.getHardenedDIP15AccountKey = _DerivableKeyChain_getHardenedDIP15AccountKey; +import _DerivableKeyChain_getRootKey from './methods/getRootKey.js'; +DerivableKeyChain.prototype.getRootKey = _DerivableKeyChain_getRootKey; +import _DerivableKeyChain_getWatchedAddresses from './methods/getWatchedAddresses.js'; +DerivableKeyChain.prototype.getWatchedAddresses = _DerivableKeyChain_getWatchedAddresses; +import _DerivableKeyChain_getIssuedPaths from './methods/getIssuedPaths.js'; +DerivableKeyChain.prototype.getIssuedPaths = _DerivableKeyChain_getIssuedPaths; +import _DerivableKeyChain_maybeLookAhead from './methods/maybeLookAhead.js'; +DerivableKeyChain.prototype.maybeLookAhead = _DerivableKeyChain_maybeLookAhead; +import _DerivableKeyChain_markAddressAsUsed from './methods/markAddressAsUsed.js'; +DerivableKeyChain.prototype.markAddressAsUsed = _DerivableKeyChain_markAddressAsUsed; +import _DerivableKeyChain_sign from './methods/sign.js'; +DerivableKeyChain.prototype.sign = _DerivableKeyChain_sign; -module.exports = DerivableKeyChain; +export default DerivableKeyChain; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/DerivableKeyChain/DerivableKeyChain.spec.js b/packages/wallet-lib/src/types/DerivableKeyChain/DerivableKeyChain.spec.js index 98dfc69bb5b..83a49463746 100644 --- a/packages/wallet-lib/src/types/DerivableKeyChain/DerivableKeyChain.spec.js +++ b/packages/wallet-lib/src/types/DerivableKeyChain/DerivableKeyChain.spec.js @@ -1,7 +1,7 @@ -const Dashcore = require('@dashevo/dashcore-lib'); -const { expect } = require('chai'); -const DerivableKeyChain = require('./DerivableKeyChain'); -const { mnemonicToHDPrivateKey } = require('../../utils/mnemonic'); +import Dashcore from '@dashevo/dashcore-lib'; +import { expect } from 'chai'; +import DerivableKeyChain from './DerivableKeyChain.js'; +import { mnemonicToHDPrivateKey } from '../../utils/mnemonic.js'; let derivableKeyChain; let derivableKeyChain2; @@ -48,7 +48,7 @@ describe('DerivableKeyChain', function suite() { const contactUniqueId = '0xa137439f36d04a15474ff7423e4b904a14373fafb37a41db74c84f1dbb5c89b5'; // m/9'/5'/15'/0'/0x555d3854c910b7dee436869c4724bed2fe0784e198b8a39f02bbb49d8ebcfc3a'/0xa137439f36d04a15474ff7423e4b904a14373fafb37a41db74c84f1dbb5c89b5'/0 - const DIP15ExtPubKey_0 = derivableKeyChain2.getDIP15ExtendedKey(userUniqueId, contactUniqueId, 0, 0, type='HDPublicKey'); + const DIP15ExtPubKey_0 = derivableKeyChain2.getDIP15ExtendedKey(userUniqueId, contactUniqueId, 0, 0, 'HDPublicKey'); expect(DIP15ExtPubKey_0.toString()).to.equal('xpub6LTkTQFSb8KMgMSz4B6sMZLpkQAY6wSTDprDkHDmLwWLpnjxazuxZn13FrSLKUafitsxuaaffM5a49P6aswhpppWUuYW6eFnwBXshR2W2eY'); expect(DIP15ExtPubKey_0.publicKey.toString()).to.equal('038030c88ab0106e1f4af3b939db2bafc56f892554106f08da1ce1f9ef10f807bd') diff --git a/packages/wallet-lib/src/types/DerivableKeyChain/methods/getDIP15ExtendedKey.js b/packages/wallet-lib/src/types/DerivableKeyChain/methods/getDIP15ExtendedKey.js index b65dc10d7da..97584c8fadb 100644 --- a/packages/wallet-lib/src/types/DerivableKeyChain/methods/getDIP15ExtendedKey.js +++ b/packages/wallet-lib/src/types/DerivableKeyChain/methods/getDIP15ExtendedKey.js @@ -23,4 +23,4 @@ function getDIP15ExtendedKey(userUniqueId, contactUniqueId, index = 0, accountIn return (type === 'HDPublicKey' ? extendedPrivateKey.hdPublicKey : extendedPrivateKey); } -module.exports = getDIP15ExtendedKey; +export default getDIP15ExtendedKey; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/DerivableKeyChain/methods/getFirstUnusedAddress.js b/packages/wallet-lib/src/types/DerivableKeyChain/methods/getFirstUnusedAddress.js index ab7f3fefeeb..bba49d551f8 100644 --- a/packages/wallet-lib/src/types/DerivableKeyChain/methods/getFirstUnusedAddress.js +++ b/packages/wallet-lib/src/types/DerivableKeyChain/methods/getFirstUnusedAddress.js @@ -9,4 +9,4 @@ function getFirstUnusedAddress() { address: firstUnused.address.toString(), }; } -module.exports = getFirstUnusedAddress; +export default getFirstUnusedAddress; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/DerivableKeyChain/methods/getForAddress.js b/packages/wallet-lib/src/types/DerivableKeyChain/methods/getForAddress.js index 4b8a01ddf04..c9109328f96 100644 --- a/packages/wallet-lib/src/types/DerivableKeyChain/methods/getForAddress.js +++ b/packages/wallet-lib/src/types/DerivableKeyChain/methods/getForAddress.js @@ -9,4 +9,4 @@ function getForAddress(address) { return this.getForPath(path); } -module.exports = getForAddress; +export default getForAddress; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/DerivableKeyChain/methods/getForPath.js b/packages/wallet-lib/src/types/DerivableKeyChain/methods/getForPath.js index ca2b8da7027..a4e77514546 100644 --- a/packages/wallet-lib/src/types/DerivableKeyChain/methods/getForPath.js +++ b/packages/wallet-lib/src/types/DerivableKeyChain/methods/getForPath.js @@ -36,4 +36,4 @@ function getForPath(path, opts = {}) { return data; } -module.exports = getForPath; +export default getForPath; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/DerivableKeyChain/methods/getHardenedBIP44HDKey.js b/packages/wallet-lib/src/types/DerivableKeyChain/methods/getHardenedBIP44HDKey.js index 48da61c1616..9d287c95f66 100644 --- a/packages/wallet-lib/src/types/DerivableKeyChain/methods/getHardenedBIP44HDKey.js +++ b/packages/wallet-lib/src/types/DerivableKeyChain/methods/getHardenedBIP44HDKey.js @@ -1,4 +1,4 @@ -const { BIP44_TESTNET_ROOT_PATH, BIP44_LIVENET_ROOT_PATH } = require('../../../CONSTANTS'); +import { BIP44_TESTNET_ROOT_PATH, BIP44_LIVENET_ROOT_PATH } from '../../../CONSTANTS.js'; /** * Return a safier root keys to derivate from @@ -8,4 +8,4 @@ function getHardenedBIP44HDKey() { const pathRoot = (this.network.toString() === 'testnet') ? BIP44_TESTNET_ROOT_PATH : BIP44_LIVENET_ROOT_PATH; return this.getForPath(pathRoot).key; } -module.exports = getHardenedBIP44HDKey; +export default getHardenedBIP44HDKey; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/DerivableKeyChain/methods/getHardenedDIP15AccountKey.js b/packages/wallet-lib/src/types/DerivableKeyChain/methods/getHardenedDIP15AccountKey.js index c01f240fc85..1b04ada3c53 100644 --- a/packages/wallet-lib/src/types/DerivableKeyChain/methods/getHardenedDIP15AccountKey.js +++ b/packages/wallet-lib/src/types/DerivableKeyChain/methods/getHardenedDIP15AccountKey.js @@ -11,4 +11,4 @@ function getHardenedDIP15AccountKey(accountIndex = 0, type = 'HDPrivateKey') { const featureKey = hardenedFeatureRootKey.deriveChild(15, true); return featureKey.deriveChild(accountIndex, true); } -module.exports = getHardenedDIP15AccountKey; +export default getHardenedDIP15AccountKey; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/DerivableKeyChain/methods/getHardenedDIP9FeatureHDKey.js b/packages/wallet-lib/src/types/DerivableKeyChain/methods/getHardenedDIP9FeatureHDKey.js index 422c9fab667..41b6ea6f1f5 100644 --- a/packages/wallet-lib/src/types/DerivableKeyChain/methods/getHardenedDIP9FeatureHDKey.js +++ b/packages/wallet-lib/src/types/DerivableKeyChain/methods/getHardenedDIP9FeatureHDKey.js @@ -1,4 +1,4 @@ -const { DIP9_LIVENET_ROOT_PATH, DIP9_TESTNET_ROOT_PATH } = require('../../../CONSTANTS'); +import { DIP9_LIVENET_ROOT_PATH, DIP9_TESTNET_ROOT_PATH } from '../../../CONSTANTS.js'; /** * Return a safier root path to derivate from @@ -8,4 +8,4 @@ function getHardenedDIP9FeatureHDKey() { const pathRoot = (this.network.toString() === 'testnet') ? DIP9_TESTNET_ROOT_PATH : DIP9_LIVENET_ROOT_PATH; return this.getForPath(pathRoot).key; } -module.exports = getHardenedDIP9FeatureHDKey; +export default getHardenedDIP9FeatureHDKey; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/DerivableKeyChain/methods/getIssuedPaths.js b/packages/wallet-lib/src/types/DerivableKeyChain/methods/getIssuedPaths.js index 324750853ba..2b5f712c769 100644 --- a/packages/wallet-lib/src/types/DerivableKeyChain/methods/getIssuedPaths.js +++ b/packages/wallet-lib/src/types/DerivableKeyChain/methods/getIssuedPaths.js @@ -2,4 +2,4 @@ function getWatchedAddresses() { return [...this.issuedPaths.values()]; } -module.exports = getWatchedAddresses; +export default getWatchedAddresses; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/DerivableKeyChain/methods/getRootKey.js b/packages/wallet-lib/src/types/DerivableKeyChain/methods/getRootKey.js index f2b54723a48..2aaca8a3d88 100644 --- a/packages/wallet-lib/src/types/DerivableKeyChain/methods/getRootKey.js +++ b/packages/wallet-lib/src/types/DerivableKeyChain/methods/getRootKey.js @@ -2,4 +2,4 @@ function getRootKey() { return this.rootKey; } -module.exports = getRootKey; +export default getRootKey; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/DerivableKeyChain/methods/getWatchedAddresses.js b/packages/wallet-lib/src/types/DerivableKeyChain/methods/getWatchedAddresses.js index 8154329119a..53e68bd61aa 100644 --- a/packages/wallet-lib/src/types/DerivableKeyChain/methods/getWatchedAddresses.js +++ b/packages/wallet-lib/src/types/DerivableKeyChain/methods/getWatchedAddresses.js @@ -4,4 +4,4 @@ function getWatchedAddresses() { .map(([, el]) => el.address.toString()); } -module.exports = getWatchedAddresses; +export default getWatchedAddresses; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/DerivableKeyChain/methods/markAddressAsUsed.js b/packages/wallet-lib/src/types/DerivableKeyChain/methods/markAddressAsUsed.js index 55c189a640f..d6f3f065752 100644 --- a/packages/wallet-lib/src/types/DerivableKeyChain/methods/markAddressAsUsed.js +++ b/packages/wallet-lib/src/types/DerivableKeyChain/methods/markAddressAsUsed.js @@ -1,4 +1,4 @@ -const logger = require('../../../logger'); +import logger from '../../../logger/index.js'; function markAddressAsUsed(address) { const searchResult = [...this.issuedPaths.entries()] @@ -17,4 +17,4 @@ function markAddressAsUsed(address) { return false; } -module.exports = markAddressAsUsed; +export default markAddressAsUsed; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/DerivableKeyChain/methods/maybeLookAhead.js b/packages/wallet-lib/src/types/DerivableKeyChain/methods/maybeLookAhead.js index fd3841f40bd..0ec520a03b2 100644 --- a/packages/wallet-lib/src/types/DerivableKeyChain/methods/maybeLookAhead.js +++ b/packages/wallet-lib/src/types/DerivableKeyChain/methods/maybeLookAhead.js @@ -79,4 +79,4 @@ function maybeLookAhead() { }); return generatedPaths; } -module.exports = maybeLookAhead; +export default maybeLookAhead; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/DerivableKeyChain/methods/sign.js b/packages/wallet-lib/src/types/DerivableKeyChain/methods/sign.js index b10b561f2c2..71a3dd6caa5 100644 --- a/packages/wallet-lib/src/types/DerivableKeyChain/methods/sign.js +++ b/packages/wallet-lib/src/types/DerivableKeyChain/methods/sign.js @@ -1,6 +1,9 @@ +import dashcore from '@dashevo/dashcore-lib'; const { - crypto, Transaction, Message, -} = require('@dashevo/dashcore-lib'); + crypto, + Transaction, + Message, +} = dashcore; /** * Allow to sign any transaction or a transition object from a valid privateKeys list @@ -26,4 +29,4 @@ function sign(object, privateKeys, sigType = crypto.Signature.SIGHASH_ALL) { } return obj; } -module.exports = sign; +export default sign; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Identities/Identities.d.ts b/packages/wallet-lib/src/types/Identities/Identities.d.ts index 9bd7a02bce9..1f416bf30f2 100644 --- a/packages/wallet-lib/src/types/Identities/Identities.d.ts +++ b/packages/wallet-lib/src/types/Identities/Identities.d.ts @@ -1,5 +1,5 @@ import { Wallet } from "../Wallet/Wallet"; -import { HDPrivateKey } from "@dashevo/dashcore-lib"; +import { HDPrivateKey } from '@dashevo/dashcore-lib'; export declare class Identities { constructor(wallet: Wallet); diff --git a/packages/wallet-lib/src/types/Identities/Identities.js b/packages/wallet-lib/src/types/Identities/Identities.js index f457fe9fc99..9395e296553 100644 --- a/packages/wallet-lib/src/types/Identities/Identities.js +++ b/packages/wallet-lib/src/types/Identities/Identities.js @@ -1,5 +1,5 @@ -const _ = require('lodash'); -const Wallet = require('../Wallet/Wallet'); +import _ from 'lodash'; +import Wallet from '../Wallet/Wallet.js'; class Identities { constructor(wallet) { @@ -14,8 +14,11 @@ class Identities { } } -Identities.prototype.getIdentityHDKeyById = require('./methods/getIdentityHDKeyById'); -Identities.prototype.getIdentityHDKeyByIndex = require('./methods/getIdentityHDKeyByIndex'); -Identities.prototype.getIdentityIds = require('./methods/getIdentityIds'); +import _Identities_getIdentityHDKeyById from './methods/getIdentityHDKeyById.js'; +Identities.prototype.getIdentityHDKeyById = _Identities_getIdentityHDKeyById; +import _Identities_getIdentityHDKeyByIndex from './methods/getIdentityHDKeyByIndex.js'; +Identities.prototype.getIdentityHDKeyByIndex = _Identities_getIdentityHDKeyByIndex; +import _Identities_getIdentityIds from './methods/getIdentityIds.js'; +Identities.prototype.getIdentityIds = _Identities_getIdentityIds; -module.exports = Identities; +export default Identities; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Identities/methods/getIdentityHDKeyById.js b/packages/wallet-lib/src/types/Identities/methods/getIdentityHDKeyById.js index 79cd6eedc77..8f03afc241d 100644 --- a/packages/wallet-lib/src/types/Identities/methods/getIdentityHDKeyById.js +++ b/packages/wallet-lib/src/types/Identities/methods/getIdentityHDKeyById.js @@ -17,4 +17,4 @@ function getIdentityHDKeyById(identityId, keyIndex) { return this.getIdentityHDKeyByIndex(identityIndex, keyIndex); } -module.exports = getIdentityHDKeyById; +export default getIdentityHDKeyById; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Identities/methods/getIdentityHDKeyById.spec.js b/packages/wallet-lib/src/types/Identities/methods/getIdentityHDKeyById.spec.js index 87e60e4d58d..c0b1b88dd44 100644 --- a/packages/wallet-lib/src/types/Identities/methods/getIdentityHDKeyById.spec.js +++ b/packages/wallet-lib/src/types/Identities/methods/getIdentityHDKeyById.spec.js @@ -1,6 +1,6 @@ -const { expect } = require('chai'); -const mockedStore = require('../../../../fixtures/sirentonight-fullstore-snapshot-1562711703'); -const getIdentityHDKeyById = require('./getIdentityHDKeyById'); +import { expect } from 'chai'; +import mockedStore from '../../../../fixtures/sirentonight-fullstore-snapshot-1562711703.json' with { type: 'json' }; +import getIdentityHDKeyById from './getIdentityHDKeyById.js'; let walletMock; let fetchTransactionInfoCalledNb = 0; diff --git a/packages/wallet-lib/src/types/Identities/methods/getIdentityHDKeyByIndex.js b/packages/wallet-lib/src/types/Identities/methods/getIdentityHDKeyByIndex.js index aee9b0919ab..27d88faa8f6 100644 --- a/packages/wallet-lib/src/types/Identities/methods/getIdentityHDKeyByIndex.js +++ b/packages/wallet-lib/src/types/Identities/methods/getIdentityHDKeyByIndex.js @@ -21,4 +21,4 @@ function getIdentityHDKeyByIndex(identityIndex, keyIndex) { .deriveChild(keyIndex, true); } -module.exports = getIdentityHDKeyByIndex; +export default getIdentityHDKeyByIndex; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Identities/methods/getIdentityHDKeyByIndex.spec.js b/packages/wallet-lib/src/types/Identities/methods/getIdentityHDKeyByIndex.spec.js index e84db4788a3..e6aabfd04ad 100644 --- a/packages/wallet-lib/src/types/Identities/methods/getIdentityHDKeyByIndex.spec.js +++ b/packages/wallet-lib/src/types/Identities/methods/getIdentityHDKeyByIndex.spec.js @@ -1,6 +1,6 @@ -const { expect } = require('chai'); +import { expect } from 'chai'; -const { Wallet, Identities } = require('../../../index'); +import { Wallet, Identities } from '../../../index.js'; let mnemonic; let expectedIdentityHDKey0_0; diff --git a/packages/wallet-lib/src/types/Identities/methods/getIdentityIds.js b/packages/wallet-lib/src/types/Identities/methods/getIdentityIds.js index e72711adb42..00a2870f563 100644 --- a/packages/wallet-lib/src/types/Identities/methods/getIdentityIds.js +++ b/packages/wallet-lib/src/types/Identities/methods/getIdentityIds.js @@ -9,4 +9,4 @@ function getIdentityIds() { .filter(Boolean); } -module.exports = getIdentityIds; +export default getIdentityIds; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Identities/methods/getIdentityIds.spec.js b/packages/wallet-lib/src/types/Identities/methods/getIdentityIds.spec.js index 6d0ee52d568..ecc6d2e4e41 100644 --- a/packages/wallet-lib/src/types/Identities/methods/getIdentityIds.spec.js +++ b/packages/wallet-lib/src/types/Identities/methods/getIdentityIds.spec.js @@ -1,7 +1,7 @@ -const { expect } = require('chai'); -const mockedStore = require('../../../../fixtures/sirentonight-fullstore-snapshot-1562711703'); -const getIdentityIds = require('./getIdentityIds'); -const WalletStore = require("../../WalletStore/WalletStore"); +import { expect } from 'chai'; +import mockedStore from '../../../../fixtures/sirentonight-fullstore-snapshot-1562711703.json' with { type: 'json' }; +import getIdentityIds from './getIdentityIds.js'; +import WalletStore from '../../WalletStore/WalletStore.js'; let mockedWallet; let fetchTransactionInfoCalledNb = 0; diff --git a/packages/wallet-lib/src/types/KeyChainStore/KeyChainStore.js b/packages/wallet-lib/src/types/KeyChainStore/KeyChainStore.js index c81c2c0ac2a..ba8e5120203 100644 --- a/packages/wallet-lib/src/types/KeyChainStore/KeyChainStore.js +++ b/packages/wallet-lib/src/types/KeyChainStore/KeyChainStore.js @@ -5,10 +5,15 @@ class KeyChainStore { } } -KeyChainStore.prototype.addKeyChain = require('./methods/addKeyChain'); -KeyChainStore.prototype.getKeyChain = require('./methods/getKeyChain'); -KeyChainStore.prototype.getKeyChains = require('./methods/getKeyChains'); -KeyChainStore.prototype.makeChildKeyChainStore = require('./methods/makeChildKeyChainStore'); -KeyChainStore.prototype.getMasterKeyChain = require('./methods/getMasterKeyChain'); +import _KeyChainStore_addKeyChain from './methods/addKeyChain.js'; +KeyChainStore.prototype.addKeyChain = _KeyChainStore_addKeyChain; +import _KeyChainStore_getKeyChain from './methods/getKeyChain.js'; +KeyChainStore.prototype.getKeyChain = _KeyChainStore_getKeyChain; +import _KeyChainStore_getKeyChains from './methods/getKeyChains.js'; +KeyChainStore.prototype.getKeyChains = _KeyChainStore_getKeyChains; +import _KeyChainStore_makeChildKeyChainStore from './methods/makeChildKeyChainStore.js'; +KeyChainStore.prototype.makeChildKeyChainStore = _KeyChainStore_makeChildKeyChainStore; +import _KeyChainStore_getMasterKeyChain from './methods/getMasterKeyChain.js'; +KeyChainStore.prototype.getMasterKeyChain = _KeyChainStore_getMasterKeyChain; -module.exports = KeyChainStore; +export default KeyChainStore; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/KeyChainStore/KeyChainStore.spec.js b/packages/wallet-lib/src/types/KeyChainStore/KeyChainStore.spec.js index 4b139d98c1d..0346c9ace1d 100644 --- a/packages/wallet-lib/src/types/KeyChainStore/KeyChainStore.spec.js +++ b/packages/wallet-lib/src/types/KeyChainStore/KeyChainStore.spec.js @@ -1,7 +1,8 @@ -const {HDPrivateKey} = require("@dashevo/dashcore-lib"); -const KeyChainsStore = require('./KeyChainStore'); -const DerivableKeyChain = require("../DerivableKeyChain/DerivableKeyChain"); -const { expect } = require('chai'); +import dashcore from '@dashevo/dashcore-lib'; +const { HDPrivateKey } = dashcore; +import KeyChainsStore from './KeyChainStore.js'; +import DerivableKeyChain from '../DerivableKeyChain/DerivableKeyChain.js'; +import { expect } from 'chai'; describe('KeyChainStore', function suite() { let keyChainsStore; diff --git a/packages/wallet-lib/src/types/KeyChainStore/methods/addKeyChain.js b/packages/wallet-lib/src/types/KeyChainStore/methods/addKeyChain.js index 04e60a50739..aff6e5136dc 100644 --- a/packages/wallet-lib/src/types/KeyChainStore/methods/addKeyChain.js +++ b/packages/wallet-lib/src/types/KeyChainStore/methods/addKeyChain.js @@ -12,4 +12,4 @@ function addKeyChain(keychain, opts = {}) { } } -module.exports = addKeyChain; +export default addKeyChain; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/KeyChainStore/methods/getKeyChain.js b/packages/wallet-lib/src/types/KeyChainStore/methods/getKeyChain.js index d964ba395ee..eef97a4f83c 100644 --- a/packages/wallet-lib/src/types/KeyChainStore/methods/getKeyChain.js +++ b/packages/wallet-lib/src/types/KeyChainStore/methods/getKeyChain.js @@ -2,4 +2,4 @@ function getKeyChain(keyChainId) { return this.keyChains.get(keyChainId); } -module.exports = getKeyChain; +export default getKeyChain; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/KeyChainStore/methods/getKeyChains.js b/packages/wallet-lib/src/types/KeyChainStore/methods/getKeyChains.js index 4e0e16160cd..abac75c07d7 100644 --- a/packages/wallet-lib/src/types/KeyChainStore/methods/getKeyChains.js +++ b/packages/wallet-lib/src/types/KeyChainStore/methods/getKeyChains.js @@ -2,4 +2,4 @@ function getKeyChains() { return Array.from(this.keyChains.values()); } -module.exports = getKeyChains; +export default getKeyChains; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/KeyChainStore/methods/getMasterKeyChain.js b/packages/wallet-lib/src/types/KeyChainStore/methods/getMasterKeyChain.js index 512d6a28133..33b7f2d2d46 100644 --- a/packages/wallet-lib/src/types/KeyChainStore/methods/getMasterKeyChain.js +++ b/packages/wallet-lib/src/types/KeyChainStore/methods/getMasterKeyChain.js @@ -3,4 +3,4 @@ function getMasterKeyChain() { return this.keyChains.get(keyChainId); } -module.exports = getMasterKeyChain; +export default getMasterKeyChain; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/KeyChainStore/methods/makeChildKeyChainStore.js b/packages/wallet-lib/src/types/KeyChainStore/methods/makeChildKeyChainStore.js index 383baee3ce0..da49ee11399 100644 --- a/packages/wallet-lib/src/types/KeyChainStore/methods/makeChildKeyChainStore.js +++ b/packages/wallet-lib/src/types/KeyChainStore/methods/makeChildKeyChainStore.js @@ -1,5 +1,5 @@ -const DerivableKeyChain = require('../../DerivableKeyChain/DerivableKeyChain'); -const logger = require('../../../logger'); +import DerivableKeyChain from '../../DerivableKeyChain/DerivableKeyChain.js'; +import logger from '../../../logger/index.js'; function makeChildKeyChainStore(path, opts) { logger.debug(`KeyChainStore - make a child keychainstore for ${path}`); @@ -16,4 +16,4 @@ function makeChildKeyChainStore(path, opts) { return childKeyChainStore; } -module.exports = makeChildKeyChainStore; +export default makeChildKeyChainStore; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Storage/Storage.js b/packages/wallet-lib/src/types/Storage/Storage.js index ccbe4ffbd18..55712023e85 100644 --- a/packages/wallet-lib/src/types/Storage/Storage.js +++ b/packages/wallet-lib/src/types/Storage/Storage.js @@ -1,6 +1,7 @@ -const EventEmitter = require('events'); -const { has } = require('lodash'); -const CONSTANTS = require('../../CONSTANTS'); +import EventEmitter from 'events'; +import lodash from 'lodash'; +const { has } = lodash; +import CONSTANTS from '../../CONSTANTS.js'; const defaultOpts = { rehydrate: true, @@ -56,14 +57,23 @@ class Storage extends EventEmitter { } } -Storage.prototype.configure = require('./methods/configure'); -Storage.prototype.createChainStore = require('./methods/createChainStore'); -Storage.prototype.createWalletStore = require('./methods/createWalletStore'); -Storage.prototype.getChainStore = require('./methods/getChainStore'); -Storage.prototype.getWalletStore = require('./methods/getWalletStore'); -Storage.prototype.rehydrateState = require('./methods/rehydrateState'); -Storage.prototype.saveState = require('./methods/saveState'); -Storage.prototype.startWorker = require('./methods/startWorker'); -Storage.prototype.stopWorker = require('./methods/stopWorker'); +import _Storage_configure from './methods/configure.js'; +Storage.prototype.configure = _Storage_configure; +import _Storage_createChainStore from './methods/createChainStore.js'; +Storage.prototype.createChainStore = _Storage_createChainStore; +import _Storage_createWalletStore from './methods/createWalletStore.js'; +Storage.prototype.createWalletStore = _Storage_createWalletStore; +import _Storage_getChainStore from './methods/getChainStore.js'; +Storage.prototype.getChainStore = _Storage_getChainStore; +import _Storage_getWalletStore from './methods/getWalletStore.js'; +Storage.prototype.getWalletStore = _Storage_getWalletStore; +import _Storage_rehydrateState from './methods/rehydrateState.js'; +Storage.prototype.rehydrateState = _Storage_rehydrateState; +import _Storage_saveState from './methods/saveState.js'; +Storage.prototype.saveState = _Storage_saveState; +import _Storage_startWorker from './methods/startWorker.js'; +Storage.prototype.startWorker = _Storage_startWorker; +import _Storage_stopWorker from './methods/stopWorker.js'; +Storage.prototype.stopWorker = _Storage_stopWorker; -module.exports = Storage; +export default Storage; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Storage/_configureAdapter.js b/packages/wallet-lib/src/types/Storage/_configureAdapter.js index 1a54b7bf39b..f692dbbdd4d 100644 --- a/packages/wallet-lib/src/types/Storage/_configureAdapter.js +++ b/packages/wallet-lib/src/types/Storage/_configureAdapter.js @@ -1,6 +1,6 @@ -const { InvalidStorageAdapter } = require('../../errors'); +import { InvalidStorageAdapter } from '../../errors/index.js'; -module.exports = async function configureAdapter(argAdapter) { +export default async function configureAdapter(argAdapter) { let adapter; if (!argAdapter) throw new Error('Expected an adapter to configure'); const argAdapterConstructorName = argAdapter.constructor.name; diff --git a/packages/wallet-lib/src/types/Storage/_getDefaultAdapter.js b/packages/wallet-lib/src/types/Storage/_getDefaultAdapter.js index bfc4bfe7dbf..8fb73797f72 100644 --- a/packages/wallet-lib/src/types/Storage/_getDefaultAdapter.js +++ b/packages/wallet-lib/src/types/Storage/_getDefaultAdapter.js @@ -1,7 +1,7 @@ -const logger = require('../../logger'); -const InMem = require('../../adapters/InMem'); +import logger from '../../logger/index.js'; +import InMem from '../../adapters/InMem.js'; -module.exports = async function getDefaultAdapter() { +export default async function getDefaultAdapter() { const isBrowser = (typeof document !== 'undefined'); // eslint-disable-next-line no-undef const isReactNative = (typeof navigator !== 'undefined' && navigator.product === 'ReactNative'); diff --git a/packages/wallet-lib/src/types/Storage/methods/configure.js b/packages/wallet-lib/src/types/Storage/methods/configure.js index a965b909da3..7c81f918fff 100644 --- a/packages/wallet-lib/src/types/Storage/methods/configure.js +++ b/packages/wallet-lib/src/types/Storage/methods/configure.js @@ -1,17 +1,18 @@ -const { has } = require('lodash'); -const InMem = require('../../../adapters/InMem'); -const configureAdapter = require('../_configureAdapter'); -const getDefaultAdapter = require('../_getDefaultAdapter'); -const { CONFIGURED } = require('../../../EVENTS'); -const logger = require('../../../logger'); -const CONSTANTS = require('../../../CONSTANTS'); +import lodash from 'lodash'; +const { has } = lodash; +import InMem from '../../../adapters/InMem.js'; +import configureAdapter from '../_configureAdapter.js'; +import getDefaultAdapter from '../_getDefaultAdapter.js'; +import { CONFIGURED } from '../../../EVENTS.js'; +import logger from '../../../logger/index.js'; +import CONSTANTS from '../../../CONSTANTS.js'; /** * To be called after instantialization as it contains all the async logic / test of adapters * @param opts * @return {Promise} */ -module.exports = async function configure(opts = {}) { +export default async function configure(opts = {}) { this.rehydrate = has(opts, 'rehydrate') ? opts.rehydrate : this.rehydrate; this.autosave = has(opts, 'autosave') ? opts.autosave : this.autosave; this.adapter = await configureAdapter((opts.adapter) ? opts.adapter : await getDefaultAdapter()); diff --git a/packages/wallet-lib/src/types/Storage/methods/createChainStore.js b/packages/wallet-lib/src/types/Storage/methods/createChainStore.js index 890ac45c070..12b188cc47e 100644 --- a/packages/wallet-lib/src/types/Storage/methods/createChainStore.js +++ b/packages/wallet-lib/src/types/Storage/methods/createChainStore.js @@ -1,5 +1,5 @@ -const ChainStore = require('../../ChainStore/ChainStore'); -const EVENTS = require('../../../EVENTS'); +import ChainStore from '../../ChainStore/ChainStore.js'; +import EVENTS from '../../../EVENTS.js'; const EVENTS_TO_FORWARD = [ EVENTS.FETCHED_CONFIRMED_TRANSACTION, @@ -26,4 +26,4 @@ const createChainStore = function createChain(network) { } return false; }; -module.exports = createChainStore; +export default createChainStore; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Storage/methods/createWalletStore.js b/packages/wallet-lib/src/types/Storage/methods/createWalletStore.js index b398746ac47..f9ace15433b 100644 --- a/packages/wallet-lib/src/types/Storage/methods/createWalletStore.js +++ b/packages/wallet-lib/src/types/Storage/methods/createWalletStore.js @@ -1,4 +1,4 @@ -const WalletStore = require('../../WalletStore/WalletStore'); +import WalletStore from '../../WalletStore/WalletStore.js'; const createWalletStore = function createWallet(walletId = 'squawk7700') { if (!this.wallets.has(walletId)) { @@ -7,4 +7,4 @@ const createWalletStore = function createWallet(walletId = 'squawk7700') { } return false; }; -module.exports = createWalletStore; +export default createWalletStore; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Storage/methods/getChainStore.js b/packages/wallet-lib/src/types/Storage/methods/getChainStore.js index 5255eb71033..a79f8dc106c 100644 --- a/packages/wallet-lib/src/types/Storage/methods/getChainStore.js +++ b/packages/wallet-lib/src/types/Storage/methods/getChainStore.js @@ -1,4 +1,4 @@ function getChainStore(network) { return this.chains.get(network); } -module.exports = getChainStore; +export default getChainStore; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Storage/methods/getWalletStore.js b/packages/wallet-lib/src/types/Storage/methods/getWalletStore.js index 3f43fc2b25e..1af1090dd81 100644 --- a/packages/wallet-lib/src/types/Storage/methods/getWalletStore.js +++ b/packages/wallet-lib/src/types/Storage/methods/getWalletStore.js @@ -2,4 +2,4 @@ function getWalletStore(walletId) { if (!this.wallets.has(walletId)) return null; return this.wallets.get(walletId); } -module.exports = getWalletStore; +export default getWalletStore; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Storage/methods/rehydrateState.js b/packages/wallet-lib/src/types/Storage/methods/rehydrateState.js index 9c8565f2af9..d1e37830e9b 100644 --- a/packages/wallet-lib/src/types/Storage/methods/rehydrateState.js +++ b/packages/wallet-lib/src/types/Storage/methods/rehydrateState.js @@ -1,8 +1,8 @@ -const { hasMethod } = require('../../../utils'); +import { hasMethod } from '../../../utils/index.js'; -const { REHYDRATE_STATE_FAILED, REHYDRATE_STATE_SUCCESS } = require('../../../EVENTS'); +import { REHYDRATE_STATE_FAILED, REHYDRATE_STATE_SUCCESS } from '../../../EVENTS.js'; -const logger = require('../../../logger'); +import logger from '../../../logger/index.js'; /** * Fetch the state from the persistence adapter @@ -49,4 +49,4 @@ const rehydrateState = async function rehydrateState() { } } }; -module.exports = rehydrateState; +export default rehydrateState; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Storage/methods/saveState.js b/packages/wallet-lib/src/types/Storage/methods/saveState.js index cd59cb244dc..2af15c942d5 100644 --- a/packages/wallet-lib/src/types/Storage/methods/saveState.js +++ b/packages/wallet-lib/src/types/Storage/methods/saveState.js @@ -1,5 +1,5 @@ -const { SAVE_STATE_SUCCESS, SAVE_STATE_FAILED } = require('../../../EVENTS'); -const CONSTANTS = require('../../../CONSTANTS'); +import { SAVE_STATE_SUCCESS, SAVE_STATE_FAILED } from '../../../EVENTS.js'; +import CONSTANTS from '../../../CONSTANTS.js'; /** * Force persistence of the state to the adapter @@ -49,4 +49,4 @@ const saveState = async function saveState() { } return false; }; -module.exports = saveState; +export default saveState; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Storage/methods/startWorker.js b/packages/wallet-lib/src/types/Storage/methods/startWorker.js index 4976c0ebc53..53b6a403498 100644 --- a/packages/wallet-lib/src/types/Storage/methods/startWorker.js +++ b/packages/wallet-lib/src/types/Storage/methods/startWorker.js @@ -2,7 +2,7 @@ * Allow to start the working interval (worker for saving state). * @return {void} */ -module.exports = function startWorker() { +export default function startWorker() { this.interval = setInterval(() => { if (this.lastModified > this.lastSave) { this.saveState(); diff --git a/packages/wallet-lib/src/types/Storage/methods/stopWorker.js b/packages/wallet-lib/src/types/Storage/methods/stopWorker.js index f0aa6690313..5dea3adc7ee 100644 --- a/packages/wallet-lib/src/types/Storage/methods/stopWorker.js +++ b/packages/wallet-lib/src/types/Storage/methods/stopWorker.js @@ -2,7 +2,7 @@ * Allow to clear the working interval (worker). * @return {boolean} */ -module.exports = function stopWorker() { +export default function stopWorker() { clearInterval(this.interval); this.interval = null; return true; diff --git a/packages/wallet-lib/src/types/Wallet/Wallet.d.ts b/packages/wallet-lib/src/types/Wallet/Wallet.d.ts index 2d44e48b790..67598f07447 100644 --- a/packages/wallet-lib/src/types/Wallet/Wallet.d.ts +++ b/packages/wallet-lib/src/types/Wallet/Wallet.d.ts @@ -1,7 +1,7 @@ import { Mnemonic, PrivateKey, PublicKey, PublicAddress, Address, HDPublicKey, Network, Plugins } from "../types"; import { Account } from "../Account/Account"; import { Storage } from "../Storage/Storage"; -import { HDPrivateKey } from "@dashevo/dashcore-lib"; +import { HDPrivateKey } from '@dashevo/dashcore-lib'; import { Transport } from "../../transport/Transport"; export declare class Wallet { diff --git a/packages/wallet-lib/src/types/Wallet/Wallet.js b/packages/wallet-lib/src/types/Wallet/Wallet.js index e6ed98aec62..409cef7b656 100644 --- a/packages/wallet-lib/src/types/Wallet/Wallet.js +++ b/packages/wallet-lib/src/types/Wallet/Wallet.js @@ -1,11 +1,13 @@ -const { PrivateKey, Networks } = require('@dashevo/dashcore-lib'); - -const EventEmitter = require('events'); -const _ = require('lodash'); -const Storage = require('../Storage/Storage'); -const { +import dashcore from '@dashevo/dashcore-lib'; +const { PrivateKey, Networks } = dashcore; + +import EventEmitter from 'events'; +import _ from 'lodash'; +import Storage from '../Storage/Storage.js'; +import Identities from '../Identities/Identities.js'; +import { generateNewMnemonic, -} = require('../../utils'); +} from '../../utils/index.js'; const defaultOptions = { debug: false, @@ -20,16 +22,16 @@ const defaultOptions = { waitForTxMetadataTimeout: 540000, }; -const fromMnemonic = require('./methods/fromMnemonic'); -const fromPrivateKey = require('./methods/fromPrivateKey'); -const fromPublicKey = require('./methods/fromPublicKey'); -const fromAddress = require('./methods/fromAddress'); -const fromSeed = require('./methods/fromSeed'); -const fromHDPublicKey = require('./methods/fromHDPublicKey'); -const fromHDPrivateKey = require('./methods/fromHDPrivateKey'); -const generateNewWalletId = require('./methods/generateNewWalletId'); +import fromMnemonic from './methods/fromMnemonic.js'; +import fromPrivateKey from './methods/fromPrivateKey.js'; +import fromPublicKey from './methods/fromPublicKey.js'; +import fromAddress from './methods/fromAddress.js'; +import fromSeed from './methods/fromSeed.js'; +import fromHDPublicKey from './methods/fromHDPublicKey.js'; +import fromHDPrivateKey from './methods/fromHDPrivateKey.js'; +import generateNewWalletId from './methods/generateNewWalletId.js'; -const createTransportFromOptions = require('../../transport/createTransportFromOptions'); +import createTransportFromOptions from '../../transport/createTransportFromOptions.js'; /** * Instantiate a basic Wallet object, @@ -194,20 +196,23 @@ class Wallet extends EventEmitter { this.accounts = []; this.interface = opts.interface; - // Suppressed global require to avoid cyclic dependencies - // eslint-disable-next-line global-require - const Identities = require('../Identities/Identities'); this.identities = new Identities(this); this.savedBackup = false; // TODO: When true, we delete mnemonic from internals } } -Wallet.prototype.createAccount = require('./methods/createAccount'); -Wallet.prototype.disconnect = require('./methods/disconnect'); -Wallet.prototype.getAccount = require('./methods/getAccount'); +import _Wallet_createAccount from './methods/createAccount.js'; +Wallet.prototype.createAccount = _Wallet_createAccount; +import _Wallet_disconnect from './methods/disconnect.js'; +Wallet.prototype.disconnect = _Wallet_disconnect; +import _Wallet_getAccount from './methods/getAccount.js'; +Wallet.prototype.getAccount = _Wallet_getAccount; Wallet.prototype.generateNewWalletId = generateNewWalletId; -Wallet.prototype.exportWallet = require('./methods/exportWallet'); -Wallet.prototype.sweepWallet = require('./methods/sweepWallet'); -Wallet.prototype.dumpStorage = require('./methods/dumpStorage'); - -module.exports = Wallet; +import _Wallet_exportWallet from './methods/exportWallet.js'; +Wallet.prototype.exportWallet = _Wallet_exportWallet; +import _Wallet_sweepWallet from './methods/sweepWallet.js'; +Wallet.prototype.sweepWallet = _Wallet_sweepWallet; +import _Wallet_dumpStorage from './methods/dumpStorage.js'; +Wallet.prototype.dumpStorage = _Wallet_dumpStorage; + +export default Wallet; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Wallet/Wallet.spec.js b/packages/wallet-lib/src/types/Wallet/Wallet.spec.js index 87f509728c5..7d7419334d5 100644 --- a/packages/wallet-lib/src/types/Wallet/Wallet.spec.js +++ b/packages/wallet-lib/src/types/Wallet/Wallet.spec.js @@ -1,14 +1,14 @@ -const { expect } = require('chai'); -const Dashcore = require('@dashevo/dashcore-lib'); -const knifeMnemonic = require('../../../fixtures/knifeeasily'); -const gatherSailMnemonic = require('../../../fixtures/gathersail'); -const fluidMnemonic = require('../../../fixtures/fluidDepth'); -const cR4t6ePrivateKey = require('../../../fixtures/cR4t6e_pk'); -const { WALLET_TYPES } = require('../../CONSTANTS'); -const { Wallet } = require('../../index'); -const inMem = require('../../adapters/InMem'); -const fromHDPublicKey = require('./methods/fromHDPublicKey'); -const gatherSail = require('../../../fixtures/gathersail'); +import { expect } from 'chai'; +import Dashcore from '@dashevo/dashcore-lib'; +import knifeMnemonic from '../../../fixtures/knifeeasily.json' with { type: 'json' }; +import gatherSailMnemonic from '../../../fixtures/gathersail.json' with { type: 'json' }; +import fluidMnemonic from '../../../fixtures/fluidDepth.json' with { type: 'json' }; +import cR4t6ePrivateKey from '../../../fixtures/cR4t6e_pk.json' with { type: 'json' }; +import { WALLET_TYPES } from '../../CONSTANTS.js'; +import { Wallet } from '../../index.js'; +import inMem from '../../adapters/InMem.js'; +import fromHDPublicKey from './methods/fromHDPublicKey.js'; +import gatherSail from '../../../fixtures/gathersail.json' with { type: 'json' }; const mocks = { adapter: inMem, diff --git a/packages/wallet-lib/src/types/Wallet/methods/createAccount.js b/packages/wallet-lib/src/types/Wallet/methods/createAccount.js index f74c4bb885c..1abdc93a41f 100644 --- a/packages/wallet-lib/src/types/Wallet/methods/createAccount.js +++ b/packages/wallet-lib/src/types/Wallet/methods/createAccount.js @@ -1,5 +1,6 @@ -const { WALLET_TYPES } = require('../../../CONSTANTS'); -const EVENTS = require('../../../EVENTS'); +import { WALLET_TYPES } from '../../../CONSTANTS.js'; +import EVENTS from '../../../EVENTS.js'; +import Account from '../../Account/Account.js'; /** * Will derivate to a new account. * @param {object} accountOpts - options to pass, will autopopulate some @@ -10,14 +11,6 @@ async function createAccount(accountOpts) { await new Promise((resolve) => { this.storage.once(EVENTS.CONFIGURED, resolve); }); } - /** - * Wallet.createAccount calls Account that depends on Wallet. - * In order to avoid a cyclic dependency issue we put this require here and - * disable eslint global require for next line - */ - // eslint-disable-next-line global-require - const Account = require('../../Account/Account'); - const { injectDefaultPlugins, debug, plugins, allowSensitiveOperations, } = this; @@ -57,4 +50,4 @@ async function createAccount(accountOpts) { throw e; } } -module.exports = createAccount; +export default createAccount; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Wallet/methods/createAccount.spec.js b/packages/wallet-lib/src/types/Wallet/methods/createAccount.spec.js index 7c41ff641ef..0307b361f2a 100644 --- a/packages/wallet-lib/src/types/Wallet/methods/createAccount.spec.js +++ b/packages/wallet-lib/src/types/Wallet/methods/createAccount.spec.js @@ -1,6 +1,6 @@ -const { expect } = require('chai'); -const createAccount = require('./createAccount'); -const { WALLET_TYPES } = require('../../../CONSTANTS'); +import { expect } from 'chai'; +import createAccount from './createAccount.js'; +import { WALLET_TYPES } from '../../../CONSTANTS.js'; const exceptedException1 = 'getAccount expected index integer to be a property of accountOptions'; diff --git a/packages/wallet-lib/src/types/Wallet/methods/disconnect.js b/packages/wallet-lib/src/types/Wallet/methods/disconnect.js index c0a042b4b2a..b700afd3051 100644 --- a/packages/wallet-lib/src/types/Wallet/methods/disconnect.js +++ b/packages/wallet-lib/src/types/Wallet/methods/disconnect.js @@ -14,4 +14,4 @@ async function disconnect() { } } } -module.exports = disconnect; +export default disconnect; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Wallet/methods/dumpStorage.js b/packages/wallet-lib/src/types/Wallet/methods/dumpStorage.js index ac141828187..4d2848c69d5 100644 --- a/packages/wallet-lib/src/types/Wallet/methods/dumpStorage.js +++ b/packages/wallet-lib/src/types/Wallet/methods/dumpStorage.js @@ -1,4 +1,4 @@ -const logger = require('../../../logger'); +import logger from '../../../logger/index.js'; const defaultOptions = { log: false, @@ -50,4 +50,4 @@ function dumpStorage(options) { return storageDump; } -module.exports = dumpStorage; +export default dumpStorage; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Wallet/methods/exportWallet.js b/packages/wallet-lib/src/types/Wallet/methods/exportWallet.js index 39cc12bc41f..ff74fadd89d 100644 --- a/packages/wallet-lib/src/types/Wallet/methods/exportWallet.js +++ b/packages/wallet-lib/src/types/Wallet/methods/exportWallet.js @@ -1,4 +1,4 @@ -const { WALLET_TYPES } = require('../../../CONSTANTS'); +import { WALLET_TYPES } from '../../../CONSTANTS.js'; function exportMnemonic(mnemonic) { if (!mnemonic) throw new Error('Wallet was not initiated with a mnemonic, can\'t export it'); @@ -77,7 +77,7 @@ function exportHDPublicWallet(outputType = 'HDPublicKey') { * @param outputType - Allow to overwrite the default output type * @return {Mnemonic|HDPrivateKey} */ -module.exports = function exportWallet(outputType) { +export default function exportWallet(outputType) { switch (this.walletType) { case WALLET_TYPES.PRIVATEKEY: case WALLET_TYPES.SINGLE_ADDRESS: diff --git a/packages/wallet-lib/src/types/Wallet/methods/exportWallet.spec.js b/packages/wallet-lib/src/types/Wallet/methods/exportWallet.spec.js index b0af3f6c3a5..21cd3ea508d 100644 --- a/packages/wallet-lib/src/types/Wallet/methods/exportWallet.spec.js +++ b/packages/wallet-lib/src/types/Wallet/methods/exportWallet.spec.js @@ -1,11 +1,12 @@ -const { expect } = require('chai'); -const Wallet = require('../Wallet'); -const { PrivateKey, Networks } = require('@dashevo/dashcore-lib'); -const exportWallet = require('./exportWallet'); -const { WALLET_TYPES } = require('../../../CONSTANTS'); -const cR4t6ePrivateKey = require('../../../../fixtures/cR4t6e_pk'); -const knifeMnemonic = require('../../../../fixtures/knifeeasily'); -const cR4t6eFixture = require("../../../../fixtures/cR4t6e_pk"); +import { expect } from 'chai'; +import Wallet from '../Wallet.js'; +import dashcore from '@dashevo/dashcore-lib'; +const { PrivateKey, Networks } = dashcore; +import exportWallet from './exportWallet.js'; +import { WALLET_TYPES } from '../../../CONSTANTS.js'; +import cR4t6ePrivateKey from '../../../../fixtures/cR4t6e_pk.json' with { type: 'json' }; +import knifeMnemonic from '../../../../fixtures/knifeeasily.json' with { type: 'json' }; +import cR4t6eFixture from '../../../../fixtures/cR4t6e_pk.json' with { type: 'json' }; const cR4t6ePublicKey = new PrivateKey(cR4t6eFixture.privateKey).toPublicKey(); describe('Wallet - export Wallet', function suite() { diff --git a/packages/wallet-lib/src/types/Wallet/methods/fromAddress.js b/packages/wallet-lib/src/types/Wallet/methods/fromAddress.js index ebf0aba2925..ab5fb616e6a 100644 --- a/packages/wallet-lib/src/types/Wallet/methods/fromAddress.js +++ b/packages/wallet-lib/src/types/Wallet/methods/fromAddress.js @@ -1,12 +1,12 @@ -const { is } = require('../../../utils'); -const DerivableKeyChain = require('../../DerivableKeyChain/DerivableKeyChain'); -const { WALLET_TYPES } = require('../../../CONSTANTS'); -const KeyChainStore = require('../../KeyChainStore/KeyChainStore'); +import { is } from '../../../utils/index.js'; +import DerivableKeyChain from '../../DerivableKeyChain/DerivableKeyChain.js'; +import { WALLET_TYPES } from '../../../CONSTANTS.js'; +import KeyChainStore from '../../KeyChainStore/KeyChainStore.js'; /** * @param address */ -module.exports = function fromAddress(address, network) { +export default function fromAddress(address, network) { if (!is.address(address)) throw new Error('Expected a valid address (typeof Address or String)'); this.walletType = WALLET_TYPES.ADDRESS; this.mnemonic = null; diff --git a/packages/wallet-lib/src/types/Wallet/methods/fromAddress.spec.js b/packages/wallet-lib/src/types/Wallet/methods/fromAddress.spec.js index f0839308fc9..7ead5b918a1 100644 --- a/packages/wallet-lib/src/types/Wallet/methods/fromAddress.spec.js +++ b/packages/wallet-lib/src/types/Wallet/methods/fromAddress.spec.js @@ -1,8 +1,9 @@ -const { expect } = require('chai'); -const { PrivateKey } = require('@dashevo/dashcore-lib'); -const fromAddress = require('./fromAddress'); -const cR4t6eFixture = require('../../../../fixtures/cR4t6e_pk'); -const { WALLET_TYPES } = require('../../../CONSTANTS'); +import { expect } from 'chai'; +import dashcore from '@dashevo/dashcore-lib'; +const { PrivateKey } = dashcore; +import fromAddress from './fromAddress.js'; +import cR4t6eFixture from '../../../../fixtures/cR4t6e_pk.json' with { type: 'json' }; +import { WALLET_TYPES } from '../../../CONSTANTS.js'; const cR4t6ePublicKey = new PrivateKey(cR4t6eFixture.privateKey).toPublicKey(); describe('Wallet - fromAddress', function suite() { diff --git a/packages/wallet-lib/src/types/Wallet/methods/fromHDPrivateKey.js b/packages/wallet-lib/src/types/Wallet/methods/fromHDPrivateKey.js index a90dd2ca516..5b6808b41c2 100644 --- a/packages/wallet-lib/src/types/Wallet/methods/fromHDPrivateKey.js +++ b/packages/wallet-lib/src/types/Wallet/methods/fromHDPrivateKey.js @@ -1,16 +1,17 @@ -const { HDPrivateKey } = require('@dashevo/dashcore-lib'); -const { +import dashcore from '@dashevo/dashcore-lib'; +const { HDPrivateKey } = dashcore; +import { is, -} = require('../../../utils'); -const DerivableKeyChain = require('../../DerivableKeyChain/DerivableKeyChain'); -const KeyChainStore = require('../../KeyChainStore/KeyChainStore'); -const { WALLET_TYPES } = require('../../../CONSTANTS'); +} from '../../../utils/index.js'; +import DerivableKeyChain from '../../DerivableKeyChain/DerivableKeyChain.js'; +import KeyChainStore from '../../KeyChainStore/KeyChainStore.js'; +import { WALLET_TYPES } from '../../../CONSTANTS.js'; /** * Will set a wallet to work with a seed (HDPrivateKey) * @param hdPrivateKey */ -module.exports = function fromHDPrivateKey(hdPrivateKey) { +export default function fromHDPrivateKey(hdPrivateKey) { if (!is.HDPrivateKey(hdPrivateKey)) throw new Error('Expected a valid HDPrivateKey (typeof HDPrivateKey or String)'); this.walletType = WALLET_TYPES.HDWALLET; this.mnemonic = null; diff --git a/packages/wallet-lib/src/types/Wallet/methods/fromHDPrivateKey.spec.js b/packages/wallet-lib/src/types/Wallet/methods/fromHDPrivateKey.spec.js index c947a076b4c..5a854c91b4e 100644 --- a/packages/wallet-lib/src/types/Wallet/methods/fromHDPrivateKey.spec.js +++ b/packages/wallet-lib/src/types/Wallet/methods/fromHDPrivateKey.spec.js @@ -1,7 +1,7 @@ -const { expect } = require('chai'); -const fromHDPrivateKey = require('./fromHDPrivateKey'); -const knifeFixture = require('../../../../fixtures/knifeeasily'); -const { WALLET_TYPES } = require('../../../CONSTANTS'); +import { expect } from 'chai'; +import fromHDPrivateKey from './fromHDPrivateKey.js'; +import knifeFixture from '../../../../fixtures/knifeeasily.json' with { type: 'json' }; +import { WALLET_TYPES } from '../../../CONSTANTS.js'; describe('Wallet - fromHDPrivateKey', function suite() { this.timeout(10000); diff --git a/packages/wallet-lib/src/types/Wallet/methods/fromHDPublicKey.js b/packages/wallet-lib/src/types/Wallet/methods/fromHDPublicKey.js index 1a6b5aacdfc..9afa69677d0 100644 --- a/packages/wallet-lib/src/types/Wallet/methods/fromHDPublicKey.js +++ b/packages/wallet-lib/src/types/Wallet/methods/fromHDPublicKey.js @@ -1,15 +1,15 @@ -const Dashcore = require('@dashevo/dashcore-lib'); -const { is } = require('../../../utils'); -const DerivableKeyChain = require('../../DerivableKeyChain/DerivableKeyChain'); -const { WALLET_TYPES } = require('../../../CONSTANTS'); -const KeyChainStore = require('../../KeyChainStore/KeyChainStore'); +import Dashcore from '@dashevo/dashcore-lib'; +import { is } from '../../../utils/index.js'; +import DerivableKeyChain from '../../DerivableKeyChain/DerivableKeyChain.js'; +import { WALLET_TYPES } from '../../../CONSTANTS.js'; +import KeyChainStore from '../../KeyChainStore/KeyChainStore.js'; const normalizeHDPubKey = (key) => (is.string(key) ? Dashcore.HDPublicKey(key) : key); /** * Will set a wallet to work with a on readonly mode from a HDPublicKey * @param HDPublicKey */ -module.exports = function fromHDPublicKey(_hdPublicKey) { +export default function fromHDPublicKey(_hdPublicKey) { if (!is.HDPublicKey(_hdPublicKey)) throw new Error('Expected a valid HDPublicKey (typeof HDPublicKey or String)'); this.walletType = WALLET_TYPES.HDPUBLIC; this.mnemonic = null; diff --git a/packages/wallet-lib/src/types/Wallet/methods/fromHDPublicKey.spec.js b/packages/wallet-lib/src/types/Wallet/methods/fromHDPublicKey.spec.js index 8a8086b7cd9..2f447129bfe 100644 --- a/packages/wallet-lib/src/types/Wallet/methods/fromHDPublicKey.spec.js +++ b/packages/wallet-lib/src/types/Wallet/methods/fromHDPublicKey.spec.js @@ -1,9 +1,9 @@ -const Dashcore = require('@dashevo/dashcore-lib'); -const { expect } = require('chai'); -const Wallet = require('../Wallet'); -const fromHDPublicKey = require('./fromHDPublicKey'); -const gatherSail = require('../../../../fixtures/gathersail'); -const { WALLET_TYPES } = require('../../../CONSTANTS'); +import Dashcore from '@dashevo/dashcore-lib'; +import { expect } from 'chai'; +import Wallet from '../Wallet.js'; +import fromHDPublicKey from './fromHDPublicKey.js'; +import gatherSail from '../../../../fixtures/gathersail.json' with { type: 'json' }; +import { WALLET_TYPES } from '../../../CONSTANTS.js'; /** * Theses first set of data labeled gatherSail correspond to the following mnemonic: * gather sail face invite together focus waste barely excuse slide harbor hint diff --git a/packages/wallet-lib/src/types/Wallet/methods/fromMnemonic.js b/packages/wallet-lib/src/types/Wallet/methods/fromMnemonic.js index b0b436fbbf4..a0516f43f4b 100644 --- a/packages/wallet-lib/src/types/Wallet/methods/fromMnemonic.js +++ b/packages/wallet-lib/src/types/Wallet/methods/fromMnemonic.js @@ -1,16 +1,16 @@ -const { +import { mnemonicToHDPrivateKey, is, -} = require('../../../utils'); -const DerivableKeyChain = require('../../DerivableKeyChain/DerivableKeyChain'); -const KeyChainStore = require('../../KeyChainStore/KeyChainStore'); -const { WALLET_TYPES } = require('../../../CONSTANTS'); +} from '../../../utils/index.js'; +import DerivableKeyChain from '../../DerivableKeyChain/DerivableKeyChain.js'; +import KeyChainStore from '../../KeyChainStore/KeyChainStore.js'; +import { WALLET_TYPES } from '../../../CONSTANTS.js'; /** * Will set a wallet to work with a mnemonic (keychain, walletType & HDPrivateKey) * @param mnemonic */ -module.exports = function fromMnemonic(mnemonic, network, passphrase = '') { +export default function fromMnemonic(mnemonic, network, passphrase = '') { if (!is.mnemonic(mnemonic)) { throw new Error('Expected a valid mnemonic (typeof String or Mnemonic)'); } diff --git a/packages/wallet-lib/src/types/Wallet/methods/fromMnemonic.spec.js b/packages/wallet-lib/src/types/Wallet/methods/fromMnemonic.spec.js index 85f498c6172..23cd06f9c4e 100644 --- a/packages/wallet-lib/src/types/Wallet/methods/fromMnemonic.spec.js +++ b/packages/wallet-lib/src/types/Wallet/methods/fromMnemonic.spec.js @@ -1,8 +1,8 @@ -const Dashcore = require('@dashevo/dashcore-lib'); -const { expect } = require('chai'); -const fromMnemonic = require('./fromMnemonic'); -const knifeFixture = require('../../../../fixtures/knifeeasily'); -const { WALLET_TYPES } = require('../../../CONSTANTS'); +import Dashcore from '@dashevo/dashcore-lib'; +import { expect } from 'chai'; +import fromMnemonic from './fromMnemonic.js'; +import knifeFixture from '../../../../fixtures/knifeeasily.json' with { type: 'json' }; +import { WALLET_TYPES } from '../../../CONSTANTS.js'; describe('Wallet - fromMnemonic', function suite() { this.timeout(10000); diff --git a/packages/wallet-lib/src/types/Wallet/methods/fromPrivateKey.js b/packages/wallet-lib/src/types/Wallet/methods/fromPrivateKey.js index 60912dcac17..7b59f5f1ab8 100644 --- a/packages/wallet-lib/src/types/Wallet/methods/fromPrivateKey.js +++ b/packages/wallet-lib/src/types/Wallet/methods/fromPrivateKey.js @@ -1,13 +1,13 @@ -const { is } = require('../../../utils'); -const DerivableKeyChain = require('../../DerivableKeyChain/DerivableKeyChain'); -const { WALLET_TYPES } = require('../../../CONSTANTS'); -const KeyChainStore = require('../../KeyChainStore/KeyChainStore'); +import { is } from '../../../utils/index.js'; +import DerivableKeyChain from '../../DerivableKeyChain/DerivableKeyChain.js'; +import { WALLET_TYPES } from '../../../CONSTANTS.js'; +import KeyChainStore from '../../KeyChainStore/KeyChainStore.js'; /** * Will set a wallet to work with a mnemonic (keychain, walletType & HDPrivateKey) * @param privateKey */ -module.exports = function fromPrivateKey(privateKey, network) { +export default function fromPrivateKey(privateKey, network) { if (!is.privateKey(privateKey)) throw new Error('Expected a valid private key (typeof PrivateKey or String)'); this.walletType = WALLET_TYPES.PRIVATEKEY; this.mnemonic = null; diff --git a/packages/wallet-lib/src/types/Wallet/methods/fromPrivateKey.spec.js b/packages/wallet-lib/src/types/Wallet/methods/fromPrivateKey.spec.js index 4b6ca5e89ab..4d779c2f98f 100644 --- a/packages/wallet-lib/src/types/Wallet/methods/fromPrivateKey.spec.js +++ b/packages/wallet-lib/src/types/Wallet/methods/fromPrivateKey.spec.js @@ -1,7 +1,7 @@ -const { expect } = require('chai'); -const fromPrivateKey = require('./fromPrivateKey'); -const cR4t6eFixture = require('../../../../fixtures/cR4t6e_pk'); -const { WALLET_TYPES } = require('../../../CONSTANTS'); +import { expect } from 'chai'; +import fromPrivateKey from './fromPrivateKey.js'; +import cR4t6eFixture from '../../../../fixtures/cR4t6e_pk.json' with { type: 'json' }; +import { WALLET_TYPES } from '../../../CONSTANTS.js'; describe('Wallet - fromPrivateKey', function suite() { this.timeout(10000); diff --git a/packages/wallet-lib/src/types/Wallet/methods/fromPublicKey.js b/packages/wallet-lib/src/types/Wallet/methods/fromPublicKey.js index c86dc6d6e37..a8388f15954 100644 --- a/packages/wallet-lib/src/types/Wallet/methods/fromPublicKey.js +++ b/packages/wallet-lib/src/types/Wallet/methods/fromPublicKey.js @@ -1,13 +1,13 @@ -const { is } = require('../../../utils'); -const DerivableKeyChain = require('../../DerivableKeyChain/DerivableKeyChain'); -const { WALLET_TYPES } = require('../../../CONSTANTS'); -const KeyChainStore = require('../../KeyChainStore/KeyChainStore'); +import { is } from '../../../utils/index.js'; +import DerivableKeyChain from '../../DerivableKeyChain/DerivableKeyChain.js'; +import { WALLET_TYPES } from '../../../CONSTANTS.js'; +import KeyChainStore from '../../KeyChainStore/KeyChainStore.js'; /** * Will set a wallet to work with a mnemonic (keychain, walletType & HDPrivateKey) * @param privateKey */ -module.exports = function fromPublicKey(publicKey, network) { +export default function fromPublicKey(publicKey, network) { if (!is.publicKey(publicKey)) throw new Error('Expected a valid public key (typeof PublicKey or String)'); this.walletType = WALLET_TYPES.PUBLICKEY; this.mnemonic = null; diff --git a/packages/wallet-lib/src/types/Wallet/methods/fromPublicKey.spec.js b/packages/wallet-lib/src/types/Wallet/methods/fromPublicKey.spec.js index 07890f2d45d..f50511ea27c 100644 --- a/packages/wallet-lib/src/types/Wallet/methods/fromPublicKey.spec.js +++ b/packages/wallet-lib/src/types/Wallet/methods/fromPublicKey.spec.js @@ -1,8 +1,9 @@ -const { expect } = require('chai'); -const { PrivateKey } = require('@dashevo/dashcore-lib'); -const fromPublicKey = require('./fromPublicKey'); -const cR4t6eFixture = require('../../../../fixtures/cR4t6e_pk'); -const { WALLET_TYPES } = require('../../../CONSTANTS'); +import { expect } from 'chai'; +import dashcore from '@dashevo/dashcore-lib'; +const { PrivateKey } = dashcore; +import fromPublicKey from './fromPublicKey.js'; +import cR4t6eFixture from '../../../../fixtures/cR4t6e_pk.json' with { type: 'json' }; +import { WALLET_TYPES } from '../../../CONSTANTS.js'; const cR4t6ePublicKey = new PrivateKey(cR4t6eFixture.privateKey).toPublicKey(); describe('Wallet - fromPublicKey', function suite() { diff --git a/packages/wallet-lib/src/types/Wallet/methods/fromSeed.js b/packages/wallet-lib/src/types/Wallet/methods/fromSeed.js index 038fc138e6b..947ea8a74d4 100644 --- a/packages/wallet-lib/src/types/Wallet/methods/fromSeed.js +++ b/packages/wallet-lib/src/types/Wallet/methods/fromSeed.js @@ -1,14 +1,14 @@ -const { +import { is, seedToHDPrivateKey, -} = require('../../../utils'); +} from '../../../utils/index.js'; /** * Will set a wallet to work with a seed (HDPrivateKey) * fixme: Term seed is often use, but we might want to rename to fromHDPrivateKey * @param seed */ -module.exports = function fromSeed(seed, network) { +export default function fromSeed(seed, network) { if (!is.seed(seed)) throw new Error('Expected a valid seed (typeof string)'); return this.fromHDPrivateKey(seedToHDPrivateKey(seed, network)); }; diff --git a/packages/wallet-lib/src/types/Wallet/methods/fromSeed.spec.js b/packages/wallet-lib/src/types/Wallet/methods/fromSeed.spec.js index a0a9ec827ca..7bac04740bd 100644 --- a/packages/wallet-lib/src/types/Wallet/methods/fromSeed.spec.js +++ b/packages/wallet-lib/src/types/Wallet/methods/fromSeed.spec.js @@ -1,8 +1,8 @@ -const { expect } = require('chai'); -const fromSeed = require('./fromSeed'); -const fromHDPrivateKey = require('./fromHDPrivateKey'); -const knifeFixture = require('../../../../fixtures/knifeeasily'); -const { WALLET_TYPES } = require('../../../CONSTANTS'); +import { expect } from 'chai'; +import fromSeed from './fromSeed.js'; +import fromHDPrivateKey from './fromHDPrivateKey.js'; +import knifeFixture from '../../../../fixtures/knifeeasily.json' with { type: 'json' }; +import { WALLET_TYPES } from '../../../CONSTANTS.js'; describe('Wallet - fromSeed', function suite() { this.timeout(10000); diff --git a/packages/wallet-lib/src/types/Wallet/methods/generateNewWalletId.js b/packages/wallet-lib/src/types/Wallet/methods/generateNewWalletId.js index 66d4f87c24e..7ff3c1aa7c1 100644 --- a/packages/wallet-lib/src/types/Wallet/methods/generateNewWalletId.js +++ b/packages/wallet-lib/src/types/Wallet/methods/generateNewWalletId.js @@ -1,11 +1,11 @@ -const { mnemonicToWalletId } = require('../../../utils'); -const { WALLET_TYPES } = require('../../../CONSTANTS'); +import { mnemonicToWalletId } from '../../../utils/index.js'; +import { WALLET_TYPES } from '../../../CONSTANTS.js'; /** * Generate a wallet id for a specific wallet based on it's (HD)privateKey * @return walletId */ -module.exports = function generateNewWalletId() { +export default function generateNewWalletId() { const { walletType } = this; const errorMessageBase = 'Cannot generate a walletId'; switch (walletType) { diff --git a/packages/wallet-lib/src/types/Wallet/methods/generateNewWalletId.spec.js b/packages/wallet-lib/src/types/Wallet/methods/generateNewWalletId.spec.js index 409a630f449..f991eece62f 100644 --- a/packages/wallet-lib/src/types/Wallet/methods/generateNewWalletId.spec.js +++ b/packages/wallet-lib/src/types/Wallet/methods/generateNewWalletId.spec.js @@ -1,9 +1,9 @@ -const { expect } = require('chai'); -const generateNewWalletId = require('./generateNewWalletId'); -const knifeMnemonic = require('../../../../fixtures/knifeeasily'); -const gatherSail = require('../../../../fixtures/gathersail'); -const cR4t6ePrivateKey = require('../../../../fixtures/cR4t6e_pk'); -const { WALLET_TYPES } = require('../../../CONSTANTS'); +import { expect } from 'chai'; +import generateNewWalletId from './generateNewWalletId.js'; +import knifeMnemonic from '../../../../fixtures/knifeeasily.json' with { type: 'json' }; +import gatherSail from '../../../../fixtures/gathersail.json' with { type: 'json' }; +import cR4t6ePrivateKey from '../../../../fixtures/cR4t6e_pk.json' with { type: 'json' }; +import { WALLET_TYPES } from '../../../CONSTANTS.js'; describe('Wallet - generateNewWalletId', function suite() { this.timeout(10000); diff --git a/packages/wallet-lib/src/types/Wallet/methods/getAccount.js b/packages/wallet-lib/src/types/Wallet/methods/getAccount.js index 8e3f33c7128..f27c4db816c 100644 --- a/packages/wallet-lib/src/types/Wallet/methods/getAccount.js +++ b/packages/wallet-lib/src/types/Wallet/methods/getAccount.js @@ -1,6 +1,6 @@ -const _ = require('lodash'); -const { is } = require('../../../utils'); -const EVENTS = require('../../../EVENTS'); +import _ from 'lodash'; +import { is } from '../../../utils/index.js'; +import EVENTS from '../../../EVENTS.js'; const defaultOpts = { index: 0, @@ -35,4 +35,4 @@ async function getAccount(accountOpts = defaultOpts) { return acc[0] || this.createAccount(opts); } -module.exports = getAccount; +export default getAccount; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/Wallet/methods/getAccount.spec.js b/packages/wallet-lib/src/types/Wallet/methods/getAccount.spec.js index 597d690f930..871949bf03b 100644 --- a/packages/wallet-lib/src/types/Wallet/methods/getAccount.spec.js +++ b/packages/wallet-lib/src/types/Wallet/methods/getAccount.spec.js @@ -1,7 +1,7 @@ -const { expect } = require('chai'); -const getAccount = require('./getAccount'); -const { WALLET_TYPES } = require('../../../CONSTANTS'); -const expectThrowsAsync = require('../../../utils/expectThrowsAsync'); +import { expect } from 'chai'; +import getAccount from './getAccount.js'; +import { WALLET_TYPES } from '../../../CONSTANTS.js'; +import expectThrowsAsync from '../../../utils/expectThrowsAsync.js'; const exceptedException1 = 'getAccount expected index integer to be a property of accountOptions'; diff --git a/packages/wallet-lib/src/types/Wallet/methods/sweepWallet.js b/packages/wallet-lib/src/types/Wallet/methods/sweepWallet.js index 1beb89ee770..82f8d72a306 100644 --- a/packages/wallet-lib/src/types/Wallet/methods/sweepWallet.js +++ b/packages/wallet-lib/src/types/Wallet/methods/sweepWallet.js @@ -1,8 +1,8 @@ // todo refactor promise function to fit no-promise-executor-return /* eslint-disable no-promise-executor-return */ -const { WALLET_TYPES } = require('../../../CONSTANTS'); -const logger = require('../../../logger'); +import { WALLET_TYPES } from '../../../CONSTANTS.js'; +import logger from '../../../logger/index.js'; /** * This will sweep any paper wallet with remaining UTXOS to another Wallet created * via a random new mnemonic or via passed one. @@ -62,4 +62,4 @@ async function sweepWallet(opts = {}) { }); } -module.exports = sweepWallet; +export default sweepWallet; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/WalletStore/WalletStore.js b/packages/wallet-lib/src/types/WalletStore/WalletStore.js index b4bbd3dbcfa..106125f3c0b 100644 --- a/packages/wallet-lib/src/types/WalletStore/WalletStore.js +++ b/packages/wallet-lib/src/types/WalletStore/WalletStore.js @@ -13,10 +13,15 @@ class WalletStore { } } -WalletStore.prototype.createPathState = require('./methods/createPathState'); -WalletStore.prototype.getIdentityIdByIndex = require('./methods/getIdentityIdByIndex'); -WalletStore.prototype.getIndexedIdentityIds = require('./methods/getIndexedIdentityIds'); -WalletStore.prototype.getPathState = require('./methods/getPathState'); -WalletStore.prototype.insertIdentityIdAtIndex = require('./methods/insertIdentityIdAtIndex'); +import _WalletStore_createPathState from './methods/createPathState.js'; +WalletStore.prototype.createPathState = _WalletStore_createPathState; +import _WalletStore_getIdentityIdByIndex from './methods/getIdentityIdByIndex.js'; +WalletStore.prototype.getIdentityIdByIndex = _WalletStore_getIdentityIdByIndex; +import _WalletStore_getIndexedIdentityIds from './methods/getIndexedIdentityIds.js'; +WalletStore.prototype.getIndexedIdentityIds = _WalletStore_getIndexedIdentityIds; +import _WalletStore_getPathState from './methods/getPathState.js'; +WalletStore.prototype.getPathState = _WalletStore_getPathState; +import _WalletStore_insertIdentityIdAtIndex from './methods/insertIdentityIdAtIndex.js'; +WalletStore.prototype.insertIdentityIdAtIndex = _WalletStore_insertIdentityIdAtIndex; -module.exports = WalletStore; +export default WalletStore; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/WalletStore/WalletStore.spec.js b/packages/wallet-lib/src/types/WalletStore/WalletStore.spec.js index 5f9aceafb5a..731023550d6 100644 --- a/packages/wallet-lib/src/types/WalletStore/WalletStore.spec.js +++ b/packages/wallet-lib/src/types/WalletStore/WalletStore.spec.js @@ -1,5 +1,5 @@ -const { expect } = require('chai'); -const WalletStore = require('./WalletStore'); +import { expect } from 'chai'; +import WalletStore from './WalletStore.js'; let walletStore; describe('WalletStore - Class', ()=> { diff --git a/packages/wallet-lib/src/types/WalletStore/methods/createPathState.js b/packages/wallet-lib/src/types/WalletStore/methods/createPathState.js index 2dd215942ce..9922687c2e2 100644 --- a/packages/wallet-lib/src/types/WalletStore/methods/createPathState.js +++ b/packages/wallet-lib/src/types/WalletStore/methods/createPathState.js @@ -1,4 +1,4 @@ -const logger = require('../../../logger'); +import logger from '../../../logger/index.js'; function createPathState(path) { logger.debug(`WalletStore - Creating path state ${path}`); @@ -9,4 +9,4 @@ function createPathState(path) { }); } } -module.exports = createPathState; +export default createPathState; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/WalletStore/methods/getIdentityIdByIndex.js b/packages/wallet-lib/src/types/WalletStore/methods/getIdentityIdByIndex.js index f90d1e5782a..a2dd9d82a48 100644 --- a/packages/wallet-lib/src/types/WalletStore/methods/getIdentityIdByIndex.js +++ b/packages/wallet-lib/src/types/WalletStore/methods/getIdentityIdByIndex.js @@ -1,4 +1,4 @@ function getIdentityIdByIndex(identityIndex) { return this.state.identities.get(identityIndex); } -module.exports = getIdentityIdByIndex; +export default getIdentityIdByIndex; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/WalletStore/methods/getIndexedIdentityIds.js b/packages/wallet-lib/src/types/WalletStore/methods/getIndexedIdentityIds.js index e251ba4806b..42845feac31 100644 --- a/packages/wallet-lib/src/types/WalletStore/methods/getIndexedIdentityIds.js +++ b/packages/wallet-lib/src/types/WalletStore/methods/getIndexedIdentityIds.js @@ -1,4 +1,4 @@ function getIndexedIdentityIds() { return [...this.state.identities.values()]; } -module.exports = getIndexedIdentityIds; +export default getIndexedIdentityIds; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/WalletStore/methods/getPathState.js b/packages/wallet-lib/src/types/WalletStore/methods/getPathState.js index d2143cd4d95..fab7202f5b7 100644 --- a/packages/wallet-lib/src/types/WalletStore/methods/getPathState.js +++ b/packages/wallet-lib/src/types/WalletStore/methods/getPathState.js @@ -1,4 +1,4 @@ function getPathState(path) { return this.state.paths.get(path); } -module.exports = getPathState; +export default getPathState; \ No newline at end of file diff --git a/packages/wallet-lib/src/types/WalletStore/methods/insertIdentityIdAtIndex.js b/packages/wallet-lib/src/types/WalletStore/methods/insertIdentityIdAtIndex.js index ee8a9325190..181220527c5 100644 --- a/packages/wallet-lib/src/types/WalletStore/methods/insertIdentityIdAtIndex.js +++ b/packages/wallet-lib/src/types/WalletStore/methods/insertIdentityIdAtIndex.js @@ -1,4 +1,4 @@ -const IdentityReplaceError = require('../../../errors/IndentityIdReplaceError'); +import IdentityReplaceError from '../../../errors/IndentityIdReplaceError.js'; function insertIdentityIdAtIndex(identityId, identityIndex) { const existingId = this.getIdentityIdByIndex(identityIndex); @@ -9,4 +9,4 @@ function insertIdentityIdAtIndex(identityId, identityIndex) { this.state.identities.set(identityIndex, identityId); } -module.exports = insertIdentityIdAtIndex; +export default insertIdentityIdAtIndex; \ No newline at end of file diff --git a/packages/wallet-lib/src/utils/bip44/ensureAddressesToGapLimit.js b/packages/wallet-lib/src/utils/bip44/ensureAddressesToGapLimit.js index 318d7959f8f..fbd1b522729 100644 --- a/packages/wallet-lib/src/utils/bip44/ensureAddressesToGapLimit.js +++ b/packages/wallet-lib/src/utils/bip44/ensureAddressesToGapLimit.js @@ -1,9 +1,9 @@ -const logger = require('../../logger'); -const { BIP44_ADDRESS_GAP } = require('../../CONSTANTS'); -const is = require('../is'); +import logger from '../../logger/index.js'; +import { BIP44_ADDRESS_GAP } from '../../CONSTANTS.js'; +import is from '../is.js'; -const getMissingIndexes = require('./getMissingIndexes'); -const isContiguousPath = require('./isContiguousPath'); +import getMissingIndexes from './getMissingIndexes.js'; +import isContiguousPath from './isContiguousPath.js'; const sortByIndex = (a, b) => parseInt(a.split('/')[5], 10) - parseInt(b.split('/')[5], 10); @@ -108,4 +108,4 @@ function ensureAccountAddressesToGapLimit(walletStore, walletType, accountIndex, return generated; } -module.exports = ensureAccountAddressesToGapLimit; +export default ensureAccountAddressesToGapLimit; \ No newline at end of file diff --git a/packages/wallet-lib/src/utils/bip44/ensureAddressesToGapLimit.spec.js b/packages/wallet-lib/src/utils/bip44/ensureAddressesToGapLimit.spec.js index a702a57263e..02e36cf7686 100644 --- a/packages/wallet-lib/src/utils/bip44/ensureAddressesToGapLimit.spec.js +++ b/packages/wallet-lib/src/utils/bip44/ensureAddressesToGapLimit.spec.js @@ -1,6 +1,6 @@ -const {expect} = require('chai'); -const ensureAddressesToGapLimit = require('./ensureAddressesToGapLimit'); -const {CONSTANTS} = require("../../index"); +import {expect} from 'chai'; +import ensureAddressesToGapLimit from './ensureAddressesToGapLimit.js'; +import {CONSTANTS} from '../../index.js'; const walletStore = { addresses: { diff --git a/packages/wallet-lib/src/utils/bip44/getMissingIndexes.js b/packages/wallet-lib/src/utils/bip44/getMissingIndexes.js index b7b50829b6b..3a32f4536e4 100644 --- a/packages/wallet-lib/src/utils/bip44/getMissingIndexes.js +++ b/packages/wallet-lib/src/utils/bip44/getMissingIndexes.js @@ -1,6 +1,6 @@ -const is = require('../is'); +import is from '../is.js'; -module.exports = function getMissingIndexes(paths, fromOrigin = true) { +export default function getMissingIndexes(paths, fromOrigin = true) { if (!is.arr(paths)) return false; let sortedIndexes = []; diff --git a/packages/wallet-lib/src/utils/bip44/isContiguousPath.js b/packages/wallet-lib/src/utils/bip44/isContiguousPath.js index 608148dd7de..ec704cbbf2d 100644 --- a/packages/wallet-lib/src/utils/bip44/isContiguousPath.js +++ b/packages/wallet-lib/src/utils/bip44/isContiguousPath.js @@ -1,6 +1,6 @@ -const is = require('../is'); +import is from '../is.js'; -module.exports = function isContiguousPath(currPath, prevPath) { +export default function isContiguousPath(currPath, prevPath) { if (is.undef(currPath)) return false; const splitCurrPath = currPath.split('/'); diff --git a/packages/wallet-lib/src/utils/calculateDuffBalance.js b/packages/wallet-lib/src/utils/calculateDuffBalance.js index f32da7d67ea..6491749d728 100644 --- a/packages/wallet-lib/src/utils/calculateDuffBalance.js +++ b/packages/wallet-lib/src/utils/calculateDuffBalance.js @@ -5,7 +5,7 @@ * @param type {{'confirmed','unconfirmed','total'}} Default: total. Calculate balance by utxo type. * @return {number} Balance in duff */ -module.exports = function calculateDuffBalance(addresses, chainStore, type = 'total') { +export default function calculateDuffBalance(addresses, chainStore, type = 'total') { let totalSat = 0; addresses.forEach((address) => { diff --git a/packages/wallet-lib/src/utils/calculateTransactionFees.js b/packages/wallet-lib/src/utils/calculateTransactionFees.js index 2d9a592bd2b..17e4127b80b 100644 --- a/packages/wallet-lib/src/utils/calculateTransactionFees.js +++ b/packages/wallet-lib/src/utils/calculateTransactionFees.js @@ -1,4 +1,4 @@ -const is = require('./is'); +import is from './is.js'; function calculateTransactionFees(transaction) { if (!is.dashcoreTransaction(transaction)) throw new Error('Expected a valid transaction'); @@ -10,4 +10,4 @@ function calculateTransactionFees(transaction) { const outputAmount = outputs.reduce((acc, output) => (acc + output.satoshis), 0); return transaction.isCoinbase() ? 0 : inputAmount - outputAmount; } -module.exports = calculateTransactionFees; +export default calculateTransactionFees; \ No newline at end of file diff --git a/packages/wallet-lib/src/utils/calculateTransactionFees.spec.js b/packages/wallet-lib/src/utils/calculateTransactionFees.spec.js index ecf44b0701e..7914d7615f6 100644 --- a/packages/wallet-lib/src/utils/calculateTransactionFees.spec.js +++ b/packages/wallet-lib/src/utils/calculateTransactionFees.spec.js @@ -1,6 +1,7 @@ -const { expect } = require('chai'); -const { Transaction } = require('@dashevo/dashcore-lib'); -const calculateTransactionFees = require('./calculateTransactionFees'); +import { expect } from 'chai'; +import dashcore from '@dashevo/dashcore-lib'; +const { Transaction } = dashcore; +import calculateTransactionFees from './calculateTransactionFees.js'; const tx1 = '0300000001b51d5a6f5c7a680bce489e6f5a9b176ac85c49f10db4798867c7d1eb2036fbc3000000006a4730440220283fd42353767188532db4a4f1c3d0a9e96e313196ae1310af6d3006c7aa64ff022027fa50cf065c096f146e00516cb3e28a9bb387a6cf1103aae0592d5c882d25e5012102ba0588ffd3c838b715d7c79bcf1cff2ba69befd5ea52aa3474d66f094536cac0ffffffff0200131a4b000000001976a914838112cc6c85e074aa7f373e942c9f5240c3e13a88ac89959800000000001976a914f728c15b9a5fe4e6d7b6ed74b323e23f5c6e303f88ac00000000'; const tx2 = '0300000001338540c64b794f73913f39f2d42d9139ce7c9d1c0ec5317c62ab4a28d6b0376f000000006b483045022100b996d726d224a762acf8ab3e37c085e796b44960b8e9933571ac57750e8ed05102201c6a36d72f16140d6a152be40add102d95a4ac5b177d300b10c277859690a859012103b5614f077d750a1eaffb23ca188dbcc7e267f4b8ffdedf81cdf970643027191bffffffff02008c8647000000001976a91414b05906daab037707927bc6c83900d5dbf2849688ac09869303000000001976a914791e51fff6554c18216c83d9ca81cf30cc66aff388ac00000000'; diff --git a/packages/wallet-lib/src/utils/castStorageItemsTypes.js b/packages/wallet-lib/src/utils/castStorageItemsTypes.js index 38180a93090..e0836aac6ce 100644 --- a/packages/wallet-lib/src/utils/castStorageItemsTypes.js +++ b/packages/wallet-lib/src/utils/castStorageItemsTypes.js @@ -75,4 +75,4 @@ const castStorageItemsTypes = (originalItem, schema, path = '') => { return { ...acc, ...result }; }, {}); }; -module.exports = castStorageItemsTypes; +export default castStorageItemsTypes; \ No newline at end of file diff --git a/packages/wallet-lib/src/utils/castStorageItemsTypes.spec.js b/packages/wallet-lib/src/utils/castStorageItemsTypes.spec.js index cb5cb75d4a2..780c8a9efc8 100644 --- a/packages/wallet-lib/src/utils/castStorageItemsTypes.spec.js +++ b/packages/wallet-lib/src/utils/castStorageItemsTypes.spec.js @@ -1,9 +1,10 @@ -const _ = require('lodash'); -const {expect} = require('chai'); -const ChainStore = require('../../src/types/ChainStore/ChainStore'); -const castItemTypes = require('./castStorageItemsTypes'); -const {BlockHeader, Transaction} = require('@dashevo/dashcore-lib') -const WalletStore = require("../types/WalletStore/WalletStore"); +import _ from 'lodash'; +import {expect} from 'chai'; +import ChainStore from '../../src/types/ChainStore/ChainStore.js'; +import castItemTypes from './castStorageItemsTypes.js'; +import dashcore from '@dashevo/dashcore-lib'; +const { BlockHeader, Transaction } = dashcore; +import WalletStore from '../types/WalletStore/WalletStore.js'; const mockChainStorage = { "headersMetadata": { diff --git a/packages/wallet-lib/src/utils/categorizeTransactions.js b/packages/wallet-lib/src/utils/categorizeTransactions.js index a117c12388b..c63accddef6 100644 --- a/packages/wallet-lib/src/utils/categorizeTransactions.js +++ b/packages/wallet-lib/src/utils/categorizeTransactions.js @@ -1,6 +1,7 @@ -const { each } = require('lodash'); -const classifyAddresses = require('./classifyAddresses'); -const { TRANSACTION_HISTORY_TYPES } = require('../CONSTANTS'); +import lodash from 'lodash'; +const { each } = lodash; +import classifyAddresses from './classifyAddresses.js'; +import { TRANSACTION_HISTORY_TYPES } from '../CONSTANTS.js'; // TODO: On a private key based wallet, as change and external is similar, // we actually cannot differentiate correctly from an address_transfer @@ -216,4 +217,4 @@ function categorizeTransactions( return categorizedTransactions; } -module.exports = categorizeTransactions; +export default categorizeTransactions; \ No newline at end of file diff --git a/packages/wallet-lib/src/utils/categorizeTransactions.spec.js b/packages/wallet-lib/src/utils/categorizeTransactions.spec.js index 48e0e13a095..0a8b385c835 100644 --- a/packages/wallet-lib/src/utils/categorizeTransactions.spec.js +++ b/packages/wallet-lib/src/utils/categorizeTransactions.spec.js @@ -1,12 +1,14 @@ -const {expect} = require('chai'); -const {Transaction} = require('@dashevo/dashcore-lib'); -const {each} = require('lodash'); -const {WALLET_TYPES} = require('../CONSTANTS'); - -const categorizeTransactions = require('./categorizeTransactions'); -const transactionsWithMetadataFixtures = require('../../fixtures/wallets/apart-trip-dignity/transactions-with-metadata.json'); -const expectedResults = require('../../fixtures/wallets/apart-trip-dignity/categorizeTransactions.expectedResults'); -const getFixtureHDAccountWithStorage = require("../../fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage"); +import {expect} from 'chai'; +import dashcore from '@dashevo/dashcore-lib'; +const { Transaction } = dashcore; +import lodash from 'lodash'; +const { each } = lodash; +import {WALLET_TYPES} from '../CONSTANTS.js'; + +import categorizeTransactions from './categorizeTransactions.js'; +import transactionsWithMetadataFixtures from '../../fixtures/wallets/apart-trip-dignity/transactions-with-metadata.json' with { type: 'json' }; +import expectedResults from '../../fixtures/wallets/apart-trip-dignity/categorizeTransactions.expectedResults.js'; +import getFixtureHDAccountWithStorage from '../../fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage.js'; const mockedHDAccount = getFixtureHDAccountWithStorage(); diff --git a/packages/wallet-lib/src/utils/classifyAddresses.js b/packages/wallet-lib/src/utils/classifyAddresses.js index c6f6f55d297..25667803f56 100644 --- a/packages/wallet-lib/src/utils/classifyAddresses.js +++ b/packages/wallet-lib/src/utils/classifyAddresses.js @@ -1,4 +1,4 @@ -const { WALLET_TYPES, BIP44_LIVENET_ROOT_PATH, BIP44_TESTNET_ROOT_PATH } = require('../CONSTANTS'); +import { WALLET_TYPES, BIP44_LIVENET_ROOT_PATH, BIP44_TESTNET_ROOT_PATH } from '../CONSTANTS.js'; function classifyAddresses(walletStore, accountIndex, walletType, network = 'testnet') { const externalAddressesList = []; @@ -46,4 +46,4 @@ function classifyAddresses(walletStore, accountIndex, walletType, network = 'tes miscAddressesList, }; } -module.exports = classifyAddresses; +export default classifyAddresses; \ No newline at end of file diff --git a/packages/wallet-lib/src/utils/classifyAddresses.spec.js b/packages/wallet-lib/src/utils/classifyAddresses.spec.js index 0e7c9e83b84..fe0915e74c1 100644 --- a/packages/wallet-lib/src/utils/classifyAddresses.spec.js +++ b/packages/wallet-lib/src/utils/classifyAddresses.spec.js @@ -1,7 +1,7 @@ -const {expect} = require('chai'); -const {WALLET_TYPES} = require('../CONSTANTS'); -const classifyAddresses = require('./classifyAddresses'); -const getFixtureHDAccountWithStorage = require("../../fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage"); +import {expect} from 'chai'; +import {WALLET_TYPES} from '../CONSTANTS.js'; +import classifyAddresses from './classifyAddresses.js'; +import getFixtureHDAccountWithStorage from '../../fixtures/wallets/apart-trip-dignity/getFixtureAccountWithStorage.js'; const mockedHDAccount = getFixtureHDAccountWithStorage(); diff --git a/packages/wallet-lib/src/utils/coinSelection.js b/packages/wallet-lib/src/utils/coinSelection.js index 7c3b0926600..ee2b580ffac 100644 --- a/packages/wallet-lib/src/utils/coinSelection.js +++ b/packages/wallet-lib/src/utils/coinSelection.js @@ -1 +1 @@ -module.exports = require('./coinSelections/index'); +export { default } from './coinSelections/index.js'; diff --git a/packages/wallet-lib/src/utils/coinSelection.spec.js b/packages/wallet-lib/src/utils/coinSelection.spec.js index fac952faeee..8c50c9951c8 100644 --- a/packages/wallet-lib/src/utils/coinSelection.spec.js +++ b/packages/wallet-lib/src/utils/coinSelection.spec.js @@ -1,9 +1,11 @@ -const {expect} = require('chai'); -const {Transaction, Address, Script} = require('@dashevo/dashcore-lib'); -const coinSelection = require('./coinSelection'); -const {utxosList} = require('../../fixtures/crackspice'); -const STRATEGIES = require('./coinSelections/strategies'); -const TransactionEstimator = require('./coinSelections/TransactionEstimator') +import {expect} from 'chai'; +import dashcore from '@dashevo/dashcore-lib'; +const { Transaction, Address, Script } = dashcore; +import coinSelection from './coinSelection.js'; +import crackspice from '../../fixtures/crackspice.json' with { type: 'json' }; +const { utxosList } = crackspice; +import STRATEGIES from './coinSelections/strategies/index.js'; +import TransactionEstimator from './coinSelections/TransactionEstimator.js'; const utxosListAsUnspentOutput = utxosList.map((utxo)=> Transaction.UnspentOutput(utxo)); const outputs = { diff --git a/packages/wallet-lib/src/utils/coinSelections/TransactionEstimator.js b/packages/wallet-lib/src/utils/coinSelections/TransactionEstimator.js index 22530490c3b..184d1841e2b 100644 --- a/packages/wallet-lib/src/utils/coinSelections/TransactionEstimator.js +++ b/packages/wallet-lib/src/utils/coinSelections/TransactionEstimator.js @@ -1,9 +1,12 @@ -const _ = require('lodash'); -const { - Address, Script, Transaction, -} = require('@dashevo/dashcore-lib'); -const logger = require('../../logger'); +import _ from 'lodash'; +import dashcore from '@dashevo/dashcore-lib'; const { + Address, + Script, + Transaction, +} = dashcore; +import logger from '../../logger/index.js'; +import { FEES, VERSION_BYTES, TXOUT_DUFFS_VALUE_BYTES, @@ -11,9 +14,9 @@ const { TXIN_OUTPOINT_TXID_BYTES, TXIN_OUTPOINT_INDEX_BYTES, TXIN_SEQUENCE_BYTES, -} = require('../../CONSTANTS'); -const is = require('../is'); -const { varIntSizeBytesFromLength } = require('../varInt'); +} from '../../CONSTANTS.js'; +import is from '../is.js'; +import { varIntSizeBytesFromLength } from '../varInt.js'; const { Output } = Transaction; const calculateInputsSize = (inputs) => { @@ -168,4 +171,4 @@ class TransactionEstimator { logger.info('========================='); } } -module.exports = TransactionEstimator; +export default TransactionEstimator; \ No newline at end of file diff --git a/packages/wallet-lib/src/utils/coinSelections/helpers/index.js b/packages/wallet-lib/src/utils/coinSelections/helpers/index.js index c0bddccd6a9..473bdc57197 100644 --- a/packages/wallet-lib/src/utils/coinSelections/helpers/index.js +++ b/packages/wallet-lib/src/utils/coinSelections/helpers/index.js @@ -1,6 +1,10 @@ -const sortAndVerifyUTXOS = require('./sortAndVerifyUTXOS'); +import sortAndVerifyUTXOS from './sortAndVerifyUTXOS.js'; -module.exports = { +export { + sortAndVerifyUTXOS, +}; + +export default { sortAndVerifyUTXOS, }; diff --git a/packages/wallet-lib/src/utils/coinSelections/helpers/sortAndVerifyUTXOS.js b/packages/wallet-lib/src/utils/coinSelections/helpers/sortAndVerifyUTXOS.js index 058683eb4e4..b0e2a8e01b1 100644 --- a/packages/wallet-lib/src/utils/coinSelections/helpers/sortAndVerifyUTXOS.js +++ b/packages/wallet-lib/src/utils/coinSelections/helpers/sortAndVerifyUTXOS.js @@ -25,4 +25,4 @@ const sort = { const sortAndVerifyUTXOS = (utxosList, opts) => sort.by(utxosList, opts); -module.exports = sortAndVerifyUTXOS; +export default sortAndVerifyUTXOS; \ No newline at end of file diff --git a/packages/wallet-lib/src/utils/coinSelections/index.js b/packages/wallet-lib/src/utils/coinSelections/index.js index 9e3cebbe356..246b58f9ff4 100644 --- a/packages/wallet-lib/src/utils/coinSelections/index.js +++ b/packages/wallet-lib/src/utils/coinSelections/index.js @@ -1,10 +1,11 @@ -const { Transaction } = require('@dashevo/dashcore-lib'); -const STRATEGIES = require('./strategies'); -const InvalidUTXO = require('../../errors/InvalidUTXO'); -const InvalidOutput = require('../../errors/InvalidOutput'); -const CoinSelectionUnsufficientUTXOS = require('../../errors/CoinSelectionUnsufficientUTXOS'); +import dashcore from '@dashevo/dashcore-lib'; +const { Transaction } = dashcore; +import STRATEGIES from './strategies/index.js'; +import InvalidUTXO from '../../errors/InvalidUTXO.js'; +import InvalidOutput from '../../errors/InvalidOutput.js'; +import CoinSelectionUnsufficientUTXOS from '../../errors/CoinSelectionUnsufficientUTXOS.js'; -module.exports = function coinSelection(utxosList, outputsList, deductFee = false, feeCategory = 'normal', strategy = STRATEGIES.simpleDescendingAccumulator) { +export default function coinSelection(utxosList, outputsList, deductFee = false, feeCategory = 'normal', strategy = STRATEGIES.simpleDescendingAccumulator) { if (!utxosList) { throw new Error('A utxosList is required'); } if (utxosList.constructor.name !== Array.name) { throw new Error('UtxosList is expected to be an array of utxos'); } if (utxosList.length < 1) { throw new Error('utxosList must contain at least 1 utxo'); } diff --git a/packages/wallet-lib/src/utils/coinSelections/strategies/index.js b/packages/wallet-lib/src/utils/coinSelections/strategies/index.js index d38fd2a7e0f..ec8ec4c8b64 100644 --- a/packages/wallet-lib/src/utils/coinSelections/strategies/index.js +++ b/packages/wallet-lib/src/utils/coinSelections/strategies/index.js @@ -1,8 +1,9 @@ -const simpleAscendingAccumulator = require('./simpleAscendingAccumulator'); -const simpleDescendingAccumulator = require('./simpleDescendingAccumulator'); +import simpleAscendingAccumulator from './simpleAscendingAccumulator.js'; +import simpleDescendingAccumulator from './simpleDescendingAccumulator.js'; const STRATEGIES = { simpleDescendingAccumulator, simpleAscendingAccumulator, }; -module.exports = STRATEGIES; +export default STRATEGIES; +export { simpleAscendingAccumulator, simpleDescendingAccumulator }; \ No newline at end of file diff --git a/packages/wallet-lib/src/utils/coinSelections/strategies/simpleAscendingAccumulator.js b/packages/wallet-lib/src/utils/coinSelections/strategies/simpleAscendingAccumulator.js index 69cb660ca97..63fcaf871be 100644 --- a/packages/wallet-lib/src/utils/coinSelections/strategies/simpleAscendingAccumulator.js +++ b/packages/wallet-lib/src/utils/coinSelections/strategies/simpleAscendingAccumulator.js @@ -1,5 +1,6 @@ -const { sortBy } = require('lodash'); -const TransactionEstimator = require('../TransactionEstimator'); +import lodash from 'lodash'; +const { sortBy } = lodash; +import TransactionEstimator from '../TransactionEstimator.js'; /** * Given a utxos list and a thresholdSatoshis, will add them * without any further logic up to met with requested params. @@ -69,4 +70,4 @@ const simpleAscendingAccumulator = (utxosList, outputsList, deductFee = false, f utxosValue: txEstimator.getInValue(), }; }; -module.exports = simpleAscendingAccumulator; +export default simpleAscendingAccumulator; \ No newline at end of file diff --git a/packages/wallet-lib/src/utils/coinSelections/strategies/simpleAscendingAccumulator.spec.js b/packages/wallet-lib/src/utils/coinSelections/strategies/simpleAscendingAccumulator.spec.js index 649b3617f8c..985e5ab0292 100644 --- a/packages/wallet-lib/src/utils/coinSelections/strategies/simpleAscendingAccumulator.spec.js +++ b/packages/wallet-lib/src/utils/coinSelections/strategies/simpleAscendingAccumulator.spec.js @@ -1,7 +1,7 @@ -const { expect } = require('chai'); -const { simpleAscendingAccumulator } = require('./index'); -const getUTXOS = require('../../../types/Account/methods/getUTXOS'); -const duringDevelopStore = require('../../../../fixtures/duringdevelop-fullstore-snapshot-1549310417'); +import { expect } from 'chai'; +import { simpleAscendingAccumulator } from './index.js'; +import getUTXOS from '../../../types/Account/methods/getUTXOS.js'; +import duringDevelopStore from '../../../../fixtures/duringdevelop-fullstore-snapshot-1549310417.json' with { type: 'json' }; describe('CoinSelection - Strategy - simpleAscendingAccumulator', () => { describe.skip('it should pass - requires FakeNet', ()=>{ diff --git a/packages/wallet-lib/src/utils/coinSelections/strategies/simpleDescendingAccumulator.js b/packages/wallet-lib/src/utils/coinSelections/strategies/simpleDescendingAccumulator.js index 1a5e9a7a21c..acca3e06347 100644 --- a/packages/wallet-lib/src/utils/coinSelections/strategies/simpleDescendingAccumulator.js +++ b/packages/wallet-lib/src/utils/coinSelections/strategies/simpleDescendingAccumulator.js @@ -1,5 +1,6 @@ -const { sortBy } = require('lodash'); -const TransactionEstimator = require('../TransactionEstimator'); +import lodash from 'lodash'; +const { sortBy } = lodash; +import TransactionEstimator from '../TransactionEstimator.js'; /** * Given a utxos list and a thresholdSatoshis, will add them @@ -67,4 +68,4 @@ const simpleDescendingAccumulator = (utxosList, outputsList, deductFee = false, utxosValue: txEstimator.getInValue(), }; }; -module.exports = simpleDescendingAccumulator; +export default simpleDescendingAccumulator; \ No newline at end of file diff --git a/packages/wallet-lib/src/utils/coinSelections/strategies/simpleDescendingAccumulator.spec.js b/packages/wallet-lib/src/utils/coinSelections/strategies/simpleDescendingAccumulator.spec.js index 6ac79a1f0dc..0b5d9034680 100644 --- a/packages/wallet-lib/src/utils/coinSelections/strategies/simpleDescendingAccumulator.spec.js +++ b/packages/wallet-lib/src/utils/coinSelections/strategies/simpleDescendingAccumulator.spec.js @@ -1,7 +1,7 @@ -const { expect } = require('chai'); -const { simpleDescendingAccumulator } = require('./index'); -const getUTXOS = require('../../../types/Account/methods/getUTXOS'); -const duringDevelopStore = require('../../../../fixtures/duringdevelop-fullstore-snapshot-1549310417'); +import { expect } from 'chai'; +import { simpleDescendingAccumulator } from './index.js'; +import getUTXOS from '../../../types/Account/methods/getUTXOS.js'; +import duringDevelopStore from '../../../../fixtures/duringdevelop-fullstore-snapshot-1549310417.json' with { type: 'json' }; console.error('coinSelection.strategies.simpleDescendingAccumulator needs a rebuilt store'); describe.skip('CoinSelection - Strategy - simpleDescendingAccumulator', () => { diff --git a/packages/wallet-lib/src/utils/crypto.js b/packages/wallet-lib/src/utils/crypto.js index 2859e74dc73..e85d2764899 100644 --- a/packages/wallet-lib/src/utils/crypto.js +++ b/packages/wallet-lib/src/utils/crypto.js @@ -1,4 +1,4 @@ -const crypto = require('crypto'); +import crypto from 'crypto'; function hash(alg, data) { return crypto.createHash(alg).update(data).digest(); @@ -12,7 +12,13 @@ function doubleSha256(data) { return sha256(sha256(data)); } -module.exports = { +export { + hash, + doubleSha256, + sha256, +}; + +export default { hash, doubleSha256, sha256, diff --git a/packages/wallet-lib/src/utils/dashToDuffs.js b/packages/wallet-lib/src/utils/dashToDuffs.js index c540377b2f6..9c9c2d8370b 100644 --- a/packages/wallet-lib/src/utils/dashToDuffs.js +++ b/packages/wallet-lib/src/utils/dashToDuffs.js @@ -1,4 +1,4 @@ -const { DUFFS_PER_DASH } = require('../CONSTANTS'); +import { DUFFS_PER_DASH } from '../CONSTANTS.js'; function dashToDuffs(dash) { if (dash === undefined || dash.constructor.name !== Number.name) { @@ -6,4 +6,4 @@ function dashToDuffs(dash) { } return parseInt((dash * DUFFS_PER_DASH).toFixed(0), 10); } -module.exports = dashToDuffs; +export default dashToDuffs; \ No newline at end of file diff --git a/packages/wallet-lib/src/utils/dashToDuffs.spec.js b/packages/wallet-lib/src/utils/dashToDuffs.spec.js index 598eaf9da50..da528519213 100644 --- a/packages/wallet-lib/src/utils/dashToDuffs.spec.js +++ b/packages/wallet-lib/src/utils/dashToDuffs.spec.js @@ -1,6 +1,6 @@ -const {expect} = require('chai'); -const dashToDuffs = require('./dashToDuffs'); -const {duffsToDash} = require("./index"); +import {expect} from 'chai'; +import dashToDuffs from './dashToDuffs.js'; +import {duffsToDash} from './index.js'; describe('Utils - dashToDuffs', function suite() { it('should correctly convert dash to duffs', () => { diff --git a/packages/wallet-lib/src/utils/duffsToDash.js b/packages/wallet-lib/src/utils/duffsToDash.js index b3d3226da86..b3de6e41199 100644 --- a/packages/wallet-lib/src/utils/duffsToDash.js +++ b/packages/wallet-lib/src/utils/duffsToDash.js @@ -1,4 +1,4 @@ -const { DUFFS_PER_DASH } = require('../CONSTANTS'); +import { DUFFS_PER_DASH } from '../CONSTANTS.js'; function duffsToDash(duffs) { if (duffs === undefined || duffs.constructor.name !== Number.name) { @@ -6,4 +6,4 @@ function duffsToDash(duffs) { } return duffs / DUFFS_PER_DASH; } -module.exports = duffsToDash; +export default duffsToDash; \ No newline at end of file diff --git a/packages/wallet-lib/src/utils/duffsToDash.spec.js b/packages/wallet-lib/src/utils/duffsToDash.spec.js index e15f79a2699..efb298946b0 100644 --- a/packages/wallet-lib/src/utils/duffsToDash.spec.js +++ b/packages/wallet-lib/src/utils/duffsToDash.spec.js @@ -1,6 +1,6 @@ -const {expect} = require('chai'); -const dashToDuffs = require('./dashToDuffs'); -const {duffsToDash} = require("./index"); +import {expect} from 'chai'; +import dashToDuffs from './dashToDuffs.js'; +import {duffsToDash} from './index.js'; describe('Utils - duffsToDash', function suite() { it('should correctly convert duffs to dash', () => { diff --git a/packages/wallet-lib/src/utils/expectThrowsAsync.js b/packages/wallet-lib/src/utils/expectThrowsAsync.js index 71f929f31f4..816d8deb645 100644 --- a/packages/wallet-lib/src/utils/expectThrowsAsync.js +++ b/packages/wallet-lib/src/utils/expectThrowsAsync.js @@ -1,5 +1,5 @@ // eslint-disable-next-line import-x/no-extraneous-dependencies -const { expect } = require('chai'); +import { expect } from 'chai'; const expectThrowsAsync = async (method, errorMessage) => { let error = null; @@ -19,4 +19,4 @@ const expectThrowsAsync = async (method, errorMessage) => { expect(error.message).to.equal(errorMessage); } }; -module.exports = expectThrowsAsync; +export default expectThrowsAsync; \ No newline at end of file diff --git a/packages/wallet-lib/src/utils/extendTransactionsWithMetadata.js b/packages/wallet-lib/src/utils/extendTransactionsWithMetadata.js index 82dea97c717..ea1521b3aa3 100644 --- a/packages/wallet-lib/src/utils/extendTransactionsWithMetadata.js +++ b/packages/wallet-lib/src/utils/extendTransactionsWithMetadata.js @@ -1,5 +1,6 @@ -const { each } = require('lodash'); -const logger = require('../logger'); +import lodash from 'lodash'; +const { each } = lodash; +import logger from '../logger/index.js'; const extendTransactionsWithMetadata = (transactions, transactionsMetadata) => { const transactionsWithMetadata = []; @@ -20,4 +21,4 @@ const extendTransactionsWithMetadata = (transactions, transactionsMetadata) => { }); return transactionsWithMetadata; }; -module.exports = extendTransactionsWithMetadata; +export default extendTransactionsWithMetadata; \ No newline at end of file diff --git a/packages/wallet-lib/src/utils/extendTransactionsWithMetadata.spec.js b/packages/wallet-lib/src/utils/extendTransactionsWithMetadata.spec.js index ef250da96ee..bf1266df8e1 100644 --- a/packages/wallet-lib/src/utils/extendTransactionsWithMetadata.spec.js +++ b/packages/wallet-lib/src/utils/extendTransactionsWithMetadata.spec.js @@ -1,6 +1,7 @@ -const { expect } = require('chai'); -const { Transaction } = require('@dashevo/dashcore-lib'); -const extendTransactionsWithMetadata = require('./extendTransactionsWithMetadata'); +import { expect } from 'chai'; +import dashcore from '@dashevo/dashcore-lib'; +const { Transaction } = dashcore; +import extendTransactionsWithMetadata from './extendTransactionsWithMetadata.js'; const rawtx = '03000000012d9101b84d69adf1b168403ab2bcfbf3d2eebbf87a99a9be05d649d47d6c7bd3010000006a47304402201cc3d6887d5161eba36a5e6fb1ccd8e8f9eeda7fe95b4fb0a1accb99eeba0223022040d0df81fde8f59c807e541ca5bcfc9d7450f76657aeb44c708fa7d65b7d58410121038cdae47fceb5b117cd3ef5bdf8c9f2a83679a9105d012095762067bdb2351ceaffffffff0280969800000000001976a914e00939d2ec2f885f5e7dc7b9f5b06dcf868d0c4b88acabfe261f000000001976a914f03286cbb7954ea6affa9654af6cfe1210dd0c6288ac00000000'; const tx = new Transaction(rawtx); diff --git a/packages/wallet-lib/src/utils/feeCalculation.js b/packages/wallet-lib/src/utils/feeCalculation.js index 482dcf35a30..0358ecfd1ac 100644 --- a/packages/wallet-lib/src/utils/feeCalculation.js +++ b/packages/wallet-lib/src/utils/feeCalculation.js @@ -1,4 +1,4 @@ -module.exports = function feeCalculation(type = 'standard') { +export default function feeCalculation(type = 'standard') { const feeRate = { type: null, value: null, diff --git a/packages/wallet-lib/src/utils/feeCalculation.spec.js b/packages/wallet-lib/src/utils/feeCalculation.spec.js index 84aa8d0b478..2387b7e9d0d 100644 --- a/packages/wallet-lib/src/utils/feeCalculation.spec.js +++ b/packages/wallet-lib/src/utils/feeCalculation.spec.js @@ -1,5 +1,5 @@ -const { expect } = require('chai'); -const feeCalculation = require('./feeCalculation'); +import { expect } from 'chai'; +import feeCalculation from './feeCalculation.js'; describe('Utils - feeCalculation', function suite() { this.timeout(10000); diff --git a/packages/wallet-lib/src/utils/filterTransactions.js b/packages/wallet-lib/src/utils/filterTransactions.js index 3badb90daef..734ac80c176 100644 --- a/packages/wallet-lib/src/utils/filterTransactions.js +++ b/packages/wallet-lib/src/utils/filterTransactions.js @@ -1,5 +1,6 @@ -const { uniq, each } = require('lodash'); -const { WALLET_TYPES } = require('../CONSTANTS'); +import lodash from 'lodash'; +const { uniq, each } = lodash; +import { WALLET_TYPES } from '../CONSTANTS.js'; const sortByNLockTime = (a, b) => (b.nLockTime - a.nLockTime); // Will filter out transaction that are not concerning us @@ -55,4 +56,4 @@ function filterTransactions(accountStore, walletType, accountIndex, transactions return filteredTransactions.sort(sortByNLockTime); } -module.exports = filterTransactions; +export default filterTransactions; \ No newline at end of file diff --git a/packages/wallet-lib/src/utils/filterTransactions.spec.js b/packages/wallet-lib/src/utils/filterTransactions.spec.js index a5a54495a0b..4d3e80fe96d 100644 --- a/packages/wallet-lib/src/utils/filterTransactions.spec.js +++ b/packages/wallet-lib/src/utils/filterTransactions.spec.js @@ -1,7 +1,8 @@ -const { Transaction } = require('@dashevo/dashcore-lib'); -const { expect } = require('chai'); -const { WALLET_TYPES } = require('../CONSTANTS'); -const filterTransactions = require('./filterTransactions'); +import dashcore from '@dashevo/dashcore-lib'; +const { Transaction } = dashcore; +import { expect } from 'chai'; +import { WALLET_TYPES } from '../CONSTANTS.js'; +import filterTransactions from './filterTransactions.js'; const fixtureAddressesStore = { external: {}, diff --git a/packages/wallet-lib/src/utils/fundWallet.js b/packages/wallet-lib/src/utils/fundWallet.js index 9f872ac5166..934ad6a2cb1 100644 --- a/packages/wallet-lib/src/utils/fundWallet.js +++ b/packages/wallet-lib/src/utils/fundWallet.js @@ -1,4 +1,4 @@ -const EVENTS = require('../EVENTS'); +import EVENTS from '../EVENTS.js'; /** * @@ -45,4 +45,4 @@ async function fundWallet(faucetWallet, recipientWallet, amount) { return transaction.id; } -module.exports = fundWallet; +export default fundWallet; \ No newline at end of file diff --git a/packages/wallet-lib/src/utils/getBytesOf.js b/packages/wallet-lib/src/utils/getBytesOf.js index 247af4615c0..d54d57f2e45 100644 --- a/packages/wallet-lib/src/utils/getBytesOf.js +++ b/packages/wallet-lib/src/utils/getBytesOf.js @@ -1,4 +1,5 @@ -const { Script, Address } = require('@dashevo/dashcore-lib'); +import dashcore from '@dashevo/dashcore-lib'; +const { Script, Address } = dashcore; function getBytesOf(elem, type) { let BASE_BYTES = 0; @@ -17,4 +18,4 @@ function getBytesOf(elem, type) { return false; } } -module.exports = getBytesOf; +export default getBytesOf; \ No newline at end of file diff --git a/packages/wallet-lib/src/utils/getBytesOf.spec.js b/packages/wallet-lib/src/utils/getBytesOf.spec.js index 9ef1a6f9d58..881760ede4f 100644 --- a/packages/wallet-lib/src/utils/getBytesOf.spec.js +++ b/packages/wallet-lib/src/utils/getBytesOf.spec.js @@ -1,5 +1,5 @@ -const { expect } = require('chai'); -const { getBytesOf } = require("./index"); +import { expect } from 'chai'; +import { getBytesOf } from './index.js'; describe('Utils - getBytesOf', function suite() { it('should have getBytesOf return false on unknown type', () => { diff --git a/packages/wallet-lib/src/utils/hasMethod.js b/packages/wallet-lib/src/utils/hasMethod.js index 6f00af1ac2c..b642b270f0a 100644 --- a/packages/wallet-lib/src/utils/hasMethod.js +++ b/packages/wallet-lib/src/utils/hasMethod.js @@ -7,4 +7,4 @@ function hasMethod(obj, methodName) { return !!obj && typeof obj[methodName] === 'function'; } -module.exports = hasMethod; +export default hasMethod; \ No newline at end of file diff --git a/packages/wallet-lib/src/utils/hasMethod.spec.js b/packages/wallet-lib/src/utils/hasMethod.spec.js index e635241ddc6..6293428d1e7 100644 --- a/packages/wallet-lib/src/utils/hasMethod.spec.js +++ b/packages/wallet-lib/src/utils/hasMethod.spec.js @@ -1,5 +1,5 @@ -const { expect } = require('chai'); -const { hasMethod} = require("./index"); +import { expect } from 'chai'; +import { hasMethod} from './index.js'; describe('Utils - hasMethod', function suite() { it('should correctly handle method detection', function () { diff --git a/packages/wallet-lib/src/utils/hasProp.js b/packages/wallet-lib/src/utils/hasProp.js index a050ff046e3..5b765cabdd1 100644 --- a/packages/wallet-lib/src/utils/hasProp.js +++ b/packages/wallet-lib/src/utils/hasProp.js @@ -6,4 +6,4 @@ function hasProp(obj, prop) { return {}.hasOwnProperty.call(obj, prop); } -module.exports = hasProp; +export default hasProp; \ No newline at end of file diff --git a/packages/wallet-lib/src/utils/hasProp.spec.js b/packages/wallet-lib/src/utils/hasProp.spec.js index 43a7d9ef3b9..d6ee673d2cd 100644 --- a/packages/wallet-lib/src/utils/hasProp.spec.js +++ b/packages/wallet-lib/src/utils/hasProp.spec.js @@ -1,5 +1,5 @@ -const { expect } = require('chai'); -const { hasProp } = require("./index"); +import { expect } from 'chai'; +import { hasProp } from './index.js'; describe('Utils - hasProp', function suite() { it('should correctly handle property detection', function () { diff --git a/packages/wallet-lib/src/utils/index.js b/packages/wallet-lib/src/utils/index.js index c23bb6a6e58..b21ca9688d6 100644 --- a/packages/wallet-lib/src/utils/index.js +++ b/packages/wallet-lib/src/utils/index.js @@ -1,30 +1,57 @@ -const extendTransactionsWithMetadata = require('./extendTransactionsWithMetadata'); -const calculateTransactionFees = require('./calculateTransactionFees'); -const categorizeTransactions = require('./categorizeTransactions'); -const calculateDuffBalance = require('./calculateDuffBalance'); -const filterTransactions = require('./filterTransactions'); -const { hash, doubleSha256, sha256 } = require('./crypto'); -const { varIntSizeBytesFromLength } = require('./varInt'); -const classifyAddresses = require('./classifyAddresses'); -const feeCalculation = require('./feeCalculation'); -const coinSelection = require('./coinSelection'); -const fundWallet = require('./fundWallet'); -const dashToDuffs = require('./dashToDuffs'); -const duffsToDash = require('./duffsToDash'); -const getBytesOf = require('./getBytesOf'); -const hasMethod = require('./hasMethod'); -const hasProp = require('./hasProp'); -const is = require('./is'); +import extendTransactionsWithMetadata from './extendTransactionsWithMetadata.js'; +import calculateTransactionFees from './calculateTransactionFees.js'; +import categorizeTransactions from './categorizeTransactions.js'; +import calculateDuffBalance from './calculateDuffBalance.js'; +import filterTransactions from './filterTransactions.js'; +import { hash, doubleSha256, sha256 } from './crypto.js'; +import { varIntSizeBytesFromLength } from './varInt.js'; +import classifyAddresses from './classifyAddresses.js'; +import feeCalculation from './feeCalculation.js'; +import coinSelection from './coinSelection.js'; +import fundWallet from './fundWallet.js'; +import dashToDuffs from './dashToDuffs.js'; +import duffsToDash from './duffsToDash.js'; +import getBytesOf from './getBytesOf.js'; +import hasMethod from './hasMethod.js'; +import hasProp from './hasProp.js'; +import is from './is.js'; -const { +import { generateNewMnemonic, mnemonicToHDPrivateKey, mnemonicToWalletId, seedToHDPrivateKey, mnemonicToSeed, -} = require('./mnemonic'); +} from './mnemonic.js'; -module.exports = { +export { + extendTransactionsWithMetadata, + varIntSizeBytesFromLength, + calculateTransactionFees, + categorizeTransactions, + mnemonicToHDPrivateKey, + calculateDuffBalance, + generateNewMnemonic, + seedToHDPrivateKey, + mnemonicToWalletId, + filterTransactions, + classifyAddresses, + mnemonicToSeed, + feeCalculation, + coinSelection, + doubleSha256, + dashToDuffs, + duffsToDash, + fundWallet, + getBytesOf, + hasMethod, + hasProp, + sha256, + hash, + is, +}; + +export default { extendTransactionsWithMetadata, varIntSizeBytesFromLength, calculateTransactionFees, diff --git a/packages/wallet-lib/src/utils/is.js b/packages/wallet-lib/src/utils/is.js index d8b25fa1120..0a910140a19 100644 --- a/packages/wallet-lib/src/utils/is.js +++ b/packages/wallet-lib/src/utils/is.js @@ -1,5 +1,6 @@ /* eslint-disable max-len */ // Todo : Some validators here are really proto type of methods, urgent impr is needed here. +import dashcore from '@dashevo/dashcore-lib'; const { PrivateKey, PublicKey, @@ -8,7 +9,7 @@ const { Transaction, Mnemonic, Address, -} = require('@dashevo/dashcore-lib'); +} = dashcore; const is = { // Primitives @@ -50,4 +51,4 @@ const is = { // aliases is.array = is.arr; -module.exports = is; +export default is; \ No newline at end of file diff --git a/packages/wallet-lib/src/utils/is.spec.js b/packages/wallet-lib/src/utils/is.spec.js index 4948857d37a..b969a38a05a 100644 --- a/packages/wallet-lib/src/utils/is.spec.js +++ b/packages/wallet-lib/src/utils/is.spec.js @@ -1,7 +1,8 @@ -const { Mnemonic, Networks, Address } = require('@dashevo/dashcore-lib'); -const { expect } = require('chai'); -const { is, generateNewMnemonic} = require("./index"); -const figureBridgeFixture = require("../../fixtures/figurebridge"); +import dashcore from '@dashevo/dashcore-lib'; +const { Mnemonic, Networks, Address } = dashcore; +import { expect } from 'chai'; +import { is, generateNewMnemonic} from './index.js'; +import figureBridgeFixture from '../../fixtures/figurebridge.json' with { type: 'json' }; describe('Utils - is', function suite() { it('should have is.num handle numbers', () => { diff --git a/packages/wallet-lib/src/utils/isBrowser.js b/packages/wallet-lib/src/utils/isBrowser.js index c11a2644b49..16cd4200af7 100644 --- a/packages/wallet-lib/src/utils/isBrowser.js +++ b/packages/wallet-lib/src/utils/isBrowser.js @@ -1,4 +1,4 @@ // eslint-disable-next-line no-new-func const isBrowser = new Function('try {return this===window;}catch(e){ return false;}'); -module.exports = isBrowser; +export default isBrowser; \ No newline at end of file diff --git a/packages/wallet-lib/src/utils/mnemonic.js b/packages/wallet-lib/src/utils/mnemonic.js index ff30fdabc8f..48d02d2930f 100644 --- a/packages/wallet-lib/src/utils/mnemonic.js +++ b/packages/wallet-lib/src/utils/mnemonic.js @@ -1,6 +1,8 @@ -const { pbkdf2Sync } = require('pbkdf2'); -const { Mnemonic, HDPrivateKey } = require('@dashevo/dashcore-lib'); -const { doubleSha256 } = require('./crypto'); +import pbkdf2 from 'pbkdf2'; +const { pbkdf2Sync } = pbkdf2; +import dashcore from '@dashevo/dashcore-lib'; +const { Mnemonic, HDPrivateKey } = dashcore; +import { doubleSha256 } from './crypto.js'; function generateNewMnemonic() { return Mnemonic(); @@ -38,7 +40,15 @@ const mnemonicToSeed = function mnemonicToSeed(mnemonic, password = '') { const seedToHDPrivateKey = function seedToHDPrivateKey(seed, network = 'testnet') { return HDPrivateKey.fromSeed(seed, network); }; -module.exports = { +export { + generateNewMnemonic, + mnemonicToHDPrivateKey, + mnemonicToWalletId, + mnemonicToSeed, + seedToHDPrivateKey, +}; + +export default { generateNewMnemonic, mnemonicToHDPrivateKey, mnemonicToWalletId, diff --git a/packages/wallet-lib/src/utils/mnemonic.spec.js b/packages/wallet-lib/src/utils/mnemonic.spec.js index 310465394ed..4d0030549e4 100644 --- a/packages/wallet-lib/src/utils/mnemonic.spec.js +++ b/packages/wallet-lib/src/utils/mnemonic.spec.js @@ -1,14 +1,15 @@ -const { expect } = require('chai'); -const { Networks } = require('@dashevo/dashcore-lib') -const { +import { expect } from 'chai'; +import dashcore from '@dashevo/dashcore-lib'; +const { Networks } = dashcore; +import { generateNewMnemonic, seedToHDPrivateKey, mnemonicToHDPrivateKey, mnemonicToWalletId, mnemonicToSeed, -} = require('./mnemonic'); -const is = require('./is'); -const knifeEasilyFixture = require("../../fixtures/knifeeasily"); +} from './mnemonic.js'; +import is from './is.js'; +import knifeEasilyFixture from '../../fixtures/knifeeasily.json' with { type: 'json' }; const mnemonic1 = 'hole lesson insane entire dolphin scissors game dwarf polar ethics drip math'; const mnemonic2 = 'woman forest output essay bleak satisfy era ordinary exotic source portion wire'; diff --git a/packages/wallet-lib/src/utils/outputHandler.js b/packages/wallet-lib/src/utils/outputHandler.js index 568b571726d..255442eab13 100644 --- a/packages/wallet-lib/src/utils/outputHandler.js +++ b/packages/wallet-lib/src/utils/outputHandler.js @@ -1,4 +1,4 @@ -module.exports = function outputHandler(outputs) { +export default function outputHandler(outputs) { return outputs.map((output) => { const result = {}; if (output.type === 'P2PKH') { diff --git a/packages/wallet-lib/src/utils/outputHandler.spec.js b/packages/wallet-lib/src/utils/outputHandler.spec.js index a7e715cc1e0..ae1580ab7f1 100644 --- a/packages/wallet-lib/src/utils/outputHandler.spec.js +++ b/packages/wallet-lib/src/utils/outputHandler.spec.js @@ -1,5 +1,5 @@ -const { expect } = require('chai'); -const outputHandler = require('./outputHandler'); +import { expect } from 'chai'; +import outputHandler from './outputHandler.js'; describe('Utils - outputHandler', function suite() { this.timeout(10000); diff --git a/packages/wallet-lib/src/utils/sleep.js b/packages/wallet-lib/src/utils/sleep.js index 2691f5be9ad..ce6ecc4a37e 100644 --- a/packages/wallet-lib/src/utils/sleep.js +++ b/packages/wallet-lib/src/utils/sleep.js @@ -1,4 +1,4 @@ const sleep = (time) => new Promise((resolve) => { setTimeout(resolve, time); }); -module.exports = sleep; +export default sleep; \ No newline at end of file diff --git a/packages/wallet-lib/src/utils/sortTransactions.js b/packages/wallet-lib/src/utils/sortTransactions.js index d64e19c8ce8..cd817a8ce21 100644 --- a/packages/wallet-lib/src/utils/sortTransactions.js +++ b/packages/wallet-lib/src/utils/sortTransactions.js @@ -46,4 +46,4 @@ const sortTransactions = (txsWithMetadata) => { }, []); }; -module.exports = sortTransactions; +export default sortTransactions; \ No newline at end of file diff --git a/packages/wallet-lib/src/utils/varInt.js b/packages/wallet-lib/src/utils/varInt.js index 8fd8fffb97e..257a53cbb2a 100644 --- a/packages/wallet-lib/src/utils/varInt.js +++ b/packages/wallet-lib/src/utils/varInt.js @@ -1,15 +1,16 @@ -module.exports = { - varIntSizeBytesFromLength: (length) => { - let bytes = 1; - if (length >= 0xfd) { +const varIntSizeBytesFromLength = (length) => { + let bytes = 1; + if (length >= 0xfd) { + bytes += 2; + if (length >= 0xffff) { bytes += 2; - if (length >= 0xffff) { - bytes += 2; - if (length >= 0xffffffff) { - bytes += 4; - } + if (length >= 0xffffffff) { + bytes += 4; } } - return bytes; - }, + } + return bytes; }; + +export { varIntSizeBytesFromLength }; +export default { varIntSizeBytesFromLength }; diff --git a/packages/wallet-lib/src/utils/varInt.spec.js b/packages/wallet-lib/src/utils/varInt.spec.js index 7f51571cdc3..7f20bd3a884 100644 --- a/packages/wallet-lib/src/utils/varInt.spec.js +++ b/packages/wallet-lib/src/utils/varInt.spec.js @@ -1,5 +1,5 @@ -const { expect } = require('chai'); -const varInt = require('./varInt'); +import { expect } from 'chai'; +import varInt from './varInt.js'; describe('Utils - varInt', function suite() { this.timeout(10000); diff --git a/packages/wallet-lib/tests/functional/sweepWallet.spec.js b/packages/wallet-lib/tests/functional/sweepWallet.spec.js index d7941725966..f114fc77ae2 100644 --- a/packages/wallet-lib/tests/functional/sweepWallet.spec.js +++ b/packages/wallet-lib/tests/functional/sweepWallet.spec.js @@ -1,6 +1,6 @@ -const {Wallet} = require('../../src/index'); -const expectThrowsAsync = require('../../src/utils/expectThrowsAsync'); -const sweepWallet = require('../../src/types/Wallet/methods/sweepWallet'); +import {Wallet} from '../../src/index.js'; +import expectThrowsAsync from '../../src/utils/expectThrowsAsync.js'; +import sweepWallet from '../../src/types/Wallet/methods/sweepWallet.js'; const paperWallet = { publicKey: 'ybvbBPisVjiemj4qSg1mzZAzTSAPk64Ppf', diff --git a/packages/wallet-lib/tests/functional/wallet.spec.js b/packages/wallet-lib/tests/functional/wallet.spec.js index f10097dcdf3..0785889a5a7 100644 --- a/packages/wallet-lib/tests/functional/wallet.spec.js +++ b/packages/wallet-lib/tests/functional/wallet.spec.js @@ -1,9 +1,9 @@ -const { expect } = require('chai'); +import { expect } from 'chai'; -const { Wallet } = require('../../src/index'); +import { Wallet } from '../../src/index.js'; -const { fundWallet } = require('../../src/utils'); -const { EVENTS } = require('../../src'); +import { fundWallet } from '../../src/utils/index.js'; +import { EVENTS } from '../../src/index.js'; const seeds = process.env.DAPI_SEED .split(','); diff --git a/packages/wallet-lib/tests/integration/plugins/Workers/BlockHeadersSyncWorker.spec.js b/packages/wallet-lib/tests/integration/plugins/Workers/BlockHeadersSyncWorker.spec.js index a64b2e06a46..035dc5000de 100644 --- a/packages/wallet-lib/tests/integration/plugins/Workers/BlockHeadersSyncWorker.spec.js +++ b/packages/wallet-lib/tests/integration/plugins/Workers/BlockHeadersSyncWorker.spec.js @@ -1,18 +1,19 @@ -const { expect } = require('chai'); -const EventEmitter = require('events'); -const { Block } = require('@dashevo/dashcore-lib'); -const DAPIClient = require('@dashevo/dapi-client'); -const EVENTS = require('../../../../src/EVENTS'); -const CONSTANTS = require('../../../../src/CONSTANTS'); -const BlockHeadersSyncWorker = require('../../../../src/plugins/Workers/BlockHeadersSyncWorker/BlockHeadersSyncWorker'); -const mockBlockHeadersProvider = require('../../../../src/test/mocks/mockBlockHeadersProvider'); -const mockStorage = require('../../../../src/test/mocks/mockStorage'); -const BlockHeadersStreamMock = require('../../../../src/test/mocks/BlockHeadersStreamMock'); -const { waitOneTick } = require('../../../../src/test/utils'); -const { mockHeadersChain } = require('../../../../src/test/mocks/dashcore/block'); +import { expect } from 'chai'; +import EventEmitter from 'events'; +import dashcore from '@dashevo/dashcore-lib'; +const { Block } = dashcore; +import DAPIClient from '@dashevo/dapi-client'; +import EVENTS from '../../../../src/EVENTS.js'; +import CONSTANTS from '../../../../src/CONSTANTS.js'; +import BlockHeadersSyncWorker from '../../../../src/plugins/Workers/BlockHeadersSyncWorker/BlockHeadersSyncWorker.js'; +import mockBlockHeadersProvider from '../../../../src/test/mocks/mockBlockHeadersProvider.js'; +import mockStorage from '../../../../src/test/mocks/mockStorage.js'; +import BlockHeadersStreamMock from '../../../../src/test/mocks/BlockHeadersStreamMock.js'; +import { waitOneTick } from '../../../../src/test/utils.js'; +import { mockHeadersChain } from '../../../../src/test/mocks/dashcore/block.js'; const { BlockHeadersProvider } = DAPIClient; -const logger = require('../../../../src/logger'); +import logger from '../../../../src/logger/index.js'; describe('BlockHeadersSyncWorker - integration', () => { let headersChain = []; diff --git a/packages/wallet-lib/tests/integration/plugins/Workers/TransactionsSyncWorker.spec.js b/packages/wallet-lib/tests/integration/plugins/Workers/TransactionsSyncWorker.spec.js index aab8022ccec..7804c8e86a3 100644 --- a/packages/wallet-lib/tests/integration/plugins/Workers/TransactionsSyncWorker.spec.js +++ b/packages/wallet-lib/tests/integration/plugins/Workers/TransactionsSyncWorker.spec.js @@ -1,15 +1,16 @@ /* eslint-disable no-console */ -const { Transaction } = require('@dashevo/dashcore-lib'); -const { expect } = require('chai'); -const TransactionsSyncWorker = require('../../../../src/plugins/Workers/TransactionsSyncWorker/TransactionsSyncWorker'); -const createTransportFromOptions = require('../../../../src/transport/createTransportFromOptions'); -const TxStreamMock = require('../../../../src/test/mocks/TxStreamMock'); -const { Wallet } = require('../../../../src'); -const LocalForageAdapterMock = require('../../../../src/test/mocks/LocalForageAdapterMock'); -const { waitOneTick } = require('../../../../src/test/utils'); -const { mockMerkleBlock } = require('../../../../src/test/mocks/dashcore/block'); -const EVENTS = require('../../../../src/EVENTS'); -const { mockInstantLock } = require('../../../../src/test/mocks/dashcore/instantlock'); +import dashcore from '@dashevo/dashcore-lib'; +const { Transaction } = dashcore; +import { expect } from 'chai'; +import TransactionsSyncWorker from '../../../../src/plugins/Workers/TransactionsSyncWorker/TransactionsSyncWorker.js'; +import createTransportFromOptions from '../../../../src/transport/createTransportFromOptions.js'; +import TxStreamMock from '../../../../src/test/mocks/TxStreamMock.js'; +import { Wallet } from '../../../../src/index.js'; +import LocalForageAdapterMock from '../../../../src/test/mocks/LocalForageAdapterMock.js'; +import { waitOneTick } from '../../../../src/test/utils.js'; +import { mockMerkleBlock } from '../../../../src/test/mocks/dashcore/block.js'; +import EVENTS from '../../../../src/EVENTS.js'; +import { mockInstantLock } from '../../../../src/test/mocks/dashcore/instantlock.js'; describe('TransactionsSyncWorker', () => { const WALLET_HD_KEY = 'xprv9s21ZrQH143K4PgfRZPuYjYUWRZkGfEPuWTEUESMoEZLC274ntC4G49qxgZJEPgmujsmY52eVggtwZgJPrWTMXmbYgqDVySWg46XzbGXrSZ'; diff --git a/packages/wallet-lib/tests/integration/types/Account.spec.js b/packages/wallet-lib/tests/integration/types/Account.spec.js index 3bdfcc4b5e8..34082f3c8e2 100644 --- a/packages/wallet-lib/tests/integration/types/Account.spec.js +++ b/packages/wallet-lib/tests/integration/types/Account.spec.js @@ -1,17 +1,18 @@ -const chai = require('chai'); -const chaiAsPromised = require('chai-as-promised'); +import chai from 'chai'; +import chaiAsPromised from 'chai-as-promised'; +import dashcore from '@dashevo/dashcore-lib'; const { - HDPrivateKey, - MerkleBlock, -} = require('@dashevo/dashcore-lib'); + HDPrivateKey, + MerkleBlock, +} = dashcore; -const TransactionsSyncWorker = require('../../../src/plugins/Workers/TransactionsSyncWorker/TransactionsSyncWorker'); +import TransactionsSyncWorker from '../../../src/plugins/Workers/TransactionsSyncWorker/TransactionsSyncWorker.js'; -const LocalForageAdapterMock = require('../../../src/test/mocks/LocalForageAdapterMock'); -const createTransactionInAccount = require('../../../src/test/mocks/createTransactionInAccount'); +import LocalForageAdapterMock from '../../../src/test/mocks/LocalForageAdapterMock.js'; +import createTransactionInAccount from '../../../src/test/mocks/createTransactionInAccount.js'; -const { Wallet } = require('../../../src'); +import { Wallet } from '../../../src/index.js'; chai.use(chaiAsPromised); const { expect } = chai; diff --git a/packages/wallet-lib/tests/integration/types/Wallet.spec.js b/packages/wallet-lib/tests/integration/types/Wallet.spec.js index 46223e11132..400c6412dcd 100644 --- a/packages/wallet-lib/tests/integration/types/Wallet.spec.js +++ b/packages/wallet-lib/tests/integration/types/Wallet.spec.js @@ -1,19 +1,20 @@ +import dashcore from '@dashevo/dashcore-lib'; const { HDPrivateKey, Transaction, - PrivateKey -} = require('@dashevo/dashcore-lib'); - -const { expect } = require('chai'); - -const { Wallet } = require("../../../src"); -const TransactionsSyncWorker = require("../../../src/plugins/Workers/TransactionsSyncWorker/TransactionsSyncWorker"); -const ChainPlugin = require("../../../src/plugins/Plugins/ChainPlugin"); -const LocalForageAdapterMock = require("../../../src/test/mocks/LocalForageAdapterMock"); -const {waitOneTick} = require("../../../src/test/utils"); -const {mockMerkleBlock} = require("../../../src/test/mocks/dashcore/block"); -const createTransportFromOptions = require("../../../src/transport/createTransportFromOptions"); -const TxStreamMock = require("../../../src/test/mocks/TxStreamMock"); + PrivateKey, +} = dashcore; + +import { expect } from 'chai'; + +import { Wallet } from '../../../src/index.js'; +import TransactionsSyncWorker from '../../../src/plugins/Workers/TransactionsSyncWorker/TransactionsSyncWorker.js'; +import ChainPlugin from '../../../src/plugins/Plugins/ChainPlugin.js'; +import LocalForageAdapterMock from '../../../src/test/mocks/LocalForageAdapterMock.js'; +import {waitOneTick} from '../../../src/test/utils.js'; +import {mockMerkleBlock} from '../../../src/test/mocks/dashcore/block.js'; +import createTransportFromOptions from '../../../src/transport/createTransportFromOptions.js'; +import TxStreamMock from '../../../src/test/mocks/TxStreamMock.js'; describe('Wallet', () => { // TODO: write test that ensures that storage getting wiped after removing skipSynchronizationBeforeHeight flag diff --git a/packages/wallet-lib/webpack.config.js b/packages/wallet-lib/webpack.config.js deleted file mode 100644 index 7b43a5feec9..00000000000 --- a/packages/wallet-lib/webpack.config.js +++ /dev/null @@ -1,42 +0,0 @@ -const path = require('path'); -const webpack = require('webpack'); - -const webConfig = { - entry: './src/index.js', - mode: 'production', - target: 'web', - output: { - path: path.resolve(__dirname, 'dist'), - libraryTarget: 'umd', - filename: 'wallet-lib.min.js', - // fixes ReferenceError: window is not defined - globalObject: "(typeof self !== 'undefined' ? self : this)", - }, - resolve: { - fallback: { - fs: false, - crypto: require.resolve('crypto-browserify'), - buffer: require.resolve('buffer/'), - assert: require.resolve('assert/'), - url: require.resolve('url/'), - path: require.resolve('path-browserify'), - http: require.resolve('stream-http'), - https: require.resolve('https-browserify'), - stream: require.resolve('stream-browserify'), - util: require.resolve('util/'), - os: require.resolve('os-browserify/browser'), - zlib: require.resolve('browserify-zlib'), - events: require.resolve('events/'), - string_decoder: require.resolve('string_decoder/'), - process: require.resolve('process/browser'), - }, - extensions: ['.ts', '.js', '.json'], - }, - plugins: [ - new webpack.ProvidePlugin({ - Buffer: [require.resolve('buffer/'), 'Buffer'], - process: require.resolve('process/browser'), - }), - ], -}; -module.exports = webConfig; diff --git a/yarn.lock b/yarn.lock index 57d28cca8c9..62d5e465f71 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1472,17 +1472,6 @@ __metadata: languageName: node linkType: hard -"@dabh/diagnostics@npm:^2.0.2": - version: 2.0.2 - resolution: "@dabh/diagnostics@npm:2.0.2" - dependencies: - colorspace: "npm:1.1.x" - enabled: "npm:2.0.x" - kuler: "npm:^2.0.0" - checksum: 10/d0c7ae32da9fc6061272ef56cf2c5af9c255e034783b68cfe3b0d47e806145d0723e6f5743e4c9fc0abae73658ca309498572688da2fbcfc56c16a8671dbe707 - languageName: node - linkType: hard - "@dashevo/bench-suite@workspace:packages/bench-suite": version: 0.0.0-use.local resolution: "@dashevo/bench-suite@workspace:packages/bench-suite" @@ -1514,53 +1503,25 @@ __metadata: version: 0.0.0-use.local resolution: "@dashevo/dapi-client@workspace:packages/js-dapi-client" dependencies: - "@babel/core": "npm:^7.26.10" "@dashevo/dapi-grpc": "workspace:*" "@dashevo/dash-spv": "workspace:*" "@dashevo/dashcore-lib": "npm:~0.22.0" "@dashevo/grpc-common": "workspace:*" "@dashevo/wasm-dpp": "workspace:*" - assert-browserify: "npm:^2.0.0" - babel-loader: "npm:^9.1.3" - browserify-zlib: "npm:^0.2.0" - bs58: "npm:^4.0.1" - buffer: "npm:^6.0.3" cbor: "npm:^8.0.0" chai: "npm:^4.3.10" chai-as-promised: "npm:^7.1.1" comment-parser: "npm:^0.7.6" - core-js: "npm:^3.33.1" - crypto-browserify: "npm:^3.12.1" dirty-chai: "npm:^2.0.1" eslint: "npm:^9.18.0" events: "npm:^3.3.0" google-protobuf: "npm:^3.12.2" - karma: "npm:^6.4.3" - karma-chai: "npm:^0.1.0" - karma-chrome-launcher: "npm:^3.1.0" - karma-firefox-launcher: "npm:^2.1.2" - karma-mocha: "npm:^2.0.1" - karma-mocha-reporter: "npm:^2.2.5" - karma-webpack: "npm:^5.0.0" - lodash: "npm:^4.17.23" mocha: "npm:^11.1.0" - node-fetch: "npm:^2.6.7" - node-inspect-extracted: "npm:^1.0.8" nyc: "npm:^15.1.0" - os-browserify: "npm:^0.3.0" - path-browserify: "npm:^1.0.1" - process: "npm:^0.11.10" - setimmediate: "npm:^1.0.5" sinon: "npm:^18.0.1" sinon-chai: "npm:^3.7.0" - stream-browserify: "npm:^3.0.0" - string_decoder: "npm:^1.3.0" - url: "npm:^0.11.3" - util: "npm:^0.12.4" + undici: "npm:^6.0.0" wasm-x11-hash: "npm:~0.0.2" - webpack: "npm:^5.104.0" - webpack-cli: "npm:^4.9.1" - winston: "npm:^3.2.1" languageName: unknown linkType: soft @@ -1856,49 +1817,23 @@ __metadata: "@dashevo/wallet-lib": "workspace:*" "@dashevo/wasm-dpp": "workspace:*" "@dashevo/withdrawals-contract": "workspace:*" - assert: "npm:^2.0.0" - assert-browserify: "npm:^2.0.0" - browserify-zlib: "npm:^0.2.0" - buffer: "npm:^6.0.3" bufferutil: "npm:^4.0.6" chai: "npm:^4.3.10" chai-as-promised: "npm:^7.1.1" - crypto-browserify: "npm:^3.12.1" dash: "workspace:*" dirty-chai: "npm:^2.0.1" dotenv-safe: "npm:^8.2.0" eslint: "npm:^9.18.0" - events: "npm:^3.3.0" glob: "npm:^10.3.4" - https-browserify: "npm:^1.0.0" js-merkle: "npm:^0.1.5" - karma: "npm:^6.4.3" - karma-chai: "npm:^0.1.0" - karma-chrome-launcher: "npm:^3.1.0" - karma-firefox-launcher: "npm:^2.1.2" - karma-mocha: "npm:^2.0.1" - karma-mocha-reporter: "npm:^2.2.5" - karma-sourcemap-loader: "npm:^0.3.7" - karma-webpack: "npm:^5.0.0" localforage: "npm:^1.10.0" mocha: "npm:^11.1.0" - net: "npm:^1.0.2" nodeforage: "npm:^1.1.2" - os-browserify: "npm:^0.3.0" - path-browserify: "npm:^1.0.1" - process: "npm:^0.11.10" semver: "npm:^7.5.3" setimmediate: "npm:^1.0.5" sinon: "npm:^18.0.1" sinon-chai: "npm:^3.7.0" - stream-browserify: "npm:^3.0.0" - stream-http: "npm:^3.2.0" - string_decoder: "npm:^1.3.0" - tls: "npm:^0.0.1" - url: "npm:^0.11.3" utf-8-validate: "npm:^5.0.9" - util: "npm:^0.12.4" - webpack: "npm:^5.104.0" ws: "npm:^8.17.1" bin: test: bin/test.sh @@ -1981,48 +1916,22 @@ __metadata: "@dashevo/grpc-common": "workspace:*" "@dashevo/wasm-dpp": "workspace:*" "@yarnpkg/pnpify": "npm:^4.0.0-rc.42" - assert: "npm:^2.0.0" - browserify-zlib: "npm:^0.2.0" - buffer: "npm:^6.0.3" cbor: "npm:^8.0.0" chai: "npm:^4.3.10" chai-as-promised: "npm:^7.1.1" - crypto-browserify: "npm:^3.12.1" crypto-js: "npm:^4.2.0" dirty-chai: "npm:^2.0.1" dotenv-safe: "npm:^8.2.0" eslint: "npm:^9.18.0" events: "npm:^3.3.0" - https-browserify: "npm:^1.0.0" - karma: "npm:^6.4.3" - karma-chai: "npm:^0.1.0" - karma-chrome-launcher: "npm:^3.1.0" - karma-firefox-launcher: "npm:^2.1.2" - karma-mocha: "npm:^2.0.1" - karma-mocha-reporter: "npm:^2.2.5" - karma-sourcemap-loader: "npm:^0.3.7" - karma-webpack: "npm:^5.0.0" lodash: "npm:^4.17.23" mocha: "npm:^11.1.0" - node-inspect-extracted: "npm:^1.0.8" nyc: "npm:^15.1.0" - os-browserify: "npm:^0.3.0" - path-browserify: "npm:^1.0.1" pbkdf2: "npm:^3.1.3" - process: "npm:^0.11.10" - setimmediate: "npm:^1.0.5" sinon: "npm:^18.0.1" sinon-chai: "npm:^3.7.0" - stream-browserify: "npm:^3.0.0" - stream-http: "npm:^3.2.0" - string_decoder: "npm:^1.3.0" tsd: "npm:^0.28.1" - url: "npm:^0.11.3" - util: "npm:^0.12.4" wasm-x11-hash: "npm:~0.0.2" - webpack: "npm:^5.104.0" - webpack-cli: "npm:^4.9.1" - winston: "npm:^3.2.1" languageName: unknown linkType: soft @@ -5246,18 +5155,6 @@ __metadata: languageName: node linkType: hard -"assert-browserify@npm:^2.0.0": - version: 2.0.0 - resolution: "assert-browserify@npm:2.0.0" - dependencies: - es6-object-assign: "npm:^1.1.0" - is-nan: "npm:^1.2.1" - object-is: "npm:^1.0.1" - util: "npm:^0.12.0" - checksum: 10/161984368c673dc574af032e3057ae31f0bb74ac1e34922b53a45ef431112cce5ade4a5bde8a53eebdbb0615395e3dc924762e6a86c0c60c25d4c3794e811a4b - languageName: node - linkType: hard - "assert@npm:^2.0.0": version: 2.0.0 resolution: "assert@npm:2.0.0" @@ -5314,7 +5211,7 @@ __metadata: languageName: node linkType: hard -"async@npm:^3.1.0, async@npm:^3.2.0, async@npm:^3.2.3, async@npm:^3.2.4": +"async@npm:^3.2.0, async@npm:^3.2.3, async@npm:^3.2.4": version: 3.2.4 resolution: "async@npm:3.2.4" checksum: 10/bebb5dc2258c45b83fa1d3be179ae0eb468e1646a62d443c8d60a45e84041b28fccebe1e2d1f234bfc3dcad44e73dcdbf4ba63d98327c9f6556e3dbd47c2ae8b @@ -5400,19 +5297,6 @@ __metadata: languageName: node linkType: hard -"babel-loader@npm:^9.1.3": - version: 9.1.3 - resolution: "babel-loader@npm:9.1.3" - dependencies: - find-cache-dir: "npm:^4.0.0" - schema-utils: "npm:^4.0.0" - peerDependencies: - "@babel/core": ^7.12.0 - webpack: ">=5" - checksum: 10/7086e678273b5d1261141dca84ed784caab9f7921c8c24d7278c8ee3088235a9a9fd85caac9f0fa687336cb3c27248ca22dbf431469769b1b995d55aec606992 - languageName: node - linkType: hard - "babel-plugin-polyfill-corejs2@npm:^0.4.10": version: 0.4.12 resolution: "babel-plugin-polyfill-corejs2@npm:0.4.12" @@ -5790,15 +5674,6 @@ __metadata: languageName: node linkType: hard -"browserify-zlib@npm:^0.2.0": - version: 0.2.0 - resolution: "browserify-zlib@npm:0.2.0" - dependencies: - pako: "npm:~1.0.5" - checksum: 10/852e72effdc00bf8acc6d167d835179eda9e5bd13721ae5d0a2d132dc542f33e73bead2959eb43a2f181a9c495bc2ae2bdb4ec37c4e37ff61a0277741cbaaa7a - languageName: node - linkType: hard - "browserslist@npm:^4.21.9": version: 4.22.1 resolution: "browserslist@npm:4.22.1" @@ -6569,7 +6444,7 @@ __metadata: languageName: node linkType: hard -"color-convert@npm:^1.9.0, color-convert@npm:^1.9.3": +"color-convert@npm:^1.9.0": version: 1.9.3 resolution: "color-convert@npm:1.9.3" dependencies: @@ -6601,16 +6476,6 @@ __metadata: languageName: node linkType: hard -"color-string@npm:^1.6.0": - version: 1.6.0 - resolution: "color-string@npm:1.6.0" - dependencies: - color-name: "npm:^1.0.0" - simple-swizzle: "npm:^0.2.2" - checksum: 10/27c2365153d3dad41a6c28901c3079f1a0b2f0777309eba83a5533bcafdd2f8bfcd6aaf695f34506627757aebb7598ff18ad5b4361e586d346ce7ba74bb94969 - languageName: node - linkType: hard - "color-string@npm:^1.9.0": version: 1.9.1 resolution: "color-string@npm:1.9.1" @@ -6630,16 +6495,6 @@ __metadata: languageName: node linkType: hard -"color@npm:^3.1.3": - version: 3.2.1 - resolution: "color@npm:3.2.1" - dependencies: - color-convert: "npm:^1.9.3" - color-string: "npm:^1.6.0" - checksum: 10/bf70438e0192f4f62f4bfbb303e7231289e8cc0d15ff6b6cbdb722d51f680049f38d4fdfc057a99cb641895cf5e350478c61d98586400b060043afc44285e7ae - languageName: node - linkType: hard - "color@npm:^4.2.3": version: 4.2.3 resolution: "color@npm:4.2.3" @@ -6664,23 +6519,6 @@ __metadata: languageName: node linkType: hard -"colors@npm:^1.2.1": - version: 1.4.0 - resolution: "colors@npm:1.4.0" - checksum: 10/90b2d5465159813a3983ea72ca8cff75f784824ad70f2cc2b32c233e95bcfbcda101ebc6d6766bc50f57263792629bfb4f1f8a4dfbd1d240f229fc7f69b785fc - languageName: node - linkType: hard - -"colorspace@npm:1.1.x": - version: 1.1.4 - resolution: "colorspace@npm:1.1.4" - dependencies: - color: "npm:^3.1.3" - text-hex: "npm:1.0.x" - checksum: 10/bb3934ef3c417e961e6d03d7ca60ea6e175947029bfadfcdb65109b01881a1c0ecf9c2b0b59abcd0ee4a0d7c1eae93beed01b0e65848936472270a0b341ebce8 - languageName: node - linkType: hard - "commander@npm:4.0.1": version: 4.0.1 resolution: "commander@npm:4.0.1" @@ -6744,13 +6582,6 @@ __metadata: languageName: node linkType: hard -"common-path-prefix@npm:^3.0.0": - version: 3.0.0 - resolution: "common-path-prefix@npm:3.0.0" - checksum: 10/09c180e8d8495d42990d617f4d4b7522b5da20f6b236afe310192d401d1da8147a7835ae1ea37797ba0c2238ef3d06f3492151591451df34539fdb4b2630f2b3 - languageName: node - linkType: hard - "commondir@npm:^1.0.1": version: 1.0.1 resolution: "commondir@npm:1.0.1" @@ -7056,13 +6887,6 @@ __metadata: languageName: node linkType: hard -"core-js@npm:^3.33.1": - version: 3.33.2 - resolution: "core-js@npm:3.33.2" - checksum: 10/d62554d51ce8a3f33d0b1f8b064cbd21afcae275043ae96d3d43f18701b80cd423fab484517a81ee1d096db252e2aeada6ef6d1fd80a26db54f82f8f349a62c7 - languageName: node - linkType: hard - "core-util-is@npm:~1.0.0": version: 1.0.3 resolution: "core-util-is@npm:1.0.3" @@ -7245,51 +7069,20 @@ __metadata: "@types/sinon": "npm:^9.0.4" "@types/sinon-chai": "npm:^3.2.4" "@yarnpkg/pnpify": "npm:^4.0.0-rc.42" - assert: "npm:^2.0.0" - browserify-zlib: "npm:^0.2.0" - bs58: "npm:^4.0.1" - buffer: "npm:^6.0.3" chai: "npm:^4.3.10" chai-as-promised: "npm:^7.1.1" chance: "npm:^1.1.6" - crypto-browserify: "npm:^3.12.1" dirty-chai: "npm:^2.0.1" dotenv-safe: "npm:^8.2.0" eslint: "npm:^9.18.0" - events: "npm:^3.3.0" - https-browserify: "npm:^1.0.0" - karma: "npm:^6.4.3" - karma-chai: "npm:^0.1.0" - karma-chrome-launcher: "npm:^3.1.0" - karma-firefox-launcher: "npm:^2.1.2" - karma-mocha: "npm:^2.0.1" - karma-mocha-reporter: "npm:^2.2.5" - karma-webpack: "npm:^5.0.0" mocha: "npm:^11.1.0" - net: "npm:^1.0.2" - node-inspect-extracted: "npm:^1.0.8" nodemon: "npm:^2.0.20" - os-browserify: "npm:^0.3.0" - path-browserify: "npm:^1.0.1" - process: "npm:^0.11.10" rimraf: "npm:^3.0.2" sinon: "npm:^18.0.1" sinon-chai: "npm:^3.7.0" - stream-browserify: "npm:^3.0.0" - stream-http: "npm:^3.2.0" - string_decoder: "npm:^1.3.0" - terser-webpack-plugin: "npm:^5.3.11" - tls: "npm:^0.0.1" - ts-loader: "npm:^9.5.0" - ts-mock-imports: "npm:^1.3.0" ts-node: "npm:^10.9.2" tsd: "npm:^0.28.1" typescript: "npm:^5.7.3" - url: "npm:^0.11.3" - util: "npm:^0.12.4" - webpack: "npm:^5.104.0" - webpack-cli: "npm:^4.9.1" - winston: "npm:^3.2.1" languageName: unknown linkType: soft @@ -7985,13 +7778,6 @@ __metadata: languageName: node linkType: hard -"enabled@npm:2.0.x": - version: 2.0.0 - resolution: "enabled@npm:2.0.0" - checksum: 10/9d256d89f4e8a46ff988c6a79b22fa814b4ffd82826c4fdacd9b42e9b9465709d3b748866d0ab4d442dfc6002d81de7f7b384146ccd1681f6a7f868d2acca063 - languageName: node - linkType: hard - "encodeurl@npm:~1.0.2": version: 1.0.2 resolution: "encodeurl@npm:1.0.2" @@ -9168,13 +8954,6 @@ __metadata: languageName: node linkType: hard -"fecha@npm:^4.2.0": - version: 4.2.1 - resolution: "fecha@npm:4.2.1" - checksum: 10/6cf959d41a4c68d5b3296d9621e0d5b7c8ee6a5ea51f11b468742a5533b74d635dd12d2edafae0b29c9df060d4d650d1c30d415a14bdaae8fc1b5c836451fbb8 - languageName: node - linkType: hard - "figures@npm:^3.0.0": version: 3.2.0 resolution: "figures@npm:3.2.0" @@ -9246,16 +9025,6 @@ __metadata: languageName: node linkType: hard -"find-cache-dir@npm:^4.0.0": - version: 4.0.0 - resolution: "find-cache-dir@npm:4.0.0" - dependencies: - common-path-prefix: "npm:^3.0.0" - pkg-dir: "npm:^7.0.0" - checksum: 10/52a456a80deeb27daa3af6e06059b63bdb9cc4af4d845fc6d6229887e505ba913cd56000349caa60bc3aa59dacdb5b4c37903d4ba34c75102d83cab330b70d2f - languageName: node - linkType: hard - "find-up@npm:^2.0.0": version: 2.1.0 resolution: "find-up@npm:2.1.0" @@ -9285,16 +9054,6 @@ __metadata: languageName: node linkType: hard -"find-up@npm:^6.3.0": - version: 6.3.0 - resolution: "find-up@npm:6.3.0" - dependencies: - locate-path: "npm:^7.1.0" - path-exists: "npm:^5.0.0" - checksum: 10/4f3bdc30d41778c647e53f4923e72de5e5fb055157031f34501c5b36c2eb59f77b997edf9cb00165c6060cda7eaa2e3da82cb6be2e61d68ad3e07c4bc4cce67e - languageName: node - linkType: hard - "find-yarn-workspace-root2@npm:1.2.16": version: 1.2.16 resolution: "find-yarn-workspace-root2@npm:1.2.16" @@ -9356,13 +9115,6 @@ __metadata: languageName: node linkType: hard -"fn.name@npm:1.x.x": - version: 1.1.0 - resolution: "fn.name@npm:1.1.0" - checksum: 10/000198af190ae02f0138ac5fa4310da733224c628e0230c81e3fff7c4e094af7e0e8bb9f4357cabd21db601759d89f3445da744afbae20623cfa41edf3888397 - languageName: node - linkType: hard - "follow-redirects@npm:^1.15.5": version: 1.15.6 resolution: "follow-redirects@npm:1.15.6" @@ -11837,15 +11589,6 @@ __metadata: languageName: node linkType: hard -"karma-sourcemap-loader@npm:^0.3.7": - version: 0.3.8 - resolution: "karma-sourcemap-loader@npm:0.3.8" - dependencies: - graceful-fs: "npm:^4.1.2" - checksum: 10/f641355ec1f9788ffd6308681f72920930627b924b8cf9c911062cba76361322443a8424b03458c09d34dcd3f73f741a395f61a4eec28ca3349a98dac8265d61 - languageName: node - linkType: hard - "karma-webpack@npm:^5.0.0": version: 5.0.0 resolution: "karma-webpack@npm:5.0.0" @@ -11909,13 +11652,6 @@ __metadata: languageName: node linkType: hard -"kuler@npm:^2.0.0": - version: 2.0.0 - resolution: "kuler@npm:2.0.0" - checksum: 10/9e10b5a1659f9ed8761d38df3c35effabffbd19fc6107324095238e4ef0ff044392cae9ac64a1c2dda26e532426485342226b93806bd97504b174b0dcf04ed81 - languageName: node - linkType: hard - "language-subtag-registry@npm:^0.3.20": version: 0.3.23 resolution: "language-subtag-registry@npm:0.3.23" @@ -12115,15 +11851,6 @@ __metadata: languageName: node linkType: hard -"locate-path@npm:^7.1.0": - version: 7.2.0 - resolution: "locate-path@npm:7.2.0" - dependencies: - p-locate: "npm:^6.0.0" - checksum: 10/1c6d269d4efec555937081be964e8a9b4a136319c79ca1d45ac6382212a8466113c75bd89e44521ca8ecd1c47fb08523b56eee5c0712bc7d14fec5f729deeb42 - languageName: node - linkType: hard - "lodash._reinterpolate@npm:^3.0.0": version: 3.0.0 resolution: "lodash._reinterpolate@npm:3.0.0" @@ -12264,19 +11991,6 @@ __metadata: languageName: node linkType: hard -"logform@npm:^2.2.0": - version: 2.3.0 - resolution: "logform@npm:2.3.0" - dependencies: - colors: "npm:^1.2.1" - fecha: "npm:^4.2.0" - ms: "npm:^2.1.1" - safe-stable-stringify: "npm:^1.1.0" - triple-beam: "npm:^1.3.0" - checksum: 10/1fbe98725e5ecddc610ddacde1bfac1da52fe4a58f12eef11893068581dd2d0e833396f3791f3c82cfe35ce0bc8f1e23982b6f78aa16f0c3f827a06264f63424 - languageName: node - linkType: hard - "long@npm:^4.0.0": version: 4.0.0 resolution: "long@npm:4.0.0" @@ -13204,13 +12918,6 @@ __metadata: languageName: node linkType: hard -"net@npm:^1.0.2": - version: 1.0.2 - resolution: "net@npm:1.0.2" - checksum: 10/d97e215d922e87e9aa86e87daae73ce7f4e291f2d71365a115f2f51831b1add86e73584e944285daafcad4058c09bb85e33250da84834a26a83020740d45b4a1 - languageName: node - linkType: hard - "nise@npm:^6.0.0": version: 6.1.3 resolution: "nise@npm:6.1.3" @@ -13301,13 +13008,6 @@ __metadata: languageName: node linkType: hard -"node-inspect-extracted@npm:^1.0.8": - version: 1.0.8 - resolution: "node-inspect-extracted@npm:1.0.8" - checksum: 10/4647a29afd1574ea513ceed1a421d64381799f116a0c50280c16bca51459a2958177d4c18528bd57368c64c777e6afe23446edb4d62fa960cbc637c658b26d9f - languageName: node - linkType: hard - "node-preload@npm:^0.2.1": version: 0.2.1 resolution: "node-preload@npm:0.2.1" @@ -13844,15 +13544,6 @@ __metadata: languageName: node linkType: hard -"one-time@npm:^1.0.0": - version: 1.0.0 - resolution: "one-time@npm:1.0.0" - dependencies: - fn.name: "npm:1.x.x" - checksum: 10/64d0160480eeae4e3b2a6fc0a02f452e05bb0cc8373a4ed56a4fc08c3939dcb91bc20075003ed499655bd16919feb63ca56f86eee7932c5251f7d629b55dfc90 - languageName: node - linkType: hard - "onetime@npm:^5.1.0, onetime@npm:^5.1.2": version: 5.1.2 resolution: "onetime@npm:5.1.2" @@ -13937,13 +13628,6 @@ __metadata: languageName: node linkType: hard -"os-browserify@npm:^0.3.0": - version: 0.3.0 - resolution: "os-browserify@npm:0.3.0" - checksum: 10/16e37ba3c0e6a4c63443c7b55799ce4066d59104143cb637ecb9fce586d5da319cdca786ba1c867abbe3890d2cbf37953f2d51eea85e20dd6c4570d6c54bfebf - languageName: node - linkType: hard - "own-keys@npm:^1.0.1": version: 1.0.1 resolution: "own-keys@npm:1.0.1" @@ -14003,15 +13687,6 @@ __metadata: languageName: node linkType: hard -"p-limit@npm:^4.0.0": - version: 4.0.0 - resolution: "p-limit@npm:4.0.0" - dependencies: - yocto-queue: "npm:^1.0.0" - checksum: 10/01d9d70695187788f984226e16c903475ec6a947ee7b21948d6f597bed788e3112cc7ec2e171c1d37125057a5f45f3da21d8653e04a3a793589e12e9e80e756b - languageName: node - linkType: hard - "p-locate@npm:^2.0.0": version: 2.0.0 resolution: "p-locate@npm:2.0.0" @@ -14039,15 +13714,6 @@ __metadata: languageName: node linkType: hard -"p-locate@npm:^6.0.0": - version: 6.0.0 - resolution: "p-locate@npm:6.0.0" - dependencies: - p-limit: "npm:^4.0.0" - checksum: 10/2bfe5234efa5e7a4e74b30a5479a193fdd9236f8f6b4d2f3f69e3d286d9a7d7ab0c118a2a50142efcf4e41625def635bd9332d6cbf9cc65d85eb0718c579ab38 - languageName: node - linkType: hard - "p-map@npm:^3.0.0": version: 3.0.0 resolution: "p-map@npm:3.0.0" @@ -14192,13 +13858,6 @@ __metadata: languageName: node linkType: hard -"pako@npm:~1.0.5": - version: 1.0.11 - resolution: "pako@npm:1.0.11" - checksum: 10/1ad07210e894472685564c4d39a08717e84c2a68a70d3c1d9e657d32394ef1670e22972a433cbfe48976cb98b154ba06855dcd3fcfba77f60f1777634bec48c0 - languageName: node - linkType: hard - "param-case@npm:^3.0.4": version: 3.0.4 resolution: "param-case@npm:3.0.4" @@ -14355,13 +14014,6 @@ __metadata: languageName: node linkType: hard -"path-exists@npm:^5.0.0": - version: 5.0.0 - resolution: "path-exists@npm:5.0.0" - checksum: 10/8ca842868cab09423994596eb2c5ec2a971c17d1a3cb36dbf060592c730c725cd524b9067d7d2a1e031fef9ba7bd2ac6dc5ec9fb92aa693265f7be3987045254 - languageName: node - linkType: hard - "path-is-absolute@npm:^1.0.0": version: 1.0.1 resolution: "path-is-absolute@npm:1.0.1" @@ -14582,15 +14234,6 @@ __metadata: languageName: node linkType: hard -"pkg-dir@npm:^7.0.0": - version: 7.0.0 - resolution: "pkg-dir@npm:7.0.0" - dependencies: - find-up: "npm:^6.3.0" - checksum: 10/94298b20a446bfbbd66604474de8a0cdd3b8d251225170970f15d9646f633e056c80520dd5b4c1d1050c9fed8f6a9e5054b141c93806439452efe72e57562c03 - languageName: node - linkType: hard - "plur@npm:^4.0.0": version: 4.0.0 resolution: "plur@npm:4.0.0" @@ -15070,7 +14713,7 @@ __metadata: languageName: node linkType: hard -"readable-stream@npm:^2.0.2, readable-stream@npm:^2.3.5, readable-stream@npm:^2.3.7, readable-stream@npm:~2.3.6": +"readable-stream@npm:^2.0.2, readable-stream@npm:^2.3.5, readable-stream@npm:~2.3.6": version: 2.3.7 resolution: "readable-stream@npm:2.3.7" dependencies: @@ -15671,13 +15314,6 @@ __metadata: languageName: node linkType: hard -"safe-stable-stringify@npm:^1.1.0": - version: 1.1.1 - resolution: "safe-stable-stringify@npm:1.1.1" - checksum: 10/bddfc2334dfa68a7f976c2b57c0ce83c087b032abdd150a24f3ca9fe19b43accfa9634d04587a7fb3d7636bc6c3d728dda1311ad43eb85bb95793a707fb127ac - languageName: node - linkType: hard - "safe-stable-stringify@npm:^2.3.1": version: 2.4.3 resolution: "safe-stable-stringify@npm:2.4.3" @@ -15715,18 +15351,6 @@ __metadata: languageName: node linkType: hard -"schema-utils@npm:^4.0.0": - version: 4.2.0 - resolution: "schema-utils@npm:4.2.0" - dependencies: - "@types/json-schema": "npm:^7.0.9" - ajv: "npm:^8.9.0" - ajv-formats: "npm:^2.1.1" - ajv-keywords: "npm:^5.1.0" - checksum: 10/808784735eeb153ab7f3f787f840aa3bc63f423d2a5a7e96c9e70a0e53d0bc62d7b37ea396fc598ce19196e4fb86a72f897154b7c6ce2358bbc426166f205e14 - languageName: node - linkType: hard - "schema-utils@npm:^4.3.0": version: 4.3.0 resolution: "schema-utils@npm:4.3.0" @@ -16517,13 +16141,6 @@ __metadata: languageName: node linkType: hard -"stack-trace@npm:0.0.x": - version: 0.0.10 - resolution: "stack-trace@npm:0.0.10" - checksum: 10/7bd633f0e9ac46e81a0b0fe6538482c1d77031959cf94478228731709db4672fbbed59176f5b9a9fd89fec656b5dae03d084ef2d1b0c4c2f5683e05f2dbb1405 - languageName: node - linkType: hard - "statuses@npm:2.0.1": version: 2.0.1 resolution: "statuses@npm:2.0.1" @@ -17118,13 +16735,6 @@ __metadata: languageName: node linkType: hard -"text-hex@npm:1.0.x": - version: 1.0.0 - resolution: "text-hex@npm:1.0.0" - checksum: 10/1138f68adc97bf4381a302a24e2352f04992b7b1316c5003767e9b0d3367ffd0dc73d65001ea02b07cd0ecc2a9d186de0cf02f3c2d880b8a522d4ccb9342244a - languageName: node - linkType: hard - "text-table@npm:^0.2.0": version: 0.2.0 resolution: "text-table@npm:0.2.0" @@ -17198,13 +16808,6 @@ __metadata: languageName: node linkType: hard -"tls@npm:^0.0.1": - version: 0.0.1 - resolution: "tls@npm:0.0.1" - checksum: 10/83aee8b284ac85630ea521b68774c9020d7701dc74788f69b92c84c8513132a21ef8f008e5513e24aaf6096ebc0dd50f2a819e1b7ea96e1ebb0202364c4e2a17 - languageName: node - linkType: hard - "tmp@npm:^0.2.4": version: 0.2.5 resolution: "tmp@npm:0.2.5" @@ -17285,13 +16888,6 @@ __metadata: languageName: node linkType: hard -"triple-beam@npm:^1.2.0, triple-beam@npm:^1.3.0": - version: 1.3.0 - resolution: "triple-beam@npm:1.3.0" - checksum: 10/7d7b77d8625fb252c126c24984a68de462b538a8fcd1de2abd0a26421629cf3527d48e23b3c2264f08f4a6c3bc40a478a722176f4d7b6a1acc154cb70c359f2b - languageName: node - linkType: hard - "ts-api-utils@npm:^1.0.1": version: 1.0.3 resolution: "ts-api-utils@npm:1.0.3" @@ -17337,16 +16933,6 @@ __metadata: languageName: node linkType: hard -"ts-mock-imports@npm:^1.3.0": - version: 1.3.8 - resolution: "ts-mock-imports@npm:1.3.8" - peerDependencies: - sinon: ">= 4.1.2" - typescript: ">=2.6.1" - checksum: 10/82ee2a725641626399e20f3707fd0e56f52a95077a87db1f7cf6e0e451b3a8da82b5426c1b5059b8da6a28c5efaf48867f0957d8f80ece553bb269f53a956673 - languageName: node - linkType: hard - "ts-node@npm:^10.9.1": version: 10.9.1 resolution: "ts-node@npm:10.9.1" @@ -17867,6 +17453,13 @@ __metadata: languageName: node linkType: hard +"undici@npm:^6.0.0": + version: 6.25.0 + resolution: "undici@npm:6.25.0" + checksum: 10/a475e45da3e1d1073283bb70531666f09a432eabff2b857bd7063d469a1ee1486192ff61dc0dadbb526673ce1120fee14d66a59b6b17d1e0bd3a4d5f0a52d0a6 + languageName: node + linkType: hard + "unicode-canonical-property-names-ecmascript@npm:^2.0.0": version: 2.0.0 resolution: "unicode-canonical-property-names-ecmascript@npm:2.0.0" @@ -18612,33 +18205,6 @@ __metadata: languageName: node linkType: hard -"winston-transport@npm:^4.4.0": - version: 4.4.0 - resolution: "winston-transport@npm:4.4.0" - dependencies: - readable-stream: "npm:^2.3.7" - triple-beam: "npm:^1.2.0" - checksum: 10/f1651e8a871038a8b71d6f8242f81a24764348e23dc0cca2da6085712a58c5669cfbcbd396638dbfefa76d73e6f627d69740e4e136e89396c28d014987d4ef9b - languageName: node - linkType: hard - -"winston@npm:^3.2.1": - version: 3.3.3 - resolution: "winston@npm:3.3.3" - dependencies: - "@dabh/diagnostics": "npm:^2.0.2" - async: "npm:^3.1.0" - is-stream: "npm:^2.0.0" - logform: "npm:^2.2.0" - one-time: "npm:^1.0.0" - readable-stream: "npm:^3.4.0" - stack-trace: "npm:0.0.x" - triple-beam: "npm:^1.3.0" - winston-transport: "npm:^4.4.0" - checksum: 10/60b74f2ea70e702c962f8834a6954fa9d1776f475121440a546106862b8b5b88cabc4827d71fd3c9b8bd0337c0954f7f109bbc0718a3c47948815b03ce2fb3d8 - languageName: node - linkType: hard - "word-wrap@npm:^1.2.4": version: 1.2.4 resolution: "word-wrap@npm:1.2.4" @@ -18999,13 +18565,6 @@ __metadata: languageName: node linkType: hard -"yocto-queue@npm:^1.0.0": - version: 1.0.0 - resolution: "yocto-queue@npm:1.0.0" - checksum: 10/2cac84540f65c64ccc1683c267edce396b26b1e931aa429660aefac8fbe0188167b7aee815a3c22fa59a28a58d898d1a2b1825048f834d8d629f4c2a5d443801 - languageName: node - linkType: hard - "z-schema@npm:^4.2.2": version: 4.2.4 resolution: "z-schema@npm:4.2.4"