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