@gitmyabi/erc20 1.0.0 → 1.0.2

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,521 @@
1
+ import type { Abi, Address, PublicClient, WalletClient, GetContractReturnType } from 'viem';
2
+ import { getContract } from 'viem';
3
+
4
+ /**
5
+ * ERC20Proxy ABI
6
+ *
7
+ * This ABI is typed using viem's type system for full type safety.
8
+ */
9
+ export const ERC20ProxyAbi = [
10
+ {
11
+ "inputs": [
12
+ {
13
+ "internalType": "address",
14
+ "name": "_owner",
15
+ "type": "address"
16
+ },
17
+ {
18
+ "internalType": "address",
19
+ "name": "_diamond",
20
+ "type": "address"
21
+ }
22
+ ],
23
+ "stateMutability": "nonpayable",
24
+ "type": "constructor"
25
+ },
26
+ {
27
+ "inputs": [],
28
+ "name": "InvalidAmount",
29
+ "type": "error"
30
+ },
31
+ {
32
+ "inputs": [],
33
+ "name": "LengthMissmatch",
34
+ "type": "error"
35
+ },
36
+ {
37
+ "inputs": [],
38
+ "name": "NoTransferToNullAddress",
39
+ "type": "error"
40
+ },
41
+ {
42
+ "inputs": [],
43
+ "name": "NotInitialized",
44
+ "type": "error"
45
+ },
46
+ {
47
+ "inputs": [],
48
+ "name": "NullAddrIsNotAnERC20Token",
49
+ "type": "error"
50
+ },
51
+ {
52
+ "inputs": [],
53
+ "name": "SliceOutOfBounds",
54
+ "type": "error"
55
+ },
56
+ {
57
+ "inputs": [],
58
+ "name": "SliceOverflow",
59
+ "type": "error"
60
+ },
61
+ {
62
+ "inputs": [],
63
+ "name": "ZeroAddress",
64
+ "type": "error"
65
+ },
66
+ {
67
+ "anonymous": false,
68
+ "inputs": [
69
+ {
70
+ "indexed": false,
71
+ "internalType": "address",
72
+ "name": "diamond",
73
+ "type": "address"
74
+ }
75
+ ],
76
+ "name": "DiamondSet",
77
+ "type": "event"
78
+ },
79
+ {
80
+ "anonymous": false,
81
+ "inputs": [
82
+ {
83
+ "indexed": true,
84
+ "internalType": "address",
85
+ "name": "previousOwner",
86
+ "type": "address"
87
+ },
88
+ {
89
+ "indexed": true,
90
+ "internalType": "address",
91
+ "name": "newOwner",
92
+ "type": "address"
93
+ }
94
+ ],
95
+ "name": "OwnershipTransferred",
96
+ "type": "event"
97
+ },
98
+ {
99
+ "inputs": [],
100
+ "name": "diamond",
101
+ "outputs": [
102
+ {
103
+ "internalType": "address",
104
+ "name": "",
105
+ "type": "address"
106
+ }
107
+ ],
108
+ "stateMutability": "view",
109
+ "type": "function"
110
+ },
111
+ {
112
+ "inputs": [],
113
+ "name": "owner",
114
+ "outputs": [
115
+ {
116
+ "internalType": "address",
117
+ "name": "",
118
+ "type": "address"
119
+ }
120
+ ],
121
+ "stateMutability": "view",
122
+ "type": "function"
123
+ },
124
+ {
125
+ "inputs": [],
126
+ "name": "renounceOwnership",
127
+ "outputs": [],
128
+ "stateMutability": "nonpayable",
129
+ "type": "function"
130
+ },
131
+ {
132
+ "inputs": [
133
+ {
134
+ "internalType": "address",
135
+ "name": "_diamond",
136
+ "type": "address"
137
+ }
138
+ ],
139
+ "name": "setDiamond",
140
+ "outputs": [],
141
+ "stateMutability": "nonpayable",
142
+ "type": "function"
143
+ },
144
+ {
145
+ "inputs": [
146
+ {
147
+ "internalType": "address[]",
148
+ "name": "tokens",
149
+ "type": "address[]"
150
+ },
151
+ {
152
+ "internalType": "uint256[]",
153
+ "name": "amounts",
154
+ "type": "uint256[]"
155
+ },
156
+ {
157
+ "internalType": "bytes",
158
+ "name": "facetCallData",
159
+ "type": "bytes"
160
+ }
161
+ ],
162
+ "name": "startViaRubic",
163
+ "outputs": [],
164
+ "stateMutability": "payable",
165
+ "type": "function"
166
+ },
167
+ {
168
+ "inputs": [
169
+ {
170
+ "internalType": "address",
171
+ "name": "newOwner",
172
+ "type": "address"
173
+ }
174
+ ],
175
+ "name": "transferOwnership",
176
+ "outputs": [],
177
+ "stateMutability": "nonpayable",
178
+ "type": "function"
179
+ }
180
+ ] as const satisfies Abi;
181
+
182
+ /**
183
+ * Type-safe ABI for ERC20Proxy
184
+ */
185
+ export type ERC20ProxyAbi = typeof ERC20ProxyAbi;
186
+
187
+ /**
188
+ * Contract instance type for ERC20Proxy
189
+ */
190
+ // Use any for contract type to avoid complex viem type issues
191
+ // The runtime behavior is type-safe through viem's ABI typing
192
+ export type ERC20ProxyContract = any;
193
+
194
+ /**
195
+ * ERC20Proxy Contract Class
196
+ *
197
+ * Provides a class-based API similar to TypeChain for interacting with the contract.
198
+ *
199
+ * @example
200
+ * ```typescript
201
+ * import { createPublicClient, createWalletClient, http } from 'viem';
202
+ * import { mainnet } from 'viem/chains';
203
+ * import { ERC20Proxy } from 'ERC20Proxy';
204
+ *
205
+ * const publicClient = createPublicClient({ chain: mainnet, transport: http() });
206
+ * const walletClient = createWalletClient({ chain: mainnet, transport: http() });
207
+ *
208
+ * const contract = new ERC20Proxy('0x...', { publicClient, walletClient });
209
+ *
210
+ * // Read functions
211
+ * const result = await contract.balanceOf('0x...');
212
+ *
213
+ * // Write functions
214
+ * const hash = await contract.transfer('0x...', 1000n);
215
+ *
216
+ * // Simulate transactions (dry-run)
217
+ * const simulation = await contract.simulate.transfer('0x...', 1000n);
218
+ * console.log('Gas estimate:', simulation.request.gas);
219
+ *
220
+ * // Watch events
221
+ * const unwatch = contract.watch.Transfer((event) => {
222
+ * console.log('Transfer event:', event);
223
+ * });
224
+ * ```
225
+ */
226
+ export class ERC20Proxy {
227
+ private contract: ERC20ProxyContract;
228
+ private contractAddress: Address;
229
+ private publicClient: PublicClient;
230
+
231
+ constructor(
232
+ address: Address,
233
+ clients: {
234
+ publicClient: PublicClient;
235
+ walletClient?: WalletClient;
236
+ }
237
+ ) {
238
+ this.contractAddress = address;
239
+ this.publicClient = clients.publicClient;
240
+ this.contract = getContract({
241
+ address,
242
+ abi: ERC20ProxyAbi,
243
+ client: {
244
+ public: clients.publicClient,
245
+ wallet: clients.walletClient,
246
+ },
247
+ });
248
+ }
249
+
250
+ /**
251
+ * Get the contract address
252
+ */
253
+ get address(): Address {
254
+ return this.contractAddress;
255
+ }
256
+
257
+ /**
258
+ * Get the underlying viem contract instance.
259
+ */
260
+ getContract(): ERC20ProxyContract {
261
+ return this.contract;
262
+ }
263
+
264
+ /**
265
+ * diamond
266
+ * view
267
+ */
268
+ async diamond(): Promise<`0x${string}`> {
269
+ return this.contract.read.diamond() as Promise<`0x${string}`>;
270
+ }
271
+
272
+ /**
273
+ * owner
274
+ * view
275
+ */
276
+ async owner(): Promise<`0x${string}`> {
277
+ return this.contract.read.owner() as Promise<`0x${string}`>;
278
+ }
279
+
280
+ /**
281
+ * renounceOwnership
282
+ * nonpayable
283
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
284
+ */
285
+ async renounceOwnership(options?: {
286
+ accessList?: import('viem').AccessList;
287
+ authorizationList?: import('viem').AuthorizationList;
288
+ chain?: import('viem').Chain | null;
289
+ dataSuffix?: `0x${string}`;
290
+ gas?: bigint;
291
+ gasPrice?: bigint;
292
+ maxFeePerGas?: bigint;
293
+ maxPriorityFeePerGas?: bigint;
294
+ nonce?: number;
295
+ value?: bigint;
296
+ }): Promise<`0x${string}`> {
297
+ if (!this.contract.write) {
298
+ throw new Error('Wallet client is required for write operations');
299
+ }
300
+ return this.contract.write.renounceOwnership(options) as Promise<`0x${string}`>;
301
+ }
302
+
303
+ /**
304
+ * setDiamond
305
+ * nonpayable
306
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
307
+ */
308
+ async setDiamond(_diamond: `0x${string}`, options?: {
309
+ accessList?: import('viem').AccessList;
310
+ authorizationList?: import('viem').AuthorizationList;
311
+ chain?: import('viem').Chain | null;
312
+ dataSuffix?: `0x${string}`;
313
+ gas?: bigint;
314
+ gasPrice?: bigint;
315
+ maxFeePerGas?: bigint;
316
+ maxPriorityFeePerGas?: bigint;
317
+ nonce?: number;
318
+ value?: bigint;
319
+ }): Promise<`0x${string}`> {
320
+ if (!this.contract.write) {
321
+ throw new Error('Wallet client is required for write operations');
322
+ }
323
+ return this.contract.write.setDiamond([_diamond] as const, options) as Promise<`0x${string}`>;
324
+ }
325
+
326
+ /**
327
+ * startViaRubic
328
+ * payable
329
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
330
+ */
331
+ async startViaRubic(tokens: `0x${string}`[], amounts: bigint[], facetCallData: `0x${string}`, options?: {
332
+ accessList?: import('viem').AccessList;
333
+ authorizationList?: import('viem').AuthorizationList;
334
+ chain?: import('viem').Chain | null;
335
+ dataSuffix?: `0x${string}`;
336
+ gas?: bigint;
337
+ gasPrice?: bigint;
338
+ maxFeePerGas?: bigint;
339
+ maxPriorityFeePerGas?: bigint;
340
+ nonce?: number;
341
+ value?: bigint;
342
+ }): Promise<`0x${string}`> {
343
+ if (!this.contract.write) {
344
+ throw new Error('Wallet client is required for write operations');
345
+ }
346
+ return this.contract.write.startViaRubic([tokens, amounts, facetCallData] as const, options) as Promise<`0x${string}`>;
347
+ }
348
+
349
+ /**
350
+ * transferOwnership
351
+ * nonpayable
352
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
353
+ */
354
+ async transferOwnership(newOwner: `0x${string}`, options?: {
355
+ accessList?: import('viem').AccessList;
356
+ authorizationList?: import('viem').AuthorizationList;
357
+ chain?: import('viem').Chain | null;
358
+ dataSuffix?: `0x${string}`;
359
+ gas?: bigint;
360
+ gasPrice?: bigint;
361
+ maxFeePerGas?: bigint;
362
+ maxPriorityFeePerGas?: bigint;
363
+ nonce?: number;
364
+ value?: bigint;
365
+ }): Promise<`0x${string}`> {
366
+ if (!this.contract.write) {
367
+ throw new Error('Wallet client is required for write operations');
368
+ }
369
+ return this.contract.write.transferOwnership([newOwner] as const, options) as Promise<`0x${string}`>;
370
+ }
371
+
372
+
373
+
374
+ /**
375
+ * Simulate contract write operations (dry-run without sending transaction)
376
+ *
377
+ * @example
378
+ * const result = await contract.simulate.transfer('0x...', 1000n);
379
+ * console.log('Gas estimate:', result.request.gas);
380
+ * console.log('Would succeed:', result.result);
381
+ */
382
+ get simulate() {
383
+ const contract = this.contract;
384
+ if (!contract.simulate) {
385
+ throw new Error('Public client is required for simulation');
386
+ }
387
+ return {
388
+ /**
389
+ * Simulate renounceOwnership
390
+ * Returns gas estimate and result without sending transaction
391
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
392
+ */
393
+ async renounceOwnership(options?: {
394
+ accessList?: import('viem').AccessList;
395
+ authorizationList?: import('viem').AuthorizationList;
396
+ chain?: import('viem').Chain | null;
397
+ dataSuffix?: `0x${string}`;
398
+ gas?: bigint;
399
+ gasPrice?: bigint;
400
+ maxFeePerGas?: bigint;
401
+ maxPriorityFeePerGas?: bigint;
402
+ nonce?: number;
403
+ value?: bigint;
404
+ }): Promise<void> {
405
+ return contract.simulate.renounceOwnership(options) as Promise<void>;
406
+ },
407
+ /**
408
+ * Simulate setDiamond
409
+ * Returns gas estimate and result without sending transaction
410
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
411
+ */
412
+ async setDiamond(_diamond: `0x${string}`, options?: {
413
+ accessList?: import('viem').AccessList;
414
+ authorizationList?: import('viem').AuthorizationList;
415
+ chain?: import('viem').Chain | null;
416
+ dataSuffix?: `0x${string}`;
417
+ gas?: bigint;
418
+ gasPrice?: bigint;
419
+ maxFeePerGas?: bigint;
420
+ maxPriorityFeePerGas?: bigint;
421
+ nonce?: number;
422
+ value?: bigint;
423
+ }): Promise<void> {
424
+ return contract.simulate.setDiamond([_diamond] as const, options) as Promise<void>;
425
+ },
426
+ /**
427
+ * Simulate startViaRubic
428
+ * Returns gas estimate and result without sending transaction
429
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
430
+ */
431
+ async startViaRubic(tokens: `0x${string}`[], amounts: bigint[], facetCallData: `0x${string}`, options?: {
432
+ accessList?: import('viem').AccessList;
433
+ authorizationList?: import('viem').AuthorizationList;
434
+ chain?: import('viem').Chain | null;
435
+ dataSuffix?: `0x${string}`;
436
+ gas?: bigint;
437
+ gasPrice?: bigint;
438
+ maxFeePerGas?: bigint;
439
+ maxPriorityFeePerGas?: bigint;
440
+ nonce?: number;
441
+ value?: bigint;
442
+ }): Promise<void> {
443
+ return contract.simulate.startViaRubic([tokens, amounts, facetCallData] as const, options) as Promise<void>;
444
+ },
445
+ /**
446
+ * Simulate transferOwnership
447
+ * Returns gas estimate and result without sending transaction
448
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
449
+ */
450
+ async transferOwnership(newOwner: `0x${string}`, options?: {
451
+ accessList?: import('viem').AccessList;
452
+ authorizationList?: import('viem').AuthorizationList;
453
+ chain?: import('viem').Chain | null;
454
+ dataSuffix?: `0x${string}`;
455
+ gas?: bigint;
456
+ gasPrice?: bigint;
457
+ maxFeePerGas?: bigint;
458
+ maxPriorityFeePerGas?: bigint;
459
+ nonce?: number;
460
+ value?: bigint;
461
+ }): Promise<void> {
462
+ return contract.simulate.transferOwnership([newOwner] as const, options) as Promise<void>;
463
+ }
464
+ };
465
+ }
466
+
467
+ /**
468
+ * Watch contract events
469
+ *
470
+ * @example
471
+ * // Watch all Transfer events
472
+ * const unwatch = contract.watch.Transfer((event) => {
473
+ * console.log('Transfer:', event);
474
+ * });
475
+ *
476
+ * // Stop watching
477
+ * unwatch();
478
+ */
479
+ get watch() {
480
+ return {
481
+ /**
482
+ * Watch DiamondSet events
483
+ * @param callback Function to call when event is emitted
484
+ * @param filter Optional filter for indexed parameters
485
+ * @returns Unwatch function to stop listening
486
+ */
487
+ DiamondSet: (callback: (event: { diamond: `0x${string}` }) => void) => {
488
+ return this.publicClient.watchContractEvent({
489
+ address: this.contractAddress,
490
+ abi: ERC20ProxyAbi,
491
+ eventName: 'DiamondSet',
492
+
493
+ onLogs: (logs: any[]) => {
494
+ logs.forEach((log: any) => {
495
+ callback(log.args as any);
496
+ });
497
+ },
498
+ }) as () => void;
499
+ },
500
+ /**
501
+ * Watch OwnershipTransferred events
502
+ * @param callback Function to call when event is emitted
503
+ * @param filter Optional filter for indexed parameters
504
+ * @returns Unwatch function to stop listening
505
+ */
506
+ OwnershipTransferred: (callback: (event: { previousOwner: `0x${string}`; newOwner: `0x${string}` }) => void, filter?: { previousOwner?: `0x${string}` | `0x${string}`[] | null; newOwner?: `0x${string}` | `0x${string}`[] | null }) => {
507
+ return this.publicClient.watchContractEvent({
508
+ address: this.contractAddress,
509
+ abi: ERC20ProxyAbi,
510
+ eventName: 'OwnershipTransferred',
511
+ args: filter as any,
512
+ onLogs: (logs: any[]) => {
513
+ logs.forEach((log: any) => {
514
+ callback(log.args as any);
515
+ });
516
+ },
517
+ }) as () => void;
518
+ }
519
+ };
520
+ }
521
+ }
@@ -1,2 +1,2 @@
1
- export { TaxableERC20_jsonAbi, TaxableERC20_json } from './TaxableERC20_json';
2
- export type { TaxableERC20_jsonAbi as TaxableERC20_jsonAbiType, TaxableERC20_jsonContract } from './TaxableERC20_json';
1
+ export { ERC20ProxyAbi, ERC20Proxy } from './ERC20Proxy';
2
+ export type { ERC20ProxyAbi as ERC20ProxyAbiType, ERC20ProxyContract } from './ERC20Proxy';
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TaxableERC20_json = exports.TaxableERC20_jsonAbi = void 0;
3
+ exports.ERC20Proxy = exports.ERC20ProxyAbi = void 0;
4
4
  // Auto-generated exports for all contracts
