quantumcoin 7.0.3 → 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 -754
- package/README.md +165 -150
- package/SPEC.md +3845 -3843
- 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 -73
- 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 -1490
- 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 -114
- package/src/contract/contract.js +354 -354
- 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 -1404
- 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 -203
- package/src/providers/provider.js +392 -371
- 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 -368
- 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 -151
- 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 -404
- 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 -99
- 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 -62
- 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
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TypeScript-only example: core Solidity types.
|
|
3
|
-
*
|
|
4
|
-
* This file is intended for developers using QuantumCoin.js from TypeScript.
|
|
5
|
-
* It is not executed by `npm run example`.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type {
|
|
9
|
-
AddressLike,
|
|
10
|
-
BigNumberish,
|
|
11
|
-
BytesLike,
|
|
12
|
-
SolidityInputValue,
|
|
13
|
-
SolidityOutputValue,
|
|
14
|
-
SolidityTypeName,
|
|
15
|
-
} from "quantumcoin/types";
|
|
16
|
-
|
|
17
|
-
// AddressLike is currently a string (32-byte QuantumCoin address).
|
|
18
|
-
const addr: AddressLike = "0x0000000000000000000000000000000000000000000000000000000000001000";
|
|
19
|
-
|
|
20
|
-
// BigNumberish is accepted for uint/int inputs (string | number | bigint).
|
|
21
|
-
const amount: BigNumberish = "123";
|
|
22
|
-
|
|
23
|
-
// BytesLike is a hex string or Uint8Array.
|
|
24
|
-
const data: BytesLike = "0x1234";
|
|
25
|
-
|
|
26
|
-
// Generic mappings for ABI input/output values:
|
|
27
|
-
type T1 = SolidityInputValue<"uint256">; // BigNumberish
|
|
28
|
-
type T2 = SolidityOutputValue<"uint256">; // bigint
|
|
29
|
-
type T3 = SolidityInputValue<"address">; // AddressLike
|
|
30
|
-
type T4 = SolidityOutputValue<"address">; // string
|
|
31
|
-
|
|
32
|
-
// Example: using SolidityTypeName
|
|
33
|
-
const t: SolidityTypeName = "bytes32";
|
|
34
|
-
|
|
35
|
-
void addr;
|
|
36
|
-
void amount;
|
|
37
|
-
void data;
|
|
38
|
-
void t;
|
|
39
|
-
void (null as any as T1);
|
|
40
|
-
void (null as any as T2);
|
|
41
|
-
void (null as any as T3);
|
|
42
|
-
void (null as any as T4);
|
|
43
|
-
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript-only example: core Solidity types.
|
|
3
|
+
*
|
|
4
|
+
* This file is intended for developers using QuantumCoin.js from TypeScript.
|
|
5
|
+
* It is not executed by `npm run example`.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type {
|
|
9
|
+
AddressLike,
|
|
10
|
+
BigNumberish,
|
|
11
|
+
BytesLike,
|
|
12
|
+
SolidityInputValue,
|
|
13
|
+
SolidityOutputValue,
|
|
14
|
+
SolidityTypeName,
|
|
15
|
+
} from "quantumcoin/types";
|
|
16
|
+
|
|
17
|
+
// AddressLike is currently a string (32-byte QuantumCoin address).
|
|
18
|
+
const addr: AddressLike = "0x0000000000000000000000000000000000000000000000000000000000001000";
|
|
19
|
+
|
|
20
|
+
// BigNumberish is accepted for uint/int inputs (string | number | bigint).
|
|
21
|
+
const amount: BigNumberish = "123";
|
|
22
|
+
|
|
23
|
+
// BytesLike is a hex string or Uint8Array.
|
|
24
|
+
const data: BytesLike = "0x1234";
|
|
25
|
+
|
|
26
|
+
// Generic mappings for ABI input/output values:
|
|
27
|
+
type T1 = SolidityInputValue<"uint256">; // BigNumberish
|
|
28
|
+
type T2 = SolidityOutputValue<"uint256">; // bigint
|
|
29
|
+
type T3 = SolidityInputValue<"address">; // AddressLike
|
|
30
|
+
type T4 = SolidityOutputValue<"address">; // string
|
|
31
|
+
|
|
32
|
+
// Example: using SolidityTypeName
|
|
33
|
+
const t: SolidityTypeName = "bytes32";
|
|
34
|
+
|
|
35
|
+
void addr;
|
|
36
|
+
void amount;
|
|
37
|
+
void data;
|
|
38
|
+
void t;
|
|
39
|
+
void (null as any as T1);
|
|
40
|
+
void (null as any as T2);
|
|
41
|
+
void (null as any as T3);
|
|
42
|
+
void (null as any as T4);
|
|
43
|
+
|
|
@@ -1,29 +1,35 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Example: Offline wallet operations (no blockchain connectivity required).
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
});
|
|
29
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Example: Offline wallet operations (no blockchain connectivity required).
|
|
3
|
+
* Run with VERBOSE=1 for wallet addresses and recovered address.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const { Initialize } = require("../config");
|
|
7
|
+
const { Wallet, verifyMessage } = require("..");
|
|
8
|
+
const { logExample, logAddress } = require("../test/verbose-logger");
|
|
9
|
+
|
|
10
|
+
async function walletOffline() {
|
|
11
|
+
logExample("wallet-offline.js", "starting");
|
|
12
|
+
await Initialize(null);
|
|
13
|
+
|
|
14
|
+
const wallet = Wallet.createRandom();
|
|
15
|
+
console.log("Wallet address:", wallet.address);
|
|
16
|
+
logAddress("wallet", wallet.address);
|
|
17
|
+
|
|
18
|
+
const msg = "Hello, QuantumCoin!";
|
|
19
|
+
const sig = wallet.signMessageSync(msg);
|
|
20
|
+
console.log("Signature:", sig.slice(0, 18) + "...");
|
|
21
|
+
|
|
22
|
+
const recovered = verifyMessage(msg, sig);
|
|
23
|
+
console.log("Recovered address:", recovered);
|
|
24
|
+
logAddress("recovered", recovered);
|
|
25
|
+
|
|
26
|
+
const json = wallet.encryptSync("mySecurePassword123");
|
|
27
|
+
console.log("Encrypted wallet JSON length:", json.length);
|
|
28
|
+
logExample("wallet-offline.js", "encryptSync", { jsonLength: json.length });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
walletOffline().catch((e) => {
|
|
32
|
+
console.error(e);
|
|
33
|
+
process.exitCode = 1;
|
|
34
|
+
});
|
|
35
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example: Offline wallet operations (no blockchain) - TypeScript.
|
|
3
|
+
* Run: npx tsx examples/wallet-offline.ts
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Initialize } from "../config";
|
|
7
|
+
import { Wallet, verifyMessage } from "..";
|
|
8
|
+
import { logExample, logAddress } from "../test/verbose-logger";
|
|
9
|
+
|
|
10
|
+
async function walletOffline(): Promise<void> {
|
|
11
|
+
logExample("wallet-offline.ts", "starting");
|
|
12
|
+
await Initialize(null);
|
|
13
|
+
|
|
14
|
+
const wallet = Wallet.createRandom();
|
|
15
|
+
console.log("Wallet address:", wallet.address);
|
|
16
|
+
logAddress("wallet", wallet.address);
|
|
17
|
+
|
|
18
|
+
const msg = "Hello, QuantumCoin!";
|
|
19
|
+
const sig = wallet.signMessageSync(msg);
|
|
20
|
+
console.log("Signature:", sig.slice(0, 18) + "...");
|
|
21
|
+
|
|
22
|
+
const recovered = verifyMessage(msg, sig);
|
|
23
|
+
console.log("Recovered address:", recovered);
|
|
24
|
+
logAddress("recovered", recovered);
|
|
25
|
+
|
|
26
|
+
const json = wallet.encryptSync("mySecurePassword123");
|
|
27
|
+
console.log("Encrypted wallet JSON length:", json.length);
|
|
28
|
+
logExample("wallet-offline.ts", "encryptSync", { jsonLength: json.length });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
walletOffline().catch((e) => {
|
|
32
|
+
console.error(e);
|
|
33
|
+
process.exitCode = 1;
|
|
34
|
+
});
|