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