@apibara/starknet 2.0.0-beta.4 → 2.0.0-beta.41

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/src/access.ts CHANGED
@@ -3,8 +3,11 @@ import type { Transaction, TransactionReceipt } from "./block";
3
3
  /** Returns the transaction receipt for the given transaction index. */
4
4
  export function getReceipt(
5
5
  transactionIndex: number,
6
- receipts: readonly TransactionReceipt[],
6
+ params:
7
+ | { receipts: readonly TransactionReceipt[] }
8
+ | readonly TransactionReceipt[],
7
9
  ): TransactionReceipt | undefined {
10
+ const receipts = "receipts" in params ? params.receipts : params;
8
11
  return binarySearch(
9
12
  transactionIndex,
10
13
  receipts,
@@ -15,8 +18,9 @@ export function getReceipt(
15
18
  /** Returns the transaction for the given transaction index. */
16
19
  export function getTransaction(
17
20
  transactionIndex: number,
18
- transactions: readonly Transaction[],
21
+ params: { transactions: readonly Transaction[] } | readonly Transaction[],
19
22
  ): Transaction | undefined {
23
+ const transactions = "transactions" in params ? params.transactions : params;
20
24
  return binarySearch(
21
25
  transactionIndex,
22
26
  transactions,
package/src/block.ts CHANGED
@@ -76,13 +76,13 @@ export const U128 = Schema.transform(
76
76
  );
77
77
 
78
78
  export const ResourceBounds = Schema.Struct({
79
- maxAmount: Schema.optional(Schema.BigIntFromSelf),
80
- maxPricePerUnit: Schema.optional(U128),
79
+ maxAmount: Schema.BigIntFromSelf,
80
+ maxPricePerUnit: U128,
81
81
  });
82
82
 
83
83
  export const ResourceBoundsMapping = Schema.Struct({
84
- l1Gas: Schema.optional(ResourceBounds),
85
- l2Gas: Schema.optional(ResourceBounds),
84
+ l1Gas: ResourceBounds,
85
+ l2Gas: ResourceBounds,
86
86
  });
87
87
 
88
88
  export const DataAvailabilityMode = Schema.transform(
@@ -120,15 +120,15 @@ export const DataAvailabilityMode = Schema.transform(
120
120
  */
121
121
  export const BlockHeader = Schema.Struct({
122
122
  blockHash: Schema.optional(FieldElement),
123
- parentBlockHash: Schema.optional(FieldElement),
123
+ parentBlockHash: FieldElement,
124
124
  blockNumber: Schema.BigIntFromSelf,
125
- sequencerAddress: Schema.optional(FieldElement),
125
+ sequencerAddress: FieldElement,
126
126
  newRoot: Schema.optional(FieldElement),
127
- timestamp: Schema.optional(Schema.DateFromSelf),
128
- starknetVersion: Schema.optional(Schema.String),
129
- l1GasPrice: Schema.optional(ResourcePrice),
130
- l1DataGasPrice: Schema.optional(ResourcePrice),
131
- l1DataAvailabilityMode: Schema.optional(L1DataAvailabilityMode),
127
+ timestamp: Schema.DateFromSelf,
128
+ starknetVersion: Schema.String,
129
+ l1GasPrice: ResourcePrice,
130
+ l1DataGasPrice: ResourcePrice,
131
+ l1DataAvailabilityMode: L1DataAvailabilityMode,
132
132
  });
133
133
 
134
134
  export type BlockHeader = typeof BlockHeader.Type;
@@ -142,9 +142,9 @@ export type BlockHeader = typeof BlockHeader.Type;
142
142
  * @prop transactionStatus The transaction status.
143
143
  */
144
144
  export const TransactionMeta = Schema.Struct({
145
- transactionIndex: Schema.optional(Schema.Number),
146
- transactionHash: Schema.optional(FieldElement),
147
- transactionStatus: Schema.optional(TransactionStatus),
145
+ transactionIndex: Schema.Number,
146
+ transactionHash: FieldElement,
147
+ transactionStatus: TransactionStatus,
148
148
  });
149
149
 
150
150
  export type TransactionMeta = typeof TransactionMeta.Type;
@@ -152,135 +152,135 @@ export type TransactionMeta = typeof TransactionMeta.Type;
152
152
  export const InvokeTransactionV0 = Schema.Struct({
153
153
  _tag: tag("invokeV0"),
154
154
  invokeV0: Schema.Struct({
155
- maxFee: Schema.optional(FieldElement),
156
- signature: Schema.optional(Schema.Array(FieldElement)),
157
- contractAddress: Schema.optional(FieldElement),
158
- entryPointSelector: Schema.optional(FieldElement),
159
- calldata: Schema.optional(Schema.Array(FieldElement)),
155
+ maxFee: FieldElement,
156
+ signature: Schema.Array(FieldElement),
157
+ contractAddress: FieldElement,
158
+ entryPointSelector: FieldElement,
159
+ calldata: Schema.Array(FieldElement),
160
160
  }),
161
161
  });
162
162
 
163
163
  export const InvokeTransactionV1 = Schema.Struct({
164
164
  _tag: tag("invokeV1"),
165
165
  invokeV1: Schema.Struct({
166
- senderAddress: Schema.optional(FieldElement),
167
- calldata: Schema.optional(Schema.Array(FieldElement)),
168
- maxFee: Schema.optional(FieldElement),
169
- signature: Schema.optional(Schema.Array(FieldElement)),
170
- nonce: Schema.optional(FieldElement),
166
+ senderAddress: FieldElement,
167
+ calldata: Schema.Array(FieldElement),
168
+ maxFee: FieldElement,
169
+ signature: Schema.Array(FieldElement),
170
+ nonce: FieldElement,
171
171
  }),
172
172
  });
173
173
 
174
174
  export const InvokeTransactionV3 = Schema.Struct({
175
175
  _tag: tag("invokeV3"),
176
176
  invokeV3: Schema.Struct({
177
- senderAddress: Schema.optional(FieldElement),
178
- calldata: Schema.optional(Schema.Array(FieldElement)),
179
- signature: Schema.optional(Schema.Array(FieldElement)),
180
- nonce: Schema.optional(FieldElement),
181
- resourceBounds: Schema.optional(ResourceBoundsMapping),
182
- tip: Schema.optional(Schema.BigIntFromSelf),
183
- paymasterData: Schema.optional(Schema.Array(FieldElement)),
184
- accountDeploymentData: Schema.optional(Schema.Array(FieldElement)),
185
- nonceDataAvailabilityMode: Schema.optional(DataAvailabilityMode),
186
- feeDataAvailabilityMode: Schema.optional(DataAvailabilityMode),
177
+ senderAddress: FieldElement,
178
+ calldata: Schema.Array(FieldElement),
179
+ signature: Schema.Array(FieldElement),
180
+ nonce: FieldElement,
181
+ resourceBounds: ResourceBoundsMapping,
182
+ tip: Schema.BigIntFromSelf,
183
+ paymasterData: Schema.Array(FieldElement),
184
+ accountDeploymentData: Schema.Array(FieldElement),
185
+ nonceDataAvailabilityMode: DataAvailabilityMode,
186
+ feeDataAvailabilityMode: DataAvailabilityMode,
187
187
  }),
188
188
  });
189
189
 
190
190
  export const L1HandlerTransaction = Schema.Struct({
191
191
  _tag: tag("l1Handler"),
192
192
  l1Handler: Schema.Struct({
193
- nonce: Schema.optional(Schema.BigIntFromSelf),
194
- contractAddress: Schema.optional(FieldElement),
195
- entryPointSelector: Schema.optional(FieldElement),
196
- calldata: Schema.optional(Schema.Array(FieldElement)),
193
+ nonce: Schema.BigIntFromSelf,
194
+ contractAddress: FieldElement,
195
+ entryPointSelector: FieldElement,
196
+ calldata: Schema.Array(FieldElement),
197
197
  }),
198
198
  });
199
199
 
200
200
  export const DeployTransaction = Schema.Struct({
201
201
  _tag: tag("deploy"),
202
202
  deploy: Schema.Struct({
203
- contractAddressSalt: Schema.optional(FieldElement),
204
- constructorCalldata: Schema.optional(Schema.Array(FieldElement)),
205
- classHash: Schema.optional(FieldElement),
203
+ contractAddressSalt: FieldElement,
204
+ constructorCalldata: Schema.Array(FieldElement),
205
+ classHash: FieldElement,
206
206
  }),
207
207
  });
208
208
 
209
209
  export const DeclareTransactionV0 = Schema.Struct({
210
210
  _tag: tag("declareV0"),
211
211
  declareV0: Schema.Struct({
212
- senderAddress: Schema.optional(FieldElement),
213
- maxFee: Schema.optional(FieldElement),
214
- signature: Schema.optional(Schema.Array(FieldElement)),
215
- classHash: Schema.optional(FieldElement),
212
+ senderAddress: FieldElement,
213
+ maxFee: FieldElement,
214
+ signature: Schema.Array(FieldElement),
215
+ classHash: FieldElement,
216
216
  }),
217
217
  });
218
218
 
219
219
  export const DeclareTransactionV1 = Schema.Struct({
220
220
  _tag: tag("declareV1"),
221
221
  declareV1: Schema.Struct({
222
- senderAddress: Schema.optional(FieldElement),
223
- maxFee: Schema.optional(FieldElement),
224
- signature: Schema.optional(Schema.Array(FieldElement)),
225
- nonce: Schema.optional(FieldElement),
226
- classHash: Schema.optional(FieldElement),
222
+ senderAddress: FieldElement,
223
+ maxFee: FieldElement,
224
+ signature: Schema.Array(FieldElement),
225
+ nonce: FieldElement,
226
+ classHash: FieldElement,
227
227
  }),
228
228
  });
229
229
 
230
230
  export const DeclareTransactionV2 = Schema.Struct({
231
231
  _tag: tag("declareV2"),
232
232
  declareV2: Schema.Struct({
233
- senderAddress: Schema.optional(FieldElement),
234
- compiledClassHash: Schema.optional(FieldElement),
235
- maxFee: Schema.optional(FieldElement),
236
- signature: Schema.optional(Schema.Array(FieldElement)),
237
- nonce: Schema.optional(FieldElement),
238
- classHash: Schema.optional(FieldElement),
233
+ senderAddress: FieldElement,
234
+ compiledClassHash: FieldElement,
235
+ maxFee: FieldElement,
236
+ signature: Schema.Array(FieldElement),
237
+ nonce: FieldElement,
238
+ classHash: FieldElement,
239
239
  }),
240
240
  });
241
241
 
242
242
  export const DeclareTransactionV3 = Schema.Struct({
243
243
  _tag: tag("declareV3"),
244
244
  declareV3: Schema.Struct({
245
- senderAddress: Schema.optional(FieldElement),
246
- compiledClassHash: Schema.optional(FieldElement),
247
- signature: Schema.optional(Schema.Array(FieldElement)),
248
- nonce: Schema.optional(FieldElement),
249
- classHash: Schema.optional(FieldElement),
250
- resourceBounds: Schema.optional(ResourceBoundsMapping),
251
- tip: Schema.optional(Schema.BigIntFromSelf),
252
- paymasterData: Schema.optional(Schema.Array(FieldElement)),
253
- accountDeploymentData: Schema.optional(Schema.Array(FieldElement)),
254
- nonceDataAvailabilityMode: Schema.optional(DataAvailabilityMode),
255
- feeDataAvailabilityMode: Schema.optional(DataAvailabilityMode),
245
+ senderAddress: FieldElement,
246
+ compiledClassHash: FieldElement,
247
+ signature: Schema.Array(FieldElement),
248
+ nonce: FieldElement,
249
+ classHash: FieldElement,
250
+ resourceBounds: ResourceBoundsMapping,
251
+ tip: Schema.BigIntFromSelf,
252
+ paymasterData: Schema.Array(FieldElement),
253
+ accountDeploymentData: Schema.Array(FieldElement),
254
+ nonceDataAvailabilityMode: DataAvailabilityMode,
255
+ feeDataAvailabilityMode: DataAvailabilityMode,
256
256
  }),
257
257
  });
258
258
 
259
259
  export const DeployAccountTransactionV1 = Schema.Struct({
260
260
  _tag: tag("deployAccountV1"),
261
261
  deployAccountV1: Schema.Struct({
262
- maxFee: Schema.optional(FieldElement),
263
- signature: Schema.optional(Schema.Array(FieldElement)),
264
- nonce: Schema.optional(FieldElement),
265
- contractAddressSalt: Schema.optional(FieldElement),
266
- constructorCalldata: Schema.optional(Schema.Array(FieldElement)),
267
- classHash: Schema.optional(FieldElement),
262
+ maxFee: FieldElement,
263
+ signature: Schema.Array(FieldElement),
264
+ nonce: FieldElement,
265
+ contractAddressSalt: FieldElement,
266
+ constructorCalldata: Schema.Array(FieldElement),
267
+ classHash: FieldElement,
268
268
  }),
269
269
  });
270
270
 
271
271
  export const DeployAccountTransactionV3 = Schema.Struct({
272
272
  _tag: tag("deployAccountV3"),
273
273
  deployAccountV3: Schema.Struct({
274
- signature: Schema.optional(Schema.Array(FieldElement)),
275
- nonce: Schema.optional(FieldElement),
276
- contractAddressSalt: Schema.optional(FieldElement),
277
- constructorCalldata: Schema.optional(Schema.Array(FieldElement)),
278
- classHash: Schema.optional(FieldElement),
279
- resourceBounds: Schema.optional(ResourceBoundsMapping),
280
- tip: Schema.optional(Schema.BigIntFromSelf),
281
- paymasterData: Schema.optional(Schema.Array(FieldElement)),
282
- nonceDataAvailabilityMode: Schema.optional(DataAvailabilityMode),
283
- feeDataAvailabilityMode: Schema.optional(DataAvailabilityMode),
274
+ signature: Schema.Array(FieldElement),
275
+ nonce: FieldElement,
276
+ contractAddressSalt: FieldElement,
277
+ constructorCalldata: Schema.Array(FieldElement),
278
+ classHash: FieldElement,
279
+ resourceBounds: ResourceBoundsMapping,
280
+ tip: Schema.BigIntFromSelf,
281
+ paymasterData: Schema.Array(FieldElement),
282
+ nonceDataAvailabilityMode: DataAvailabilityMode,
283
+ feeDataAvailabilityMode: DataAvailabilityMode,
284
284
  }),
285
285
  });
286
286
 
@@ -289,22 +289,20 @@ export const DeployAccountTransactionV3 = Schema.Struct({
289
289
  * @prop meta Transaction metadata.
290
290
  */
291
291
  export const Transaction = Schema.Struct({
292
- filterIds: Schema.optional(Schema.Array(Schema.Number)),
293
- meta: Schema.optional(TransactionMeta),
294
- transaction: Schema.optional(
295
- Schema.Union(
296
- InvokeTransactionV0,
297
- InvokeTransactionV1,
298
- InvokeTransactionV3,
299
- L1HandlerTransaction,
300
- DeployTransaction,
301
- DeclareTransactionV0,
302
- DeclareTransactionV1,
303
- DeclareTransactionV2,
304
- DeclareTransactionV3,
305
- DeployAccountTransactionV1,
306
- DeployAccountTransactionV3,
307
- ),
292
+ filterIds: Schema.Array(Schema.Number),
293
+ meta: TransactionMeta,
294
+ transaction: Schema.Union(
295
+ InvokeTransactionV0,
296
+ InvokeTransactionV1,
297
+ InvokeTransactionV3,
298
+ L1HandlerTransaction,
299
+ DeployTransaction,
300
+ DeclareTransactionV0,
301
+ DeclareTransactionV1,
302
+ DeclareTransactionV2,
303
+ DeclareTransactionV3,
304
+ DeployAccountTransactionV1,
305
+ DeployAccountTransactionV3,
308
306
  ),
309
307
  });
310
308
 
@@ -331,12 +329,12 @@ export const PriceUnit = Schema.transform(
331
329
  );
332
330
 
333
331
  export const FeePayment = Schema.Struct({
334
- amount: Schema.optional(FieldElement),
335
- unit: Schema.optional(PriceUnit),
332
+ amount: FieldElement,
333
+ unit: PriceUnit,
336
334
  });
337
335
 
338
336
  export const ComputationResources = Schema.Struct({
339
- steps: Schema.optional(Schema.BigIntFromSelf),
337
+ steps: Schema.BigIntFromSelf,
340
338
  memoryHoles: Schema.optional(Schema.BigIntFromSelf),
341
339
  rangeCheckBuiltinApplications: Schema.optional(Schema.BigIntFromSelf),
342
340
  pedersenBuiltinApplications: Schema.optional(Schema.BigIntFromSelf),
@@ -349,13 +347,13 @@ export const ComputationResources = Schema.Struct({
349
347
  });
350
348
 
351
349
  export const DataAvailabilityResources = Schema.Struct({
352
- l1Gas: Schema.optional(Schema.BigIntFromSelf),
353
- l1DataGas: Schema.optional(Schema.BigIntFromSelf),
350
+ l1Gas: Schema.BigIntFromSelf,
351
+ l1DataGas: Schema.BigIntFromSelf,
354
352
  });
355
353
 
356
354
  export const ExecutionResources = Schema.Struct({
357
- computation: Schema.optional(ComputationResources),
358
- dataAvailability: Schema.optional(DataAvailabilityResources),
355
+ computation: ComputationResources,
356
+ dataAvailability: DataAvailabilityResources,
359
357
  });
360
358
 
361
359
  export const ExecutionSucceeded = Schema.Struct({
@@ -372,13 +370,11 @@ export const ExecutionReverted = Schema.Struct({
372
370
 
373
371
  /** Common fields for all transaction receipts. */
374
372
  export const TransactionReceiptMeta = Schema.Struct({
375
- transactionIndex: Schema.optional(Schema.Number),
376
- transactionHash: Schema.optional(FieldElement),
377
- actualFee: Schema.optional(FeePayment),
378
- executionResources: Schema.optional(ExecutionResources),
379
- executionResult: Schema.optional(
380
- Schema.Union(ExecutionSucceeded, ExecutionReverted),
381
- ),
373
+ transactionIndex: Schema.Number,
374
+ transactionHash: FieldElement,
375
+ actualFee: FeePayment,
376
+ executionResources: ExecutionResources,
377
+ executionResult: Schema.Union(ExecutionSucceeded, ExecutionReverted),
382
378
  });
383
379
 
384
380
  export const InvokeTransactionReceipt = Schema.Struct({
@@ -389,7 +385,7 @@ export const InvokeTransactionReceipt = Schema.Struct({
389
385
  export const L1HandlerTransactionReceipt = Schema.Struct({
390
386
  _tag: tag("l1Handler"),
391
387
  l1Handler: Schema.Struct({
392
- messageHash: Schema.optional(Schema.Uint8ArrayFromSelf),
388
+ messageHash: Schema.Uint8ArrayFromSelf,
393
389
  }),
394
390
  });
395
391
 
@@ -401,14 +397,14 @@ export const DeclareTransactionReceipt = Schema.Struct({
401
397
  export const DeployTransactionReceipt = Schema.Struct({
402
398
  _tag: tag("deploy"),
403
399
  deploy: Schema.Struct({
404
- contractAddress: Schema.optional(FieldElement),
400
+ contractAddress: FieldElement,
405
401
  }),
406
402
  });
407
403
 
408
404
  export const DeployAccountTransactionReceipt = Schema.Struct({
409
405
  _tag: tag("deployAccount"),
410
406
  deployAccount: Schema.Struct({
411
- contractAddress: Schema.optional(FieldElement),
407
+ contractAddress: FieldElement,
412
408
  }),
413
409
  });
414
410
 
@@ -418,16 +414,14 @@ export const DeployAccountTransactionReceipt = Schema.Struct({
418
414
  * @prop receipt Transaction-specific receipt.
419
415
  */
420
416
  export const TransactionReceipt = Schema.Struct({
421
- filterIds: Schema.optional(Schema.Array(Schema.Number)),
422
- meta: Schema.optional(TransactionReceiptMeta),
423
- receipt: Schema.optional(
424
- Schema.Union(
425
- InvokeTransactionReceipt,
426
- L1HandlerTransactionReceipt,
427
- DeclareTransactionReceipt,
428
- DeployTransactionReceipt,
429
- DeployAccountTransactionReceipt,
430
- ),
417
+ filterIds: Schema.Array(Schema.Number),
418
+ meta: TransactionReceiptMeta,
419
+ receipt: Schema.Union(
420
+ InvokeTransactionReceipt,
421
+ L1HandlerTransactionReceipt,
422
+ DeclareTransactionReceipt,
423
+ DeployTransactionReceipt,
424
+ DeployAccountTransactionReceipt,
431
425
  ),
432
426
  });
433
427
 
@@ -442,16 +436,18 @@ export type TransactionReceipt = typeof TransactionReceipt.Type;
442
436
  * @prop transactionIndex The transaction index in the block.
443
437
  * @prop transactionHash The transaction hash.
444
438
  * @prop transactionStatus The transaction status.
439
+ * @prop eventIndexInTransaction The event index in the transaction.
445
440
  */
446
441
  export const Event = Schema.Struct({
447
- filterIds: Schema.optional(Schema.Array(Schema.Number)),
448
- address: Schema.optional(FieldElement),
449
- keys: Schema.optional(Schema.Array(FieldElement)),
450
- data: Schema.optional(Schema.Array(FieldElement)),
451
- eventIndex: Schema.optional(Schema.Number),
452
- transactionIndex: Schema.optional(Schema.Number),
453
- transactionHash: Schema.optional(FieldElement),
454
- transactionStatus: Schema.optional(TransactionStatus),
442
+ filterIds: Schema.Array(Schema.Number),
443
+ address: FieldElement,
444
+ keys: Schema.Array(FieldElement),
445
+ data: Schema.Array(FieldElement),
446
+ eventIndex: Schema.Number,
447
+ transactionIndex: Schema.Number,
448
+ transactionHash: FieldElement,
449
+ transactionStatus: TransactionStatus,
450
+ eventIndexInTransaction: Schema.Number,
455
451
  });
456
452
 
457
453
  export type Event = typeof Event.Type;
@@ -465,20 +461,117 @@ export type Event = typeof Event.Type;
465
461
  * @prop transactionIndex The transaction index in the block.
466
462
  * @prop transactionHash The transaction hash.
467
463
  * @prop transactionStatus The transaction status.
464
+ * @prop messageIndexInTransaction The message index in the transaction.
468
465
  */
469
466
  export const MessageToL1 = Schema.Struct({
470
- filterIds: Schema.optional(Schema.Array(Schema.Number)),
471
- fromAddress: Schema.optional(FieldElement),
472
- toAddress: Schema.optional(FieldElement),
473
- payload: Schema.optional(Schema.Array(FieldElement)),
474
- messageIndex: Schema.optional(Schema.Number),
475
- transactionIndex: Schema.optional(Schema.Number),
476
- transactionHash: Schema.optional(FieldElement),
477
- transactionStatus: Schema.optional(TransactionStatus),
467
+ filterIds: Schema.Array(Schema.Number),
468
+ fromAddress: FieldElement,
469
+ toAddress: FieldElement,
470
+ payload: Schema.Array(FieldElement),
471
+ messageIndex: Schema.Number,
472
+ transactionIndex: Schema.Number,
473
+ transactionHash: FieldElement,
474
+ transactionStatus: TransactionStatus,
475
+ messageIndexInTransaction: Schema.Number,
478
476
  });
479
477
 
480
478
  export type MessageToL1 = typeof MessageToL1.Type;
481
479
 
480
+ /** An entry in the storage diff.
481
+ *
482
+ * @prop key The storage location.
483
+ * @prop value The new value at the storage location.
484
+ */
485
+ export const StorageEntry = Schema.Struct({
486
+ key: FieldElement,
487
+ value: FieldElement,
488
+ });
489
+
490
+ export type StorageEntry = typeof StorageEntry.Type;
491
+
492
+ /** Storage diff.
493
+ *
494
+ * @prop contractAddress The contract address.
495
+ * @prop storageEntries The entries that changed.
496
+ */
497
+ export const StorageDiff = Schema.Struct({
498
+ filterIds: Schema.Array(Schema.Number),
499
+ contractAddress: FieldElement,
500
+ storageEntries: Schema.Array(StorageEntry),
501
+ });
502
+
503
+ export type StorageDiff = typeof StorageDiff.Type;
504
+
505
+ /** A new class declared.
506
+ *
507
+ * @prop classHash The class hash.
508
+ * @prop compiledClassHash The compiled class hash. If undefined, it's the result of a deprecated Cairo 0 declaration.
509
+ */
510
+ export const DeclaredClass = Schema.Struct({
511
+ _tag: tag("declaredClass"),
512
+ declaredClass: Schema.Struct({
513
+ classHash: Schema.optional(FieldElement),
514
+ compiledClassHash: Schema.optional(FieldElement),
515
+ }),
516
+ });
517
+
518
+ export type DeclaredClass = typeof DeclaredClass.Type;
519
+
520
+ /** A class replaced.
521
+ *
522
+ * @prop contractAddress The contract address.
523
+ * @prop classHash The class new hash.
524
+ */
525
+ export const ReplacedClass = Schema.Struct({
526
+ _tag: tag("replacedClass"),
527
+ replacedClass: Schema.Struct({
528
+ contractAddress: Schema.optional(FieldElement),
529
+ classHash: Schema.optional(FieldElement),
530
+ }),
531
+ });
532
+
533
+ export type ReplacedClass = typeof ReplacedClass.Type;
534
+
535
+ /** A contract deployed.
536
+ *
537
+ * @prop contractAddress The contract address.
538
+ * @prop classHash The class hash.
539
+ */
540
+ export const DeployedContract = Schema.Struct({
541
+ _tag: tag("deployedContract"),
542
+ deployedContract: Schema.Struct({
543
+ contractAddress: Schema.optional(FieldElement),
544
+ classHash: Schema.optional(FieldElement),
545
+ }),
546
+ });
547
+
548
+ export type DeployedContract = typeof DeployedContract.Type;
549
+
550
+ /** A contract change.
551
+ *
552
+ * @prop contractAddress The contract address.
553
+ * @prop change The change.
554
+ */
555
+ export const ContractChange = Schema.Struct({
556
+ filterIds: Schema.Array(Schema.Number),
557
+ change: Schema.Union(DeclaredClass, ReplacedClass, DeployedContract),
558
+ });
559
+
560
+ export type ContractChange = typeof ContractChange.Type;
561
+
562
+ /** A nonce update.
563
+ *
564
+ * @prop contractAddress The contract address.
565
+ * @prop nonce The new nonce.
566
+ */
567
+ export const NonceUpdate = Schema.Struct({
568
+ filterIds: Schema.Array(Schema.Number),
569
+ contractAddress: FieldElement,
570
+ nonce: FieldElement,
571
+ });
572
+
573
+ export type NonceUpdate = typeof NonceUpdate.Type;
574
+
482
575
  /** A block.
483
576
  *
484
577
  * @prop header The block header.
@@ -486,13 +579,18 @@ export type MessageToL1 = typeof MessageToL1.Type;
486
579
  * @prop receipts The receipts of the transactions.
487
580
  * @prop events The events emitted by the transactions.
488
581
  * @prop messages The messages sent to L1 by the transactions.
582
+ * @prop storageDiffs The changes to the storage.
583
+ * @prop contractChanges The changes to contracts and classes.
489
584
  */
490
585
  export const Block = Schema.Struct({
491
- header: Schema.optional(BlockHeader),
586
+ header: BlockHeader,
492
587
  transactions: Schema.Array(Transaction),
493
588
  receipts: Schema.Array(TransactionReceipt),
494
589
  events: Schema.Array(Event),
495
590
  messages: Schema.Array(MessageToL1),
591
+ storageDiffs: Schema.Array(StorageDiff),
592
+ contractChanges: Schema.Array(ContractChange),
593
+ nonceUpdates: Schema.Array(NonceUpdate),
496
594
  });
497
595
 
498
596
  export type Block = typeof Block.Type;
package/src/common.ts CHANGED
@@ -34,5 +34,7 @@ export const FieldElement = Schema.transform(FieldElementProto, _FieldElement, {
34
34
  },
35
35
  });
36
36
 
37
+ export type FieldElement = Schema.Schema.Type<typeof FieldElement>;
38
+
37
39
  export const feltToProto = Schema.encodeSync(FieldElement);
38
40
  export const feltFromProto = Schema.decodeSync(FieldElement);