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