@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,580 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.B26_json = exports.B26_jsonAbi = void 0;
4
+ const viem_1 = require("viem");
5
+ /**
6
+ * B26_json ABI
7
+ *
8
+ * This ABI is typed using viem's type system for full type safety.
9
+ */
10
+ exports.B26_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": "tokenOwner",
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": "tokens",
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": "tokens",
79
+ "type": "uint256"
80
+ }
81
+ ],
82
+ "name": "Transfer",
83
+ "type": "event"
84
+ },
85
+ {
86
+ "inputs": [
87
+ {
88
+ "internalType": "address",
89
+ "name": "_tokenOwner",
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": "_tokens",
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": "_tokenOwner",
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": "uint256",
158
+ "name": "",
159
+ "type": "uint256"
160
+ }
161
+ ],
162
+ "stateMutability": "view",
163
+ "type": "function"
164
+ },
165
+ {
166
+ "inputs": [],
167
+ "name": "isOwner",
168
+ "outputs": [
169
+ {
170
+ "internalType": "bool",
171
+ "name": "",
172
+ "type": "bool"
173
+ }
174
+ ],
175
+ "stateMutability": "view",
176
+ "type": "function"
177
+ },
178
+ {
179
+ "inputs": [],
180
+ "name": "name",
181
+ "outputs": [
182
+ {
183
+ "internalType": "string",
184
+ "name": "",
185
+ "type": "string"
186
+ }
187
+ ],
188
+ "stateMutability": "view",
189
+ "type": "function"
190
+ },
191
+ {
192
+ "inputs": [],
193
+ "name": "owner",
194
+ "outputs": [
195
+ {
196
+ "internalType": "address",
197
+ "name": "",
198
+ "type": "address"
199
+ }
200
+ ],
201
+ "stateMutability": "view",
202
+ "type": "function"
203
+ },
204
+ {
205
+ "inputs": [],
206
+ "name": "symbol",
207
+ "outputs": [
208
+ {
209
+ "internalType": "string",
210
+ "name": "",
211
+ "type": "string"
212
+ }
213
+ ],
214
+ "stateMutability": "view",
215
+ "type": "function"
216
+ },
217
+ {
218
+ "inputs": [],
219
+ "name": "totalSupply",
220
+ "outputs": [
221
+ {
222
+ "internalType": "uint256",
223
+ "name": "",
224
+ "type": "uint256"
225
+ }
226
+ ],
227
+ "stateMutability": "view",
228
+ "type": "function"
229
+ },
230
+ {
231
+ "inputs": [
232
+ {
233
+ "internalType": "address",
234
+ "name": "_to",
235
+ "type": "address"
236
+ },
237
+ {
238
+ "internalType": "uint256",
239
+ "name": "_tokens",
240
+ "type": "uint256"
241
+ }
242
+ ],
243
+ "name": "transfer",
244
+ "outputs": [
245
+ {
246
+ "internalType": "bool",
247
+ "name": "",
248
+ "type": "bool"
249
+ }
250
+ ],
251
+ "stateMutability": "nonpayable",
252
+ "type": "function"
253
+ },
254
+ {
255
+ "inputs": [
256
+ {
257
+ "internalType": "address",
258
+ "name": "_from",
259
+ "type": "address"
260
+ },
261
+ {
262
+ "internalType": "address",
263
+ "name": "_to",
264
+ "type": "address"
265
+ },
266
+ {
267
+ "internalType": "uint256",
268
+ "name": "_tokens",
269
+ "type": "uint256"
270
+ }
271
+ ],
272
+ "name": "transferFrom",
273
+ "outputs": [
274
+ {
275
+ "internalType": "bool",
276
+ "name": "",
277
+ "type": "bool"
278
+ }
279
+ ],
280
+ "stateMutability": "nonpayable",
281
+ "type": "function"
282
+ },
283
+ {
284
+ "inputs": [
285
+ {
286
+ "internalType": "address",
287
+ "name": "_newOwner",
288
+ "type": "address"
289
+ }
290
+ ],
291
+ "name": "transferOwnership",
292
+ "outputs": [],
293
+ "stateMutability": "nonpayable",
294
+ "type": "function"
295
+ },
296
+ {
297
+ "stateMutability": "payable",
298
+ "type": "receive"
299
+ }
300
+ ];
301
+ /**
302
+ * B26_json Contract Class
303
+ *
304
+ * Provides a class-based API similar to TypeChain for interacting with the contract.
305
+ *
306
+ * @example
307
+ * ```typescript
308
+ * import { createPublicClient, createWalletClient, http } from 'viem';
309
+ * import { mainnet } from 'viem/chains';
310
+ * import { B26_json } from 'B26_json';
311
+ *
312
+ * const publicClient = createPublicClient({ chain: mainnet, transport: http() });
313
+ * const walletClient = createWalletClient({ chain: mainnet, transport: http() });
314
+ *
315
+ * const contract = new B26_json('0x...', { publicClient, walletClient });
316
+ *
317
+ * // Read functions
318
+ * const result = await contract.balanceOf('0x...');
319
+ *
320
+ * // Write functions
321
+ * const hash = await contract.transfer('0x...', 1000n);
322
+ *
323
+ * // Simulate transactions (dry-run)
324
+ * const simulation = await contract.simulate.transfer('0x...', 1000n);
325
+ * console.log('Gas estimate:', simulation.request.gas);
326
+ *
327
+ * // Watch events
328
+ * const unwatch = contract.watch.Transfer((event) => {
329
+ * console.log('Transfer event:', event);
330
+ * });
331
+ * ```
332
+ */
333
+ class B26_json {
334
+ constructor(address, clients) {
335
+ this.contractAddress = address;
336
+ this.publicClient = clients.publicClient;
337
+ this.contract = (0, viem_1.getContract)({
338
+ address,
339
+ abi: exports.B26_jsonAbi,
340
+ client: {
341
+ public: clients.publicClient,
342
+ wallet: clients.walletClient,
343
+ },
344
+ });
345
+ }
346
+ /**
347
+ * Get the contract address
348
+ */
349
+ get address() {
350
+ return this.contractAddress;
351
+ }
352
+ /**
353
+ * Get the underlying viem contract instance
354
+ */
355
+ getContract() {
356
+ return this.contract;
357
+ }
358
+ /**
359
+ * allowance
360
+ * view
361
+ */
362
+ async allowance(_tokenOwner, _spender) {
363
+ return this.contract.read.allowance([_tokenOwner, _spender]);
364
+ }
365
+ /**
366
+ * balanceOf
367
+ * view
368
+ */
369
+ async balanceOf(_tokenOwner) {
370
+ return this.contract.read.balanceOf([_tokenOwner]);
371
+ }
372
+ /**
373
+ * decimals
374
+ * view
375
+ */
376
+ async decimals() {
377
+ return this.contract.read.decimals();
378
+ }
379
+ /**
380
+ * isOwner
381
+ * view
382
+ */
383
+ async isOwner() {
384
+ return this.contract.read.isOwner();
385
+ }
386
+ /**
387
+ * name
388
+ * view
389
+ */
390
+ async name() {
391
+ return this.contract.read.name();
392
+ }
393
+ /**
394
+ * owner
395
+ * view
396
+ */
397
+ async owner() {
398
+ return this.contract.read.owner();
399
+ }
400
+ /**
401
+ * symbol
402
+ * view
403
+ */
404
+ async symbol() {
405
+ return this.contract.read.symbol();
406
+ }
407
+ /**
408
+ * totalSupply
409
+ * view
410
+ */
411
+ async totalSupply() {
412
+ return this.contract.read.totalSupply();
413
+ }
414
+ /**
415
+ * approve
416
+ * nonpayable
417
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
418
+ */
419
+ async approve(_spender, _tokens, options) {
420
+ if (!this.contract.write) {
421
+ throw new Error('Wallet client is required for write operations');
422
+ }
423
+ return this.contract.write.approve([_spender, _tokens], options);
424
+ }
425
+ /**
426
+ * transfer
427
+ * nonpayable
428
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
429
+ */
430
+ async transfer(_to, _tokens, options) {
431
+ if (!this.contract.write) {
432
+ throw new Error('Wallet client is required for write operations');
433
+ }
434
+ return this.contract.write.transfer([_to, _tokens], options);
435
+ }
436
+ /**
437
+ * transferFrom
438
+ * nonpayable
439
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
440
+ */
441
+ async transferFrom(_from, _to, _tokens, options) {
442
+ if (!this.contract.write) {
443
+ throw new Error('Wallet client is required for write operations');
444
+ }
445
+ return this.contract.write.transferFrom([_from, _to, _tokens], options);
446
+ }
447
+ /**
448
+ * transferOwnership
449
+ * nonpayable
450
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
451
+ */
452
+ async transferOwnership(_newOwner, options) {
453
+ if (!this.contract.write) {
454
+ throw new Error('Wallet client is required for write operations');
455
+ }
456
+ return this.contract.write.transferOwnership([_newOwner], options);
457
+ }
458
+ /**
459
+ * Simulate contract write operations (dry-run without sending transaction)
460
+ *
461
+ * @example
462
+ * const result = await contract.simulate.transfer('0x...', 1000n);
463
+ * console.log('Gas estimate:', result.request.gas);
464
+ * console.log('Would succeed:', result.result);
465
+ */
466
+ get simulate() {
467
+ const contract = this.contract;
468
+ if (!contract.simulate) {
469
+ throw new Error('Public client is required for simulation');
470
+ }
471
+ return {
472
+ /**
473
+ * Simulate approve
474
+ * Returns gas estimate and result without sending transaction
475
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
476
+ */
477
+ async approve(_spender, _tokens, options) {
478
+ return contract.simulate.approve([_spender, _tokens], options);
479
+ },
480
+ /**
481
+ * Simulate transfer
482
+ * Returns gas estimate and result without sending transaction
483
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
484
+ */
485
+ async transfer(_to, _tokens, options) {
486
+ return contract.simulate.transfer([_to, _tokens], options);
487
+ },
488
+ /**
489
+ * Simulate transferFrom
490
+ * Returns gas estimate and result without sending transaction
491
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
492
+ */
493
+ async transferFrom(_from, _to, _tokens, options) {
494
+ return contract.simulate.transferFrom([_from, _to, _tokens], options);
495
+ },
496
+ /**
497
+ * Simulate transferOwnership
498
+ * Returns gas estimate and result without sending transaction
499
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
500
+ */
501
+ async transferOwnership(_newOwner, options) {
502
+ return contract.simulate.transferOwnership([_newOwner], options);
503
+ }
504
+ };
505
+ }
506
+ /**
507
+ * Watch contract events
508
+ *
509
+ * @example
510
+ * // Watch all Transfer events
511
+ * const unwatch = contract.watch.Transfer((event) => {
512
+ * console.log('Transfer:', event);
513
+ * });
514
+ *
515
+ * // Stop watching
516
+ * unwatch();
517
+ */
518
+ get watch() {
519
+ return {
520
+ /**
521
+ * Watch Approval events
522
+ * @param callback Function to call when event is emitted
523
+ * @param filter Optional filter for indexed parameters
524
+ * @returns Unwatch function to stop listening
525
+ */
526
+ Approval: (callback, filter) => {
527
+ return this.publicClient.watchContractEvent({
528
+ address: this.contractAddress,
529
+ abi: exports.B26_jsonAbi,
530
+ eventName: 'Approval',
531
+ args: filter,
532
+ onLogs: (logs) => {
533
+ logs.forEach((log) => {
534
+ callback(log.args);
535
+ });
536
+ },
537
+ });
538
+ },
539
+ /**
540
+ * Watch OwnershipTransferred events
541
+ * @param callback Function to call when event is emitted
542
+ * @param filter Optional filter for indexed parameters
543
+ * @returns Unwatch function to stop listening
544
+ */
545
+ OwnershipTransferred: (callback, filter) => {
546
+ return this.publicClient.watchContractEvent({
547
+ address: this.contractAddress,
548
+ abi: exports.B26_jsonAbi,
549
+ eventName: 'OwnershipTransferred',
550
+ args: filter,
551
+ onLogs: (logs) => {
552
+ logs.forEach((log) => {
553
+ callback(log.args);
554
+ });
555
+ },
556
+ });
557
+ },
558
+ /**
559
+ * Watch Transfer events
560
+ * @param callback Function to call when event is emitted
561
+ * @param filter Optional filter for indexed parameters
562
+ * @returns Unwatch function to stop listening
563
+ */
564
+ Transfer: (callback, filter) => {
565
+ return this.publicClient.watchContractEvent({
566
+ address: this.contractAddress,
567
+ abi: exports.B26_jsonAbi,
568
+ eventName: 'Transfer',
569
+ args: filter,
570
+ onLogs: (logs) => {
571
+ logs.forEach((log) => {
572
+ callback(log.args);
573
+ });
574
+ },
575
+ });
576
+ }
577
+ };
578
+ }
579
+ }
580
+ exports.B26_json = B26_json;