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