viem 0.0.0-main.20231026T220458 → 0.0.0-main.20231026T222229

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 (47) hide show
  1. package/_cjs/chains/celo/formatters.js +34 -5
  2. package/_cjs/chains/celo/formatters.js.map +1 -1
  3. package/_cjs/chains/celo/parsers.js +55 -0
  4. package/_cjs/chains/celo/parsers.js.map +1 -1
  5. package/_cjs/chains/celo/serializers.js +70 -6
  6. package/_cjs/chains/celo/serializers.js.map +1 -1
  7. package/_cjs/chains/utils/index.js.map +1 -1
  8. package/_cjs/errors/node.js +11 -11
  9. package/_cjs/errors/node.js.map +1 -1
  10. package/_cjs/errors/rpc.js +18 -18
  11. package/_cjs/errors/rpc.js.map +1 -1
  12. package/_cjs/errors/version.js +1 -1
  13. package/_esm/chains/celo/formatters.js +34 -5
  14. package/_esm/chains/celo/formatters.js.map +1 -1
  15. package/_esm/chains/celo/parsers.js +56 -1
  16. package/_esm/chains/celo/parsers.js.map +1 -1
  17. package/_esm/chains/celo/serializers.js +73 -7
  18. package/_esm/chains/celo/serializers.js.map +1 -1
  19. package/_esm/chains/utils/index.js.map +1 -1
  20. package/_esm/errors/node.js +22 -11
  21. package/_esm/errors/node.js.map +1 -1
  22. package/_esm/errors/rpc.js +36 -18
  23. package/_esm/errors/rpc.js.map +1 -1
  24. package/_esm/errors/version.js +1 -1
  25. package/_types/chains/celo/formatters.d.ts +126 -0
  26. package/_types/chains/celo/formatters.d.ts.map +1 -1
  27. package/_types/chains/celo/parsers.d.ts.map +1 -1
  28. package/_types/chains/celo/serializers.d.ts +3 -1
  29. package/_types/chains/celo/serializers.d.ts.map +1 -1
  30. package/_types/chains/celo/types.d.ts +39 -7
  31. package/_types/chains/celo/types.d.ts.map +1 -1
  32. package/_types/chains/definitions/celo.d.ts +126 -0
  33. package/_types/chains/definitions/celo.d.ts.map +1 -1
  34. package/_types/chains/definitions/celoAlfajores.d.ts +126 -0
  35. package/_types/chains/definitions/celoAlfajores.d.ts.map +1 -1
  36. package/_types/chains/definitions/celoCannoli.d.ts +126 -0
  37. package/_types/chains/definitions/celoCannoli.d.ts.map +1 -1
  38. package/_types/chains/utils/index.d.ts +1 -1
  39. package/_types/chains/utils/index.d.ts.map +1 -1
  40. package/_types/errors/version.d.ts +1 -1
  41. package/chains/celo/formatters.ts +39 -5
  42. package/chains/celo/parsers.ts +82 -1
  43. package/chains/celo/serializers.ts +121 -9
  44. package/chains/celo/types.ts +60 -2
  45. package/chains/utils/index.ts +6 -0
  46. package/errors/version.ts +1 -1
  47. package/package.json +1 -1
