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