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