@@ -82,6 +82,9 @@ export declare const celoCannoli: import("../../types/utils.js").Assign<{
82
82
  gatewayFee: `0x${string}` | null;
83
83
  gatewayFeeRecipient: `0x${string}` | null;
84
84
  type: "0x7c";
85
+ }) | (import("../../types/utils.js").Assign_<Partial<Omit<import("../../index.js").TransactionLegacy<`0x${string}`, `0x${string}`, boolean, "0x0">, "typeHex">>, import("../celo/types.js").CeloRpcTransaction> & import("../../index.js").TransactionBase<`0x${string}`, `0x${string}`, boolean> & import("../../index.js").FeeValuesEIP1559<`0x${string}`> & {
86
+ feeCurrency: `0x${string}` | null;
87
+ type: "0x7b";
85
88
  }) | (import("../../types/utils.js").Assign_<Partial<Omit<import("../../index.js").TransactionEIP2930<`0x${string}`, `0x${string}`, boolean, "0x1">, "typeHex">>, import("../celo/types.js").CeloRpcTransaction> & Omit<import("../../index.js").TransactionLegacy<`0x${string}`, `0x${string}`, boolean, "0x0">, "typeHex"> & {
86
89
  feeCurrency: `0x${string}` | null;
87
90
  gatewayFee: `0x${string}` | null;
@@ -99,6 +102,9 @@ export declare const celoCannoli: import("../../types/utils.js").Assign<{
99
102
  gatewayFee: `0x${string}` | null;
100
103
  gatewayFeeRecipient: `0x${string}` | null;
101
104
  type: "0x7c";
105
+ }) | (import("../../types/utils.js").Assign_<Partial<Omit<import("../../index.js").TransactionEIP2930<`0x${string}`, `0x${string}`, boolean, "0x1">, "typeHex">>, import("../celo/types.js").CeloRpcTransaction> & import("../../index.js").TransactionBase<`0x${string}`, `0x${string}`, boolean> & import("../../index.js").FeeValuesEIP1559<`0x${string}`> & {
106
+ feeCurrency: `0x${string}` | null;
107
+ type: "0x7b";
102
108
  }) | (import("../../types/utils.js").Assign_<Partial<Omit<import("../../index.js").TransactionEIP1559<`0x${string}`, `0x${string}`, boolean, "0x2">, "typeHex">>, import("../celo/types.js").CeloRpcTransaction> & Omit<import("../../index.js").TransactionLegacy<`0x${string}`, `0x${string}`, boolean, "0x0">, "typeHex"> & {
103
109
  feeCurrency: `0x${string}` | null;
104
110
  gatewayFee: `0x${string}` | null;
@@ -116,6 +122,9 @@ export declare const celoCannoli: import("../../types/utils.js").Assign<{
116
122
  gatewayFee: `0x${string}` | null;
117
123
  gatewayFeeRecipient: `0x${string}` | null;
118
124
  type: "0x7c";
125
+ }) | (import("../../types/utils.js").Assign_<Partial<Omit<import("../../index.js").TransactionEIP1559<`0x${string}`, `0x${string}`, boolean, "0x2">, "typeHex">>, import("../celo/types.js").CeloRpcTransaction> & import("../../index.js").TransactionBase<`0x${string}`, `0x${string}`, boolean> & import("../../index.js").FeeValuesEIP1559<`0x${string}`> & {
126
+ feeCurrency: `0x${string}` | null;
127
+ type: "0x7b";
119
128
  })) => ({
120
129
  blockHash: `0x${string}` | null;
121
130
  blockNumber: bigint | null;
@@ -164,6 +173,30 @@ export declare const celoCannoli: import("../../types/utils.js").Assign<{
164
173
  feeCurrency: `0x${string}` | null;
165
174
  gatewayFee: bigint | null;
166
175
  gatewayFeeRecipient: `0x${string}` | null;
176
+ } | {
177
+ blockHash: `0x${string}` | null;
178
+ blockNumber: bigint | null;
179
+ from: `0x${string}`;
180
+ gas: bigint;
181
+ hash: `0x${string}`;
182
+ input: `0x${string}`;
183
+ nonce: number;
184
+ r: `0x${string}`;
185
+ s: `0x${string}`;
186
+ to: `0x${string}` | null;
187
+ transactionIndex: number | null;
188
+ typeHex: `0x${string}` | null;
189
+ v: bigint;
190
+ value: bigint;
191
+ gasPrice: undefined;
192
+ maxFeePerGas: bigint;
193
+ maxPriorityFeePerGas: bigint;
194
+ accessList?: undefined;
195
+ chainId?: number | undefined;
196
+ type: "cip64";
197
+ feeCurrency: `0x${string}` | null;
198
+ gatewayFee?: undefined;
199
+ gatewayFeeRecipient?: undefined;
167
200
  } | {
168
201
  blockHash: `0x${string}` | null;
169
202
  blockNumber: bigint | null;
@@ -236,6 +269,30 @@ export declare const celoCannoli: import("../../types/utils.js").Assign<{
236
269
  feeCurrency: `0x${string}` | null;
237
270
  gatewayFee: bigint | null;
238
271
  gatewayFeeRecipient: `0x${string}` | null;
272
+ } | {
273
+ blockHash: `0x${string}` | null;
274
+ blockNumber: bigint | null;
275
+ from: `0x${string}`;
276
+ gas: bigint;
277
+ hash: `0x${string}`;
278
+ input: `0x${string}`;
279
+ nonce: number;
280
+ r: `0x${string}`;
281
+ s: `0x${string}`;
282
+ to: `0x${string}` | null;
283
+ transactionIndex: number | null;
284
+ typeHex: `0x${string}` | null;
285
+ v: bigint;
286
+ value: bigint;
287
+ gasPrice: undefined;
288
+ maxFeePerGas: bigint;
289
+ maxPriorityFeePerGas: bigint;
290
+ accessList: import("../../index.js").AccessList;
291
+ chainId: number;
292
+ type: "cip64";
293
+ feeCurrency: `0x${string}` | null;
294
+ gatewayFee?: undefined;
295
+ gatewayFeeRecipient?: undefined;
239
296
  } | {
240
297
  blockHash: `0x${string}` | null;
241
298
  blockNumber: bigint | null;
@@ -308,6 +365,30 @@ export declare const celoCannoli: import("../../types/utils.js").Assign<{
308
365
  feeCurrency: `0x${string}` | null;
309
366
  gatewayFee: bigint | null;
310
367
  gatewayFeeRecipient: `0x${string}` | null;
368
+ } | {
369
+ blockHash: `0x${string}` | null;
370
+ blockNumber: bigint | null;
371
+ from: `0x${string}`;
372
+ gas: bigint;
373
+ hash: `0x${string}`;
374
+ input: `0x${string}`;
375
+ nonce: number;
376
+ r: `0x${string}`;
377
+ s: `0x${string}`;
378
+ to: `0x${string}` | null;
379
+ transactionIndex: number | null;
380
+ typeHex: `0x${string}` | null;
381
+ v: bigint;
382
+ value: bigint;
383
+ gasPrice?: undefined;
384
+ maxFeePerGas: bigint;
385
+ maxPriorityFeePerGas: bigint;
386
+ accessList: import("../../index.js").AccessList;
387
+ chainId: number;
388
+ type: "cip64";
389
+ feeCurrency: `0x${string}` | null;
390
+ gatewayFee?: undefined;
391
+ gatewayFeeRecipient?: undefined;
311
392
  }) & {};
312
393
  type: "transaction";
313
394
  };
@@ -396,6 +477,21 @@ export declare const celoCannoli: import("../../types/utils.js").Assign<{
396
477
  feeCurrency?: `0x${string}` | undefined;
397
478
  gatewayFee?: `0x${string}` | undefined;
398
479
  gatewayFeeRecipient?: `0x${string}` | undefined;
480
+ } | {
481
+ data?: `0x${string}` | undefined;
482
+ from: `0x${string}`;
483
+ gas?: `0x${string}` | undefined;
484
+ nonce?: `0x${string}` | undefined;
485
+ to?: `0x${string}` | null | undefined;
486
+ value?: `0x${string}` | undefined;
487
+ gasPrice?: undefined;
488
+ maxFeePerGas?: `0x${string}` | undefined;
489
+ maxPriorityFeePerGas?: `0x${string}` | undefined;
490
+ accessList?: import("../../index.js").AccessList | undefined;
491
+ type?: "0x7b" | undefined;
492
+ feeCurrency?: `0x${string}` | undefined;
493
+ gatewayFee?: undefined;
494
+ gatewayFeeRecipient?: undefined;
399
495
  } | {
400
496
  data?: `0x${string}` | undefined;
401
497
  from: `0x${string}`;
@@ -456,6 +552,21 @@ export declare const celoCannoli: import("../../types/utils.js").Assign<{
456
552
  feeCurrency?: `0x${string}` | undefined;
457
553
  gatewayFee?: `0x${string}` | undefined;
458
554
  gatewayFeeRecipient?: `0x${string}` | undefined;
555
+ } | {
556
+ data?: `0x${string}` | undefined;
557
+ from: `0x${string}`;
558
+ gas?: `0x${string}` | undefined;
559
+ nonce?: `0x${string}` | undefined;
560
+ to?: `0x${string}` | null | undefined;
561
+ value?: `0x${string}` | undefined;
562
+ gasPrice?: undefined;
563
+ maxFeePerGas?: `0x${string}` | undefined;
564
+ maxPriorityFeePerGas?: `0x${string}` | undefined;
565
+ accessList?: import("../../index.js").AccessList | undefined;
566
+ type?: "0x7b" | undefined;
567
+ feeCurrency?: `0x${string}` | undefined;
568
+ gatewayFee?: undefined;
569
+ gatewayFeeRecipient?: undefined;
459
570
  } | {
460
571
  data?: `0x${string}` | undefined;
461
572
  from: `0x${string}`;
@@ -516,6 +627,21 @@ export declare const celoCannoli: import("../../types/utils.js").Assign<{
516
627
  feeCurrency?: `0x${string}` | undefined;
517
628
  gatewayFee?: `0x${string}` | undefined;
518
629
  gatewayFeeRecipient?: `0x${string}` | undefined;
630
+ } | {
631
+ data?: `0x${string}` | undefined;
632
+ from: `0x${string}`;
633
+ gas?: `0x${string}` | undefined;
634
+ nonce?: `0x${string}` | undefined;
635
+ to?: `0x${string}` | null | undefined;
636
+ value?: `0x${string}` | undefined;
637
+ gasPrice?: undefined;
638
+ maxFeePerGas?: `0x${string}` | undefined;
639
+ maxPriorityFeePerGas?: `0x${string}` | undefined;
640
+ accessList?: import("../../index.js").AccessList | undefined;
641
+ type?: "0x7b" | undefined;
642
+ feeCurrency?: `0x${string}` | undefined;
643
+ gatewayFee?: undefined;
644
+ gatewayFeeRecipient?: undefined;
519
645
  }) & {};
520
646
  type: "transactionRequest";
521
647
  };
@@ -1 +1 @@
1
- {"version":3,"file":"celoCannoli.d.ts","sourceRoot":"","sources":["../../../chains/definitions/celoCannoli.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCvB,CAAA"}
1
+ {"version":3,"file":"celoCannoli.d.ts","sourceRoot":"","sources":["../../../chains/definitions/celoCannoli.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCvB,CAAA"}
@@ -1,7 +1,7 @@
1
1
  export { formattersCelo } from '../celo/formatters.js';
2
2
  export { serializeTransactionCelo, serializersCelo, } from '../celo/serializers.js';
3
3
  export { parseTransactionCelo } from '../celo/parsers.js';
4
- export type { CeloBlock, CeloBlockOverrides, CeloRpcBlock, CeloRpcBlockOverrides, CeloRpcTransaction, CeloRpcTransactionReceipt, CeloRpcTransactionReceiptOverrides, CeloRpcTransactionRequest, CeloTransaction, CeloTransactionReceipt, CeloTransactionReceiptOverrides, CeloTransactionRequest, CeloTransactionSerializable, CeloTransactionSerialized, CeloTransactionType, RpcTransactionCIP42, RpcTransactionRequestCIP42, TransactionCIP42, TransactionRequestCIP42, TransactionSerializableCIP42, TransactionSerializedCIP42, } from '../celo/types.js';
4
+ export type { CeloBlock, CeloBlockOverrides, CeloRpcBlock, CeloRpcBlockOverrides, CeloRpcTransaction, CeloRpcTransactionReceipt, CeloRpcTransactionReceiptOverrides, CeloRpcTransactionRequest, CeloTransaction, CeloTransactionReceipt, CeloTransactionReceiptOverrides, CeloTransactionRequest, CeloTransactionSerializable, CeloTransactionSerialized, CeloTransactionType, RpcTransactionCIP42, RpcTransactionCIP64, RpcTransactionRequestCIP42, RpcTransactionRequestCIP64, TransactionCIP42, TransactionCIP64, TransactionRequestCIP42, TransactionRequestCIP64, TransactionSerializableCIP42, TransactionSerializableCIP64, TransactionSerializedCIP42, TransactionSerializedCIP64, } from '../celo/types.js';
5
5
  export { formattersOptimism } from '../optimism/formatters.js';
6
6
  export type { OptimismBlock, OptimismBlockOverrides, OptimismDepositTransaction, OptimismRpcBlock, OptimismRpcBlockOverrides, OptimismRpcDepositTransaction, OptimismRpcTransaction, OptimismRpcTransactionReceipt, OptimismRpcTransactionReceiptOverrides, OptimismTransaction, OptimismTransactionReceipt, OptimismTransactionReceiptOverrides, } from '../optimism/types.js';
7
7
  export { formattersZkSync } from '../zksync/formatters.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../chains/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EACL,wBAAwB,EACxB,eAAe,GAChB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACzD,YAAY,EACV,SAAS,EACT,kBAAkB,EAClB,YAAY,EACZ,qBAAqB,EACrB,kBAAkB,EAClB,yBAAyB,EACzB,kCAAkC,EAClC,yBAAyB,EACzB,eAAe,EACf,sBAAsB,EACtB,+BAA+B,EAC/B,sBAAsB,EACtB,2BAA2B,EAC3B,yBAAyB,EACzB,mBAAmB,EACnB,mBAAmB,EACnB,0BAA0B,EAC1B,gBAAgB,EAChB,uBAAuB,EACvB,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAC9D,YAAY,EACV,aAAa,EACb,sBAAsB,EACtB,0BAA0B,EAC1B,gBAAgB,EAChB,yBAAyB,EACzB,6BAA6B,EAC7B,sBAAsB,EACtB,6BAA6B,EAC7B,sCAAsC,EACtC,mBAAmB,EACnB,0BAA0B,EAC1B,mCAAmC,GACpC,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,YAAY,EACV,WAAW,EACX,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,SAAS,EACT,cAAc,EACd,uBAAuB,EACvB,kBAAkB,EAClB,YAAY,EACZ,oBAAoB,EACpB,0BAA0B,EAC1B,4BAA4B,EAC5B,oCAAoC,EACpC,2BAA2B,EAC3B,iCAAiC,EACjC,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB,iCAAiC,EACjC,wBAAwB,EACxB,8BAA8B,EAC9B,6BAA6B,EAC7B,mCAAmC,EACnC,2BAA2B,EAC3B,iCAAiC,EACjC,qBAAqB,GACtB,MAAM,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../chains/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EACL,wBAAwB,EACxB,eAAe,GAChB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACzD,YAAY,EACV,SAAS,EACT,kBAAkB,EAClB,YAAY,EACZ,qBAAqB,EACrB,kBAAkB,EAClB,yBAAyB,EACzB,kCAAkC,EAClC,yBAAyB,EACzB,eAAe,EACf,sBAAsB,EACtB,+BAA+B,EAC/B,sBAAsB,EACtB,2BAA2B,EAC3B,yBAAyB,EACzB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,0BAA0B,EAC1B,0BAA0B,EAC1B,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,EACvB,4BAA4B,EAC5B,4BAA4B,EAC5B,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAC9D,YAAY,EACV,aAAa,EACb,sBAAsB,EACtB,0BAA0B,EAC1B,gBAAgB,EAChB,yBAAyB,EACzB,6BAA6B,EAC7B,sBAAsB,EACtB,6BAA6B,EAC7B,sCAAsC,EACtC,mBAAmB,EACnB,0BAA0B,EAC1B,mCAAmC,GACpC,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,YAAY,EACV,WAAW,EACX,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,SAAS,EACT,cAAc,EACd,uBAAuB,EACvB,kBAAkB,EAClB,YAAY,EACZ,oBAAoB,EACpB,0BAA0B,EAC1B,4BAA4B,EAC5B,oCAAoC,EACpC,2BAA2B,EAC3B,iCAAiC,EACjC,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB,iCAAiC,EACjC,wBAAwB,EACxB,8BAA8B,EAC9B,6BAA6B,EAC7B,mCAAmC,EACnC,2BAA2B,EAC3B,iCAAiC,EACjC,qBAAqB,GACtB,MAAM,oBAAoB,CAAA"}
@@ -1,2 +1,2 @@
1
- export declare const version = "0.0.0-main.20231026T220458";
1
+ export declare const version = "0.0.0-main.20231026T222229";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -20,6 +20,22 @@ import type {
20
20
  CeloTransactionRequest,
21
21
  } from './types.js'
22
22
 
23
+ function isTransactionRequestCIP64(args: CeloTransactionRequest): boolean {
24
+ if (args.type === 'cip64') return true
25
+ if (args.type) return false
26
+ return (
27
+ 'feeCurrency' in args &&
28
+ args.gatewayFee === undefined &&
29
+ args.gatewayFeeRecipient === undefined
30
+ )
31
+ }
32
+
33
+ function isTransactionRequestCIP42(args: CeloTransactionRequest): boolean {
34
+ if (args.type === 'cip42') return true
35
+ if (args.type) return false
36
+ return args.gatewayFee !== undefined || args.gatewayFeeRecipient !== undefined
37
+ }
38
+
23
39
  export const formattersCelo = {
24
40
  block: /*#__PURE__*/ defineBlock({
25
41
  exclude: ['difficulty', 'gasLimit', 'mixHash', 'nonce', 'uncles'],
@@ -35,10 +51,15 @@ export const formattersCelo = {
35
51
  return {
36
52
  ...formatTransaction(transaction as RpcTransaction),
37
53
  feeCurrency: transaction.feeCurrency,
38
- gatewayFee: transaction.gatewayFee
39
- ? hexToBigInt(transaction.gatewayFee)
40
- : null,
41
- gatewayFeeRecipient: transaction.gatewayFeeRecipient,
54
+
55
+ ...(transaction.type !== '0x7b'
56
+ ? {
57
+ gatewayFee: transaction.gatewayFee
58
+ ? hexToBigInt(transaction.gatewayFee)
59
+ : null,
60
+ gatewayFeeRecipient: transaction.gatewayFeeRecipient || null,
61
+ }
62
+ : {}),
42
63
  }
43
64
  }) as Hash[] | CeloTransaction[]
44
65
  return {
@@ -49,6 +70,10 @@ export const formattersCelo = {
49
70
  }),
50
71
  transaction: /*#__PURE__*/ defineTransaction({
51
72
  format(args: CeloRpcTransaction): CeloTransaction {
73
+ if (args.type === '0x7b')
74
+ return {
75
+ feeCurrency: args.feeCurrency,
76
+ } as CeloTransaction
52
77
  return {
53
78
  feeCurrency: args.feeCurrency,
54
79
  gatewayFee: args.gatewayFee ? hexToBigInt(args.gatewayFee) : null,
@@ -67,8 +92,15 @@ export const formattersCelo = {
67
92
  }
68
93
  },
69
94
  }),
95
+
70
96
  transactionRequest: /*#__PURE__*/ defineTransactionRequest({
71
97
  format(args: CeloTransactionRequest): CeloRpcTransactionRequest {
98
+ if (isTransactionRequestCIP64(args))
99
+ return {
100
+ type: '0x7b',
101
+ feeCurrency: args.feeCurrency,
102
+ } as CeloRpcTransactionRequest
103
+
72
104
  const request = {
73
105
  feeCurrency: args.feeCurrency,
74
106
  gatewayFee:
@@ -77,7 +109,9 @@ export const formattersCelo = {
77
109
  : undefined,
78
110
  gatewayFeeRecipient: args.gatewayFeeRecipient,
79
111
  } as CeloRpcTransactionRequest
80
- if (args.type === 'cip42') request.type = '0x7c'
112
+
113
+ if (isTransactionRequestCIP42(args)) request.type = '0x7c'
114
+
81
115
  return request
82
116
  },
83
117
  }),
@@ -11,12 +11,17 @@ import {
11
11
  parseTransaction,
12
12
  toTransactionArray,
13
13
  } from '../../utils/transaction/parseTransaction.js'
14
- import { assertTransactionCIP42 } from './serializers.js'
14
+ import {
15
+ assertTransactionCIP42,
16
+ assertTransactionCIP64,
17
+ } from './serializers.js'
15
18
  import type {
16
19
  CeloTransactionSerialized,
17
20
  CeloTransactionType,
18
21
  TransactionSerializableCIP42,
22
+ TransactionSerializableCIP64,
19
23
  TransactionSerializedCIP42,
24
+ TransactionSerializedCIP64,
20
25
  } from './types.js'
21
26
 
22
27
  export type ParseTransactionCeloReturnType<
@@ -38,6 +43,11 @@ export function parseTransactionCelo<
38
43
  serializedTransaction as TransactionSerializedCIP42,
39
44
  ) as ParseTransactionCeloReturnType<TSerialized>
40
45
 
46
+ if (serializedType === '0x7b')
47
+ return parseTransactionCIP64(
48
+ serializedTransaction as TransactionSerializedCIP64,
49
+ ) as ParseTransactionCeloReturnType<TSerialized>
50
+
41
51
  return parseTransaction(
42
52
  serializedTransaction,
43
53
  ) as ParseTransactionCeloReturnType<TSerialized>
@@ -121,3 +131,74 @@ function parseTransactionCIP42(
121
131
 
122
132
  return transaction as TransactionSerializableCIP42
123
133
  }
134
+
135
+ function parseTransactionCIP64(
136
+ serializedTransaction: TransactionSerializedCIP64,
137
+ ): TransactionSerializableCIP64 {
138
+ const transactionArray = toTransactionArray(serializedTransaction)
139
+
140
+ const [
141
+ chainId,
142
+ nonce,
143
+ maxPriorityFeePerGas,
144
+ maxFeePerGas,
145
+ gas,
146
+ to,
147
+ value,
148
+ data,
149
+ accessList,
150
+ feeCurrency,
151
+ v,
152
+ r,
153
+ s,
154
+ ] = transactionArray
155
+
156
+ if (transactionArray.length !== 13 && transactionArray.length !== 10) {
157
+ throw new InvalidSerializedTransactionError({
158
+ attributes: {
159
+ chainId,
160
+ nonce,
161
+ maxPriorityFeePerGas,
162
+ maxFeePerGas,
163
+ gas,
164
+ to,
165
+ value,
166
+ data,
167
+ accessList,
168
+ feeCurrency,
169
+ ...(transactionArray.length > 10
170
+ ? {
171
+ v,
172
+ r,
173
+ s,
174
+ }
175
+ : {}),
176
+ },
177
+ serializedTransaction,
178
+ type: 'cip64',
179
+ })
180
+ }
181
+
182
+ const transaction: Partial<TransactionSerializableCIP64> = {
183
+ chainId: hexToNumber(chainId as Hex),
184
+ type: 'cip64',
185
+ }
186
+
187
+ if (isHex(to) && to !== '0x') transaction.to = to
188
+ if (isHex(gas) && gas !== '0x') transaction.gas = hexToBigInt(gas)
189
+ if (isHex(data) && data !== '0x') transaction.data = data
190
+ if (isHex(nonce) && nonce !== '0x') transaction.nonce = hexToNumber(nonce)
191
+ if (isHex(value) && value !== '0x') transaction.value = hexToBigInt(value)
192
+ if (isHex(feeCurrency) && feeCurrency !== '0x')
193
+ transaction.feeCurrency = feeCurrency
194
+ if (isHex(maxFeePerGas) && maxFeePerGas !== '0x')
195
+ transaction.maxFeePerGas = hexToBigInt(maxFeePerGas)
196
+ if (isHex(maxPriorityFeePerGas) && maxPriorityFeePerGas !== '0x')
197
+ transaction.maxPriorityFeePerGas = hexToBigInt(maxPriorityFeePerGas)
198
+ if (accessList.length !== 0 && accessList !== '0x')
199
+ transaction.accessList = parseAccessList(accessList as RecursiveArray<Hex>)
200
+
201
+ assertTransactionCIP64(transaction as TransactionSerializableCIP64)
202
+
203
+ return transaction as TransactionSerializableCIP64
204
+ }
@@ -18,21 +18,27 @@ import {
18
18
  import type {
19
19
  CeloTransactionSerializable,
20
20
  TransactionSerializableCIP42,
21
+ TransactionSerializableCIP64,
21
22
  TransactionSerializedCIP42,
23
+ TransactionSerializedCIP64,
22
24
  } from './types.js'
23
25
 
24
26
  export const serializeTransactionCelo: SerializeTransactionFn<
25
27
  CeloTransactionSerializable
26
28
  > = (tx, signature) => {
27
- // Handle CIP-42 transactions
28
- if (isCIP42(tx))
29
+ if (isCIP64(tx)) {
30
+ return serializeTransactionCIP64(
31
+ tx as TransactionSerializableCIP64,
32
+ signature,
33
+ )
34
+ } else if (isCIP42(tx)) {
29
35
  return serializeTransactionCIP42(
30
36
  tx as TransactionSerializableCIP42,
31
37
  signature,
32
38
  )
33
-
34
- // Handle other transaction types
35
- return serializeTransaction(tx as TransactionSerializable, signature)
39
+ } else {
40
+ return serializeTransaction(tx as TransactionSerializable, signature)
41
+ }
36
42
  }
37
43
 
38
44
  export const serializersCelo = {
@@ -43,6 +49,7 @@ export const serializersCelo = {
43
49
  // Serializers
44
50
 
45
51
  export type SerializeTransactionCIP42ReturnType = TransactionSerializedCIP42
52
+ export type SerializeTransactionCIP64ReturnType = TransactionSerializedCIP64
46
53
 
47
54
  // There shall be a typed transaction with the code 0x7c that has the following format:
48
55
  // 0x7c || rlp([chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas, gas_limit, feecurrency, gatewayFeeRecipient, gatewayfee, destination, amount, data, access_list, signature_y_parity, signature_r, signature_s]).
@@ -96,20 +103,83 @@ function serializeTransactionCIP42(
96
103
  ]) as SerializeTransactionCIP42ReturnType
97
104
  }
98
105
 
106
+ function serializeTransactionCIP64(
107
+ transaction: TransactionSerializableCIP64,
108
+ signature?: Signature,
109
+ ): SerializeTransactionCIP64ReturnType {
110
+ assertTransactionCIP64(transaction)
111
+ const {
112
+ chainId,
113
+ gas,
114
+ nonce,
115
+ to,
116
+ value,
117
+ maxFeePerGas,
118
+ maxPriorityFeePerGas,
119
+ accessList,
120
+ feeCurrency,
121
+ data,
122
+ } = transaction
123
+
124
+ const serializedTransaction = [
125
+ toHex(chainId),
126
+ nonce ? toHex(nonce) : '0x',
127
+ maxPriorityFeePerGas ? toHex(maxPriorityFeePerGas) : '0x',
128
+ maxFeePerGas ? toHex(maxFeePerGas) : '0x',
129
+ gas ? toHex(gas) : '0x',
130
+ to ?? '0x',
131
+ value ? toHex(value) : '0x',
132
+ data ?? '0x',
133
+ serializeAccessList(accessList),
134
+ feeCurrency ?? '0x',
135
+ ]
136
+
137
+ if (signature) {
138
+ serializedTransaction.push(
139
+ signature.v === 27n ? '0x' : toHex(1), // yParity
140
+ trim(signature.r),
141
+ trim(signature.s),
142
+ )
143
+ }
144
+
145
+ return concatHex([
146
+ '0x7b',
147
+ toRlp(serializedTransaction),
148
+ ]) as SerializeTransactionCIP64ReturnType
149
+ }
150
+
99
151
  //////////////////////////////////////////////////////////////////////////////
100
152
  // Utilities
101
153
 
102
154
  // process as CIP42 if any of these fields are present. realistically gatewayfee is not used but is part of spec
103
- function isCIP42(transaction: CeloTransactionSerializable) {
104
- if (
155
+ function isCIP42(transaction: CeloTransactionSerializable): boolean {
156
+ if (transaction.type === 'cip42') return true
157
+ // if the type is defined as anything else, assume it is *not* cip42
158
+ if (transaction.type) return false
159
+
160
+ // if the type is undefined, check if the fields match the expectations for cip42
161
+ return (
105
162
  'maxFeePerGas' in transaction &&
106
163
  'maxPriorityFeePerGas' in transaction &&
107
164
  ('feeCurrency' in transaction ||
108
165
  'gatewayFee' in transaction ||
109
166
  'gatewayFeeRecipient' in transaction)
110
167
  )
111
- return true
112
- return false
168
+ }
169
+
170
+ function isCIP64(transaction: CeloTransactionSerializable): boolean {
171
+ if (transaction.type === 'cip64') return true
172
+ // if the type is defined as anything else, assume it is *not* cip64
173
+ if (transaction.type) return false
174
+
175
+ // if the type is undefined, check if the fields match the expectations for cip64
176
+ return (
177
+ 'maxFeePerGas' in transaction &&
178
+ 'maxPriorityFeePerGas' in transaction &&
179
+ 'feeCurrency' in transaction &&
180
+ !('gatewayFee' in transaction) &&
181
+ !('gatewayFeeRecipient' in transaction)
182
+ )
113
183
  }
114
184
 
115
185
  // maxFeePerGas must be less than 2^256 - 1: however writing like that caused exceptions to be raised
@@ -167,3 +237,45 @@ export function assertTransactionCIP42(
167
237
  )
168
238
  }
169
239
  }
240
+
241
+ export function assertTransactionCIP64(
242
+ transaction: TransactionSerializableCIP64,
243
+ ) {
244
+ const {
245
+ chainId,
246
+ maxPriorityFeePerGas,
247
+ gasPrice,
248
+ maxFeePerGas,
249
+ to,
250
+ feeCurrency,
251
+ } = transaction
252
+
253
+ if (chainId <= 0) throw new InvalidChainIdError({ chainId })
254
+ if (to && !isAddress(to)) throw new InvalidAddressError({ address: to })
255
+
256
+ if (gasPrice)
257
+ throw new BaseError(
258
+ '`gasPrice` is not a valid CIP-64 Transaction attribute.',
259
+ )
260
+
261
+ if (maxFeePerGas && maxFeePerGas > MAX_MAX_FEE_PER_GAS)
262
+ throw new FeeCapTooHighError({ maxFeePerGas })
263
+ if (
264
+ maxPriorityFeePerGas &&
265
+ maxFeePerGas &&
266
+ maxPriorityFeePerGas > maxFeePerGas
267
+ )
268
+ throw new TipAboveFeeCapError({ maxFeePerGas, maxPriorityFeePerGas })
269
+
270
+ if (feeCurrency && !feeCurrency?.startsWith('0x')) {
271
+ throw new BaseError(
272
+ '`feeCurrency` MUST be a token address for CIP-64 transactions.',
273
+ )
274
+ }
275
+
276
+ if (!feeCurrency) {
277
+ throw new BaseError(
278
+ '`feeCurrency` must be provided for CIP-64 transactions.',
279
+ )
280
+ }
281
+ }