@gitmyabi/resilientoracle 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,487 @@
1
+ import type { Abi, Address, PublicClient, WalletClient, GetContractReturnType } from 'viem';
2
+ import { getContract } from 'viem';
3
+
4
+ /**
5
+ * OptimizedTransparentUpgradeableProxy_json ABI
6
+ *
7
+ * This ABI is typed using viem's type system for full type safety.
8
+ */
9
+ export const OptimizedTransparentUpgradeableProxy_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": "beacon",
57
+ "type": "address"
58
+ }
59
+ ],
60
+ "name": "BeaconUpgraded",
61
+ "type": "event"
62
+ },
63
+ {
64
+ "anonymous": false,
65
+ "inputs": [
66
+ {
67
+ "indexed": true,
68
+ "internalType": "address",
69
+ "name": "implementation",
70
+ "type": "address"
71
+ }
72
+ ],
73
+ "name": "Upgraded",
74
+ "type": "event"
75
+ },
76
+ {
77
+ "stateMutability": "payable",
78
+ "type": "fallback"
79
+ },
80
+ {
81
+ "inputs": [],
82
+ "name": "admin",
83
+ "outputs": [
84
+ {
85
+ "internalType": "address",
86
+ "name": "admin_",
87
+ "type": "address"
88
+ }
89
+ ],
90
+ "stateMutability": "nonpayable",
91
+ "type": "function"
92
+ },
93
+ {
94
+ "inputs": [],
95
+ "name": "implementation",
96
+ "outputs": [
97
+ {
98
+ "internalType": "address",
99
+ "name": "implementation_",
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 OptimizedTransparentUpgradeableProxy_json
145
+ */
146
+ export type OptimizedTransparentUpgradeableProxy_jsonAbi = typeof OptimizedTransparentUpgradeableProxy_jsonAbi;
147
+
148
+ /**
149
+ * Contract instance type for OptimizedTransparentUpgradeableProxy_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 OptimizedTransparentUpgradeableProxy_jsonContract = any;
154
+
155
+ /**
156
+ * OptimizedTransparentUpgradeableProxy_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 { OptimizedTransparentUpgradeableProxy_json } from 'OptimizedTransparentUpgradeableProxy_json';
165
+ *
166
+ * const publicClient = createPublicClient({ chain: mainnet, transport: http() });
167
+ * const walletClient = createWalletClient({ chain: mainnet, transport: http() });
168
+ *
169
+ * const contract = new OptimizedTransparentUpgradeableProxy_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 OptimizedTransparentUpgradeableProxy_json {
188
+ private contract: OptimizedTransparentUpgradeableProxy_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: OptimizedTransparentUpgradeableProxy_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(): OptimizedTransparentUpgradeableProxy_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
+ * implementation
252
+ * nonpayable
253
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
254
+ */
255
+ async implementation(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.implementation(options) as Promise<`0x${string}`>;
271
+ }
272
+
273
+ /**
274
+ * upgradeTo
275
+ * nonpayable
276
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
277
+ */
278
+ async upgradeTo(newImplementation: `0x${string}`, 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.upgradeTo([newImplementation] as const, options) as Promise<`0x${string}`>;
294
+ }
295
+
296
+ /**
297
+ * upgradeToAndCall
298
+ * payable
299
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
300
+ */
301
+ async upgradeToAndCall(newImplementation: `0x${string}`, data: `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.upgradeToAndCall([newImplementation, data] as const, options) as Promise<`0x${string}`>;
317
+ }
318
+
319
+
320
+
321
+ /**
322
+ * Simulate contract write operations (dry-run without sending transaction)
323
+ *
324
+ * @example
325
+ * const result = await contract.simulate.transfer('0x...', 1000n);
326
+ * console.log('Gas estimate:', result.request.gas);
327
+ * console.log('Would succeed:', result.result);
328
+ */
329
+ get simulate() {
330
+ const contract = this.contract;
331
+ if (!contract.simulate) {
332
+ throw new Error('Public client is required for simulation');
333
+ }
334
+ return {
335
+ /**
336
+ * Simulate admin
337
+ * Returns gas estimate and result without sending transaction
338
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
339
+ */
340
+ async admin(options?: {
341
+ accessList?: import('viem').AccessList;
342
+ authorizationList?: import('viem').AuthorizationList;
343
+ chain?: import('viem').Chain | null;
344
+ dataSuffix?: `0x${string}`;
345
+ gas?: bigint;
346
+ gasPrice?: bigint;
347
+ maxFeePerGas?: bigint;
348
+ maxPriorityFeePerGas?: bigint;
349
+ nonce?: number;
350
+ value?: bigint;
351
+ }): Promise<`0x${string}`> {
352
+ return contract.simulate.admin(options) as Promise<`0x${string}`>;
353
+ },
354
+ /**
355
+ * Simulate implementation
356
+ * Returns gas estimate and result without sending transaction
357
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
358
+ */
359
+ async implementation(options?: {
360
+ accessList?: import('viem').AccessList;
361
+ authorizationList?: import('viem').AuthorizationList;
362
+ chain?: import('viem').Chain | null;
363
+ dataSuffix?: `0x${string}`;
364
+ gas?: bigint;
365
+ gasPrice?: bigint;
366
+ maxFeePerGas?: bigint;
367
+ maxPriorityFeePerGas?: bigint;
368
+ nonce?: number;
369
+ value?: bigint;
370
+ }): Promise<`0x${string}`> {
371
+ return contract.simulate.implementation(options) as Promise<`0x${string}`>;
372
+ },
373
+ /**
374
+ * Simulate upgradeTo
375
+ * Returns gas estimate and result without sending transaction
376
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
377
+ */
378
+ async upgradeTo(newImplementation: `0x${string}`, options?: {
379
+ accessList?: import('viem').AccessList;
380
+ authorizationList?: import('viem').AuthorizationList;
381
+ chain?: import('viem').Chain | null;
382
+ dataSuffix?: `0x${string}`;
383
+ gas?: bigint;
384
+ gasPrice?: bigint;
385
+ maxFeePerGas?: bigint;
386
+ maxPriorityFeePerGas?: bigint;
387
+ nonce?: number;
388
+ value?: bigint;
389
+ }): Promise<void> {
390
+ return contract.simulate.upgradeTo([newImplementation] as const, options) as Promise<void>;
391
+ },
392
+ /**
393
+ * Simulate upgradeToAndCall
394
+ * Returns gas estimate and result without sending transaction
395
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
396
+ */
397
+ async upgradeToAndCall(newImplementation: `0x${string}`, data: `0x${string}`, options?: {
398
+ accessList?: import('viem').AccessList;
399
+ authorizationList?: import('viem').AuthorizationList;
400
+ chain?: import('viem').Chain | null;
401
+ dataSuffix?: `0x${string}`;
402
+ gas?: bigint;
403
+ gasPrice?: bigint;
404
+ maxFeePerGas?: bigint;
405
+ maxPriorityFeePerGas?: bigint;
406
+ nonce?: number;
407
+ value?: bigint;
408
+ }): Promise<void> {
409
+ return contract.simulate.upgradeToAndCall([newImplementation, data] as const, options) as Promise<void>;
410
+ }
411
+ };
412
+ }
413
+
414
+ /**
415
+ * Watch contract events
416
+ *
417
+ * @example
418
+ * // Watch all Transfer events
419
+ * const unwatch = contract.watch.Transfer((event) => {
420
+ * console.log('Transfer:', event);
421
+ * });
422
+ *
423
+ * // Stop watching
424
+ * unwatch();
425
+ */
426
+ get watch() {
427
+ return {
428
+ /**
429
+ * Watch AdminChanged events
430
+ * @param callback Function to call when event is emitted
431
+ * @param filter Optional filter for indexed parameters
432
+ * @returns Unwatch function to stop listening
433
+ */
434
+ AdminChanged: (callback: (event: { previousAdmin: `0x${string}`; newAdmin: `0x${string}` }) => void) => {
435
+ return this.publicClient.watchContractEvent({
436
+ address: this.contractAddress,
437
+ abi: OptimizedTransparentUpgradeableProxy_jsonAbi,
438
+ eventName: 'AdminChanged',
439
+
440
+ onLogs: (logs: any[]) => {
441
+ logs.forEach((log: any) => {
442
+ callback(log.args as any);
443
+ });
444
+ },
445
+ }) as () => void;
446
+ },
447
+ /**
448
+ * Watch BeaconUpgraded events
449
+ * @param callback Function to call when event is emitted
450
+ * @param filter Optional filter for indexed parameters
451
+ * @returns Unwatch function to stop listening
452
+ */
453
+ BeaconUpgraded: (callback: (event: { beacon: `0x${string}` }) => void, filter?: { beacon: `0x${string}` }) => {
454
+ return this.publicClient.watchContractEvent({
455
+ address: this.contractAddress,
456
+ abi: OptimizedTransparentUpgradeableProxy_jsonAbi,
457
+ eventName: 'BeaconUpgraded',
458
+ args: filter,
459
+ onLogs: (logs: any[]) => {
460
+ logs.forEach((log: any) => {
461
+ callback(log.args as any);
462
+ });
463
+ },
464
+ }) as () => void;
465
+ },
466
+ /**
467
+ * Watch Upgraded events
468
+ * @param callback Function to call when event is emitted
469
+ * @param filter Optional filter for indexed parameters
470
+ * @returns Unwatch function to stop listening
471
+ */
472
+ Upgraded: (callback: (event: { implementation: `0x${string}` }) => void, filter?: { implementation: `0x${string}` }) => {
473
+ return this.publicClient.watchContractEvent({
474
+ address: this.contractAddress,
475
+ abi: OptimizedTransparentUpgradeableProxy_jsonAbi,
476
+ eventName: 'Upgraded',
477
+ args: filter,
478
+ onLogs: (logs: any[]) => {
479
+ logs.forEach((log: any) => {
480
+ callback(log.args as any);
481
+ });
482
+ },
483
+ }) as () => void;
484
+ }
485
+ };
486
+ }
487
+ }