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