@apibara/indexer 0.2.5 → 0.3.1

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
1
  import { FieldElement } from "./felt";
2
- export type Block = {
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. */
@@ -24,7 +24,9 @@ export type BlockHeader = {
24
24
  newRoot: FieldElement;
25
25
  /** Block production timestamp. */
26
26
  timestamp: string;
27
- };
27
+ /** Price of L1 gas in the block. */
28
+ l1GasPrice: ResourcePrice;
29
+ }>;
28
30
  export type TransactionWithReceipt = {
29
31
  /** Transaction. */
30
32
  transaction: Transaction;
@@ -45,11 +47,11 @@ export type L2ToL1MessageWithTransaction = {
45
47
  /** Message from L2 to L1. */
46
48
  message: L2ToL1Message;
47
49
  };
48
- export type Transaction = TransactionCommon & (InvokeTransactionV0 | InvokeTransactionV1 | DeployTransaction | DeclareTransaction | DeployAccountTransaction | L1HandlerTransaction);
50
+ export type Transaction = TransactionCommon & (InvokeTransactionV0 | InvokeTransactionV1 | InvokeTransactionV3 | DeployTransaction | DeclareTransaction | DeclareTransactionV3 | DeployAccountTransaction | DeployAccountTransactionV3 | L1HandlerTransaction);
49
51
  export type TransactionCommon = {
50
52
  meta: TransactionMeta;
51
53
  };
52
- export type TransactionMeta = {
54
+ export type TransactionMeta = Partial<{
53
55
  /** Transaction hash. */
54
56
  hash: FieldElement;
55
57
  /** Maximum fee. */
@@ -60,96 +62,181 @@ export type TransactionMeta = {
60
62
  nonce: FieldElement;
61
63
  /** Transaction version. */
62
64
  version: string;
63
- };
65
+ /** Transaction resources. */
66
+ resourceBounds?: ResourceBoundsMapping;
67
+ /** Tip to the sequencer. */
68
+ tip?: number;
69
+ /** Data passed to the paymaster. */
70
+ paymasterData?: FieldElement[];
71
+ /** Account nonce's DA. */
72
+ nonceDataAvailabilityMode?: DataAvailabilityMode;
73
+ /** Transaction's DA. */
74
+ feeDataAvailabilityMode?: DataAvailabilityMode;
75
+ /** Transaction index in the block. */
76
+ transactionIndex?: number;
77
+ }>;
64
78
  export type InvokeTransactionV0 = {
65
- invokeV0?: {
79
+ invokeV0?: Partial<{
66
80
  /** Target contract address. */
67
81
  contractAddress: FieldElement;
68
82
  /** Selector of the function being invoked. */
69
83
  entryPointSelector: FieldElement;
70
84
  /** Calldata. */
71
85
  calldata: FieldElement[];
72
- };
86
+ }>;
73
87
  invokeV1?: never;
88
+ invokeV3?: never;
74
89
  deploy?: never;
75
90
  declare?: never;
91
+ declareV3?: never;
76
92
  l1Handler?: never;
77
93
  deployAccount?: never;
94
+ deployAccountV3?: never;
78
95
  };
79
96
  export type InvokeTransactionV1 = {
80
- invokeV1?: {
97
+ invokeV1?: Partial<{
98
+ /** Address of the account sending the transaction. */
99
+ senderAddress: FieldElement;
100
+ /** Calldata. */
101
+ calldata: FieldElement[];
102
+ }>;
103
+ invokeV0?: never;
104
+ invokeV3?: never;
105
+ deploy?: never;
106
+ declare?: never;
107
+ declareV3?: never;
108
+ l1Handler?: never;
109
+ deployAccount?: never;
110
+ deployAccountV3?: never;
111
+ };
112
+ export type InvokeTransactionV3 = {
113
+ invokeV3?: Partial<{
81
114
  /** Address of the account sending the transaction. */
82
115
  senderAddress: FieldElement;
83
116
  /** Calldata. */
84
117
  calldata: FieldElement[];
85
- };
118
+ /** Data passed to the account deployment. */
119
+ accountDeploymentData: FieldElement[];
120
+ }>;
121
+ invokeV1?: never;
86
122
  invokeV0?: never;
87
123
  deploy?: never;
88
124
  declare?: never;
125
+ declareV3?: never;
89
126
  l1Handler?: never;
90
127
  deployAccount?: never;
128
+ deployAccountV3?: never;
91
129
  };
92
130
  export type DeployTransaction = {
93
- deploy?: {
131
+ deploy?: Partial<{
94
132
  /** Constructor calldata. */
95
133
  constructorCalldata: FieldElement[];
96
134
  /** Salt used when computing the contract's address. */
97
135
  contractAddressSalt: FieldElement;
98
136
  /** Hash of the class being deployed. */
99
137
  classHash: FieldElement;
100
- };
138
+ }>;
101
139
  invokeV0?: never;
102
140
  invokeV1?: never;
141
+ invokeV3?: never;
103
142
  declare?: never;
143
+ declareV3?: never;
104
144
  l1Handler?: never;
105
145
  deployAccount?: never;
146
+ deployAccountV3?: never;
106
147
  };
107
148
  export type DeclareTransaction = {
108
- declare?: {
149
+ declare?: Partial<{
150
+ /** Class hash. */
151
+ classHash: FieldElement;
152
+ /** Address of the account sending the transaction. */
153
+ senderAddress: FieldElement;
154
+ /** Hash of the cairo assembly resulting from the sierra compilation. */
155
+ compiledClassHash: FieldElement;
156
+ }>;
157
+ declareV3?: never;
158
+ invokeV0?: never;
159
+ invokeV1?: never;
160
+ invokeV3?: never;
161
+ deploy?: never;
162
+ l1Handler?: never;
163
+ deployAccount?: never;
164
+ deployAccountV3?: never;
165
+ };
166
+ export type DeclareTransactionV3 = {
167
+ declareV3?: Partial<{
109
168
  /** Class hash. */
110
169
  classHash: FieldElement;
111
170
  /** Address of the account sending the transaction. */
112
171
  senderAddress: FieldElement;
113
172
  /** Hash of the cairo assembly resulting from the sierra compilation. */
114
173
  compiledClassHash: FieldElement;
115
- };
174
+ /** Data passed to the account deployment. */
175
+ accountDeploymentData: FieldElement[];
176
+ }>;
177
+ declare?: never;
116
178
  invokeV0?: never;
117
179
  invokeV1?: never;
180
+ invokeV3?: never;
118
181
  deploy?: never;
182
+ deployAccountV3?: never;
119
183
  l1Handler?: never;
120
184
  deployAccount?: never;
121
185
  };
122
186
  export type DeployAccountTransaction = {
123
- deployAccount?: {
187
+ deployAccount?: Partial<{
188
+ /** Constructor calldata. */
189
+ constructorCalldata: FieldElement[];
190
+ /** Salt used when computing the contract's address. */
191
+ contractAddressSalt: FieldElement;
192
+ /** Hash of the class being deployed. */
193
+ classHash: FieldElement;
194
+ }>;
195
+ deployAccountV3?: never;
196
+ invokeV0?: never;
197
+ invokeV1?: never;
198
+ invokeV3?: never;
199
+ deploy?: never;
200
+ declare?: never;
201
+ declareV3?: never;
202
+ l1Handler?: never;
203
+ };
204
+ export type DeployAccountTransactionV3 = {
205
+ deployAccountV3?: Partial<{
124
206
  /** Constructor calldata. */
125
207
  constructorCalldata: FieldElement[];
126
208
  /** Salt used when computing the contract's address. */
127
209
  contractAddressSalt: FieldElement;
128
210
  /** Hash of the class being deployed. */
129
211
  classHash: FieldElement;
130
- };
212
+ }>;
213
+ deployAccount?: never;
131
214
  invokeV0?: never;
132
215
  invokeV1?: never;
216
+ invokeV3?: never;
133
217
  deploy?: never;
134
218
  declare?: never;
219
+ declareV3?: never;
135
220
  l1Handler?: never;
136
221
  };
137
222
  export type L1HandlerTransaction = {
138
- l1Handler?: {
223
+ l1Handler?: Partial<{
139
224
  /** Target contract address. */
140
225
  contractAddress: FieldElement;
141
226
  /** Selector of the function being invoked. */
142
227
  entryPointSelector: FieldElement;
143
228
  /** Calldata. */
144
229
  calldata: FieldElement[];
145
- };
230
+ }>;
146
231
  invokeV0?: never;
147
232
  invokeV1?: never;
233
+ invokeV3?: never;
148
234
  deploy?: never;
149
235
  declare?: never;
236
+ declareV3?: never;
150
237
  deployAccount?: never;
151
238
  };
152
- export type TransactionReceipt = {
239
+ export type TransactionReceipt = Partial<{
153
240
  /** Transaction status. */
154
241
  executionStatus: ExecutionStatus;
155
242
  /** Transaction hash. */
@@ -166,9 +253,9 @@ export type TransactionReceipt = {
166
253
  events: Event[];
167
254
  /** Revert reason. */
168
255
  revertReason?: string;
169
- };
256
+ }>;
170
257
  export type ExecutionStatus = "EXECUTION_STATUS_UNSPECIFIED" | "EXECUTION_STATUS_SUCCEEDED" | "EXECUTION_STATUS_REVERTED";
171
- export type Event = {
258
+ export type Event = Partial<{
172
259
  /** Event index. */
173
260
  index: number;
174
261
  /** Contract address. */
@@ -177,8 +264,8 @@ export type Event = {
177
264
  keys: FieldElement[];
178
265
  /** Event data. */
179
266
  data: FieldElement[];
180
- };
181
- export type L2ToL1Message = {
267
+ }>;
268
+ export type L2ToL1Message = Partial<{
182
269
  /** Message index. */
183
270
  index: number;
184
271
  /** L2 sender address. */
@@ -187,16 +274,16 @@ export type L2ToL1Message = {
187
274
  toAddress: FieldElement;
188
275
  /** Calldata. */
189
276
  payload: FieldElement[];
190
- };
191
- export type StateUpdate = {
277
+ }>;
278
+ export type StateUpdate = Partial<{
192
279
  /** New state root. */
193
280
  newRoot: FieldElement;
194
281
  /** Old state root. */
195
282
  oldRoot: FieldElement;
196
283
  /** State diff. */
197
284
  stateDiff: StateDiff;
198
- };
199
- export type StateDiff = {
285
+ }>;
286
+ export type StateDiff = Partial<{
200
287
  /** Changes in storage. */
201
288
  storageDiffs: StorageDiff[];
202
289
  /** Declared contracts. */
@@ -209,44 +296,62 @@ export type StateDiff = {
209
296
  declaredClasses: DeclaredClass[];
210
297
  /** Classes replaced. */
211
298
  replacedClasses: ReplacedClass[];
212
- };
213
- export type StorageDiff = {
299
+ }>;
300
+ export type StorageDiff = Partial<{
214
301
  /** Contract address. */
215
302
  contractAddress: FieldElement;
216
303
  /** Changes in storage. */
217
304
  storageEntries: StorageEntry[];
218
- };
219
- export type StorageEntry = {
305
+ }>;
306
+ export type StorageEntry = Partial<{
220
307
  /** Storage key. */
221
308
  key: FieldElement;
222
309
  /** New storage value. */
223
310
  value: FieldElement;
224
- };
225
- export type DeclaredContract = {
311
+ }>;
312
+ export type DeclaredContract = Partial<{
226
313
  /** Class hash. */
227
314
  classHash: FieldElement;
228
- };
229
- export type DeclaredClass = {
315
+ }>;
316
+ export type DeclaredClass = Partial<{
230
317
  /** Class hash. */
231
318
  classHash: FieldElement;
232
319
  /** Compiled class hash. */
233
320
  compiledClassHash: FieldElement;
234
- };
235
- export type ReplacedClass = {
321
+ }>;
322
+ export type ReplacedClass = Partial<{
236
323
  /** Contract address. */
237
324
  contractAddress: FieldElement;
238
325
  /** Class hash. */
239
326
  classHash: FieldElement;
240
- };
241
- export type DeployedContract = {
327
+ }>;
328
+ export type DeployedContract = Partial<{
242
329
  /** Contract address. */
243
330
  contractAddress: FieldElement;
244
331
  /** Class hash. */
245
332
  classHash: FieldElement;
246
- };
247
- export type NonceUpdate = {
333
+ }>;
334
+ export type NonceUpdate = Partial<{
248
335
  /** Contract address. */
249
336
  contractAddress: FieldElement;
250
337
  /** New nonce. */
251
338
  nonce: FieldElement;
252
- };
339
+ }>;
340
+ export type ResourcePrice = Partial<{
341
+ /** Price in fri (10^-18 strk). */
342
+ priceInFri: FieldElement;
343
+ /** Price in wei (10^-18 eth). */
344
+ priceInWei: FieldElement;
345
+ }>;
346
+ export type ResourceBoundsMapping = Partial<{
347
+ l1Gas: ResourceBounds;
348
+ l2Gas: ResourceBounds;
349
+ }>;
350
+ export type ResourceBounds = Partial<{
351
+ maxAmount: number;
352
+ maxPricePerUnit: Partial<{
353
+ low: number;
354
+ high: number;
355
+ }>;
356
+ }>;
357
+ export type DataAvailabilityMode = "DATA_AVAILABILITY_MODE_UNSPECIFIED" | "DATA_AVAILABILITY_MODE_L2" | "DATA_AVAILABILITY_MODE_L1";
@@ -1 +1 @@
1
- {"version":3,"file":"block.test-d.js","sourceRoot":"","sources":["../../src/starknet/block.test-d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAGpD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,OAAO,G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;YACJ,QAAQ;SACT,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE;QACpB,UAAU,CAAc;YACtB,IAAI;YACJ,QAAQ;SACT,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE;QAClB,UAAU,CAAc;YACtB,IAAI;YACJ,MAAM;SACP,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;QACnB,UAAU,CAAc;YACtB,IAAI;YACJ,OAAO;SACR,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE;QACrB,UAAU,CAAc;YACtB,IAAI;YACJ,SAAS,EAAE,QAAQ;SACpB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE;QACzB,UAAU,CAAc;YACtB,IAAI;YACJ,aAAa,EAAE,MAAM;SACtB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apibara/indexer",
3
- "version": "0.2.5",
3
+ "version": "0.3.1",
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 { Block, BlockHeader, Transaction } from "./block";
3
+ import { Block, BlockHeader, Transaction, TransactionMeta } from "./block";
4
4
  import { FieldElement } from "./felt";
5
5
 
6
6
  const address =
@@ -8,7 +8,7 @@ const address =
8
8
  const entryPointSelector =
9
9
  "0x03943907ef0ef6f9d2e2408b05e520a66daaf74293dbf665e5a20b117676170e";
10
10
  const calldata = [FieldElement.parse("0x01"), FieldElement.parse("0x02")];
11
- const meta = {
11
+ const meta: TransactionMeta = {
12
12
  hash: FieldElement.parse("0x01"),
13
13
  maxFee: FieldElement.parse("0x02"),
14
14
  signature: [FieldElement.parse("0x03")],
@@ -1,19 +1,19 @@
1
1
  import { 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. */
@@ -26,7 +26,9 @@ export type BlockHeader = {
26
26
  newRoot: FieldElement;
27
27
  /** Block production timestamp. */
28
28
  timestamp: string;
29
- };
29
+ /** Price of L1 gas in the block. */
30
+ l1GasPrice: ResourcePrice;
31
+ }>;
30
32
 
31
33
  export type TransactionWithReceipt = {
32
34
  /** Transaction. */
@@ -55,9 +57,12 @@ export type Transaction = TransactionCommon &
55
57
  (
56
58
  | InvokeTransactionV0
57
59
  | InvokeTransactionV1
60
+ | InvokeTransactionV3
58
61
  | DeployTransaction
59
62
  | DeclareTransaction
63
+ | DeclareTransactionV3
60
64
  | DeployAccountTransaction
65
+ | DeployAccountTransactionV3
61
66
  | L1HandlerTransaction
62
67
  );
63
68
 
@@ -65,7 +70,7 @@ export type TransactionCommon = {
65
70
  meta: TransactionMeta;
66
71
  };
67
72
 
68
- export type TransactionMeta = {
73
+ export type TransactionMeta = Partial<{
69
74
  /** Transaction hash. */
70
75
  hash: FieldElement;
71
76
  /** Maximum fee. */
@@ -76,103 +81,191 @@ export type TransactionMeta = {
76
81
  nonce: FieldElement;
77
82
  /** Transaction version. */
78
83
  version: string;
79
- };
84
+ /** Transaction resources. */
85
+ resourceBounds?: ResourceBoundsMapping;
86
+ /** Tip to the sequencer. */
87
+ tip?: number;
88
+ /** Data passed to the paymaster. */
89
+ paymasterData?: FieldElement[];
90
+ /** Account nonce's DA. */
91
+ nonceDataAvailabilityMode?: DataAvailabilityMode;
92
+ /** Transaction's DA. */
93
+ feeDataAvailabilityMode?: DataAvailabilityMode;
94
+ /** Transaction index in the block. */
95
+ transactionIndex?: number;
96
+ }>;
80
97
 
81
98
  export type InvokeTransactionV0 = {
82
- invokeV0?: {
99
+ invokeV0?: Partial<{
83
100
  /** Target contract address. */
84
101
  contractAddress: FieldElement;
85
102
  /** Selector of the function being invoked. */
86
103
  entryPointSelector: FieldElement;
87
104
  /** Calldata. */
88
105
  calldata: FieldElement[];
89
- };
106
+ }>;
90
107
  invokeV1?: never;
108
+ invokeV3?: never;
91
109
  deploy?: never;
92
110
  declare?: never;
111
+ declareV3?: never;
93
112
  l1Handler?: never;
94
113
  deployAccount?: never;
114
+ deployAccountV3?: never;
95
115
  };
96
116
 
97
117
  export type InvokeTransactionV1 = {
98
- invokeV1?: {
118
+ invokeV1?: Partial<{
99
119
  /** Address of the account sending the transaction. */
100
120
  senderAddress: FieldElement;
101
121
  /** Calldata. */
102
122
  calldata: FieldElement[];
103
- };
123
+ }>;
124
+ invokeV0?: never;
125
+ invokeV3?: never;
126
+ deploy?: never;
127
+ declare?: never;
128
+ declareV3?: never;
129
+ l1Handler?: never;
130
+ deployAccount?: never;
131
+ deployAccountV3?: never;
132
+ };
133
+
134
+ export type InvokeTransactionV3 = {
135
+ invokeV3?: Partial<{
136
+ /** Address of the account sending the transaction. */
137
+ senderAddress: FieldElement;
138
+ /** Calldata. */
139
+ calldata: FieldElement[];
140
+ /** Data passed to the account deployment. */
141
+ accountDeploymentData: FieldElement[];
142
+ }>;
143
+ invokeV1?: never;
104
144
  invokeV0?: never;
105
145
  deploy?: never;
106
146
  declare?: never;
147
+ declareV3?: never;
107
148
  l1Handler?: never;
108
149
  deployAccount?: never;
150
+ deployAccountV3?: never;
109
151
  };
110
152
 
111
153
  export type DeployTransaction = {
112
- deploy?: {
154
+ deploy?: Partial<{
113
155
  /** Constructor calldata. */
114
156
  constructorCalldata: FieldElement[];
115
157
  /** Salt used when computing the contract's address. */
116
158
  contractAddressSalt: FieldElement;
117
159
  /** Hash of the class being deployed. */
118
160
  classHash: FieldElement;
119
- };
161
+ }>;
120
162
  invokeV0?: never;
121
163
  invokeV1?: never;
164
+ invokeV3?: never;
122
165
  declare?: never;
166
+ declareV3?: never;
123
167
  l1Handler?: never;
124
168
  deployAccount?: never;
169
+ deployAccountV3?: never;
125
170
  };
126
171
 
127
172
  export type DeclareTransaction = {
128
- declare?: {
173
+ declare?: Partial<{
129
174
  /** Class hash. */
130
175
  classHash: FieldElement;
131
176
  /** Address of the account sending the transaction. */
132
177
  senderAddress: FieldElement;
133
178
  /** Hash of the cairo assembly resulting from the sierra compilation. */
134
179
  compiledClassHash: FieldElement;
135
- };
180
+ }>;
181
+ declareV3?: never;
136
182
  invokeV0?: never;
137
183
  invokeV1?: never;
184
+ invokeV3?: never;
138
185
  deploy?: never;
139
186
  l1Handler?: never;
140
187
  deployAccount?: never;
188
+ deployAccountV3?: never;
189
+ };
190
+
191
+ export type DeclareTransactionV3 = {
192
+ declareV3?: Partial<{
193
+ /** Class hash. */
194
+ classHash: FieldElement;
195
+ /** Address of the account sending the transaction. */
196
+ senderAddress: FieldElement;
197
+ /** Hash of the cairo assembly resulting from the sierra compilation. */
198
+ compiledClassHash: FieldElement;
199
+ /** Data passed to the account deployment. */
200
+ accountDeploymentData: FieldElement[];
201
+ }>;
202
+ declare?: never;
203
+ invokeV0?: never;
204
+ invokeV1?: never;
205
+ invokeV3?: never;
206
+ deploy?: never;
207
+ deployAccountV3?: never;
208
+ l1Handler?: never;
209
+ deployAccount?: never;
141
210
  };
142
211
 
143
212
  export type DeployAccountTransaction = {
144
- deployAccount?: {
213
+ deployAccount?: Partial<{
145
214
  /** Constructor calldata. */
146
215
  constructorCalldata: FieldElement[];
147
216
  /** Salt used when computing the contract's address. */
148
217
  contractAddressSalt: FieldElement;
149
218
  /** Hash of the class being deployed. */
150
219
  classHash: FieldElement;
151
- };
220
+ }>;
221
+ deployAccountV3?: never;
152
222
  invokeV0?: never;
153
223
  invokeV1?: never;
224
+ invokeV3?: never;
154
225
  deploy?: never;
155
226
  declare?: never;
227
+ declareV3?: never;
228
+ l1Handler?: never;
229
+ };
230
+
231
+ export type DeployAccountTransactionV3 = {
232
+ deployAccountV3?: Partial<{
233
+ /** Constructor calldata. */
234
+ constructorCalldata: FieldElement[];
235
+ /** Salt used when computing the contract's address. */
236
+ contractAddressSalt: FieldElement;
237
+ /** Hash of the class being deployed. */
238
+ classHash: FieldElement;
239
+ }>;
240
+ deployAccount?: never;
241
+ invokeV0?: never;
242
+ invokeV1?: never;
243
+ invokeV3?: never;
244
+ deploy?: never;
245
+ declare?: never;
246
+ declareV3?: never;
156
247
  l1Handler?: never;
157
248
  };
158
249
 
159
250
  export type L1HandlerTransaction = {
160
- l1Handler?: {
251
+ l1Handler?: Partial<{
161
252
  /** Target contract address. */
162
253
  contractAddress: FieldElement;
163
254
  /** Selector of the function being invoked. */
164
255
  entryPointSelector: FieldElement;
165
256
  /** Calldata. */
166
257
  calldata: FieldElement[];
167
- };
258
+ }>;
168
259
  invokeV0?: never;
169
260
  invokeV1?: never;
261
+ invokeV3?: never;
170
262
  deploy?: never;
171
263
  declare?: never;
264
+ declareV3?: never;
172
265
  deployAccount?: never;
173
266
  };
174
267
 
175
- export type TransactionReceipt = {
268
+ export type TransactionReceipt = Partial<{
176
269
  /** Transaction status. */
177
270
  executionStatus: ExecutionStatus;
178
271
  /** Transaction hash. */
@@ -189,14 +282,14 @@ export type TransactionReceipt = {
189
282
  events: Event[];
190
283
  /** Revert reason. */
191
284
  revertReason?: string;
192
- };
285
+ }>;
193
286
 
194
287
  export type ExecutionStatus =
195
288
  | "EXECUTION_STATUS_UNSPECIFIED"
196
289
  | "EXECUTION_STATUS_SUCCEEDED"
197
290
  | "EXECUTION_STATUS_REVERTED";
198
291
 
199
- export type Event = {
292
+ export type Event = Partial<{
200
293
  /** Event index. */
201
294
  index: number;
202
295
  /** Contract address. */
@@ -205,9 +298,9 @@ export type Event = {
205
298
  keys: FieldElement[];
206
299
  /** Event data. */
207
300
  data: FieldElement[];
208
- };
301
+ }>;
209
302
 
210
- export type L2ToL1Message = {
303
+ export type L2ToL1Message = Partial<{
211
304
  /** Message index. */
212
305
  index: number;
213
306
  /** L2 sender address. */
@@ -216,18 +309,18 @@ export type L2ToL1Message = {
216
309
  toAddress: FieldElement;
217
310
  /** Calldata. */
218
311
  payload: FieldElement[];
219
- };
312
+ }>;
220
313
 
221
- export type StateUpdate = {
314
+ export type StateUpdate = Partial<{
222
315
  /** New state root. */
223
316
  newRoot: FieldElement;
224
317
  /** Old state root. */
225
318
  oldRoot: FieldElement;
226
319
  /** State diff. */
227
320
  stateDiff: StateDiff;
228
- };
321
+ }>;
229
322
 
230
- export type StateDiff = {
323
+ export type StateDiff = Partial<{
231
324
  /** Changes in storage. */
232
325
  storageDiffs: StorageDiff[];
233
326
  /** Declared contracts. */
@@ -240,51 +333,73 @@ export type StateDiff = {
240
333
  declaredClasses: DeclaredClass[];
241
334
  /** Classes replaced. */
242
335
  replacedClasses: ReplacedClass[];
243
- };
336
+ }>;
244
337
 
245
- export type StorageDiff = {
338
+ export type StorageDiff = Partial<{
246
339
  /** Contract address. */
247
340
  contractAddress: FieldElement;
248
341
  /** Changes in storage. */
249
342
  storageEntries: StorageEntry[];
250
- };
343
+ }>;
251
344
 
252
- export type StorageEntry = {
345
+ export type StorageEntry = Partial<{
253
346
  /** Storage key. */
254
347
  key: FieldElement;
255
348
  /** New storage value. */
256
349
  value: FieldElement;
257
- };
350
+ }>;
258
351
 
259
- export type DeclaredContract = {
352
+ export type DeclaredContract = Partial<{
260
353
  /** Class hash. */
261
354
  classHash: FieldElement;
262
- };
355
+ }>;
263
356
 
264
- export type DeclaredClass = {
357
+ export type DeclaredClass = Partial<{
265
358
  /** Class hash. */
266
359
  classHash: FieldElement;
267
360
  /** Compiled class hash. */
268
361
  compiledClassHash: FieldElement;
269
- };
362
+ }>;
270
363
 
271
- export type ReplacedClass = {
364
+ export type ReplacedClass = Partial<{
272
365
  /** Contract address. */
273
366
  contractAddress: FieldElement;
274
367
  /** Class hash. */
275
368
  classHash: FieldElement;
276
- };
369
+ }>;
277
370
 
278
- export type DeployedContract = {
371
+ export type DeployedContract = Partial<{
279
372
  /** Contract address. */
280
373
  contractAddress: FieldElement;
281
374
  /** Class hash. */
282
375
  classHash: FieldElement;
283
- };
376
+ }>;
284
377
 
285
- export type NonceUpdate = {
378
+ export type NonceUpdate = Partial<{
286
379
  /** Contract address. */
287
380
  contractAddress: FieldElement;
288
381
  /** New nonce. */
289
382
  nonce: FieldElement;
290
- };
383
+ }>;
384
+
385
+ export type ResourcePrice = Partial<{
386
+ /** Price in fri (10^-18 strk). */
387
+ priceInFri: FieldElement;
388
+ /** Price in wei (10^-18 eth). */
389
+ priceInWei: FieldElement;
390
+ }>;
391
+
392
+ export type ResourceBoundsMapping = Partial<{
393
+ l1Gas: ResourceBounds;
394
+ l2Gas: ResourceBounds;
395
+ }>;
396
+
397
+ export type ResourceBounds = Partial<{
398
+ maxAmount: number;
399
+ maxPricePerUnit: Partial<{ low: number; high: number }>;
400
+ }>;
401
+
402
+ export type DataAvailabilityMode =
403
+ | "DATA_AVAILABILITY_MODE_UNSPECIFIED"
404
+ | "DATA_AVAILABILITY_MODE_L2"
405
+ | "DATA_AVAILABILITY_MODE_L1";