near-kit 0.0.0 → 0.2.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 (132) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +473 -2
  3. package/dist/contracts/contract.d.ts +63 -0
  4. package/dist/contracts/contract.d.ts.map +1 -0
  5. package/dist/contracts/contract.js +42 -0
  6. package/dist/contracts/contract.js.map +1 -0
  7. package/dist/contracts/index.d.ts +5 -0
  8. package/dist/contracts/index.d.ts.map +1 -0
  9. package/dist/contracts/index.js +5 -0
  10. package/dist/contracts/index.js.map +1 -0
  11. package/dist/core/actions.d.ts +193 -0
  12. package/dist/core/actions.d.ts.map +1 -0
  13. package/dist/core/actions.js +195 -0
  14. package/dist/core/actions.js.map +1 -0
  15. package/dist/core/config-schemas.d.ts +179 -0
  16. package/dist/core/config-schemas.d.ts.map +1 -0
  17. package/dist/core/config-schemas.js +169 -0
  18. package/dist/core/config-schemas.js.map +1 -0
  19. package/dist/core/constants.d.ts +43 -0
  20. package/dist/core/constants.d.ts.map +1 -0
  21. package/dist/core/constants.js +49 -0
  22. package/dist/core/constants.js.map +1 -0
  23. package/dist/core/near.d.ts +301 -0
  24. package/dist/core/near.d.ts.map +1 -0
  25. package/dist/core/near.js +504 -0
  26. package/dist/core/near.js.map +1 -0
  27. package/dist/core/nonce-manager.d.ts +39 -0
  28. package/dist/core/nonce-manager.d.ts.map +1 -0
  29. package/dist/core/nonce-manager.js +73 -0
  30. package/dist/core/nonce-manager.js.map +1 -0
  31. package/dist/core/rpc/rpc-error-handler.d.ts +60 -0
  32. package/dist/core/rpc/rpc-error-handler.d.ts.map +1 -0
  33. package/dist/core/rpc/rpc-error-handler.js +324 -0
  34. package/dist/core/rpc/rpc-error-handler.js.map +1 -0
  35. package/dist/core/rpc/rpc-schemas.d.ts +1812 -0
  36. package/dist/core/rpc/rpc-schemas.d.ts.map +1 -0
  37. package/dist/core/rpc/rpc-schemas.js +424 -0
  38. package/dist/core/rpc/rpc-schemas.js.map +1 -0
  39. package/dist/core/rpc/rpc.d.ts +117 -0
  40. package/dist/core/rpc/rpc.d.ts.map +1 -0
  41. package/dist/core/rpc/rpc.js +325 -0
  42. package/dist/core/rpc/rpc.js.map +1 -0
  43. package/dist/core/schema.d.ts +1188 -0
  44. package/dist/core/schema.d.ts.map +1 -0
  45. package/dist/core/schema.js +396 -0
  46. package/dist/core/schema.js.map +1 -0
  47. package/dist/core/transaction.d.ts +390 -0
  48. package/dist/core/transaction.d.ts.map +1 -0
  49. package/dist/core/transaction.js +653 -0
  50. package/dist/core/transaction.js.map +1 -0
  51. package/dist/core/types.d.ts +271 -0
  52. package/dist/core/types.d.ts.map +1 -0
  53. package/dist/core/types.js +9 -0
  54. package/dist/core/types.js.map +1 -0
  55. package/dist/errors/index.d.ts +226 -0
  56. package/dist/errors/index.d.ts.map +1 -0
  57. package/dist/errors/index.js +366 -0
  58. package/dist/errors/index.js.map +1 -0
  59. package/dist/index.d.ts +16 -0
  60. package/dist/index.d.ts.map +1 -0
  61. package/dist/index.js +23 -0
  62. package/dist/index.js.map +1 -0
  63. package/dist/keys/credential-schemas.d.ts +98 -0
  64. package/dist/keys/credential-schemas.d.ts.map +1 -0
  65. package/dist/keys/credential-schemas.js +128 -0
  66. package/dist/keys/credential-schemas.js.map +1 -0
  67. package/dist/keys/file-keystore.d.ts +130 -0
  68. package/dist/keys/file-keystore.d.ts.map +1 -0
  69. package/dist/keys/file-keystore.js +266 -0
  70. package/dist/keys/file-keystore.js.map +1 -0
  71. package/dist/keys/in-memory-keystore.d.ts +71 -0
  72. package/dist/keys/in-memory-keystore.d.ts.map +1 -0
  73. package/dist/keys/in-memory-keystore.js +85 -0
  74. package/dist/keys/in-memory-keystore.js.map +1 -0
  75. package/dist/keys/index.d.ts +14 -0
  76. package/dist/keys/index.d.ts.map +1 -0
  77. package/dist/keys/index.js +20 -0
  78. package/dist/keys/index.js.map +1 -0
  79. package/dist/keys/native-keystore.d.ts +111 -0
  80. package/dist/keys/native-keystore.d.ts.map +1 -0
  81. package/dist/keys/native-keystore.js +167 -0
  82. package/dist/keys/native-keystore.js.map +1 -0
  83. package/dist/keys/rotating-keystore.d.ts +207 -0
  84. package/dist/keys/rotating-keystore.d.ts.map +1 -0
  85. package/dist/keys/rotating-keystore.js +240 -0
  86. package/dist/keys/rotating-keystore.js.map +1 -0
  87. package/dist/sandbox/index.d.ts +6 -0
  88. package/dist/sandbox/index.d.ts.map +1 -0
  89. package/dist/sandbox/index.js +5 -0
  90. package/dist/sandbox/index.js.map +1 -0
  91. package/dist/sandbox/sandbox.d.ts +55 -0
  92. package/dist/sandbox/sandbox.d.ts.map +1 -0
  93. package/dist/sandbox/sandbox.js +341 -0
  94. package/dist/sandbox/sandbox.js.map +1 -0
  95. package/dist/utils/amount.d.ts +76 -0
  96. package/dist/utils/amount.d.ts.map +1 -0
  97. package/dist/utils/amount.js +137 -0
  98. package/dist/utils/amount.js.map +1 -0
  99. package/dist/utils/gas.d.ts +69 -0
  100. package/dist/utils/gas.d.ts.map +1 -0
  101. package/dist/utils/gas.js +92 -0
  102. package/dist/utils/gas.js.map +1 -0
  103. package/dist/utils/index.d.ts +14 -0
  104. package/dist/utils/index.d.ts.map +1 -0
  105. package/dist/utils/index.js +14 -0
  106. package/dist/utils/index.js.map +1 -0
  107. package/dist/utils/key.d.ts +117 -0
  108. package/dist/utils/key.d.ts.map +1 -0
  109. package/dist/utils/key.js +270 -0
  110. package/dist/utils/key.js.map +1 -0
  111. package/dist/utils/nep413.d.ts +97 -0
  112. package/dist/utils/nep413.d.ts.map +1 -0
  113. package/dist/utils/nep413.js +154 -0
  114. package/dist/utils/nep413.js.map +1 -0
  115. package/dist/utils/validation.d.ts +114 -0
  116. package/dist/utils/validation.d.ts.map +1 -0
  117. package/dist/utils/validation.js +150 -0
  118. package/dist/utils/validation.js.map +1 -0
  119. package/dist/wallets/adapters.d.ts +119 -0
  120. package/dist/wallets/adapters.d.ts.map +1 -0
  121. package/dist/wallets/adapters.js +267 -0
  122. package/dist/wallets/adapters.js.map +1 -0
  123. package/dist/wallets/index.d.ts +11 -0
  124. package/dist/wallets/index.d.ts.map +1 -0
  125. package/dist/wallets/index.js +2 -0
  126. package/dist/wallets/index.js.map +1 -0
  127. package/dist/wallets/types.d.ts +99 -0
  128. package/dist/wallets/types.d.ts.map +1 -0
  129. package/dist/wallets/types.js +10 -0
  130. package/dist/wallets/types.js.map +1 -0
  131. package/package.json +78 -7
  132. package/index.js +0 -1
