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