@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,397 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InitializableAdminUpgradeabilityProxy = exports.InitializableAdminUpgradeabilityProxyAbi = void 0;
4
+ const viem_1 = require("viem");
5
+ /**
6
+ * InitializableAdminUpgradeabilityProxy ABI
7
+ *
8
+ * This ABI is typed using viem's type system for full type safety.
9
+ */
10
+ exports.InitializableAdminUpgradeabilityProxyAbi = [
11
+ {
12
+ "anonymous": false,
13
+ "inputs": [
14
+ {
15
+ "indexed": false,
16
+ "internalType": "address",
17
+ "name": "previousAdmin",
18
+ "type": "address"
19
+ },
20
+ {
21
+ "indexed": false,
22
+ "internalType": "address",
23
+ "name": "newAdmin",
24
+ "type": "address"
25
+ }
26
+ ],
27
+ "name": "AdminChanged",
28
+ "type": "event"
29
+ },
30
+ {
31
+ "anonymous": false,
32
+ "inputs": [
33
+ {
34
+ "indexed": true,
35
+ "internalType": "address",
36
+ "name": "implementation",
37
+ "type": "address"
38
+ }
39
+ ],
40
+ "name": "Upgraded",
41
+ "type": "event"
42
+ },
43
+ {
44
+ "stateMutability": "payable",
45
+ "type": "fallback"
46
+ },
47
+ {
48
+ "inputs": [],
49
+ "name": "admin",
50
+ "outputs": [
51
+ {
52
+ "internalType": "address",
53
+ "name": "",
54
+ "type": "address"
55
+ }
56
+ ],
57
+ "stateMutability": "nonpayable",
58
+ "type": "function"
59
+ },
60
+ {
61
+ "inputs": [
62
+ {
63
+ "internalType": "address",
64
+ "name": "newAdmin",
65
+ "type": "address"
66
+ }
67
+ ],
68
+ "name": "changeAdmin",
69
+ "outputs": [],
70
+ "stateMutability": "nonpayable",
71
+ "type": "function"
72
+ },
73
+ {
74
+ "inputs": [],
75
+ "name": "implementation",
76
+ "outputs": [
77
+ {
78
+ "internalType": "address",
79
+ "name": "",
80
+ "type": "address"
81
+ }
82
+ ],
83
+ "stateMutability": "nonpayable",
84
+ "type": "function"
85
+ },
86
+ {
87
+ "inputs": [
88
+ {
89
+ "internalType": "address",
90
+ "name": "logic",
91
+ "type": "address"
92
+ },
93
+ {
94
+ "internalType": "address",
95
+ "name": "admin",
96
+ "type": "address"
97
+ },
98
+ {
99
+ "internalType": "bytes",
100
+ "name": "data",
101
+ "type": "bytes"
102
+ }
103
+ ],
104
+ "name": "initialize",
105
+ "outputs": [],
106
+ "stateMutability": "payable",
107
+ "type": "function"
108
+ },
109
+ {
110
+ "inputs": [
111
+ {
112
+ "internalType": "address",
113
+ "name": "_logic",
114
+ "type": "address"
115
+ },
116
+ {
117
+ "internalType": "bytes",
118
+ "name": "_data",
119
+ "type": "bytes"
120
+ }
121
+ ],
122
+ "name": "initialize",
123
+ "outputs": [],
124
+ "stateMutability": "payable",
125
+ "type": "function"
126
+ },
127
+ {
128
+ "inputs": [
129
+ {
130
+ "internalType": "address",
131
+ "name": "newImplementation",
132
+ "type": "address"
133
+ }
134
+ ],
135
+ "name": "upgradeTo",
136
+ "outputs": [],
137
+ "stateMutability": "nonpayable",
138
+ "type": "function"
139
+ },
140
+ {
141
+ "inputs": [
142
+ {
143
+ "internalType": "address",
144
+ "name": "newImplementation",
145
+ "type": "address"
146
+ },
147
+ {
148
+ "internalType": "bytes",
149
+ "name": "data",
150
+ "type": "bytes"
151
+ }
152
+ ],
153
+ "name": "upgradeToAndCall",
154
+ "outputs": [],
155
+ "stateMutability": "payable",
156
+ "type": "function"
157
+ }
158
+ ];
159
+ /**
160
+ * InitializableAdminUpgradeabilityProxy Contract Class
161
+ *
162
+ * Provides a class-based API similar to TypeChain for interacting with the contract.
163
+ *
164
+ * @example
165
+ * ```typescript
166
+ * import { createPublicClient, createWalletClient, http } from 'viem';
167
+ * import { mainnet } from 'viem/chains';
168
+ * import { InitializableAdminUpgradeabilityProxy } from 'InitializableAdminUpgradeabilityProxy';
169
+ *
170
+ * const publicClient = createPublicClient({ chain: mainnet, transport: http() });
171
+ * const walletClient = createWalletClient({ chain: mainnet, transport: http() });
172
+ *
173
+ * const contract = new InitializableAdminUpgradeabilityProxy('0x...', { publicClient, walletClient });
174
+ *
175
+ * // Read functions
176
+ * const result = await contract.balanceOf('0x...');
177
+ *
178
+ * // Write functions
179
+ * const hash = await contract.transfer('0x...', 1000n);
180
+ *
181
+ * // Simulate transactions (dry-run)
182
+ * const simulation = await contract.simulate.transfer('0x...', 1000n);
183
+ * console.log('Gas estimate:', simulation.request.gas);
184
+ *
185
+ * // Watch events
186
+ * const unwatch = contract.watch.Transfer((event) => {
187
+ * console.log('Transfer event:', event);
188
+ * });
189
+ * ```
190
+ */
191
+ class InitializableAdminUpgradeabilityProxy {
192
+ constructor(address, clients) {
193
+ this.contractAddress = address;
194
+ this.publicClient = clients.publicClient;
195
+ this.contract = (0, viem_1.getContract)({
196
+ address,
197
+ abi: exports.InitializableAdminUpgradeabilityProxyAbi,
198
+ client: {
199
+ public: clients.publicClient,
200
+ wallet: clients.walletClient,
201
+ },
202
+ });
203
+ }
204
+ /**
205
+ * Get the contract address
206
+ */
207
+ get address() {
208
+ return this.contractAddress;
209
+ }
210
+ /**
211
+ * Get the underlying viem contract instance.
212
+ */
213
+ getContract() {
214
+ return this.contract;
215
+ }
216
+ // No read functions
217
+ /**
218
+ * admin
219
+ * nonpayable
220
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
221
+ */
222
+ async admin(options) {
223
+ if (!this.contract.write) {
224
+ throw new Error('Wallet client is required for write operations');
225
+ }
226
+ return this.contract.write.admin(options);
227
+ }
228
+ /**
229
+ * changeAdmin
230
+ * nonpayable
231
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
232
+ */
233
+ async changeAdmin(newAdmin, options) {
234
+ if (!this.contract.write) {
235
+ throw new Error('Wallet client is required for write operations');
236
+ }
237
+ return this.contract.write.changeAdmin([newAdmin], options);
238
+ }
239
+ /**
240
+ * implementation
241
+ * nonpayable
242
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
243
+ */
244
+ async implementation(options) {
245
+ if (!this.contract.write) {
246
+ throw new Error('Wallet client is required for write operations');
247
+ }
248
+ return this.contract.write.implementation(options);
249
+ }
250
+ async initialize(...args) {
251
+ if (!this.contract.write) {
252
+ throw new Error('Wallet client is required for write operations');
253
+ }
254
+ return this.contract.write.initialize(args);
255
+ }
256
+ /**
257
+ * upgradeTo
258
+ * nonpayable
259
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
260
+ */
261
+ async upgradeTo(newImplementation, options) {
262
+ if (!this.contract.write) {
263
+ throw new Error('Wallet client is required for write operations');
264
+ }
265
+ return this.contract.write.upgradeTo([newImplementation], options);
266
+ }
267
+ /**
268
+ * upgradeToAndCall
269
+ * payable
270
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
271
+ */
272
+ async upgradeToAndCall(newImplementation, data, options) {
273
+ if (!this.contract.write) {
274
+ throw new Error('Wallet client is required for write operations');
275
+ }
276
+ return this.contract.write.upgradeToAndCall([newImplementation, data], options);
277
+ }
278
+ /**
279
+ * Simulate contract write operations (dry-run without sending transaction)
280
+ *
281
+ * @example
282
+ * const result = await contract.simulate.transfer('0x...', 1000n);
283
+ * console.log('Gas estimate:', result.request.gas);
284
+ * console.log('Would succeed:', result.result);
285
+ */
286
+ get simulate() {
287
+ const contract = this.contract;
288
+ if (!contract.simulate) {
289
+ throw new Error('Public client is required for simulation');
290
+ }
291
+ return {
292
+ /**
293
+ * Simulate admin
294
+ * Returns gas estimate and result without sending transaction
295
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
296
+ */
297
+ async admin(options) {
298
+ return contract.simulate.admin(options);
299
+ },
300
+ /**
301
+ * Simulate changeAdmin
302
+ * Returns gas estimate and result without sending transaction
303
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
304
+ */
305
+ async changeAdmin(newAdmin, options) {
306
+ return contract.simulate.changeAdmin([newAdmin], options);
307
+ },
308
+ /**
309
+ * Simulate implementation
310
+ * Returns gas estimate and result without sending transaction
311
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
312
+ */
313
+ async implementation(options) {
314
+ return contract.simulate.implementation(options);
315
+ },
316
+ /**
317
+ * Simulate initialize
318
+ * Returns gas estimate and result without sending transaction
319
+ * Supports multiple overloads: (address, address, bytes), (address, bytes)
320
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
321
+ */
322
+ async initialize(...args) {
323
+ return contract.simulate.initialize(args);
324
+ },
325
+ /**
326
+ * Simulate upgradeTo
327
+ * Returns gas estimate and result without sending transaction
328
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
329
+ */
330
+ async upgradeTo(newImplementation, options) {
331
+ return contract.simulate.upgradeTo([newImplementation], options);
332
+ },
333
+ /**
334
+ * Simulate upgradeToAndCall
335
+ * Returns gas estimate and result without sending transaction
336
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
337
+ */
338
+ async upgradeToAndCall(newImplementation, data, options) {
339
+ return contract.simulate.upgradeToAndCall([newImplementation, data], options);
340
+ }
341
+ };
342
+ }
343
+ /**
344
+ * Watch contract events
345
+ *
346
+ * @example
347
+ * // Watch all Transfer events
348
+ * const unwatch = contract.watch.Transfer((event) => {
349
+ * console.log('Transfer:', event);
350
+ * });
351
+ *
352
+ * // Stop watching
353
+ * unwatch();
354
+ */
355
+ get watch() {
356
+ return {
357
+ /**
358
+ * Watch AdminChanged events
359
+ * @param callback Function to call when event is emitted
360
+ * @param filter Optional filter for indexed parameters
361
+ * @returns Unwatch function to stop listening
362
+ */
363
+ AdminChanged: (callback) => {
364
+ return this.publicClient.watchContractEvent({
365
+ address: this.contractAddress,
366
+ abi: exports.InitializableAdminUpgradeabilityProxyAbi,
367
+ eventName: 'AdminChanged',
368
+ onLogs: (logs) => {
369
+ logs.forEach((log) => {
370
+ callback(log.args);
371
+ });
372
+ },
373
+ });
374
+ },
375
+ /**
376
+ * Watch Upgraded events
377
+ * @param callback Function to call when event is emitted
378
+ * @param filter Optional filter for indexed parameters
379
+ * @returns Unwatch function to stop listening
380
+ */
381
+ Upgraded: (callback, filter) => {
382
+ return this.publicClient.watchContractEvent({
383
+ address: this.contractAddress,
384
+ abi: exports.InitializableAdminUpgradeabilityProxyAbi,
385
+ eventName: 'Upgraded',
386
+ args: filter,
387
+ onLogs: (logs) => {
388
+ logs.forEach((log) => {
389
+ callback(log.args);
390
+ });
391
+ },
392
+ });
393
+ }
394
+ };
395
+ }
396
+ }
397
+ exports.InitializableAdminUpgradeabilityProxy = InitializableAdminUpgradeabilityProxy;