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