@@ -0,0 +1,1188 @@
1
+ /**
2
+ * Borsh serialization schemas for NEAR transactions using Zorsh
3
+ * Based on NEAR Protocol specification and near-api-js implementation
4
+ *
5
+ * This module handles the low-level binary serialization details and keeps
6
+ * all Zorsh-specific types internal. External code should only use the
7
+ * serializeTransaction and serializeSignedTransaction functions.
8
+ */
9
+ import { b } from "@zorsh/zorsh";
10
+ import type { DelegateAction, SignedDelegate } from "./actions.js";
11
+ import type { Ed25519PublicKey, Ed25519Signature, PublicKey, Secp256k1PublicKey, Secp256k1Signature, Signature, SignedTransaction, Transaction } from "./types.js";
12
+ /**
13
+ * Prefix for delegate actions (NEP-366 meta transactions)
14
+ * Value: 2^30 + 366 = 1073742190
15
+ *
16
+ * This prefix is prepended to DelegateAction when serializing for signing,
17
+ * ensuring delegate action signatures are always distinguishable from
18
+ * transaction signatures.
19
+ */
20
+ export declare const DELEGATE_ACTION_PREFIX = 1073742190;
21
+ /**
22
+ * PublicKey enum (0 = Ed25519, 1 = Secp256k1)
23
+ */
24
+ export declare const PublicKeySchema: import("@zorsh/zorsh").Schema<{
25
+ ed25519Key: {
26
+ data: number[];
27
+ };
28
+ } | {
29
+ secp256k1Key: {
30
+ data: number[];
31
+ };
32
+ }, string>;
33
+ /**
34
+ * Signature enum (0 = Ed25519, 1 = Secp256k1)
35
+ */
36
+ export declare const SignatureSchema: import("@zorsh/zorsh").Schema<{
37
+ ed25519Signature: {
38
+ data: number[];
39
+ };
40
+ } | {
41
+ secp256k1Signature: {
42
+ data: number[];
43
+ };
44
+ }, string>;
45
+ /**
46
+ * AccessKeyPermission enum (0 = FunctionCall, 1 = FullAccess)
47
+ */
48
+ declare const AccessKeyPermissionSchema: import("@zorsh/zorsh").Schema<{
49
+ functionCall: {
50
+ allowance: bigint | null;
51
+ receiverId: string;
52
+ methodNames: string[];
53
+ };
54
+ } | {
55
+ fullAccess: {};
56
+ }, string>;
57
+ /**
58
+ * AccessKeyPermission type inferred from schema
59
+ */
60
+ export type AccessKeyPermissionBorsh = b.infer<typeof AccessKeyPermissionSchema>;
61
+ /**
62
+ * CreateAccount action (empty struct)
63
+ */
64
+ declare const CreateAccountSchema: import("@zorsh/zorsh").Schema<{}, string>;
65
+ /**
66
+ * DeployContract action with WASM code
67
+ */
68
+ declare const DeployContractSchema: import("@zorsh/zorsh").Schema<{
69
+ code: Uint8Array<ArrayBufferLike>;
70
+ }, string>;
71
+ /**
72
+ * FunctionCall action
73
+ * Field order: methodName, args, gas, deposit
74
+ */
75
+ declare const FunctionCallSchema: import("@zorsh/zorsh").Schema<{
76
+ methodName: string;
77
+ args: Uint8Array<ArrayBufferLike>;
78
+ gas: bigint;
79
+ deposit: bigint;
80
+ }, string>;
81
+ /**
82
+ * Transfer action with deposit amount
83
+ */
84
+ declare const TransferSchema: import("@zorsh/zorsh").Schema<{
85
+ deposit: bigint;
86
+ }, string>;
87
+ /**
88
+ * Stake action with amount and validator public key
89
+ */
90
+ declare const StakeSchema: import("@zorsh/zorsh").Schema<{
91
+ stake: bigint;
92
+ publicKey: {
93
+ ed25519Key: {
94
+ data: number[];
95
+ };
96
+ } | {
97
+ secp256k1Key: {
98
+ data: number[];
99
+ };
100
+ };
101
+ }, string>;
102
+ /**
103
+ * AddKey action to add a new access key
104
+ */
105
+ declare const AddKeySchema: import("@zorsh/zorsh").Schema<{
106
+ publicKey: {
107
+ ed25519Key: {
108
+ data: number[];
109
+ };
110
+ } | {
111
+ secp256k1Key: {
112
+ data: number[];
113
+ };
114
+ };
115
+ accessKey: {
116
+ nonce: bigint;
117
+ permission: {
118
+ functionCall: {
119
+ allowance: bigint | null;
120
+ receiverId: string;
121
+ methodNames: string[];
122
+ };
123
+ } | {
124
+ fullAccess: {};
125
+ };
126
+ };
127
+ }, string>;
128
+ /**
129
+ * DeleteKey action to remove an access key
130
+ */
131
+ declare const DeleteKeySchema: import("@zorsh/zorsh").Schema<{
132
+ publicKey: {
133
+ ed25519Key: {
134
+ data: number[];
135
+ };
136
+ } | {
137
+ secp256k1Key: {
138
+ data: number[];
139
+ };
140
+ };
141
+ }, string>;
142
+ /**
143
+ * DeleteAccount action with beneficiary
144
+ */
145
+ declare const DeleteAccountSchema: import("@zorsh/zorsh").Schema<{
146
+ beneficiaryId: string;
147
+ }, string>;
148
+ /**
149
+ * DeployGlobalContract action
150
+ */
151
+ declare const DeployGlobalContractSchema: import("@zorsh/zorsh").Schema<{
152
+ code: Uint8Array<ArrayBufferLike>;
153
+ deployMode: {
154
+ CodeHash: {};
155
+ } | {
156
+ AccountId: {};
157
+ };
158
+ }, string>;
159
+ /**
160
+ * UseGlobalContract action
161
+ */
162
+ declare const UseGlobalContractSchema: import("@zorsh/zorsh").Schema<{
163
+ contractIdentifier: {
164
+ CodeHash: number[];
165
+ } | {
166
+ AccountId: string;
167
+ };
168
+ }, string>;
169
+ /**
170
+ * ClassicActions enum - same as Action but without SignedDelegate
171
+ * Used within DelegateAction to prevent infinite recursion
172
+ * Note: The discriminant values must match the NEAR protocol spec
173
+ */
174
+ declare const ClassicActionsSchema: import("@zorsh/zorsh").Schema<{
175
+ stake: {
176
+ stake: bigint;
177
+ publicKey: {
178
+ ed25519Key: {
179
+ data: number[];
180
+ };
181
+ } | {
182
+ secp256k1Key: {
183
+ data: number[];
184
+ };
185
+ };
186
+ };
187
+ } | {
188
+ createAccount: {};
189
+ } | {
190
+ deployContract: {
191
+ code: Uint8Array<ArrayBufferLike>;
192
+ };
193
+ } | {
194
+ functionCall: {
195
+ methodName: string;
196
+ args: Uint8Array<ArrayBufferLike>;
197
+ gas: bigint;
198
+ deposit: bigint;
199
+ };
200
+ } | {
201
+ transfer: {
202
+ deposit: bigint;
203
+ };
204
+ } | {
205
+ addKey: {
206
+ publicKey: {
207
+ ed25519Key: {
208
+ data: number[];
209
+ };
210
+ } | {
211
+ secp256k1Key: {
212
+ data: number[];
213
+ };
214
+ };
215
+ accessKey: {
216
+ nonce: bigint;
217
+ permission: {
218
+ functionCall: {
219
+ allowance: bigint | null;
220
+ receiverId: string;
221
+ methodNames: string[];
222
+ };
223
+ } | {
224
+ fullAccess: {};
225
+ };
226
+ };
227
+ };
228
+ } | {
229
+ deleteKey: {
230
+ publicKey: {
231
+ ed25519Key: {
232
+ data: number[];
233
+ };
234
+ } | {
235
+ secp256k1Key: {
236
+ data: number[];
237
+ };
238
+ };
239
+ };
240
+ } | {
241
+ deleteAccount: {
242
+ beneficiaryId: string;
243
+ };
244
+ } | {
245
+ deployGlobalContract: {
246
+ code: Uint8Array<ArrayBufferLike>;
247
+ deployMode: {
248
+ CodeHash: {};
249
+ } | {
250
+ AccountId: {};
251
+ };
252
+ };
253
+ } | {
254
+ useGlobalContract: {
255
+ contractIdentifier: {
256
+ CodeHash: number[];
257
+ } | {
258
+ AccountId: string;
259
+ };
260
+ };
261
+ }, string>;
262
+ /**
263
+ * ClassicAction type - actions that can be used within a DelegateAction
264
+ * This excludes SignedDelegate to prevent infinite nesting
265
+ */
266
+ export type ClassicAction = b.infer<typeof ClassicActionsSchema>;
267
+ /**
268
+ * SignedDelegate - a delegate action with signature
269
+ */
270
+ declare const SignedDelegateSchema: import("@zorsh/zorsh").Schema<{
271
+ delegateAction: {
272
+ senderId: string;
273
+ receiverId: string;
274
+ actions: ({
275
+ stake: {
276
+ stake: bigint;
277
+ publicKey: {
278
+ ed25519Key: {
279
+ data: number[];
280
+ };
281
+ } | {
282
+ secp256k1Key: {
283
+ data: number[];
284
+ };
285
+ };
286
+ };
287
+ } | {
288
+ createAccount: {};
289
+ } | {
290
+ deployContract: {
291
+ code: Uint8Array<ArrayBufferLike>;
292
+ };
293
+ } | {
294
+ functionCall: {
295
+ methodName: string;
296
+ args: Uint8Array<ArrayBufferLike>;
297
+ gas: bigint;
298
+ deposit: bigint;
299
+ };
300
+ } | {
301
+ transfer: {
302
+ deposit: bigint;
303
+ };
304
+ } | {
305
+ addKey: {
306
+ publicKey: {
307
+ ed25519Key: {
308
+ data: number[];
309
+ };
310
+ } | {
311
+ secp256k1Key: {
312
+ data: number[];
313
+ };
314
+ };
315
+ accessKey: {
316
+ nonce: bigint;
317
+ permission: {
318
+ functionCall: {
319
+ allowance: bigint | null;
320
+ receiverId: string;
321
+ methodNames: string[];
322
+ };
323
+ } | {
324
+ fullAccess: {};
325
+ };
326
+ };
327
+ };
328
+ } | {
329
+ deleteKey: {
330
+ publicKey: {
331
+ ed25519Key: {
332
+ data: number[];
333
+ };
334
+ } | {
335
+ secp256k1Key: {
336
+ data: number[];
337
+ };
338
+ };
339
+ };
340
+ } | {
341
+ deleteAccount: {
342
+ beneficiaryId: string;
343
+ };
344
+ } | {
345
+ deployGlobalContract: {
346
+ code: Uint8Array<ArrayBufferLike>;
347
+ deployMode: {
348
+ CodeHash: {};
349
+ } | {
350
+ AccountId: {};
351
+ };
352
+ };
353
+ } | {
354
+ useGlobalContract: {
355
+ contractIdentifier: {
356
+ CodeHash: number[];
357
+ } | {
358
+ AccountId: string;
359
+ };
360
+ };
361
+ })[];
362
+ nonce: bigint;
363
+ maxBlockHeight: bigint;
364
+ publicKey: {
365
+ ed25519Key: {
366
+ data: number[];
367
+ };
368
+ } | {
369
+ secp256k1Key: {
370
+ data: number[];
371
+ };
372
+ };
373
+ };
374
+ signature: {
375
+ ed25519Signature: {
376
+ data: number[];
377
+ };
378
+ } | {
379
+ secp256k1Signature: {
380
+ data: number[];
381
+ };
382
+ };
383
+ }, string>;
384
+ /**
385
+ * Action enum matching NEAR protocol action discriminants
386
+ * Order matters! Each position corresponds to the action type index:
387
+ * 0 = CreateAccount
388
+ * 1 = DeployContract
389
+ * 2 = FunctionCall
390
+ * 3 = Transfer
391
+ * 4 = Stake
392
+ * 5 = AddKey
393
+ * 6 = DeleteKey
394
+ * 7 = DeleteAccount
395
+ * 8 = SignedDelegate
396
+ * 9 = DeployGlobalContract
397
+ * 10 = UseGlobalContract
398
+ */
399
+ export declare const ActionSchema: import("@zorsh/zorsh").Schema<{
400
+ stake: {
401
+ stake: bigint;
402
+ publicKey: {
403
+ ed25519Key: {
404
+ data: number[];
405
+ };
406
+ } | {
407
+ secp256k1Key: {
408
+ data: number[];
409
+ };
410
+ };
411
+ };
412
+ } | {
413
+ createAccount: {};
414
+ } | {
415
+ deployContract: {
416
+ code: Uint8Array<ArrayBufferLike>;
417
+ };
418
+ } | {
419
+ functionCall: {
420
+ methodName: string;
421
+ args: Uint8Array<ArrayBufferLike>;
422
+ gas: bigint;
423
+ deposit: bigint;
424
+ };
425
+ } | {
426
+ transfer: {
427
+ deposit: bigint;
428
+ };
429
+ } | {
430
+ addKey: {
431
+ publicKey: {
432
+ ed25519Key: {
433
+ data: number[];
434
+ };
435
+ } | {
436
+ secp256k1Key: {
437
+ data: number[];
438
+ };
439
+ };
440
+ accessKey: {
441
+ nonce: bigint;
442
+ permission: {
443
+ functionCall: {
444
+ allowance: bigint | null;
445
+ receiverId: string;
446
+ methodNames: string[];
447
+ };
448
+ } | {
449
+ fullAccess: {};
450
+ };
451
+ };
452
+ };
453
+ } | {
454
+ deleteKey: {
455
+ publicKey: {
456
+ ed25519Key: {
457
+ data: number[];
458
+ };
459
+ } | {
460
+ secp256k1Key: {
461
+ data: number[];
462
+ };
463
+ };
464
+ };
465
+ } | {
466
+ deleteAccount: {
467
+ beneficiaryId: string;
468
+ };
469
+ } | {
470
+ deployGlobalContract: {
471
+ code: Uint8Array<ArrayBufferLike>;
472
+ deployMode: {
473
+ CodeHash: {};
474
+ } | {
475
+ AccountId: {};
476
+ };
477
+ };
478
+ } | {
479
+ useGlobalContract: {
480
+ contractIdentifier: {
481
+ CodeHash: number[];
482
+ } | {
483
+ AccountId: string;
484
+ };
485
+ };
486
+ } | {
487
+ signedDelegate: {
488
+ delegateAction: {
489
+ senderId: string;
490
+ receiverId: string;
491
+ actions: ({
492
+ stake: {
493
+ stake: bigint;
494
+ publicKey: {
495
+ ed25519Key: {
496
+ data: number[];
497
+ };
498
+ } | {
499
+ secp256k1Key: {
500
+ data: number[];
501
+ };
502
+ };
503
+ };
504
+ } | {
505
+ createAccount: {};
506
+ } | {
507
+ deployContract: {
508
+ code: Uint8Array<ArrayBufferLike>;
509
+ };
510
+ } | {
511
+ functionCall: {
512
+ methodName: string;
513
+ args: Uint8Array<ArrayBufferLike>;
514
+ gas: bigint;
515
+ deposit: bigint;
516
+ };
517
+ } | {
518
+ transfer: {
519
+ deposit: bigint;
520
+ };
521
+ } | {
522
+ addKey: {
523
+ publicKey: {
524
+ ed25519Key: {
525
+ data: number[];
526
+ };
527
+ } | {
528
+ secp256k1Key: {
529
+ data: number[];
530
+ };
531
+ };
532
+ accessKey: {
533
+ nonce: bigint;
534
+ permission: {
535
+ functionCall: {
536
+ allowance: bigint | null;
537
+ receiverId: string;
538
+ methodNames: string[];
539
+ };
540
+ } | {
541
+ fullAccess: {};
542
+ };
543
+ };
544
+ };
545
+ } | {
546
+ deleteKey: {
547
+ publicKey: {
548
+ ed25519Key: {
549
+ data: number[];
550
+ };
551
+ } | {
552
+ secp256k1Key: {
553
+ data: number[];
554
+ };
555
+ };
556
+ };
557
+ } | {
558
+ deleteAccount: {
559
+ beneficiaryId: string;
560
+ };
561
+ } | {
562
+ deployGlobalContract: {
563
+ code: Uint8Array<ArrayBufferLike>;
564
+ deployMode: {
565
+ CodeHash: {};
566
+ } | {
567
+ AccountId: {};
568
+ };
569
+ };
570
+ } | {
571
+ useGlobalContract: {
572
+ contractIdentifier: {
573
+ CodeHash: number[];
574
+ } | {
575
+ AccountId: string;
576
+ };
577
+ };
578
+ })[];
579
+ nonce: bigint;
580
+ maxBlockHeight: bigint;
581
+ publicKey: {
582
+ ed25519Key: {
583
+ data: number[];
584
+ };
585
+ } | {
586
+ secp256k1Key: {
587
+ data: number[];
588
+ };
589
+ };
590
+ };
591
+ signature: {
592
+ ed25519Signature: {
593
+ data: number[];
594
+ };
595
+ } | {
596
+ secp256k1Signature: {
597
+ data: number[];
598
+ };
599
+ };
600
+ };
601
+ }, string>;
602
+ /**
603
+ * Action type inferred from the Borsh schema
604
+ * This is the single source of truth for action types
605
+ */
606
+ export type Action = b.infer<typeof ActionSchema>;
607
+ export type TransferAction = {
608
+ transfer: b.infer<typeof TransferSchema>;
609
+ };
610
+ export type FunctionCallAction = {
611
+ functionCall: b.infer<typeof FunctionCallSchema>;
612
+ };
613
+ export type CreateAccountAction = {
614
+ createAccount: b.infer<typeof CreateAccountSchema>;
615
+ };
616
+ export type DeleteAccountAction = {
617
+ deleteAccount: b.infer<typeof DeleteAccountSchema>;
618
+ };
619
+ export type DeployContractAction = {
620
+ deployContract: b.infer<typeof DeployContractSchema>;
621
+ };
622
+ export type StakeAction = {
623
+ stake: b.infer<typeof StakeSchema>;
624
+ };
625
+ export type AddKeyAction = {
626
+ addKey: b.infer<typeof AddKeySchema>;
627
+ };
628
+ export type DeleteKeyAction = {
629
+ deleteKey: b.infer<typeof DeleteKeySchema>;
630
+ };
631
+ export type DeployGlobalContractAction = {
632
+ deployGlobalContract: b.infer<typeof DeployGlobalContractSchema>;
633
+ };
634
+ export type UseGlobalContractAction = {
635
+ useGlobalContract: b.infer<typeof UseGlobalContractSchema>;
636
+ };
637
+ export type SignedDelegateAction = {
638
+ signedDelegate: b.infer<typeof SignedDelegateSchema>;
639
+ };
640
+ /**
641
+ * Transaction schema
642
+ * Field order: signerId, publicKey, nonce, receiverId, blockHash, actions
643
+ */
644
+ export declare const TransactionSchema: import("@zorsh/zorsh").Schema<{
645
+ signerId: string;
646
+ publicKey: {
647
+ ed25519Key: {
648
+ data: number[];
649
+ };
650
+ } | {
651
+ secp256k1Key: {
652
+ data: number[];
653
+ };
654
+ };
655
+ nonce: bigint;
656
+ receiverId: string;
657
+ blockHash: number[];
658
+ actions: ({
659
+ stake: {
660
+ stake: bigint;
661
+ publicKey: {
662
+ ed25519Key: {
663
+ data: number[];
664
+ };
665
+ } | {
666
+ secp256k1Key: {
667
+ data: number[];
668
+ };
669
+ };
670
+ };
671
+ } | {
672
+ createAccount: {};
673
+ } | {
674
+ deployContract: {
675
+ code: Uint8Array<ArrayBufferLike>;
676
+ };
677
+ } | {
678
+ functionCall: {
679
+ methodName: string;
680
+ args: Uint8Array<ArrayBufferLike>;
681
+ gas: bigint;
682
+ deposit: bigint;
683
+ };
684
+ } | {
685
+ transfer: {
686
+ deposit: bigint;
687
+ };
688
+ } | {
689
+ addKey: {
690
+ publicKey: {
691
+ ed25519Key: {
692
+ data: number[];
693
+ };
694
+ } | {
695
+ secp256k1Key: {
696
+ data: number[];
697
+ };
698
+ };
699
+ accessKey: {
700
+ nonce: bigint;
701
+ permission: {
702
+ functionCall: {
703
+ allowance: bigint | null;
704
+ receiverId: string;
705
+ methodNames: string[];
706
+ };
707
+ } | {
708
+ fullAccess: {};
709
+ };
710
+ };
711
+ };
712
+ } | {
713
+ deleteKey: {
714
+ publicKey: {
715
+ ed25519Key: {
716
+ data: number[];
717
+ };
718
+ } | {
719
+ secp256k1Key: {
720
+ data: number[];
721
+ };
722
+ };
723
+ };
724
+ } | {
725
+ deleteAccount: {
726
+ beneficiaryId: string;
727
+ };
728
+ } | {
729
+ deployGlobalContract: {
730
+ code: Uint8Array<ArrayBufferLike>;
731
+ deployMode: {
732
+ CodeHash: {};
733
+ } | {
734
+ AccountId: {};
735
+ };
736
+ };
737
+ } | {
738
+ useGlobalContract: {
739
+ contractIdentifier: {
740
+ CodeHash: number[];
741
+ } | {
742
+ AccountId: string;
743
+ };
744
+ };
745
+ } | {
746
+ signedDelegate: {
747
+ delegateAction: {
748
+ senderId: string;
749
+ receiverId: string;
750
+ actions: ({
751
+ stake: {
752
+ stake: bigint;
753
+ publicKey: {
754
+ ed25519Key: {
755
+ data: number[];
756
+ };
757
+ } | {
758
+ secp256k1Key: {
759
+ data: number[];
760
+ };
761
+ };
762
+ };
763
+ } | {
764
+ createAccount: {};
765
+ } | {
766
+ deployContract: {
767
+ code: Uint8Array<ArrayBufferLike>;
768
+ };
769
+ } | {
770
+ functionCall: {
771
+ methodName: string;
772
+ args: Uint8Array<ArrayBufferLike>;
773
+ gas: bigint;
774
+ deposit: bigint;
775
+ };
776
+ } | {
777
+ transfer: {
778
+ deposit: bigint;
779
+ };
780
+ } | {
781
+ addKey: {
782
+ publicKey: {
783
+ ed25519Key: {
784
+ data: number[];
785
+ };
786
+ } | {
787
+ secp256k1Key: {
788
+ data: number[];
789
+ };
790
+ };
791
+ accessKey: {
792
+ nonce: bigint;
793
+ permission: {
794
+ functionCall: {
795
+ allowance: bigint | null;
796
+ receiverId: string;
797
+ methodNames: string[];
798
+ };
799
+ } | {
800
+ fullAccess: {};
801
+ };
802
+ };
803
+ };
804
+ } | {
805
+ deleteKey: {
806
+ publicKey: {
807
+ ed25519Key: {
808
+ data: number[];
809
+ };
810
+ } | {
811
+ secp256k1Key: {
812
+ data: number[];
813
+ };
814
+ };
815
+ };
816
+ } | {
817
+ deleteAccount: {
818
+ beneficiaryId: string;
819
+ };
820
+ } | {
821
+ deployGlobalContract: {
822
+ code: Uint8Array<ArrayBufferLike>;
823
+ deployMode: {
824
+ CodeHash: {};
825
+ } | {
826
+ AccountId: {};
827
+ };
828
+ };
829
+ } | {
830
+ useGlobalContract: {
831
+ contractIdentifier: {
832
+ CodeHash: number[];
833
+ } | {
834
+ AccountId: string;
835
+ };
836
+ };
837
+ })[];
838
+ nonce: bigint;
839
+ maxBlockHeight: bigint;
840
+ publicKey: {
841
+ ed25519Key: {
842
+ data: number[];
843
+ };
844
+ } | {
845
+ secp256k1Key: {
846
+ data: number[];
847
+ };
848
+ };
849
+ };
850
+ signature: {
851
+ ed25519Signature: {
852
+ data: number[];
853
+ };
854
+ } | {
855
+ secp256k1Signature: {
856
+ data: number[];
857
+ };
858
+ };
859
+ };
860
+ })[];
861
+ }, string>;
862
+ /**
863
+ * SignedTransaction schema
864
+ */
865
+ export declare const SignedTransactionSchema: import("@zorsh/zorsh").Schema<{
866
+ transaction: {
867
+ signerId: string;
868
+ publicKey: {
869
+ ed25519Key: {
870
+ data: number[];
871
+ };
872
+ } | {
873
+ secp256k1Key: {
874
+ data: number[];
875
+ };
876
+ };
877
+ nonce: bigint;
878
+ receiverId: string;
879
+ blockHash: number[];
880
+ actions: ({
881
+ stake: {
882
+ stake: bigint;
883
+ publicKey: {
884
+ ed25519Key: {
885
+ data: number[];
886
+ };
887
+ } | {
888
+ secp256k1Key: {
889
+ data: number[];
890
+ };
891
+ };
892
+ };
893
+ } | {
894
+ createAccount: {};
895
+ } | {
896
+ deployContract: {
897
+ code: Uint8Array<ArrayBufferLike>;
898
+ };
899
+ } | {
900
+ functionCall: {
901
+ methodName: string;
902
+ args: Uint8Array<ArrayBufferLike>;
903
+ gas: bigint;
904
+ deposit: bigint;
905
+ };
906
+ } | {
907
+ transfer: {
908
+ deposit: bigint;
909
+ };
910
+ } | {
911
+ addKey: {
912
+ publicKey: {
913
+ ed25519Key: {
914
+ data: number[];
915
+ };
916
+ } | {
917
+ secp256k1Key: {
918
+ data: number[];
919
+ };
920
+ };
921
+ accessKey: {
922
+ nonce: bigint;
923
+ permission: {
924
+ functionCall: {
925
+ allowance: bigint | null;
926
+ receiverId: string;
927
+ methodNames: string[];
928
+ };
929
+ } | {
930
+ fullAccess: {};
931
+ };
932
+ };
933
+ };
934
+ } | {
935
+ deleteKey: {
936
+ publicKey: {
937
+ ed25519Key: {
938
+ data: number[];
939
+ };
940
+ } | {
941
+ secp256k1Key: {
942
+ data: number[];
943
+ };
944
+ };
945
+ };
946
+ } | {
947
+ deleteAccount: {
948
+ beneficiaryId: string;
949
+ };
950
+ } | {
951
+ deployGlobalContract: {
952
+ code: Uint8Array<ArrayBufferLike>;
953
+ deployMode: {
954
+ CodeHash: {};
955
+ } | {
956
+ AccountId: {};
957
+ };
958
+ };
959
+ } | {
960
+ useGlobalContract: {
961
+ contractIdentifier: {
962
+ CodeHash: number[];
963
+ } | {
964
+ AccountId: string;
965
+ };
966
+ };
967
+ } | {
968
+ signedDelegate: {
969
+ delegateAction: {
970
+ senderId: string;
971
+ receiverId: string;
972
+ actions: ({
973
+ stake: {
974
+ stake: bigint;
975
+ publicKey: {
976
+ ed25519Key: {
977
+ data: number[];
978
+ };
979
+ } | {
980
+ secp256k1Key: {
981
+ data: number[];
982
+ };
983
+ };
984
+ };
985
+ } | {
986
+ createAccount: {};
987
+ } | {
988
+ deployContract: {
989
+ code: Uint8Array<ArrayBufferLike>;
990
+ };
991
+ } | {
992
+ functionCall: {
993
+ methodName: string;
994
+ args: Uint8Array<ArrayBufferLike>;
995
+ gas: bigint;
996
+ deposit: bigint;
997
+ };
998
+ } | {
999
+ transfer: {
1000
+ deposit: bigint;
1001
+ };
1002
+ } | {
1003
+ addKey: {
1004
+ publicKey: {
1005
+ ed25519Key: {
1006
+ data: number[];
1007
+ };
1008
+ } | {
1009
+ secp256k1Key: {
1010
+ data: number[];
1011
+ };
1012
+ };
1013
+ accessKey: {
1014
+ nonce: bigint;
1015
+ permission: {
1016
+ functionCall: {
1017
+ allowance: bigint | null;
1018
+ receiverId: string;
1019
+ methodNames: string[];
1020
+ };
1021
+ } | {
1022
+ fullAccess: {};
1023
+ };
1024
+ };
1025
+ };
1026
+ } | {
1027
+ deleteKey: {
1028
+ publicKey: {
1029
+ ed25519Key: {
1030
+ data: number[];
1031
+ };
1032
+ } | {
1033
+ secp256k1Key: {
1034
+ data: number[];
1035
+ };
1036
+ };
1037
+ };
1038
+ } | {
1039
+ deleteAccount: {
1040
+ beneficiaryId: string;
1041
+ };
1042
+ } | {
1043
+ deployGlobalContract: {
1044
+ code: Uint8Array<ArrayBufferLike>;
1045
+ deployMode: {
1046
+ CodeHash: {};
1047
+ } | {
1048
+ AccountId: {};
1049
+ };
1050
+ };
1051
+ } | {
1052
+ useGlobalContract: {
1053
+ contractIdentifier: {
1054
+ CodeHash: number[];
1055
+ } | {
1056
+ AccountId: string;
1057
+ };
1058
+ };
1059
+ })[];
1060
+ nonce: bigint;
1061
+ maxBlockHeight: bigint;
1062
+ publicKey: {
1063
+ ed25519Key: {
1064
+ data: number[];
1065
+ };
1066
+ } | {
1067
+ secp256k1Key: {
1068
+ data: number[];
1069
+ };
1070
+ };
1071
+ };
1072
+ signature: {
1073
+ ed25519Signature: {
1074
+ data: number[];
1075
+ };
1076
+ } | {
1077
+ secp256k1Signature: {
1078
+ data: number[];
1079
+ };
1080
+ };
1081
+ };
1082
+ })[];
1083
+ };
1084
+ signature: {
1085
+ ed25519Signature: {
1086
+ data: number[];
1087
+ };
1088
+ } | {
1089
+ secp256k1Signature: {
1090
+ data: number[];
1091
+ };
1092
+ };
1093
+ }, string>;
1094
+ /**
1095
+ * Convert our PublicKey type to zorsh-compatible format.
1096
+ *
1097
+ * @internal Exported for use in action helpers only.
1098
+ */
1099
+ export declare function publicKeyToZorsh(pk: Ed25519PublicKey): {
1100
+ ed25519Key: {
1101
+ data: number[];
1102
+ };
1103
+ };
1104
+ export declare function publicKeyToZorsh(pk: Secp256k1PublicKey): {
1105
+ secp256k1Key: {
1106
+ data: number[];
1107
+ };
1108
+ };
1109
+ export declare function publicKeyToZorsh(pk: PublicKey): {
1110
+ ed25519Key: {
1111
+ data: number[];
1112
+ };
1113
+ } | {
1114
+ secp256k1Key: {
1115
+ data: number[];
1116
+ };
1117
+ };
1118
+ /**
1119
+ * Convert our Signature type to zorsh-compatible format.
1120
+ *
1121
+ * @internal Exported for use in action helpers only.
1122
+ */
1123
+ export declare function signatureToZorsh(sig: Ed25519Signature): {
1124
+ ed25519Signature: {
1125
+ data: number[];
1126
+ };
1127
+ };
1128
+ export declare function signatureToZorsh(sig: Secp256k1Signature): {
1129
+ secp256k1Signature: {
1130
+ data: number[];
1131
+ };
1132
+ };
1133
+ export declare function signatureToZorsh(sig: Signature): {
1134
+ ed25519Signature: {
1135
+ data: number[];
1136
+ };
1137
+ } | {
1138
+ secp256k1Signature: {
1139
+ data: number[];
1140
+ };
1141
+ };
1142
+ /**
1143
+ * Serialize a transaction to bytes
1144
+ */
1145
+ export declare function serializeTransaction(tx: Transaction): Uint8Array;
1146
+ /**
1147
+ * Serialize a signed transaction to bytes
1148
+ */
1149
+ export declare function serializeSignedTransaction(signedTx: SignedTransaction): Uint8Array;
1150
+ /**
1151
+ * Serialize a delegate action for signing
1152
+ *
1153
+ * Per NEP-461, this prepends a u32 prefix (2^30 + 366) before the delegate action,
1154
+ * ensuring signed delegate actions are never identical to signed transactions.
1155
+ *
1156
+ * Use this when you need to sign a DelegateAction to create a SignedDelegate.
1157
+ *
1158
+ * @param delegateAction - The delegate action to serialize
1159
+ * @returns Uint8Array - The prefixed and serialized delegate action
1160
+ *
1161
+ * @example
1162
+ * ```typescript
1163
+ * const encoded = serializeDelegateAction(delegateAction)
1164
+ * const hash = await crypto.subtle.digest("SHA-256", encoded)
1165
+ * const signature = await signer.sign(new Uint8Array(hash))
1166
+ * ```
1167
+ */
1168
+ export declare function serializeDelegateAction(delegateAction: DelegateAction): Uint8Array;
1169
+ /**
1170
+ * Serialize a signed delegate action for inclusion in a transaction
1171
+ *
1172
+ * This serializes a SignedDelegate (DelegateAction + signature) for use as
1173
+ * an action within a meta transaction.
1174
+ *
1175
+ * Note: This does NOT include the NEP-461 prefix (only needed when signing).
1176
+ *
1177
+ * @param signedDelegate - The signed delegate action to serialize
1178
+ * @returns Uint8Array - The serialized signed delegate action
1179
+ *
1180
+ * @example
1181
+ * ```typescript
1182
+ * const encoded = serializeSignedDelegate(signedDelegate)
1183
+ * // Use encoded bytes in transaction action
1184
+ * ```
1185
+ */
1186
+ export declare function serializeSignedDelegate(signedDelegate: SignedDelegate): Uint8Array;
1187
+ export {};
1188
+ //# sourceMappingURL=schema.d.ts.map