@gitmyabi/vault 1.0.3 → 1.0.5

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