@r3e/neo-js-sdk 0.3.0

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 (42) hide show
  1. package/README.md +117 -0
  2. package/dist/constants.d.ts +25 -0
  3. package/dist/constants.js +34 -0
  4. package/dist/core/block.d.ts +65 -0
  5. package/dist/core/block.js +128 -0
  6. package/dist/core/hash.d.ts +20 -0
  7. package/dist/core/hash.js +51 -0
  8. package/dist/core/keypair.d.ts +24 -0
  9. package/dist/core/keypair.js +97 -0
  10. package/dist/core/opcode.d.ts +3 -0
  11. package/dist/core/opcode.js +2 -0
  12. package/dist/core/script.d.ts +25 -0
  13. package/dist/core/script.js +144 -0
  14. package/dist/core/serializing.d.ts +40 -0
  15. package/dist/core/serializing.js +175 -0
  16. package/dist/core/tx.d.ts +147 -0
  17. package/dist/core/tx.js +252 -0
  18. package/dist/core/witness-rule.d.ts +128 -0
  19. package/dist/core/witness-rule.js +201 -0
  20. package/dist/core/witness.d.ts +24 -0
  21. package/dist/core/witness.js +62 -0
  22. package/dist/index.d.ts +16 -0
  23. package/dist/index.js +15 -0
  24. package/dist/internal/bytes.d.ts +11 -0
  25. package/dist/internal/bytes.js +55 -0
  26. package/dist/internal/hex.d.ts +2 -0
  27. package/dist/internal/hex.js +10 -0
  28. package/dist/rpcclient/index.d.ts +166 -0
  29. package/dist/rpcclient/index.js +539 -0
  30. package/dist/rpcclient/parse.d.ts +16 -0
  31. package/dist/rpcclient/parse.js +48 -0
  32. package/dist/rpcclient/types.d.ts +640 -0
  33. package/dist/rpcclient/types.js +1 -0
  34. package/dist/utils.d.ts +20 -0
  35. package/dist/utils.js +40 -0
  36. package/dist/wallet/index.d.ts +2 -0
  37. package/dist/wallet/index.js +2 -0
  38. package/dist/wallet/nep2.d.ts +19 -0
  39. package/dist/wallet/nep2.js +96 -0
  40. package/dist/wallet/nep6.d.ts +136 -0
  41. package/dist/wallet/nep6.js +178 -0
  42. package/package.json +62 -0
