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