quantumcoin 7.0.9 → 7.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/README-SDK.md +1 -5
  2. package/README.md +18 -3
  3. package/SPEC.md +2 -63
  4. package/config.js +10 -2
  5. package/examples/example.js +0 -5
  6. package/examples/example.ts +0 -5
  7. package/examples/node_modules/.bin/esbuild +16 -0
  8. package/examples/node_modules/.bin/esbuild.cmd +17 -0
  9. package/examples/node_modules/.bin/esbuild.ps1 +28 -0
  10. package/examples/node_modules/.bin/sdkgen +16 -0
  11. package/examples/node_modules/.bin/sdkgen.cmd +17 -0
  12. package/examples/node_modules/.bin/sdkgen.ps1 +28 -0
  13. package/examples/node_modules/.bin/tsx +16 -0
  14. package/examples/node_modules/.bin/tsx.cmd +17 -0
  15. package/examples/node_modules/.bin/tsx.ps1 +28 -0
  16. package/examples/node_modules/.package-lock.json +235 -0
  17. package/examples/node_modules/@esbuild/win32-x64/README.md +3 -0
  18. package/examples/node_modules/@esbuild/win32-x64/esbuild.exe +0 -0
  19. package/examples/node_modules/@esbuild/win32-x64/package.json +20 -0
  20. package/examples/node_modules/esbuild/LICENSE.md +21 -0
  21. package/examples/node_modules/esbuild/README.md +3 -0
  22. package/examples/node_modules/esbuild/bin/esbuild +223 -0
  23. package/examples/node_modules/esbuild/install.js +289 -0
  24. package/examples/node_modules/esbuild/lib/main.d.ts +716 -0
  25. package/examples/node_modules/esbuild/lib/main.js +2532 -0
  26. package/examples/node_modules/esbuild/package.json +49 -0
  27. package/examples/node_modules/get-tsconfig/LICENSE +21 -0
  28. package/examples/node_modules/get-tsconfig/README.md +235 -0
  29. package/examples/node_modules/get-tsconfig/dist/index.cjs +7 -0
  30. package/examples/node_modules/get-tsconfig/dist/index.d.cts +2088 -0
  31. package/examples/node_modules/get-tsconfig/dist/index.d.mts +2088 -0
  32. package/examples/node_modules/get-tsconfig/dist/index.mjs +7 -0
  33. package/examples/node_modules/get-tsconfig/package.json +46 -0
  34. package/examples/node_modules/quantum-coin-js-sdk/.github/workflows/publish-npmjs.yaml +22 -0
  35. package/examples/node_modules/quantum-coin-js-sdk/LICENSE +21 -0
  36. package/examples/node_modules/quantum-coin-js-sdk/LICENSE-wasm_exec.js.txt +30 -0
  37. package/examples/node_modules/quantum-coin-js-sdk/README.md +1665 -0
  38. package/examples/node_modules/quantum-coin-js-sdk/example/README.md +14 -0
  39. package/examples/node_modules/quantum-coin-js-sdk/example/conversion-example.js +19 -0
  40. package/examples/node_modules/quantum-coin-js-sdk/example/example-create-contract.js +396 -0
  41. package/examples/node_modules/quantum-coin-js-sdk/example/example-encode-decode-rlp.js +225 -0
  42. package/examples/node_modules/quantum-coin-js-sdk/example/example-event-pack-unpack.js +391 -0
  43. package/examples/node_modules/quantum-coin-js-sdk/example/example-misc.js +101 -0
  44. package/examples/node_modules/quantum-coin-js-sdk/example/example-rpc-send-signRawTransaction.js +318 -0
  45. package/examples/node_modules/quantum-coin-js-sdk/example/example-rpc-send.js +116 -0
  46. package/examples/node_modules/quantum-coin-js-sdk/example/example-send.js +70 -0
  47. package/examples/node_modules/quantum-coin-js-sdk/example/example-token-pack-unpack.js +961 -0
  48. package/examples/node_modules/quantum-coin-js-sdk/example/example-wallet-version4.js +35 -0
  49. package/examples/node_modules/quantum-coin-js-sdk/example/example-wallet.js +43 -0
  50. package/examples/node_modules/quantum-coin-js-sdk/example/example.js +405 -0
  51. package/examples/node_modules/quantum-coin-js-sdk/example/package-lock.json +134 -0
  52. package/examples/node_modules/quantum-coin-js-sdk/example/package.json +15 -0
  53. package/examples/node_modules/quantum-coin-js-sdk/index.d.ts +1024 -0
  54. package/examples/node_modules/quantum-coin-js-sdk/index.js +3062 -0
  55. package/examples/node_modules/quantum-coin-js-sdk/package.json +34 -0
  56. package/examples/node_modules/quantum-coin-js-sdk/tests/encrypted-32.json +1 -0
  57. package/examples/node_modules/quantum-coin-js-sdk/tests/encrypted-36.json +1 -0
  58. package/examples/node_modules/quantum-coin-js-sdk/tests/encrypted-48.json +1 -0
  59. package/examples/node_modules/quantum-coin-js-sdk/tests/generate-verify-vectors.js +91 -0
  60. package/examples/node_modules/quantum-coin-js-sdk/tests/non-transactional.preinit.test.js +41 -0
  61. package/examples/node_modules/quantum-coin-js-sdk/tests/non-transactional.test.js +686 -0
  62. package/examples/node_modules/quantum-coin-js-sdk/tests/sign-raw-keytype5-context-null.test.js +107 -0
  63. package/examples/node_modules/quantum-coin-js-sdk/tests/sign-raw-transaction.test.js +196 -0
  64. package/examples/node_modules/quantum-coin-js-sdk/tests/sign-verify.test.js +311 -0
  65. package/examples/node_modules/quantum-coin-js-sdk/tests/transactional.relay.test.js +131 -0
  66. package/examples/node_modules/quantum-coin-js-sdk/tests/transactional.rpc.test.js +103 -0
  67. package/examples/node_modules/quantum-coin-js-sdk/tests/verify-vectors.json +95035 -0
  68. package/examples/node_modules/quantum-coin-js-sdk/wasmBase64.d.ts +9 -0
  69. package/examples/node_modules/quantum-coin-js-sdk/wasmBase64.js +16 -0
  70. package/examples/node_modules/quantum-coin-js-sdk/wasm_exec.d.ts +0 -0
  71. package/examples/node_modules/quantum-coin-js-sdk/wasm_exec.js +587 -0
  72. package/examples/node_modules/resolve-pkg-maps/LICENSE +21 -0
  73. package/examples/node_modules/resolve-pkg-maps/README.md +216 -0
  74. package/examples/node_modules/resolve-pkg-maps/dist/index.cjs +1 -0
  75. package/examples/node_modules/resolve-pkg-maps/dist/index.d.cts +11 -0
  76. package/examples/node_modules/resolve-pkg-maps/dist/index.d.mts +11 -0
  77. package/examples/node_modules/resolve-pkg-maps/dist/index.mjs +1 -0
  78. package/examples/node_modules/resolve-pkg-maps/package.json +42 -0
  79. package/examples/node_modules/seed-words/.github/workflows/publish-npmjs.yaml +22 -0
  80. package/examples/node_modules/seed-words/BUILD.md +7 -0
  81. package/examples/node_modules/seed-words/LICENSE +121 -0
  82. package/examples/node_modules/seed-words/README.md +67 -0
  83. package/examples/node_modules/seed-words/dist/seedwords.d.ts +39 -0
  84. package/examples/node_modules/seed-words/package.json +27 -0
  85. package/examples/node_modules/seed-words/seedwords.js +315 -0
  86. package/examples/node_modules/seed-words/seedwords.txt +65536 -0
  87. package/examples/node_modules/seed-words/tsconfig.json +21 -0
  88. package/examples/node_modules/tsx/LICENSE +21 -0
  89. package/examples/node_modules/tsx/README.md +32 -0
  90. package/examples/node_modules/tsx/dist/cjs/api/index.cjs +1 -0
  91. package/examples/node_modules/tsx/dist/cjs/api/index.d.cts +35 -0
  92. package/examples/node_modules/tsx/dist/cjs/api/index.d.mts +35 -0
  93. package/examples/node_modules/tsx/dist/cjs/api/index.mjs +1 -0
  94. package/examples/node_modules/tsx/dist/cjs/index.cjs +1 -0
  95. package/examples/node_modules/tsx/dist/cjs/index.mjs +1 -0
  96. package/examples/node_modules/tsx/dist/cli.cjs +54 -0
  97. package/examples/node_modules/tsx/dist/cli.mjs +55 -0
  98. package/examples/node_modules/tsx/dist/client-BQVF1NaW.mjs +1 -0
  99. package/examples/node_modules/tsx/dist/client-D6NvIMSC.cjs +1 -0
  100. package/examples/node_modules/tsx/dist/esm/api/index.cjs +1 -0
  101. package/examples/node_modules/tsx/dist/esm/api/index.d.cts +35 -0
  102. package/examples/node_modules/tsx/dist/esm/api/index.d.mts +35 -0
  103. package/examples/node_modules/tsx/dist/esm/api/index.mjs +1 -0
  104. package/examples/node_modules/tsx/dist/esm/index.cjs +2 -0
  105. package/examples/node_modules/tsx/dist/esm/index.mjs +2 -0
  106. package/examples/node_modules/tsx/dist/get-pipe-path-BHW2eJdv.mjs +1 -0
  107. package/examples/node_modules/tsx/dist/get-pipe-path-BoR10qr8.cjs +1 -0
  108. package/examples/node_modules/tsx/dist/index-7AaEi15b.mjs +14 -0
  109. package/examples/node_modules/tsx/dist/index-BWFBUo6r.cjs +1 -0
  110. package/examples/node_modules/tsx/dist/index-gbaejti9.mjs +1 -0
  111. package/examples/node_modules/tsx/dist/index-gckBtVBf.cjs +14 -0
  112. package/examples/node_modules/tsx/dist/lexer-DQCqS3nf.mjs +3 -0
  113. package/examples/node_modules/tsx/dist/lexer-DgIbo0BU.cjs +3 -0
  114. package/examples/node_modules/tsx/dist/loader.cjs +1 -0
  115. package/examples/node_modules/tsx/dist/loader.mjs +1 -0
  116. package/examples/node_modules/tsx/dist/node-features-_8ZFwP_x.mjs +1 -0
  117. package/examples/node_modules/tsx/dist/node-features-roYmp9jK.cjs +1 -0
  118. package/examples/node_modules/tsx/dist/package-CeBgXWuR.mjs +1 -0
  119. package/examples/node_modules/tsx/dist/package-Dxt5kIHw.cjs +1 -0
  120. package/examples/node_modules/tsx/dist/patch-repl.cjs +1 -0
  121. package/examples/node_modules/tsx/dist/patch-repl.mjs +1 -0
  122. package/examples/node_modules/tsx/dist/preflight.cjs +1 -0
  123. package/examples/node_modules/tsx/dist/preflight.mjs +1 -0
  124. package/examples/node_modules/tsx/dist/register-2sWVXuRQ.cjs +1 -0
  125. package/examples/node_modules/tsx/dist/register-B7jrtLTO.mjs +1 -0
  126. package/examples/node_modules/tsx/dist/register-CFH5oNdT.mjs +4 -0
  127. package/examples/node_modules/tsx/dist/register-D46fvsV_.cjs +4 -0
  128. package/examples/node_modules/tsx/dist/repl.cjs +3 -0
  129. package/examples/node_modules/tsx/dist/repl.mjs +3 -0
  130. package/examples/node_modules/tsx/dist/require-D4F1Lv60.cjs +1 -0
  131. package/examples/node_modules/tsx/dist/require-DQxpCAr4.mjs +1 -0
  132. package/examples/node_modules/tsx/dist/suppress-warnings.cjs +1 -0
  133. package/examples/node_modules/tsx/dist/suppress-warnings.mjs +1 -0
  134. package/examples/node_modules/tsx/dist/temporary-directory-B83uKxJF.cjs +1 -0
  135. package/examples/node_modules/tsx/dist/temporary-directory-CwHp0_NW.mjs +1 -0
  136. package/examples/node_modules/tsx/dist/types-Cxp8y2TL.d.ts +5 -0
  137. package/examples/node_modules/tsx/package.json +68 -0
  138. package/examples/offline-signing.js +0 -2
  139. package/examples/offline-signing.ts +0 -1
  140. package/examples/package-lock.json +424 -73
  141. package/examples/package.json +2 -2
  142. package/examples/wallet-offline.js +10 -9
  143. package/examples/wallet-offline.ts +1 -9
  144. package/generate-sdk.js +4 -6
  145. package/package.json +2 -2
  146. package/src/abi/interface.js +13 -7
  147. package/src/abi/js-abi-coder.js +23 -18
  148. package/src/constants.d.ts +0 -5
  149. package/src/constants.js +0 -7
  150. package/src/contract/contract-factory.js +9 -3
  151. package/src/contract/contract.js +9 -3
  152. package/src/errors/index.js +12 -0
  153. package/src/index.d.ts +0 -3
  154. package/src/providers/extra-providers.js +20 -6
  155. package/src/providers/json-rpc-provider.js +15 -5
  156. package/src/providers/provider.d.ts +0 -2
  157. package/src/providers/provider.js +1 -3
  158. package/src/utils/address.d.ts +0 -14
  159. package/src/utils/address.js +12 -49
  160. package/src/utils/hashing.d.ts +0 -6
  161. package/src/utils/hashing.js +8 -23
  162. package/src/utils/index.d.ts +0 -3
  163. package/src/utils/rlp.js +7 -4
  164. package/src/wallet/wallet.d.ts +11 -13
  165. package/src/wallet/wallet.js +135 -96
  166. package/test/security/malformed-input.test.js +295 -1
  167. package/test/unit/address-wallet.test.js +277 -128
  168. package/test/unit/address-wallet.test.ts +276 -127
  169. package/test/unit/hashing.test.js +0 -11
  170. package/test/unit/hashing.test.ts +0 -11
  171. package/test/unit/providers.test.js +3 -1
  172. package/test/unit/providers.test.ts +3 -1
