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