@gitmyabi/ben 1.0.0 → 1.0.1

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