@gitmyabi/cover 1.0.0 → 1.0.1

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,370 @@
1
+ import type { Abi, Address, PublicClient, WalletClient, GetContractReturnType } from 'viem';
2
+ import { getContract } from 'viem';
3
+
4
+ /**
5
+ * OwnedUpgradeabilityProxy ABI
6
+ *
7
+ * This ABI is typed using viem's type system for full type safety.
8
+ */
9
+ export const OwnedUpgradeabilityProxyAbi = [
10
+ {
11
+ "inputs": [
12
+ {
13
+ "internalType": "address",
14
+ "name": "_implementation",
15
+ "type": "address"
16
+ }
17
+ ],
18
+ "stateMutability": "nonpayable",
19
+ "type": "constructor"
20
+ },
21
+ {
22
+ "anonymous": false,
23
+ "inputs": [
24
+ {
25
+ "indexed": false,
26
+ "internalType": "address",
27
+ "name": "previousOwner",
28
+ "type": "address"
29
+ },
30
+ {
31
+ "indexed": false,
32
+ "internalType": "address",
33
+ "name": "newOwner",
34
+ "type": "address"
35
+ }
36
+ ],
37
+ "name": "ProxyOwnershipTransferred",
38
+ "type": "event"
39
+ },
40
+ {
41
+ "anonymous": false,
42
+ "inputs": [
43
+ {
44
+ "indexed": true,
45
+ "internalType": "address",
46
+ "name": "implementation",
47
+ "type": "address"
48
+ }
49
+ ],
50
+ "name": "Upgraded",
51
+ "type": "event"
52
+ },
53
+ {
54
+ "stateMutability": "payable",
55
+ "type": "fallback"
56
+ },
57
+ {
58
+ "inputs": [],
59
+ "name": "implementation",
60
+ "outputs": [
61
+ {
62
+ "internalType": "address",
63
+ "name": "impl",
64
+ "type": "address"
65
+ }
66
+ ],
67
+ "stateMutability": "view",
68
+ "type": "function"
69
+ },
70
+ {
71
+ "inputs": [],
72
+ "name": "proxyOwner",
73
+ "outputs": [
74
+ {
75
+ "internalType": "address",
76
+ "name": "owner",
77
+ "type": "address"
78
+ }
79
+ ],
80
+ "stateMutability": "view",
81
+ "type": "function"
82
+ },
83
+ {
84
+ "inputs": [
85
+ {
86
+ "internalType": "address",
87
+ "name": "_newOwner",
88
+ "type": "address"
89
+ }
90
+ ],
91
+ "name": "transferProxyOwnership",
92
+ "outputs": [],
93
+ "stateMutability": "nonpayable",
94
+ "type": "function"
95
+ },
96
+ {
97
+ "inputs": [
98
+ {
99
+ "internalType": "address",
100
+ "name": "_implementation",
101
+ "type": "address"
102
+ }
103
+ ],
104
+ "name": "upgradeTo",
105
+ "outputs": [],
106
+ "stateMutability": "nonpayable",
107
+ "type": "function"
108
+ },
109
+ {
110
+ "stateMutability": "payable",
111
+ "type": "receive"
112
+ }
113
+ ] as const satisfies Abi;
114
+
115
+ /**
116
+ * Type-safe ABI for OwnedUpgradeabilityProxy
117
+ */
118
+ export type OwnedUpgradeabilityProxyAbi = typeof OwnedUpgradeabilityProxyAbi;
119
+
120
+ /**
121
+ * Contract instance type for OwnedUpgradeabilityProxy
122
+ */
123
+ // Use any for contract type to avoid complex viem type issues
124
+ // The runtime behavior is type-safe through viem's ABI typing
125
+ export type OwnedUpgradeabilityProxyContract = any;
126
+
127
+ /**
128
+ * OwnedUpgradeabilityProxy Contract Class
129
+ *
130
+ * Provides a class-based API similar to TypeChain for interacting with the contract.
131
+ *
132
+ * @example
133
+ * ```typescript
134
+ * import { createPublicClient, createWalletClient, http } from 'viem';
135
+ * import { mainnet } from 'viem/chains';
136
+ * import { OwnedUpgradeabilityProxy } from 'OwnedUpgradeabilityProxy';
137
+ *
138
+ * const publicClient = createPublicClient({ chain: mainnet, transport: http() });
139
+ * const walletClient = createWalletClient({ chain: mainnet, transport: http() });
140
+ *
141
+ * const contract = new OwnedUpgradeabilityProxy('0x...', { publicClient, walletClient });
142
+ *
143
+ * // Read functions
144
+ * const result = await contract.balanceOf('0x...');
145
+ *
146
+ * // Write functions
147
+ * const hash = await contract.transfer('0x...', 1000n);
148
+ *
149
+ * // Simulate transactions (dry-run)
150
+ * const simulation = await contract.simulate.transfer('0x...', 1000n);
151
+ * console.log('Gas estimate:', simulation.request.gas);
152
+ *
153
+ * // Watch events
154
+ * const unwatch = contract.watch.Transfer((event) => {
155
+ * console.log('Transfer event:', event);
156
+ * });
157
+ * ```
158
+ */
159
+ export class OwnedUpgradeabilityProxy {
160
+ private contract: OwnedUpgradeabilityProxyContract;
161
+ private contractAddress: Address;
162
+ private publicClient: PublicClient;
163
+
164
+ constructor(
165
+ address: Address,
166
+ clients: {
167
+ publicClient: PublicClient;
168
+ walletClient?: WalletClient;
169
+ }
170
+ ) {
171
+ this.contractAddress = address;
172
+ this.publicClient = clients.publicClient;
173
+ this.contract = getContract({
174
+ address,
175
+ abi: OwnedUpgradeabilityProxyAbi,
176
+ client: {
177
+ public: clients.publicClient,
178
+ wallet: clients.walletClient,
179
+ },
180
+ });
181
+ }
182
+
183
+ /**
184
+ * Get the contract address
185
+ */
186
+ get address(): Address {
187
+ return this.contractAddress;
188
+ }
189
+
190
+ /**
191
+ * Get the underlying viem contract instance.
192
+ */
193
+ getContract(): OwnedUpgradeabilityProxyContract {
194
+ return this.contract;
195
+ }
196
+
197
+ /**
198
+ * implementation
199
+ * view
200
+ */
201
+ async implementation(): Promise<`0x${string}`> {
202
+ return this.contract.read.implementation() as Promise<`0x${string}`>;
203
+ }
204
+
205
+ /**
206
+ * proxyOwner
207
+ * view
208
+ */
209
+ async proxyOwner(): Promise<`0x${string}`> {
210
+ return this.contract.read.proxyOwner() as Promise<`0x${string}`>;
211
+ }
212
+
213
+ /**
214
+ * transferProxyOwnership
215
+ * nonpayable
216
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
217
+ */
218
+ async transferProxyOwnership(_newOwner: `0x${string}`, options?: {
219
+ accessList?: import('viem').AccessList;
220
+ authorizationList?: import('viem').AuthorizationList;
221
+ chain?: import('viem').Chain | null;
222
+ dataSuffix?: `0x${string}`;
223
+ gas?: bigint;
224
+ gasPrice?: bigint;
225
+ maxFeePerGas?: bigint;
226
+ maxPriorityFeePerGas?: bigint;
227
+ nonce?: number;
228
+ value?: bigint;
229
+ }): Promise<`0x${string}`> {
230
+ if (!this.contract.write) {
231
+ throw new Error('Wallet client is required for write operations');
232
+ }
233
+ return this.contract.write.transferProxyOwnership([_newOwner] as const, options) as Promise<`0x${string}`>;
234
+ }
235
+
236
+ /**
237
+ * upgradeTo
238
+ * nonpayable
239
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
240
+ */
241
+ async upgradeTo(_implementation: `0x${string}`, options?: {
242
+ accessList?: import('viem').AccessList;
243
+ authorizationList?: import('viem').AuthorizationList;
244
+ chain?: import('viem').Chain | null;
245
+ dataSuffix?: `0x${string}`;
246
+ gas?: bigint;
247
+ gasPrice?: bigint;
248
+ maxFeePerGas?: bigint;
249
+ maxPriorityFeePerGas?: bigint;
250
+ nonce?: number;
251
+ value?: bigint;
252
+ }): Promise<`0x${string}`> {
253
+ if (!this.contract.write) {
254
+ throw new Error('Wallet client is required for write operations');
255
+ }
256
+ return this.contract.write.upgradeTo([_implementation] as const, options) as Promise<`0x${string}`>;
257
+ }
258
+
259
+
260
+
261
+ /**
262
+ * Simulate contract write operations (dry-run without sending transaction)
263
+ *
264
+ * @example
265
+ * const result = await contract.simulate.transfer('0x...', 1000n);
266
+ * console.log('Gas estimate:', result.request.gas);
267
+ * console.log('Would succeed:', result.result);
268
+ */
269
+ get simulate() {
270
+ const contract = this.contract;
271
+ if (!contract.simulate) {
272
+ throw new Error('Public client is required for simulation');
273
+ }
274
+ return {
275
+ /**
276
+ * Simulate transferProxyOwnership
277
+ * Returns gas estimate and result without sending transaction
278
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
279
+ */
280
+ async transferProxyOwnership(_newOwner: `0x${string}`, options?: {
281
+ accessList?: import('viem').AccessList;
282
+ authorizationList?: import('viem').AuthorizationList;
283
+ chain?: import('viem').Chain | null;
284
+ dataSuffix?: `0x${string}`;
285
+ gas?: bigint;
286
+ gasPrice?: bigint;
287
+ maxFeePerGas?: bigint;
288
+ maxPriorityFeePerGas?: bigint;
289
+ nonce?: number;
290
+ value?: bigint;
291
+ }): Promise<void> {
292
+ return contract.simulate.transferProxyOwnership([_newOwner] as const, options) as Promise<void>;
293
+ },
294
+ /**
295
+ * Simulate upgradeTo
296
+ * Returns gas estimate and result without sending transaction
297
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
298
+ */
299
+ async upgradeTo(_implementation: `0x${string}`, options?: {
300
+ accessList?: import('viem').AccessList;
301
+ authorizationList?: import('viem').AuthorizationList;
302
+ chain?: import('viem').Chain | null;
303
+ dataSuffix?: `0x${string}`;
304
+ gas?: bigint;
305
+ gasPrice?: bigint;
306
+ maxFeePerGas?: bigint;
307
+ maxPriorityFeePerGas?: bigint;
308
+ nonce?: number;
309
+ value?: bigint;
310
+ }): Promise<void> {
311
+ return contract.simulate.upgradeTo([_implementation] as const, options) as Promise<void>;
312
+ }
313
+ };
314
+ }
315
+
316
+ /**
317
+ * Watch contract events
318
+ *
319
+ * @example
320
+ * // Watch all Transfer events
321
+ * const unwatch = contract.watch.Transfer((event) => {
322
+ * console.log('Transfer:', event);
323
+ * });
324
+ *
325
+ * // Stop watching
326
+ * unwatch();
327
+ */
328
+ get watch() {
329
+ return {
330
+ /**
331
+ * Watch ProxyOwnershipTransferred events
332
+ * @param callback Function to call when event is emitted
333
+ * @param filter Optional filter for indexed parameters
334
+ * @returns Unwatch function to stop listening
335
+ */
336
+ ProxyOwnershipTransferred: (callback: (event: { previousOwner: `0x${string}`; newOwner: `0x${string}` }) => void) => {
337
+ return this.publicClient.watchContractEvent({
338
+ address: this.contractAddress,
339
+ abi: OwnedUpgradeabilityProxyAbi,
340
+ eventName: 'ProxyOwnershipTransferred',
341
+
342
+ onLogs: (logs: any[]) => {
343
+ logs.forEach((log: any) => {
344
+ callback(log.args as any);
345
+ });
346
+ },
347
+ }) as () => void;
348
+ },
349
+ /**
350
+ * Watch Upgraded events
351
+ * @param callback Function to call when event is emitted
352
+ * @param filter Optional filter for indexed parameters
353
+ * @returns Unwatch function to stop listening
354
+ */
355
+ Upgraded: (callback: (event: { implementation: `0x${string}` }) => void, filter?: { implementation?: `0x${string}` | `0x${string}`[] | null }) => {
356
+ return this.publicClient.watchContractEvent({
357
+ address: this.contractAddress,
358
+ abi: OwnedUpgradeabilityProxyAbi,
359
+ eventName: 'Upgraded',
360
+ args: filter as any,
361
+ onLogs: (logs: any[]) => {
362
+ logs.forEach((log: any) => {
363
+ callback(log.args as any);
364
+ });
365
+ },
366
+ }) as () => void;
367
+ }
368
+ };
369
+ }
370
+ }
@@ -1,2 +1,4 @@
1
- export { COVER_jsonAbi, COVER_json } from './COVER_json';
2
- export type { COVER_jsonAbi as COVER_jsonAbiType, COVER_jsonContract } from './COVER_json';
1
+ export { CoverAbi, Cover } from './Cover';
2
+ export type { CoverAbi as CoverAbiType, CoverContract } from './Cover';
3
+ export { OwnedUpgradeabilityProxyAbi, OwnedUpgradeabilityProxy } from './OwnedUpgradeabilityProxy';
4
+ export type { OwnedUpgradeabilityProxyAbi as OwnedUpgradeabilityProxyAbiType, OwnedUpgradeabilityProxyContract } from './OwnedUpgradeabilityProxy';
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.COVER_json = exports.COVER_jsonAbi = void 0;
3
+ exports.OwnedUpgradeabilityProxy = exports.OwnedUpgradeabilityProxyAbi = exports.Cover = exports.CoverAbi = void 0;
4
4
  // Auto-generated exports for all contracts
