@gitmyabi/usdc 1.0.1 → 1.0.3

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