quantumcoin 7.0.2 → 7.0.4
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.
- package/.github/workflows/publish-npmjs.yaml +22 -22
- package/.gitignore +15 -15
- package/LICENSE +21 -21
- package/README-SDK.md +756 -756
- package/README.md +165 -152
- package/SPEC.md +3845 -3845
- package/config.d.ts +50 -50
- package/config.js +115 -115
- package/examples/AllSolidityTypes.sol +184 -184
- package/examples/SimpleIERC20.sol +74 -74
- package/examples/events.js +41 -35
- package/examples/events.ts +35 -0
- package/examples/example-generator-sdk-js.js +100 -95
- package/examples/example-generator-sdk-js.ts +77 -0
- package/examples/example-generator-sdk-ts.js +100 -95
- package/examples/example-generator-sdk-ts.ts +77 -0
- package/examples/example.js +72 -61
- package/examples/example.ts +61 -0
- package/examples/offline-signing.js +79 -0
- package/examples/offline-signing.ts +66 -0
- package/examples/package-lock.json +48 -57
- package/examples/package.json +32 -16
- package/examples/read-operations.js +32 -27
- package/examples/read-operations.ts +31 -0
- package/examples/sdk-generator-erc20.inline.json +251 -251
- package/examples/solidity-types.ts +43 -43
- package/examples/wallet-offline.js +35 -29
- package/examples/wallet-offline.ts +34 -0
- package/generate-sdk.js +1824 -1383
- package/index.js +12 -12
- package/package.json +95 -75
- package/scripts/copy-declarations.js +31 -0
- package/scripts/run-all-one-by-one.js +151 -0
- package/src/abi/fragments.d.ts +42 -42
- package/src/abi/fragments.js +63 -63
- package/src/abi/index.d.ts +13 -13
- package/src/abi/index.js +9 -9
- package/src/abi/interface.d.ts +128 -132
- package/src/abi/interface.js +590 -590
- package/src/abi/js-abi-coder.d.ts +8 -0
- package/src/abi/js-abi-coder.js +474 -474
- package/src/constants.d.ts +66 -61
- package/src/constants.js +101 -94
- package/src/contract/contract-factory.d.ts +28 -28
- package/src/contract/contract-factory.js +105 -105
- package/src/contract/contract.d.ts +113 -105
- package/src/contract/contract.js +354 -312
- package/src/contract/index.d.ts +9 -9
- package/src/contract/index.js +9 -9
- package/src/errors/index.d.ts +92 -92
- package/src/errors/index.js +188 -188
- package/src/generator/index.d.ts +74 -0
- package/src/generator/index.js +1404 -1201
- package/src/index.d.ts +125 -127
- package/src/index.js +41 -41
- package/src/internal/hex.d.ts +61 -61
- package/src/internal/hex.js +144 -144
- package/src/providers/extra-providers.d.ts +139 -128
- package/src/providers/extra-providers.js +600 -575
- package/src/providers/index.d.ts +17 -16
- package/src/providers/index.js +10 -10
- package/src/providers/json-rpc-provider.d.ts +12 -12
- package/src/providers/json-rpc-provider.js +79 -79
- package/src/providers/provider.d.ts +207 -196
- package/src/providers/provider.js +392 -359
- package/src/types/index.d.ts +214 -462
- package/src/types/index.js +9 -9
- package/src/utils/address.d.ts +72 -72
- package/src/utils/address.js +181 -182
- package/src/utils/encoding.d.ts +120 -120
- package/src/utils/encoding.js +306 -306
- package/src/utils/hashing.d.ts +82 -76
- package/src/utils/hashing.js +313 -298
- package/src/utils/index.d.ts +65 -55
- package/src/utils/index.js +13 -13
- package/src/utils/result.d.ts +57 -57
- package/src/utils/result.js +128 -128
- package/src/utils/rlp.d.ts +12 -12
- package/src/utils/rlp.js +200 -200
- package/src/utils/units.d.ts +29 -29
- package/src/utils/units.js +107 -107
- package/src/wallet/index.d.ts +10 -10
- package/src/wallet/index.js +8 -8
- package/src/wallet/wallet.d.ts +160 -160
- package/src/wallet/wallet.js +483 -489
- package/test/e2e/all-solidity-types.dynamic.test.js +207 -200
- package/test/e2e/all-solidity-types.dynamic.test.ts +191 -0
- package/test/e2e/all-solidity-types.fixtures.js +231 -231
- package/test/e2e/all-solidity-types.generated-sdks.e2e.test.js +387 -361
- package/test/e2e/all-solidity-types.generated-sdks.e2e.test.ts +350 -0
- package/test/e2e/helpers.js +59 -47
- package/test/e2e/signing-context-and-fee.e2e.test.js +137 -0
- package/test/e2e/signing-context-and-fee.e2e.test.ts +128 -0
- package/test/e2e/simple-erc20.generated-sdks.e2e.test.js +168 -144
- package/test/e2e/simple-erc20.generated-sdks.e2e.test.ts +141 -0
- package/test/e2e/transactional.test.js +245 -191
- package/test/e2e/transactional.test.ts +208 -0
- package/test/e2e/typed-generator.e2e.test.js +407 -402
- package/test/e2e/typed-generator.e2e.test.ts +337 -0
- package/test/fixtures/ConstructorParam.sol +23 -23
- package/test/fixtures/MultiContracts.sol +37 -37
- package/test/fixtures/SimpleStorage.sol +18 -18
- package/test/fixtures/StakingContract.abi.json +1 -1
- package/test/integration/ipc-provider.test.js +49 -44
- package/test/integration/ipc-provider.test.ts +44 -0
- package/test/integration/provider.test.js +88 -72
- package/test/integration/provider.test.ts +85 -0
- package/test/integration/ws-provider.test.js +41 -33
- package/test/integration/ws-provider.test.ts +38 -0
- package/test/security/malformed-input.test.js +37 -31
- package/test/security/malformed-input.test.ts +35 -0
- package/test/unit/_encrypted-output.txt +6 -0
- package/test/unit/_log-encrypted-jsons.js +45 -0
- package/test/unit/_write-keystore-fixture.js +16 -0
- package/test/unit/abi-interface.test.js +103 -98
- package/test/unit/abi-interface.test.ts +102 -0
- package/test/unit/address-wallet.test.js +355 -257
- package/test/unit/address-wallet.test.ts +342 -0
- package/test/unit/browser-provider.test.js +85 -82
- package/test/unit/browser-provider.test.ts +79 -0
- package/test/unit/contract.test.js +85 -82
- package/test/unit/contract.test.ts +83 -0
- package/test/unit/encoding-units-rlp.test.js +92 -89
- package/test/unit/encoding-units-rlp.test.ts +91 -0
- package/test/unit/errors.test.js +77 -74
- package/test/unit/errors.test.ts +76 -0
- package/test/unit/filter-by-blockhash.test.js +55 -52
- package/test/unit/filter-by-blockhash.test.ts +54 -0
- package/test/unit/fixtures/encrypted-keystores-48-32-36.js +9 -0
- package/test/unit/generate-contract-cli.test.js +42 -39
- package/test/unit/generate-contract-cli.test.ts +41 -0
- package/test/unit/generate-sdk-artifacts-json.test.js +113 -110
- package/test/unit/generate-sdk-artifacts-json.test.ts +110 -0
- package/test/unit/generator.test.js +102 -98
- package/test/unit/generator.test.ts +101 -0
- package/test/unit/hashing.test.js +68 -54
- package/test/unit/hashing.test.ts +67 -0
- package/test/unit/init.test.js +39 -36
- package/test/unit/init.test.ts +38 -0
- package/test/unit/interface.test.js +56 -53
- package/test/unit/interface.test.ts +54 -0
- package/test/unit/internal-hex.test.js +50 -47
- package/test/unit/internal-hex.test.ts +49 -0
- package/test/unit/populate-transaction.test.js +65 -0
- package/test/unit/populate-transaction.test.ts +64 -0
- package/test/unit/providers.test.js +200 -144
- package/test/unit/providers.test.ts +196 -0
- package/test/unit/result.test.js +80 -77
- package/test/unit/result.test.ts +79 -0
- package/test/unit/solidity-types.test.js +49 -46
- package/test/unit/solidity-types.test.ts +39 -0
- package/test/unit/utils.test.js +57 -54
- package/test/unit/utils.test.ts +56 -0
- package/test/verbose-logger.js +74 -0
- package/tsconfig.build.json +14 -0
package/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Package entrypoint for `require("quantumcoin")`.
|
|
3
|
-
*
|
|
4
|
-
* This exports the ethers.js v6 compatible API surface implemented in `src/`,
|
|
5
|
-
* plus the initialization utilities from `config.js`.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
module.exports = {
|
|
9
|
-
...require("./src"),
|
|
10
|
-
...require("./config"),
|
|
11
|
-
};
|
|
12
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Package entrypoint for `require("quantumcoin")`.
|
|
3
|
+
*
|
|
4
|
+
* This exports the ethers.js v6 compatible API surface implemented in `src/`,
|
|
5
|
+
* plus the initialization utilities from `config.js`.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
...require("./src"),
|
|
10
|
+
...require("./config"),
|
|
11
|
+
};
|
|
12
|
+
|
package/package.json
CHANGED
|
@@ -1,75 +1,95 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "quantumcoin",
|
|
3
|
-
"version": "7.0.
|
|
4
|
-
"description": "QuantumCoin SDK - a complete SDK for dapps",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"types": "src/index.d.ts",
|
|
7
|
-
"typesVersions": {
|
|
8
|
-
"*": {
|
|
9
|
-
"types": [
|
|
10
|
-
"src/types/index.d.ts"
|
|
11
|
-
],
|
|
12
|
-
"config": [
|
|
13
|
-
"config.d.ts"
|
|
14
|
-
]
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
"exports": {
|
|
18
|
-
".": {
|
|
19
|
-
"types": "./src/index.d.ts",
|
|
20
|
-
"default": "./index.js"
|
|
21
|
-
},
|
|
22
|
-
"./config": {
|
|
23
|
-
"types": "./config.d.ts",
|
|
24
|
-
"default": "./config.js"
|
|
25
|
-
},
|
|
26
|
-
"./types": {
|
|
27
|
-
"types": "./src/types/index.d.ts",
|
|
28
|
-
"default": "./src/types/index.js"
|
|
29
|
-
},
|
|
30
|
-
"./package.json": "./package.json"
|
|
31
|
-
},
|
|
32
|
-
"scripts": {
|
|
33
|
-
"test": "node --test \"test/**/*.test.js\"",
|
|
34
|
-
"test:unit": "node --test \"test/unit/**/*.test.js\"",
|
|
35
|
-
"test:integration": "node --test \"test/integration/**/*.test.js\"",
|
|
36
|
-
"test:security": "node --test \"test/security/**/*.test.js\"",
|
|
37
|
-
"test:non-transactional": "node --test \"test/unit/**/*.test.js\" \"test/integration/**/*.test.js\" \"test/security/**/*.test.js\"",
|
|
38
|
-
"test:e2e": "node --test --test-concurrency=1 \"test/e2e
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "quantumcoin",
|
|
3
|
+
"version": "7.0.4",
|
|
4
|
+
"description": "QuantumCoin SDK - a complete SDK for dapps",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "src/index.d.ts",
|
|
7
|
+
"typesVersions": {
|
|
8
|
+
"*": {
|
|
9
|
+
"types": [
|
|
10
|
+
"src/types/index.d.ts"
|
|
11
|
+
],
|
|
12
|
+
"config": [
|
|
13
|
+
"config.d.ts"
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./src/index.d.ts",
|
|
20
|
+
"default": "./index.js"
|
|
21
|
+
},
|
|
22
|
+
"./config": {
|
|
23
|
+
"types": "./config.d.ts",
|
|
24
|
+
"default": "./config.js"
|
|
25
|
+
},
|
|
26
|
+
"./types": {
|
|
27
|
+
"types": "./src/types/index.d.ts",
|
|
28
|
+
"default": "./src/types/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"test": "node --test \"test/unit/**/*.test.js\" \"test/integration/**/*.test.js\" \"test/security/**/*.test.js\" \"test/e2e/*.test.js\"",
|
|
34
|
+
"test:unit": "node --test \"test/unit/**/*.test.js\"",
|
|
35
|
+
"test:integration": "node --test \"test/integration/**/*.test.js\"",
|
|
36
|
+
"test:security": "node --test \"test/security/**/*.test.js\"",
|
|
37
|
+
"test:non-transactional": "node --test \"test/unit/**/*.test.js\" \"test/integration/**/*.test.js\" \"test/security/**/*.test.js\"",
|
|
38
|
+
"test:e2e": "node --test --test-concurrency=1 \"test/e2e/*.test.js\"",
|
|
39
|
+
"test:generator-sdk": "node --test \"test/unit/generate-contract-cli.test.js\" \"test/unit/generator.test.js\" \"test/unit/generate-sdk-artifacts-json.test.js\" && node --test --test-concurrency=1 \"test/e2e/typed-generator.e2e.test.js\" \"test/e2e/simple-erc20.generated-sdks.e2e.test.js\" \"test/e2e/all-solidity-types.generated-sdks.e2e.test.js\"",
|
|
40
|
+
"test:ts:generator-sdk": "npx tsx --test \"test/unit/generate-contract-cli.test.ts\" \"test/unit/generator.test.ts\" \"test/unit/generate-sdk-artifacts-json.test.ts\" && npx tsx --test --test-concurrency=1 \"test/e2e/typed-generator.e2e.test.ts\" \"test/e2e/simple-erc20.generated-sdks.e2e.test.ts\" \"test/e2e/all-solidity-types.generated-sdks.e2e.test.ts\"",
|
|
41
|
+
"test:ts": "npx tsx --test \"test/unit/**/*.test.ts\" \"test/integration/**/*.test.ts\" \"test/security/**/*.test.ts\"",
|
|
42
|
+
"test:ts:unit": "npx tsx --test \"test/unit/**/*.test.ts\"",
|
|
43
|
+
"test:ts:integration": "npx tsx --test \"test/integration/**/*.test.ts\"",
|
|
44
|
+
"test:ts:security": "npx tsx --test \"test/security/**/*.test.ts\"",
|
|
45
|
+
"test:ts:e2e": "npx tsx --test --test-concurrency=1 \"test/e2e/*.test.ts\" \"test/e2e/*.e2e.test.ts\" \"test/e2e/*.dynamic.test.ts\"",
|
|
46
|
+
"example": "node examples/example.js",
|
|
47
|
+
"example:ts": "npx tsx examples/example.ts",
|
|
48
|
+
"example:provider": "node examples/example.js",
|
|
49
|
+
"example:wallet": "node examples/wallet-offline.js",
|
|
50
|
+
"example:wallet:ts": "npx tsx examples/wallet-offline.ts",
|
|
51
|
+
"example:contract:read": "node examples/read-operations.js",
|
|
52
|
+
"example:contract:read:ts": "npx tsx examples/read-operations.ts",
|
|
53
|
+
"example:events": "node examples/events.js",
|
|
54
|
+
"example:events:ts": "npx tsx examples/events.ts",
|
|
55
|
+
"example:offline-signing": "node examples/offline-signing.js",
|
|
56
|
+
"example:offline-signing:ts": "npx tsx examples/offline-signing.ts",
|
|
57
|
+
"example:generator-js": "node examples/example-generator-sdk-js.js",
|
|
58
|
+
"example:generator-js:ts": "npx tsx examples/example-generator-sdk-js.ts",
|
|
59
|
+
"example:generator-ts": "node examples/example-generator-sdk-ts.js",
|
|
60
|
+
"example:generator-ts:ts": "npx tsx examples/example-generator-sdk-ts.ts",
|
|
61
|
+
"examples": "node examples/example.js && node examples/wallet-offline.js && node examples/read-operations.js && node examples/events.js && node examples/example-generator-sdk-js.js && node examples/example-generator-sdk-ts.js",
|
|
62
|
+
"examples:ts": "npx tsx examples/example.ts && npx tsx examples/wallet-offline.ts && npx tsx examples/read-operations.ts && npx tsx examples/events.ts && npx tsx examples/example-generator-sdk-js.ts && npx tsx examples/example-generator-sdk-ts.ts",
|
|
63
|
+
"build": "npx -p typescript tsc -p tsconfig.build.json && node scripts/copy-declarations.js"
|
|
64
|
+
},
|
|
65
|
+
"repository": {
|
|
66
|
+
"type": "git",
|
|
67
|
+
"url": "git+https://github.com/quantumcoinproject/quantumcoin.js.git"
|
|
68
|
+
},
|
|
69
|
+
"files": [
|
|
70
|
+
"**"
|
|
71
|
+
],
|
|
72
|
+
"keywords": [
|
|
73
|
+
"cryptography",
|
|
74
|
+
"quantum coins",
|
|
75
|
+
"quantum coin",
|
|
76
|
+
"quantumcoin",
|
|
77
|
+
"blockchain"
|
|
78
|
+
],
|
|
79
|
+
"author": "QuantumCoin Community",
|
|
80
|
+
"license": "MIT",
|
|
81
|
+
"bugs": {
|
|
82
|
+
"url": "https://github.com/quantumcoinproject/quantumcoin.js/issues"
|
|
83
|
+
},
|
|
84
|
+
"homepage": "https://github.com/quantumcoinproject/quantumcoin.js#readme",
|
|
85
|
+
"bin": {
|
|
86
|
+
"sdkgen": "./generate-sdk.js"
|
|
87
|
+
},
|
|
88
|
+
"devDependencies": {
|
|
89
|
+
"tsx": "^4.19.0"
|
|
90
|
+
},
|
|
91
|
+
"dependencies": {
|
|
92
|
+
"seed-words": "^1.0.2",
|
|
93
|
+
"quantum-coin-js-sdk": "1.0.31"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copy generated .d.ts from dist/ into src/ so that package types stay in sync
|
|
3
|
+
* with the declarations emitted by `tsc` from JSDoc in the .js sources.
|
|
4
|
+
* Run after `npm run build`.
|
|
5
|
+
*/
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
|
|
9
|
+
const distDir = path.join(__dirname, "..", "dist");
|
|
10
|
+
const srcDir = path.join(__dirname, "..", "src");
|
|
11
|
+
|
|
12
|
+
if (!fs.existsSync(distDir)) {
|
|
13
|
+
console.warn("scripts/copy-declarations.js: dist/ not found, run build first.");
|
|
14
|
+
process.exit(0);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function copyRecursive(from, to) {
|
|
18
|
+
for (const name of fs.readdirSync(from)) {
|
|
19
|
+
const fromPath = path.join(from, name);
|
|
20
|
+
const toPath = path.join(to, name);
|
|
21
|
+
if (fs.statSync(fromPath).isDirectory()) {
|
|
22
|
+
if (!fs.existsSync(toPath)) fs.mkdirSync(toPath, { recursive: true });
|
|
23
|
+
copyRecursive(fromPath, toPath);
|
|
24
|
+
} else {
|
|
25
|
+
fs.copyFileSync(fromPath, toPath);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
copyRecursive(distDir, srcDir);
|
|
31
|
+
console.log("Declarations copied from dist/ to src/.");
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run all tests and examples one by one with process.env (set QC_RPC_URL, QC_SOLC_PATH).
|
|
3
|
+
* Prints a status table at the end.
|
|
4
|
+
* Usage: node scripts/run-all-one-by-one.js
|
|
5
|
+
*/
|
|
6
|
+
const { spawnSync } = require("node:child_process");
|
|
7
|
+
const path = require("node:path");
|
|
8
|
+
const fs = require("node:fs");
|
|
9
|
+
|
|
10
|
+
const repoRoot = path.resolve(__dirname, "..");
|
|
11
|
+
const isWin = process.platform === "win32";
|
|
12
|
+
|
|
13
|
+
function run(cmd, args, opts = {}) {
|
|
14
|
+
const cwd = opts.cwd || repoRoot;
|
|
15
|
+
const env = { ...process.env, ...opts.env };
|
|
16
|
+
const res = spawnSync(cmd, args, {
|
|
17
|
+
cwd,
|
|
18
|
+
env,
|
|
19
|
+
encoding: "utf8",
|
|
20
|
+
stdio: "pipe",
|
|
21
|
+
shell: false,
|
|
22
|
+
windowsHide: true,
|
|
23
|
+
timeout: opts.timeout ?? 120000,
|
|
24
|
+
});
|
|
25
|
+
return { ...res, status: res.status ?? (res.signal ? 1 : 0) };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function runShell(cmdLine, opts = {}) {
|
|
29
|
+
const cwd = opts.cwd || repoRoot;
|
|
30
|
+
const env = { ...process.env, ...opts.env };
|
|
31
|
+
if (isWin) {
|
|
32
|
+
return spawnSync("cmd.exe", ["/d", "/s", "/c", cmdLine], {
|
|
33
|
+
cwd,
|
|
34
|
+
env,
|
|
35
|
+
encoding: "utf8",
|
|
36
|
+
stdio: "pipe",
|
|
37
|
+
windowsHide: true,
|
|
38
|
+
timeout: opts.timeout ?? 120000,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return spawnSync("sh", ["-c", cmdLine], {
|
|
42
|
+
cwd,
|
|
43
|
+
env,
|
|
44
|
+
encoding: "utf8",
|
|
45
|
+
stdio: "pipe",
|
|
46
|
+
timeout: opts.timeout ?? 120000,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const results = [];
|
|
51
|
+
|
|
52
|
+
function add(name, ok, errMsg = "") {
|
|
53
|
+
results.push({ name, status: ok ? "PASS" : "FAIL", err: errMsg });
|
|
54
|
+
process.stdout.write(ok ? "." : "F");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Unit tests (node --test single file)
|
|
58
|
+
const unitDir = path.join(repoRoot, "test", "unit");
|
|
59
|
+
const unitFiles = fs.readdirSync(unitDir)
|
|
60
|
+
.filter((f) => f.endsWith(".test.js"))
|
|
61
|
+
.sort();
|
|
62
|
+
for (const f of unitFiles) {
|
|
63
|
+
const name = `unit / ${f}`;
|
|
64
|
+
const r = run(process.execPath, ["--test", path.join(unitDir, f)], { timeout: 60000 });
|
|
65
|
+
add(name, r.status === 0, r.stderr || r.stdout);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Integration
|
|
69
|
+
const intDir = path.join(repoRoot, "test", "integration");
|
|
70
|
+
const intFiles = fs.readdirSync(intDir)
|
|
71
|
+
.filter((f) => f.endsWith(".test.js"))
|
|
72
|
+
.sort();
|
|
73
|
+
for (const f of intFiles) {
|
|
74
|
+
const name = `integration / ${f}`;
|
|
75
|
+
const r = run(process.execPath, ["--test", path.join(intDir, f)], { timeout: 60000 });
|
|
76
|
+
add(name, r.status === 0, r.stderr || r.stdout);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Security
|
|
80
|
+
const secDir = path.join(repoRoot, "test", "security");
|
|
81
|
+
const secFiles = fs.readdirSync(secDir)
|
|
82
|
+
.filter((f) => f.endsWith(".test.js"))
|
|
83
|
+
.sort();
|
|
84
|
+
for (const f of secFiles) {
|
|
85
|
+
const name = `security / ${f}`;
|
|
86
|
+
const r = run(process.execPath, ["--test", path.join(secDir, f)], { timeout: 60000 });
|
|
87
|
+
add(name, r.status === 0, r.stderr || r.stdout);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// E2E (one by one, longer timeout)
|
|
91
|
+
const e2eDir = path.join(repoRoot, "test", "e2e");
|
|
92
|
+
const e2eFiles = fs.readdirSync(e2eDir)
|
|
93
|
+
.filter((f) => f.endsWith(".test.js"))
|
|
94
|
+
.sort();
|
|
95
|
+
for (const f of e2eFiles) {
|
|
96
|
+
const name = `e2e / ${f}`;
|
|
97
|
+
const r = run(process.execPath, ["--test", "--test-concurrency=1", path.join(e2eDir, f)], { timeout: 180000 });
|
|
98
|
+
add(name, r.status === 0, r.stderr || r.stdout);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Examples (JS)
|
|
102
|
+
const examples = [
|
|
103
|
+
["example.js", [process.execPath, "examples/example.js"]],
|
|
104
|
+
["wallet-offline.js", [process.execPath, "examples/wallet-offline.js"]],
|
|
105
|
+
["read-operations.js", [process.execPath, "examples/read-operations.js"]],
|
|
106
|
+
["events.js", [process.execPath, "examples/events.js"]],
|
|
107
|
+
["offline-signing.js", [process.execPath, "examples/offline-signing.js"]],
|
|
108
|
+
["example-generator-sdk-js.js", [process.execPath, "examples/example-generator-sdk-js.js"]],
|
|
109
|
+
["example-generator-sdk-ts.js", [process.execPath, "examples/example-generator-sdk-ts.js"]],
|
|
110
|
+
];
|
|
111
|
+
for (const [label, [cmd, ...args]] of examples) {
|
|
112
|
+
const r = run(cmd, args, { timeout: 90000 });
|
|
113
|
+
add(`example / ${label}`, r.status === 0, r.stderr || r.stdout);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Examples (TS via npx tsx)
|
|
117
|
+
const examplesTs = [
|
|
118
|
+
"example.ts",
|
|
119
|
+
"wallet-offline.ts",
|
|
120
|
+
"read-operations.ts",
|
|
121
|
+
"events.ts",
|
|
122
|
+
"offline-signing.ts",
|
|
123
|
+
"example-generator-sdk-js.ts",
|
|
124
|
+
"example-generator-sdk-ts.ts",
|
|
125
|
+
];
|
|
126
|
+
for (const f of examplesTs) {
|
|
127
|
+
const name = `example / ${f}`;
|
|
128
|
+
const r = runShell(`npx tsx examples/${f}`, { timeout: 90000 });
|
|
129
|
+
const status = r.status ?? (r.signal ? 1 : 0);
|
|
130
|
+
add(name, status === 0, r.stderr || r.stdout);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Print table
|
|
134
|
+
console.log("\n\n| Category | Item | Status |");
|
|
135
|
+
console.log("|------------|------|--------|");
|
|
136
|
+
let lastCat = "";
|
|
137
|
+
for (const { name, status } of results) {
|
|
138
|
+
const [cat, item] = name.split(" / ");
|
|
139
|
+
const catDisplay = cat !== lastCat ? cat : "";
|
|
140
|
+
lastCat = cat;
|
|
141
|
+
console.log(`| ${catDisplay.padEnd(10)} | ${item} | ${status} |`);
|
|
142
|
+
}
|
|
143
|
+
const passed = results.filter((r) => r.status === "PASS").length;
|
|
144
|
+
const failed = results.filter((r) => r.status === "FAIL").length;
|
|
145
|
+
console.log("\nTotal:", passed, "passed,", failed, "failed.");
|
|
146
|
+
if (failed > 0) {
|
|
147
|
+
console.log("\nFailed:");
|
|
148
|
+
results.filter((r) => r.status === "FAIL").forEach((r) => console.log(" -", r.name, "\n", r.err.slice(0, 500)));
|
|
149
|
+
process.exit(1);
|
|
150
|
+
}
|
|
151
|
+
process.exit(0);
|
package/src/abi/fragments.d.ts
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Minimal ABI fragment classes (ethers.js v6 compatible surface).
|
|
3
|
-
*
|
|
4
|
-
* This SDK keeps fragment handling lightweight and delegates ABI encoding/decoding
|
|
5
|
-
* to `quantum-coin-js-sdk` (WASM).
|
|
6
|
-
*/
|
|
7
|
-
export class Fragment {
|
|
8
|
-
/**
|
|
9
|
-
* @param {any} fragment
|
|
10
|
-
*/
|
|
11
|
-
constructor(fragment: any);
|
|
12
|
-
type: any;
|
|
13
|
-
name: any;
|
|
14
|
-
inputs: any;
|
|
15
|
-
outputs: any;
|
|
16
|
-
stateMutability: any;
|
|
17
|
-
anonymous: any;
|
|
18
|
-
/**
|
|
19
|
-
* Formats the fragment.
|
|
20
|
-
* @param {string=} format
|
|
21
|
-
* @returns {string}
|
|
22
|
-
*/
|
|
23
|
-
format(format?: string | undefined): string;
|
|
24
|
-
/**
|
|
25
|
-
* @returns {any}
|
|
26
|
-
*/
|
|
27
|
-
toJSON(): any;
|
|
28
|
-
}
|
|
29
|
-
export class NamedFragment extends Fragment {
|
|
30
|
-
}
|
|
31
|
-
export class FunctionFragment extends NamedFragment {
|
|
32
|
-
}
|
|
33
|
-
export class EventFragment extends NamedFragment {
|
|
34
|
-
}
|
|
35
|
-
export class ErrorFragment extends NamedFragment {
|
|
36
|
-
}
|
|
37
|
-
export class ConstructorFragment extends Fragment {
|
|
38
|
-
}
|
|
39
|
-
export class StructFragment extends Fragment {
|
|
40
|
-
}
|
|
41
|
-
export class FallbackFragment extends Fragment {
|
|
42
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Minimal ABI fragment classes (ethers.js v6 compatible surface).
|
|
3
|
+
*
|
|
4
|
+
* This SDK keeps fragment handling lightweight and delegates ABI encoding/decoding
|
|
5
|
+
* to `quantum-coin-js-sdk` (WASM).
|
|
6
|
+
*/
|
|
7
|
+
export class Fragment {
|
|
8
|
+
/**
|
|
9
|
+
* @param {any} fragment
|
|
10
|
+
*/
|
|
11
|
+
constructor(fragment: any);
|
|
12
|
+
type: any;
|
|
13
|
+
name: any;
|
|
14
|
+
inputs: any;
|
|
15
|
+
outputs: any;
|
|
16
|
+
stateMutability: any;
|
|
17
|
+
anonymous: any;
|
|
18
|
+
/**
|
|
19
|
+
* Formats the fragment.
|
|
20
|
+
* @param {string=} format
|
|
21
|
+
* @returns {string}
|
|
22
|
+
*/
|
|
23
|
+
format(format?: string | undefined): string;
|
|
24
|
+
/**
|
|
25
|
+
* @returns {any}
|
|
26
|
+
*/
|
|
27
|
+
toJSON(): any;
|
|
28
|
+
}
|
|
29
|
+
export class NamedFragment extends Fragment {
|
|
30
|
+
}
|
|
31
|
+
export class FunctionFragment extends NamedFragment {
|
|
32
|
+
}
|
|
33
|
+
export class EventFragment extends NamedFragment {
|
|
34
|
+
}
|
|
35
|
+
export class ErrorFragment extends NamedFragment {
|
|
36
|
+
}
|
|
37
|
+
export class ConstructorFragment extends Fragment {
|
|
38
|
+
}
|
|
39
|
+
export class StructFragment extends Fragment {
|
|
40
|
+
}
|
|
41
|
+
export class FallbackFragment extends Fragment {
|
|
42
|
+
}
|
package/src/abi/fragments.js
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Minimal ABI fragment classes (ethers.js v6 compatible surface).
|
|
3
|
-
*
|
|
4
|
-
* This SDK keeps fragment handling lightweight and delegates ABI encoding/decoding
|
|
5
|
-
* to `quantum-coin-js-sdk` (WASM).
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
class Fragment {
|
|
9
|
-
/**
|
|
10
|
-
* @param {any} fragment
|
|
11
|
-
*/
|
|
12
|
-
constructor(fragment) {
|
|
13
|
-
this.type = fragment?.type;
|
|
14
|
-
this.name = fragment?.name;
|
|
15
|
-
this.inputs = fragment?.inputs || [];
|
|
16
|
-
this.outputs = fragment?.outputs || [];
|
|
17
|
-
this.stateMutability = fragment?.stateMutability;
|
|
18
|
-
this.anonymous = fragment?.anonymous;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Formats the fragment.
|
|
23
|
-
* @param {string=} format
|
|
24
|
-
* @returns {string}
|
|
25
|
-
*/
|
|
26
|
-
format(format) {
|
|
27
|
-
// For now, return JSON-ish format (compatible enough for tooling).
|
|
28
|
-
// ethers supports "sighash", "full", etc.
|
|
29
|
-
void format;
|
|
30
|
-
return JSON.stringify(this.toJSON());
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* @returns {any}
|
|
35
|
-
*/
|
|
36
|
-
toJSON() {
|
|
37
|
-
const out = {};
|
|
38
|
-
for (const k of ["type", "name", "inputs", "outputs", "stateMutability", "anonymous"]) {
|
|
39
|
-
if (this[k] != null) out[k] = this[k];
|
|
40
|
-
}
|
|
41
|
-
return out;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
class NamedFragment extends Fragment {}
|
|
46
|
-
class FunctionFragment extends NamedFragment {}
|
|
47
|
-
class EventFragment extends NamedFragment {}
|
|
48
|
-
class ErrorFragment extends NamedFragment {}
|
|
49
|
-
class ConstructorFragment extends Fragment {}
|
|
50
|
-
class StructFragment extends Fragment {}
|
|
51
|
-
class FallbackFragment extends Fragment {}
|
|
52
|
-
|
|
53
|
-
module.exports = {
|
|
54
|
-
Fragment,
|
|
55
|
-
NamedFragment,
|
|
56
|
-
FunctionFragment,
|
|
57
|
-
EventFragment,
|
|
58
|
-
ErrorFragment,
|
|
59
|
-
ConstructorFragment,
|
|
60
|
-
StructFragment,
|
|
61
|
-
FallbackFragment,
|
|
62
|
-
};
|
|
63
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Minimal ABI fragment classes (ethers.js v6 compatible surface).
|
|
3
|
+
*
|
|
4
|
+
* This SDK keeps fragment handling lightweight and delegates ABI encoding/decoding
|
|
5
|
+
* to `quantum-coin-js-sdk` (WASM).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
class Fragment {
|
|
9
|
+
/**
|
|
10
|
+
* @param {any} fragment
|
|
11
|
+
*/
|
|
12
|
+
constructor(fragment) {
|
|
13
|
+
this.type = fragment?.type;
|
|
14
|
+
this.name = fragment?.name;
|
|
15
|
+
this.inputs = fragment?.inputs || [];
|
|
16
|
+
this.outputs = fragment?.outputs || [];
|
|
17
|
+
this.stateMutability = fragment?.stateMutability;
|
|
18
|
+
this.anonymous = fragment?.anonymous;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Formats the fragment.
|
|
23
|
+
* @param {string=} format
|
|
24
|
+
* @returns {string}
|
|
25
|
+
*/
|
|
26
|
+
format(format) {
|
|
27
|
+
// For now, return JSON-ish format (compatible enough for tooling).
|
|
28
|
+
// ethers supports "sighash", "full", etc.
|
|
29
|
+
void format;
|
|
30
|
+
return JSON.stringify(this.toJSON());
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @returns {any}
|
|
35
|
+
*/
|
|
36
|
+
toJSON() {
|
|
37
|
+
const out = {};
|
|
38
|
+
for (const k of ["type", "name", "inputs", "outputs", "stateMutability", "anonymous"]) {
|
|
39
|
+
if (this[k] != null) out[k] = this[k];
|
|
40
|
+
}
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
class NamedFragment extends Fragment {}
|
|
46
|
+
class FunctionFragment extends NamedFragment {}
|
|
47
|
+
class EventFragment extends NamedFragment {}
|
|
48
|
+
class ErrorFragment extends NamedFragment {}
|
|
49
|
+
class ConstructorFragment extends Fragment {}
|
|
50
|
+
class StructFragment extends Fragment {}
|
|
51
|
+
class FallbackFragment extends Fragment {}
|
|
52
|
+
|
|
53
|
+
module.exports = {
|
|
54
|
+
Fragment,
|
|
55
|
+
NamedFragment,
|
|
56
|
+
FunctionFragment,
|
|
57
|
+
EventFragment,
|
|
58
|
+
ErrorFragment,
|
|
59
|
+
ConstructorFragment,
|
|
60
|
+
StructFragment,
|
|
61
|
+
FallbackFragment,
|
|
62
|
+
};
|
|
63
|
+
|
package/src/abi/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
declare const _exports: {
|
|
2
|
-
Interface: typeof import("./interface").Interface;
|
|
3
|
-
AbiCoder: typeof import("./interface").AbiCoder;
|
|
4
|
-
Fragment: typeof import("./fragments").Fragment;
|
|
5
|
-
NamedFragment: typeof import("./fragments").NamedFragment;
|
|
6
|
-
FunctionFragment: typeof import("./fragments").FunctionFragment;
|
|
7
|
-
EventFragment: typeof import("./fragments").EventFragment;
|
|
8
|
-
ErrorFragment: typeof import("./fragments").ErrorFragment;
|
|
9
|
-
ConstructorFragment: typeof import("./fragments").ConstructorFragment;
|
|
10
|
-
StructFragment: typeof import("./fragments").StructFragment;
|
|
11
|
-
FallbackFragment: typeof import("./fragments").FallbackFragment;
|
|
12
|
-
};
|
|
13
|
-
export = _exports;
|
|
1
|
+
declare const _exports: {
|
|
2
|
+
Interface: typeof import("./interface").Interface;
|
|
3
|
+
AbiCoder: typeof import("./interface").AbiCoder;
|
|
4
|
+
Fragment: typeof import("./fragments").Fragment;
|
|
5
|
+
NamedFragment: typeof import("./fragments").NamedFragment;
|
|
6
|
+
FunctionFragment: typeof import("./fragments").FunctionFragment;
|
|
7
|
+
EventFragment: typeof import("./fragments").EventFragment;
|
|
8
|
+
ErrorFragment: typeof import("./fragments").ErrorFragment;
|
|
9
|
+
ConstructorFragment: typeof import("./fragments").ConstructorFragment;
|
|
10
|
+
StructFragment: typeof import("./fragments").StructFragment;
|
|
11
|
+
FallbackFragment: typeof import("./fragments").FallbackFragment;
|
|
12
|
+
};
|
|
13
|
+
export = _exports;
|
package/src/abi/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview ABI exports.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
...require("./fragments"),
|
|
7
|
-
...require("./interface"),
|
|
8
|
-
};
|
|
9
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview ABI exports.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
...require("./fragments"),
|
|
7
|
+
...require("./interface"),
|
|
8
|
+
};
|
|
9
|
+
|