5
- var COVER_json_1 = require("./COVER_json");
6
- Object.defineProperty(exports, "COVER_jsonAbi", { enumerable: true, get: function () { return COVER_json_1.COVER_jsonAbi; } });
7
- Object.defineProperty(exports, "COVER_json", { enumerable: true, get: function () { return COVER_json_1.COVER_json; } });
5
+ var Cover_1 = require("./Cover");
6
+ Object.defineProperty(exports, "CoverAbi", { enumerable: true, get: function () { return Cover_1.CoverAbi; } });
7
+ Object.defineProperty(exports, "Cover", { enumerable: true, get: function () { return Cover_1.Cover; } });
8
+ var OwnedUpgradeabilityProxy_1 = require("./OwnedUpgradeabilityProxy");
9
+ Object.defineProperty(exports, "OwnedUpgradeabilityProxyAbi", { enumerable: true, get: function () { return OwnedUpgradeabilityProxy_1.OwnedUpgradeabilityProxyAbi; } });
10
+ Object.defineProperty(exports, "OwnedUpgradeabilityProxy", { enumerable: true, get: function () { return OwnedUpgradeabilityProxy_1.OwnedUpgradeabilityProxy; } });
@@ -1,3 +1,5 @@
1
1
  // Auto-generated exports for all contracts
