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