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