2
- export { COVER_jsonAbi, COVER_json } from './COVER_json';
3
- export type { COVER_jsonAbi as COVER_jsonAbiType, COVER_jsonContract } from './COVER_json';
2
+ export { CoverAbi, Cover } from './Cover';
3
+ export type { CoverAbi as CoverAbiType, CoverContract } from './Cover';
4
+ export { OwnedUpgradeabilityProxyAbi, OwnedUpgradeabilityProxy } from './OwnedUpgradeabilityProxy';
5
+ export type { OwnedUpgradeabilityProxyAbi as OwnedUpgradeabilityProxyAbiType, OwnedUpgradeabilityProxyContract } from './OwnedUpgradeabilityProxy';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gitmyabi/cover",
3
- "version": "1.0.0",
4
- "description": "Auto-generated TypeScript type bindings for COVER (build etherscan-cover-5d8d9f5b-1790622879929, commit c27dd1b, branch etherscan)",
3
+ "version": "1.0.1",
4
+ "description": "Auto-generated TypeScript type bindings for Cover (build etherscan-cover-cafeac0f-1794700022638, commit 3ab2755, 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/cover"
40
40
  },
41
41
  "branch": "etherscan",
42
- "shortHash": "c27dd1b"
42
+ "shortHash": "3ab2755"
43
43
  }