@gitmyabi-stg/dock 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,1054 @@
1
+ import type { Abi, Address, PublicClient, WalletClient, GetContractReturnType } from 'viem';
2
+ import { getContract } from 'viem';
3
+
4
+ /**
5
+ * DockToken ABI
6
+ *
7
+ * This ABI is typed using viem's type system for full type safety.
8
+ */
9
+ export const DockTokenAbi = [
10
+ {
11
+ "constant": true,
12
+ "inputs": [],
13
+ "name": "name",
14
+ "outputs": [
15
+ {
16
+ "name": "",
17
+ "type": "string"
18
+ }
19
+ ],
20
+ "payable": false,
21
+ "stateMutability": "view",
22
+ "type": "function"
23
+ },
24
+ {
25
+ "constant": false,
26
+ "inputs": [
27
+ {
28
+ "name": "_spender",
29
+ "type": "address"
30
+ },
31
+ {
32
+ "name": "_value",
33
+ "type": "uint256"
34
+ }
35
+ ],
36
+ "name": "approve",
37
+ "outputs": [
38
+ {
39
+ "name": "",
40
+ "type": "bool"
41
+ }
42
+ ],
43
+ "payable": false,
44
+ "stateMutability": "nonpayable",
45
+ "type": "function"
46
+ },
47
+ {
48
+ "constant": true,
49
+ "inputs": [],
50
+ "name": "totalSupply",
51
+ "outputs": [
52
+ {
53
+ "name": "",
54
+ "type": "uint256"
55
+ }
56
+ ],
57
+ "payable": false,
58
+ "stateMutability": "view",
59
+ "type": "function"
60
+ },
61
+ {
62
+ "constant": false,
63
+ "inputs": [
64
+ {
65
+ "name": "from",
66
+ "type": "address"
67
+ },
68
+ {
69
+ "name": "to",
70
+ "type": "address"
71
+ },
72
+ {
73
+ "name": "value",
74
+ "type": "uint256"
75
+ }
76
+ ],
77
+ "name": "transferFrom",
78
+ "outputs": [
79
+ {
80
+ "name": "",
81
+ "type": "bool"
82
+ }
83
+ ],
84
+ "payable": false,
85
+ "stateMutability": "nonpayable",
86
+ "type": "function"
87
+ },
88
+ {
89
+ "constant": true,
90
+ "inputs": [],
91
+ "name": "INITIAL_SUPPLY",
92
+ "outputs": [
93
+ {
94
+ "name": "",
95
+ "type": "uint256"
96
+ }
97
+ ],
98
+ "payable": false,
99
+ "stateMutability": "view",
100
+ "type": "function"
101
+ },
102
+ {
103
+ "constant": true,
104
+ "inputs": [],
105
+ "name": "decimals",
106
+ "outputs": [
107
+ {
108
+ "name": "",
109
+ "type": "uint8"
110
+ }
111
+ ],
112
+ "payable": false,
113
+ "stateMutability": "view",
114
+ "type": "function"
115
+ },
116
+ {
117
+ "constant": true,
118
+ "inputs": [],
119
+ "name": "transferEnabled",
120
+ "outputs": [
121
+ {
122
+ "name": "",
123
+ "type": "bool"
124
+ }
125
+ ],
126
+ "payable": false,
127
+ "stateMutability": "view",
128
+ "type": "function"
129
+ },
130
+ {
131
+ "constant": true,
132
+ "inputs": [],
133
+ "name": "tokenOfferingAddr",
134
+ "outputs": [
135
+ {
136
+ "name": "",
137
+ "type": "address"
138
+ }
139
+ ],
140
+ "payable": false,
141
+ "stateMutability": "view",
142
+ "type": "function"
143
+ },
144
+ {
145
+ "constant": false,
146
+ "inputs": [
147
+ {
148
+ "name": "_spender",
149
+ "type": "address"
150
+ },
151
+ {
152
+ "name": "_subtractedValue",
153
+ "type": "uint256"
154
+ }
155
+ ],
156
+ "name": "decreaseApproval",
157
+ "outputs": [
158
+ {
159
+ "name": "",
160
+ "type": "bool"
161
+ }
162
+ ],
163
+ "payable": false,
164
+ "stateMutability": "nonpayable",
165
+ "type": "function"
166
+ },
167
+ {
168
+ "constant": true,
169
+ "inputs": [
170
+ {
171
+ "name": "_owner",
172
+ "type": "address"
173
+ }
174
+ ],
175
+ "name": "balanceOf",
176
+ "outputs": [
177
+ {
178
+ "name": "balance",
179
+ "type": "uint256"
180
+ }
181
+ ],
182
+ "payable": false,
183
+ "stateMutability": "view",
184
+ "type": "function"
185
+ },
186
+ {
187
+ "constant": false,
188
+ "inputs": [
189
+ {
190
+ "name": "offeringAddr",
191
+ "type": "address"
192
+ },
193
+ {
194
+ "name": "amountForSale",
195
+ "type": "uint256"
196
+ }
197
+ ],
198
+ "name": "setTokenOffering",
199
+ "outputs": [],
200
+ "payable": false,
201
+ "stateMutability": "nonpayable",
202
+ "type": "function"
203
+ },
204
+ {
205
+ "constant": true,
206
+ "inputs": [],
207
+ "name": "adminAddr",
208
+ "outputs": [
209
+ {
210
+ "name": "",
211
+ "type": "address"
212
+ }
213
+ ],
214
+ "payable": false,
215
+ "stateMutability": "view",
216
+ "type": "function"
217
+ },
218
+ {
219
+ "constant": true,
220
+ "inputs": [],
221
+ "name": "owner",
222
+ "outputs": [
223
+ {
224
+ "name": "",
225
+ "type": "address"
226
+ }
227
+ ],
228
+ "payable": false,
229
+ "stateMutability": "view",
230
+ "type": "function"
231
+ },
232
+ {
233
+ "constant": true,
234
+ "inputs": [],
235
+ "name": "symbol",
236
+ "outputs": [
237
+ {
238
+ "name": "",
239
+ "type": "string"
240
+ }
241
+ ],
242
+ "payable": false,
243
+ "stateMutability": "view",
244
+ "type": "function"
245
+ },
246
+ {
247
+ "constant": false,
248
+ "inputs": [
249
+ {
250
+ "name": "to",
251
+ "type": "address"
252
+ },
253
+ {
254
+ "name": "value",
255
+ "type": "uint256"
256
+ }
257
+ ],
258
+ "name": "transfer",
259
+ "outputs": [
260
+ {
261
+ "name": "",
262
+ "type": "bool"
263
+ }
264
+ ],
265
+ "payable": false,
266
+ "stateMutability": "nonpayable",
267
+ "type": "function"
268
+ },
269
+ {
270
+ "constant": false,
271
+ "inputs": [
272
+ {
273
+ "name": "_spender",
274
+ "type": "address"
275
+ },
276
+ {
277
+ "name": "_addedValue",
278
+ "type": "uint256"
279
+ }
280
+ ],
281
+ "name": "increaseApproval",
282
+ "outputs": [
283
+ {
284
+ "name": "",
285
+ "type": "bool"
286
+ }
287
+ ],
288
+ "payable": false,
289
+ "stateMutability": "nonpayable",
290
+ "type": "function"
291
+ },
292
+ {
293
+ "constant": true,
294
+ "inputs": [
295
+ {
296
+ "name": "_owner",
297
+ "type": "address"
298
+ },
299
+ {
300
+ "name": "_spender",
301
+ "type": "address"
302
+ }
303
+ ],
304
+ "name": "allowance",
305
+ "outputs": [
306
+ {
307
+ "name": "",
308
+ "type": "uint256"
309
+ }
310
+ ],
311
+ "payable": false,
312
+ "stateMutability": "view",
313
+ "type": "function"
314
+ },
315
+ {
316
+ "constant": true,
317
+ "inputs": [],
318
+ "name": "TOKEN_OFFERING_ALLOWANCE",
319
+ "outputs": [
320
+ {
321
+ "name": "",
322
+ "type": "uint256"
323
+ }
324
+ ],
325
+ "payable": false,
326
+ "stateMutability": "view",
327
+ "type": "function"
328
+ },
329
+ {
330
+ "constant": false,
331
+ "inputs": [],
332
+ "name": "enableTransfer",
333
+ "outputs": [],
334
+ "payable": false,
335
+ "stateMutability": "nonpayable",
336
+ "type": "function"
337
+ },
338
+ {
339
+ "constant": false,
340
+ "inputs": [
341
+ {
342
+ "name": "newOwner",
343
+ "type": "address"
344
+ }
345
+ ],
346
+ "name": "transferOwnership",
347
+ "outputs": [],
348
+ "payable": false,
349
+ "stateMutability": "nonpayable",
350
+ "type": "function"
351
+ },
352
+ {
353
+ "constant": true,
354
+ "inputs": [],
355
+ "name": "ADMIN_ALLOWANCE",
356
+ "outputs": [
357
+ {
358
+ "name": "",
359
+ "type": "uint256"
360
+ }
361
+ ],
362
+ "payable": false,
363
+ "stateMutability": "view",
364
+ "type": "function"
365
+ },
366
+ {
367
+ "inputs": [
368
+ {
369
+ "name": "admin",
370
+ "type": "address"
371
+ }
372
+ ],
373
+ "payable": false,
374
+ "stateMutability": "nonpayable",
375
+ "type": "constructor"
376
+ },
377
+ {
378
+ "anonymous": false,
379
+ "inputs": [
380
+ {
381
+ "indexed": true,
382
+ "name": "previousOwner",
383
+ "type": "address"
384
+ },
385
+ {
386
+ "indexed": true,
387
+ "name": "newOwner",
388
+ "type": "address"
389
+ }
390
+ ],
391
+ "name": "OwnershipTransferred",
392
+ "type": "event"
393
+ },
394
+ {
395
+ "anonymous": false,
396
+ "inputs": [
397
+ {
398
+ "indexed": true,
399
+ "name": "owner",
400
+ "type": "address"
401
+ },
402
+ {
403
+ "indexed": true,
404
+ "name": "spender",
405
+ "type": "address"
406
+ },
407
+ {
408
+ "indexed": false,
409
+ "name": "value",
410
+ "type": "uint256"
411
+ }
412
+ ],
413
+ "name": "Approval",
414
+ "type": "event"
415
+ },
416
+ {
417
+ "anonymous": false,
418
+ "inputs": [
419
+ {
420
+ "indexed": true,
421
+ "name": "from",
422
+ "type": "address"
423
+ },
424
+ {
425
+ "indexed": true,
426
+ "name": "to",
427
+ "type": "address"
428
+ },
429
+ {
430
+ "indexed": false,
431
+ "name": "value",
432
+ "type": "uint256"
433
+ }
434
+ ],
435
+ "name": "Transfer",
436
+ "type": "event"
437
+ }
438
+ ] as const satisfies Abi;
439
+
440
+ /**
441
+ * Type-safe ABI for DockToken
442
+ */
443
+ export type DockTokenAbi = typeof DockTokenAbi;
444
+
445
+ /**
446
+ * Contract instance type for DockToken
447
+ */
448
+ // Use any for contract type to avoid complex viem type issues
449
+ // The runtime behavior is type-safe through viem's ABI typing
450
+ export type DockTokenContract = any;
451
+
452
+ /**
453
+ * DockToken Contract Class
454
+ *
455
+ * Provides a class-based API similar to TypeChain for interacting with the contract.
456
+ *
457
+ * @example
458
+ * ```typescript
459
+ * import { createPublicClient, createWalletClient, http } from 'viem';
460
+ * import { mainnet } from 'viem/chains';
461
+ * import { DockToken } from 'DockToken';
462
+ *
463
+ * const publicClient = createPublicClient({ chain: mainnet, transport: http() });
464
+ * const walletClient = createWalletClient({ chain: mainnet, transport: http() });
465
+ *
466
+ * const contract = new DockToken('0x...', { publicClient, walletClient });
467
+ *
468
+ * // Read functions
469
+ * const result = await contract.balanceOf('0x...');
470
+ *
471
+ * // Write functions
472
+ * const hash = await contract.transfer('0x...', 1000n);
473
+ *
474
+ * // Simulate transactions (dry-run)
475
+ * const simulation = await contract.simulate.transfer('0x...', 1000n);
476
+ * console.log('Gas estimate:', simulation.request.gas);
477
+ *
478
+ * // Watch events
479
+ * const unwatch = contract.watch.Transfer((event) => {
480
+ * console.log('Transfer event:', event);
481
+ * });
482
+ * ```
483
+ */
484
+ export class DockToken {
485
+ private contract: DockTokenContract;
486
+ private contractAddress: Address;
487
+ private publicClient: PublicClient;
488
+
489
+ constructor(
490
+ address: Address,
491
+ clients: {
492
+ publicClient: PublicClient;
493
+ walletClient?: WalletClient;
494
+ }
495
+ ) {
496
+ this.contractAddress = address;
497
+ this.publicClient = clients.publicClient;
498
+ this.contract = getContract({
499
+ address,
500
+ abi: DockTokenAbi,
501
+ client: {
502
+ public: clients.publicClient,
503
+ wallet: clients.walletClient,
504
+ },
505
+ });
506
+ }
507
+
508
+ /**
509
+ * Get the contract address
510
+ */
511
+ get address(): Address {
512
+ return this.contractAddress;
513
+ }
514
+
515
+ /**
516
+ * Get the underlying viem contract instance.
517
+ */
518
+ getContract(): DockTokenContract {
519
+ return this.contract;
520
+ }
521
+
522
+ /**
523
+ * name
524
+ * view
525
+ */
526
+ async name(): Promise<string> {
527
+ return this.contract.read.name() as Promise<string>;
528
+ }
529
+
530
+ /**
531
+ * totalSupply
532
+ * view
533
+ */
534
+ async totalSupply(): Promise<bigint> {
535
+ return this.contract.read.totalSupply() as Promise<bigint>;
536
+ }
537
+
538
+ /**
539
+ * INITIAL_SUPPLY
540
+ * view
541
+ */
542
+ async INITIAL_SUPPLY(): Promise<bigint> {
543
+ return this.contract.read.INITIAL_SUPPLY() as Promise<bigint>;
544
+ }
545
+
546
+ /**
547
+ * decimals
548
+ * view
549
+ */
550
+ async decimals(): Promise<bigint> {
551
+ return this.contract.read.decimals() as Promise<bigint>;
552
+ }
553
+
554
+ /**
555
+ * transferEnabled
556
+ * view
557
+ */
558
+ async transferEnabled(): Promise<boolean> {
559
+ return this.contract.read.transferEnabled() as Promise<boolean>;
560
+ }
561
+
562
+ /**
563
+ * tokenOfferingAddr
564
+ * view
565
+ */
566
+ async tokenOfferingAddr(): Promise<`0x${string}`> {
567
+ return this.contract.read.tokenOfferingAddr() as Promise<`0x${string}`>;
568
+ }
569
+
570
+ /**
571
+ * balanceOf
572
+ * view
573
+ */
574
+ async balanceOf(_owner: `0x${string}`): Promise<bigint> {
575
+ return this.contract.read.balanceOf([_owner] as const) as Promise<bigint>;
576
+ }
577
+
578
+ /**
579
+ * adminAddr
580
+ * view
581
+ */
582
+ async adminAddr(): Promise<`0x${string}`> {
583
+ return this.contract.read.adminAddr() as Promise<`0x${string}`>;
584
+ }
585
+
586
+ /**
587
+ * owner
588
+ * view
589
+ */
590
+ async owner(): Promise<`0x${string}`> {
591
+ return this.contract.read.owner() as Promise<`0x${string}`>;
592
+ }
593
+
594
+ /**
595
+ * symbol
596
+ * view
597
+ */
598
+ async symbol(): Promise<string> {
599
+ return this.contract.read.symbol() as Promise<string>;
600
+ }
601
+
602
+ /**
603
+ * allowance
604
+ * view
605
+ */
606
+ async allowance(_owner: `0x${string}`, _spender: `0x${string}`): Promise<bigint> {
607
+ return this.contract.read.allowance([_owner, _spender] as const) as Promise<bigint>;
608
+ }
609
+
610
+ /**
611
+ * TOKEN_OFFERING_ALLOWANCE
612
+ * view
613
+ */
614
+ async TOKEN_OFFERING_ALLOWANCE(): Promise<bigint> {
615
+ return this.contract.read.TOKEN_OFFERING_ALLOWANCE() as Promise<bigint>;
616
+ }
617
+
618
+ /**
619
+ * ADMIN_ALLOWANCE
620
+ * view
621
+ */
622
+ async ADMIN_ALLOWANCE(): Promise<bigint> {
623
+ return this.contract.read.ADMIN_ALLOWANCE() as Promise<bigint>;
624
+ }
625
+
626
+ /**
627
+ * approve
628
+ * nonpayable
629
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
630
+ */
631
+ async approve(_spender: `0x${string}`, _value: bigint, options?: {
632
+ accessList?: import('viem').AccessList;
633
+ authorizationList?: import('viem').AuthorizationList;
634
+ chain?: import('viem').Chain | null;
635
+ dataSuffix?: `0x${string}`;
636
+ gas?: bigint;
637
+ gasPrice?: bigint;
638
+ maxFeePerGas?: bigint;
639
+ maxPriorityFeePerGas?: bigint;
640
+ nonce?: number;
641
+ value?: bigint;
642
+ }): Promise<`0x${string}`> {
643
+ if (!this.contract.write) {
644
+ throw new Error('Wallet client is required for write operations');
645
+ }
646
+ return this.contract.write.approve([_spender, _value] as const, options) as Promise<`0x${string}`>;
647
+ }
648
+
649
+ /**
650
+ * transferFrom
651
+ * nonpayable
652
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
653
+ */
654
+ async transferFrom(from: `0x${string}`, to: `0x${string}`, value: bigint, options?: {
655
+ accessList?: import('viem').AccessList;
656
+ authorizationList?: import('viem').AuthorizationList;
657
+ chain?: import('viem').Chain | null;
658
+ dataSuffix?: `0x${string}`;
659
+ gas?: bigint;
660
+ gasPrice?: bigint;
661
+ maxFeePerGas?: bigint;
662
+ maxPriorityFeePerGas?: bigint;
663
+ nonce?: number;
664
+ value?: bigint;
665
+ }): Promise<`0x${string}`> {
666
+ if (!this.contract.write) {
667
+ throw new Error('Wallet client is required for write operations');
668
+ }
669
+ return this.contract.write.transferFrom([from, to, value] as const, options) as Promise<`0x${string}`>;
670
+ }
671
+
672
+ /**
673
+ * decreaseApproval
674
+ * nonpayable
675
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
676
+ */
677
+ async decreaseApproval(_spender: `0x${string}`, _subtractedValue: bigint, options?: {
678
+ accessList?: import('viem').AccessList;
679
+ authorizationList?: import('viem').AuthorizationList;
680
+ chain?: import('viem').Chain | null;
681
+ dataSuffix?: `0x${string}`;
682
+ gas?: bigint;
683
+ gasPrice?: bigint;
684
+ maxFeePerGas?: bigint;
685
+ maxPriorityFeePerGas?: bigint;
686
+ nonce?: number;
687
+ value?: bigint;
688
+ }): Promise<`0x${string}`> {
689
+ if (!this.contract.write) {
690
+ throw new Error('Wallet client is required for write operations');
691
+ }
692
+ return this.contract.write.decreaseApproval([_spender, _subtractedValue] as const, options) as Promise<`0x${string}`>;
693
+ }
694
+
695
+ /**
696
+ * setTokenOffering
697
+ * nonpayable
698
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
699
+ */
700
+ async setTokenOffering(offeringAddr: `0x${string}`, amountForSale: bigint, options?: {
701
+ accessList?: import('viem').AccessList;
702
+ authorizationList?: import('viem').AuthorizationList;
703
+ chain?: import('viem').Chain | null;
704
+ dataSuffix?: `0x${string}`;
705
+ gas?: bigint;
706
+ gasPrice?: bigint;
707
+ maxFeePerGas?: bigint;
708
+ maxPriorityFeePerGas?: bigint;
709
+ nonce?: number;
710
+ value?: bigint;
711
+ }): Promise<`0x${string}`> {
712
+ if (!this.contract.write) {
713
+ throw new Error('Wallet client is required for write operations');
714
+ }
715
+ return this.contract.write.setTokenOffering([offeringAddr, amountForSale] as const, options) as Promise<`0x${string}`>;
716
+ }
717
+
718
+ /**
719
+ * transfer
720
+ * nonpayable
721
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
722
+ */
723
+ async transfer(to: `0x${string}`, value: bigint, options?: {
724
+ accessList?: import('viem').AccessList;
725
+ authorizationList?: import('viem').AuthorizationList;
726
+ chain?: import('viem').Chain | null;
727
+ dataSuffix?: `0x${string}`;
728
+ gas?: bigint;
729
+ gasPrice?: bigint;
730
+ maxFeePerGas?: bigint;
731
+ maxPriorityFeePerGas?: bigint;
732
+ nonce?: number;
733
+ value?: bigint;
734
+ }): Promise<`0x${string}`> {
735
+ if (!this.contract.write) {
736
+ throw new Error('Wallet client is required for write operations');
737
+ }
738
+ return this.contract.write.transfer([to, value] as const, options) as Promise<`0x${string}`>;
739
+ }
740
+
741
+ /**
742
+ * increaseApproval
743
+ * nonpayable
744
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
745
+ */
746
+ async increaseApproval(_spender: `0x${string}`, _addedValue: bigint, options?: {
747
+ accessList?: import('viem').AccessList;
748
+ authorizationList?: import('viem').AuthorizationList;
749
+ chain?: import('viem').Chain | null;
750
+ dataSuffix?: `0x${string}`;
751
+ gas?: bigint;
752
+ gasPrice?: bigint;
753
+ maxFeePerGas?: bigint;
754
+ maxPriorityFeePerGas?: bigint;
755
+ nonce?: number;
756
+ value?: bigint;
757
+ }): Promise<`0x${string}`> {
758
+ if (!this.contract.write) {
759
+ throw new Error('Wallet client is required for write operations');
760
+ }
761
+ return this.contract.write.increaseApproval([_spender, _addedValue] as const, options) as Promise<`0x${string}`>;
762
+ }
763
+
764
+ /**
765
+ * enableTransfer
766
+ * nonpayable
767
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
768
+ */
769
+ async enableTransfer(options?: {
770
+ accessList?: import('viem').AccessList;
771
+ authorizationList?: import('viem').AuthorizationList;
772
+ chain?: import('viem').Chain | null;
773
+ dataSuffix?: `0x${string}`;
774
+ gas?: bigint;
775
+ gasPrice?: bigint;
776
+ maxFeePerGas?: bigint;
777
+ maxPriorityFeePerGas?: bigint;
778
+ nonce?: number;
779
+ value?: bigint;
780
+ }): Promise<`0x${string}`> {
781
+ if (!this.contract.write) {
782
+ throw new Error('Wallet client is required for write operations');
783
+ }
784
+ return this.contract.write.enableTransfer(options) as Promise<`0x${string}`>;
785
+ }
786
+
787
+ /**
788
+ * transferOwnership
789
+ * nonpayable
790
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
791
+ */
792
+ async transferOwnership(newOwner: `0x${string}`, options?: {
793
+ accessList?: import('viem').AccessList;
794
+ authorizationList?: import('viem').AuthorizationList;
795
+ chain?: import('viem').Chain | null;
796
+ dataSuffix?: `0x${string}`;
797
+ gas?: bigint;
798
+ gasPrice?: bigint;
799
+ maxFeePerGas?: bigint;
800
+ maxPriorityFeePerGas?: bigint;
801
+ nonce?: number;
802
+ value?: bigint;
803
+ }): Promise<`0x${string}`> {
804
+ if (!this.contract.write) {
805
+ throw new Error('Wallet client is required for write operations');
806
+ }
807
+ return this.contract.write.transferOwnership([newOwner] as const, options) as Promise<`0x${string}`>;
808
+ }
809
+
810
+
811
+
812
+ /**
813
+ * Simulate contract write operations (dry-run without sending transaction)
814
+ *
815
+ * @example
816
+ * const result = await contract.simulate.transfer('0x...', 1000n);
817
+ * console.log('Gas estimate:', result.request.gas);
818
+ * console.log('Would succeed:', result.result);
819
+ */
820
+ get simulate() {
821
+ const contract = this.contract;
822
+ if (!contract.simulate) {
823
+ throw new Error('Public client is required for simulation');
824
+ }
825
+ return {
826
+ /**
827
+ * Simulate approve
828
+ * Returns gas estimate and result without sending transaction
829
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
830
+ */
831
+ async approve(_spender: `0x${string}`, _value: bigint, options?: {
832
+ accessList?: import('viem').AccessList;
833
+ authorizationList?: import('viem').AuthorizationList;
834
+ chain?: import('viem').Chain | null;
835
+ dataSuffix?: `0x${string}`;
836
+ gas?: bigint;
837
+ gasPrice?: bigint;
838
+ maxFeePerGas?: bigint;
839
+ maxPriorityFeePerGas?: bigint;
840
+ nonce?: number;
841
+ value?: bigint;
842
+ }): Promise<boolean> {
843
+ return contract.simulate.approve([_spender, _value] as const, options) as Promise<boolean>;
844
+ },
845
+ /**
846
+ * Simulate transferFrom
847
+ * Returns gas estimate and result without sending transaction
848
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
849
+ */
850
+ async transferFrom(from: `0x${string}`, to: `0x${string}`, value: bigint, options?: {
851
+ accessList?: import('viem').AccessList;
852
+ authorizationList?: import('viem').AuthorizationList;
853
+ chain?: import('viem').Chain | null;
854
+ dataSuffix?: `0x${string}`;
855
+ gas?: bigint;
856
+ gasPrice?: bigint;
857
+ maxFeePerGas?: bigint;
858
+ maxPriorityFeePerGas?: bigint;
859
+ nonce?: number;
860
+ value?: bigint;
861
+ }): Promise<boolean> {
862
+ return contract.simulate.transferFrom([from, to, value] as const, options) as Promise<boolean>;
863
+ },
864
+ /**
865
+ * Simulate decreaseApproval
866
+ * Returns gas estimate and result without sending transaction
867
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
868
+ */
869
+ async decreaseApproval(_spender: `0x${string}`, _subtractedValue: bigint, options?: {
870
+ accessList?: import('viem').AccessList;
871
+ authorizationList?: import('viem').AuthorizationList;
872
+ chain?: import('viem').Chain | null;
873
+ dataSuffix?: `0x${string}`;
874
+ gas?: bigint;
875
+ gasPrice?: bigint;
876
+ maxFeePerGas?: bigint;
877
+ maxPriorityFeePerGas?: bigint;
878
+ nonce?: number;
879
+ value?: bigint;
880
+ }): Promise<boolean> {
881
+ return contract.simulate.decreaseApproval([_spender, _subtractedValue] as const, options) as Promise<boolean>;
882
+ },
883
+ /**
884
+ * Simulate setTokenOffering
885
+ * Returns gas estimate and result without sending transaction
886
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
887
+ */
888
+ async setTokenOffering(offeringAddr: `0x${string}`, amountForSale: bigint, options?: {
889
+ accessList?: import('viem').AccessList;
890
+ authorizationList?: import('viem').AuthorizationList;
891
+ chain?: import('viem').Chain | null;
892
+ dataSuffix?: `0x${string}`;
893
+ gas?: bigint;
894
+ gasPrice?: bigint;
895
+ maxFeePerGas?: bigint;
896
+ maxPriorityFeePerGas?: bigint;
897
+ nonce?: number;
898
+ value?: bigint;
899
+ }): Promise<void> {
900
+ return contract.simulate.setTokenOffering([offeringAddr, amountForSale] as const, options) as Promise<void>;
901
+ },
902
+ /**
903
+ * Simulate transfer
904
+ * Returns gas estimate and result without sending transaction
905
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
906
+ */
907
+ async transfer(to: `0x${string}`, value: bigint, options?: {
908
+ accessList?: import('viem').AccessList;
909
+ authorizationList?: import('viem').AuthorizationList;
910
+ chain?: import('viem').Chain | null;
911
+ dataSuffix?: `0x${string}`;
912
+ gas?: bigint;
913
+ gasPrice?: bigint;
914
+ maxFeePerGas?: bigint;
915
+ maxPriorityFeePerGas?: bigint;
916
+ nonce?: number;
917
+ value?: bigint;
918
+ }): Promise<boolean> {
919
+ return contract.simulate.transfer([to, value] as const, options) as Promise<boolean>;
920
+ },
921
+ /**
922
+ * Simulate increaseApproval
923
+ * Returns gas estimate and result without sending transaction
924
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
925
+ */
926
+ async increaseApproval(_spender: `0x${string}`, _addedValue: bigint, options?: {
927
+ accessList?: import('viem').AccessList;
928
+ authorizationList?: import('viem').AuthorizationList;
929
+ chain?: import('viem').Chain | null;
930
+ dataSuffix?: `0x${string}`;
931
+ gas?: bigint;
932
+ gasPrice?: bigint;
933
+ maxFeePerGas?: bigint;
934
+ maxPriorityFeePerGas?: bigint;
935
+ nonce?: number;
936
+ value?: bigint;
937
+ }): Promise<boolean> {
938
+ return contract.simulate.increaseApproval([_spender, _addedValue] as const, options) as Promise<boolean>;
939
+ },
940
+ /**
941
+ * Simulate enableTransfer
942
+ * Returns gas estimate and result without sending transaction
943
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
944
+ */
945
+ async enableTransfer(options?: {
946
+ accessList?: import('viem').AccessList;
947
+ authorizationList?: import('viem').AuthorizationList;
948
+ chain?: import('viem').Chain | null;
949
+ dataSuffix?: `0x${string}`;
950
+ gas?: bigint;
951
+ gasPrice?: bigint;
952
+ maxFeePerGas?: bigint;
953
+ maxPriorityFeePerGas?: bigint;
954
+ nonce?: number;
955
+ value?: bigint;
956
+ }): Promise<void> {
957
+ return contract.simulate.enableTransfer(options) as Promise<void>;
958
+ },
959
+ /**
960
+ * Simulate transferOwnership
961
+ * Returns gas estimate and result without sending transaction
962
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
963
+ */
964
+ async transferOwnership(newOwner: `0x${string}`, options?: {
965
+ accessList?: import('viem').AccessList;
966
+ authorizationList?: import('viem').AuthorizationList;
967
+ chain?: import('viem').Chain | null;
968
+ dataSuffix?: `0x${string}`;
969
+ gas?: bigint;
970
+ gasPrice?: bigint;
971
+ maxFeePerGas?: bigint;
972
+ maxPriorityFeePerGas?: bigint;
973
+ nonce?: number;
974
+ value?: bigint;
975
+ }): Promise<void> {
976
+ return contract.simulate.transferOwnership([newOwner] as const, options) as Promise<void>;
977
+ }
978
+ };
979
+ }
980
+
981
+ /**
982
+ * Watch contract events
983
+ *
984
+ * @example
985
+ * // Watch all Transfer events
986
+ * const unwatch = contract.watch.Transfer((event) => {
987
+ * console.log('Transfer:', event);
988
+ * });
989
+ *
990
+ * // Stop watching
991
+ * unwatch();
992
+ */
993
+ get watch() {
994
+ return {
995
+ /**
996
+ * Watch OwnershipTransferred events
997
+ * @param callback Function to call when event is emitted
998
+ * @param filter Optional filter for indexed parameters
999
+ * @returns Unwatch function to stop listening
1000
+ */
1001
+ OwnershipTransferred: (callback: (event: { previousOwner: `0x${string}`; newOwner: `0x${string}` }) => void, filter?: { previousOwner?: `0x${string}` | `0x${string}`[] | null; newOwner?: `0x${string}` | `0x${string}`[] | null }) => {
1002
+ return this.publicClient.watchContractEvent({
1003
+ address: this.contractAddress,
1004
+ abi: DockTokenAbi,
1005
+ eventName: 'OwnershipTransferred',
1006
+ args: filter as any,
1007
+ onLogs: (logs: any[]) => {
1008
+ logs.forEach((log: any) => {
1009
+ callback(log.args as any);
1010
+ });
1011
+ },
1012
+ }) as () => void;
1013
+ },
1014
+ /**
1015
+ * Watch Approval events
1016
+ * @param callback Function to call when event is emitted
1017
+ * @param filter Optional filter for indexed parameters
1018
+ * @returns Unwatch function to stop listening
1019
+ */
1020
+ Approval: (callback: (event: { owner: `0x${string}`; spender: `0x${string}`; value: bigint }) => void, filter?: { owner?: `0x${string}` | `0x${string}`[] | null; spender?: `0x${string}` | `0x${string}`[] | null }) => {
1021
+ return this.publicClient.watchContractEvent({
1022
+ address: this.contractAddress,
1023
+ abi: DockTokenAbi,
1024
+ eventName: 'Approval',
1025
+ args: filter as any,
1026
+ onLogs: (logs: any[]) => {
1027
+ logs.forEach((log: any) => {
1028
+ callback(log.args as any);
1029
+ });
1030
+ },
1031
+ }) as () => void;
1032
+ },
1033
+ /**
1034
+ * Watch Transfer events
1035
+ * @param callback Function to call when event is emitted
1036
+ * @param filter Optional filter for indexed parameters
1037
+ * @returns Unwatch function to stop listening
1038
+ */
1039
+ Transfer: (callback: (event: { from: `0x${string}`; to: `0x${string}`; value: bigint }) => void, filter?: { from?: `0x${string}` | `0x${string}`[] | null; to?: `0x${string}` | `0x${string}`[] | null }) => {
1040
+ return this.publicClient.watchContractEvent({
1041
+ address: this.contractAddress,
1042
+ abi: DockTokenAbi,
1043
+ eventName: 'Transfer',
1044
+ args: filter as any,
1045
+ onLogs: (logs: any[]) => {
1046
+ logs.forEach((log: any) => {
1047
+ callback(log.args as any);
1048
+ });
1049
+ },
1050
+ }) as () => void;
1051
+ }
1052
+ };
1053
+ }
1054
+ }