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