@apibara/indexer 0.3.0 → 0.4.0

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.
@@ -1,17 +1,17 @@
1
- import { FieldElement } from "./felt";
2
- export type Block = {
1
+ import type { FieldElement } from "./felt";
2
+ export type Block = Partial<{
3
3
  /** Block header. */
4
- header?: BlockHeader;
4
+ header: BlockHeader;
5
5
  /** Transactions. */
6
- transactions?: TransactionWithReceipt[];
6
+ transactions: TransactionWithReceipt[];
7
7
  /** Events. */
8
- events?: EventWithTransaction[];
8
+ events: EventWithTransaction[];
9
9
  /** Messages from L2 to L1. */
10
- l2ToL1Messages?: L2ToL1MessageWithTransaction[];
10
+ l2ToL1Messages: L2ToL1MessageWithTransaction[];
11
11
  /** State update. */
12
- stateUpdate?: StateUpdate;
13
- };
14
- export type BlockHeader = {
12
+ stateUpdate: StateUpdate;
13
+ }>;
14
+ export type BlockHeader = Partial<{
15
15
  /** Block hash. */
16
16
  blockHash: FieldElement;
17
17
  /** Parent block hash. */
@@ -26,7 +26,11 @@ export type BlockHeader = {
26
26
  timestamp: string;
27
27
  /** Price of L1 gas in the block. */
28
28
  l1GasPrice?: ResourcePrice;
29
- };
29
+ /** Price of L1 data gas in the block. */
30
+ l1DataGasPrice?: ResourcePrice;
31
+ /** L1 data availability mode. */
32
+ l1DataAvailabilityMode?: L1DataAvailabilityMode;
33
+ }>;
30
34
  export type TransactionWithReceipt = {
31
35
  /** Transaction. */
32
36
  transaction: Transaction;
@@ -51,7 +55,7 @@ export type Transaction = TransactionCommon & (InvokeTransactionV0 | InvokeTrans
51
55
  export type TransactionCommon = {
52
56
  meta: TransactionMeta;
53
57
  };
54
- export type TransactionMeta = {
58
+ export type TransactionMeta = Partial<{
55
59
  /** Transaction hash. */
56
60
  hash: FieldElement;
57
61
  /** Maximum fee. */
@@ -74,16 +78,16 @@ export type TransactionMeta = {
74
78
  feeDataAvailabilityMode?: DataAvailabilityMode;
75
79
  /** Transaction index in the block. */
76
80
  transactionIndex?: number;
77
- };
81
+ }>;
78
82
  export type InvokeTransactionV0 = {
79
- invokeV0?: {
83
+ invokeV0?: Partial<{
80
84
  /** Target contract address. */
81
85
  contractAddress: FieldElement;
82
86
  /** Selector of the function being invoked. */
83
87
  entryPointSelector: FieldElement;
84
88
  /** Calldata. */
85
89
  calldata: FieldElement[];
86
- };
90
+ }>;
87
91
  invokeV1?: never;
88
92
  invokeV3?: never;
89
93
  deploy?: never;
@@ -94,12 +98,12 @@ export type InvokeTransactionV0 = {
94
98
  deployAccountV3?: never;
95
99
  };
96
100
  export type InvokeTransactionV1 = {
97
- invokeV1?: {
101
+ invokeV1?: Partial<{
98
102
  /** Address of the account sending the transaction. */
99
103
  senderAddress: FieldElement;
100
104
  /** Calldata. */
101
105
  calldata: FieldElement[];
102
- };
106
+ }>;
103
107
  invokeV0?: never;
104
108
  invokeV3?: never;
105
109
  deploy?: never;
@@ -110,14 +114,14 @@ export type InvokeTransactionV1 = {
110
114
  deployAccountV3?: never;
111
115
  };
112
116
  export type InvokeTransactionV3 = {
113
- invokeV3?: {
117
+ invokeV3?: Partial<{
114
118
  /** Address of the account sending the transaction. */
115
119
  senderAddress: FieldElement;
116
120
  /** Calldata. */
117
121
  calldata: FieldElement[];
118
122
  /** Data passed to the account deployment. */
119
123
  accountDeploymentData: FieldElement[];
120
- };
124
+ }>;
121
125
  invokeV1?: never;
122
126
  invokeV0?: never;
123
127
  deploy?: never;
@@ -128,14 +132,14 @@ export type InvokeTransactionV3 = {
128
132
  deployAccountV3?: never;
129
133
  };
130
134
  export type DeployTransaction = {
131
- deploy?: {
135
+ deploy?: Partial<{
132
136
  /** Constructor calldata. */
133
137
  constructorCalldata: FieldElement[];
134
138
  /** Salt used when computing the contract's address. */
135
139
  contractAddressSalt: FieldElement;
136
140
  /** Hash of the class being deployed. */
137
141
  classHash: FieldElement;
138
- };
142
+ }>;
139
143
  invokeV0?: never;
140
144
  invokeV1?: never;
141
145
  invokeV3?: never;
@@ -146,14 +150,14 @@ export type DeployTransaction = {
146
150
  deployAccountV3?: never;
147
151
  };
148
152
  export type DeclareTransaction = {
149
- declare?: {
153
+ declare?: Partial<{
150
154
  /** Class hash. */
151
155
  classHash: FieldElement;
152
156
  /** Address of the account sending the transaction. */
153
157
  senderAddress: FieldElement;
154
158
  /** Hash of the cairo assembly resulting from the sierra compilation. */
155
159
  compiledClassHash: FieldElement;
156
- };
160
+ }>;
157
161
  declareV3?: never;
158
162
  invokeV0?: never;
159
163
  invokeV1?: never;
@@ -164,7 +168,7 @@ export type DeclareTransaction = {
164
168
  deployAccountV3?: never;
165
169
  };
166
170
  export type DeclareTransactionV3 = {
167
- declareV3?: {
171
+ declareV3?: Partial<{
168
172
  /** Class hash. */
169
173
  classHash: FieldElement;
170
174
  /** Address of the account sending the transaction. */
@@ -173,7 +177,7 @@ export type DeclareTransactionV3 = {
173
177
  compiledClassHash: FieldElement;
174
178
  /** Data passed to the account deployment. */
175
179
  accountDeploymentData: FieldElement[];
176
- };
180
+ }>;
177
181
  declare?: never;
178
182
  invokeV0?: never;
179
183
  invokeV1?: never;
@@ -184,14 +188,14 @@ export type DeclareTransactionV3 = {
184
188
  deployAccount?: never;
185
189
  };
186
190
  export type DeployAccountTransaction = {
187
- deployAccount?: {
191
+ deployAccount?: Partial<{
188
192
  /** Constructor calldata. */
189
193
  constructorCalldata: FieldElement[];
190
194
  /** Salt used when computing the contract's address. */
191
195
  contractAddressSalt: FieldElement;
192
196
  /** Hash of the class being deployed. */
193
197
  classHash: FieldElement;
194
- };
198
+ }>;
195
199
  deployAccountV3?: never;
196
200
  invokeV0?: never;
197
201
  invokeV1?: never;
@@ -202,14 +206,14 @@ export type DeployAccountTransaction = {
202
206
  l1Handler?: never;
203
207
  };
204
208
  export type DeployAccountTransactionV3 = {
205
- deployAccountV3?: {
209
+ deployAccountV3?: Partial<{
206
210
  /** Constructor calldata. */
207
211
  constructorCalldata: FieldElement[];
208
212
  /** Salt used when computing the contract's address. */
209
213
  contractAddressSalt: FieldElement;
210
214
  /** Hash of the class being deployed. */
211
215
  classHash: FieldElement;
212
- };
216
+ }>;
213
217
  deployAccount?: never;
214
218
  invokeV0?: never;
215
219
  invokeV1?: never;
@@ -220,14 +224,14 @@ export type DeployAccountTransactionV3 = {
220
224
  l1Handler?: never;
221
225
  };
222
226
  export type L1HandlerTransaction = {
223
- l1Handler?: {
227
+ l1Handler?: Partial<{
224
228
  /** Target contract address. */
225
229
  contractAddress: FieldElement;
226
230
  /** Selector of the function being invoked. */
227
231
  entryPointSelector: FieldElement;
228
232
  /** Calldata. */
229
233
  calldata: FieldElement[];
230
- };
234
+ }>;
231
235
  invokeV0?: never;
232
236
  invokeV1?: never;
233
237
  invokeV3?: never;
@@ -236,7 +240,7 @@ export type L1HandlerTransaction = {
236
240
  declareV3?: never;
237
241
  deployAccount?: never;
238
242
  };
239
- export type TransactionReceipt = {
243
+ export type TransactionReceipt = Partial<{
240
244
  /** Transaction status. */
241
245
  executionStatus: ExecutionStatus;
242
246
  /** Transaction hash. */
@@ -252,10 +256,55 @@ export type TransactionReceipt = {
252
256
  /** Events. */
253
257
  events: Event[];
254
258
  /** Revert reason. */
255
- revertReason?: string;
256
- };
259
+ revertReason: string;
260
+ /** Fee paid. */
261
+ actualFeePaid: FeePayment;
262
+ /** Resources consumed by the transaction. */
263
+ executionResources: ExecutionResources;
264
+ }>;
257
265
  export type ExecutionStatus = "EXECUTION_STATUS_UNSPECIFIED" | "EXECUTION_STATUS_SUCCEEDED" | "EXECUTION_STATUS_REVERTED";
258
- export type Event = {
266
+ export type FeePayment = Partial<{
267
+ /** Amount paid. */
268
+ amount: FieldElement;
269
+ /** Unit of the amount. */
270
+ unit: PriceUnit;
271
+ }>;
272
+ export type ExecutionResources = Partial<{
273
+ /** Computation resources. */
274
+ computation: ComputationResources;
275
+ /** Data availability resources. */
276
+ dataAvailability: DataAvailabilityResources;
277
+ }>;
278
+ export type ComputationResources = Partial<{
279
+ /** The gas consumed by this transaction's data, 0 if it uses data gas for DA. */
280
+ l1Gas: number;
281
+ /** The data gas consumed by this transaction's data, 0 if it uses gas for DA. */
282
+ l1DataGas: number;
283
+ }>;
284
+ export type DataAvailabilityResources = Partial<{
285
+ /** The number of Cairo steps used. */
286
+ steps: number;
287
+ /** The number of unused memory cells. */
288
+ memoryHoles: number;
289
+ /** The number of RANGE_CHECK builtin instances. */
290
+ rangeCheckBuiltinApplications: number;
291
+ /** The number of Pedersen builtin instances. */
292
+ pedersenBuiltinApplications: number;
293
+ /** The number of Poseidon builtin instances. */
294
+ poseidonBuiltinApplications: number;
295
+ /** The number of EC_OP builtin instances. */
296
+ ecOpBuiltinApplications: number;
297
+ /** The number of ECDSA builtin instances. */
298
+ ecdsaBuiltinApplications: number;
299
+ /** The number of BITWISE builtin instances. */
300
+ bitwiseBuiltinApplications: number;
301
+ /** The number of KECCAK builtin instances. */
302
+ keccakBuiltinApplications: number;
303
+ /** The number of accesses to the segment arena. */
304
+ segmentArenaBuiltin: number;
305
+ }>;
306
+ export type PriceUnit = "PRICE_UNIT_UNSPECIFIED" | "PRICE_UNIT_FRI" | "PRICE_UNIT_WEI";
307
+ export type Event = Partial<{
259
308
  /** Event index. */
260
309
  index: number;
261
310
  /** Contract address. */
@@ -264,8 +313,8 @@ export type Event = {
264
313
  keys: FieldElement[];
265
314
  /** Event data. */
266
315
  data: FieldElement[];
267
- };
268
- export type L2ToL1Message = {
316
+ }>;
317
+ export type L2ToL1Message = Partial<{
269
318
  /** Message index. */
270
319
  index: number;
271
320
  /** L2 sender address. */
@@ -274,16 +323,16 @@ export type L2ToL1Message = {
274
323
  toAddress: FieldElement;
275
324
  /** Calldata. */
276
325
  payload: FieldElement[];
277
- };
278
- export type StateUpdate = {
326
+ }>;
327
+ export type StateUpdate = Partial<{
279
328
  /** New state root. */
280
329
  newRoot: FieldElement;
281
330
  /** Old state root. */
282
331
  oldRoot: FieldElement;
283
332
  /** State diff. */
284
333
  stateDiff: StateDiff;
285
- };
286
- export type StateDiff = {
334
+ }>;
335
+ export type StateDiff = Partial<{
287
336
  /** Changes in storage. */
288
337
  storageDiffs: StorageDiff[];
289
338
  /** Declared contracts. */
@@ -296,62 +345,63 @@ export type StateDiff = {
296
345
  declaredClasses: DeclaredClass[];
297
346
  /** Classes replaced. */
298
347
  replacedClasses: ReplacedClass[];
299
- };
300
- export type StorageDiff = {
348
+ }>;
349
+ export type StorageDiff = Partial<{
301
350
  /** Contract address. */
302
351
  contractAddress: FieldElement;
303
352
  /** Changes in storage. */
304
353
  storageEntries: StorageEntry[];
305
- };
306
- export type StorageEntry = {
354
+ }>;
355
+ export type StorageEntry = Partial<{
307
356
  /** Storage key. */
308
357
  key: FieldElement;
309
358
  /** New storage value. */
310
359
  value: FieldElement;
311
- };
312
- export type DeclaredContract = {
360
+ }>;
361
+ export type DeclaredContract = Partial<{
313
362
  /** Class hash. */
314
363
  classHash: FieldElement;
315
- };
316
- export type DeclaredClass = {
364
+ }>;
365
+ export type DeclaredClass = Partial<{
317
366
  /** Class hash. */
318
367
  classHash: FieldElement;
319
368
  /** Compiled class hash. */
320
369
  compiledClassHash: FieldElement;
321
- };
322
- export type ReplacedClass = {
370
+ }>;
371
+ export type ReplacedClass = Partial<{
323
372
  /** Contract address. */
324
373
  contractAddress: FieldElement;
325
374
  /** Class hash. */
326
375
  classHash: FieldElement;
327
- };
328
- export type DeployedContract = {
376
+ }>;
377
+ export type DeployedContract = Partial<{
329
378
  /** Contract address. */
330
379
  contractAddress: FieldElement;
331
380
  /** Class hash. */
332
381
  classHash: FieldElement;
333
- };
334
- export type NonceUpdate = {
382
+ }>;
383
+ export type NonceUpdate = Partial<{
335
384
  /** Contract address. */
336
385
  contractAddress: FieldElement;
337
386
  /** New nonce. */
338
387
  nonce: FieldElement;
339
- };
340
- export type ResourcePrice = {
388
+ }>;
389
+ export type ResourcePrice = Partial<{
341
390
  /** Price in fri (10^-18 strk). */
342
391
  priceInFri: FieldElement;
343
392
  /** Price in wei (10^-18 eth). */
344
393
  priceInWei: FieldElement;
345
- };
346
- export type ResourceBoundsMapping = {
394
+ }>;
395
+ export type ResourceBoundsMapping = Partial<{
347
396
  l1Gas: ResourceBounds;
348
397
  l2Gas: ResourceBounds;
349
- };
350
- export type ResourceBounds = {
398
+ }>;
399
+ export type ResourceBounds = Partial<{
351
400
  maxAmount: number;
352
- maxPricePerUnit: {
401
+ maxPricePerUnit: Partial<{
353
402
  low: number;
354
403
  high: number;
355
- };
356
- };
404
+ }>;
405
+ }>;
357
406
  export type DataAvailabilityMode = "DATA_AVAILABILITY_MODE_UNSPECIFIED" | "DATA_AVAILABILITY_MODE_L2" | "DATA_AVAILABILITY_MODE_L1";
407
+ export type L1DataAvailabilityMode = "L1_DATA_AVAILABILITY_MODE_UNSPECIFIED" | "L1_DATA_AVAILABILITY_MODE_BLOB" | "L1_DATA_AVAILABILITY_MODE_CALLDATA";
@@ -1,4 +1,4 @@
1
- import { FieldElement } from "./felt";
1
+ import type { FieldElement } from "./felt";
2
2
  export type Filter = {
3
3
  /** Header information. */
4
4
  header?: HeaderFilter;
@@ -2,7 +2,7 @@ export * from "./filter";
2
2
  export * from "./block";
3
3
  export { FieldElement, getSelector } from "./felt";
4
4
  export { Contract } from "./parser";
5
- import { Filter } from "./filter";
5
+ import type { Filter } from "./filter";
6
6
  /** Starknet network type and data filter. */
7
7
  export type Starknet = {
8
8
  network: "starknet";
@@ -1,6 +1,6 @@
1
- import { type Abi } from "starknet";
2
- import { FieldElement } from "./felt";
3
- import { EventFilter } from "./filter";
1
+ import type { Abi } from "starknet";
2
+ import { type FieldElement } from "./felt";
3
+ import type { EventFilter } from "./filter";
4
4
  /** Build a stream filter from a contract ABI. */
5
5
  export declare class Contract {
6
6
  readonly address: FieldElement;
@@ -1 +1 @@
1
- {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/starknet/parser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,WAAW,EAAE,MAAM,QAAQ,CAAC;AAGnD,iDAAiD;AACjD,MAA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I,CAAC;SAC5D;IACH,CAAC;IAED,iEAAiE;IACjE,WAAW,CACT,IAAY,EACZ,OAGI,EAAE;QAEN,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAEpC,sDAAsD;QACtD,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,4BAA4B,CAAC,CAAC;SAC5D;QAED,0BAA0B;QAC1B,OAAO;YACL,WAAW,EAAE,IAAI,CAAC,OAAO;YACzB,IAAI,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC/B,kBAAkB,EAAE,IAAI,CAAC,kBAAkB,IAAI,KAAK;YACpD,cAAc,EAAE,IAAI,CAAC,cAAc,IAAI,KAAK;YAC5C,eAAe,EAAE,IAAI,CAAC,eAAe,IAAI,KAAK;SAC/C,CAAC;IACJ,CAAC;IAED,oDAAoD;IACpD,uBAAuB,CAAC,QAAsB;QAC5C,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apibara/indexer",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,6 +1,6 @@
1
1
  import { assertType, describe, test } from "vitest";
2
2
 
3
- import { Config } from "./config";
3
+ import type { Config } from "./config";
4
4
 
5
5
  describe("Config", () => {
6
6
  test("without any network or sink type", () => {
@@ -1,6 +1,6 @@
1
1
  import { assertType, describe, test } from "vitest";
2
2
 
3
- import { Console } from "./console";
3
+ import type { Console } from "./console";
4
4
 
5
5
  describe("Console", () => {
6
6
  test("accepts any option", () => {
@@ -1,6 +1,6 @@
1
1
  import { assertType, describe, test } from "vitest";
2
2
 
3
- import { Block, BlockHeader, Transaction, TransactionMeta } from "./block";
3
+ import type { Block, BlockHeader, Transaction, TransactionMeta } from "./block";
4
4
  import { FieldElement } from "./felt";
5
5
 
6
6
  const address =
@@ -1,19 +1,19 @@
1
- import { FieldElement } from "./felt";
1
+ import type { FieldElement } from "./felt";
2
2
 
3
- export type Block = {
3
+ export type Block = Partial<{
4
4
  /** Block header. */
5
- header?: BlockHeader;
5
+ header: BlockHeader;
6
6
  /** Transactions. */
7
- transactions?: TransactionWithReceipt[];
7
+ transactions: TransactionWithReceipt[];
8
8
  /** Events. */
9
- events?: EventWithTransaction[];
9
+ events: EventWithTransaction[];
10
10
  /** Messages from L2 to L1. */
11
- l2ToL1Messages?: L2ToL1MessageWithTransaction[];
11
+ l2ToL1Messages: L2ToL1MessageWithTransaction[];
12
12
  /** State update. */
13
- stateUpdate?: StateUpdate;
14
- };
13
+ stateUpdate: StateUpdate;
14
+ }>;
15
15
 
16
- export type BlockHeader = {
16
+ export type BlockHeader = Partial<{
17
17
  /** Block hash. */
18
18
  blockHash: FieldElement;
19
19
  /** Parent block hash. */
@@ -28,7 +28,11 @@ export type BlockHeader = {
28
28
  timestamp: string;
29
29
  /** Price of L1 gas in the block. */
30
30
  l1GasPrice?: ResourcePrice;
31
- };
31
+ /** Price of L1 data gas in the block. */
32
+ l1DataGasPrice?: ResourcePrice;
33
+ /** L1 data availability mode. */
34
+ l1DataAvailabilityMode?: L1DataAvailabilityMode;
35
+ }>;
32
36
 
33
37
  export type TransactionWithReceipt = {
34
38
  /** Transaction. */
@@ -70,7 +74,7 @@ export type TransactionCommon = {
70
74
  meta: TransactionMeta;
71
75
  };
72
76
 
73
- export type TransactionMeta = {
77
+ export type TransactionMeta = Partial<{
74
78
  /** Transaction hash. */
75
79
  hash: FieldElement;
76
80
  /** Maximum fee. */
@@ -93,17 +97,17 @@ export type TransactionMeta = {
93
97
  feeDataAvailabilityMode?: DataAvailabilityMode;
94
98
  /** Transaction index in the block. */
95
99
  transactionIndex?: number;
96
- };
100
+ }>;
97
101
 
98
102
  export type InvokeTransactionV0 = {
99
- invokeV0?: {
103
+ invokeV0?: Partial<{
100
104
  /** Target contract address. */
101
105
  contractAddress: FieldElement;
102
106
  /** Selector of the function being invoked. */
103
107
  entryPointSelector: FieldElement;
104
108
  /** Calldata. */
105
109
  calldata: FieldElement[];
106
- };
110
+ }>;
107
111
  invokeV1?: never;
108
112
  invokeV3?: never;
109
113
  deploy?: never;
@@ -115,12 +119,12 @@ export type InvokeTransactionV0 = {
115
119
  };
116
120
 
117
121
  export type InvokeTransactionV1 = {
118
- invokeV1?: {
122
+ invokeV1?: Partial<{
119
123
  /** Address of the account sending the transaction. */
120
124
  senderAddress: FieldElement;
121
125
  /** Calldata. */
122
126
  calldata: FieldElement[];
123
- };
127
+ }>;
124
128
  invokeV0?: never;
125
129
  invokeV3?: never;
126
130
  deploy?: never;
@@ -132,14 +136,14 @@ export type InvokeTransactionV1 = {
132
136
  };
133
137
 
134
138
  export type InvokeTransactionV3 = {
135
- invokeV3?: {
139
+ invokeV3?: Partial<{
136
140
  /** Address of the account sending the transaction. */
137
141
  senderAddress: FieldElement;
138
142
  /** Calldata. */
139
143
  calldata: FieldElement[];
140
144
  /** Data passed to the account deployment. */
141
145
  accountDeploymentData: FieldElement[];
142
- };
146
+ }>;
143
147
  invokeV1?: never;
144
148
  invokeV0?: never;
145
149
  deploy?: never;
@@ -151,14 +155,14 @@ export type InvokeTransactionV3 = {
151
155
  };
152
156
 
153
157
  export type DeployTransaction = {
154
- deploy?: {
158
+ deploy?: Partial<{
155
159
  /** Constructor calldata. */
156
160
  constructorCalldata: FieldElement[];
157
161
  /** Salt used when computing the contract's address. */
158
162
  contractAddressSalt: FieldElement;
159
163
  /** Hash of the class being deployed. */
160
164
  classHash: FieldElement;
161
- };
165
+ }>;
162
166
  invokeV0?: never;
163
167
  invokeV1?: never;
164
168
  invokeV3?: never;
@@ -170,14 +174,14 @@ export type DeployTransaction = {
170
174
  };
171
175
 
172
176
  export type DeclareTransaction = {
173
- declare?: {
177
+ declare?: Partial<{
174
178
  /** Class hash. */
175
179
  classHash: FieldElement;
176
180
  /** Address of the account sending the transaction. */
177
181
  senderAddress: FieldElement;
178
182
  /** Hash of the cairo assembly resulting from the sierra compilation. */
179
183
  compiledClassHash: FieldElement;
180
- };
184
+ }>;
181
185
  declareV3?: never;
182
186
  invokeV0?: never;
183
187
  invokeV1?: never;
@@ -189,7 +193,7 @@ export type DeclareTransaction = {
189
193
  };
190
194
 
191
195
  export type DeclareTransactionV3 = {
192
- declareV3?: {
196
+ declareV3?: Partial<{
193
197
  /** Class hash. */
194
198
  classHash: FieldElement;
195
199
  /** Address of the account sending the transaction. */
@@ -198,7 +202,7 @@ export type DeclareTransactionV3 = {
198
202
  compiledClassHash: FieldElement;
199
203
  /** Data passed to the account deployment. */
200
204
  accountDeploymentData: FieldElement[];
201
- };
205
+ }>;
202
206
  declare?: never;
203
207
  invokeV0?: never;
204
208
  invokeV1?: never;
@@ -210,14 +214,14 @@ export type DeclareTransactionV3 = {
210
214
  };
211
215
 
212
216
  export type DeployAccountTransaction = {
213
- deployAccount?: {
217
+ deployAccount?: Partial<{
214
218
  /** Constructor calldata. */
215
219
  constructorCalldata: FieldElement[];
216
220
  /** Salt used when computing the contract's address. */
217
221
  contractAddressSalt: FieldElement;
218
222
  /** Hash of the class being deployed. */
219
223
  classHash: FieldElement;
220
- };
224
+ }>;
221
225
  deployAccountV3?: never;
222
226
  invokeV0?: never;
223
227
  invokeV1?: never;
@@ -229,14 +233,14 @@ export type DeployAccountTransaction = {
229
233
  };
230
234
 
231
235
  export type DeployAccountTransactionV3 = {
232
- deployAccountV3?: {
236
+ deployAccountV3?: Partial<{
233
237
  /** Constructor calldata. */
234
238
  constructorCalldata: FieldElement[];
235
239
  /** Salt used when computing the contract's address. */
236
240
  contractAddressSalt: FieldElement;
237
241
  /** Hash of the class being deployed. */
238
242
  classHash: FieldElement;
239
- };
243
+ }>;
240
244
  deployAccount?: never;
241
245
  invokeV0?: never;
242
246
  invokeV1?: never;
@@ -248,14 +252,14 @@ export type DeployAccountTransactionV3 = {
248
252
  };
249
253
 
250
254
  export type L1HandlerTransaction = {
251
- l1Handler?: {
255
+ l1Handler?: Partial<{
252
256
  /** Target contract address. */
253
257
  contractAddress: FieldElement;
254
258
  /** Selector of the function being invoked. */
255
259
  entryPointSelector: FieldElement;
256
260
  /** Calldata. */
257
261
  calldata: FieldElement[];
258
- };
262
+ }>;
259
263
  invokeV0?: never;
260
264
  invokeV1?: never;
261
265
  invokeV3?: never;
@@ -265,7 +269,7 @@ export type L1HandlerTransaction = {
265
269
  deployAccount?: never;
266
270
  };
267
271
 
268
- export type TransactionReceipt = {
272
+ export type TransactionReceipt = Partial<{
269
273
  /** Transaction status. */
270
274
  executionStatus: ExecutionStatus;
271
275
  /** Transaction hash. */
@@ -281,15 +285,68 @@ export type TransactionReceipt = {
281
285
  /** Events. */
282
286
  events: Event[];
283
287
  /** Revert reason. */
284
- revertReason?: string;
285
- };
288
+ revertReason: string;
289
+ /** Fee paid. */
290
+ actualFeePaid: FeePayment;
291
+ /** Resources consumed by the transaction. */
292
+ executionResources: ExecutionResources;
293
+ }>;
286
294
 
287
295
  export type ExecutionStatus =
288
296
  | "EXECUTION_STATUS_UNSPECIFIED"
289
297
  | "EXECUTION_STATUS_SUCCEEDED"
290
298
  | "EXECUTION_STATUS_REVERTED";
291
299
 
292
- export type Event = {
300
+ export type FeePayment = Partial<{
301
+ /** Amount paid. */
302
+ amount: FieldElement;
303
+ /** Unit of the amount. */
304
+ unit: PriceUnit;
305
+ }>;
306
+
307
+ export type ExecutionResources = Partial<{
308
+ /** Computation resources. */
309
+ computation: ComputationResources;
310
+ /** Data availability resources. */
311
+ dataAvailability: DataAvailabilityResources;
312
+ }>;
313
+
314
+ export type ComputationResources = Partial<{
315
+ /** The gas consumed by this transaction's data, 0 if it uses data gas for DA. */
316
+ l1Gas: number;
317
+ /** The data gas consumed by this transaction's data, 0 if it uses gas for DA. */
318
+ l1DataGas: number;
319
+ }>;
320
+
321
+ export type DataAvailabilityResources = Partial<{
322
+ /** The number of Cairo steps used. */
323
+ steps: number;
324
+ /** The number of unused memory cells. */
325
+ memoryHoles: number;
326
+ /** The number of RANGE_CHECK builtin instances. */
327
+ rangeCheckBuiltinApplications: number;
328
+ /** The number of Pedersen builtin instances. */
329
+ pedersenBuiltinApplications: number;
330
+ /** The number of Poseidon builtin instances. */
331
+ poseidonBuiltinApplications: number;
332
+ /** The number of EC_OP builtin instances. */
333
+ ecOpBuiltinApplications: number;
334
+ /** The number of ECDSA builtin instances. */
335
+ ecdsaBuiltinApplications: number;
336
+ /** The number of BITWISE builtin instances. */
337
+ bitwiseBuiltinApplications: number;
338
+ /** The number of KECCAK builtin instances. */
339
+ keccakBuiltinApplications: number;
340
+ /** The number of accesses to the segment arena. */
341
+ segmentArenaBuiltin: number;
342
+ }>;
343
+
344
+ export type PriceUnit =
345
+ | "PRICE_UNIT_UNSPECIFIED"
346
+ | "PRICE_UNIT_FRI"
347
+ | "PRICE_UNIT_WEI";
348
+
349
+ export type Event = Partial<{
293
350
  /** Event index. */
294
351
  index: number;
295
352
  /** Contract address. */
@@ -298,9 +355,9 @@ export type Event = {
298
355
  keys: FieldElement[];
299
356
  /** Event data. */
300
357
  data: FieldElement[];
301
- };
358
+ }>;
302
359
 
303
- export type L2ToL1Message = {
360
+ export type L2ToL1Message = Partial<{
304
361
  /** Message index. */
305
362
  index: number;
306
363
  /** L2 sender address. */
@@ -309,18 +366,18 @@ export type L2ToL1Message = {
309
366
  toAddress: FieldElement;
310
367
  /** Calldata. */
311
368
  payload: FieldElement[];
312
- };
369
+ }>;
313
370
 
314
- export type StateUpdate = {
371
+ export type StateUpdate = Partial<{
315
372
  /** New state root. */
316
373
  newRoot: FieldElement;
317
374
  /** Old state root. */
318
375
  oldRoot: FieldElement;
319
376
  /** State diff. */
320
377
  stateDiff: StateDiff;
321
- };
378
+ }>;
322
379
 
323
- export type StateDiff = {
380
+ export type StateDiff = Partial<{
324
381
  /** Changes in storage. */
325
382
  storageDiffs: StorageDiff[];
326
383
  /** Declared contracts. */
@@ -333,73 +390,78 @@ export type StateDiff = {
333
390
  declaredClasses: DeclaredClass[];
334
391
  /** Classes replaced. */
335
392
  replacedClasses: ReplacedClass[];
336
- };
393
+ }>;
337
394
 
338
- export type StorageDiff = {
395
+ export type StorageDiff = Partial<{
339
396
  /** Contract address. */
340
397
  contractAddress: FieldElement;
341
398
  /** Changes in storage. */
342
399
  storageEntries: StorageEntry[];
343
- };
400
+ }>;
344
401
 
345
- export type StorageEntry = {
402
+ export type StorageEntry = Partial<{
346
403
  /** Storage key. */
347
404
  key: FieldElement;
348
405
  /** New storage value. */
349
406
  value: FieldElement;
350
- };
407
+ }>;
351
408
 
352
- export type DeclaredContract = {
409
+ export type DeclaredContract = Partial<{
353
410
  /** Class hash. */
354
411
  classHash: FieldElement;
355
- };
412
+ }>;
356
413
 
357
- export type DeclaredClass = {
414
+ export type DeclaredClass = Partial<{
358
415
  /** Class hash. */
359
416
  classHash: FieldElement;
360
417
  /** Compiled class hash. */
361
418
  compiledClassHash: FieldElement;
362
- };
419
+ }>;
363
420
 
364
- export type ReplacedClass = {
421
+ export type ReplacedClass = Partial<{
365
422
  /** Contract address. */
366
423
  contractAddress: FieldElement;
367
424
  /** Class hash. */
368
425
  classHash: FieldElement;
369
- };
426
+ }>;
370
427
 
371
- export type DeployedContract = {
428
+ export type DeployedContract = Partial<{
372
429
  /** Contract address. */
373
430
  contractAddress: FieldElement;
374
431
  /** Class hash. */
375
432
  classHash: FieldElement;
376
- };
433
+ }>;
377
434
 
378
- export type NonceUpdate = {
435
+ export type NonceUpdate = Partial<{
379
436
  /** Contract address. */
380
437
  contractAddress: FieldElement;
381
438
  /** New nonce. */
382
439
  nonce: FieldElement;
383
- };
440
+ }>;
384
441
 
385
- export type ResourcePrice = {
442
+ export type ResourcePrice = Partial<{
386
443
  /** Price in fri (10^-18 strk). */
387
444
  priceInFri: FieldElement;
388
445
  /** Price in wei (10^-18 eth). */
389
446
  priceInWei: FieldElement;
390
- };
447
+ }>;
391
448
 
392
- export type ResourceBoundsMapping = {
449
+ export type ResourceBoundsMapping = Partial<{
393
450
  l1Gas: ResourceBounds;
394
451
  l2Gas: ResourceBounds;
395
- };
452
+ }>;
396
453
 
397
- export type ResourceBounds = {
454
+ export type ResourceBounds = Partial<{
398
455
  maxAmount: number;
399
- maxPricePerUnit: { low: number; high: number };
400
- };
456
+ maxPricePerUnit: Partial<{ low: number; high: number }>;
457
+ }>;
401
458
 
402
459
  export type DataAvailabilityMode =
403
460
  | "DATA_AVAILABILITY_MODE_UNSPECIFIED"
404
461
  | "DATA_AVAILABILITY_MODE_L2"
405
462
  | "DATA_AVAILABILITY_MODE_L1";
463
+
464
+ export type L1DataAvailabilityMode =
465
+ | "L1_DATA_AVAILABILITY_MODE_UNSPECIFIED"
466
+ | "L1_DATA_AVAILABILITY_MODE_BLOB"
467
+ | "L1_DATA_AVAILABILITY_MODE_CALLDATA";
@@ -1,7 +1,7 @@
1
1
  import { assertType, describe, test } from "vitest";
2
2
 
3
3
  import { FieldElement } from "./felt";
4
- import {
4
+ import type {
5
5
  EventFilter,
6
6
  Filter,
7
7
  L2ToL1MessageFilter,
@@ -1,4 +1,4 @@
1
- import { FieldElement } from "./felt";
1
+ import type { FieldElement } from "./felt";
2
2
 
3
3
  export type Filter = {
4
4
  /** Header information. */
@@ -3,7 +3,7 @@ export * from "./block";
3
3
  export { FieldElement, getSelector } from "./felt";
4
4
  export { Contract } from "./parser";
5
5
 
6
- import { Filter } from "./filter";
6
+ import type { Filter } from "./filter";
7
7
 
8
8
  /** Starknet network type and data filter. */
9
9
  export type Starknet = {
@@ -1,6 +1,6 @@
1
1
  import { Contract } from "./parser";
2
2
  import { describe, expect, it } from "vitest";
3
- import { FieldElement } from "./felt";
3
+ import type { FieldElement } from "./felt";
4
4
  import { EventAbi } from "starknet";
5
5
 
6
6
  describe("Contract", () => {
@@ -1,7 +1,7 @@
1
- import { type Abi, EventAbi } from "starknet";
1
+ import type { Abi, EventAbi } from "starknet";
2
2
 
3
- import { FieldElement, getSelector } from "./felt";
4
- import { EventFilter } from "./filter";
3
+ import { type FieldElement, getSelector } from "./felt";
4
+ import type { EventFilter } from "./filter";
5
5
 
6
6
  /** Build a stream filter from a contract ABI. */
7
7
  export class Contract {