@cheny56/node-client 1.0.4 → 1.0.5

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/README.md CHANGED
@@ -10,6 +10,7 @@ A comprehensive JavaScript/TypeScript client library for interacting with Quorum
10
10
  - ✅ **Multiple Transaction Types**: Legacy (Type 0), AccessList (Type 1), DynamicFee (Type 2)
11
11
  - ✅ **Token Support**: ERC20 token transfers with PQC and Hybrid signatures
12
12
  - ✅ **Ethers.js Compatible**: Built on top of ethers.js for familiar API
13
+ - ✅ **TypeScript Support**: Full TypeScript definitions included
13
14
 
14
15
  ## Installation
15
16
 
@@ -19,7 +20,7 @@ npm install @cheny56/node-client
19
20
 
20
21
  ## Quick Start
21
22
 
22
- ### Basic Setup
23
+ ### JavaScript (ES Modules)
23
24
 
24
25
  ```javascript
25
26
  import { QuorumProvider, ECDSAWallet, PQCWallet, HybridWallet } from '@cheny56/node-client';
@@ -33,6 +34,20 @@ const pqcWallet = new PQCWallet(); // Generates new key pair
33
34
  const hybridWallet = new HybridWallet(ecdsaWallet, pqcWallet);
34
35
  ```
35
36
 
37
+ ### TypeScript
38
+
39
+ ```typescript
40
+ import { QuorumProvider, ECDSAWallet, PQCWallet, HybridWallet } from '@cheny56/node-client';
41
+
42
+ // Connect to Quorum node
43
+ const provider: QuorumProvider = new QuorumProvider('http://localhost:8545');
44
+
45
+ // Create wallets
46
+ const ecdsaWallet: ECDSAWallet = new ECDSAWallet('0x...', provider);
47
+ const pqcWallet: PQCWallet = new PQCWallet(); // Generates new key pair
48
+ const hybridWallet: HybridWallet = new HybridWallet(ecdsaWallet, pqcWallet);
49
+ ```
50
+
36
51
  ### Send Native Coin (ETH)
37
52
 
38
53
  #### ECDSA Transaction
@@ -262,6 +277,16 @@ const token = new ERC20Token(address, provider, wallet);
262
277
  - `balanceOf(address)`: Get balance
263
278
  - `name()`, `symbol()`, `decimals()`, `totalSupply()`: Token info
264
279
 
280
+ ## TypeScript Support
281
+
282
+ This library includes full TypeScript definitions. When using TypeScript, you'll get:
283
+
284
+ - Full type checking and IntelliSense support
285
+ - Type definitions for all classes, methods, and properties
286
+ - Proper type inference for transaction parameters and return values
287
+
288
+ The library is designed to work seamlessly with both JavaScript and TypeScript projects. JavaScript is the primary target, but TypeScript users get full type safety.
289
+
265
290
  ## Examples
266
291
 
267
292
  See the `examples/` directory for more comprehensive examples:
@@ -278,7 +303,7 @@ See the `examples/` directory for more comprehensive examples:
278
303
  ## Dependencies
279
304
 
280
305
  - `ethers`: ^5.7.2
281
- - `@noble/post-quantum`: ^1.0.0
306
+ - `@noble/post-quantum`: ^0.5.4
282
307
 
283
308
  ## License
284
309
 