5
- var TaxableERC20_json_1 = require("./TaxableERC20_json");
6
- Object.defineProperty(exports, "TaxableERC20_jsonAbi", { enumerable: true, get: function () { return TaxableERC20_json_1.TaxableERC20_jsonAbi; } });
7
- Object.defineProperty(exports, "TaxableERC20_json", { enumerable: true, get: function () { return TaxableERC20_json_1.TaxableERC20_json; } });
5
+ var ERC20Proxy_1 = require("./ERC20Proxy");
6
+ Object.defineProperty(exports, "ERC20ProxyAbi", { enumerable: true, get: function () { return ERC20Proxy_1.ERC20ProxyAbi; } });
7
+ Object.defineProperty(exports, "ERC20Proxy", { enumerable: true, get: function () { return ERC20Proxy_1.ERC20Proxy; } });
@@ -1,3 +1,3 @@
1
1
  // Auto-generated exports for all contracts
2
- export { TaxableERC20_jsonAbi, TaxableERC20_json } from './TaxableERC20_json';
3
- export type { TaxableERC20_jsonAbi as TaxableERC20_jsonAbiType, TaxableERC20_jsonContract } from './TaxableERC20_json';
2
+ export { ERC20ProxyAbi, ERC20Proxy } from './ERC20Proxy';
3
+ export type { ERC20ProxyAbi as ERC20ProxyAbiType, ERC20ProxyContract } from './ERC20Proxy';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gitmyabi/erc20",
3
- "version": "1.0.0",
4
- "description": "Auto-generated TypeScript type bindings for ERC20 (build etherscan-erc20-cdd981ef-1787662240317, commit 0b5abf6, branch etherscan)",
3
+ "version": "1.0.2",
4
+ "description": "Auto-generated TypeScript type bindings for ERC20 (build etherscan-erc20-3335733c-1793997005446, commit fb0e79e, branch etherscan)",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
7
7
  "exports": {
@@ -30,7 +30,7 @@
30
30
  "abi",
31
31
  "ethers-v6"
32
32
  ],
33
- "license": "MIT",
33
+ "license": "Apache-2.0",
34
34
  "dependencies": {
35
35
  "viem": "^2.0.0"
36
36
  },
@@ -39,5 +39,5 @@
39
39
  "url": "https://github.com/etherscan/erc20"
40
40
  },
41
41
  "branch": "etherscan",
42
- "shortHash": "0b5abf6"
42
+ "shortHash": "fb0e79e"
43
43
  }