@gitmyabi-stg/equad 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,777 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QuadToken = exports.QuadTokenAbi = void 0;
4
+ const viem_1 = require("viem");
5
+ /**
6
+ * QuadToken ABI
7
+ *
8
+ * This ABI is typed using viem's type system for full type safety.
9
+ */
10
+ exports.QuadTokenAbi = [
11
+ {
12
+ "constant": true,
13
+ "inputs": [],
14
+ "name": "name",
15
+ "outputs": [
16
+ {
17
+ "name": "",
18
+ "type": "string"
19
+ }
20
+ ],
21
+ "payable": false,
22
+ "stateMutability": "view",
23
+ "type": "function"
24
+ },
25
+ {
26
+ "constant": false,
27
+ "inputs": [
28
+ {
29
+ "name": "_spender",
30
+ "type": "address"
31
+ },
32
+ {
33
+ "name": "_value",
34
+ "type": "uint256"
35
+ }
36
+ ],
37
+ "name": "approve",
38
+ "outputs": [
39
+ {
40
+ "name": "",
41
+ "type": "bool"
42
+ }
43
+ ],
44
+ "payable": false,
45
+ "stateMutability": "nonpayable",
46
+ "type": "function"
47
+ },
48
+ {
49
+ "constant": false,
50
+ "inputs": [
51
+ {
52
+ "name": "oldAddress",
53
+ "type": "address"
54
+ }
55
+ ],
56
+ "name": "restrictTokenTransfer",
57
+ "outputs": [],
58
+ "payable": false,
59
+ "stateMutability": "nonpayable",
60
+ "type": "function"
61
+ },
62
+ {
63
+ "constant": true,
64
+ "inputs": [],
65
+ "name": "totalSupply",
66
+ "outputs": [
67
+ {
68
+ "name": "",
69
+ "type": "uint256"
70
+ }
71
+ ],
72
+ "payable": false,
73
+ "stateMutability": "view",
74
+ "type": "function"
75
+ },
76
+ {
77
+ "constant": false,
78
+ "inputs": [
79
+ {
80
+ "name": "_from",
81
+ "type": "address"
82
+ },
83
+ {
84
+ "name": "_to",
85
+ "type": "address"
86
+ },
87
+ {
88
+ "name": "_value",
89
+ "type": "uint256"
90
+ }
91
+ ],
92
+ "name": "transferFrom",
93
+ "outputs": [
94
+ {
95
+ "name": "",
96
+ "type": "bool"
97
+ }
98
+ ],
99
+ "payable": false,
100
+ "stateMutability": "nonpayable",
101
+ "type": "function"
102
+ },
103
+ {
104
+ "constant": true,
105
+ "inputs": [],
106
+ "name": "INITIAL_SUPPLY",
107
+ "outputs": [
108
+ {
109
+ "name": "",
110
+ "type": "uint256"
111
+ }
112
+ ],
113
+ "payable": false,
114
+ "stateMutability": "view",
115
+ "type": "function"
116
+ },
117
+ {
118
+ "constant": true,
119
+ "inputs": [],
120
+ "name": "decimals",
121
+ "outputs": [
122
+ {
123
+ "name": "",
124
+ "type": "uint8"
125
+ }
126
+ ],
127
+ "payable": false,
128
+ "stateMutability": "view",
129
+ "type": "function"
130
+ },
131
+ {
132
+ "constant": false,
133
+ "inputs": [
134
+ {
135
+ "name": "_spender",
136
+ "type": "address"
137
+ },
138
+ {
139
+ "name": "_subtractedValue",
140
+ "type": "uint256"
141
+ }
142
+ ],
143
+ "name": "decreaseApproval",
144
+ "outputs": [
145
+ {
146
+ "name": "",
147
+ "type": "bool"
148
+ }
149
+ ],
150
+ "payable": false,
151
+ "stateMutability": "nonpayable",
152
+ "type": "function"
153
+ },
154
+ {
155
+ "constant": true,
156
+ "inputs": [
157
+ {
158
+ "name": "_owner",
159
+ "type": "address"
160
+ }
161
+ ],
162
+ "name": "balanceOf",
163
+ "outputs": [
164
+ {
165
+ "name": "balance",
166
+ "type": "uint256"
167
+ }
168
+ ],
169
+ "payable": false,
170
+ "stateMutability": "view",
171
+ "type": "function"
172
+ },
173
+ {
174
+ "constant": true,
175
+ "inputs": [],
176
+ "name": "owner",
177
+ "outputs": [
178
+ {
179
+ "name": "",
180
+ "type": "address"
181
+ }
182
+ ],
183
+ "payable": false,
184
+ "stateMutability": "view",
185
+ "type": "function"
186
+ },
187
+ {
188
+ "constant": false,
189
+ "inputs": [
190
+ {
191
+ "name": "newAddress",
192
+ "type": "address"
193
+ }
194
+ ],
195
+ "name": "allowTokenTransfer",
196
+ "outputs": [],
197
+ "payable": false,
198
+ "stateMutability": "nonpayable",
199
+ "type": "function"
200
+ },
201
+ {
202
+ "constant": true,
203
+ "inputs": [],
204
+ "name": "symbol",
205
+ "outputs": [
206
+ {
207
+ "name": "",
208
+ "type": "string"
209
+ }
210
+ ],
211
+ "payable": false,
212
+ "stateMutability": "view",
213
+ "type": "function"
214
+ },
215
+ {
216
+ "constant": false,
217
+ "inputs": [
218
+ {
219
+ "name": "_to",
220
+ "type": "address"
221
+ },
222
+ {
223
+ "name": "_value",
224
+ "type": "uint256"
225
+ }
226
+ ],
227
+ "name": "transfer",
228
+ "outputs": [
229
+ {
230
+ "name": "",
231
+ "type": "bool"
232
+ }
233
+ ],
234
+ "payable": false,
235
+ "stateMutability": "nonpayable",
236
+ "type": "function"
237
+ },
238
+ {
239
+ "constant": false,
240
+ "inputs": [],
241
+ "name": "disableTransfer",
242
+ "outputs": [],
243
+ "payable": false,
244
+ "stateMutability": "nonpayable",
245
+ "type": "function"
246
+ },
247
+ {
248
+ "constant": false,
249
+ "inputs": [
250
+ {
251
+ "name": "_spender",
252
+ "type": "address"
253
+ },
254
+ {
255
+ "name": "_addedValue",
256
+ "type": "uint256"
257
+ }
258
+ ],
259
+ "name": "increaseApproval",
260
+ "outputs": [
261
+ {
262
+ "name": "",
263
+ "type": "bool"
264
+ }
265
+ ],
266
+ "payable": false,
267
+ "stateMutability": "nonpayable",
268
+ "type": "function"
269
+ },
270
+ {
271
+ "constant": true,
272
+ "inputs": [
273
+ {
274
+ "name": "_owner",
275
+ "type": "address"
276
+ },
277
+ {
278
+ "name": "_spender",
279
+ "type": "address"
280
+ }
281
+ ],
282
+ "name": "allowance",
283
+ "outputs": [
284
+ {
285
+ "name": "",
286
+ "type": "uint256"
287
+ }
288
+ ],
289
+ "payable": false,
290
+ "stateMutability": "view",
291
+ "type": "function"
292
+ },
293
+ {
294
+ "constant": false,
295
+ "inputs": [],
296
+ "name": "enableTransfer",
297
+ "outputs": [],
298
+ "payable": false,
299
+ "stateMutability": "nonpayable",
300
+ "type": "function"
301
+ },
302
+ {
303
+ "constant": false,
304
+ "inputs": [
305
+ {
306
+ "name": "newOwner",
307
+ "type": "address"
308
+ }
309
+ ],
310
+ "name": "transferOwnership",
311
+ "outputs": [],
312
+ "payable": false,
313
+ "stateMutability": "nonpayable",
314
+ "type": "function"
315
+ },
316
+ {
317
+ "inputs": [],
318
+ "payable": false,
319
+ "stateMutability": "nonpayable",
320
+ "type": "constructor"
321
+ },
322
+ {
323
+ "anonymous": false,
324
+ "inputs": [
325
+ {
326
+ "indexed": true,
327
+ "name": "previousOwner",
328
+ "type": "address"
329
+ },
330
+ {
331
+ "indexed": true,
332
+ "name": "newOwner",
333
+ "type": "address"
334
+ }
335
+ ],
336
+ "name": "OwnershipTransferred",
337
+ "type": "event"
338
+ },
339
+ {
340
+ "anonymous": false,
341
+ "inputs": [
342
+ {
343
+ "indexed": true,
344
+ "name": "owner",
345
+ "type": "address"
346
+ },
347
+ {
348
+ "indexed": true,
349
+ "name": "spender",
350
+ "type": "address"
351
+ },
352
+ {
353
+ "indexed": false,
354
+ "name": "value",
355
+ "type": "uint256"
356
+ }
357
+ ],
358
+ "name": "Approval",
359
+ "type": "event"
360
+ },
361
+ {
362
+ "anonymous": false,
363
+ "inputs": [
364
+ {
365
+ "indexed": true,
366
+ "name": "from",
367
+ "type": "address"
368
+ },
369
+ {
370
+ "indexed": true,
371
+ "name": "to",
372
+ "type": "address"
373
+ },
374
+ {
375
+ "indexed": false,
376
+ "name": "value",
377
+ "type": "uint256"
378
+ }
379
+ ],
380
+ "name": "Transfer",
381
+ "type": "event"
382
+ }
383
+ ];
384
+ /**
385
+ * QuadToken Contract Class
386
+ *
387
+ * Provides a class-based API similar to TypeChain for interacting with the contract.
388
+ *
389
+ * @example
390
+ * ```typescript
391
+ * import { createPublicClient, createWalletClient, http } from 'viem';
392
+ * import { mainnet } from 'viem/chains';
393
+ * import { QuadToken } from 'QuadToken';
394
+ *
395
+ * const publicClient = createPublicClient({ chain: mainnet, transport: http() });
396
+ * const walletClient = createWalletClient({ chain: mainnet, transport: http() });
397
+ *
398
+ * const contract = new QuadToken('0x...', { publicClient, walletClient });
399
+ *
400
+ * // Read functions
401
+ * const result = await contract.balanceOf('0x...');
402
+ *
403
+ * // Write functions
404
+ * const hash = await contract.transfer('0x...', 1000n);
405
+ *
406
+ * // Simulate transactions (dry-run)
407
+ * const simulation = await contract.simulate.transfer('0x...', 1000n);
408
+ * console.log('Gas estimate:', simulation.request.gas);
409
+ *
410
+ * // Watch events
411
+ * const unwatch = contract.watch.Transfer((event) => {
412
+ * console.log('Transfer event:', event);
413
+ * });
414
+ * ```
415
+ */
416
+ class QuadToken {
417
+ constructor(address, clients) {
418
+ this.contractAddress = address;
419
+ this.publicClient = clients.publicClient;
420
+ this.contract = (0, viem_1.getContract)({
421
+ address,
422
+ abi: exports.QuadTokenAbi,
423
+ client: {
424
+ public: clients.publicClient,
425
+ wallet: clients.walletClient,
426
+ },
427
+ });
428
+ }
429
+ /**
430
+ * Get the contract address
431
+ */
432
+ get address() {
433
+ return this.contractAddress;
434
+ }
435
+ /**
436
+ * Get the underlying viem contract instance.
437
+ */
438
+ getContract() {
439
+ return this.contract;
440
+ }
441
+ /**
442
+ * name
443
+ * view
444
+ */
445
+ async name() {
446
+ return this.contract.read.name();
447
+ }
448
+ /**
449
+ * totalSupply
450
+ * view
451
+ */
452
+ async totalSupply() {
453
+ return this.contract.read.totalSupply();
454
+ }
455
+ /**
456
+ * INITIAL_SUPPLY
457
+ * view
458
+ */
459
+ async INITIAL_SUPPLY() {
460
+ return this.contract.read.INITIAL_SUPPLY();
461
+ }
462
+ /**
463
+ * decimals
464
+ * view
465
+ */
466
+ async decimals() {
467
+ return this.contract.read.decimals();
468
+ }
469
+ /**
470
+ * balanceOf
471
+ * view
472
+ */
473
+ async balanceOf(_owner) {
474
+ return this.contract.read.balanceOf([_owner]);
475
+ }
476
+ /**
477
+ * owner
478
+ * view
479
+ */
480
+ async owner() {
481
+ return this.contract.read.owner();
482
+ }
483
+ /**
484
+ * symbol
485
+ * view
486
+ */
487
+ async symbol() {
488
+ return this.contract.read.symbol();
489
+ }
490
+ /**
491
+ * allowance
492
+ * view
493
+ */
494
+ async allowance(_owner, _spender) {
495
+ return this.contract.read.allowance([_owner, _spender]);
496
+ }
497
+ /**
498
+ * approve
499
+ * nonpayable
500
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
501
+ */
502
+ async approve(_spender, _value, options) {
503
+ if (!this.contract.write) {
504
+ throw new Error('Wallet client is required for write operations');
505
+ }
506
+ return this.contract.write.approve([_spender, _value], options);
507
+ }
508
+ /**
509
+ * restrictTokenTransfer
510
+ * nonpayable
511
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
512
+ */
513
+ async restrictTokenTransfer(oldAddress, options) {
514
+ if (!this.contract.write) {
515
+ throw new Error('Wallet client is required for write operations');
516
+ }
517
+ return this.contract.write.restrictTokenTransfer([oldAddress], options);
518
+ }
519
+ /**
520
+ * transferFrom
521
+ * nonpayable
522
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
523
+ */
524
+ async transferFrom(_from, _to, _value, options) {
525
+ if (!this.contract.write) {
526
+ throw new Error('Wallet client is required for write operations');
527
+ }
528
+ return this.contract.write.transferFrom([_from, _to, _value], options);
529
+ }
530
+ /**
531
+ * decreaseApproval
532
+ * nonpayable
533
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
534
+ */
535
+ async decreaseApproval(_spender, _subtractedValue, options) {
536
+ if (!this.contract.write) {
537
+ throw new Error('Wallet client is required for write operations');
538
+ }
539
+ return this.contract.write.decreaseApproval([_spender, _subtractedValue], options);
540
+ }
541
+ /**
542
+ * allowTokenTransfer
543
+ * nonpayable
544
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
545
+ */
546
+ async allowTokenTransfer(newAddress, options) {
547
+ if (!this.contract.write) {
548
+ throw new Error('Wallet client is required for write operations');
549
+ }
550
+ return this.contract.write.allowTokenTransfer([newAddress], options);
551
+ }
552
+ /**
553
+ * transfer
554
+ * nonpayable
555
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
556
+ */
557
+ async transfer(_to, _value, options) {
558
+ if (!this.contract.write) {
559
+ throw new Error('Wallet client is required for write operations');
560
+ }
561
+ return this.contract.write.transfer([_to, _value], options);
562
+ }
563
+ /**
564
+ * disableTransfer
565
+ * nonpayable
566
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
567
+ */
568
+ async disableTransfer(options) {
569
+ if (!this.contract.write) {
570
+ throw new Error('Wallet client is required for write operations');
571
+ }
572
+ return this.contract.write.disableTransfer(options);
573
+ }
574
+ /**
575
+ * increaseApproval
576
+ * nonpayable
577
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
578
+ */
579
+ async increaseApproval(_spender, _addedValue, options) {
580
+ if (!this.contract.write) {
581
+ throw new Error('Wallet client is required for write operations');
582
+ }
583
+ return this.contract.write.increaseApproval([_spender, _addedValue], options);
584
+ }
585
+ /**
586
+ * enableTransfer
587
+ * nonpayable
588
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
589
+ */
590
+ async enableTransfer(options) {
591
+ if (!this.contract.write) {
592
+ throw new Error('Wallet client is required for write operations');
593
+ }
594
+ return this.contract.write.enableTransfer(options);
595
+ }
596
+ /**
597
+ * transferOwnership
598
+ * nonpayable
599
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
600
+ */
601
+ async transferOwnership(newOwner, options) {
602
+ if (!this.contract.write) {
603
+ throw new Error('Wallet client is required for write operations');
604
+ }
605
+ return this.contract.write.transferOwnership([newOwner], options);
606
+ }
607
+ /**
608
+ * Simulate contract write operations (dry-run without sending transaction)
609
+ *
610
+ * @example
611
+ * const result = await contract.simulate.transfer('0x...', 1000n);
612
+ * console.log('Gas estimate:', result.request.gas);
613
+ * console.log('Would succeed:', result.result);
614
+ */
615
+ get simulate() {
616
+ const contract = this.contract;
617
+ if (!contract.simulate) {
618
+ throw new Error('Public client is required for simulation');
619
+ }
620
+ return {
621
+ /**
622
+ * Simulate approve
623
+ * Returns gas estimate and result without sending transaction
624
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
625
+ */
626
+ async approve(_spender, _value, options) {
627
+ return contract.simulate.approve([_spender, _value], options);
628
+ },
629
+ /**
630
+ * Simulate restrictTokenTransfer
631
+ * Returns gas estimate and result without sending transaction
632
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
633
+ */
634
+ async restrictTokenTransfer(oldAddress, options) {
635
+ return contract.simulate.restrictTokenTransfer([oldAddress], options);
636
+ },
637
+ /**
638
+ * Simulate transferFrom
639
+ * Returns gas estimate and result without sending transaction
640
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
641
+ */
642
+ async transferFrom(_from, _to, _value, options) {
643
+ return contract.simulate.transferFrom([_from, _to, _value], options);
644
+ },
645
+ /**
646
+ * Simulate decreaseApproval
647
+ * Returns gas estimate and result without sending transaction
648
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
649
+ */
650
+ async decreaseApproval(_spender, _subtractedValue, options) {
651
+ return contract.simulate.decreaseApproval([_spender, _subtractedValue], options);
652
+ },
653
+ /**
654
+ * Simulate allowTokenTransfer
655
+ * Returns gas estimate and result without sending transaction
656
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
657
+ */
658
+ async allowTokenTransfer(newAddress, options) {
659
+ return contract.simulate.allowTokenTransfer([newAddress], options);
660
+ },
661
+ /**
662
+ * Simulate transfer
663
+ * Returns gas estimate and result without sending transaction
664
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
665
+ */
666
+ async transfer(_to, _value, options) {
667
+ return contract.simulate.transfer([_to, _value], options);
668
+ },
669
+ /**
670
+ * Simulate disableTransfer
671
+ * Returns gas estimate and result without sending transaction
672
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
673
+ */
674
+ async disableTransfer(options) {
675
+ return contract.simulate.disableTransfer(options);
676
+ },
677
+ /**
678
+ * Simulate increaseApproval
679
+ * Returns gas estimate and result without sending transaction
680
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
681
+ */
682
+ async increaseApproval(_spender, _addedValue, options) {
683
+ return contract.simulate.increaseApproval([_spender, _addedValue], options);
684
+ },
685
+ /**
686
+ * Simulate enableTransfer
687
+ * Returns gas estimate and result without sending transaction
688
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
689
+ */
690
+ async enableTransfer(options) {
691
+ return contract.simulate.enableTransfer(options);
692
+ },
693
+ /**
694
+ * Simulate transferOwnership
695
+ * Returns gas estimate and result without sending transaction
696
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
697
+ */
698
+ async transferOwnership(newOwner, options) {
699
+ return contract.simulate.transferOwnership([newOwner], options);
700
+ }
701
+ };
702
+ }
703
+ /**
704
+ * Watch contract events
705
+ *
706
+ * @example
707
+ * // Watch all Transfer events
708
+ * const unwatch = contract.watch.Transfer((event) => {
709
+ * console.log('Transfer:', event);
710
+ * });
711
+ *
712
+ * // Stop watching
713
+ * unwatch();
714
+ */
715
+ get watch() {
716
+ return {
717
+ /**
718
+ * Watch OwnershipTransferred events
719
+ * @param callback Function to call when event is emitted
720
+ * @param filter Optional filter for indexed parameters
721
+ * @returns Unwatch function to stop listening
722
+ */
723
+ OwnershipTransferred: (callback, filter) => {
724
+ return this.publicClient.watchContractEvent({
725
+ address: this.contractAddress,
726
+ abi: exports.QuadTokenAbi,
727
+ eventName: 'OwnershipTransferred',
728
+ args: filter,
729
+ onLogs: (logs) => {
730
+ logs.forEach((log) => {
731
+ callback(log.args);
732
+ });
733
+ },
734
+ });
735
+ },
736
+ /**
737
+ * Watch Approval events
738
+ * @param callback Function to call when event is emitted
739
+ * @param filter Optional filter for indexed parameters
740
+ * @returns Unwatch function to stop listening
741
+ */
742
+ Approval: (callback, filter) => {
743
+ return this.publicClient.watchContractEvent({
744
+ address: this.contractAddress,
745
+ abi: exports.QuadTokenAbi,
746
+ eventName: 'Approval',
747
+ args: filter,
748
+ onLogs: (logs) => {
749
+ logs.forEach((log) => {
750
+ callback(log.args);
751
+ });
752
+ },
753
+ });
754
+ },
755
+ /**
756
+ * Watch Transfer events
757
+ * @param callback Function to call when event is emitted
758
+ * @param filter Optional filter for indexed parameters
759
+ * @returns Unwatch function to stop listening
760
+ */
761
+ Transfer: (callback, filter) => {
762
+ return this.publicClient.watchContractEvent({
763
+ address: this.contractAddress,
764
+ abi: exports.QuadTokenAbi,
765
+ eventName: 'Transfer',
766
+ args: filter,
767
+ onLogs: (logs) => {
768
+ logs.forEach((log) => {
769
+ callback(log.args);
770
+ });
771
+ },
772
+ });
773
+ }
774
+ };
775
+ }
776
+ }
777
+ exports.QuadToken = QuadToken;