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