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