quantumcoin 7.0.1 → 7.0.2

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 (36) hide show
  1. package/.gitignore +3 -0
  2. package/README-SDK.md +62 -6
  3. package/README.md +25 -0
  4. package/SPEC.md +3845 -0
  5. package/examples/AllSolidityTypes.sol +184 -0
  6. package/examples/SimpleIERC20.sol +74 -0
  7. package/examples/example-generator-sdk-js.js +95 -0
  8. package/examples/example-generator-sdk-ts.js +95 -0
  9. package/examples/example.js +2 -2
  10. package/examples/package-lock.json +10 -1103
  11. package/examples/package.json +1 -2
  12. package/examples/read-operations.js +1 -2
  13. package/examples/sdk-generator-erc20.inline.json +251 -0
  14. package/examples/solidity-types.ts +43 -0
  15. package/generate-sdk.js +579 -84
  16. package/package.json +27 -6
  17. package/src/abi/interface.d.ts +18 -0
  18. package/src/abi/interface.js +247 -9
  19. package/src/abi/js-abi-coder.js +474 -0
  20. package/src/contract/contract-factory.d.ts +1 -1
  21. package/src/contract/contract-factory.js +14 -2
  22. package/src/contract/contract.d.ts +1 -1
  23. package/src/generator/index.js +834 -59
  24. package/src/index.d.ts +16 -0
  25. package/src/providers/provider.d.ts +13 -11
  26. package/src/types/index.d.ts +462 -0
  27. package/src/types/index.js +9 -0
  28. package/test/e2e/all-solidity-types.dynamic.test.js +200 -0
  29. package/test/e2e/all-solidity-types.fixtures.js +231 -0
  30. package/test/e2e/all-solidity-types.generated-sdks.e2e.test.js +361 -0
  31. package/test/e2e/simple-erc20.generated-sdks.e2e.test.js +144 -0
  32. package/test/e2e/typed-generator.e2e.test.js +6 -6
  33. package/test/unit/generate-contract-cli.test.js +1 -0
  34. package/test/unit/generate-sdk-artifacts-json.test.js +45 -0
  35. package/test/unit/solidity-types.test.js +46 -0
  36. package/test/unit/utils.test.js +1 -1
package/.gitignore CHANGED
@@ -1,6 +1,9 @@
1
1
  node_modules/**
2
2
  output/**
3
3
  examples/node_modules/**
4
+ examples/example-generated-sdk-ts/**
5
+ examples/example-generated-sdk-js/**
6
+ test/e2e/generated-sdks/**
4
7
  **/*.save
5
8
  **/*.swp
6
9
  **/*.tgz
package/README-SDK.md CHANGED
@@ -563,6 +563,35 @@ From `quantumcoin`:
563
563
  **Example(s):**
564
564
  - `examples/wallet-offline.js`
565
565
 
566
+ ## Solidity Types (TypeScript)
567
+
568
+ QuantumCoin.js exposes core Solidity-related types for TypeScript users.
569
+
570
+ - **Import path**: `quantumcoin/types`
571
+
572
+ **Key exports**
573
+
574
+ - `AddressLike` (currently `string`, 32-byte address)
575
+ - `BytesLike` (`string | Uint8Array`)
576
+ - `BigNumberish` (`string | number | bigint`)
577
+ - `SolidityTypeName` (ABI type string model)
578
+ - **Hard Solidity aliases** (preferred for typed wrappers):
579
+ - Integers: `Uint256Like` / `Uint256`, `Int256Like` / `Int256` (and all widths `Uint8Like`…`Uint256Like`, `Int8Like`…`Int256Like`)
580
+ - Fixed bytes: `Bytes32Like` / `Bytes32` (and `Bytes1Like`…`Bytes32Like`)
581
+ - Arrays/tuples helpers: `SolArray<T>`, `SolFixedArray<T, N>`, `SolStruct<T>`
582
+ - `SolidityInputValue<T>` / `SolidityOutputValue<T>` (advanced type-level mapping from ABI type strings to JS values; the generator no longer uses these for wrapper signatures)
583
+
584
+ Example:
585
+
586
+ ```ts
587
+ import type { AddressLike, BigNumberish, Uint256Like, Uint256 } from "quantumcoin/types";
588
+
589
+ const to: AddressLike = "0x0000000000000000000000000000000000000000000000000000000000001000";
590
+ const amount: BigNumberish = "123";
591
+ const asInput: Uint256Like = amount;
592
+ const asOutput: Uint256 = 123n;
593
+ ```
594
+
566
595
  ### Encoding utilities
