@gitmyabi/statecommitmentchain 0.0.0-stage → 1.0.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.
- package/README.md +107 -2
- package/contracts/StateCommitmentChain.d.ts +527 -0
- package/contracts/StateCommitmentChain.js +607 -0
- package/contracts/StateCommitmentChain.ts +709 -0
- package/contracts/index.d.ts +2 -0
- package/contracts/index.js +7 -0
- package/contracts/index.ts +3 -0
- package/index.d.ts +1 -0
- package/index.js +19 -0
- package/package.json +40 -3
|
@@ -0,0 +1,607 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StateCommitmentChain = exports.StateCommitmentChainAbi = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
/**
|
|
6
|
+
* StateCommitmentChain ABI
|
|
7
|
+
*
|
|
8
|
+
* This ABI is typed using viem's type system for full type safety.
|
|
9
|
+
*/
|
|
10
|
+
exports.StateCommitmentChainAbi = [
|
|
11
|
+
{
|
|
12
|
+
"inputs": [
|
|
13
|
+
{
|
|
14
|
+
"internalType": "address",
|
|
15
|
+
"name": "_libAddressManager",
|
|
16
|
+
"type": "address"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"internalType": "uint256",
|
|
20
|
+
"name": "_fraudProofWindow",
|
|
21
|
+
"type": "uint256"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"internalType": "uint256",
|
|
25
|
+
"name": "_sequencerPublishWindow",
|
|
26
|
+
"type": "uint256"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"stateMutability": "nonpayable",
|
|
30
|
+
"type": "constructor"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"anonymous": false,
|
|
34
|
+
"inputs": [
|
|
35
|
+
{
|
|
36
|
+
"indexed": true,
|
|
37
|
+
"internalType": "uint256",
|
|
38
|
+
"name": "_batchIndex",
|
|
39
|
+
"type": "uint256"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"indexed": false,
|
|
43
|
+
"internalType": "bytes32",
|
|
44
|
+
"name": "_batchRoot",
|
|
45
|
+
"type": "bytes32"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"indexed": false,
|
|
49
|
+
"internalType": "uint256",
|
|
50
|
+
"name": "_batchSize",
|
|
51
|
+
"type": "uint256"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"indexed": false,
|
|
55
|
+
"internalType": "uint256",
|
|
56
|
+
"name": "_prevTotalElements",
|
|
57
|
+
"type": "uint256"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"indexed": false,
|
|
61
|
+
"internalType": "bytes",
|
|
62
|
+
"name": "_extraData",
|
|
63
|
+
"type": "bytes"
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"name": "StateBatchAppended",
|
|
67
|
+
"type": "event"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"anonymous": false,
|
|
71
|
+
"inputs": [
|
|
72
|
+
{
|
|
73
|
+
"indexed": true,
|
|
74
|
+
"internalType": "uint256",
|
|
75
|
+
"name": "_batchIndex",
|
|
76
|
+
"type": "uint256"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"indexed": false,
|
|
80
|
+
"internalType": "bytes32",
|
|
81
|
+
"name": "_batchRoot",
|
|
82
|
+
"type": "bytes32"
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
"name": "StateBatchDeleted",
|
|
86
|
+
"type": "event"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"inputs": [],
|
|
90
|
+
"name": "FRAUD_PROOF_WINDOW",
|
|
91
|
+
"outputs": [
|
|
92
|
+
{
|
|
93
|
+
"internalType": "uint256",
|
|
94
|
+
"name": "",
|
|
95
|
+
"type": "uint256"
|
|
96
|
+
}
|
|
97
|
+
],
|
|
98
|
+
"stateMutability": "view",
|
|
99
|
+
"type": "function"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"inputs": [],
|
|
103
|
+
"name": "SEQUENCER_PUBLISH_WINDOW",
|
|
104
|
+
"outputs": [
|
|
105
|
+
{
|
|
106
|
+
"internalType": "uint256",
|
|
107
|
+
"name": "",
|
|
108
|
+
"type": "uint256"
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
"stateMutability": "view",
|
|
112
|
+
"type": "function"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"inputs": [
|
|
116
|
+
{
|
|
117
|
+
"internalType": "bytes32[]",
|
|
118
|
+
"name": "_batch",
|
|
119
|
+
"type": "bytes32[]"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"internalType": "uint256",
|
|
123
|
+
"name": "_shouldStartAtElement",
|
|
124
|
+
"type": "uint256"
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
"name": "appendStateBatch",
|
|
128
|
+
"outputs": [],
|
|
129
|
+
"stateMutability": "nonpayable",
|
|
130
|
+
"type": "function"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"inputs": [],
|
|
134
|
+
"name": "batches",
|
|
135
|
+
"outputs": [
|
|
136
|
+
{
|
|
137
|
+
"internalType": "contract IChainStorageContainer",
|
|
138
|
+
"name": "",
|
|
139
|
+
"type": "address"
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
"stateMutability": "view",
|
|
143
|
+
"type": "function"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"inputs": [
|
|
147
|
+
{
|
|
148
|
+
"components": [
|
|
149
|
+
{
|
|
150
|
+
"internalType": "uint256",
|
|
151
|
+
"name": "batchIndex",
|
|
152
|
+
"type": "uint256"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"internalType": "bytes32",
|
|
156
|
+
"name": "batchRoot",
|
|
157
|
+
"type": "bytes32"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"internalType": "uint256",
|
|
161
|
+
"name": "batchSize",
|
|
162
|
+
"type": "uint256"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"internalType": "uint256",
|
|
166
|
+
"name": "prevTotalElements",
|
|
167
|
+
"type": "uint256"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"internalType": "bytes",
|
|
171
|
+
"name": "extraData",
|
|
172
|
+
"type": "bytes"
|
|
173
|
+
}
|
|
174
|
+
],
|
|
175
|
+
"internalType": "struct Lib_OVMCodec.ChainBatchHeader",
|
|
176
|
+
"name": "_batchHeader",
|
|
177
|
+
"type": "tuple"
|
|
178
|
+
}
|
|
179
|
+
],
|
|
180
|
+
"name": "deleteStateBatch",
|
|
181
|
+
"outputs": [],
|
|
182
|
+
"stateMutability": "nonpayable",
|
|
183
|
+
"type": "function"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"inputs": [],
|
|
187
|
+
"name": "getLastSequencerTimestamp",
|
|
188
|
+
"outputs": [
|
|
189
|
+
{
|
|
190
|
+
"internalType": "uint256",
|
|
191
|
+
"name": "_lastSequencerTimestamp",
|
|
192
|
+
"type": "uint256"
|
|
193
|
+
}
|
|
194
|
+
],
|
|
195
|
+
"stateMutability": "view",
|
|
196
|
+
"type": "function"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"inputs": [],
|
|
200
|
+
"name": "getTotalBatches",
|
|
201
|
+
"outputs": [
|
|
202
|
+
{
|
|
203
|
+
"internalType": "uint256",
|
|
204
|
+
"name": "_totalBatches",
|
|
205
|
+
"type": "uint256"
|
|
206
|
+
}
|
|
207
|
+
],
|
|
208
|
+
"stateMutability": "view",
|
|
209
|
+
"type": "function"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"inputs": [],
|
|
213
|
+
"name": "getTotalElements",
|
|
214
|
+
"outputs": [
|
|
215
|
+
{
|
|
216
|
+
"internalType": "uint256",
|
|
217
|
+
"name": "_totalElements",
|
|
218
|
+
"type": "uint256"
|
|
219
|
+
}
|
|
220
|
+
],
|
|
221
|
+
"stateMutability": "view",
|
|
222
|
+
"type": "function"
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
"inputs": [
|
|
226
|
+
{
|
|
227
|
+
"components": [
|
|
228
|
+
{
|
|
229
|
+
"internalType": "uint256",
|
|
230
|
+
"name": "batchIndex",
|
|
231
|
+
"type": "uint256"
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
"internalType": "bytes32",
|
|
235
|
+
"name": "batchRoot",
|
|
236
|
+
"type": "bytes32"
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"internalType": "uint256",
|
|
240
|
+
"name": "batchSize",
|
|
241
|
+
"type": "uint256"
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
"internalType": "uint256",
|
|
245
|
+
"name": "prevTotalElements",
|
|
246
|
+
"type": "uint256"
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
"internalType": "bytes",
|
|
250
|
+
"name": "extraData",
|
|
251
|
+
"type": "bytes"
|
|
252
|
+
}
|
|
253
|
+
],
|
|
254
|
+
"internalType": "struct Lib_OVMCodec.ChainBatchHeader",
|
|
255
|
+
"name": "_batchHeader",
|
|
256
|
+
"type": "tuple"
|
|
257
|
+
}
|
|
258
|
+
],
|
|
259
|
+
"name": "insideFraudProofWindow",
|
|
260
|
+
"outputs": [
|
|
261
|
+
{
|
|
262
|
+
"internalType": "bool",
|
|
263
|
+
"name": "_inside",
|
|
264
|
+
"type": "bool"
|
|
265
|
+
}
|
|
266
|
+
],
|
|
267
|
+
"stateMutability": "view",
|
|
268
|
+
"type": "function"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
"inputs": [],
|
|
272
|
+
"name": "libAddressManager",
|
|
273
|
+
"outputs": [
|
|
274
|
+
{
|
|
275
|
+
"internalType": "contract Lib_AddressManager",
|
|
276
|
+
"name": "",
|
|
277
|
+
"type": "address"
|
|
278
|
+
}
|
|
279
|
+
],
|
|
280
|
+
"stateMutability": "view",
|
|
281
|
+
"type": "function"
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
"inputs": [
|
|
285
|
+
{
|
|
286
|
+
"internalType": "string",
|
|
287
|
+
"name": "_name",
|
|
288
|
+
"type": "string"
|
|
289
|
+
}
|
|
290
|
+
],
|
|
291
|
+
"name": "resolve",
|
|
292
|
+
"outputs": [
|
|
293
|
+
{
|
|
294
|
+
"internalType": "address",
|
|
295
|
+
"name": "",
|
|
296
|
+
"type": "address"
|
|
297
|
+
}
|
|
298
|
+
],
|
|
299
|
+
"stateMutability": "view",
|
|
300
|
+
"type": "function"
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
"inputs": [
|
|
304
|
+
{
|
|
305
|
+
"internalType": "bytes32",
|
|
306
|
+
"name": "_element",
|
|
307
|
+
"type": "bytes32"
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
"components": [
|
|
311
|
+
{
|
|
312
|
+
"internalType": "uint256",
|
|
313
|
+
"name": "batchIndex",
|
|
314
|
+
"type": "uint256"
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
"internalType": "bytes32",
|
|
318
|
+
"name": "batchRoot",
|
|
319
|
+
"type": "bytes32"
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
"internalType": "uint256",
|
|
323
|
+
"name": "batchSize",
|
|
324
|
+
"type": "uint256"
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
"internalType": "uint256",
|
|
328
|
+
"name": "prevTotalElements",
|
|
329
|
+
"type": "uint256"
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
"internalType": "bytes",
|
|
333
|
+
"name": "extraData",
|
|
334
|
+
"type": "bytes"
|
|
335
|
+
}
|
|
336
|
+
],
|
|
337
|
+
"internalType": "struct Lib_OVMCodec.ChainBatchHeader",
|
|
338
|
+
"name": "_batchHeader",
|
|
339
|
+
"type": "tuple"
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
"components": [
|
|
343
|
+
{
|
|
344
|
+
"internalType": "uint256",
|
|
345
|
+
"name": "index",
|
|
346
|
+
"type": "uint256"
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
"internalType": "bytes32[]",
|
|
350
|
+
"name": "siblings",
|
|
351
|
+
"type": "bytes32[]"
|
|
352
|
+
}
|
|
353
|
+
],
|
|
354
|
+
"internalType": "struct Lib_OVMCodec.ChainInclusionProof",
|
|
355
|
+
"name": "_proof",
|
|
356
|
+
"type": "tuple"
|
|
357
|
+
}
|
|
358
|
+
],
|
|
359
|
+
"name": "verifyStateCommitment",
|
|
360
|
+
"outputs": [
|
|
361
|
+
{
|
|
362
|
+
"internalType": "bool",
|
|
363
|
+
"name": "",
|
|
364
|
+
"type": "bool"
|
|
365
|
+
}
|
|
366
|
+
],
|
|
367
|
+
"stateMutability": "view",
|
|
368
|
+
"type": "function"
|
|
369
|
+
}
|
|
370
|
+
];
|
|
371
|
+
/**
|
|
372
|
+
* StateCommitmentChain Contract Class
|
|
373
|
+
*
|
|
374
|
+
* Provides a class-based API similar to TypeChain for interacting with the contract.
|
|
375
|
+
*
|
|
376
|
+
* @example
|
|
377
|
+
* ```typescript
|
|
378
|
+
* import { createPublicClient, createWalletClient, http } from 'viem';
|
|
379
|
+
* import { mainnet } from 'viem/chains';
|
|
380
|
+
* import { StateCommitmentChain } from 'StateCommitmentChain';
|
|
381
|
+
*
|
|
382
|
+
* const publicClient = createPublicClient({ chain: mainnet, transport: http() });
|
|
383
|
+
* const walletClient = createWalletClient({ chain: mainnet, transport: http() });
|
|
384
|
+
*
|
|
385
|
+
* const contract = new StateCommitmentChain('0x...', { publicClient, walletClient });
|
|
386
|
+
*
|
|
387
|
+
* // Read functions
|
|
388
|
+
* const result = await contract.balanceOf('0x...');
|
|
389
|
+
*
|
|
390
|
+
* // Write functions
|
|
391
|
+
* const hash = await contract.transfer('0x...', 1000n);
|
|
392
|
+
*
|
|
393
|
+
* // Simulate transactions (dry-run)
|
|
394
|
+
* const simulation = await contract.simulate.transfer('0x...', 1000n);
|
|
395
|
+
* console.log('Gas estimate:', simulation.request.gas);
|
|
396
|
+
*
|
|
397
|
+
* // Watch events
|
|
398
|
+
* const unwatch = contract.watch.Transfer((event) => {
|
|
399
|
+
* console.log('Transfer event:', event);
|
|
400
|
+
* });
|
|
401
|
+
* ```
|
|
402
|
+
*/
|
|
403
|
+
class StateCommitmentChain {
|
|
404
|
+
constructor(address, clients) {
|
|
405
|
+
this.contractAddress = address;
|
|
406
|
+
this.publicClient = clients.publicClient;
|
|
407
|
+
this.contract = (0, viem_1.getContract)({
|
|
408
|
+
address,
|
|
409
|
+
abi: exports.StateCommitmentChainAbi,
|
|
410
|
+
client: {
|
|
411
|
+
public: clients.publicClient,
|
|
412
|
+
wallet: clients.walletClient,
|
|
413
|
+
},
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Get the contract address
|
|
418
|
+
*/
|
|
419
|
+
get address() {
|
|
420
|
+
return this.contractAddress;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Get the underlying viem contract instance.
|
|
424
|
+
*/
|
|
425
|
+
getContract() {
|
|
426
|
+
return this.contract;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* FRAUD_PROOF_WINDOW
|
|
430
|
+
* view
|
|
431
|
+
*/
|
|
432
|
+
async FRAUD_PROOF_WINDOW() {
|
|
433
|
+
return this.contract.read.FRAUD_PROOF_WINDOW();
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* SEQUENCER_PUBLISH_WINDOW
|
|
437
|
+
* view
|
|
438
|
+
*/
|
|
439
|
+
async SEQUENCER_PUBLISH_WINDOW() {
|
|
440
|
+
return this.contract.read.SEQUENCER_PUBLISH_WINDOW();
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* batches
|
|
444
|
+
* view
|
|
445
|
+
*/
|
|
446
|
+
async batches() {
|
|
447
|
+
return this.contract.read.batches();
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* getLastSequencerTimestamp
|
|
451
|
+
* view
|
|
452
|
+
*/
|
|
453
|
+
async getLastSequencerTimestamp() {
|
|
454
|
+
return this.contract.read.getLastSequencerTimestamp();
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* getTotalBatches
|
|
458
|
+
* view
|
|
459
|
+
*/
|
|
460
|
+
async getTotalBatches() {
|
|
461
|
+
return this.contract.read.getTotalBatches();
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* getTotalElements
|
|
465
|
+
* view
|
|
466
|
+
*/
|
|
467
|
+
async getTotalElements() {
|
|
468
|
+
return this.contract.read.getTotalElements();
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* insideFraudProofWindow
|
|
472
|
+
* view
|
|
473
|
+
*/
|
|
474
|
+
async insideFraudProofWindow(_batchHeader) {
|
|
475
|
+
return this.contract.read.insideFraudProofWindow([_batchHeader]);
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* libAddressManager
|
|
479
|
+
* view
|
|
480
|
+
*/
|
|
481
|
+
async libAddressManager() {
|
|
482
|
+
return this.contract.read.libAddressManager();
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* resolve
|
|
486
|
+
* view
|
|
487
|
+
*/
|
|
488
|
+
async resolve(_name) {
|
|
489
|
+
return this.contract.read.resolve([_name]);
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* verifyStateCommitment
|
|
493
|
+
* view
|
|
494
|
+
*/
|
|
495
|
+
async verifyStateCommitment(_element, _batchHeader, _proof) {
|
|
496
|
+
return this.contract.read.verifyStateCommitment([_element, _batchHeader, _proof]);
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* appendStateBatch
|
|
500
|
+
* nonpayable
|
|
501
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
502
|
+
*/
|
|
503
|
+
async appendStateBatch(_batch, _shouldStartAtElement, options) {
|
|
504
|
+
if (!this.contract.write) {
|
|
505
|
+
throw new Error('Wallet client is required for write operations');
|
|
506
|
+
}
|
|
507
|
+
return this.contract.write.appendStateBatch([_batch, _shouldStartAtElement], options);
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* deleteStateBatch
|
|
511
|
+
* nonpayable
|
|
512
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
513
|
+
*/
|
|
514
|
+
async deleteStateBatch(_batchHeader, options) {
|
|
515
|
+
if (!this.contract.write) {
|
|
516
|
+
throw new Error('Wallet client is required for write operations');
|
|
517
|
+
}
|
|
518
|
+
return this.contract.write.deleteStateBatch([_batchHeader], options);
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Simulate contract write operations (dry-run without sending transaction)
|
|
522
|
+
*
|
|
523
|
+
* @example
|
|
524
|
+
* const result = await contract.simulate.transfer('0x...', 1000n);
|
|
525
|
+
* console.log('Gas estimate:', result.request.gas);
|
|
526
|
+
* console.log('Would succeed:', result.result);
|
|
527
|
+
*/
|
|
528
|
+
get simulate() {
|
|
529
|
+
const contract = this.contract;
|
|
530
|
+
if (!contract.simulate) {
|
|
531
|
+
throw new Error('Public client is required for simulation');
|
|
532
|
+
}
|
|
533
|
+
return {
|
|
534
|
+
/**
|
|
535
|
+
* Simulate appendStateBatch
|
|
536
|
+
* Returns gas estimate and result without sending transaction
|
|
537
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
538
|
+
*/
|
|
539
|
+
async appendStateBatch(_batch, _shouldStartAtElement, options) {
|
|
540
|
+
return contract.simulate.appendStateBatch([_batch, _shouldStartAtElement], options);
|
|
541
|
+
},
|
|
542
|
+
/**
|
|
543
|
+
* Simulate deleteStateBatch
|
|
544
|
+
* Returns gas estimate and result without sending transaction
|
|
545
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
546
|
+
*/
|
|
547
|
+
async deleteStateBatch(_batchHeader, options) {
|
|
548
|
+
return contract.simulate.deleteStateBatch([_batchHeader], options);
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Watch contract events
|
|
554
|
+
*
|
|
555
|
+
* @example
|
|
556
|
+
* // Watch all Transfer events
|
|
557
|
+
* const unwatch = contract.watch.Transfer((event) => {
|
|
558
|
+
* console.log('Transfer:', event);
|
|
559
|
+
* });
|
|
560
|
+
*
|
|
561
|
+
* // Stop watching
|
|
562
|
+
* unwatch();
|
|
563
|
+
*/
|
|
564
|
+
get watch() {
|
|
565
|
+
return {
|
|
566
|
+
/**
|
|
567
|
+
* Watch StateBatchAppended events
|
|
568
|
+
* @param callback Function to call when event is emitted
|
|
569
|
+
* @param filter Optional filter for indexed parameters
|
|
570
|
+
* @returns Unwatch function to stop listening
|
|
571
|
+
*/
|
|
572
|
+
StateBatchAppended: (callback, filter) => {
|
|
573
|
+
return this.publicClient.watchContractEvent({
|
|
574
|
+
address: this.contractAddress,
|
|
575
|
+
abi: exports.StateCommitmentChainAbi,
|
|
576
|
+
eventName: 'StateBatchAppended',
|
|
577
|
+
args: filter,
|
|
578
|
+
onLogs: (logs) => {
|
|
579
|
+
logs.forEach((log) => {
|
|
580
|
+
callback(log.args);
|
|
581
|
+
});
|
|
582
|
+
},
|
|
583
|
+
});
|
|
584
|
+
},
|
|
585
|
+
/**
|
|
586
|
+
* Watch StateBatchDeleted events
|
|
587
|
+
* @param callback Function to call when event is emitted
|
|
588
|
+
* @param filter Optional filter for indexed parameters
|
|
589
|
+
* @returns Unwatch function to stop listening
|
|
590
|
+
*/
|
|
591
|
+
StateBatchDeleted: (callback, filter) => {
|
|
592
|
+
return this.publicClient.watchContractEvent({
|
|
593
|
+
address: this.contractAddress,
|
|
594
|
+
abi: exports.StateCommitmentChainAbi,
|
|
595
|
+
eventName: 'StateBatchDeleted',
|
|
596
|
+
args: filter,
|
|
597
|
+
onLogs: (logs) => {
|
|
598
|
+
logs.forEach((log) => {
|
|
599
|
+
callback(log.args);
|
|
600
|
+
});
|
|
601
|
+
},
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
exports.StateCommitmentChain = StateCommitmentChain;
|