@@ -0,0 +1,640 @@
1
+ import type { H160, H256 } from "../core/hash.js";
2
+ import type { PublicKey } from "../core/keypair.js";
3
+ import type { Signer, SignerJson, Tx, TxAttributeJson } from "../core/tx.js";
4
+ import type { WitnessRuleJson } from "../core/witness-rule.js";
5
+ export interface JsonRpcRequest {
6
+ jsonrpc: "2.0";
7
+ id: number;
8
+ method: string;
9
+ params: unknown[];
10
+ }
11
+ export interface JsonRpcErrorShape {
12
+ code: number;
13
+ message: string;
14
+ }
15
+ export interface JsonRpcSuccess<T = unknown> {
16
+ jsonrpc: "2.0";
17
+ id: number;
18
+ result: T;
19
+ }
20
+ export interface JsonRpcFailure {
21
+ jsonrpc: "2.0";
22
+ id: number;
23
+ error: JsonRpcErrorShape;
24
+ }
25
+ export type JsonRpcResponse<T = unknown> = JsonRpcSuccess<T> | JsonRpcFailure;
26
+ export type JsonRpcTransport = (url: string, request: JsonRpcRequest, timeoutMs: number) => Promise<JsonRpcResponse>;
27
+ export interface JsonRpcOptions {
28
+ timeoutMs?: number;
29
+ transport?: JsonRpcTransport;
30
+ endpointStrategy?: "first" | "round-robin";
31
+ retryTransportErrors?: boolean;
32
+ }
33
+ export interface RpcClientOptions extends JsonRpcOptions {
34
+ jsonrpc?: JsonRpcLike;
35
+ }
36
+ export interface JsonRpcLike {
37
+ send<T = unknown>(method: string, params?: unknown[]): Promise<T>;
38
+ }
39
+ export type BooleanLikeParam = 0 | 1 | boolean;
40
+ export interface InvokeParameterJson {
41
+ type: string;
42
+ value?: unknown;
43
+ }
44
+ export interface Base64Encodable {
45
+ toBase64(asLittleEndian?: boolean): string;
46
+ }
47
+ export interface ContractParamLikeJson {
48
+ toJSON?(): InvokeParameterJson;
49
+ toJson?(): InvokeParameterJson;
50
+ }
51
+ export interface InvokeParametersLike {
52
+ toJSON(): InvokeParameterJson[];
53
+ }
54
+ export type RpcBinaryPayload = Tx | Uint8Array | string | Base64Encodable;
55
+ export type RpcInvokeArgsInput = InvokeParametersLike | Array<InvokeParameterJson | ContractParamLikeJson | Record<string, unknown>>;
56
+ export type RpcSignerInput = Array<Signer | SignerJson | Record<string, unknown>>;
57
+ export interface GetBlockInput {
58
+ indexOrHash: number | string;
59
+ verbose?: BooleanLikeParam;
60
+ }
61
+ export interface GetBlockHashInput {
62
+ blockIndex: number;
63
+ }
64
+ export interface GetBlockHeaderInput {
65
+ indexOrHash?: number | string;
66
+ blockHash?: H256 | string | null;
67
+ height?: number | null;
68
+ verbose?: BooleanLikeParam;
69
+ }
70
+ export interface GetApplicationLogInput {
71
+ hash: H256 | string;
72
+ trigger?: string;
73
+ }
74
+ export interface GetContractStateInput {
75
+ scriptHash: H160 | string;
76
+ }
77
+ export interface GetNep11BalancesInput {
78
+ account: string;
79
+ }
80
+ export interface GetNep11PropertiesInput {
81
+ contractHash: H160 | string;
82
+ tokenId: string;
83
+ }
84
+ export interface GetNep11TransfersInput {
85
+ account: string;
86
+ startTime?: string;
87
+ endTime?: string;
88
+ }
89
+ export interface GetNep17TransfersInput {
90
+ account: string;
91
+ startTime?: string;
92
+ endTime?: string;
93
+ }
94
+ export interface GetNep17BalancesInput {
95
+ account: string;
96
+ }
97
+ export interface GetRawTransactionInput {
98
+ hash: H256 | string;
99
+ verbose?: BooleanLikeParam;
100
+ }
101
+ export interface GetStateRootInput {
102
+ index: number;
103
+ }
104
+ export interface GetProofInput {
105
+ rootHash: H256 | string;
106
+ contractHash: H160 | string;
107
+ key: Uint8Array | string;
108
+ }
109
+ export interface VerifyProofInput {
110
+ rootHash: H256 | string;
111
+ proof: Uint8Array | string;
112
+ }
113
+ export interface GetStateInput {
114
+ rootHash: H256 | string;
115
+ contractHash: H160 | string;
116
+ key: Uint8Array | string;
117
+ }
118
+ export interface GetStorageInput {
119
+ scriptHash: H160 | string;
120
+ key: Uint8Array | string;
121
+ }
122
+ export interface FindStorageInput {
123
+ scriptHash: H160 | string;
124
+ prefix: Uint8Array | string;
125
+ start?: number;
126
+ }
127
+ export interface FindStatesInput {
128
+ rootHash: H256 | string;
129
+ contractHash: H160 | string;
130
+ prefix: Uint8Array | string;
131
+ from?: Uint8Array | string;
132
+ count?: number;
133
+ }
134
+ export interface GetUnclaimedGasInput {
135
+ address: string;
136
+ }
137
+ export interface GetTransactionHeightInput {
138
+ hash: H256 | string;
139
+ }
140
+ export interface GetUnspentsInput {
141
+ address: string;
142
+ }
143
+ export interface OpenWalletInput {
144
+ path: string;
145
+ password: string;
146
+ }
147
+ export interface DumpPrivKeyInput {
148
+ address: string;
149
+ }
150
+ export interface GetWalletBalanceInput {
151
+ assetId: H160 | string;
152
+ }
153
+ export interface ImportPrivKeyInput {
154
+ wif: string;
155
+ }
156
+ export interface InvokeFunctionInput {
157
+ contractHash: H160 | string;
158
+ method: string;
159
+ args?: RpcInvokeArgsInput;
160
+ signers?: RpcSignerInput;
161
+ }
162
+ export interface InvokeContractVerifyInput {
163
+ contractHash: H160 | string;
164
+ args?: RpcInvokeArgsInput;
165
+ signers?: RpcSignerInput;
166
+ }
167
+ export interface InvokeScriptInput {
168
+ script: RpcBinaryPayload;
169
+ signers?: RpcSignerInput;
170
+ }
171
+ export interface TraverseIteratorInput {
172
+ sessionId: string;
173
+ iteratorId: string;
174
+ count: number;
175
+ }
176
+ export interface SendRawTransactionInput {
177
+ tx: RpcBinaryPayload;
178
+ }
179
+ export interface SendManyTransferInput {
180
+ asset: H160 | string;
181
+ value: bigint | number | string;
182
+ address: string;
183
+ }
184
+ export interface SendFromInput {
185
+ assetId: H160 | string;
186
+ from: string;
187
+ to: string;
188
+ amount: bigint | number | string;
189
+ signers?: Array<H160 | string>;
190
+ }
191
+ export interface SendManyInput {
192
+ transfers: SendManyTransferInput[];
193
+ from?: string;
194
+ signers?: Array<H160 | string>;
195
+ }
196
+ export interface SendToAddressInput {
197
+ assetId: H160 | string;
198
+ to: string;
199
+ amount: bigint | number | string;
200
+ }
201
+ export interface SubmitBlockInput {
202
+ block: RpcBinaryPayload;
203
+ }
204
+ export interface ValidateAddressInput {
205
+ address: string;
206
+ }
207
+ export interface CancelTransactionInput {
208
+ txHash: H256 | string;
209
+ signers?: Array<H160 | string>;
210
+ extraFee?: bigint | number | string;
211
+ }
212
+ export interface CalculateNetworkFeeInput {
213
+ tx: RpcBinaryPayload;
214
+ }
215
+ export type GetBlockHeaderCountResult = number;
216
+ export type GetConnectionCountResult = number;
217
+ export type TransactionJsonResult = ReturnType<Tx["toJSON"]>;
218
+ export interface RpcBaseStackItemJson {
219
+ type: string;
220
+ }
221
+ export interface RpcBooleanStackItemJson extends RpcBaseStackItemJson {
222
+ type: "Boolean";
223
+ value: boolean;
224
+ }
225
+ export interface RpcIntegerStackItemJson extends RpcBaseStackItemJson {
226
+ type: "Integer";
227
+ value: string;
228
+ }
229
+ export interface RpcByteStringStackItemJson extends RpcBaseStackItemJson {
230
+ type: "ByteString";
231
+ value: string;
232
+ }
233
+ export interface RpcBufferStackItemJson extends RpcBaseStackItemJson {
234
+ type: "Buffer";
235
+ value: string;
236
+ }
237
+ export interface RpcPointerStackItemJson extends RpcBaseStackItemJson {
238
+ type: "Pointer";
239
+ value: number;
240
+ }
241
+ export interface RpcAnyStackItemJson extends RpcBaseStackItemJson {
242
+ type: "Any";
243
+ value?: string;
244
+ }
245
+ export interface RpcInteropInterfaceStackItemJson extends RpcBaseStackItemJson {
246
+ type: "InteropInterface";
247
+ interface?: string;
248
+ id?: string;
249
+ }
250
+ export interface RpcArrayStackItemJson extends RpcBaseStackItemJson {
251
+ type: "Array";
252
+ value: RpcStackItemJson[];
253
+ }
254
+ export interface RpcStructStackItemJson extends RpcBaseStackItemJson {
255
+ type: "Struct";
256
+ value: RpcStackItemJson[];
257
+ }
258
+ export interface RpcMapStackEntryJson {
259
+ key: RpcStackItemJson;
260
+ value: RpcStackItemJson;
261
+ }
262
+ export interface RpcMapStackItemJson extends RpcBaseStackItemJson {
263
+ type: "Map";
264
+ value: RpcMapStackEntryJson[];
265
+ }
266
+ export type RpcStackItemJson = RpcBooleanStackItemJson | RpcIntegerStackItemJson | RpcByteStringStackItemJson | RpcBufferStackItemJson | RpcPointerStackItemJson | RpcAnyStackItemJson | RpcInteropInterfaceStackItemJson | RpcArrayStackItemJson | RpcStructStackItemJson | RpcMapStackItemJson;
267
+ export interface RpcNotification {
268
+ contract: string;
269
+ eventname: string;
270
+ state: RpcStackItemJson;
271
+ }
272
+ export interface ApplicationLogInvocation {
273
+ hash: string;
274
+ method: string;
275
+ arguments: {
276
+ type: "Array";
277
+ value: RpcStackItemJson[];
278
+ };
279
+ argumentscount: number;
280
+ truncated: boolean;
281
+ }
282
+ export interface ApplicationLogExecution {
283
+ trigger: string;
284
+ vmstate: string;
285
+ gasconsumed: string;
286
+ stack?: RpcStackItemJson[];
287
+ notifications: RpcNotification[];
288
+ exception?: string | null;
289
+ invocations?: ApplicationLogInvocation[];
290
+ }
291
+ export interface GetApplicationLogResult {
292
+ txid?: string;
293
+ blockhash?: string;
294
+ executions: ApplicationLogExecution[];
295
+ }
296
+ export interface GetBlockHeaderVerboseResult {
297
+ hash: string;
298
+ size: number;
299
+ version: number;
300
+ previousblockhash: string;
301
+ merkleroot: string;
302
+ time: number;
303
+ nonce: string;
304
+ index: number;
305
+ primary: number;
306
+ nextconsensus: string;
307
+ witnesses: RpcWitnessJson[];
308
+ confirmations: number;
309
+ nextblockhash?: string;
310
+ }
311
+ export interface GetBlockVerboseResult extends GetBlockHeaderVerboseResult {
312
+ tx: TransactionJsonResult[];
313
+ }
314
+ export interface GetContractStateNefMethodTokenResult {
315
+ hash: string;
316
+ method: string;
317
+ parameterscount: number;
318
+ hasreturnvalue: boolean;
319
+ callflags: string;
320
+ }
321
+ export interface GetContractStateNefResult {
322
+ magic?: number;
323
+ compiler: string;
324
+ source: string;
325
+ tokens: GetContractStateNefMethodTokenResult[];
326
+ script: string;
327
+ checksum: number;
328
+ }
329
+ export interface GetContractStateManifestParameterResult {
330
+ name: string;
331
+ type: string;
332
+ }
333
+ export interface GetContractStateManifestMethodResult {
334
+ name: string;
335
+ offset: number;
336
+ parameters: GetContractStateManifestParameterResult[];
337
+ returntype: string;
338
+ safe: boolean;
339
+ }
340
+ export interface GetContractStateManifestEventResult {
341
+ name: string;
342
+ parameters: GetContractStateManifestParameterResult[];
343
+ }
344
+ export interface GetContractStateManifestAbiResult {
345
+ methods: GetContractStateManifestMethodResult[];
346
+ events: GetContractStateManifestEventResult[];
347
+ }
348
+ export interface GetContractStateManifestGroupResult {
349
+ pubkey: string;
350
+ signature: string;
351
+ }
352
+ export interface GetContractStateManifestPermissionResult {
353
+ contract: string;
354
+ methods: "*" | string[];
355
+ }
356
+ export interface GetContractStateManifestResult {
357
+ name: string;
358
+ groups: GetContractStateManifestGroupResult[];
359
+ features: Record<string, never>;
360
+ supportedstandards: string[];
361
+ abi: GetContractStateManifestAbiResult;
362
+ permissions: GetContractStateManifestPermissionResult[];
363
+ trusts: "*" | string[];
364
+ extra?: unknown;
365
+ }
366
+ export interface GetContractStateResult {
367
+ id: number;
368
+ updatecounter: number;
369
+ hash: string;
370
+ nef: GetContractStateNefResult;
371
+ manifest: GetContractStateManifestResult;
372
+ }
373
+ export type GetNativeContractsResult = GetContractStateResult[];
374
+ export interface Nep11TokenBalance {
375
+ id: string;
376
+ amount: string;
377
+ lastupdatedblock: number;
378
+ }
379
+ export interface Nep11Balance {
380
+ assethash: string;
381
+ name: string;
382
+ symbol: string;
383
+ decimals: string;
384
+ tokens: Nep11TokenBalance[];
385
+ }
386
+ export interface GetNep11BalancesResult {
387
+ address: string;
388
+ balance: Nep11Balance[];
389
+ }
390
+ export type GetNep11PropertyValueResult = string | null;
391
+ export type GetNep11PropertiesResult = Record<string, GetNep11PropertyValueResult>;
392
+ export interface Nep11TransferEvent {
393
+ timestamp: number;
394
+ assethash: string;
395
+ transferaddress: string;
396
+ amount: string;
397
+ blockindex: number;
398
+ transfernotifyindex: number;
399
+ txhash: string;
400
+ tokenid: string;
401
+ }
402
+ export interface GetNep11TransfersResult {
403
+ sent: Nep11TransferEvent[];
404
+ received: Nep11TransferEvent[];
405
+ address: string;
406
+ }
407
+ export interface Nep17Balance {
408
+ assethash: string;
409
+ amount: string;
410
+ lastupdatedblock: number;
411
+ }
412
+ export interface GetNep17BalancesResult {
413
+ address: string;
414
+ balance: Nep17Balance[];
415
+ }
416
+ export interface Nep17TransferEvent {
417
+ timestamp: number;
418
+ assethash: string;
419
+ transferaddress: string;
420
+ amount: string;
421
+ blockindex: number;
422
+ transfernotifyindex: number;
423
+ txhash: string;
424
+ }
425
+ export interface GetNep17TransfersResult {
426
+ sent: Nep17TransferEvent[];
427
+ received: Nep17TransferEvent[];
428
+ address: string;
429
+ }
430
+ export interface RpcValidatorResult {
431
+ publickey: string;
432
+ votes: string;
433
+ active: boolean;
434
+ }
435
+ export type GetCandidatesResult = RpcValidatorResult[];
436
+ export interface NodePeer {
437
+ address: string;
438
+ port: number;
439
+ }
440
+ export interface GetPeersResult {
441
+ unconnected: NodePeer[];
442
+ bad: NodePeer[];
443
+ connected: NodePeer[];
444
+ }
445
+ export interface GetVersionProtocolResult {
446
+ addressversion: number;
447
+ network: number;
448
+ validatorscount: number;
449
+ msperblock: number;
450
+ maxtraceableblocks: number;
451
+ maxvaliduntilblockincrement: number;
452
+ maxtransactionsperblock: number;
453
+ memorypoolmaxtransactions: number;
454
+ initialgasdistribution: number;
455
+ hardforks?: GetVersionHardforkResult[];
456
+ committeehistory?: Record<string, number>;
457
+ }
458
+ export interface GetVersionHardforkResult {
459
+ name: string;
460
+ blockheight: number;
461
+ }
462
+ export interface GetVersionResult {
463
+ tcpport: number;
464
+ wsport: number;
465
+ nonce: number;
466
+ useragent: string;
467
+ protocol: GetVersionProtocolResult;
468
+ rpc?: GetVersionRpcSettingsResult;
469
+ }
470
+ export interface GetVersionRpcSettingsResult {
471
+ maxiteratorresultitems?: number;
472
+ sessionenabled?: boolean;
473
+ }
474
+ export interface RpcPlugin {
475
+ name: string;
476
+ version: string;
477
+ interfaces: string[];
478
+ }
479
+ export type ListPluginsResult = RpcPlugin[];
480
+ export interface ValidateAddressResult {
481
+ address: string;
482
+ isvalid: boolean;
483
+ }
484
+ export interface RpcWitnessJson {
485
+ invocation: string;
486
+ verification: string;
487
+ }
488
+ export interface GetStateRootResult {
489
+ version: number;
490
+ index: number;
491
+ roothash: string;
492
+ witnesses: RpcWitnessJson[];
493
+ }
494
+ export interface RpcSignerJson {
495
+ account: string;
496
+ scopes: string;
497
+ allowedcontracts?: string[];
498
+ allowedgroups?: string[];
499
+ rules?: WitnessRuleJson[];
500
+ }
501
+ export interface GetRawTransactionResult {
502
+ txid: string;
503
+ size: number;
504
+ version: number;
505
+ nonce: number;
506
+ sender: string;
507
+ sysfee: string;
508
+ netfee: string;
509
+ validuntilblock: number;
510
+ signers: RpcSignerJson[];
511
+ attributes: TxAttributeJson[];
512
+ script: string;
513
+ witnesses: RpcWitnessJson[];
514
+ blockhash?: string;
515
+ confirmations?: number;
516
+ blocktime?: number;
517
+ vmstate?: string;
518
+ }
519
+ export interface GetRawMemPoolVerboseResult {
520
+ height: number;
521
+ verified: string[];
522
+ unverified: string[];
523
+ }
524
+ export type GetRawMemPoolResult = string[] | GetRawMemPoolVerboseResult;
525
+ export interface GetStateHeightResult {
526
+ localrootindex: number;
527
+ validatedrootindex: number;
528
+ }
529
+ export type GetProofResult = string;
530
+ export type VerifyProofResult = string;
531
+ export type GetStateResult = string;
532
+ export type GetStorageResult = string;
533
+ export interface FindStorageEntry {
534
+ key: string;
535
+ value: string;
536
+ }
537
+ export interface FindStorageResult {
538
+ truncated: boolean;
539
+ next?: number;
540
+ results: FindStorageEntry[];
541
+ }
542
+ export interface FindStatesResult {
543
+ truncated: boolean;
544
+ results: Array<{
545
+ key: string;
546
+ value: string;
547
+ }>;
548
+ }
549
+ export interface GetUnclaimedGasResult {
550
+ unclaimed: string;
551
+ address: string;
552
+ }
553
+ export interface UnspentTransaction {
554
+ txid: string;
555
+ n: number;
556
+ value: string;
557
+ }
558
+ export interface UnspentBalance {
559
+ asset_hash: string;
560
+ asset: string;
561
+ amount: string;
562
+ unspent: UnspentTransaction[];
563
+ }
564
+ export interface GetUnspentsResult {
565
+ address: string;
566
+ balance: UnspentBalance[];
567
+ }
568
+ export interface InvokeResult<TStackItem = RpcStackItemJson> {
569
+ script: string;
570
+ state: string;
571
+ gasconsumed: string;
572
+ stack: TStackItem[];
573
+ exception?: string | null;
574
+ session?: string;
575
+ notifications?: RpcNotification[];
576
+ diagnostics?: InvokeDiagnosticsResult;
577
+ tx?: string;
578
+ pending_signature?: PendingSignatureResult;
579
+ }
580
+ export interface InvokeDiagnosticsInvocationTree {
581
+ current: RpcNotification;
582
+ calls?: InvokeDiagnosticsInvocationTree[];
583
+ }
584
+ export interface InvokeDiagnosticsStorageChange {
585
+ state: string;
586
+ key: string;
587
+ value?: string;
588
+ }
589
+ export interface InvokeDiagnosticsResult {
590
+ invocations?: InvokeDiagnosticsInvocationTree[];
591
+ storagechanges?: InvokeDiagnosticsStorageChange[];
592
+ }
593
+ export interface PendingSignatureContextItem {
594
+ account: string;
595
+ scopes: string;
596
+ allowedcontracts: string[];
597
+ allowedgroups: string[];
598
+ rules: WitnessRuleJson[];
599
+ signatures: string[];
600
+ }
601
+ export interface PendingSignatureResult {
602
+ type: string;
603
+ hex: string;
604
+ items: PendingSignatureContextItem[];
605
+ }
606
+ export type InvokeContractVerifyResult<TStackItem = RpcStackItemJson> = InvokeResult<TStackItem>;
607
+ export interface SendRawTransactionResult {
608
+ hash: string;
609
+ }
610
+ export interface WalletBalanceResult {
611
+ balance: string;
612
+ confirmed: string;
613
+ }
614
+ export type OpenWalletResult = boolean;
615
+ export type CloseWalletResult = boolean;
616
+ export type DumpPrivKeyResult = string;
617
+ export type GetNewAddressResult = string;
618
+ export type GetWalletUnclaimedGasResult = string;
619
+ export interface RpcAccountResult {
620
+ address: string;
621
+ haskey: boolean;
622
+ label?: string;
623
+ watchonly: boolean;
624
+ }
625
+ export type ListAddressResult = RpcAccountResult[];
626
+ export type ImportPrivKeyResult = RpcAccountResult;
627
+ export type TraverseIteratorResult = RpcStackItemJson[];
628
+ export type TerminateSessionResult = boolean;
629
+ export interface RelayTransactionResult {
630
+ hash: string;
631
+ }
632
+ export type CancelTransactionResult = RelayTransactionResult;
633
+ export type SubmitBlockResult = SendRawTransactionResult;
634
+ export interface NetworkFeeResult {
635
+ networkfee: string;
636
+ }
637
+ export interface SignerLikeJson {
638
+ toJSON(): unknown;
639
+ }
640
+ export type InvokeSerializable = InvokeParameterJson | ContractParamLikeJson | Signer | SignerJson | SignerLikeJson | H160 | H256 | PublicKey;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Reverse the byte order of a hex string
3
+ */
4
+ export declare function reverseHex(hex: string): string;
5
+ /**
6
+ * Convert UTF-8 string to hex string
7
+ */
8
+ export declare function str2hexstring(str: string): string;
9
+ /**
10
+ * Convert hex string to UTF-8 string
11
+ */
12
+ export declare function hexstring2str(hex: string): string;
13
+ /**
14
+ * Convert number to hex string
15
+ */
16
+ export declare function num2hexstring(num: number, size?: number, littleEndian?: boolean): string;
17
+ /**
18
+ * RIPEMD160(SHA256(data))
19
+ */
20
+ export declare function hash160(hex: string): string;
package/dist/utils.js ADDED
@@ -0,0 +1,40 @@
1
+ import { createHash } from "crypto";
2
+ import { bytesToHex, hexToBytes, reverseBytes, utf8ToBytes } from "./internal/bytes.js";
3
+ /**
4
+ * Reverse the byte order of a hex string
5
+ */
6
+ export function reverseHex(hex) {
7
+ return bytesToHex(reverseBytes(hexToBytes(hex)));
8
+ }
9
+ /**
10
+ * Convert UTF-8 string to hex string
11
+ */
12
+ export function str2hexstring(str) {
13
+ return bytesToHex(utf8ToBytes(str));
14
+ }
15
+ /**
16
+ * Convert hex string to UTF-8 string
17
+ */
18
+ export function hexstring2str(hex) {
19
+ return Buffer.from(hexToBytes(hex)).toString("utf8");
20
+ }
21
+ /**
22
+ * Convert number to hex string
23
+ */
24
+ export function num2hexstring(num, size = 2, littleEndian = false) {
25
+ let hex = num.toString(16);
26
+ hex = hex.length % 2 ? "0" + hex : hex;
27
+ hex = hex.padStart(size * 2, "0");
28
+ if (littleEndian) {
29
+ hex = reverseHex(hex);
30
+ }
31
+ return hex;
32
+ }
33
+ /**
34
+ * RIPEMD160(SHA256(data))
35
+ */
36
+ export function hash160(hex) {
37
+ const sha256 = createHash("sha256").update(hexToBytes(hex)).digest();
38
+ const ripemd160 = createHash("ripemd160").update(sha256).digest();
39
+ return bytesToHex(ripemd160);
40
+ }
@@ -0,0 +1,2 @@
1
+ export { ScryptParams, decryptSecp256r1Key, encryptSecp256r1Key } from "./nep2.js";
2
+ export { Account, Contract, Parameter, Wallet } from "./nep6.js";
@@ -0,0 +1,2 @@
1
+ export { ScryptParams, decryptSecp256r1Key, encryptSecp256r1Key } from "./nep2.js";
2
+ export { Account, Contract, Parameter, Wallet } from "./nep6.js";