567
596
 
568
597
  - `toUtf8String(data: BytesLike): string`
@@ -625,7 +654,20 @@ From `quantumcoin`:
625
654
 
626
655
  ### Overview
627
656
 
628
- `generate-sdk.js` creates **typed TypeScript wrappers** for one or more contracts, and can optionally scaffold a complete npm package (with examples and transactional tests).
657
+ `generate-sdk.js` creates **typed contract wrappers** for one or more contracts, and can optionally scaffold a complete npm package (with examples and transactional tests).
658
+
659
+ It supports generating:
660
+ - **TypeScript source** (`--lang ts`, default)
661
+ - **JavaScript source + TypeScript declarations** (`--lang js`)
662
+
663
+ **Typing behaviour (generated wrappers)**
664
+
665
+ - **Hard types**: wrapper signatures use concrete types from `quantumcoin/types` (e.g. `Uint256Like` for inputs, `Uint256` for outputs).
666
+ - **Single output unwrapping**: functions returning one value return the value directly (not `[value]`).
667
+ - **Multiple outputs**: returned as a tuple type (e.g. `Promise<[Uint256, Bool]>`).
668
+ - **No outputs**: `Promise<void>`.
669
+ - **Structs / tuples**: emitted as `export type <Name>Input` / `export type <Name>Output` and used in signatures.
670
+ - **JS typing**: JS output uses JSDoc types plus `.d.ts` files; TS users still get strong types.
629
671
 
630
672
  **Entry point**
631
673
  - `node generate-sdk.js ...`
@@ -637,12 +679,18 @@ From `quantumcoin`:
637
679
 
638
680
  ```bash
639
681
  node generate-sdk.js --abi path/to/My.abi.json --bin path/to/My.bin --name MyContract --out ./out --non-interactive
682
+
683
+ # JS output
684
+ node generate-sdk.js --lang js --abi path/to/My.abi.json --bin path/to/My.bin --name MyContract --out ./out --non-interactive
640
685
  ```
641
686
 
642
687
  2) **Solidity sources**
643
688
 
644
689
  ```bash
645
690
  node generate-sdk.js --sol ".\\contracts\\A.sol,.\\contracts\\B.sol" --solc "c:\\solc\\solc.exe" --out ./out --non-interactive
691
+
692
+ # Pass additional solc args (example)
693
+ node generate-sdk.js --sol ".\\contracts\\A.sol" --solc "c:\\solc\\solc.exe" --solc-args "--via-ir --evm-version london" --out ./out --non-interactive
646
694
  ```
647
695
 
648
696
  3) **Artifacts JSON (multi-contract ABI+BIN list)**
@@ -656,16 +704,22 @@ Example `artifacts.json`:
656
704
  ```json
657
705
  [
658
706
  { "abi": "./Alpha.abi.json", "bin": "./Alpha.bin" },
659
- { "abi": "./Beta.abi.json", "bin": "./Beta.bin", "name": "Beta" }
707
+ { "abi": "./Beta.abi.json", "bin": "./Beta.bin", "name": "Beta" },
708
+ {
709
+ "name": "Gamma",
710
+ "abi": "[{\"type\":\"function\",\"name\":\"set\",\"stateMutability\":\"nonpayable\",\"inputs\":[{\"name\":\"value\",\"type\":\"uint256\"}],\"outputs\":[]}]",
711
+ "bin": "0x6000600055..."
712
+ }
660
713
  ]
661
714
  ```
662
715
 
663
716
  ### Package scaffolding mode
664
717
 
