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