viem 0.0.0-main.20231026T214025 → 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.
- package/_cjs/chains/celo/formatters.js +34 -5
- package/_cjs/chains/celo/formatters.js.map +1 -1
- package/_cjs/chains/celo/parsers.js +55 -0
- package/_cjs/chains/celo/parsers.js.map +1 -1
- package/_cjs/chains/celo/serializers.js +70 -6
- package/_cjs/chains/celo/serializers.js.map +1 -1
- package/_cjs/chains/utils/index.js.map +1 -1
- package/_cjs/chains/zksync/formatters.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_esm/chains/celo/formatters.js +34 -5
- package/_esm/chains/celo/formatters.js.map +1 -1
- package/_esm/chains/celo/parsers.js +56 -1
- package/_esm/chains/celo/parsers.js.map +1 -1
- package/_esm/chains/celo/serializers.js +73 -7
- package/_esm/chains/celo/serializers.js.map +1 -1
- package/_esm/chains/utils/index.js.map +1 -1
- package/_esm/chains/zksync/formatters.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_types/chains/celo/formatters.d.ts +126 -0
- package/_types/chains/celo/formatters.d.ts.map +1 -1
- package/_types/chains/celo/parsers.d.ts.map +1 -1
- package/_types/chains/celo/serializers.d.ts +3 -1
- package/_types/chains/celo/serializers.d.ts.map +1 -1
- package/_types/chains/celo/types.d.ts +39 -7
- package/_types/chains/celo/types.d.ts.map +1 -1
- package/_types/chains/definitions/celo.d.ts +126 -0
- package/_types/chains/definitions/celo.d.ts.map +1 -1
- package/_types/chains/definitions/celoAlfajores.d.ts +126 -0
- package/_types/chains/definitions/celoAlfajores.d.ts.map +1 -1
- package/_types/chains/definitions/celoCannoli.d.ts +126 -0
- package/_types/chains/definitions/celoCannoli.d.ts.map +1 -1
- package/_types/chains/definitions/zkSync.d.ts +2 -52
- package/_types/chains/definitions/zkSync.d.ts.map +1 -1
- package/_types/chains/definitions/zkSyncTestnet.d.ts +2 -52
- package/_types/chains/definitions/zkSyncTestnet.d.ts.map +1 -1
- package/_types/chains/utils/index.d.ts +1 -1
- package/_types/chains/utils/index.d.ts.map +1 -1
- package/_types/chains/zksync/formatters.d.ts +2 -52
- package/_types/chains/zksync/formatters.d.ts.map +1 -1
- package/_types/chains/zksync/types.d.ts +12 -11
- package/_types/chains/zksync/types.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/chains/celo/formatters.ts +39 -5
- package/chains/celo/parsers.ts +82 -1
- package/chains/celo/serializers.ts +121 -9
- package/chains/celo/types.ts +60 -2
- package/chains/utils/index.ts +6 -0
- package/chains/zksync/formatters.ts +1 -2
- package/chains/zksync/types.ts +22 -20
- package/errors/version.ts +1 -1
- package/package.json +1 -1
@@ -37,57 +37,7 @@ export declare const formattersZkSync: {
|
|
37
37
|
};
|
38
38
|
readonly transaction: {
|
39
39
|
exclude: [] | undefined;
|
40
|
-
format: (args:
|
41
|
-
accessList?: undefined;
|
42
|
-
chainId?: `0x${string}` | undefined;
|
43
|
-
type: "0x0";
|
44
|
-
} & {
|
45
|
-
l1BatchNumber: `0x${string}`;
|
46
|
-
l1BatchTxIndex: `0x${string}`;
|
47
|
-
}, "typeHex">) | (import("../../types/utils.js").Assign_<Partial<Omit<import("../../index.js").TransactionLegacy<`0x${string}`, `0x${string}`, boolean, "0x0">, "typeHex">>, ZkSyncRpcTransaction> & Omit<import("../../index.js").TransactionBase<`0x${string}`, `0x${string}`, boolean> & import("./types.js").ZkSyncFeeValues<`0x${string}`> & {
|
48
|
-
l1BatchNumber: `0x${string}`;
|
49
|
-
l1BatchTxIndex: `0x${string}`;
|
50
|
-
} & {
|
51
|
-
type: "0x2";
|
52
|
-
}, "typeHex">) | (import("../../types/utils.js").Assign_<Partial<Omit<import("../../index.js").TransactionLegacy<`0x${string}`, `0x${string}`, boolean, "0x0">, "typeHex">>, ZkSyncRpcTransaction> & Omit<import("./types.js").ZkSyncRpcTransactionPriority<boolean>, "typeHex">) | (import("../../types/utils.js").Assign_<Partial<Omit<import("../../index.js").TransactionLegacy<`0x${string}`, `0x${string}`, boolean, "0x0">, "typeHex">>, ZkSyncRpcTransaction> & Omit<import("./types.js").ZkSyncRpcTransactionEIP712<boolean>, "typeHex">) | (import("../../types/utils.js").Assign_<Partial<Omit<import("../../index.js").TransactionEIP2930<`0x${string}`, `0x${string}`, boolean, "0x1">, "typeHex">>, ZkSyncRpcTransaction> & Omit<import("../../index.js").TransactionBase<`0x${string}`, `0x${string}`, boolean> & import("../../index.js").FeeValuesLegacy<`0x${string}`> & {
|
53
|
-
accessList?: undefined;
|
54
|
-
chainId?: `0x${string}` | undefined;
|
55
|
-
type: "0x0";
|
56
|
-
} & {
|
57
|
-
l1BatchNumber: `0x${string}`;
|
58
|
-
l1BatchTxIndex: `0x${string}`;
|
59
|
-
}, "typeHex">) | (import("../../types/utils.js").Assign_<Partial<Omit<import("../../index.js").TransactionEIP2930<`0x${string}`, `0x${string}`, boolean, "0x1">, "typeHex">>, ZkSyncRpcTransaction> & Omit<import("../../index.js").TransactionBase<`0x${string}`, `0x${string}`, boolean> & import("../../index.js").FeeValuesLegacy<`0x${string}`> & {
|
60
|
-
accessList: import("../../index.js").AccessList;
|
61
|
-
chainId: `0x${string}`;
|
62
|
-
type: "0x1";
|
63
|
-
} & {
|
64
|
-
l1BatchNumber: `0x${string}`;
|
65
|
-
l1BatchTxIndex: `0x${string}`;
|
66
|
-
}, "typeHex">) | (import("../../types/utils.js").Assign_<Partial<Omit<import("../../index.js").TransactionEIP2930<`0x${string}`, `0x${string}`, boolean, "0x1">, "typeHex">>, ZkSyncRpcTransaction> & Omit<import("../../index.js").TransactionBase<`0x${string}`, `0x${string}`, boolean> & import("./types.js").ZkSyncFeeValues<`0x${string}`> & {
|
67
|
-
l1BatchNumber: `0x${string}`;
|
68
|
-
l1BatchTxIndex: `0x${string}`;
|
69
|
-
} & {
|
70
|
-
type: "0x2";
|
71
|
-
}, "typeHex">) | (import("../../types/utils.js").Assign_<Partial<Omit<import("../../index.js").TransactionEIP2930<`0x${string}`, `0x${string}`, boolean, "0x1">, "typeHex">>, ZkSyncRpcTransaction> & Omit<import("./types.js").ZkSyncRpcTransactionPriority<boolean>, "typeHex">) | (import("../../types/utils.js").Assign_<Partial<Omit<import("../../index.js").TransactionEIP2930<`0x${string}`, `0x${string}`, boolean, "0x1">, "typeHex">>, ZkSyncRpcTransaction> & Omit<import("./types.js").ZkSyncRpcTransactionEIP712<boolean>, "typeHex">) | (import("../../types/utils.js").Assign_<Partial<Omit<import("../../index.js").TransactionEIP1559<`0x${string}`, `0x${string}`, boolean, "0x2">, "typeHex">>, ZkSyncRpcTransaction> & Omit<import("../../index.js").TransactionBase<`0x${string}`, `0x${string}`, boolean> & import("../../index.js").FeeValuesLegacy<`0x${string}`> & {
|
72
|
-
accessList?: undefined;
|
73
|
-
chainId?: `0x${string}` | undefined;
|
74
|
-
type: "0x0";
|
75
|
-
} & {
|
76
|
-
l1BatchNumber: `0x${string}`;
|
77
|
-
l1BatchTxIndex: `0x${string}`;
|
78
|
-
}, "typeHex">) | (import("../../types/utils.js").Assign_<Partial<Omit<import("../../index.js").TransactionEIP1559<`0x${string}`, `0x${string}`, boolean, "0x2">, "typeHex">>, ZkSyncRpcTransaction> & Omit<import("../../index.js").TransactionBase<`0x${string}`, `0x${string}`, boolean> & import("../../index.js").FeeValuesLegacy<`0x${string}`> & {
|
79
|
-
accessList: import("../../index.js").AccessList;
|
80
|
-
chainId: `0x${string}`;
|
81
|
-
type: "0x1";
|
82
|
-
} & {
|
83
|
-
l1BatchNumber: `0x${string}`;
|
84
|
-
l1BatchTxIndex: `0x${string}`;
|
85
|
-
}, "typeHex">) | (import("../../types/utils.js").Assign_<Partial<Omit<import("../../index.js").TransactionEIP1559<`0x${string}`, `0x${string}`, boolean, "0x2">, "typeHex">>, ZkSyncRpcTransaction> & Omit<import("../../index.js").TransactionBase<`0x${string}`, `0x${string}`, boolean> & import("./types.js").ZkSyncFeeValues<`0x${string}`> & {
|
86
|
-
l1BatchNumber: `0x${string}`;
|
87
|
-
l1BatchTxIndex: `0x${string}`;
|
88
|
-
} & {
|
89
|
-
type: "0x2";
|
90
|
-
}, "typeHex">) | (import("../../types/utils.js").Assign_<Partial<Omit<import("../../index.js").TransactionEIP1559<`0x${string}`, `0x${string}`, boolean, "0x2">, "typeHex">>, ZkSyncRpcTransaction> & Omit<import("./types.js").ZkSyncRpcTransactionPriority<boolean>, "typeHex">) | (import("../../types/utils.js").Assign_<Partial<Omit<import("../../index.js").TransactionEIP1559<`0x${string}`, `0x${string}`, boolean, "0x2">, "typeHex">>, ZkSyncRpcTransaction> & Omit<import("./types.js").ZkSyncRpcTransactionEIP712<boolean>, "typeHex">)) => ({
|
40
|
+
format: (args: import("../../types/utils.js").Assign<Partial<import("../../index.js").RpcTransaction>, ZkSyncRpcTransaction>) => ({
|
91
41
|
blockHash: `0x${string}` | null;
|
92
42
|
blockNumber: bigint | null;
|
93
43
|
from: `0x${string}`;
|
@@ -359,7 +309,7 @@ export declare const formattersZkSync: {
|
|
359
309
|
to: `0x${string}` | null;
|
360
310
|
transactionHash: `0x${string}`;
|
361
311
|
transactionIndex: number;
|
362
|
-
type: import("
|
312
|
+
type: import("./types.js").ZkSyncTransactionType;
|
363
313
|
l1BatchNumber: bigint | null;
|
364
314
|
l1BatchTxIndex: bigint | null;
|
365
315
|
l2ToL1Logs: ZkSyncL2ToL1Log[];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../../../chains/zksync/formatters.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAS/C,OAAO,KAAK,EAEV,eAAe,EACf,SAAS,EACT,uBAAuB,EACvB,oBAAoB,EACpB,oCAAoC,EAEpC,iBAAiB,
|
1
|
+
{"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../../../chains/zksync/formatters.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAS/C,OAAO,KAAK,EAEV,eAAe,EACf,SAAS,EACT,uBAAuB,EACvB,oBAAoB,EACpB,oCAAoC,EAEpC,iBAAiB,EAEjB,wBAAwB,EACzB,MAAM,YAAY,CAAA;AAEnB,eAAO,MAAM,gBAAgB;;;;0BAIP,IAAI,EAAE,GAAG,oBAAoB,EAAE;;;;;;;;;;;;;;;;;;;;;0BAGjC,IAAI,EAAE,GAAG,iBAAiB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+GZ,CAAA"}
|
@@ -3,10 +3,11 @@ import type { Block, BlockTag } from '../../types/block.js';
|
|
3
3
|
import type { FeeValuesEIP1559 } from '../../types/fee.js';
|
4
4
|
import type { Log as Log_ } from '../../types/log.js';
|
5
5
|
import type { Hex } from '../../types/misc.js';
|
6
|
-
import type { Index, Quantity, RpcBlock, RpcLog as RpcLog_, RpcTransactionRequest as RpcTransactionRequest_
|
7
|
-
import type { TransactionSerializable, TransactionSerializableEIP1559, TransactionSerialized } from '../../types/transaction.js';
|
8
|
-
import type { Transaction as Transaction_, TransactionBase, TransactionEIP2930, TransactionLegacy, TransactionReceipt, TransactionRequest as TransactionRequest_, TransactionRequestBase } from '../../types/transaction.js';
|
6
|
+
import type { Index, Quantity, RpcBlock, RpcLog as RpcLog_, RpcTransactionRequest as RpcTransactionRequest_ } from '../../types/rpc.js';
|
7
|
+
import type { Transaction as Transaction_, TransactionBase, TransactionEIP1559 as TransactionEIP1559_, TransactionEIP2930 as TransactionEIP2930_, TransactionLegacy as TransactionLegacy_, TransactionReceipt, TransactionRequest as TransactionRequest_, TransactionRequestBase, TransactionSerializable, TransactionSerializableEIP1559, TransactionSerialized, TransactionType } from '../../types/transaction.js';
|
9
8
|
import type { UnionOmit } from '../../types/utils.js';
|
9
|
+
type EIP712Type = '0x71';
|
10
|
+
type PriorityType = '0xff';
|
10
11
|
export type ZkSyncLog<TQuantity = bigint, TIndex = number, TPending extends boolean = boolean, TAbiEvent extends AbiEvent | undefined = undefined, TStrict extends boolean | undefined = undefined, TAbi extends Abi | readonly unknown[] | undefined = TAbiEvent extends AbiEvent ? [TAbiEvent] : undefined, TEventName extends string | undefined = TAbiEvent extends AbiEvent ? TAbiEvent['name'] : undefined> = Log_<TQuantity, TIndex, TPending, TAbiEvent, TStrict, TAbi, TEventName> & {
|
11
12
|
l1BatchNumber: TQuantity;
|
12
13
|
transactionLogIndex: TIndex;
|
@@ -58,8 +59,6 @@ export type ZkSyncFeeValues<TQuantity = bigint> = {
|
|
58
59
|
maxFeePerGas: TQuantity;
|
59
60
|
maxPriorityFeePerGas: TQuantity;
|
60
61
|
};
|
61
|
-
type EIP712Type = '0x71';
|
62
|
-
type PriorityType = '0xff';
|
63
62
|
export type ZkSyncBlockOverrides = {
|
64
63
|
l1BatchNumber: bigint | null;
|
65
64
|
l1BatchTimestamp: bigint | null;
|
@@ -86,15 +85,17 @@ type RpcTransactionOverrides = {
|
|
86
85
|
l1BatchNumber: Hex;
|
87
86
|
l1BatchTxIndex: Hex;
|
88
87
|
};
|
89
|
-
type RpcTransactionLegacy<TPending extends boolean = boolean> =
|
90
|
-
type RpcTransactionEIP2930<TPending extends boolean = boolean> =
|
91
|
-
type RpcTransactionEIP1559<TPending extends boolean = boolean> =
|
92
|
-
type: '0x2';
|
93
|
-
};
|
88
|
+
type RpcTransactionLegacy<TPending extends boolean = boolean> = TransactionLegacy_<Hex, Hex, TPending, '0x0'> & RpcTransactionOverrides;
|
89
|
+
type RpcTransactionEIP2930<TPending extends boolean = boolean> = TransactionEIP2930_<Hex, Hex, TPending, '0x1'> & RpcTransactionOverrides;
|
90
|
+
type RpcTransactionEIP1559<TPending extends boolean = boolean> = TransactionEIP1559_<Hex, Hex, TPending, '0x2'> & RpcTransactionOverrides;
|
94
91
|
export type ZkSyncRpcTransactionPriority<TPending extends boolean = boolean> = TransactionBase<Quantity, Index, TPending> & ZkSyncFeeValues<Quantity> & RpcTransactionOverrides & {
|
92
|
+
accessList?: undefined;
|
93
|
+
chainId: Hex;
|
95
94
|
type: PriorityType;
|
96
95
|
};
|
97
96
|
export type ZkSyncRpcTransactionEIP712<TPending extends boolean = boolean> = TransactionBase<Quantity, Index, TPending> & ZkSyncFeeValues<Quantity> & RpcTransactionOverrides & {
|
97
|
+
accessList?: undefined;
|
98
|
+
chainId: Hex;
|
98
99
|
type: EIP712Type;
|
99
100
|
};
|
100
101
|
export type ZkSyncRpcTransaction<TPending extends boolean = boolean> = UnionOmit<RpcTransactionLegacy<TPending> | RpcTransactionEIP2930<TPending> | RpcTransactionEIP1559<TPending> | ZkSyncRpcTransactionPriority<TPending> | ZkSyncRpcTransactionEIP712<TPending>, 'typeHex'>;
|
@@ -140,7 +141,7 @@ export type ZkSyncTransactionReceiptOverrides = {
|
|
140
141
|
logs: ZkSyncLog[];
|
141
142
|
l2ToL1Logs: ZkSyncL2ToL1Log[];
|
142
143
|
};
|
143
|
-
export type ZkSyncTransactionReceipt = Omit<TransactionReceipt, 'logs'> & ZkSyncTransactionReceiptOverrides;
|
144
|
+
export type ZkSyncTransactionReceipt<TStatus = 'success' | 'reverted', TType = ZkSyncTransactionType> = Omit<TransactionReceipt<bigint, number, TStatus, TType>, 'logs'> & ZkSyncTransactionReceiptOverrides;
|
144
145
|
export type ZkSyncTransactionSerializable = TransactionSerializable | ZkSyncTransactionSerializableEIP712;
|
145
146
|
export type ZkSyncTransactionSerialized<TType extends TransactionType = 'eip712'> = TType extends 'eip712' ? ZkSyncTransactionSerializedEIP712 : TransactionSerialized<TType>;
|
146
147
|
export type ZkSyncTransactionSerializedEIP712 = `0x71${string}`;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../chains/zksync/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,KAAK,EAAE,GAAG,IAAI,IAAI,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,KAAK,EACV,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,MAAM,IAAI,OAAO,EACjB,qBAAqB,IAAI,sBAAsB,
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../chains/zksync/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,KAAK,EAAE,GAAG,IAAI,IAAI,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA;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rC,KAAK,SAAS,eAAe,GAAG,QAAQ,IACtC,KAAK,SAAS,QAAQ,GACtB,iCAAiC,GACjC,qBAAqB,CAAC,KAAK,CAAC,CAAA;AAEhC,MAAM,MAAM,iCAAiC,GAAG,OAAO,MAAM,EAAE,CAAA;AAE/D,MAAM,MAAM,mCAAmC,CAC7C,SAAS,GAAG,MAAM,EAClB,MAAM,GAAG,MAAM,IACb,IAAI,CAAC,8BAA8B,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,GAAG;IACpE,IAAI,EAAE,GAAG,CAAA;IACT,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,WAAW,CAAC,EAAE,GAAG,EAAE,CAAA;IACnB,cAAc,CAAC,EAAE,GAAG,CAAA;IACpB,eAAe,CAAC,EAAE,GAAG,CAAA;IACrB,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB,CAAA"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare const version = "0.0.0-main.
|
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
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
-
|
112
|
+
|
113
|
+
if (isTransactionRequestCIP42(args)) request.type = '0x7c'
|
114
|
+
|
81
115
|
return request
|
82
116
|
},
|
83
117
|
}),
|
package/chains/celo/parsers.ts
CHANGED
@@ -11,12 +11,17 @@ import {
|
|
11
11
|
parseTransaction,
|
12
12
|
toTransactionArray,
|
13
13
|
} from '../../utils/transaction/parseTransaction.js'
|
14
|
-
import {
|
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
|
-
|
28
|
-
|
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
|
-
|
35
|
-
|
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
|
-
|
112
|
-
|
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
|
+
}
|
package/chains/celo/types.ts
CHANGED
@@ -75,6 +75,7 @@ export type CeloRpcBlock<
|
|
75
75
|
export type CeloRpcTransaction<TPending extends boolean = boolean> =
|
76
76
|
| RpcTransaction<TPending>
|
77
77
|
| RpcTransactionCIP42<TPending>
|
78
|
+
| RpcTransactionCIP64<TPending>
|
78
79
|
|
79
80
|
export type CeloRpcTransactionReceiptOverrides = {
|
80
81
|
feeCurrency: Address | null
|
@@ -87,10 +88,12 @@ export type CeloRpcTransactionReceipt = RpcTransactionReceipt &
|
|
87
88
|
export type CeloRpcTransactionRequest =
|
88
89
|
| RpcTransactionRequest
|
89
90
|
| RpcTransactionRequestCIP42
|
91
|
+
| RpcTransactionRequestCIP64
|
90
92
|
|
91
93
|
export type CeloTransaction<TPending extends boolean = boolean> =
|
92
94
|
| Transaction<TPending>
|
93
95
|
| TransactionCIP42<TPending>
|
96
|
+
| TransactionCIP64<TPending>
|
94
97
|
|
95
98
|
export type CeloTransactionReceiptOverrides = {
|
96
99
|
feeCurrency: Address | null
|
@@ -103,16 +106,21 @@ export type CeloTransactionReceipt = TransactionReceipt &
|
|
103
106
|
export type CeloTransactionRequest =
|
104
107
|
| TransactionRequest
|
105
108
|
| TransactionRequestCIP42
|
109
|
+
| TransactionRequestCIP64
|
106
110
|
|
107
111
|
export type CeloTransactionSerializable =
|
108
112
|
| TransactionSerializableCIP42
|
113
|
+
| TransactionSerializableCIP64
|
109
114
|
| TransactionSerializable
|
110
115
|
|
111
116
|
export type CeloTransactionSerialized<
|
112
117
|
TType extends CeloTransactionType = 'legacy',
|
113
|
-
> =
|
118
|
+
> =
|
119
|
+
| TransactionSerialized<TType>
|
120
|
+
| TransactionSerializedCIP42
|
121
|
+
| TransactionSerializedCIP64
|
114
122
|
|
115
|
-
export type CeloTransactionType = TransactionType | 'cip42'
|
123
|
+
export type CeloTransactionType = TransactionType | 'cip42' | 'cip64'
|
116
124
|
|
117
125
|
type RpcTransaction<TPending extends boolean = boolean> =
|
118
126
|
RpcTransaction_<TPending> & {
|
@@ -136,6 +144,13 @@ export type RpcTransactionCIP42<TPending extends boolean = boolean> =
|
|
136
144
|
type: '0x7c'
|
137
145
|
}
|
138
146
|
|
147
|
+
export type RpcTransactionCIP64<TPending extends boolean = boolean> =
|
148
|
+
TransactionBase<Quantity, Index, TPending> &
|
149
|
+
FeeValuesEIP1559<Quantity> & {
|
150
|
+
feeCurrency: Address | null
|
151
|
+
type: '0x7b'
|
152
|
+
}
|
153
|
+
|
139
154
|
export type RpcTransactionRequestCIP42 = TransactionRequestBase<
|
140
155
|
Quantity,
|
141
156
|
Index
|
@@ -148,6 +163,18 @@ export type RpcTransactionRequestCIP42 = TransactionRequestBase<
|
|
148
163
|
type?: '0x7c'
|
149
164
|
}
|
150
165
|
|
166
|
+
export type RpcTransactionRequestCIP64 = TransactionRequestBase<
|
167
|
+
Quantity,
|
168
|
+
Index
|
169
|
+
> &
|
170
|
+
Partial<FeeValuesEIP1559<Quantity>> & {
|
171
|
+
accessList?: AccessList
|
172
|
+
feeCurrency?: Address
|
173
|
+
gatewayFee?: undefined
|
174
|
+
gatewayFeeRecipient?: undefined
|
175
|
+
type?: '0x7b'
|
176
|
+
}
|
177
|
+
|
151
178
|
type Transaction<TPending extends boolean = boolean> = Transaction_<
|
152
179
|
bigint,
|
153
180
|
number,
|
@@ -167,6 +194,15 @@ export type TransactionCIP42<TPending extends boolean = boolean> =
|
|
167
194
|
type: 'cip42'
|
168
195
|
}
|
169
196
|
|
197
|
+
export type TransactionCIP64<TPending extends boolean = boolean> =
|
198
|
+
TransactionBase<bigint, number, TPending> &
|
199
|
+
FeeValuesEIP1559 & {
|
200
|
+
feeCurrency: Address | null
|
201
|
+
gatewayFee?: undefined
|
202
|
+
gatewayFeeRecipient?: undefined
|
203
|
+
type: 'cip64'
|
204
|
+
}
|
205
|
+
|
170
206
|
type TransactionRequest = TransactionRequest_ & {
|
171
207
|
feeCurrency?: Address
|
172
208
|
gatewayFee?: bigint
|
@@ -182,6 +218,15 @@ export type TransactionRequestCIP42 = TransactionRequestBase &
|
|
182
218
|
type?: 'cip42'
|
183
219
|
}
|
184
220
|
|
221
|
+
export type TransactionRequestCIP64 = TransactionRequestBase &
|
222
|
+
Partial<FeeValuesEIP1559> & {
|
223
|
+
accessList?: AccessList
|
224
|
+
feeCurrency?: Address
|
225
|
+
gatewayFee?: undefined
|
226
|
+
gatewayFeeRecipient?: undefined
|
227
|
+
type?: 'cip64'
|
228
|
+
}
|
229
|
+
|
185
230
|
export type TransactionSerializableCIP42<
|
186
231
|
TQuantity = bigint,
|
187
232
|
TIndex = number,
|
@@ -196,4 +241,17 @@ export type TransactionSerializableCIP42<
|
|
196
241
|
type?: 'cip42'
|
197
242
|
}
|
198
243
|
|
244
|
+
export type TransactionSerializableCIP64<
|
245
|
+
TQuantity = bigint,
|
246
|
+
TIndex = number,
|
247
|
+
> = TransactionSerializableBase<TQuantity, TIndex> &
|
248
|
+
FeeValuesEIP1559<TQuantity> & {
|
249
|
+
accessList?: AccessList
|
250
|
+
gasPrice?: never
|
251
|
+
feeCurrency?: Address
|
252
|
+
chainId: number
|
253
|
+
type?: 'cip64'
|
254
|
+
}
|
255
|
+
|
199
256
|
export type TransactionSerializedCIP42 = `0x7c${string}`
|
257
|
+
export type TransactionSerializedCIP64 = `0x7b${string}`
|