665
- Use `--create-package` to create a full npm package (source, tests, examples, README build scripts).
718
+ Use `--create-package` to create a full npm package (source, tests, examples, README).
666
719
 
667
720
  ```bash
668
721
  node generate-sdk.js --artifacts-json .\\artifacts.json ^
722
+ --lang ts ^
669
723
  --create-package --package-dir .\\tmp --package-name my-typed-package ^
670
724
  --package-description "My typed package" --package-author "me" ^
671
725
  --package-license MIT --package-version 0.0.1 ^
@@ -676,11 +730,13 @@ node generate-sdk.js --artifacts-json .\\artifacts.json ^
676
730
 
677
731
  When `--create-package` is used, the generator produces:
678
732
 
679
- - `src/` typed contract wrappers + factories + `types.ts`
733
+ - `src/` contract wrappers + factories
734
+ - TS mode: `*.ts` (compiled output in `dist/` after `npm run build:ts`)
735
+ - JS mode: `*.js` with `*.d.ts` types (no build step required)
680
736
  - `test/e2e/*.e2e.test.js` per-contract transactional tests
681
737
  - `examples/` deploy/read/write/events scripts
682
- - `index.js` (JSDoc source for `jsdoc-to-markdown`)
683
- - `README.md`, `index.d.ts` produced by `npm run build*`
738
+ - `README.md` generated by the generator (includes ABI-derived API overview)
739
+ - `index.js` + `index.d.ts` (package entry shims)
684
740
 
685
741
  ### Running generated transactional tests
686
742
 
package/README.md CHANGED
@@ -84,6 +84,9 @@ This repo includes a generator described in `SPEC.md` section 15.
84
84
  # Non-interactive
85
85
  node generate-sdk.js --abi path/to/abi.json --bin path/to/bytecode.bin --out ./generated --name MyContract --non-interactive
86
86
 
87
+ # JavaScript output (with TypeScript `.d.ts` types)
88
+ node generate-sdk.js --lang js --abi path/to/abi.json --bin path/to/bytecode.bin --out ./generated --name MyContract --non-interactive
89
+
87
90
  # Interactive
88
91
  node generate-sdk.js --abi path/to/abi.json --bin path/to/bytecode.bin
89
92
  ```
@@ -92,6 +95,28 @@ If installed as a package, you can also run:
92
95
 
93
96
  `npx quantumcoin-sdk-generator --abi ... --bin ...`
94
97
 
98
+ ### Generator typing model
99
+
100
+ - **Hard types**: generated wrappers use concrete types from `quantumcoin/types` (e.g. `Uint256Like` for inputs, `Uint256` for outputs).
101
+ - **Single return values are unwrapped**: a Solidity function returning one value returns that value directly (not `[value]`).
102
+ - **Multiple returns**: returned as a tuple type (e.g. `Promise<[Uint256, Bool]>`).
103
+ - **No returns**: `Promise<void>`.
104
+ - **Structs / tuples**: generated as `export type <Name>Input` / `export type <Name>Output` and used directly in method signatures.
105
+
106
+ ## Solidity types (TypeScript)
107
+
108
+ QuantumCoin.js exports core Solidity-related typings from:
109
+
110
+ - `quantumcoin/types`
111
+
112
+ Common types:
113
+
114
+ - `AddressLike` (currently `string`, 32-byte address)
115
+ - `BytesLike` (`string | Uint8Array`)
116
+ - `BigNumberish` (`string | number | bigint`)
117
+ - **Hard Solidity aliases** (preferred for typed wrappers): `Uint256Like` / `Uint256`, `Int256Like` / `Int256`, `Bytes32Like` / `Bytes32`, and all widths `Uint8Like`…`Uint256Like`, `Int8Like`…`Int256Like`, plus `Bytes1Like`…`Bytes32Like`
118
+ - `SolidityTypeName`, `SolidityInputValue<T>`, `SolidityOutputValue<T>` (advanced type-level mapping helpers; the generator no longer uses these for wrapper signatures)
119
+
95
120
  ## Examples
96
121
 
97
122
  ```bash