@apibara/indexer 0.4.1 → 2.0.0-beta.3
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/README.md +2 -9
- package/package.json +66 -45
- package/src/context.ts +19 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useKVStore.ts +12 -0
- package/src/hooks/useSink.ts +13 -0
- package/src/index.ts +7 -1
- package/src/indexer.test.ts +491 -0
- package/src/indexer.ts +322 -0
- package/src/otel.ts +3 -0
- package/src/plugins/config.ts +11 -0
- package/src/plugins/kv.test.ts +120 -0
- package/src/plugins/kv.ts +132 -0
- package/src/plugins/persistence.test.ts +151 -0
- package/src/plugins/persistence.ts +202 -0
- package/src/sink.ts +36 -0
- package/src/sinks/csv.test.ts +65 -0
- package/src/sinks/csv.ts +159 -0
- package/src/sinks/drizzle/Int8Range.ts +52 -0
- package/src/sinks/drizzle/delete.ts +42 -0
- package/src/sinks/drizzle/drizzle.test.ts +239 -0
- package/src/sinks/drizzle/drizzle.ts +115 -0
- package/src/sinks/drizzle/index.ts +6 -0
- package/src/sinks/drizzle/insert.ts +39 -0
- package/src/sinks/drizzle/select.ts +44 -0
- package/src/sinks/drizzle/transaction.ts +49 -0
- package/src/sinks/drizzle/update.ts +47 -0
- package/src/sinks/drizzle/utils.ts +36 -0
- package/src/sinks/sqlite.test.ts +99 -0
- package/src/sinks/sqlite.ts +170 -0
- package/src/testing/helper.ts +13 -0
- package/src/testing/index.ts +3 -0
- package/src/testing/indexer.ts +35 -0
- package/src/testing/setup.ts +59 -0
- package/src/testing/vcr.ts +54 -0
- package/src/vcr/config.ts +11 -0
- package/src/vcr/helper.ts +27 -0
- package/src/vcr/index.ts +4 -0
- package/src/vcr/record.ts +45 -0
- package/src/vcr/replay.ts +51 -0
- package/LICENSE.txt +0 -202
- package/dist/config.d.ts +0 -35
- package/dist/config.js +0 -2
- package/dist/config.js.map +0 -1
- package/dist/config.test-d.d.ts +0 -1
- package/dist/config.test-d.js +0 -38
- package/dist/config.test-d.js.map +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
- package/dist/sink/console.d.ts +0 -10
- package/dist/sink/console.js +0 -2
- package/dist/sink/console.js.map +0 -1
- package/dist/sink/console.test-d.d.ts +0 -1
- package/dist/sink/console.test-d.js +0 -12
- package/dist/sink/console.test-d.js.map +0 -1
- package/dist/sink/mongo.d.ts +0 -14
- package/dist/sink/mongo.js +0 -2
- package/dist/sink/mongo.js.map +0 -1
- package/dist/sink/parquet.d.ts +0 -9
- package/dist/sink/parquet.js +0 -2
- package/dist/sink/parquet.js.map +0 -1
- package/dist/sink/postgres.d.ts +0 -10
- package/dist/sink/postgres.js +0 -2
- package/dist/sink/postgres.js.map +0 -1
- package/dist/sink/webhook.d.ts +0 -12
- package/dist/sink/webhook.js +0 -2
- package/dist/sink/webhook.js.map +0 -1
- package/dist/starknet/block.d.ts +0 -409
- package/dist/starknet/block.js +0 -2
- package/dist/starknet/block.js.map +0 -1
- package/dist/starknet/block.test-d.d.ts +0 -1
- package/dist/starknet/block.test-d.js +0 -95
- package/dist/starknet/block.test-d.js.map +0 -1
- package/dist/starknet/felt.d.ts +0 -11
- package/dist/starknet/felt.js +0 -25
- package/dist/starknet/felt.js.map +0 -1
- package/dist/starknet/felt.test.d.ts +0 -1
- package/dist/starknet/felt.test.js +0 -16
- package/dist/starknet/felt.test.js.map +0 -1
- package/dist/starknet/filter.d.ts +0 -175
- package/dist/starknet/filter.js +0 -2
- package/dist/starknet/filter.js.map +0 -1
- package/dist/starknet/filter.test-d.d.ts +0 -1
- package/dist/starknet/filter.test-d.js +0 -166
- package/dist/starknet/filter.test-d.js.map +0 -1
- package/dist/starknet/index.d.ts +0 -10
- package/dist/starknet/index.js +0 -5
- package/dist/starknet/index.js.map +0 -1
- package/dist/starknet/parser.d.ts +0 -16
- package/dist/starknet/parser.js +0 -49
- package/dist/starknet/parser.js.map +0 -1
- package/dist/starknet/parser.test.d.ts +0 -1
- package/dist/starknet/parser.test.js +0 -50
- package/dist/starknet/parser.test.js.map +0 -1
- package/src/config.test-d.ts +0 -55
- package/src/config.ts +0 -47
- package/src/sink/console.test-d.ts +0 -14
- package/src/sink/console.ts +0 -11
- package/src/sink/mongo.ts +0 -14
- package/src/sink/parquet.ts +0 -9
- package/src/sink/postgres.ts +0 -10
- package/src/sink/webhook.ts +0 -12
- package/src/starknet/block.test-d.ts +0 -112
- package/src/starknet/block.ts +0 -469
- package/src/starknet/felt.test.ts +0 -25
- package/src/starknet/felt.ts +0 -30
- package/src/starknet/filter.test-d.ts +0 -197
- package/src/starknet/filter.ts +0 -205
- package/src/starknet/index.ts +0 -12
- package/src/starknet/parser.test.ts +0 -67
- package/src/starknet/parser.ts +0 -69
- /package/{dist/index.d.ts → src/plugins/index.ts} +0 -0
package/src/starknet/block.ts
DELETED
|
@@ -1,469 +0,0 @@
|
|
|
1
|
-
import type { FieldElement } from "./felt";
|
|
2
|
-
|
|
3
|
-
export type Block = Partial<{
|
|
4
|
-
/** Block header. */
|
|
5
|
-
header: BlockHeader;
|
|
6
|
-
/** Transactions. */
|
|
7
|
-
transactions: TransactionWithReceipt[];
|
|
8
|
-
/** Events. */
|
|
9
|
-
events: EventWithTransaction[];
|
|
10
|
-
/** Messages from L2 to L1. */
|
|
11
|
-
l2ToL1Messages: L2ToL1MessageWithTransaction[];
|
|
12
|
-
/** State update. */
|
|
13
|
-
stateUpdate: StateUpdate;
|
|
14
|
-
}>;
|
|
15
|
-
|
|
16
|
-
export type BlockHeader = Partial<{
|
|
17
|
-
/** Block hash. */
|
|
18
|
-
blockHash: FieldElement;
|
|
19
|
-
/** Parent block hash. */
|
|
20
|
-
parentBlockHash: FieldElement;
|
|
21
|
-
/** Block number. */
|
|
22
|
-
blockNumber: string;
|
|
23
|
-
/** Sequencer address. */
|
|
24
|
-
sequencerAddress: FieldElement;
|
|
25
|
-
/** New state root. */
|
|
26
|
-
newRoot: FieldElement;
|
|
27
|
-
/** Block production timestamp. */
|
|
28
|
-
timestamp: string;
|
|
29
|
-
/** Starknet version. */
|
|
30
|
-
starknetVersion: string;
|
|
31
|
-
/** Price of L1 gas in the block. */
|
|
32
|
-
l1GasPrice?: ResourcePrice;
|
|
33
|
-
/** Price of L1 data gas in the block. */
|
|
34
|
-
l1DataGasPrice?: ResourcePrice;
|
|
35
|
-
/** L1 data availability mode. */
|
|
36
|
-
l1DataAvailabilityMode?: L1DataAvailabilityMode;
|
|
37
|
-
}>;
|
|
38
|
-
|
|
39
|
-
export type TransactionWithReceipt = {
|
|
40
|
-
/** Transaction. */
|
|
41
|
-
transaction: Transaction;
|
|
42
|
-
/** Transaction receipt. */
|
|
43
|
-
receipt: TransactionReceipt;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export type EventWithTransaction = {
|
|
47
|
-
/** Transaction. */
|
|
48
|
-
transaction: Transaction;
|
|
49
|
-
/** Transaction receipt. */
|
|
50
|
-
receipt: TransactionReceipt;
|
|
51
|
-
/** Event. */
|
|
52
|
-
event: Event;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export type L2ToL1MessageWithTransaction = {
|
|
56
|
-
/** Transaction. */
|
|
57
|
-
transaction: Transaction;
|
|
58
|
-
/** Message from L2 to L1. */
|
|
59
|
-
message: L2ToL1Message;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export type Transaction = TransactionCommon &
|
|
63
|
-
(
|
|
64
|
-
| InvokeTransactionV0
|
|
65
|
-
| InvokeTransactionV1
|
|
66
|
-
| InvokeTransactionV3
|
|
67
|
-
| DeployTransaction
|
|
68
|
-
| DeclareTransaction
|
|
69
|
-
| DeclareTransactionV3
|
|
70
|
-
| DeployAccountTransaction
|
|
71
|
-
| DeployAccountTransactionV3
|
|
72
|
-
| L1HandlerTransaction
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
export type TransactionCommon = {
|
|
76
|
-
meta: TransactionMeta;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export type TransactionMeta = Partial<{
|
|
80
|
-
/** Transaction hash. */
|
|
81
|
-
hash: FieldElement;
|
|
82
|
-
/** Maximum fee. */
|
|
83
|
-
maxFee: FieldElement;
|
|
84
|
-
/** Signature. */
|
|
85
|
-
signature: FieldElement[];
|
|
86
|
-
/** Nonce. */
|
|
87
|
-
nonce: FieldElement;
|
|
88
|
-
/** Transaction version. */
|
|
89
|
-
version: string;
|
|
90
|
-
/** Transaction resources. */
|
|
91
|
-
resourceBounds?: ResourceBoundsMapping;
|
|
92
|
-
/** Tip to the sequencer. */
|
|
93
|
-
tip?: number;
|
|
94
|
-
/** Data passed to the paymaster. */
|
|
95
|
-
paymasterData?: FieldElement[];
|
|
96
|
-
/** Account nonce's DA. */
|
|
97
|
-
nonceDataAvailabilityMode?: DataAvailabilityMode;
|
|
98
|
-
/** Transaction's DA. */
|
|
99
|
-
feeDataAvailabilityMode?: DataAvailabilityMode;
|
|
100
|
-
/** Transaction index in the block. */
|
|
101
|
-
transactionIndex?: number;
|
|
102
|
-
}>;
|
|
103
|
-
|
|
104
|
-
export type InvokeTransactionV0 = {
|
|
105
|
-
invokeV0?: Partial<{
|
|
106
|
-
/** Target contract address. */
|
|
107
|
-
contractAddress: FieldElement;
|
|
108
|
-
/** Selector of the function being invoked. */
|
|
109
|
-
entryPointSelector: FieldElement;
|
|
110
|
-
/** Calldata. */
|
|
111
|
-
calldata: FieldElement[];
|
|
112
|
-
}>;
|
|
113
|
-
invokeV1?: never;
|
|
114
|
-
invokeV3?: never;
|
|
115
|
-
deploy?: never;
|
|
116
|
-
declare?: never;
|
|
117
|
-
declareV3?: never;
|
|
118
|
-
l1Handler?: never;
|
|
119
|
-
deployAccount?: never;
|
|
120
|
-
deployAccountV3?: never;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
export type InvokeTransactionV1 = {
|
|
124
|
-
invokeV1?: Partial<{
|
|
125
|
-
/** Address of the account sending the transaction. */
|
|
126
|
-
senderAddress: FieldElement;
|
|
127
|
-
/** Calldata. */
|
|
128
|
-
calldata: FieldElement[];
|
|
129
|
-
}>;
|
|
130
|
-
invokeV0?: never;
|
|
131
|
-
invokeV3?: never;
|
|
132
|
-
deploy?: never;
|
|
133
|
-
declare?: never;
|
|
134
|
-
declareV3?: never;
|
|
135
|
-
l1Handler?: never;
|
|
136
|
-
deployAccount?: never;
|
|
137
|
-
deployAccountV3?: never;
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
export type InvokeTransactionV3 = {
|
|
141
|
-
invokeV3?: Partial<{
|
|
142
|
-
/** Address of the account sending the transaction. */
|
|
143
|
-
senderAddress: FieldElement;
|
|
144
|
-
/** Calldata. */
|
|
145
|
-
calldata: FieldElement[];
|
|
146
|
-
/** Data passed to the account deployment. */
|
|
147
|
-
accountDeploymentData: FieldElement[];
|
|
148
|
-
}>;
|
|
149
|
-
invokeV1?: never;
|
|
150
|
-
invokeV0?: never;
|
|
151
|
-
deploy?: never;
|
|
152
|
-
declare?: never;
|
|
153
|
-
declareV3?: never;
|
|
154
|
-
l1Handler?: never;
|
|
155
|
-
deployAccount?: never;
|
|
156
|
-
deployAccountV3?: never;
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
export type DeployTransaction = {
|
|
160
|
-
deploy?: Partial<{
|
|
161
|
-
/** Constructor calldata. */
|
|
162
|
-
constructorCalldata: FieldElement[];
|
|
163
|
-
/** Salt used when computing the contract's address. */
|
|
164
|
-
contractAddressSalt: FieldElement;
|
|
165
|
-
/** Hash of the class being deployed. */
|
|
166
|
-
classHash: FieldElement;
|
|
167
|
-
}>;
|
|
168
|
-
invokeV0?: never;
|
|
169
|
-
invokeV1?: never;
|
|
170
|
-
invokeV3?: never;
|
|
171
|
-
declare?: never;
|
|
172
|
-
declareV3?: never;
|
|
173
|
-
l1Handler?: never;
|
|
174
|
-
deployAccount?: never;
|
|
175
|
-
deployAccountV3?: never;
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
export type DeclareTransaction = {
|
|
179
|
-
declare?: Partial<{
|
|
180
|
-
/** Class hash. */
|
|
181
|
-
classHash: FieldElement;
|
|
182
|
-
/** Address of the account sending the transaction. */
|
|
183
|
-
senderAddress: FieldElement;
|
|
184
|
-
/** Hash of the cairo assembly resulting from the sierra compilation. */
|
|
185
|
-
compiledClassHash: FieldElement;
|
|
186
|
-
}>;
|
|
187
|
-
declareV3?: never;
|
|
188
|
-
invokeV0?: never;
|
|
189
|
-
invokeV1?: never;
|
|
190
|
-
invokeV3?: never;
|
|
191
|
-
deploy?: never;
|
|
192
|
-
l1Handler?: never;
|
|
193
|
-
deployAccount?: never;
|
|
194
|
-
deployAccountV3?: never;
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
export type DeclareTransactionV3 = {
|
|
198
|
-
declareV3?: Partial<{
|
|
199
|
-
/** Class hash. */
|
|
200
|
-
classHash: FieldElement;
|
|
201
|
-
/** Address of the account sending the transaction. */
|
|
202
|
-
senderAddress: FieldElement;
|
|
203
|
-
/** Hash of the cairo assembly resulting from the sierra compilation. */
|
|
204
|
-
compiledClassHash: FieldElement;
|
|
205
|
-
/** Data passed to the account deployment. */
|
|
206
|
-
accountDeploymentData: FieldElement[];
|
|
207
|
-
}>;
|
|
208
|
-
declare?: never;
|
|
209
|
-
invokeV0?: never;
|
|
210
|
-
invokeV1?: never;
|
|
211
|
-
invokeV3?: never;
|
|
212
|
-
deploy?: never;
|
|
213
|
-
deployAccountV3?: never;
|
|
214
|
-
l1Handler?: never;
|
|
215
|
-
deployAccount?: never;
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
export type DeployAccountTransaction = {
|
|
219
|
-
deployAccount?: Partial<{
|
|
220
|
-
/** Constructor calldata. */
|
|
221
|
-
constructorCalldata: FieldElement[];
|
|
222
|
-
/** Salt used when computing the contract's address. */
|
|
223
|
-
contractAddressSalt: FieldElement;
|
|
224
|
-
/** Hash of the class being deployed. */
|
|
225
|
-
classHash: FieldElement;
|
|
226
|
-
}>;
|
|
227
|
-
deployAccountV3?: never;
|
|
228
|
-
invokeV0?: never;
|
|
229
|
-
invokeV1?: never;
|
|
230
|
-
invokeV3?: never;
|
|
231
|
-
deploy?: never;
|
|
232
|
-
declare?: never;
|
|
233
|
-
declareV3?: never;
|
|
234
|
-
l1Handler?: never;
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
export type DeployAccountTransactionV3 = {
|
|
238
|
-
deployAccountV3?: Partial<{
|
|
239
|
-
/** Constructor calldata. */
|
|
240
|
-
constructorCalldata: FieldElement[];
|
|
241
|
-
/** Salt used when computing the contract's address. */
|
|
242
|
-
contractAddressSalt: FieldElement;
|
|
243
|
-
/** Hash of the class being deployed. */
|
|
244
|
-
classHash: FieldElement;
|
|
245
|
-
}>;
|
|
246
|
-
deployAccount?: never;
|
|
247
|
-
invokeV0?: never;
|
|
248
|
-
invokeV1?: never;
|
|
249
|
-
invokeV3?: never;
|
|
250
|
-
deploy?: never;
|
|
251
|
-
declare?: never;
|
|
252
|
-
declareV3?: never;
|
|
253
|
-
l1Handler?: never;
|
|
254
|
-
};
|
|
255
|
-
|
|
256
|
-
export type L1HandlerTransaction = {
|
|
257
|
-
l1Handler?: Partial<{
|
|
258
|
-
/** Target contract address. */
|
|
259
|
-
contractAddress: FieldElement;
|
|
260
|
-
/** Selector of the function being invoked. */
|
|
261
|
-
entryPointSelector: FieldElement;
|
|
262
|
-
/** Calldata. */
|
|
263
|
-
calldata: FieldElement[];
|
|
264
|
-
}>;
|
|
265
|
-
invokeV0?: never;
|
|
266
|
-
invokeV1?: never;
|
|
267
|
-
invokeV3?: never;
|
|
268
|
-
deploy?: never;
|
|
269
|
-
declare?: never;
|
|
270
|
-
declareV3?: never;
|
|
271
|
-
deployAccount?: never;
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
export type TransactionReceipt = Partial<{
|
|
275
|
-
/** Transaction status. */
|
|
276
|
-
executionStatus: ExecutionStatus;
|
|
277
|
-
/** Transaction hash. */
|
|
278
|
-
transactionHash: FieldElement;
|
|
279
|
-
/** Transaction index. */
|
|
280
|
-
transactionIndex: string;
|
|
281
|
-
/** Actual fee paid by the account. */
|
|
282
|
-
actualFee: FieldElement;
|
|
283
|
-
/** Address of the contract created by the transaction. */
|
|
284
|
-
contractAddress: FieldElement;
|
|
285
|
-
/** Messages from L2 to L1. */
|
|
286
|
-
l2ToL1Messages: L2ToL1Message[];
|
|
287
|
-
/** Events. */
|
|
288
|
-
events: Event[];
|
|
289
|
-
/** Revert reason. */
|
|
290
|
-
revertReason: string;
|
|
291
|
-
/** Fee paid. */
|
|
292
|
-
actualFeePaid: FeePayment;
|
|
293
|
-
/** Resources consumed by the transaction. */
|
|
294
|
-
executionResources: ExecutionResources;
|
|
295
|
-
}>;
|
|
296
|
-
|
|
297
|
-
export type ExecutionStatus =
|
|
298
|
-
| "EXECUTION_STATUS_UNSPECIFIED"
|
|
299
|
-
| "EXECUTION_STATUS_SUCCEEDED"
|
|
300
|
-
| "EXECUTION_STATUS_REVERTED";
|
|
301
|
-
|
|
302
|
-
export type FeePayment = Partial<{
|
|
303
|
-
/** Amount paid. */
|
|
304
|
-
amount: FieldElement;
|
|
305
|
-
/** Unit of the amount. */
|
|
306
|
-
unit: PriceUnit;
|
|
307
|
-
}>;
|
|
308
|
-
|
|
309
|
-
export type ExecutionResources = Partial<{
|
|
310
|
-
/** Computation resources. */
|
|
311
|
-
computation: ComputationResources;
|
|
312
|
-
/** Data availability resources. */
|
|
313
|
-
dataAvailability: DataAvailabilityResources;
|
|
314
|
-
}>;
|
|
315
|
-
|
|
316
|
-
export type DataAvailabilityResources = Partial<{
|
|
317
|
-
/** The gas consumed by this transaction's data, 0 if it uses data gas for DA. */
|
|
318
|
-
l1Gas: number;
|
|
319
|
-
/** The data gas consumed by this transaction's data, 0 if it uses gas for DA. */
|
|
320
|
-
l1DataGas: number;
|
|
321
|
-
}>;
|
|
322
|
-
|
|
323
|
-
export type ComputationResources = Partial<{
|
|
324
|
-
/** The number of Cairo steps used. */
|
|
325
|
-
steps: number;
|
|
326
|
-
/** The number of unused memory cells. */
|
|
327
|
-
memoryHoles: number;
|
|
328
|
-
/** The number of RANGE_CHECK builtin instances. */
|
|
329
|
-
rangeCheckBuiltinApplications: number;
|
|
330
|
-
/** The number of Pedersen builtin instances. */
|
|
331
|
-
pedersenBuiltinApplications: number;
|
|
332
|
-
/** The number of Poseidon builtin instances. */
|
|
333
|
-
poseidonBuiltinApplications: number;
|
|
334
|
-
/** The number of EC_OP builtin instances. */
|
|
335
|
-
ecOpBuiltinApplications: number;
|
|
336
|
-
/** The number of ECDSA builtin instances. */
|
|
337
|
-
ecdsaBuiltinApplications: number;
|
|
338
|
-
/** The number of BITWISE builtin instances. */
|
|
339
|
-
bitwiseBuiltinApplications: number;
|
|
340
|
-
/** The number of KECCAK builtin instances. */
|
|
341
|
-
keccakBuiltinApplications: number;
|
|
342
|
-
/** The number of accesses to the segment arena. */
|
|
343
|
-
segmentArenaBuiltin: number;
|
|
344
|
-
}>;
|
|
345
|
-
|
|
346
|
-
export type PriceUnit =
|
|
347
|
-
| "PRICE_UNIT_UNSPECIFIED"
|
|
348
|
-
| "PRICE_UNIT_FRI"
|
|
349
|
-
| "PRICE_UNIT_WEI";
|
|
350
|
-
|
|
351
|
-
export type Event = Partial<{
|
|
352
|
-
/** Event index. */
|
|
353
|
-
index: number;
|
|
354
|
-
/** Contract address. */
|
|
355
|
-
fromAddress: FieldElement;
|
|
356
|
-
/** Event selector. */
|
|
357
|
-
keys: FieldElement[];
|
|
358
|
-
/** Event data. */
|
|
359
|
-
data: FieldElement[];
|
|
360
|
-
}>;
|
|
361
|
-
|
|
362
|
-
export type L2ToL1Message = Partial<{
|
|
363
|
-
/** Message index. */
|
|
364
|
-
index: number;
|
|
365
|
-
/** L2 sender address. */
|
|
366
|
-
fromAddress: FieldElement;
|
|
367
|
-
/** L1 target address. */
|
|
368
|
-
toAddress: FieldElement;
|
|
369
|
-
/** Calldata. */
|
|
370
|
-
payload: FieldElement[];
|
|
371
|
-
}>;
|
|
372
|
-
|
|
373
|
-
export type StateUpdate = Partial<{
|
|
374
|
-
/** New state root. */
|
|
375
|
-
newRoot: FieldElement;
|
|
376
|
-
/** Old state root. */
|
|
377
|
-
oldRoot: FieldElement;
|
|
378
|
-
/** State diff. */
|
|
379
|
-
stateDiff: StateDiff;
|
|
380
|
-
}>;
|
|
381
|
-
|
|
382
|
-
export type StateDiff = Partial<{
|
|
383
|
-
/** Changes in storage. */
|
|
384
|
-
storageDiffs: StorageDiff[];
|
|
385
|
-
/** Declared contracts. */
|
|
386
|
-
declaredContracts: DeclaredContract[];
|
|
387
|
-
/** Deployed contracts. */
|
|
388
|
-
deployedContracts: DeployedContract[];
|
|
389
|
-
/** Nonce updates. */
|
|
390
|
-
nonces: NonceUpdate[];
|
|
391
|
-
/** Classes declared. */
|
|
392
|
-
declaredClasses: DeclaredClass[];
|
|
393
|
-
/** Classes replaced. */
|
|
394
|
-
replacedClasses: ReplacedClass[];
|
|
395
|
-
}>;
|
|
396
|
-
|
|
397
|
-
export type StorageDiff = Partial<{
|
|
398
|
-
/** Contract address. */
|
|
399
|
-
contractAddress: FieldElement;
|
|
400
|
-
/** Changes in storage. */
|
|
401
|
-
storageEntries: StorageEntry[];
|
|
402
|
-
}>;
|
|
403
|
-
|
|
404
|
-
export type StorageEntry = Partial<{
|
|
405
|
-
/** Storage key. */
|
|
406
|
-
key: FieldElement;
|
|
407
|
-
/** New storage value. */
|
|
408
|
-
value: FieldElement;
|
|
409
|
-
}>;
|
|
410
|
-
|
|
411
|
-
export type DeclaredContract = Partial<{
|
|
412
|
-
/** Class hash. */
|
|
413
|
-
classHash: FieldElement;
|
|
414
|
-
}>;
|
|
415
|
-
|
|
416
|
-
export type DeclaredClass = Partial<{
|
|
417
|
-
/** Class hash. */
|
|
418
|
-
classHash: FieldElement;
|
|
419
|
-
/** Compiled class hash. */
|
|
420
|
-
compiledClassHash: FieldElement;
|
|
421
|
-
}>;
|
|
422
|
-
|
|
423
|
-
export type ReplacedClass = Partial<{
|
|
424
|
-
/** Contract address. */
|
|
425
|
-
contractAddress: FieldElement;
|
|
426
|
-
/** Class hash. */
|
|
427
|
-
classHash: FieldElement;
|
|
428
|
-
}>;
|
|
429
|
-
|
|
430
|
-
export type DeployedContract = Partial<{
|
|
431
|
-
/** Contract address. */
|
|
432
|
-
contractAddress: FieldElement;
|
|
433
|
-
/** Class hash. */
|
|
434
|
-
classHash: FieldElement;
|
|
435
|
-
}>;
|
|
436
|
-
|
|
437
|
-
export type NonceUpdate = Partial<{
|
|
438
|
-
/** Contract address. */
|
|
439
|
-
contractAddress: FieldElement;
|
|
440
|
-
/** New nonce. */
|
|
441
|
-
nonce: FieldElement;
|
|
442
|
-
}>;
|
|
443
|
-
|
|
444
|
-
export type ResourcePrice = Partial<{
|
|
445
|
-
/** Price in fri (10^-18 strk). */
|
|
446
|
-
priceInFri: FieldElement;
|
|
447
|
-
/** Price in wei (10^-18 eth). */
|
|
448
|
-
priceInWei: FieldElement;
|
|
449
|
-
}>;
|
|
450
|
-
|
|
451
|
-
export type ResourceBoundsMapping = Partial<{
|
|
452
|
-
l1Gas: ResourceBounds;
|
|
453
|
-
l2Gas: ResourceBounds;
|
|
454
|
-
}>;
|
|
455
|
-
|
|
456
|
-
export type ResourceBounds = Partial<{
|
|
457
|
-
maxAmount: number;
|
|
458
|
-
maxPricePerUnit: Partial<{ low: number; high: number }>;
|
|
459
|
-
}>;
|
|
460
|
-
|
|
461
|
-
export type DataAvailabilityMode =
|
|
462
|
-
| "DATA_AVAILABILITY_MODE_UNSPECIFIED"
|
|
463
|
-
| "DATA_AVAILABILITY_MODE_L2"
|
|
464
|
-
| "DATA_AVAILABILITY_MODE_L1";
|
|
465
|
-
|
|
466
|
-
export type L1DataAvailabilityMode =
|
|
467
|
-
| "L1_DATA_AVAILABILITY_MODE_UNSPECIFIED"
|
|
468
|
-
| "L1_DATA_AVAILABILITY_MODE_BLOB"
|
|
469
|
-
| "L1_DATA_AVAILABILITY_MODE_CALLDATA";
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "vitest";
|
|
2
|
-
|
|
3
|
-
import { FieldElement } from "./felt";
|
|
4
|
-
|
|
5
|
-
describe("FieldElement", () => {
|
|
6
|
-
test("parse address", () => {
|
|
7
|
-
const output = FieldElement.parse(
|
|
8
|
-
"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
|
|
9
|
-
);
|
|
10
|
-
expect(output).toEqual(
|
|
11
|
-
"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
|
|
12
|
-
);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
test("parse value", () => {
|
|
16
|
-
const output = FieldElement.parse("0x1");
|
|
17
|
-
expect(output).toEqual(
|
|
18
|
-
"0x0000000000000000000000000000000000000000000000000000000000000001",
|
|
19
|
-
);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test("parse invalid value", () => {
|
|
23
|
-
expect(() => FieldElement.parse("0x")).toThrowError();
|
|
24
|
-
});
|
|
25
|
-
});
|
package/src/starknet/felt.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { hash } from "starknet";
|
|
3
|
-
|
|
4
|
-
export type FieldElement = `0x${string}`;
|
|
5
|
-
|
|
6
|
-
export const FieldElement = z.string().transform((value, ctx) => {
|
|
7
|
-
const regex = /^0x[0-9a-fA-F]{1,64}$/;
|
|
8
|
-
|
|
9
|
-
if (!regex.test(value)) {
|
|
10
|
-
ctx.addIssue({
|
|
11
|
-
code: z.ZodIssueCode.custom,
|
|
12
|
-
message: `FieldElement must be a hex string with a 0x prefix, got ${value}`,
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const bn = BigInt(value);
|
|
17
|
-
const padded = bn.toString(16).padStart(64, "0");
|
|
18
|
-
return `0x${padded}` as FieldElement;
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Compute the selector from a function or event name.
|
|
23
|
-
*
|
|
24
|
-
* The return value is padded to 32 bytes.
|
|
25
|
-
* @param name the function/event name
|
|
26
|
-
* @returns a field element
|
|
27
|
-
*/
|
|
28
|
-
export function getSelector(name: string): FieldElement {
|
|
29
|
-
return FieldElement.parse(hash.getSelectorFromName(name));
|
|
30
|
-
}
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import { assertType, describe, test } from "vitest";
|
|
2
|
-
|
|
3
|
-
import { FieldElement } from "./felt";
|
|
4
|
-
import type {
|
|
5
|
-
EventFilter,
|
|
6
|
-
Filter,
|
|
7
|
-
L2ToL1MessageFilter,
|
|
8
|
-
StateUpdateFilter,
|
|
9
|
-
TransactionFilter,
|
|
10
|
-
} from "./filter";
|
|
11
|
-
|
|
12
|
-
const address =
|
|
13
|
-
"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7";
|
|
14
|
-
const entryPointSelector =
|
|
15
|
-
"0x03943907ef0ef6f9d2e2408b05e520a66daaf74293dbf665e5a20b117676170e";
|
|
16
|
-
const calldata = [FieldElement.parse("0x01"), FieldElement.parse("0x02")];
|
|
17
|
-
|
|
18
|
-
describe("Filter", () => {
|
|
19
|
-
test("all optional", () => {
|
|
20
|
-
assertType<Filter>({});
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
describe("TransactionFilter", () => {
|
|
25
|
-
test("all optional", () => {
|
|
26
|
-
assertType<TransactionFilter>({});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test("includeReverted", () => {
|
|
30
|
-
assertType<TransactionFilter>({ includeReverted: true });
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test("only one inner filter", () => {
|
|
34
|
-
// @ts-expect-error - multiple inner filters
|
|
35
|
-
assertType<TransactionFilter>({
|
|
36
|
-
invokeV0: {},
|
|
37
|
-
deployAccount: {},
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
test("filter invoke transaction v0", () => {
|
|
42
|
-
assertType<TransactionFilter>({
|
|
43
|
-
invokeV0: {
|
|
44
|
-
contractAddress: address,
|
|
45
|
-
entryPointSelector,
|
|
46
|
-
calldata,
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
test("filter invoke transaction v1", () => {
|
|
52
|
-
assertType<TransactionFilter>({
|
|
53
|
-
invokeV1: {
|
|
54
|
-
senderAddress: address,
|
|
55
|
-
calldata,
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test("filter deploy transaction", () => {
|
|
61
|
-
assertType<TransactionFilter>({
|
|
62
|
-
deploy: {
|
|
63
|
-
contractAddressSalt: address,
|
|
64
|
-
classHash: address,
|
|
65
|
-
constructorCalldata: calldata,
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
test("filter declare transaction", () => {
|
|
71
|
-
assertType<TransactionFilter>({
|
|
72
|
-
declare: {
|
|
73
|
-
senderAddress: address,
|
|
74
|
-
classHash: address,
|
|
75
|
-
},
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
test("filter l1 handler transaction", () => {
|
|
80
|
-
assertType<TransactionFilter>({
|
|
81
|
-
l1Handler: {
|
|
82
|
-
contractAddress: address,
|
|
83
|
-
entryPointSelector,
|
|
84
|
-
calldata,
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
test("filter deploy account transaction", () => {
|
|
90
|
-
assertType<TransactionFilter>({
|
|
91
|
-
deployAccount: {
|
|
92
|
-
contractAddressSalt: address,
|
|
93
|
-
classHash: address,
|
|
94
|
-
constructorCalldata: calldata,
|
|
95
|
-
},
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
describe("EventFilter", () => {
|
|
101
|
-
test("all optional", () => {
|
|
102
|
-
assertType<EventFilter>({});
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
test("with properties", () => {
|
|
106
|
-
assertType<EventFilter>({
|
|
107
|
-
fromAddress: address,
|
|
108
|
-
keys: [entryPointSelector],
|
|
109
|
-
includeReverted: true,
|
|
110
|
-
data: calldata,
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
describe("L2ToL1MessageFilter", () => {
|
|
116
|
-
test("all optional", () => {
|
|
117
|
-
assertType<L2ToL1MessageFilter>({});
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
test("with properties", () => {
|
|
121
|
-
assertType<L2ToL1MessageFilter>({
|
|
122
|
-
toAddress: address,
|
|
123
|
-
includeReverted: true,
|
|
124
|
-
payload: calldata,
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
describe("StateUpdateFilter", () => {
|
|
130
|
-
test("all optional", () => {
|
|
131
|
-
assertType<StateUpdateFilter>({});
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
test("with storage diffs", () => {
|
|
135
|
-
assertType<StateUpdateFilter>({
|
|
136
|
-
storageDiffs: [
|
|
137
|
-
{
|
|
138
|
-
contractAddress: address,
|
|
139
|
-
},
|
|
140
|
-
],
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
test("with declared contracts", () => {
|
|
145
|
-
assertType<StateUpdateFilter>({
|
|
146
|
-
declaredContracts: [
|
|
147
|
-
{
|
|
148
|
-
classHash: address,
|
|
149
|
-
},
|
|
150
|
-
],
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
test("with deployed contracts", () => {
|
|
155
|
-
assertType<StateUpdateFilter>({
|
|
156
|
-
deployedContracts: [
|
|
157
|
-
{
|
|
158
|
-
classHash: address,
|
|
159
|
-
contractAddress: address,
|
|
160
|
-
},
|
|
161
|
-
],
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
test("with nonces", () => {
|
|
166
|
-
assertType<StateUpdateFilter>({
|
|
167
|
-
nonces: [
|
|
168
|
-
{
|
|
169
|
-
contractAddress: address,
|
|
170
|
-
nonce: "0x1",
|
|
171
|
-
},
|
|
172
|
-
],
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
test("with declared classes", () => {
|
|
177
|
-
assertType<StateUpdateFilter>({
|
|
178
|
-
declaredClasses: [
|
|
179
|
-
{
|
|
180
|
-
compiledClassHash: address,
|
|
181
|
-
classHash: address,
|
|
182
|
-
},
|
|
183
|
-
],
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
test("with replaced classes", () => {
|
|
188
|
-
assertType<StateUpdateFilter>({
|
|
189
|
-
replacedClasses: [
|
|
190
|
-
{
|
|
191
|
-
contractAddress: address,
|
|
192
|
-
classHash: address,
|
|
193
|
-
},
|
|
194
|
-
],
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
});
|