@apibara/starknet 2.1.0-beta.5 → 2.1.0-beta.51
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/dist/index.cjs +1666 -691
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +5193 -4382
- package/dist/index.d.mts +5193 -4382
- package/dist/index.d.ts +5193 -4382
- package/dist/index.mjs +1660 -686
- package/dist/index.mjs.map +1 -0
- package/dist/parser.cjs +59 -5
- package/dist/parser.cjs.map +1 -0
- package/dist/parser.d.cts +20 -13
- package/dist/parser.d.mts +20 -13
- package/dist/parser.d.ts +20 -13
- package/dist/parser.mjs +58 -6
- package/dist/parser.mjs.map +1 -0
- package/dist/shared/starknet.e649ecb1.d.cts +40 -0
- package/dist/shared/starknet.e649ecb1.d.mts +40 -0
- package/dist/shared/starknet.e649ecb1.d.ts +40 -0
- package/package.json +5 -7
- package/src/abi-wan-helpers.ts +181 -0
- package/src/abi.ts +6 -0
- package/src/block.ts +907 -423
- package/src/common.ts +20 -35
- package/src/event.ts +192 -44
- package/src/filter.ts +240 -239
- package/src/index.ts +3 -0
- package/src/parser.ts +102 -6
- package/src/proto/data.ts +1104 -2
- package/src/proto/filter.ts +76 -2
- package/dist/shared/starknet.2b19268a.d.cts +0 -32
- package/dist/shared/starknet.2b19268a.d.mts +0 -32
- package/dist/shared/starknet.2b19268a.d.ts +0 -32
- package/src/common.test.ts +0 -21
- package/src/filter.test.ts +0 -832
- package/src/helpers.ts +0 -8
- package/src/parser.test.ts +0 -169
package/src/block.ts
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
ArrayCodec,
|
|
3
|
+
BigIntCodec,
|
|
4
|
+
type Codec,
|
|
5
|
+
type CodecType,
|
|
6
|
+
DateCodec,
|
|
7
|
+
type Evaluate,
|
|
8
|
+
MessageCodec,
|
|
9
|
+
NumberCodec,
|
|
10
|
+
OneOfCodec,
|
|
11
|
+
OptionalCodec,
|
|
12
|
+
RequiredCodec,
|
|
13
|
+
StringCodec,
|
|
14
|
+
Uint8ArrayCodec,
|
|
15
|
+
} from "@apibara/protocol/codec";
|
|
3
16
|
import { FieldElement } from "./common";
|
|
4
|
-
import { tag } from "./helpers";
|
|
5
17
|
import * as proto from "./proto";
|
|
6
18
|
|
|
7
19
|
/** Price of a unit of resource.
|
|
@@ -9,101 +21,154 @@ import * as proto from "./proto";
|
|
|
9
21
|
* @prop priceInFri The price in Fri (1e-18 STRK).
|
|
10
22
|
* @prop priceInWei The price in Wei (1e-18 ETH).
|
|
11
23
|
*/
|
|
12
|
-
export const ResourcePrice =
|
|
13
|
-
priceInFri:
|
|
14
|
-
priceInWei:
|
|
24
|
+
export const ResourcePrice = MessageCodec({
|
|
25
|
+
priceInFri: OptionalCodec(FieldElement),
|
|
26
|
+
priceInWei: OptionalCodec(FieldElement),
|
|
15
27
|
});
|
|
16
28
|
|
|
17
|
-
|
|
18
|
-
export const L1DataAvailabilityMode = Schema.transform(
|
|
19
|
-
Schema.Enums(proto.data.L1DataAvailabilityMode),
|
|
20
|
-
Schema.Literal("blob", "calldata", "unknown"),
|
|
21
|
-
{
|
|
22
|
-
decode(value) {
|
|
23
|
-
const enumMap = {
|
|
24
|
-
[proto.data.L1DataAvailabilityMode.CALLDATA]: "calldata",
|
|
25
|
-
[proto.data.L1DataAvailabilityMode.BLOB]: "blob",
|
|
26
|
-
[proto.data.L1DataAvailabilityMode.UNSPECIFIED]: "unknown",
|
|
27
|
-
[proto.data.L1DataAvailabilityMode.UNRECOGNIZED]: "unknown",
|
|
28
|
-
} as const;
|
|
29
|
+
export type ResourcePrice = Readonly<CodecType<typeof ResourcePrice>>;
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
// -----------------------------------------------------
|
|
32
|
+
|
|
33
|
+
/** How data is posted to L1. */
|
|
34
|
+
export const L1DataAvailabilityMode: Codec<
|
|
35
|
+
"blob" | "calldata" | "unknown",
|
|
36
|
+
proto.data.L1DataAvailabilityMode
|
|
37
|
+
> = {
|
|
38
|
+
encode(x) {
|
|
39
|
+
switch (x) {
|
|
40
|
+
case "calldata":
|
|
41
|
+
return proto.data.L1DataAvailabilityMode.CALLDATA;
|
|
42
|
+
case "blob":
|
|
43
|
+
return proto.data.L1DataAvailabilityMode.BLOB;
|
|
44
|
+
case "unknown":
|
|
45
|
+
return proto.data.L1DataAvailabilityMode.UNSPECIFIED;
|
|
46
|
+
default:
|
|
47
|
+
return proto.data.L1DataAvailabilityMode.UNRECOGNIZED;
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
decode(p) {
|
|
51
|
+
const enumMap = {
|
|
52
|
+
[proto.data.L1DataAvailabilityMode.CALLDATA]: "calldata",
|
|
53
|
+
[proto.data.L1DataAvailabilityMode.BLOB]: "blob",
|
|
54
|
+
[proto.data.L1DataAvailabilityMode.UNSPECIFIED]: "unknown",
|
|
55
|
+
[proto.data.L1DataAvailabilityMode.UNRECOGNIZED]: "unknown",
|
|
56
|
+
} as const;
|
|
57
|
+
|
|
58
|
+
return enumMap[p] ?? "unknown";
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export type L1DataAvailabilityMode = CodecType<typeof L1DataAvailabilityMode>;
|
|
63
|
+
|
|
64
|
+
// -----------------------------------------------------
|
|
65
|
+
|
|
66
|
+
/** Status of a transaction. */
|
|
67
|
+
export const TransactionStatus: Codec<
|
|
68
|
+
"unknown" | "succeeded" | "reverted",
|
|
69
|
+
proto.data.TransactionStatus
|
|
70
|
+
> = {
|
|
71
|
+
encode(x) {
|
|
72
|
+
switch (x) {
|
|
73
|
+
case "succeeded":
|
|
74
|
+
return proto.data.TransactionStatus.SUCCEEDED;
|
|
75
|
+
case "reverted":
|
|
76
|
+
return proto.data.TransactionStatus.REVERTED;
|
|
77
|
+
case "unknown":
|
|
78
|
+
return proto.data.TransactionStatus.UNSPECIFIED;
|
|
79
|
+
default:
|
|
80
|
+
return proto.data.TransactionStatus.UNRECOGNIZED;
|
|
81
|
+
}
|
|
35
82
|
},
|
|
36
|
-
)
|
|
83
|
+
decode(p) {
|
|
84
|
+
const enumMap = {
|
|
85
|
+
[proto.data.TransactionStatus.SUCCEEDED]: "succeeded",
|
|
86
|
+
[proto.data.TransactionStatus.REVERTED]: "reverted",
|
|
87
|
+
[proto.data.TransactionStatus.UNSPECIFIED]: "unknown",
|
|
88
|
+
[proto.data.TransactionStatus.UNRECOGNIZED]: "unknown",
|
|
89
|
+
} as const;
|
|
90
|
+
|
|
91
|
+
return enumMap[p] ?? "unknown";
|
|
92
|
+
},
|
|
93
|
+
};
|
|
37
94
|
|
|
38
|
-
export
|
|
39
|
-
Schema.Enums(proto.data.TransactionStatus),
|
|
40
|
-
Schema.Literal("unknown", "succeeded", "reverted"),
|
|
41
|
-
{
|
|
42
|
-
decode(value) {
|
|
43
|
-
const enumMap = {
|
|
44
|
-
[proto.data.TransactionStatus.SUCCEEDED]: "succeeded",
|
|
45
|
-
[proto.data.TransactionStatus.REVERTED]: "reverted",
|
|
46
|
-
[proto.data.TransactionStatus.UNSPECIFIED]: "unknown",
|
|
47
|
-
[proto.data.TransactionStatus.UNRECOGNIZED]: "unknown",
|
|
48
|
-
} as const;
|
|
95
|
+
export type TransactionStatus = CodecType<typeof TransactionStatus>;
|
|
49
96
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
97
|
+
// -----------------------------------------------------
|
|
98
|
+
|
|
99
|
+
/** 128-bit unsigned integer. */
|
|
100
|
+
export const U128: Codec<bigint, proto.data.Uint128> = {
|
|
101
|
+
// TODO: double check if this is correct
|
|
102
|
+
encode(x) {
|
|
103
|
+
const low = x.toString(16).padStart(16, "0");
|
|
104
|
+
const high = (x >> 128n).toString(16).padStart(16, "0");
|
|
105
|
+
return { x0: BigInt(`0x${low}`), x1: BigInt(`0x${high}`) };
|
|
55
106
|
},
|
|
56
|
-
)
|
|
107
|
+
decode(p) {
|
|
108
|
+
const low = (p.x0 ?? 0n).toString(16).padStart(16, "0");
|
|
109
|
+
const high = (p.x1 ?? 0n).toString(16).padStart(16, "0");
|
|
110
|
+
return BigInt(`0x${low}${high}`);
|
|
111
|
+
},
|
|
112
|
+
};
|
|
57
113
|
|
|
58
|
-
export type
|
|
114
|
+
export type U128 = CodecType<typeof U128>;
|
|
59
115
|
|
|
60
|
-
|
|
61
|
-
Schema.Struct({
|
|
62
|
-
x0: Schema.BigIntFromSelf,
|
|
63
|
-
x1: Schema.BigIntFromSelf,
|
|
64
|
-
}),
|
|
65
|
-
Schema.BigIntFromSelf,
|
|
66
|
-
{
|
|
67
|
-
decode(value) {
|
|
68
|
-
const low = value.x0.toString(16).padStart(16, "0");
|
|
69
|
-
const high = value.x1.toString(16).padStart(16, "0");
|
|
70
|
-
return BigInt(`0x${low}${high}`);
|
|
71
|
-
},
|
|
72
|
-
encode(value) {
|
|
73
|
-
throw new Error("encode: not implemented");
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
);
|
|
116
|
+
// -----------------------------------------------------
|
|
77
117
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
118
|
+
/** Resource bounds. */
|
|
119
|
+
export const ResourceBounds = MessageCodec({
|
|
120
|
+
maxAmount: RequiredCodec(BigIntCodec),
|
|
121
|
+
maxPricePerUnit: RequiredCodec(U128),
|
|
81
122
|
});
|
|
82
123
|
|
|
83
|
-
export
|
|
84
|
-
l1Gas: ResourceBounds,
|
|
85
|
-
l2Gas: ResourceBounds,
|
|
86
|
-
});
|
|
124
|
+
export type ResourceBounds = Readonly<CodecType<typeof ResourceBounds>>;
|
|
87
125
|
|
|
88
|
-
|
|
89
|
-
Schema.Enums(proto.data.DataAvailabilityMode),
|
|
90
|
-
Schema.Literal("l1", "l2", "unknown"),
|
|
91
|
-
{
|
|
92
|
-
decode(value) {
|
|
93
|
-
const enumMap = {
|
|
94
|
-
[proto.data.DataAvailabilityMode.L1]: "l1",
|
|
95
|
-
[proto.data.DataAvailabilityMode.L2]: "l2",
|
|
96
|
-
[proto.data.DataAvailabilityMode.UNSPECIFIED]: "unknown",
|
|
97
|
-
[proto.data.DataAvailabilityMode.UNRECOGNIZED]: "unknown",
|
|
98
|
-
} as const;
|
|
126
|
+
// -----------------------------------------------------
|
|
99
127
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
128
|
+
/** Resource bounds mapping. */
|
|
129
|
+
export const ResourceBoundsMapping = MessageCodec({
|
|
130
|
+
l1Gas: RequiredCodec(ResourceBounds),
|
|
131
|
+
l2Gas: RequiredCodec(ResourceBounds),
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
export type ResourceBoundsMapping = Readonly<
|
|
135
|
+
CodecType<typeof ResourceBoundsMapping>
|
|
136
|
+
>;
|
|
137
|
+
|
|
138
|
+
// -----------------------------------------------------
|
|
139
|
+
|
|
140
|
+
/** Data availability mode. */
|
|
141
|
+
export const DataAvailabilityMode: Codec<
|
|
142
|
+
"l1" | "l2" | "unknown",
|
|
143
|
+
proto.data.DataAvailabilityMode
|
|
144
|
+
> = {
|
|
145
|
+
encode(x) {
|
|
146
|
+
switch (x) {
|
|
147
|
+
case "l1":
|
|
148
|
+
return proto.data.DataAvailabilityMode.L1;
|
|
149
|
+
case "l2":
|
|
150
|
+
return proto.data.DataAvailabilityMode.L2;
|
|
151
|
+
case "unknown":
|
|
152
|
+
return proto.data.DataAvailabilityMode.UNSPECIFIED;
|
|
153
|
+
default:
|
|
154
|
+
return proto.data.DataAvailabilityMode.UNRECOGNIZED;
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
decode(p) {
|
|
158
|
+
const enumMap = {
|
|
159
|
+
[proto.data.DataAvailabilityMode.L1]: "l1",
|
|
160
|
+
[proto.data.DataAvailabilityMode.L2]: "l2",
|
|
161
|
+
[proto.data.DataAvailabilityMode.UNSPECIFIED]: "unknown",
|
|
162
|
+
[proto.data.DataAvailabilityMode.UNRECOGNIZED]: "unknown",
|
|
163
|
+
} as const;
|
|
164
|
+
|
|
165
|
+
return enumMap[p] ?? "unknown";
|
|
105
166
|
},
|
|
106
|
-
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
export type DataAvailabilityMode = CodecType<typeof DataAvailabilityMode>;
|
|
170
|
+
|
|
171
|
+
// -----------------------------------------------------
|
|
107
172
|
|
|
108
173
|
/** Starknet block header.
|
|
109
174
|
*
|
|
@@ -117,21 +182,25 @@ export const DataAvailabilityMode = Schema.transform(
|
|
|
117
182
|
* @prop l1GasPrice Calldata gas price.
|
|
118
183
|
* @prop l1DataGasPrice Blob gas price.
|
|
119
184
|
* @prop l1DataAvailabilityMode How data is posted to L1.
|
|
185
|
+
* @prop l2GasPrice L2 gas price.
|
|
120
186
|
*/
|
|
121
|
-
export const BlockHeader =
|
|
122
|
-
blockHash:
|
|
123
|
-
parentBlockHash: FieldElement,
|
|
124
|
-
blockNumber:
|
|
125
|
-
sequencerAddress: FieldElement,
|
|
126
|
-
newRoot:
|
|
127
|
-
timestamp:
|
|
128
|
-
starknetVersion:
|
|
129
|
-
l1GasPrice: ResourcePrice,
|
|
130
|
-
l1DataGasPrice: ResourcePrice,
|
|
131
|
-
l1DataAvailabilityMode: L1DataAvailabilityMode,
|
|
187
|
+
export const BlockHeader = MessageCodec({
|
|
188
|
+
blockHash: OptionalCodec(FieldElement),
|
|
189
|
+
parentBlockHash: RequiredCodec(FieldElement),
|
|
190
|
+
blockNumber: RequiredCodec(BigIntCodec),
|
|
191
|
+
sequencerAddress: RequiredCodec(FieldElement),
|
|
192
|
+
newRoot: OptionalCodec(FieldElement),
|
|
193
|
+
timestamp: RequiredCodec(DateCodec),
|
|
194
|
+
starknetVersion: RequiredCodec(StringCodec),
|
|
195
|
+
l1GasPrice: RequiredCodec(ResourcePrice),
|
|
196
|
+
l1DataGasPrice: RequiredCodec(ResourcePrice),
|
|
197
|
+
l1DataAvailabilityMode: RequiredCodec(L1DataAvailabilityMode),
|
|
198
|
+
l2GasPrice: OptionalCodec(ResourcePrice),
|
|
132
199
|
});
|
|
133
200
|
|
|
134
|
-
export type BlockHeader = typeof BlockHeader
|
|
201
|
+
export type BlockHeader = Readonly<CodecType<typeof BlockHeader>>;
|
|
202
|
+
|
|
203
|
+
// -----------------------------------------------------
|
|
135
204
|
|
|
136
205
|
/** Transaction metadata.
|
|
137
206
|
*
|
|
@@ -141,178 +210,327 @@ export type BlockHeader = typeof BlockHeader.Type;
|
|
|
141
210
|
* @prop transactionHash The transaction hash.
|
|
142
211
|
* @prop transactionStatus The transaction status.
|
|
143
212
|
*/
|
|
144
|
-
export const TransactionMeta =
|
|
145
|
-
transactionIndex:
|
|
146
|
-
transactionHash: FieldElement,
|
|
147
|
-
transactionStatus: TransactionStatus,
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
export type TransactionMeta = typeof TransactionMeta
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
213
|
+
export const TransactionMeta = MessageCodec({
|
|
214
|
+
transactionIndex: RequiredCodec(NumberCodec),
|
|
215
|
+
transactionHash: RequiredCodec(FieldElement),
|
|
216
|
+
transactionStatus: RequiredCodec(TransactionStatus),
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
export type TransactionMeta = Readonly<CodecType<typeof TransactionMeta>>;
|
|
220
|
+
|
|
221
|
+
// -----------------------------------------------------
|
|
222
|
+
|
|
223
|
+
/** Invoke transaction v0.
|
|
224
|
+
*
|
|
225
|
+
* @prop maxFee The maximum fee.
|
|
226
|
+
* @prop signature The signature.
|
|
227
|
+
* @prop contractAddress The contract address.
|
|
228
|
+
* @prop entryPointSelector The entry point selector.
|
|
229
|
+
* @prop calldata The calldata.
|
|
230
|
+
*/
|
|
231
|
+
export const InvokeTransactionV0 = MessageCodec({
|
|
232
|
+
maxFee: RequiredCodec(FieldElement),
|
|
233
|
+
signature: ArrayCodec(FieldElement),
|
|
234
|
+
contractAddress: RequiredCodec(FieldElement),
|
|
235
|
+
entryPointSelector: RequiredCodec(FieldElement),
|
|
236
|
+
calldata: ArrayCodec(FieldElement),
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
export type InvokeTransactionV0 = Readonly<
|
|
240
|
+
CodecType<typeof InvokeTransactionV0>
|
|
241
|
+
>;
|
|
242
|
+
|
|
243
|
+
// -----------------------------------------------------
|
|
244
|
+
|
|
245
|
+
/** Invoke transaction v1.
|
|
246
|
+
*
|
|
247
|
+
* @prop senderAddress The sender address.
|
|
248
|
+
* @prop calldata The calldata.
|
|
249
|
+
* @prop maxFee The maximum fee.
|
|
250
|
+
* @prop signature The signature.
|
|
251
|
+
* @prop nonce The nonce.
|
|
252
|
+
*/
|
|
253
|
+
export const InvokeTransactionV1 = MessageCodec({
|
|
254
|
+
senderAddress: RequiredCodec(FieldElement),
|
|
255
|
+
calldata: ArrayCodec(FieldElement),
|
|
256
|
+
maxFee: RequiredCodec(FieldElement),
|
|
257
|
+
signature: ArrayCodec(FieldElement),
|
|
258
|
+
nonce: RequiredCodec(FieldElement),
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
export type InvokeTransactionV1 = Readonly<
|
|
262
|
+
CodecType<typeof InvokeTransactionV1>
|
|
263
|
+
>;
|
|
264
|
+
|
|
265
|
+
// -----------------------------------------------------
|
|
266
|
+
|
|
267
|
+
/** Invoke transaction v3.
|
|
268
|
+
*
|
|
269
|
+
* @prop senderAddress The sender address.
|
|
270
|
+
* @prop calldata The calldata.
|
|
271
|
+
* @prop signature The signature.
|
|
272
|
+
* @prop nonce The nonce.
|
|
273
|
+
* @prop resourceBounds The resource bounds.
|
|
274
|
+
* @prop tip The tip.
|
|
275
|
+
* @prop paymasterData The paymaster data.
|
|
276
|
+
* @prop accountDeploymentData The account deployment data.
|
|
277
|
+
* @prop nonceDataAvailabilityMode How nonce data is posted to L1.
|
|
278
|
+
* @prop feeDataAvailabilityMode How fee data is posted to L1.
|
|
279
|
+
*/
|
|
280
|
+
export const InvokeTransactionV3 = MessageCodec({
|
|
281
|
+
senderAddress: RequiredCodec(FieldElement),
|
|
282
|
+
calldata: ArrayCodec(FieldElement),
|
|
283
|
+
signature: ArrayCodec(FieldElement),
|
|
284
|
+
nonce: RequiredCodec(FieldElement),
|
|
285
|
+
resourceBounds: RequiredCodec(ResourceBoundsMapping),
|
|
286
|
+
tip: RequiredCodec(BigIntCodec),
|
|
287
|
+
paymasterData: ArrayCodec(FieldElement),
|
|
288
|
+
accountDeploymentData: ArrayCodec(FieldElement),
|
|
289
|
+
nonceDataAvailabilityMode: RequiredCodec(DataAvailabilityMode),
|
|
290
|
+
feeDataAvailabilityMode: RequiredCodec(DataAvailabilityMode),
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
export type InvokeTransactionV3 = Readonly<
|
|
294
|
+
CodecType<typeof InvokeTransactionV3>
|
|
295
|
+
>;
|
|
296
|
+
|
|
297
|
+
// -----------------------------------------------------
|
|
298
|
+
|
|
299
|
+
/** L1 handler transaction.
|
|
300
|
+
*
|
|
301
|
+
* @prop nonce The nonce.
|
|
302
|
+
* @prop contractAddress The contract address.
|
|
303
|
+
* @prop entryPointSelector The entry point selector.
|
|
304
|
+
* @prop calldata The calldata.
|
|
305
|
+
*/
|
|
306
|
+
export const L1HandlerTransaction = MessageCodec({
|
|
307
|
+
nonce: RequiredCodec(BigIntCodec),
|
|
308
|
+
contractAddress: RequiredCodec(FieldElement),
|
|
309
|
+
entryPointSelector: RequiredCodec(FieldElement),
|
|
310
|
+
calldata: ArrayCodec(FieldElement),
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
export type L1HandlerTransaction = Readonly<
|
|
314
|
+
CodecType<typeof L1HandlerTransaction>
|
|
315
|
+
>;
|
|
316
|
+
|
|
317
|
+
// -----------------------------------------------------
|
|
318
|
+
|
|
319
|
+
/** Deploy transaction.
|
|
320
|
+
*
|
|
321
|
+
* @prop contractAddressSalt The contract address salt.
|
|
322
|
+
* @prop constructorCalldata The constructor calldata.
|
|
323
|
+
* @prop classHash The class hash.
|
|
324
|
+
*/
|
|
325
|
+
export const DeployTransaction = MessageCodec({
|
|
326
|
+
contractAddressSalt: RequiredCodec(FieldElement),
|
|
327
|
+
constructorCalldata: ArrayCodec(FieldElement),
|
|
328
|
+
classHash: RequiredCodec(FieldElement),
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
export type DeployTransaction = Readonly<CodecType<typeof DeployTransaction>>;
|
|
332
|
+
|
|
333
|
+
// -----------------------------------------------------
|
|
334
|
+
|
|
335
|
+
/** Declare transaction v0.
|
|
336
|
+
*
|
|
337
|
+
* @prop senderAddress The sender address.
|
|
338
|
+
* @prop maxFee The maximum fee.
|
|
339
|
+
* @prop signature The signature.
|
|
340
|
+
* @prop classHash The class hash.
|
|
341
|
+
*/
|
|
342
|
+
export const DeclareTransactionV0 = MessageCodec({
|
|
343
|
+
senderAddress: RequiredCodec(FieldElement),
|
|
344
|
+
maxFee: RequiredCodec(FieldElement),
|
|
345
|
+
signature: ArrayCodec(FieldElement),
|
|
346
|
+
classHash: RequiredCodec(FieldElement),
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
export type DeclareTransactionV0 = Readonly<
|
|
350
|
+
CodecType<typeof DeclareTransactionV0>
|
|
351
|
+
>;
|
|
352
|
+
|
|
353
|
+
// -----------------------------------------------------
|
|
354
|
+
|
|
355
|
+
/** Declare transaction v1.
|
|
356
|
+
*
|
|
357
|
+
* @prop senderAddress The sender address.
|
|
358
|
+
* @prop maxFee The maximum fee.
|
|
359
|
+
* @prop signature The signature.
|
|
360
|
+
* @prop nonce The nonce.
|
|
361
|
+
* @prop classHash The class hash.
|
|
362
|
+
*/
|
|
363
|
+
export const DeclareTransactionV1 = MessageCodec({
|
|
364
|
+
senderAddress: RequiredCodec(FieldElement),
|
|
365
|
+
maxFee: RequiredCodec(FieldElement),
|
|
366
|
+
signature: ArrayCodec(FieldElement),
|
|
367
|
+
nonce: RequiredCodec(FieldElement),
|
|
368
|
+
classHash: RequiredCodec(FieldElement),
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
export type DeclareTransactionV1 = Readonly<
|
|
372
|
+
CodecType<typeof DeclareTransactionV1>
|
|
373
|
+
>;
|
|
374
|
+
|
|
375
|
+
// -----------------------------------------------------
|
|
376
|
+
|
|
377
|
+
/** Declare transaction v2.
|
|
378
|
+
*
|
|
379
|
+
* @prop senderAddress The sender address.
|
|
380
|
+
* @prop compiledClassHash The compiled class hash.
|
|
381
|
+
* @prop maxFee The maximum fee.
|
|
382
|
+
* @prop signature The signature.
|
|
383
|
+
* @prop nonce The nonce.
|
|
384
|
+
* @prop classHash The class hash.
|
|
385
|
+
*/
|
|
386
|
+
export const DeclareTransactionV2 = MessageCodec({
|
|
387
|
+
senderAddress: RequiredCodec(FieldElement),
|
|
388
|
+
compiledClassHash: RequiredCodec(FieldElement),
|
|
389
|
+
maxFee: RequiredCodec(FieldElement),
|
|
390
|
+
signature: ArrayCodec(FieldElement),
|
|
391
|
+
nonce: RequiredCodec(FieldElement),
|
|
392
|
+
classHash: RequiredCodec(FieldElement),
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
export type DeclareTransactionV2 = Readonly<
|
|
396
|
+
CodecType<typeof DeclareTransactionV2>
|
|
397
|
+
>;
|
|
398
|
+
|
|
399
|
+
// -----------------------------------------------------
|
|
400
|
+
|
|
401
|
+
/** Declare transaction v3.
|
|
402
|
+
*
|
|
403
|
+
* @prop senderAddress The sender address.
|
|
404
|
+
* @prop compiledClassHash The compiled class hash.
|
|
405
|
+
* @prop signature The signature.
|
|
406
|
+
* @prop nonce The nonce.
|
|
407
|
+
* @prop classHash The class hash.
|
|
408
|
+
* @prop resourceBounds The resource bounds.
|
|
409
|
+
* @prop tip The tip.
|
|
410
|
+
* @prop paymasterData The paymaster data.
|
|
411
|
+
* @prop nonceDataAvailabilityMode How nonce data is posted to L1.
|
|
412
|
+
* @prop feeDataAvailabilityMode How fee data is posted to L1.
|
|
413
|
+
*/
|
|
414
|
+
export const DeclareTransactionV3 = MessageCodec({
|
|
415
|
+
senderAddress: RequiredCodec(FieldElement),
|
|
416
|
+
compiledClassHash: RequiredCodec(FieldElement),
|
|
417
|
+
signature: ArrayCodec(FieldElement),
|
|
418
|
+
nonce: RequiredCodec(FieldElement),
|
|
419
|
+
classHash: RequiredCodec(FieldElement),
|
|
420
|
+
resourceBounds: RequiredCodec(ResourceBoundsMapping),
|
|
421
|
+
tip: RequiredCodec(BigIntCodec),
|
|
422
|
+
paymasterData: ArrayCodec(FieldElement),
|
|
423
|
+
accountDeploymentData: ArrayCodec(FieldElement),
|
|
424
|
+
nonceDataAvailabilityMode: RequiredCodec(DataAvailabilityMode),
|
|
425
|
+
feeDataAvailabilityMode: RequiredCodec(DataAvailabilityMode),
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
export type DeclareTransactionV3 = Readonly<
|
|
429
|
+
CodecType<typeof DeclareTransactionV3>
|
|
430
|
+
>;
|
|
431
|
+
|
|
432
|
+
// -----------------------------------------------------
|
|
433
|
+
|
|
434
|
+
/** Deploy account transaction v1.
|
|
435
|
+
*
|
|
436
|
+
* @prop maxFee The maximum fee.
|
|
437
|
+
* @prop signature The signature.
|
|
438
|
+
* @prop nonce The nonce.
|
|
439
|
+
* @prop contractAddressSalt The contract address salt.
|
|
440
|
+
* @prop constructorCalldata The constructor calldata.
|
|
441
|
+
* @prop classHash The class hash.
|
|
442
|
+
*/
|
|
443
|
+
export const DeployAccountTransactionV1 = MessageCodec({
|
|
444
|
+
maxFee: RequiredCodec(FieldElement),
|
|
445
|
+
signature: ArrayCodec(FieldElement),
|
|
446
|
+
nonce: RequiredCodec(FieldElement),
|
|
447
|
+
contractAddressSalt: RequiredCodec(FieldElement),
|
|
448
|
+
constructorCalldata: ArrayCodec(FieldElement),
|
|
449
|
+
classHash: RequiredCodec(FieldElement),
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
export type DeployAccountTransactionV1 = Readonly<
|
|
453
|
+
CodecType<typeof DeployAccountTransactionV1>
|
|
454
|
+
>;
|
|
455
|
+
|
|
456
|
+
// -----------------------------------------------------
|
|
457
|
+
|
|
458
|
+
/** Deploy account transaction v3.
|
|
459
|
+
*
|
|
460
|
+
* @prop signature The signature.
|
|
461
|
+
* @prop nonce The nonce.
|
|
462
|
+
* @prop contractAddressSalt The contract address salt.
|
|
463
|
+
* @prop constructorCalldata The constructor calldata.
|
|
464
|
+
* @prop classHash The class hash.
|
|
465
|
+
* @prop resourceBounds The resource bounds.
|
|
466
|
+
* @prop tip The tip.
|
|
467
|
+
* @prop paymasterData The paymaster data.
|
|
468
|
+
* @prop nonceDataAvailabilityMode How nonce data is posted to L1.
|
|
469
|
+
* @prop feeDataAvailabilityMode How fee data is posted to L1.
|
|
470
|
+
*/
|
|
471
|
+
export const DeployAccountTransactionV3 = MessageCodec({
|
|
472
|
+
signature: ArrayCodec(FieldElement),
|
|
473
|
+
nonce: RequiredCodec(FieldElement),
|
|
474
|
+
contractAddressSalt: RequiredCodec(FieldElement),
|
|
475
|
+
constructorCalldata: ArrayCodec(FieldElement),
|
|
476
|
+
classHash: RequiredCodec(FieldElement),
|
|
477
|
+
resourceBounds: RequiredCodec(ResourceBoundsMapping),
|
|
478
|
+
tip: RequiredCodec(BigIntCodec),
|
|
479
|
+
paymasterData: ArrayCodec(FieldElement),
|
|
480
|
+
nonceDataAvailabilityMode: RequiredCodec(DataAvailabilityMode),
|
|
481
|
+
feeDataAvailabilityMode: RequiredCodec(DataAvailabilityMode),
|
|
285
482
|
});
|
|
286
483
|
|
|
484
|
+
export type DeployAccountTransactionV3 = Readonly<
|
|
485
|
+
CodecType<typeof DeployAccountTransactionV3>
|
|
486
|
+
>;
|
|
487
|
+
|
|
488
|
+
// -----------------------------------------------------
|
|
489
|
+
|
|
287
490
|
/** A transaction.
|
|
288
491
|
*
|
|
289
|
-
* @prop
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
492
|
+
* @prop filterIds The filter IDs.
|
|
493
|
+
* @prop meta The transaction metadata.
|
|
494
|
+
*/
|
|
495
|
+
export const Transaction = MessageCodec({
|
|
496
|
+
filterIds: ArrayCodec(NumberCodec),
|
|
497
|
+
meta: RequiredCodec(TransactionMeta),
|
|
498
|
+
transaction: RequiredCodec(
|
|
499
|
+
OneOfCodec({
|
|
500
|
+
invokeV0: InvokeTransactionV0,
|
|
501
|
+
invokeV1: InvokeTransactionV1,
|
|
502
|
+
invokeV3: InvokeTransactionV3,
|
|
503
|
+
l1Handler: L1HandlerTransaction,
|
|
504
|
+
deploy: DeployTransaction,
|
|
505
|
+
declareV0: DeclareTransactionV0,
|
|
506
|
+
declareV1: DeclareTransactionV1,
|
|
507
|
+
declareV2: DeclareTransactionV2,
|
|
508
|
+
declareV3: DeclareTransactionV3,
|
|
509
|
+
deployAccountV1: DeployAccountTransactionV1,
|
|
510
|
+
deployAccountV3: DeployAccountTransactionV3,
|
|
511
|
+
}),
|
|
306
512
|
),
|
|
307
513
|
});
|
|
308
514
|
|
|
309
|
-
export type Transaction = typeof Transaction
|
|
515
|
+
export type Transaction = Readonly<CodecType<typeof Transaction>>;
|
|
516
|
+
|
|
517
|
+
// -----------------------------------------------------
|
|
310
518
|
|
|
311
|
-
export const PriceUnit
|
|
312
|
-
Schema.Enums(proto.data.PriceUnit),
|
|
313
|
-
Schema.Literal("wei", "fri", "unknown"),
|
|
519
|
+
export const PriceUnit: Codec<"wei" | "fri" | "unknown", proto.data.PriceUnit> =
|
|
314
520
|
{
|
|
315
|
-
|
|
521
|
+
encode(x) {
|
|
522
|
+
switch (x) {
|
|
523
|
+
case "wei":
|
|
524
|
+
return proto.data.PriceUnit.WEI;
|
|
525
|
+
case "fri":
|
|
526
|
+
return proto.data.PriceUnit.FRI;
|
|
527
|
+
case "unknown":
|
|
528
|
+
return proto.data.PriceUnit.UNSPECIFIED;
|
|
529
|
+
default:
|
|
530
|
+
return proto.data.PriceUnit.UNRECOGNIZED;
|
|
531
|
+
}
|
|
532
|
+
},
|
|
533
|
+
decode(p) {
|
|
316
534
|
const enumMap = {
|
|
317
535
|
[proto.data.PriceUnit.WEI]: "wei",
|
|
318
536
|
[proto.data.PriceUnit.FRI]: "fri",
|
|
@@ -320,112 +538,163 @@ export const PriceUnit = Schema.transform(
|
|
|
320
538
|
[proto.data.PriceUnit.UNRECOGNIZED]: "unknown",
|
|
321
539
|
} as const;
|
|
322
540
|
|
|
323
|
-
return enumMap[
|
|
324
|
-
},
|
|
325
|
-
encode(value) {
|
|
326
|
-
throw new Error("encode: not implemented");
|
|
541
|
+
return enumMap[p] ?? "unknown";
|
|
327
542
|
},
|
|
328
|
-
}
|
|
329
|
-
);
|
|
543
|
+
};
|
|
330
544
|
|
|
331
|
-
export
|
|
332
|
-
amount: FieldElement,
|
|
333
|
-
unit: PriceUnit,
|
|
334
|
-
});
|
|
545
|
+
export type PriceUnit = CodecType<typeof PriceUnit>;
|
|
335
546
|
|
|
336
|
-
|
|
337
|
-
steps: Schema.BigIntFromSelf,
|
|
338
|
-
memoryHoles: Schema.optional(Schema.BigIntFromSelf),
|
|
339
|
-
rangeCheckBuiltinApplications: Schema.optional(Schema.BigIntFromSelf),
|
|
340
|
-
pedersenBuiltinApplications: Schema.optional(Schema.BigIntFromSelf),
|
|
341
|
-
poseidonBuiltinApplications: Schema.optional(Schema.BigIntFromSelf),
|
|
342
|
-
ecOpBuiltinApplications: Schema.optional(Schema.BigIntFromSelf),
|
|
343
|
-
ecdsaBuiltinApplications: Schema.optional(Schema.BigIntFromSelf),
|
|
344
|
-
bitwiseBuiltinApplications: Schema.optional(Schema.BigIntFromSelf),
|
|
345
|
-
keccakBuiltinApplications: Schema.optional(Schema.BigIntFromSelf),
|
|
346
|
-
segmentArenaBuiltin: Schema.optional(Schema.BigIntFromSelf),
|
|
347
|
-
});
|
|
547
|
+
// -----------------------------------------------------
|
|
348
548
|
|
|
349
|
-
export const
|
|
350
|
-
|
|
351
|
-
|
|
549
|
+
export const FeePayment = MessageCodec({
|
|
550
|
+
amount: RequiredCodec(FieldElement),
|
|
551
|
+
unit: RequiredCodec(PriceUnit),
|
|
352
552
|
});
|
|
353
553
|
|
|
354
|
-
export
|
|
355
|
-
|
|
356
|
-
|
|
554
|
+
export type FeePayment = Readonly<CodecType<typeof FeePayment>>;
|
|
555
|
+
|
|
556
|
+
// -----------------------------------------------------
|
|
557
|
+
|
|
558
|
+
export const ComputationResources = MessageCodec({
|
|
559
|
+
steps: RequiredCodec(BigIntCodec),
|
|
560
|
+
memoryHoles: OptionalCodec(BigIntCodec),
|
|
561
|
+
rangeCheckBuiltinApplications: OptionalCodec(BigIntCodec),
|
|
562
|
+
pedersenBuiltinApplications: OptionalCodec(BigIntCodec),
|
|
563
|
+
poseidonBuiltinApplications: OptionalCodec(BigIntCodec),
|
|
564
|
+
ecOpBuiltinApplications: OptionalCodec(BigIntCodec),
|
|
565
|
+
ecdsaBuiltinApplications: OptionalCodec(BigIntCodec),
|
|
566
|
+
bitwiseBuiltinApplications: OptionalCodec(BigIntCodec),
|
|
567
|
+
keccakBuiltinApplications: OptionalCodec(BigIntCodec),
|
|
568
|
+
segmentArenaBuiltin: OptionalCodec(BigIntCodec),
|
|
357
569
|
});
|
|
358
570
|
|
|
359
|
-
export
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
});
|
|
571
|
+
export type ComputationResources = Readonly<
|
|
572
|
+
CodecType<typeof ComputationResources>
|
|
573
|
+
>;
|
|
363
574
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
575
|
+
// -----------------------------------------------------
|
|
576
|
+
|
|
577
|
+
export const DataAvailabilityResources = MessageCodec({
|
|
578
|
+
l1Gas: RequiredCodec(BigIntCodec),
|
|
579
|
+
l1DataGas: RequiredCodec(BigIntCodec),
|
|
369
580
|
});
|
|
370
581
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
582
|
+
export type DataAvailabilityResources = Readonly<
|
|
583
|
+
CodecType<typeof DataAvailabilityResources>
|
|
584
|
+
>;
|
|
585
|
+
|
|
586
|
+
// -----------------------------------------------------
|
|
587
|
+
|
|
588
|
+
export const ExecutionResources = MessageCodec({
|
|
589
|
+
computation: RequiredCodec(ComputationResources),
|
|
590
|
+
dataAvailability: RequiredCodec(DataAvailabilityResources),
|
|
378
591
|
});
|
|
379
592
|
|
|
380
|
-
export
|
|
381
|
-
|
|
382
|
-
|
|
593
|
+
export type ExecutionResources = Readonly<CodecType<typeof ExecutionResources>>;
|
|
594
|
+
|
|
595
|
+
// -----------------------------------------------------
|
|
596
|
+
|
|
597
|
+
export const ExecutionSucceeded = MessageCodec({});
|
|
598
|
+
|
|
599
|
+
export type ExecutionSucceeded = Readonly<CodecType<typeof ExecutionSucceeded>>;
|
|
600
|
+
|
|
601
|
+
// -----------------------------------------------------
|
|
602
|
+
|
|
603
|
+
export const ExecutionReverted = MessageCodec({
|
|
604
|
+
reason: OptionalCodec(StringCodec),
|
|
383
605
|
});
|
|
384
606
|
|
|
385
|
-
export
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
607
|
+
export type ExecutionReverted = Readonly<CodecType<typeof ExecutionReverted>>;
|
|
608
|
+
|
|
609
|
+
// -----------------------------------------------------
|
|
610
|
+
|
|
611
|
+
export const TransactionReceiptMeta = MessageCodec({
|
|
612
|
+
transactionIndex: RequiredCodec(NumberCodec),
|
|
613
|
+
transactionHash: RequiredCodec(FieldElement),
|
|
614
|
+
actualFee: RequiredCodec(FeePayment),
|
|
615
|
+
executionResources: RequiredCodec(ExecutionResources),
|
|
616
|
+
executionResult: RequiredCodec(
|
|
617
|
+
OneOfCodec({
|
|
618
|
+
succeeded: ExecutionSucceeded,
|
|
619
|
+
reverted: ExecutionReverted,
|
|
620
|
+
}),
|
|
621
|
+
),
|
|
390
622
|
});
|
|
391
623
|
|
|
392
|
-
export
|
|
393
|
-
|
|
394
|
-
|
|
624
|
+
export type TransactionReceiptMeta = Readonly<
|
|
625
|
+
CodecType<typeof TransactionReceiptMeta>
|
|
626
|
+
>;
|
|
627
|
+
|
|
628
|
+
// -----------------------------------------------------
|
|
629
|
+
|
|
630
|
+
export const InvokeTransactionReceipt = MessageCodec({});
|
|
631
|
+
|
|
632
|
+
export type InvokeTransactionReceipt = Readonly<
|
|
633
|
+
CodecType<typeof InvokeTransactionReceipt>
|
|
634
|
+
>;
|
|
635
|
+
|
|
636
|
+
// -----------------------------------------------------
|
|
637
|
+
|
|
638
|
+
export const L1HandlerTransactionReceipt = MessageCodec({
|
|
639
|
+
messageHash: RequiredCodec(Uint8ArrayCodec),
|
|
395
640
|
});
|
|
396
641
|
|
|
397
|
-
export
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
642
|
+
export type L1HandlerTransactionReceipt = Readonly<
|
|
643
|
+
CodecType<typeof L1HandlerTransactionReceipt>
|
|
644
|
+
>;
|
|
645
|
+
|
|
646
|
+
// -----------------------------------------------------
|
|
647
|
+
|
|
648
|
+
export const DeclareTransactionReceipt = MessageCodec({});
|
|
649
|
+
|
|
650
|
+
export type DeclareTransactionReceipt = Readonly<
|
|
651
|
+
CodecType<typeof DeclareTransactionReceipt>
|
|
652
|
+
>;
|
|
653
|
+
|
|
654
|
+
// -----------------------------------------------------
|
|
655
|
+
|
|
656
|
+
export const DeployTransactionReceipt = MessageCodec({
|
|
657
|
+
contractAddress: RequiredCodec(FieldElement),
|
|
402
658
|
});
|
|
403
659
|
|
|
404
|
-
export
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
660
|
+
export type DeployTransactionReceipt = Readonly<
|
|
661
|
+
CodecType<typeof DeployTransactionReceipt>
|
|
662
|
+
>;
|
|
663
|
+
|
|
664
|
+
// -----------------------------------------------------
|
|
665
|
+
|
|
666
|
+
export const DeployAccountTransactionReceipt = MessageCodec({
|
|
667
|
+
contractAddress: RequiredCodec(FieldElement),
|
|
409
668
|
});
|
|
410
669
|
|
|
670
|
+
export type DeployAccountTransactionReceipt = Readonly<
|
|
671
|
+
CodecType<typeof DeployAccountTransactionReceipt>
|
|
672
|
+
>;
|
|
673
|
+
|
|
674
|
+
// -----------------------------------------------------
|
|
675
|
+
|
|
411
676
|
/** A transaction receipt.
|
|
412
677
|
*
|
|
413
678
|
* @prop meta Transaction receipt metadata.
|
|
414
679
|
* @prop receipt Transaction-specific receipt.
|
|
415
680
|
*/
|
|
416
|
-
export const TransactionReceipt =
|
|
417
|
-
filterIds:
|
|
418
|
-
meta: TransactionReceiptMeta,
|
|
419
|
-
receipt:
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
681
|
+
export const TransactionReceipt = MessageCodec({
|
|
682
|
+
filterIds: ArrayCodec(NumberCodec),
|
|
683
|
+
meta: RequiredCodec(TransactionReceiptMeta),
|
|
684
|
+
receipt: RequiredCodec(
|
|
685
|
+
OneOfCodec({
|
|
686
|
+
invoke: InvokeTransactionReceipt,
|
|
687
|
+
l1Handler: L1HandlerTransactionReceipt,
|
|
688
|
+
declare: DeclareTransactionReceipt,
|
|
689
|
+
deploy: DeployTransactionReceipt,
|
|
690
|
+
deployAccount: DeployAccountTransactionReceipt,
|
|
691
|
+
}),
|
|
425
692
|
),
|
|
426
693
|
});
|
|
427
694
|
|
|
428
|
-
export type TransactionReceipt = typeof TransactionReceipt
|
|
695
|
+
export type TransactionReceipt = Readonly<CodecType<typeof TransactionReceipt>>;
|
|
696
|
+
|
|
697
|
+
// -----------------------------------------------------
|
|
429
698
|
|
|
430
699
|
/** A transaction event.
|
|
431
700
|
*
|
|
@@ -438,22 +707,25 @@ export type TransactionReceipt = typeof TransactionReceipt.Type;
|
|
|
438
707
|
* @prop transactionStatus The transaction status.
|
|
439
708
|
* @prop eventIndexInTransaction The event index in the transaction.
|
|
440
709
|
*/
|
|
441
|
-
export const Event =
|
|
442
|
-
filterIds:
|
|
443
|
-
address: FieldElement,
|
|
444
|
-
keys:
|
|
445
|
-
data:
|
|
446
|
-
eventIndex:
|
|
447
|
-
transactionIndex:
|
|
448
|
-
transactionHash: FieldElement,
|
|
449
|
-
transactionStatus: TransactionStatus,
|
|
450
|
-
eventIndexInTransaction:
|
|
710
|
+
export const Event = MessageCodec({
|
|
711
|
+
filterIds: ArrayCodec(NumberCodec),
|
|
712
|
+
address: RequiredCodec(FieldElement),
|
|
713
|
+
keys: ArrayCodec(FieldElement),
|
|
714
|
+
data: ArrayCodec(FieldElement),
|
|
715
|
+
eventIndex: RequiredCodec(NumberCodec),
|
|
716
|
+
transactionIndex: RequiredCodec(NumberCodec),
|
|
717
|
+
transactionHash: RequiredCodec(FieldElement),
|
|
718
|
+
transactionStatus: RequiredCodec(TransactionStatus),
|
|
719
|
+
eventIndexInTransaction: RequiredCodec(NumberCodec),
|
|
451
720
|
});
|
|
452
721
|
|
|
453
|
-
export type Event = typeof Event
|
|
722
|
+
export type Event = Readonly<CodecType<typeof Event>>;
|
|
723
|
+
|
|
724
|
+
// -----------------------------------------------------
|
|
454
725
|
|
|
455
726
|
/** A message from the L2 to the L1.
|
|
456
727
|
*
|
|
728
|
+
* @prop filterIds The filter IDs.
|
|
457
729
|
* @prop fromAddress The address on L2 that sent the message.
|
|
458
730
|
* @prop toAddress The address on L1 that will receive the message.
|
|
459
731
|
* @prop payload The message payload.
|
|
@@ -463,114 +735,330 @@ export type Event = typeof Event.Type;
|
|
|
463
735
|
* @prop transactionStatus The transaction status.
|
|
464
736
|
* @prop messageIndexInTransaction The message index in the transaction.
|
|
465
737
|
*/
|
|
466
|
-
export const MessageToL1 =
|
|
467
|
-
filterIds:
|
|
468
|
-
fromAddress: FieldElement,
|
|
469
|
-
toAddress: FieldElement,
|
|
470
|
-
payload:
|
|
471
|
-
messageIndex:
|
|
472
|
-
transactionIndex:
|
|
473
|
-
transactionHash: FieldElement,
|
|
474
|
-
transactionStatus: TransactionStatus,
|
|
475
|
-
messageIndexInTransaction:
|
|
738
|
+
export const MessageToL1 = MessageCodec({
|
|
739
|
+
filterIds: ArrayCodec(NumberCodec),
|
|
740
|
+
fromAddress: RequiredCodec(FieldElement),
|
|
741
|
+
toAddress: RequiredCodec(FieldElement),
|
|
742
|
+
payload: ArrayCodec(FieldElement),
|
|
743
|
+
messageIndex: RequiredCodec(NumberCodec),
|
|
744
|
+
transactionIndex: RequiredCodec(NumberCodec),
|
|
745
|
+
transactionHash: RequiredCodec(FieldElement),
|
|
746
|
+
transactionStatus: RequiredCodec(TransactionStatus),
|
|
747
|
+
messageIndexInTransaction: RequiredCodec(NumberCodec),
|
|
476
748
|
});
|
|
477
749
|
|
|
478
|
-
export type MessageToL1 = typeof MessageToL1
|
|
750
|
+
export type MessageToL1 = Readonly<CodecType<typeof MessageToL1>>;
|
|
751
|
+
|
|
752
|
+
// -----------------------------------------------------
|
|
479
753
|
|
|
480
754
|
/** An entry in the storage diff.
|
|
481
755
|
*
|
|
482
756
|
* @prop key The storage location.
|
|
483
757
|
* @prop value The new value at the storage location.
|
|
484
758
|
*/
|
|
485
|
-
export const StorageEntry =
|
|
486
|
-
key: FieldElement,
|
|
487
|
-
value: FieldElement,
|
|
759
|
+
export const StorageEntry = MessageCodec({
|
|
760
|
+
key: RequiredCodec(FieldElement),
|
|
761
|
+
value: RequiredCodec(FieldElement),
|
|
488
762
|
});
|
|
489
763
|
|
|
490
|
-
export type StorageEntry = typeof StorageEntry
|
|
764
|
+
export type StorageEntry = Readonly<CodecType<typeof StorageEntry>>;
|
|
765
|
+
|
|
766
|
+
// -----------------------------------------------------
|
|
491
767
|
|
|
492
768
|
/** Storage diff.
|
|
493
769
|
*
|
|
494
770
|
* @prop contractAddress The contract address.
|
|
495
771
|
* @prop storageEntries The entries that changed.
|
|
496
772
|
*/
|
|
497
|
-
export const StorageDiff =
|
|
498
|
-
filterIds:
|
|
499
|
-
contractAddress: FieldElement,
|
|
500
|
-
storageEntries:
|
|
773
|
+
export const StorageDiff = MessageCodec({
|
|
774
|
+
filterIds: ArrayCodec(NumberCodec),
|
|
775
|
+
contractAddress: RequiredCodec(FieldElement),
|
|
776
|
+
storageEntries: ArrayCodec(StorageEntry),
|
|
501
777
|
});
|
|
502
778
|
|
|
503
|
-
export type StorageDiff = typeof StorageDiff
|
|
779
|
+
export type StorageDiff = Readonly<CodecType<typeof StorageDiff>>;
|
|
780
|
+
|
|
781
|
+
// -----------------------------------------------------
|
|
504
782
|
|
|
505
783
|
/** A new class declared.
|
|
506
784
|
*
|
|
507
785
|
* @prop classHash The class hash.
|
|
508
786
|
* @prop compiledClassHash The compiled class hash. If undefined, it's the result of a deprecated Cairo 0 declaration.
|
|
509
787
|
*/
|
|
510
|
-
export const DeclaredClass =
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
classHash: Schema.optional(FieldElement),
|
|
514
|
-
compiledClassHash: Schema.optional(FieldElement),
|
|
515
|
-
}),
|
|
788
|
+
export const DeclaredClass = MessageCodec({
|
|
789
|
+
classHash: OptionalCodec(FieldElement),
|
|
790
|
+
compiledClassHash: OptionalCodec(FieldElement),
|
|
516
791
|
});
|
|
517
792
|
|
|
518
|
-
export type DeclaredClass = typeof DeclaredClass
|
|
793
|
+
export type DeclaredClass = Readonly<CodecType<typeof DeclaredClass>>;
|
|
794
|
+
|
|
795
|
+
// -----------------------------------------------------
|
|
519
796
|
|
|
520
797
|
/** A class replaced.
|
|
521
798
|
*
|
|
522
799
|
* @prop contractAddress The contract address.
|
|
523
800
|
* @prop classHash The class new hash.
|
|
524
801
|
*/
|
|
525
|
-
export const ReplacedClass =
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
contractAddress: Schema.optional(FieldElement),
|
|
529
|
-
classHash: Schema.optional(FieldElement),
|
|
530
|
-
}),
|
|
802
|
+
export const ReplacedClass = MessageCodec({
|
|
803
|
+
contractAddress: OptionalCodec(FieldElement),
|
|
804
|
+
classHash: OptionalCodec(FieldElement),
|
|
531
805
|
});
|
|
532
806
|
|
|
533
|
-
export type ReplacedClass = typeof ReplacedClass
|
|
807
|
+
export type ReplacedClass = Readonly<CodecType<typeof ReplacedClass>>;
|
|
808
|
+
|
|
809
|
+
// -----------------------------------------------------
|
|
534
810
|
|
|
535
811
|
/** A contract deployed.
|
|
536
812
|
*
|
|
537
813
|
* @prop contractAddress The contract address.
|
|
538
814
|
* @prop classHash The class hash.
|
|
539
815
|
*/
|
|
540
|
-
export const DeployedContract =
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
contractAddress: Schema.optional(FieldElement),
|
|
544
|
-
classHash: Schema.optional(FieldElement),
|
|
545
|
-
}),
|
|
816
|
+
export const DeployedContract = MessageCodec({
|
|
817
|
+
contractAddress: OptionalCodec(FieldElement),
|
|
818
|
+
classHash: OptionalCodec(FieldElement),
|
|
546
819
|
});
|
|
547
820
|
|
|
548
|
-
export type DeployedContract = typeof DeployedContract
|
|
821
|
+
export type DeployedContract = Readonly<CodecType<typeof DeployedContract>>;
|
|
822
|
+
|
|
823
|
+
// -----------------------------------------------------
|
|
549
824
|
|
|
550
825
|
/** A contract change.
|
|
551
826
|
*
|
|
552
|
-
* @prop
|
|
827
|
+
* @prop filterIds The filter IDs.
|
|
553
828
|
* @prop change The change.
|
|
554
829
|
*/
|
|
555
|
-
export const ContractChange =
|
|
556
|
-
filterIds:
|
|
557
|
-
change:
|
|
830
|
+
export const ContractChange = MessageCodec({
|
|
831
|
+
filterIds: ArrayCodec(NumberCodec),
|
|
832
|
+
change: RequiredCodec(
|
|
833
|
+
OneOfCodec({
|
|
834
|
+
declaredClass: DeclaredClass,
|
|
835
|
+
replacedClass: ReplacedClass,
|
|
836
|
+
deployedContract: DeployedContract,
|
|
837
|
+
}),
|
|
838
|
+
),
|
|
558
839
|
});
|
|
559
840
|
|
|
560
|
-
export type ContractChange = typeof ContractChange
|
|
841
|
+
export type ContractChange = Readonly<CodecType<typeof ContractChange>>;
|
|
842
|
+
|
|
843
|
+
// -----------------------------------------------------
|
|
561
844
|
|
|
562
845
|
/** A nonce update.
|
|
563
846
|
*
|
|
564
847
|
* @prop contractAddress The contract address.
|
|
565
848
|
* @prop nonce The new nonce.
|
|
566
849
|
*/
|
|
567
|
-
export const NonceUpdate =
|
|
568
|
-
filterIds:
|
|
569
|
-
contractAddress: FieldElement,
|
|
570
|
-
nonce: FieldElement,
|
|
850
|
+
export const NonceUpdate = MessageCodec({
|
|
851
|
+
filterIds: ArrayCodec(NumberCodec),
|
|
852
|
+
contractAddress: RequiredCodec(FieldElement),
|
|
853
|
+
nonce: RequiredCodec(FieldElement),
|
|
571
854
|
});
|
|
572
855
|
|
|
573
|
-
export type NonceUpdate = typeof NonceUpdate
|
|
856
|
+
export type NonceUpdate = Readonly<CodecType<typeof NonceUpdate>>;
|
|
857
|
+
|
|
858
|
+
// -----------------------------------------------------
|
|
859
|
+
|
|
860
|
+
export const CallType: Codec<
|
|
861
|
+
"libraryCall" | "call" | "delegate" | "unknown",
|
|
862
|
+
proto.data.CallType
|
|
863
|
+
> = {
|
|
864
|
+
encode(x) {
|
|
865
|
+
switch (x) {
|
|
866
|
+
case "libraryCall":
|
|
867
|
+
return proto.data.CallType.LIBRARY_CALL;
|
|
868
|
+
case "call":
|
|
869
|
+
return proto.data.CallType.CALL;
|
|
870
|
+
case "delegate":
|
|
871
|
+
return proto.data.CallType.DELEGATE;
|
|
872
|
+
case "unknown":
|
|
873
|
+
return proto.data.CallType.UNSPECIFIED;
|
|
874
|
+
default:
|
|
875
|
+
return proto.data.CallType.UNRECOGNIZED;
|
|
876
|
+
}
|
|
877
|
+
},
|
|
878
|
+
decode(p) {
|
|
879
|
+
const enumMap = {
|
|
880
|
+
[proto.data.CallType.LIBRARY_CALL]: "libraryCall",
|
|
881
|
+
[proto.data.CallType.CALL]: "call",
|
|
882
|
+
[proto.data.CallType.DELEGATE]: "delegate",
|
|
883
|
+
[proto.data.CallType.UNSPECIFIED]: "unknown",
|
|
884
|
+
[proto.data.CallType.UNRECOGNIZED]: "unknown",
|
|
885
|
+
} as const;
|
|
886
|
+
|
|
887
|
+
return enumMap[p] ?? "unknown";
|
|
888
|
+
},
|
|
889
|
+
};
|
|
890
|
+
|
|
891
|
+
export type CallType = CodecType<typeof CallType>;
|
|
892
|
+
|
|
893
|
+
// -----------------------------------------------------
|
|
894
|
+
|
|
895
|
+
const _FunctionInvocationCodec = MessageCodec({
|
|
896
|
+
contractAddress: RequiredCodec(FieldElement),
|
|
897
|
+
entryPointSelector: RequiredCodec(FieldElement),
|
|
898
|
+
calldata: ArrayCodec(FieldElement),
|
|
899
|
+
callerAddress: RequiredCodec(FieldElement),
|
|
900
|
+
classHash: RequiredCodec(FieldElement),
|
|
901
|
+
callType: RequiredCodec(CallType),
|
|
902
|
+
result: ArrayCodec(FieldElement),
|
|
903
|
+
events: ArrayCodec(NumberCodec),
|
|
904
|
+
messages: ArrayCodec(NumberCodec),
|
|
905
|
+
});
|
|
906
|
+
|
|
907
|
+
/**
|
|
908
|
+
* @note This is a recursive type.
|
|
909
|
+
*/
|
|
910
|
+
export type FunctionInvocation = Evaluate<
|
|
911
|
+
CodecType<typeof _FunctionInvocationCodec> & {
|
|
912
|
+
calls: FunctionInvocation[];
|
|
913
|
+
}
|
|
914
|
+
>;
|
|
915
|
+
|
|
916
|
+
/** A function invocation.
|
|
917
|
+
*
|
|
918
|
+
* @prop contractAddress The contract address.
|
|
919
|
+
* @prop entryPointSelector The entry point selector.
|
|
920
|
+
* @prop calldata The calldata.
|
|
921
|
+
* @prop callerAddress The caller address.
|
|
922
|
+
* @prop classHash The class hash.
|
|
923
|
+
* @prop callType The call type.
|
|
924
|
+
* @prop result The function invocation result.
|
|
925
|
+
* @prop calls The nested function invocations.
|
|
926
|
+
* @prop events The events index in the current transaction.
|
|
927
|
+
* @prop messages The messages index in the current transaction.
|
|
928
|
+
*/
|
|
929
|
+
const FunctionInvocationCodec: Codec<
|
|
930
|
+
FunctionInvocation,
|
|
931
|
+
proto.data.FunctionInvocation
|
|
932
|
+
> = {
|
|
933
|
+
encode(x) {
|
|
934
|
+
const { calls, ...rest } = x;
|
|
935
|
+
const encodedCalls = calls.map(FunctionInvocationCodec.encode);
|
|
936
|
+
const encodedRest = _FunctionInvocationCodec.encode(rest);
|
|
937
|
+
return { calls: encodedCalls, ...encodedRest };
|
|
938
|
+
},
|
|
939
|
+
decode(p) {
|
|
940
|
+
const { calls = [], ...rest } = p;
|
|
941
|
+
const decodedCalls = calls.map(FunctionInvocationCodec.decode);
|
|
942
|
+
const decodedRest = _FunctionInvocationCodec.decode(rest);
|
|
943
|
+
return { ...decodedRest, calls: decodedCalls };
|
|
944
|
+
},
|
|
945
|
+
};
|
|
946
|
+
|
|
947
|
+
// -----------------------------------------------------
|
|
948
|
+
|
|
949
|
+
/** A successful invocation of the __execute__ call.
|
|
950
|
+
*
|
|
951
|
+
* The call.
|
|
952
|
+
*/
|
|
953
|
+
export const ExecuteInvocationSuccess = FunctionInvocationCodec;
|
|
954
|
+
|
|
955
|
+
// -----------------------------------------------------
|
|
956
|
+
|
|
957
|
+
/** A failed invocation of the __execute__ call.
|
|
958
|
+
*
|
|
959
|
+
* @prop reason The reason for the failure.
|
|
960
|
+
*/
|
|
961
|
+
export const ExecuteInvocationReverted = MessageCodec({
|
|
962
|
+
reason: OptionalCodec(StringCodec),
|
|
963
|
+
});
|
|
964
|
+
|
|
965
|
+
// -----------------------------------------------------
|
|
966
|
+
|
|
967
|
+
/** Trace for invoke transactions.
|
|
968
|
+
*
|
|
969
|
+
* @prop validateInvocation The __validate__ call.
|
|
970
|
+
* @prop executeInvocation The __execute__ call.
|
|
971
|
+
* @prop feeTransferInvocation The __fee_transfer__ call.
|
|
972
|
+
*/
|
|
973
|
+
export const InvokeTransactionTrace = MessageCodec({
|
|
974
|
+
validateInvocation: OptionalCodec(FunctionInvocationCodec),
|
|
975
|
+
executeInvocation: RequiredCodec(
|
|
976
|
+
OneOfCodec({
|
|
977
|
+
success: ExecuteInvocationSuccess,
|
|
978
|
+
reverted: ExecuteInvocationReverted,
|
|
979
|
+
}),
|
|
980
|
+
),
|
|
981
|
+
feeTransferInvocation: OptionalCodec(FunctionInvocationCodec),
|
|
982
|
+
});
|
|
983
|
+
|
|
984
|
+
export type InvokeTransactionTrace = Readonly<
|
|
985
|
+
CodecType<typeof InvokeTransactionTrace>
|
|
986
|
+
>;
|
|
987
|
+
|
|
988
|
+
// -----------------------------------------------------
|
|
989
|
+
|
|
990
|
+
/** Trace for declare transactions.
|
|
991
|
+
*
|
|
992
|
+
* @prop validateInvocation The __validate__ call.
|
|
993
|
+
* @prop feeTransferInvocation The __fee_transfer__ call.
|
|
994
|
+
*/
|
|
995
|
+
export const DeclareTransactionTrace = MessageCodec({
|
|
996
|
+
validateInvocation: OptionalCodec(FunctionInvocationCodec),
|
|
997
|
+
feeTransferInvocation: OptionalCodec(FunctionInvocationCodec),
|
|
998
|
+
});
|
|
999
|
+
|
|
1000
|
+
export type DeclareTransactionTrace = Readonly<
|
|
1001
|
+
CodecType<typeof DeclareTransactionTrace>
|
|
1002
|
+
>;
|
|
1003
|
+
|
|
1004
|
+
// -----------------------------------------------------
|
|
1005
|
+
|
|
1006
|
+
/** Trace for deploy account transactions.
|
|
1007
|
+
*
|
|
1008
|
+
* @prop validateInvocation The __validate__ call.
|
|
1009
|
+
* @prop constructorInvocation The __constructor__ invocation.
|
|
1010
|
+
* @prop feeTransferInvocation The __fee_transfer__ call.
|
|
1011
|
+
*/
|
|
1012
|
+
export const DeployAccountTransactionTrace = MessageCodec({
|
|
1013
|
+
validateInvocation: OptionalCodec(FunctionInvocationCodec),
|
|
1014
|
+
constructorInvocation: OptionalCodec(FunctionInvocationCodec),
|
|
1015
|
+
feeTransferInvocation: OptionalCodec(FunctionInvocationCodec),
|
|
1016
|
+
});
|
|
1017
|
+
|
|
1018
|
+
export type DeployAccountTransactionTrace = Readonly<
|
|
1019
|
+
CodecType<typeof DeployAccountTransactionTrace>
|
|
1020
|
+
>;
|
|
1021
|
+
|
|
1022
|
+
// -----------------------------------------------------
|
|
1023
|
+
|
|
1024
|
+
/** Trace for L1 handler transactions.
|
|
1025
|
+
*
|
|
1026
|
+
* @prop functionInvocation The L1 handler function invocation.
|
|
1027
|
+
*/
|
|
1028
|
+
export const L1HandlerTransactionTrace = MessageCodec({
|
|
1029
|
+
functionInvocation: OptionalCodec(FunctionInvocationCodec),
|
|
1030
|
+
});
|
|
1031
|
+
|
|
1032
|
+
export type L1HandlerTransactionTrace = Readonly<
|
|
1033
|
+
CodecType<typeof L1HandlerTransactionTrace>
|
|
1034
|
+
>;
|
|
1035
|
+
|
|
1036
|
+
// -----------------------------------------------------
|
|
1037
|
+
|
|
1038
|
+
/** A transaction trace.
|
|
1039
|
+
*
|
|
1040
|
+
* @prop filterIds The filter IDs.
|
|
1041
|
+
* @prop transactionIndex The transaction index.
|
|
1042
|
+
* @prop transactionHash The transaction hash.
|
|
1043
|
+
* @prop traceRoot The trace root.
|
|
1044
|
+
*/
|
|
1045
|
+
export const TransactionTrace = MessageCodec({
|
|
1046
|
+
filterIds: ArrayCodec(NumberCodec),
|
|
1047
|
+
transactionIndex: RequiredCodec(NumberCodec),
|
|
1048
|
+
transactionHash: RequiredCodec(FieldElement),
|
|
1049
|
+
traceRoot: RequiredCodec(
|
|
1050
|
+
OneOfCodec({
|
|
1051
|
+
invoke: InvokeTransactionTrace,
|
|
1052
|
+
declare: DeclareTransactionTrace,
|
|
1053
|
+
deployAccount: DeployAccountTransactionTrace,
|
|
1054
|
+
l1Handler: L1HandlerTransactionTrace,
|
|
1055
|
+
}),
|
|
1056
|
+
),
|
|
1057
|
+
});
|
|
1058
|
+
|
|
1059
|
+
export type TransactionTrace = Readonly<CodecType<typeof TransactionTrace>>;
|
|
1060
|
+
|
|
1061
|
+
// -----------------------------------------------------
|
|
574
1062
|
|
|
575
1063
|
/** A block.
|
|
576
1064
|
*
|
|
@@ -579,38 +1067,34 @@ export type NonceUpdate = typeof NonceUpdate.Type;
|
|
|
579
1067
|
* @prop receipts The receipts of the transactions.
|
|
580
1068
|
* @prop events The events emitted by the transactions.
|
|
581
1069
|
* @prop messages The messages sent to L1 by the transactions.
|
|
1070
|
+
* @prop traces The transaction traces.
|
|
582
1071
|
* @prop storageDiffs The changes to the storage.
|
|
583
1072
|
* @prop contractChanges The changes to contracts and classes.
|
|
1073
|
+
* @prop nonceUpdates The nonce updates.
|
|
584
1074
|
*/
|
|
585
|
-
export const Block =
|
|
586
|
-
header: BlockHeader,
|
|
587
|
-
transactions:
|
|
588
|
-
receipts:
|
|
589
|
-
events:
|
|
590
|
-
messages:
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
1075
|
+
export const Block = MessageCodec({
|
|
1076
|
+
header: RequiredCodec(BlockHeader),
|
|
1077
|
+
transactions: ArrayCodec(Transaction),
|
|
1078
|
+
receipts: ArrayCodec(TransactionReceipt),
|
|
1079
|
+
events: ArrayCodec(Event),
|
|
1080
|
+
messages: ArrayCodec(MessageToL1),
|
|
1081
|
+
traces: ArrayCodec(TransactionTrace),
|
|
1082
|
+
storageDiffs: ArrayCodec(StorageDiff),
|
|
1083
|
+
contractChanges: ArrayCodec(ContractChange),
|
|
1084
|
+
nonceUpdates: ArrayCodec(NonceUpdate),
|
|
594
1085
|
});
|
|
595
1086
|
|
|
596
|
-
export type Block = typeof Block
|
|
1087
|
+
export type Block = Readonly<CodecType<typeof Block>>;
|
|
597
1088
|
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
{
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
},
|
|
609
|
-
encode(value) {
|
|
610
|
-
if (value === null) {
|
|
611
|
-
return new Uint8Array();
|
|
612
|
-
}
|
|
613
|
-
return proto.data.Block.encode(value).finish();
|
|
614
|
-
},
|
|
1089
|
+
// -----------------------------------------------------
|
|
1090
|
+
|
|
1091
|
+
export const BlockFromBytes: Codec<Block, Uint8Array> = {
|
|
1092
|
+
encode(x) {
|
|
1093
|
+
const block = Block.encode(x);
|
|
1094
|
+
return proto.data.Block.encode(block).finish();
|
|
1095
|
+
},
|
|
1096
|
+
decode(p) {
|
|
1097
|
+
const block = proto.data.Block.decode(p);
|
|
1098
|
+
return Block.decode(block);
|
|
615
1099
|
},
|
|
616
|
-
|
|
1100
|
+
};
|