package/generate-sdk.js CHANGED
@@ -1269,7 +1269,6 @@ async function main() {
1269
1269
  nonce: nonce0,
1270
1270
  chainId,
1271
1271
  gasLimit,
1272
- gasPrice: 1n,
1273
1272
  });
1274
1273
 
1275
1274
  const sentDeploy = await provider.sendRawTransaction(rawDeploy);
@@ -1283,7 +1282,7 @@ async function main() {
1283
1282
  if (contract.populateTransaction && typeof contract.populateTransaction.approve === "function") {
1284
1283
  const txReq = await contract.populateTransaction.approve(from, 123, { gasLimit: 200000 });
1285
1284
  const nonce1 = await provider.getTransactionCount(from, "pending");
1286
- const raw = await wallet.signTransaction({ ...txReq, nonce: nonce1, chainId, gasPrice: 1n });
1285
+ const raw = await wallet.signTransaction({ ...txReq, nonce: nonce1, chainId });
1287
1286
  const sent = await provider.sendRawTransaction(raw);
1288
1287
  console.log("approve tx hash:", sent.hash);
1289
1288
  await sent.wait(1, 600_000);
@@ -1358,7 +1357,6 @@ async function main(): Promise<void> {
1358
1357
  nonce: nonce0,
1359
1358
  chainId,
1360
1359
  gasLimit,
1361
- gasPrice: 1n,
1362
1360
  });
1363
1361
 
1364
1362
  const sentDeploy = await provider.sendRawTransaction(rawDeploy);
@@ -1371,7 +1369,7 @@ async function main(): Promise<void> {
1371
1369
  if (contract.populateTransaction && typeof contract.populateTransaction.approve === "function") {
1372
1370
  const txReq = await contract.populateTransaction.approve(from, 123, { gasLimit: 200000 });
1373
1371
  const nonce1 = await provider.getTransactionCount(from, "pending");
1374
- const raw = await wallet.signTransaction({ ...txReq, nonce: nonce1, chainId, gasPrice: 1n });
1372
+ const raw = await wallet.signTransaction({ ...txReq, nonce: nonce1, chainId });
1375
1373
  const sent = await provider.sendRawTransaction(raw);
1376
1374
  console.log("approve tx hash:", sent.hash);
1377
1375
  await sent.wait(1, 600_000);
@@ -1492,7 +1490,7 @@ main().catch((e) => {
1492
1490
 
1493
1491
  _writeText(
1494
1492
  path.join(outDir, "examples", `offline-signing-${a.contractName}.js`),
1495
- `const { Initialize } = require("quantumcoin/config");\nconst { getProvider, Wallet, getCreateAddress } = require("quantumcoin");\nconst { TEST_WALLET_ENCRYPTED_JSON, TEST_WALLET_PASSPHRASE } = require("./_test-wallet");\nconst { ${a.contractName}__factory, ${a.contractName} } = require("..");\n\nasync function main() {\n const rpcUrl = process.env.QC_RPC_URL;\n if (!rpcUrl) throw new Error("QC_RPC_URL is required");\n const chainId = process.env.QC_CHAIN_ID ? Number(process.env.QC_CHAIN_ID) : 123123;\n await Initialize(null);\n\n const provider = getProvider(rpcUrl, chainId);\n const wallet = Wallet.fromEncryptedJsonSync(TEST_WALLET_ENCRYPTED_JSON, TEST_WALLET_PASSPHRASE);\n const from = wallet.address;\n\n const factory = new ${a.contractName}__factory(wallet);\n const deployTxReq = factory.getDeployTransaction();\n const nonce0 = await provider.getTransactionCount(from, \"pending\");\n const predicted = getCreateAddress({ from, nonce: nonce0 });\n\n const rawDeploy = await wallet.signTransaction({ ...deployTxReq, nonce: nonce0, chainId, gasLimit: 6_000_000, gasPrice: 1n });\n const sentDeploy = await provider.sendRawTransaction(rawDeploy);\n await sentDeploy.wait(1, 600_000);\n\n const contract = ${a.contractName}.connect(predicted, provider);\n console.log(\"deployed at:\", contract.target);\n}\n\nmain().catch((e) => { console.error(e); process.exitCode = 1; });\n`,
1493
+ `const { Initialize } = require("quantumcoin/config");\nconst { getProvider, Wallet, getCreateAddress } = require("quantumcoin");\nconst { TEST_WALLET_ENCRYPTED_JSON, TEST_WALLET_PASSPHRASE } = require("./_test-wallet");\nconst { ${a.contractName}__factory, ${a.contractName} } = require("..");\n\nasync function main() {\n const rpcUrl = process.env.QC_RPC_URL;\n if (!rpcUrl) throw new Error("QC_RPC_URL is required");\n const chainId = process.env.QC_CHAIN_ID ? Number(process.env.QC_CHAIN_ID) : 123123;\n await Initialize(null);\n\n const provider = getProvider(rpcUrl, chainId);\n const wallet = Wallet.fromEncryptedJsonSync(TEST_WALLET_ENCRYPTED_JSON, TEST_WALLET_PASSPHRASE);\n const from = wallet.address;\n\n const factory = new ${a.contractName}__factory(wallet);\n const deployTxReq = factory.getDeployTransaction();\n const nonce0 = await provider.getTransactionCount(from, \"pending\");\n const predicted = getCreateAddress({ from, nonce: nonce0 });\n\n const rawDeploy = await wallet.signTransaction({ ...deployTxReq, nonce: nonce0, chainId, gasLimit: 6_000_000 });\n const sentDeploy = await provider.sendRawTransaction(rawDeploy);\n await sentDeploy.wait(1, 600_000);\n\n const contract = ${a.contractName}.connect(predicted, provider);\n console.log(\"deployed at:\", contract.target);\n}\n\nmain().catch((e) => { console.error(e); process.exitCode = 1; });\n`,
1496
1494
  );
1497
1495
 
1498
1496
  _writeText(
@@ -1514,7 +1512,7 @@ main().catch((e) => {
1514
1512
  );
1515
1513
  _writeText(
1516
1514
  path.join(outDir, "examples", `offline-signing-${a.contractName}.ts`),
1517
- `import { Initialize } from "quantumcoin/config";\nimport { getProvider, Wallet, getCreateAddress } from "quantumcoin";\nimport { TEST_WALLET_ENCRYPTED_JSON, TEST_WALLET_PASSPHRASE } from "./_test-wallet";\nimport { ${a.contractName}__factory, ${a.contractName} } from "..";\n\nasync function main(): Promise<void> {\n const rpcUrl = process.env.QC_RPC_URL;\n if (!rpcUrl) throw new Error("QC_RPC_URL is required");\n const chainId = process.env.QC_CHAIN_ID ? Number(process.env.QC_CHAIN_ID) : 123123;\n await Initialize(null);\n\n const provider = getProvider(rpcUrl, chainId);\n const wallet = Wallet.fromEncryptedJsonSync(TEST_WALLET_ENCRYPTED_JSON, TEST_WALLET_PASSPHRASE);\n const from = wallet.address;\n\n const factory = new ${a.contractName}__factory(wallet);\n const deployTxReq = factory.getDeployTransaction();\n const nonce0 = await provider.getTransactionCount(from, "pending");\n const predicted = getCreateAddress({ from, nonce: nonce0 });\n\n const rawDeploy = await wallet.signTransaction({ ...deployTxReq, nonce: nonce0, chainId, gasLimit: 6_000_000, gasPrice: 1n });\n const sentDeploy = await provider.sendRawTransaction(rawDeploy);\n await sentDeploy.wait(1, 600_000);\n\n const contract = ${a.contractName}.connect(predicted, provider);\n console.log("deployed at:", contract.target);\n}\n\nmain().catch((e) => { console.error(e); process.exitCode = 1; });\n`,
1515
+ `import { Initialize } from "quantumcoin/config";\nimport { getProvider, Wallet, getCreateAddress } from "quantumcoin";\nimport { TEST_WALLET_ENCRYPTED_JSON, TEST_WALLET_PASSPHRASE } from "./_test-wallet";\nimport { ${a.contractName}__factory, ${a.contractName} } from "..";\n\nasync function main(): Promise<void> {\n const rpcUrl = process.env.QC_RPC_URL;\n if (!rpcUrl) throw new Error("QC_RPC_URL is required");\n const chainId = process.env.QC_CHAIN_ID ? Number(process.env.QC_CHAIN_ID) : 123123;\n await Initialize(null);\n\n const provider = getProvider(rpcUrl, chainId);\n const wallet = Wallet.fromEncryptedJsonSync(TEST_WALLET_ENCRYPTED_JSON, TEST_WALLET_PASSPHRASE);\n const from = wallet.address;\n\n const factory = new ${a.contractName}__factory(wallet);\n const deployTxReq = factory.getDeployTransaction();\n const nonce0 = await provider.getTransactionCount(from, "pending");\n const predicted = getCreateAddress({ from, nonce: nonce0 });\n\n const rawDeploy = await wallet.signTransaction({ ...deployTxReq, nonce: nonce0, chainId, gasLimit: 6_000_000 });\n const sentDeploy = await provider.sendRawTransaction(rawDeploy);\n await sentDeploy.wait(1, 600_000);\n\n const contract = ${a.contractName}.connect(predicted, provider);\n console.log("deployed at:", contract.target);\n}\n\nmain().catch((e) => { console.error(e); process.exitCode = 1; });\n`,
1518
1516
  );
1519
1517
  _writeText(
1520
1518
  path.join(outDir, "examples", `events-${a.contractName}.ts`),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quantumcoin",
3
- "version": "7.0.9",
3
+ "version": "7.0.11",
4
4
  "description": "QuantumCoin.js - a post quantum cryptography SDK for QuantumCoin",
5
5
  "main": "index.js",
6
6
  "types": "src/index.d.ts",
@@ -90,6 +90,6 @@
90
90
  },
91
91
  "dependencies": {
92
92
  "seed-words": "^1.0.2",
93
- "quantum-coin-js-sdk": "1.0.32"
93
+ "quantum-coin-js-sdk": "1.0.35"
94
94
  }
95
95
  }
@@ -16,12 +16,18 @@ const jsAbi = require("./js-abi-coder");
16
16
 
17
17
  function _requireInitialized() {
18
18
  // eslint-disable-next-line global-require
19
- const { isInitialized } = require("../../config");
20
- if (!isInitialized()) {
21
- throw makeError("QuantumCoin SDK not initialized. Call Initialize() first.", "UNKNOWN_ERROR", {
22
- operation: "abi",
23
- });
24
- }
19
+ const { isInitialized, getInitializationPromise } = require("../../config");
20
+ if (isInitialized()) return;
21
+ if (getInitializationPromise() != null) {
22
+ throw makeError(
23
+ "QuantumCoin SDK is still initializing. Await the Initialize() promise before using SDK methods.",
24
+ "UNKNOWN_ERROR",
25
+ { operation: "requireInitialized" },
26
+ );
27
+ }
28
+ throw makeError("QuantumCoin SDK not initialized. Call Initialize() first.", "UNKNOWN_ERROR", {
29
+ operation: "abi",
30
+ });
25
31
  }
26
32
 
27
33
  function _sanitizeArg(value) {
@@ -134,8 +140,8 @@ function _uint256ToFixedBytesHex(type, value) {
134
140
  if (value == null) return value;
135
141
 
136
142
  const bi = typeof value === "bigint" ? value : BigInt(value);
143
+ if (bi >= (1n << 256n)) throw makeError("value exceeds uint256", "INVALID_ARGUMENT", { value: bi.toString() });
137
144
  let hex = bi.toString(16);
138
- if (hex.length > 64) hex = hex.slice(-64);
139
145
  hex = hex.padStart(64, "0");
140
146
  // bytesN is the first N bytes (right-padded in the 32-byte word).
141
147
  return normalizeHex("0x" + hex.slice(0, n * 2));
@@ -13,6 +13,8 @@ const { makeError } = require("../errors");
13
13
  const { normalizeHex, strip0x, arrayify, bytesToHex, utf8ToBytes, bytesToUtf8 } = require("../internal/hex");
14
14
  const { id } = require("../utils/hashing");
15
15
 
16
+ const MAX_ABI_DEPTH = 16;
17
+
16
18
  function _isArrayType(type) {
17
19
  return typeof type === "string" && type.endsWith("]");
18
20
  }
@@ -115,8 +117,8 @@ function _concat(parts) {
115
117
  function _u256ToWord(bi) {
116
118
  let x = bi;
117
119
  if (x < 0n) throw new Error("uint must be non-negative");
120
+ if (x >= (1n << 256n)) throw makeError("value exceeds uint256", "INVALID_ARGUMENT", { value: x.toString() });
118
121
  let hex = x.toString(16);
119
- if (hex.length > 64) hex = hex.slice(-64);
120
122
  hex = hex.padStart(64, "0");
121
123
  return arrayify("0x" + hex);
122
124
  }
@@ -204,7 +206,8 @@ function _tupleValues(components, value) {
204
206
  return [];
205
207
  }
206
208
 
207
- function encodeTupleLike(params, values) {
209
+ function encodeTupleLike(params, values, depth) {
210
+ if (depth == null) depth = 0;
208
211
  const ps = Array.isArray(params) ? params : [];
209
212
  const vs = Array.isArray(values) ? values : [];
210
213
 
@@ -221,19 +224,21 @@ function encodeTupleLike(params, values) {
221
224
  const p = ps[i];
222
225
  const v = vs[i];
223
226
  if (_isDynamicType(p)) {
224
- const encTail = encodeParam(p, v);
227
+ const encTail = encodeParam(p, v, depth);
225
228
  headParts.push(_u256ToWord(BigInt(headSize + tailOffset)));
226
229
  tailParts.push(encTail);
227
230
  tailOffset += encTail.length;
228
231
  } else {
229
- headParts.push(encodeParam(p, v));
232
+ headParts.push(encodeParam(p, v, depth));
230
233
  }
231
234
  }
232
235
 
233
236
  return _concat([...headParts, ...tailParts]);
234
237
  }
235
238
 
236
- function encodeParam(param, value) {
239
+ function encodeParam(param, value, depth) {
240
+ if (depth == null) depth = 0;
241
+ if (depth > MAX_ABI_DEPTH) throw makeError("ABI encoding: maximum nesting depth exceeded", "INVALID_ARGUMENT", {});
237
242
  const type = String(param && param.type ? param.type : "");
238
243
 
239
244
  if (_isArrayType(type)) {
@@ -243,20 +248,19 @@ function encodeParam(param, value) {
243
248
 
244
249
  if (_isDynamicArray(type)) {
245
250
  const lenWord = _u256ToWord(BigInt(arr.length));
246
- const elems = encodeTupleLike(Array.from({ length: arr.length }).map(() => innerParam), arr);
251
+ const elems = encodeTupleLike(Array.from({ length: arr.length }).map(() => innerParam), arr, depth + 1);
247
252
  return _concat([lenWord, elems]);
248
253
  }
249
254
 
250
- // fixed array
251
255
  const n = _fixedArrayLength(type);
252
- const elems = encodeTupleLike(Array.from({ length: n }).map(() => innerParam), arr.slice(0, n));
256
+ const elems = encodeTupleLike(Array.from({ length: n }).map(() => innerParam), arr.slice(0, n), depth + 1);
253
257
  return elems;
254
258
  }
255
259
 
256
260
  if (type === "tuple") {
257
261
  const comps = Array.isArray(param.components) ? param.components : [];
258
262
  const vals = _tupleValues(comps, value);
259
- return encodeTupleLike(comps, vals);
263
+ return encodeTupleLike(comps, vals, depth + 1);
260
264
  }
261
265
 
262
266
  if (_isUint(type)) {
@@ -358,10 +362,10 @@ function _decodeString(data, baseOffset) {
358
362
  return bytesToUtf8(out);
359
363
  }
360
364
 
361
- function decodeTupleLike(params, data, baseOffset) {
365
+ function decodeTupleLike(params, data, baseOffset, depth) {
366
+ if (depth == null) depth = 0;
362
367
  const ps = Array.isArray(params) ? params : [];
363
368
 
364
- // Compute head size for this tuple-like block.
365
369
  const headWords = ps.reduce((a, p) => a + (_isDynamicType(p) ? 1 : _staticWords(p)), 0);
366
370
  const headSize = headWords * 32;
367
371
 
@@ -373,20 +377,21 @@ function decodeTupleLike(params, data, baseOffset) {
373
377
  const p = ps[i];
374
378
  if (_isDynamicType(p)) {
375
379
  const rel = _readWordAsNumber(data, baseOffset + headOff);
376
- values.push(decodeParam(p, data, baseOffset + rel));
380
+ values.push(decodeParam(p, data, baseOffset + rel, depth));
377
381
  headOff += 32;
378
382
  } else {
379
- values.push(decodeParam(p, data, baseOffset + headOff));
383
+ values.push(decodeParam(p, data, baseOffset + headOff, depth));
380
384
  headOff += _staticWords(p) * 32;
381
385
  }
382
386
  }
383
387
 
384
- // Ignore headSize; decodeParam consumes offsets itself.
385
388
  void headSize;
386
389
  return values;
387
390
  }
388
391
 
389
- function decodeParam(param, data, offset) {
392
+ function decodeParam(param, data, offset, depth) {
393
+ if (depth == null) depth = 0;
394
+ if (depth > MAX_ABI_DEPTH) throw makeError("ABI decoding: maximum nesting depth exceeded", "INVALID_ARGUMENT", {});
390
395
  const type = String(param && param.type ? param.type : "");
391
396
 
392
397
  if (_isArrayType(type)) {
@@ -395,17 +400,17 @@ function decodeParam(param, data, offset) {
395
400
 
396
401
  if (_isDynamicArray(type)) {
397
402
  const len = _readWordAsNumber(data, offset);
398
- const elems = decodeTupleLike(Array.from({ length: len }).map(() => innerParam), data, offset + 32);
403
+ const elems = decodeTupleLike(Array.from({ length: len }).map(() => innerParam), data, offset + 32, depth + 1);
399
404
  return elems;
400
405
  }
401
406
 
402
407
  const n = _fixedArrayLength(type);
403
- return decodeTupleLike(Array.from({ length: n }).map(() => innerParam), data, offset);
408
+ return decodeTupleLike(Array.from({ length: n }).map(() => innerParam), data, offset, depth + 1);
404
409
  }
405
410
 
406
411
  if (type === "tuple") {
407
412
  const comps = Array.isArray(param.components) ? param.components : [];
408
- const vals = decodeTupleLike(comps, data, offset);
413
+ const vals = decodeTupleLike(comps, data, offset, depth + 1);
409
414
  const out = {};
410
415
  for (let i = 0; i < comps.length; i++) {
411
416
  const c = comps[i];
@@ -59,8 +59,3 @@ export const EtherSymbol: string;
59
59
  * @type {bigint}
60
60
  */
61
61
  export const N: bigint;
62
- /**
63
- * EIP-191 personal sign message prefix (ethers.js compatible).
64
- * @type {string}
65
- */
66
- export const MessagePrefix: string;
package/src/constants.js CHANGED
@@ -77,12 +77,6 @@ const EtherSymbol = "Ξ";
77
77
  */
78
78
  const N = 0n;
79
79
 
80
- /**
81
- * EIP-191 personal sign message prefix (ethers.js compatible).
82
- * @type {string}
83
- */
84
- const MessagePrefix = "\x19Ethereum Signed Message:\n";
85
-
86
80
  module.exports = {
87
81
  version,
88
82
  ZeroAddress,
@@ -96,6 +90,5 @@ module.exports = {
96
90
  WeiPerEther,
97
91
  EtherSymbol,
98
92
  N,
99
- MessagePrefix,
100
93
  };
101
94
 
@@ -12,10 +12,16 @@ const { getCreateAddress } = require("../utils/address");
12
12
 
13
13
  function _requireInitialized() {
14
14
  // eslint-disable-next-line global-require
15
- const { isInitialized } = require("../../config");
16
- if (!isInitialized()) {
17
- throw makeError("QuantumCoin SDK not initialized. Call Initialize() first.", "UNKNOWN_ERROR", { operation: "contract-factory" });
15
+ const { isInitialized, getInitializationPromise } = require("../../config");
16
+ if (isInitialized()) return;
17
+ if (getInitializationPromise() != null) {
18
+ throw makeError(
19
+ "QuantumCoin SDK is still initializing. Await the Initialize() promise before using SDK methods.",
20
+ "UNKNOWN_ERROR",
21
+ { operation: "requireInitialized" },
22
+ );
18
23
  }
24
+ throw makeError("QuantumCoin SDK not initialized. Call Initialize() first.", "UNKNOWN_ERROR", { operation: "contract-factory" });
19
25
  }
20
26
 
21
27
  class ContractFactory {
@@ -10,10 +10,16 @@ const { normalizeHex } = require("../internal/hex");
10
10
 
11
11
  function _requireInitialized() {
12
12
  // eslint-disable-next-line global-require
13
- const { isInitialized } = require("../../config");
14
- if (!isInitialized()) {
15
- throw makeError("QuantumCoin SDK not initialized. Call Initialize() first.", "UNKNOWN_ERROR", { operation: "contract" });
13
+ const { isInitialized, getInitializationPromise } = require("../../config");
14
+ if (isInitialized()) return;
15
+ if (getInitializationPromise() != null) {
16
+ throw makeError(
17
+ "QuantumCoin SDK is still initializing. Await the Initialize() promise before using SDK methods.",
18
+ "UNKNOWN_ERROR",
19
+ { operation: "requireInitialized" },
20
+ );
16
21
  }
22
+ throw makeError("QuantumCoin SDK not initialized. Call Initialize() first.", "UNKNOWN_ERROR", { operation: "contract" });
17
23
  }
18
24
 
19
25
  function _isProvider(obj) {
@@ -124,6 +124,17 @@ function assertArgument(check, message, name, value) {
124
124
  assert(check, message, "INVALID_ARGUMENT", { argument: name, value });
125
125
  }
126
126
 
127
+ /**
128
+ * Assert an argument constraint for sensitive material (keys, seeds, passwords).
129
+ * Uses "[REDACTED]" instead of the actual value to prevent leaking secrets in logs.
130
+ * @param {any} check
131
+ * @param {string} message
132
+ * @param {string} name
133
+ */
134
+ function assertSecretArgument(check, message, name) {
135
+ assert(check, message, "INVALID_ARGUMENT", { argument: name, value: "[REDACTED]" });
136
+ }
137
+
127
138
  /**
128
139
  * Provider error.
129
140
  */
@@ -181,6 +192,7 @@ module.exports = {
181
192
  makeError,
182
193
  assert,
183
194
  assertArgument,
195
+ assertSecretArgument,
184
196
  ProviderError,
185
197
  TransactionError,
186
198
  ContractError,
package/src/index.d.ts CHANGED
@@ -23,7 +23,6 @@ declare const _exports: {
23
23
  encodeRlp(value: any): string;
24
24
  decodeRlp(data: string): any;
25
25
  keccak256(data: string | Uint8Array): string;
26
- hashMessage(message: string | Uint8Array): string;
27
26
  sha256(data: string | Uint8Array): string;
28
27
  sha512(data: string | Uint8Array): string;
29
28
  ripemd160(data: string | Uint8Array): string;
@@ -70,8 +69,6 @@ declare const _exports: {
70
69
  }): string;
71
70
  getCreate2Address(from: string, salt: string, initCodeHash: string): string;
72
71
  computeAddress(key: string | Uint8Array): string;
73
- verifyMessage(message: string | Uint8Array, signature: string): string;
74
- recoverAddress(message: string | Uint8Array, signature: string): string;
75
72
  Interface: typeof import("./abi/interface").Interface;
76
73
  AbiCoder: typeof import("./abi/interface").AbiCoder;
77
74
  Fragment: typeof import("./abi/fragments").Fragment;
@@ -12,8 +12,12 @@ const net = require("node:net");
12
12
  const { JsonRpcSigner } = require("../wallet/wallet");
13
13
  const { normalizeHex, isHexString } = require("../internal/hex");
14
14
 
15
- let _wsRpcId = 1;
16
- let _ipcRpcId = 1;
15
+ const MAX_RESPONSE_SIZE = 16 * 1024 * 1024;
16
+ const MAX_IPC_BUFFER = 16 * 1024 * 1024;
17
+
18
+ function _bigIntReplacer(_key, value) {
19
+ return typeof value === "bigint" ? "0x" + value.toString(16) : value;
20
+ }
17
21
 
18
22
  /**
19
23
  * Extract the first complete JSON object from a stream buffer.
@@ -85,6 +89,7 @@ class WebSocketProvider extends AbstractProvider {
85
89
  }
86
90
  this.url = url.trim();
87
91
  this.chainId = chainId == null ? 123123 : chainId;
92
+ this._wsRpcId = 1;
88
93
 
89
94
  /** @type {any|null} */
90
95
  this._ws = null;
@@ -168,6 +173,7 @@ class WebSocketProvider extends AbstractProvider {
168
173
  const onMessage = (event) => {
169
174
  const data = event && event.data != null ? event.data : "";
170
175
  const text = typeof data === "string" ? data : data.toString();
176
+ if (text.length > MAX_RESPONSE_SIZE) return;
171
177
  let msg;
172
178
  try {
173
179
  msg = JSON.parse(text);
@@ -224,8 +230,8 @@ class WebSocketProvider extends AbstractProvider {
224
230
  throw makeError("WebSocket not connected", "UNKNOWN_ERROR", { url: this.url, method });
225
231
  }
226
232
 
227
- const id = _wsRpcId++;
228
- const body = JSON.stringify({ jsonrpc: "2.0", id, method, params: params || [] });
233
+ const id = this._wsRpcId++;
234
+ const body = JSON.stringify({ jsonrpc: "2.0", id, method, params: params || [] }, _bigIntReplacer);
229
235
 
230
236
  return new Promise((resolve, reject) => {
231
237
  const timer = setTimeout(() => {
@@ -267,6 +273,7 @@ class IpcSocketProvider extends AbstractProvider {
267
273
  throw makeError("missing IPC path", "INVALID_ARGUMENT", { path });
268
274
  }
269
275
  this.path = path;
276
+ this._ipcRpcId = 1;
270
277
  }
271
278
 
272
279
  /**
@@ -275,14 +282,14 @@ class IpcSocketProvider extends AbstractProvider {
275
282
  * @returns {Promise<any>}
276
283
  */
277
284
  async _perform(method, params) {
278
- const id = _ipcRpcId++;
285
+ const id = this._ipcRpcId++;
279
286
  const body =
280
287
  JSON.stringify({
281
288
  jsonrpc: "2.0",
282
289
  id,
283
290
  method,
284
291
  params: params || [],
285
- }) + "\n";
292
+ }, _bigIntReplacer) + "\n";
286
293
 
287
294
  return new Promise((resolve, reject) => {
288
295
  /** @type {boolean} */
@@ -337,6 +344,13 @@ class IpcSocketProvider extends AbstractProvider {
337
344
  socket.on("data", (chunk) => {
338
345
  buffer += String(chunk);
339
346
 
347
+ if (buffer.length > MAX_IPC_BUFFER) {
348
+ finish(makeError("IPC response too large", "UNKNOWN_ERROR", {
349
+ method, path: this.path, size: buffer.length, limit: MAX_IPC_BUFFER,
350
+ }));
351
+ return;
352
+ }
353
+
340
354
  // Fast path: newline-delimited JSON responses.
341
355
  while (buffer.includes("\n")) {
342
356
  const idx = buffer.indexOf("\n");
@@ -6,7 +6,11 @@ const { AbstractProvider } = require("./provider");
6
6
  const { makeError } = require("../errors");
7
7
  const { Config, getConfig, isInitialized } = require("../../config");
8
8
 
9
- let _rpcId = 1;
9
+ const MAX_RESPONSE_SIZE = 16 * 1024 * 1024;
10
+
11
+ function _bigIntReplacer(_key, value) {
12
+ return typeof value === "bigint" ? "0x" + value.toString(16) : value;
13
+ }
10
14
 
11
15
  class JsonRpcProvider extends AbstractProvider {
12
16
  /**
@@ -15,11 +19,11 @@ class JsonRpcProvider extends AbstractProvider {
15
19
  */
16
20
  constructor(url, chainId) {
17
21
  super();
18
- // If not provided, attempt to use initialized config.js defaults.
19
22
  const active = isInitialized() ? getConfig() : null;
20
23
  const cfg = active || new Config();
21
24
  this.url = url || cfg.rpcEndpoint;
22
25
  this.chainId = chainId == null ? cfg.chainId : chainId;
26
+ this._rpcId = 1;
23
27
  }
24
28
 
25
29
  /**
@@ -29,13 +33,13 @@ class JsonRpcProvider extends AbstractProvider {
29
33
  * @returns {Promise<any>}
30
34
  */
31
35
  async _perform(method, params) {
32
- const id = _rpcId++;
36
+ const id = this._rpcId++;
33
37
  const body = JSON.stringify({
34
38
  jsonrpc: "2.0",
35
39
  id,
36
40
  method,
37
41
  params: params || [],
38
- });
42
+ }, _bigIntReplacer);
39
43
 
40
44
  const controller = new AbortController();
41
45
  const timeout = setTimeout(() => controller.abort(), 30_000);
@@ -46,7 +50,13 @@ class JsonRpcProvider extends AbstractProvider {
46
50
  body,
47
51
  signal: controller.signal,
48
52
  });
49
- const json = await resp.json().catch(() => null);
53
+ const text = await resp.text().catch(() => null);
54
+ if (text && text.length > MAX_RESPONSE_SIZE) {
55
+ throw makeError("JSON-RPC response too large", "UNKNOWN_ERROR", {
56
+ method, url: this.url, size: text.length, limit: MAX_RESPONSE_SIZE,
57
+ });
58
+ }
59
+ const json = text ? (() => { try { return JSON.parse(text); } catch { return null; } })() : null;
50
60
  if (!resp.ok) {
51
61
  throw makeError("JSON-RPC HTTP error", "UNKNOWN_ERROR", {
52
62
  status: resp.status,
@@ -5,7 +5,6 @@ export type TransactionRequest = {
5
5
  value?: (bigint | string | number) | undefined;
6
6
  data?: string | undefined;
7
7
  gasLimit?: (bigint | string | number) | undefined;
8
- gasPrice?: (bigint | string | number) | undefined;
9
8
  nonce?: number | undefined;
10
9
  chainId?: number | undefined;
11
10
  /**
@@ -149,7 +148,6 @@ export class TransactionResponse {
149
148
  data: any;
150
149
  value: any;
151
150
  gasLimit: any;
152
- gasPrice: any;
153
151
  chainId: number;
154
152
  blockNumber: number;
155
153
  txType: number | null;
@@ -20,7 +20,6 @@ const { normalizeHex, isHexString } = require("../internal/hex");
20
20
  * @property {bigint|string|number=} value
21
21
  * @property {string=} data
22
22
  * @property {bigint|string|number=} gasLimit
23
- * @property {bigint|string|number=} gasPrice
24
23
  * @property {number=} nonce
25
24
  * @property {number=} chainId
26
25
  * @property {string=} remarks Optional remark field (hex, max 32 bytes)
@@ -39,7 +38,7 @@ const { normalizeHex, isHexString } = require("../internal/hex");
39
38
  function _hexToBigInt(hex) {
40
39
  if (typeof hex === "bigint") return hex;
41
40
  if (typeof hex === "number") return BigInt(hex);
42
- // JSON-RPC "quantity" values may be odd-length (e.g. "0x0", "0x1").
41
+ if (hex === "0x" || hex === "0X") return 0n;
43
42
  assertArgument(typeof hex === "string" && /^0x[0-9a-fA-F]+$/.test(hex), "invalid hex quantity", "hex", hex);
44
43
  return BigInt(hex);
45
44
  }
@@ -139,7 +138,6 @@ class TransactionResponse {
139
138
  this.data = tx.input || tx.data || "0x";
140
139
  this.value = tx.value != null ? _hexToBigInt(tx.value) : 0n;
141
140
  this.gasLimit = tx.gas != null ? _hexToBigInt(tx.gas) : null;
142
- this.gasPrice = tx.gasPrice != null ? _hexToBigInt(tx.gasPrice) : null;
143
141
  this.chainId = tx.chainId != null ? _hexToNumber(tx.chainId) : null;
144
142
  this.blockNumber = tx.blockNumber != null ? _hexToNumber(tx.blockNumber) : null;
145
143
  this.txType = tx.type != null ? _hexToNumber(tx.type) : null;
@@ -56,17 +56,3 @@ export function getCreate2Address(from: string, salt: string, initCodeHash: stri
56
56
  * @returns {string}
57
57
  */
58
58
  export function computeAddress(key: string | Uint8Array): string;
59
- /**
60
- * Verifies a message signature and recovers the address.
61
- * @param {string|Uint8Array} message
62
- * @param {string} signature Hex string signature
63
- * @returns {string}
64
- */
65
- export function verifyMessage(message: string | Uint8Array, signature: string): string;
66
- /**
67
- * Recovers the address from a message signature.
68
- * @param {string|Uint8Array} message
69
- * @param {string} signature Hex string signature
70
- * @returns {string}
71
- */
72
- export function recoverAddress(message: string | Uint8Array, signature: string): string;
@@ -8,18 +8,22 @@
8
8
  const qcsdk = require("quantum-coin-js-sdk");
9
9
  const { assertArgument, makeError } = require("../errors");
10
10
  const { arrayify, bytesToHex, hexToBytes, isHexString, normalizeHex } = require("../internal/hex");
11
- const { hashMessage } = require("./hashing");
11
+
12
12
 
13
13
  function _requireInitialized() {
14
- // The spec requires Initialize() to be called before using the SDK.
15
- // config.js tracks initialization state for this package.
16
14
  // eslint-disable-next-line global-require
17
- const { isInitialized } = require("../../config");
18
- if (!isInitialized()) {
19
- throw makeError("QuantumCoin SDK not initialized. Call Initialize() first.", "UNKNOWN_ERROR", {
20
- operation: "address-utils",
21
- });
15
+ const { isInitialized, getInitializationPromise } = require("../../config");
16
+ if (isInitialized()) return;
17
+ if (getInitializationPromise() != null) {
18
+ throw makeError(
19
+ "QuantumCoin SDK is still initializing. Await the Initialize() promise before using SDK methods.",
20
+ "UNKNOWN_ERROR",
21
+ { operation: "requireInitialized" },
22
+ );
22
23
  }
24
+ throw makeError("QuantumCoin SDK not initialized. Call Initialize() first.", "UNKNOWN_ERROR", {
25
+ operation: "address-utils",
26
+ });
23
27
  }
24
28
 
25
29
  /**
@@ -127,45 +131,6 @@ function computeAddress(key) {
127
131
  return normalizeHex(out);
128
132
  }
129
133
 
130
- function _digestMessage(message) {
131
- const digestHex = hashMessage(message);
132
- const digest = Array.from(hexToBytes(digestHex));
133
- assertArgument(digest.length === 32, "invalid digest length", "digest", digest.length);
134
- return digest;
135
- }
136
-
137
- function _signatureToBytes(signature) {
138
- assertArgument(typeof signature === "string", "signature must be a hex string", "signature", signature);
139
- assertArgument(isHexString(signature), "invalid signature hex", "signature", signature);
140
- return Array.from(hexToBytes(signature));
141
- }
142
-
143
- /**
144
- * Verifies a message signature and recovers the address.
145
- * @param {string|Uint8Array} message
146
- * @param {string} signature Hex string signature
147
- * @returns {string}
148
- */
149
- function verifyMessage(message, signature) {
150
- return recoverAddress(message, signature);
151
- }
152
-
153
- /**
154
- * Recovers the address from a message signature.
155
- * @param {string|Uint8Array} message
156
- * @param {string} signature Hex string signature
157
- * @returns {string}
158
- */
159
- function recoverAddress(message, signature) {
160
- _requireInitialized();
161
- const digest = _digestMessage(message);
162
- const sigBytes = _signatureToBytes(signature);
163
- const pubHex = qcsdk.publicKeyFromSignature(digest, sigBytes);
164
- if (typeof pubHex !== "string") throw makeError("publicKeyFromSignature failed", "UNKNOWN_ERROR", {});
165
- const addr = computeAddress(pubHex);
166
- return addr;
167
- }
168
-
169
134
  module.exports = {
170
135
  isAddress,
171
136
  getAddress,
@@ -175,7 +140,5 @@ module.exports = {
175
140
  getCreateAddress,
176
141
  getCreate2Address,
177
142
  computeAddress,
178
- verifyMessage,
179
- recoverAddress,
180
143
  };
181
144
 
@@ -4,12 +4,6 @@
4
4
  * @returns {string}
5
5
  */
6
6
  export function keccak256(data: string | Uint8Array): string;
7
- /**
8
- * EIP-191 personal-sign message digest (ethers.js hashMessage pattern).
9
- * @param {string|Uint8Array} message
10
- * @returns {string}
11
- */
12
- export function hashMessage(message: string | Uint8Array): string;
13
7
  /**
14
8
  * sha256 hash of BytesLike.
15
9
  * @param {string|Uint8Array} data