package/package.json CHANGED
@@ -1,9 +1,20 @@
1
1
  {
2
2
  "name": "@cheny56/node-client",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Client library for Quorum blockchain with Post-Quantum Cryptography (PQC) and Zero-Knowledge Proof (ZK) support",
5
5
  "main": "src/index.js",
6
+ "types": "src/index.d.ts",
6
7
  "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./src/index.js",
11
+ "types": "./src/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "src/**/*.js",
16
+ "src/**/*.d.ts"
17
+ ],
7
18
  "scripts": {
8
19
  "test": "echo \"Error: no test specified\" && exit 1"
9
20
  },
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Transaction Type Constants
3
+ */
4
+ export declare const TX_TYPE: {
5
+ readonly LEGACY: 0;
6
+ readonly ACCESS_LIST: 1;
7
+ readonly DYNAMIC_FEE: 2;
8
+ readonly ZK_PRIVATE: 4;
9
+ };
10
+
11
+ /**
12
+ * PQC Signature Type Constants
13
+ */
14
+ export declare const PQC_TYPE: {
15
+ readonly NONE: 0;
16
+ readonly DILITHIUM: 1;
17
+ };
18
+
19
+ /**
20
+ * ZK Proof System Constants
21
+ */
22
+ export declare const ZK_PROOF_SYSTEM: {
23
+ readonly GROTH16: 1;
24
+ readonly PLONK: 2;
25
+ readonly STARK: 3;
26
+ };
27
+
28
+ /**
29
+ * Default Chain ID for Quorum
30
+ */
31
+ export declare const DEFAULT_CHAIN_ID: 1337;
@@ -0,0 +1,63 @@
1
+ import { ethers } from 'ethers';
2
+ import { QuorumProvider } from './provider.js';
3
+ import { ECDSAWallet, PQCWallet, HybridWallet } from './wallet.js';
4
+
5
+ export declare class Contract {
6
+ address: string;
7
+ abi: any[];
8
+ provider: QuorumProvider;
9
+ wallet: ECDSAWallet | PQCWallet | HybridWallet | null;
10
+ contract: ethers.Contract;
11
+
12
+ constructor(
13
+ address: string,
14
+ abi: any[],
15
+ provider: QuorumProvider,
16
+ wallet?: ECDSAWallet | PQCWallet | HybridWallet | null
17
+ );
18
+
19
+ connect(wallet: ECDSAWallet | PQCWallet | HybridWallet): Contract;
20
+ encodeFunctionData(functionName: string, params?: any[]): string;
21
+ decodeFunctionResult(functionName: string, data: string): any[];
22
+ call(functionName: string, ...params: any[]): Promise<any>;
23
+ sendTransaction(
24
+ functionName: string,
25
+ params?: any[],
26
+ txOptions?: any
27
+ ): Promise<ethers.ContractTransaction>;
28
+ }
29
+
30
+ export interface TokenTransferOptions {
31
+ chainId?: number;
32
+ gasPrice?: bigint;
33
+ gasLimit?: bigint;
34
+ }
35
+
36
+ export declare class ERC20Token extends Contract {
37
+ constructor(
38
+ address: string,
39
+ provider: QuorumProvider,
40
+ wallet?: ECDSAWallet | PQCWallet | HybridWallet | null
41
+ );
42
+
43
+ name(): Promise<string>;
44
+ symbol(): Promise<string>;
45
+ decimals(): Promise<number>;
46
+ totalSupply(): Promise<ethers.BigNumber>;
47
+ balanceOf(address: string): Promise<ethers.BigNumber>;
48
+ transfer(to: string, amount: string | ethers.BigNumber, txOptions?: any): Promise<ethers.ContractTransaction>;
49
+ transferPQC(
50
+ wallet: PQCWallet,
51
+ provider: QuorumProvider,
52
+ to: string,
53
+ amount: string | ethers.BigNumber,
54
+ txOptions?: TokenTransferOptions
55
+ ): Promise<string>;
56
+ transferHybrid(
57
+ wallet: HybridWallet,
58
+ provider: QuorumProvider,
59
+ to: string,
60
+ amount: string | ethers.BigNumber,
61
+ txOptions?: TokenTransferOptions
62
+ ): Promise<string>;
63
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ // Providers
2
+ export { QuorumProvider } from './provider.js';
3
+
4
+ // Wallets
5
+ export { ECDSAWallet, PQCWallet, HybridWallet } from './wallet.js';
6
+
7
+ // Transactions
8
+ export {
9
+ LegacyTransaction,
10
+ PQCLegacyTransaction,
11
+ HybridLegacyTransaction,
12
+ AccessListTransaction,
13
+ PQCAccessListTransaction,
14
+ DynamicFeeTransaction,
15
+ PQCDynamicFeeTransaction,
16
+ } from './transaction.js';
17
+
18
+ // ZK Transactions
19
+ export { ZKTransaction } from './zk-transaction.js';
20
+
21
+ // Contracts
22
+ export { Contract, ERC20Token } from './contract.js';
23
+
24
+ // Constants
25
+ export { TX_TYPE, PQC_TYPE, ZK_PROOF_SYSTEM, DEFAULT_CHAIN_ID } from './constants.js';
26
+
27
+ // Utilities
28
+ export { derivePQCAddress, deriveHybridAddress, isValidAddress } from './utils/address.js';
29
+ export { encodeUint64, encodeBigInt, encodeSignature } from './utils/rlp.js';
30
+
31
+ // Re-export ethers utilities for convenience
32
+ export { ethers } from 'ethers';
@@ -0,0 +1,52 @@
1
+ import { ethers } from 'ethers';
2
+
3
+ export declare class QuorumProvider extends ethers.providers.JsonRpcProvider {
4
+ url: string;
5
+
6
+ constructor(url: string, network?: ethers.providers.Networkish);
7
+
8
+ /**
9
+ * Send a raw transaction (for PQC/Hybrid transactions)
10
+ */
11
+ sendRawTransaction(signedTx: string): Promise<string>;
12
+
13
+ /**
14
+ * Get transaction receipt
15
+ */
16
+ getTransactionReceipt(txHash: string): Promise<ethers.providers.TransactionReceipt>;
17
+
18
+ /**
19
+ * Wait for transaction to be mined
20
+ */
21
+ waitForTransaction(txHash: string, confirmations?: number): Promise<ethers.providers.TransactionReceipt>;
22
+
23
+ /**
24
+ * Get transaction count (nonce) for an address
25
+ */
26
+ getTransactionCount(address: string, blockTag?: ethers.providers.BlockTag): Promise<number>;
27
+
28
+ /**
29
+ * Get balance for an address
30
+ */
31
+ getBalance(address: string, blockTag?: ethers.providers.BlockTag): Promise<ethers.BigNumber>;
32
+
33
+ /**
34
+ * Estimate gas for a transaction
35
+ */
36
+ estimateGas(transaction: ethers.providers.TransactionRequest): Promise<ethers.BigNumber>;
37
+
38
+ /**
39
+ * Get gas price
40
+ */
41
+ getGasPrice(): Promise<ethers.BigNumber>;
42
+
43
+ /**
44
+ * Get current block number
45
+ */
46
+ getBlockNumber(): Promise<number>;
47
+
48
+ /**
49
+ * Get block by number
50
+ */
51
+ getBlock(blockNumber: number | string): Promise<ethers.providers.Block>;
52
+ }
@@ -0,0 +1,161 @@
1
+ import { ECDSAWallet, PQCWallet } from './wallet.js';
2
+
3
+ export interface TransactionParams {
4
+ chainId?: number;
5
+ nonce?: number;
6
+ to?: string | null;
7
+ value?: bigint;
8
+ data?: string;
9
+ gasPrice?: bigint;
10
+ gasLimit?: bigint;
11
+ maxPriorityFeePerGas?: bigint;
12
+ maxFeePerGas?: bigint;
13
+ accessList?: any[];
14
+ }
15
+
16
+ export declare class LegacyTransaction {
17
+ type: number;
18
+ chainId: number;
19
+ nonce: number;
20
+ gasPrice: bigint;
21
+ gasLimit: bigint;
22
+ to?: string | null;
23
+ value: bigint;
24
+ data: string;
25
+
26
+ constructor(params: TransactionParams);
27
+ sign(wallet: ECDSAWallet): Promise<string>;
28
+ getHex(wallet: ECDSAWallet): Promise<string>;
29
+ }
30
+
31
+ export declare class PQCLegacyTransaction {
32
+ type: number;
33
+ chainId: number;
34
+ nonce: number;
35
+ gasPrice: bigint;
36
+ gasLimit: bigint;
37
+ to?: string | null;
38
+ value: bigint;
39
+ data: string;
40
+ pqcType: number;
41
+ pqcPubKey: Uint8Array | null;
42
+ pqcSig: Uint8Array | null;
43
+ v: number;
44
+ r: string;
45
+ s: string;
46
+
47
+ constructor(params: TransactionParams);
48
+ getSigningHash(): string;
49
+ sign(wallet: PQCWallet): PQCLegacyTransaction;
50
+ verify(): boolean;
51
+ serialize(): Uint8Array;
52
+ getHex(): string;
53
+ }
54
+
55
+ export declare class HybridLegacyTransaction {
56
+ type: number;
57
+ chainId: number;
58
+ nonce: number;
59
+ gasPrice: bigint;
60
+ gasLimit: bigint;
61
+ to?: string | null;
62
+ value: bigint;
63
+ data: string;
64
+ pqcType: number;
65
+ pqcPubKey: Uint8Array | null;
66
+ pqcSig: Uint8Array | null;
67
+ v: number | null;
68
+ r: string | null;
69
+ s: string | null;
70
+
71
+ constructor(params: TransactionParams);
72
+ getSigningHash(): string;
73
+ sign(ecdsaWallet: ECDSAWallet, pqcWallet: PQCWallet): HybridLegacyTransaction;
74
+ verify(): boolean;
75
+ serialize(): Uint8Array;
76
+ getHex(): string;
77
+ }
78
+
79
+ export declare class AccessListTransaction {
80
+ type: number;
81
+ chainId: number;
82
+ nonce: number;
83
+ gasPrice: bigint;
84
+ gasLimit: bigint;
85
+ to?: string | null;
86
+ value: bigint;
87
+ data: string;
88
+ accessList: any[];
89
+
90
+ constructor(params: TransactionParams & { accessList?: any[] });
91
+ sign(wallet: ECDSAWallet): Promise<string>;
92
+ getHex(wallet: ECDSAWallet): Promise<string>;
93
+ }
94
+
95
+ export declare class PQCAccessListTransaction {
96
+ type: number;
97
+ chainId: number;
98
+ nonce: number;
99
+ gasPrice: bigint;
100
+ gasLimit: bigint;
101
+ to?: string | null;
102
+ value: bigint;
103
+ data: string;
104
+ accessList: any[];
105
+ pqcType: number;
106
+ pqcPubKey: Uint8Array | null;
107
+ pqcSig: Uint8Array | null;
108
+ v: number;
109
+ r: string;
110
+ s: string;
111
+
112
+ constructor(params: TransactionParams & { accessList?: any[] });
113
+ getSigningHash(): string;
114
+ sign(wallet: PQCWallet): PQCAccessListTransaction;
115
+ verify(): boolean;
116
+ serialize(): Uint8Array;
117
+ getHex(): string;
118
+ }
119
+
120
+ export declare class DynamicFeeTransaction {
121
+ type: number;
122
+ chainId: number;
123
+ nonce: number;
124
+ maxPriorityFeePerGas: bigint;
125
+ maxFeePerGas: bigint;
126
+ gasLimit: bigint;
127
+ to?: string | null;
128
+ value: bigint;
129
+ data: string;
130
+ accessList: any[];
131
+
132
+ constructor(params: TransactionParams & { accessList?: any[] });
133
+ sign(wallet: ECDSAWallet): Promise<string>;
134
+ getHex(wallet: ECDSAWallet): Promise<string>;
135
+ }
136
+
137
+ export declare class PQCDynamicFeeTransaction {
138
+ type: number;
139
+ chainId: number;
140
+ nonce: number;
141
+ maxPriorityFeePerGas: bigint;
142
+ maxFeePerGas: bigint;
143
+ gasLimit: bigint;
144
+ to?: string | null;
145
+ value: bigint;
146
+ data: string;
147
+ accessList: any[];
148
+ pqcType: number;
149
+ pqcPubKey: Uint8Array | null;
150
+ pqcSig: Uint8Array | null;
151
+ v: number;
152
+ r: string;
153
+ s: string;
154
+
155
+ constructor(params: TransactionParams & { accessList?: any[] });
156
+ getSigningHash(): string;
157
+ sign(wallet: PQCWallet): PQCDynamicFeeTransaction;
158
+ verify(): boolean;
159
+ serialize(): Uint8Array;
160
+ getHex(): string;
161
+ }
@@ -4,6 +4,7 @@
4
4
  */
5
5
 
6
6
  import { ethers } from 'ethers';
7
+ // @ts-ignore - @noble/post-quantum may not have TypeScript definitions
7
8
  import { ml_dsa65 } from '@noble/post-quantum/ml-dsa';
8
9
  import { TX_TYPE, PQC_TYPE, DEFAULT_CHAIN_ID } from './constants.js';
9
10
  import { encodeUint64, encodeBigInt, encodeSignature } from './utils/rlp.js';
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Derive PQC address from Dilithium public key
3
+ */
4
+ export declare function derivePQCAddress(publicKey: Uint8Array): string;
5
+
6
+ /**
7
+ * Derive Hybrid address from ECDSA and Dilithium public keys
8
+ */
9
+ export declare function deriveHybridAddress(ecdsaPublicKey: Uint8Array, dilithiumPublicKey: Uint8Array): string;
10
+
11
+ /**
12
+ * Validate Ethereum address format
13
+ */
14
+ export declare function isValidAddress(address: string): boolean;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Encode uint64 value for RLP as hex string
3
+ */
4
+ export declare function encodeUint64(value: number | bigint | null | undefined): string;
5
+
6
+ /**
7
+ * Encode *big.Int value for RLP as hex string
8
+ */
9
+ export declare function encodeBigInt(value: number | bigint | null | undefined): string;
10
+
11
+ /**
12
+ * Encode signature value (R, S) for RLP as hex string
13
+ */
14
+ export declare function encodeSignature(value: string | null | undefined): string;
@@ -0,0 +1,45 @@
1
+ import { QuorumProvider } from './provider.js';
2
+
3
+ export declare class ECDSAWallet {
4
+ wallet: any;
5
+ address: string;
6
+ privateKey: string;
7
+ provider: QuorumProvider | null;
8
+
9
+ constructor(privateKey: string, provider?: QuorumProvider | null);
10
+
11
+ connect(provider: QuorumProvider): ECDSAWallet;
12
+ getPublicKey(): string;
13
+ signMessage(message: string | Uint8Array): Promise<string>;
14
+ }
15
+
16
+ export declare class PQCWallet {
17
+ secretKey: Uint8Array;
18
+ publicKey: Uint8Array;
19
+ address: string;
20
+
21
+ constructor(secretKey?: Uint8Array | null, publicKey?: Uint8Array | null);
22
+
23
+ static fromSecretKey(secretKey: Uint8Array | string, publicKey: Uint8Array | string): PQCWallet;
24
+
25
+ sign(hash: Uint8Array): Uint8Array;
26
+ verify(hash: Uint8Array, signature: Uint8Array): boolean;
27
+ getPublicKeyHex(): string;
28
+ getSecretKeyHex(): string;
29
+ }
30
+
31
+ export declare class HybridWallet {
32
+ ecdsaWallet: ECDSAWallet;
33
+ pqcWallet: PQCWallet;
34
+ address: string;
35
+
36
+ constructor(ecdsaWallet: ECDSAWallet | string, pqcWallet: PQCWallet);
37
+
38
+ static fromKeys(
39
+ ecdsaPrivateKey: string,
40
+ pqcSecretKey: Uint8Array,
41
+ pqcPublicKey: Uint8Array
42
+ ): HybridWallet;
43
+
44
+ connect(provider: QuorumProvider): HybridWallet;
45
+ }
package/src/wallet.js CHANGED
@@ -4,6 +4,7 @@
4
4
  */
5
5
 
6
6
  import { ethers } from 'ethers';
7
+ // @ts-ignore - @noble/post-quantum may not have TypeScript definitions
7
8
  import { ml_dsa65 } from '@noble/post-quantum/ml-dsa';
8
9
  import { derivePQCAddress, deriveHybridAddress } from './utils/address.js';
9
10
 
@@ -0,0 +1,45 @@
1
+ import { QuorumProvider } from './provider.js';
2
+
3
+ export interface ZKTransactionParams {
4
+ chainId?: number;
5
+ nonce?: number;
6
+ to?: string | null;
7
+ value?: bigint;
8
+ data?: string;
9
+ gasPrice?: bigint;
10
+ gasLimit?: bigint;
11
+ accessList?: any[];
12
+ zkProofSystem?: number;
13
+ zkProof?: Uint8Array | string | null;
14
+ zkPublicInputs?: (Uint8Array | string)[];
15
+ zkVerificationKeyHash?: Uint8Array | string | null;
16
+ encryptedPayload?: Uint8Array | string | null;
17
+ recipients?: string[];
18
+ privateFrom?: string | null;
19
+ privateFor?: string[] | null;
20
+ }
21
+
22
+ export declare class ZKTransaction {
23
+ type: number;
24
+ chainId: number;
25
+ nonce: number;
26
+ gasPrice: bigint;
27
+ gasLimit: bigint;
28
+ to?: string | null;
29
+ value: bigint;
30
+ data: string;
31
+ accessList: any[];
32
+ zkProofSystem: number;
33
+ zkProof: Uint8Array | string | null;
34
+ zkPublicInputs: (Uint8Array | string)[];
35
+ zkVerificationKeyHash: Uint8Array | string | null;
36
+ encryptedPayload: Uint8Array | string | null;
37
+ recipients: string[];
38
+ privateFrom: string | null;
39
+ privateFor: string[] | null;
40
+
41
+ constructor(params: ZKTransactionParams);
42
+
43
+ toZKTxArgs(from: string): any;
44
+ send(provider: QuorumProvider, from: string): Promise<string>;
45
+ }