@gitmyabi/erc20predicate 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.
- package/README.md +108 -0
- package/contracts/ERC20PredicateProxy_json.d.ts +336 -0
- package/contracts/ERC20PredicateProxy_json.js +357 -0
- package/contracts/ERC20PredicateProxy_json.ts +457 -0
- package/contracts/ERC20Predicate_json.d.ts +760 -0
- package/contracts/ERC20Predicate_json.js +796 -0
- package/contracts/ERC20Predicate_json.ts +992 -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,457 @@
|
|
|
1
|
+
import type { Abi, Address, PublicClient, WalletClient, GetContractReturnType } from 'viem';
|
|
2
|
+
import { getContract } from 'viem';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ERC20PredicateProxy_json ABI
|
|
6
|
+
*
|
|
7
|
+
* This ABI is typed using viem's type system for full type safety.
|
|
8
|
+
*/
|
|
9
|
+
export const ERC20PredicateProxy_jsonAbi = [
|
|
10
|
+
{
|
|
11
|
+
"inputs": [
|
|
12
|
+
{
|
|
13
|
+
"internalType": "address",
|
|
14
|
+
"name": "_proxyTo",
|
|
15
|
+
"type": "address"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"stateMutability": "nonpayable",
|
|
19
|
+
"type": "constructor"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"anonymous": false,
|
|
23
|
+
"inputs": [
|
|
24
|
+
{
|
|
25
|
+
"indexed": false,
|
|
26
|
+
"internalType": "address",
|
|
27
|
+
"name": "_new",
|
|
28
|
+
"type": "address"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"indexed": false,
|
|
32
|
+
"internalType": "address",
|
|
33
|
+
"name": "_old",
|
|
34
|
+
"type": "address"
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"name": "ProxyOwnerUpdate",
|
|
38
|
+
"type": "event"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"anonymous": false,
|
|
42
|
+
"inputs": [
|
|
43
|
+
{
|
|
44
|
+
"indexed": true,
|
|
45
|
+
"internalType": "address",
|
|
46
|
+
"name": "_new",
|
|
47
|
+
"type": "address"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"indexed": true,
|
|
51
|
+
"internalType": "address",
|
|
52
|
+
"name": "_old",
|
|
53
|
+
"type": "address"
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
"name": "ProxyUpdated",
|
|
57
|
+
"type": "event"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"stateMutability": "payable",
|
|
61
|
+
"type": "fallback"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"inputs": [],
|
|
65
|
+
"name": "implementation",
|
|
66
|
+
"outputs": [
|
|
67
|
+
{
|
|
68
|
+
"internalType": "address",
|
|
69
|
+
"name": "",
|
|
70
|
+
"type": "address"
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
"stateMutability": "view",
|
|
74
|
+
"type": "function"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"inputs": [],
|
|
78
|
+
"name": "proxyOwner",
|
|
79
|
+
"outputs": [
|
|
80
|
+
{
|
|
81
|
+
"internalType": "address",
|
|
82
|
+
"name": "",
|
|
83
|
+
"type": "address"
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
"stateMutability": "view",
|
|
87
|
+
"type": "function"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"inputs": [],
|
|
91
|
+
"name": "proxyType",
|
|
92
|
+
"outputs": [
|
|
93
|
+
{
|
|
94
|
+
"internalType": "uint256",
|
|
95
|
+
"name": "proxyTypeId",
|
|
96
|
+
"type": "uint256"
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
"stateMutability": "pure",
|
|
100
|
+
"type": "function"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"inputs": [
|
|
104
|
+
{
|
|
105
|
+
"internalType": "address",
|
|
106
|
+
"name": "newOwner",
|
|
107
|
+
"type": "address"
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
"name": "transferProxyOwnership",
|
|
111
|
+
"outputs": [],
|
|
112
|
+
"stateMutability": "nonpayable",
|
|
113
|
+
"type": "function"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"inputs": [
|
|
117
|
+
{
|
|
118
|
+
"internalType": "address",
|
|
119
|
+
"name": "_newProxyTo",
|
|
120
|
+
"type": "address"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"internalType": "bytes",
|
|
124
|
+
"name": "data",
|
|
125
|
+
"type": "bytes"
|
|
126
|
+
}
|
|
127
|
+
],
|
|
128
|
+
"name": "updateAndCall",
|
|
129
|
+
"outputs": [],
|
|
130
|
+
"stateMutability": "payable",
|
|
131
|
+
"type": "function"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"inputs": [
|
|
135
|
+
{
|
|
136
|
+
"internalType": "address",
|
|
137
|
+
"name": "_newProxyTo",
|
|
138
|
+
"type": "address"
|
|
139
|
+
}
|
|
140
|
+
],
|
|
141
|
+
"name": "updateImplementation",
|
|
142
|
+
"outputs": [],
|
|
143
|
+
"stateMutability": "nonpayable",
|
|
144
|
+
"type": "function"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"stateMutability": "payable",
|
|
148
|
+
"type": "receive"
|
|
149
|
+
}
|
|
150
|
+
] as const satisfies Abi;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Type-safe ABI for ERC20PredicateProxy_json
|
|
154
|
+
*/
|
|
155
|
+
export type ERC20PredicateProxy_jsonAbi = typeof ERC20PredicateProxy_jsonAbi;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Contract instance type for ERC20PredicateProxy_json
|
|
159
|
+
*/
|
|
160
|
+
// Use any for contract type to avoid complex viem type issues
|
|
161
|
+
// The runtime behavior is type-safe through viem's ABI typing
|
|
162
|
+
export type ERC20PredicateProxy_jsonContract = any;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* ERC20PredicateProxy_json Contract Class
|
|
166
|
+
*
|
|
167
|
+
* Provides a class-based API similar to TypeChain for interacting with the contract.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* import { createPublicClient, createWalletClient, http } from 'viem';
|
|
172
|
+
* import { mainnet } from 'viem/chains';
|
|
173
|
+
* import { ERC20PredicateProxy_json } from 'ERC20PredicateProxy_json';
|
|
174
|
+
*
|
|
175
|
+
* const publicClient = createPublicClient({ chain: mainnet, transport: http() });
|
|
176
|
+
* const walletClient = createWalletClient({ chain: mainnet, transport: http() });
|
|
177
|
+
*
|
|
178
|
+
* const contract = new ERC20PredicateProxy_json('0x...', { publicClient, walletClient });
|
|
179
|
+
*
|
|
180
|
+
* // Read functions
|
|
181
|
+
* const result = await contract.balanceOf('0x...');
|
|
182
|
+
*
|
|
183
|
+
* // Write functions
|
|
184
|
+
* const hash = await contract.transfer('0x...', 1000n);
|
|
185
|
+
*
|
|
186
|
+
* // Simulate transactions (dry-run)
|
|
187
|
+
* const simulation = await contract.simulate.transfer('0x...', 1000n);
|
|
188
|
+
* console.log('Gas estimate:', simulation.request.gas);
|
|
189
|
+
*
|
|
190
|
+
* // Watch events
|
|
191
|
+
* const unwatch = contract.watch.Transfer((event) => {
|
|
192
|
+
* console.log('Transfer event:', event);
|
|
193
|
+
* });
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
export class ERC20PredicateProxy_json {
|
|
197
|
+
private contract: ERC20PredicateProxy_jsonContract;
|
|
198
|
+
private contractAddress: Address;
|
|
199
|
+
private publicClient: PublicClient;
|
|
200
|
+
|
|
201
|
+
constructor(
|
|
202
|
+
address: Address,
|
|
203
|
+
clients: {
|
|
204
|
+
publicClient: PublicClient;
|
|
205
|
+
walletClient?: WalletClient;
|
|
206
|
+
}
|
|
207
|
+
) {
|
|
208
|
+
this.contractAddress = address;
|
|
209
|
+
this.publicClient = clients.publicClient;
|
|
210
|
+
this.contract = getContract({
|
|
211
|
+
address,
|
|
212
|
+
abi: ERC20PredicateProxy_jsonAbi,
|
|
213
|
+
client: {
|
|
214
|
+
public: clients.publicClient,
|
|
215
|
+
wallet: clients.walletClient,
|
|
216
|
+
},
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Get the contract address
|
|
222
|
+
*/
|
|
223
|
+
get address(): Address {
|
|
224
|
+
return this.contractAddress;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Get the underlying viem contract instance
|
|
229
|
+
*/
|
|
230
|
+
getContract(): ERC20PredicateProxy_jsonContract {
|
|
231
|
+
return this.contract;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* implementation
|
|
236
|
+
* view
|
|
237
|
+
*/
|
|
238
|
+
async implementation(): Promise<`0x${string}`> {
|
|
239
|
+
return this.contract.read.implementation() as Promise<`0x${string}`>;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* proxyOwner
|
|
244
|
+
* view
|
|
245
|
+
*/
|
|
246
|
+
async proxyOwner(): Promise<`0x${string}`> {
|
|
247
|
+
return this.contract.read.proxyOwner() as Promise<`0x${string}`>;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* proxyType
|
|
252
|
+
* pure
|
|
253
|
+
*/
|
|
254
|
+
async proxyType(): Promise<bigint> {
|
|
255
|
+
return this.contract.read.proxyType() as Promise<bigint>;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* transferProxyOwnership
|
|
260
|
+
* nonpayable
|
|
261
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
262
|
+
*/
|
|
263
|
+
async transferProxyOwnership(newOwner: `0x${string}`, options?: {
|
|
264
|
+
accessList?: import('viem').AccessList;
|
|
265
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
266
|
+
chain?: import('viem').Chain | null;
|
|
267
|
+
dataSuffix?: `0x${string}`;
|
|
268
|
+
gas?: bigint;
|
|
269
|
+
gasPrice?: bigint;
|
|
270
|
+
maxFeePerGas?: bigint;
|
|
271
|
+
maxPriorityFeePerGas?: bigint;
|
|
272
|
+
nonce?: number;
|
|
273
|
+
value?: bigint;
|
|
274
|
+
}): Promise<`0x${string}`> {
|
|
275
|
+
if (!this.contract.write) {
|
|
276
|
+
throw new Error('Wallet client is required for write operations');
|
|
277
|
+
}
|
|
278
|
+
return this.contract.write.transferProxyOwnership([newOwner] as const, options) as Promise<`0x${string}`>;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* updateAndCall
|
|
283
|
+
* payable
|
|
284
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
285
|
+
*/
|
|
286
|
+
async updateAndCall(_newProxyTo: `0x${string}`, data: `0x${string}`, options?: {
|
|
287
|
+
accessList?: import('viem').AccessList;
|
|
288
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
289
|
+
chain?: import('viem').Chain | null;
|
|
290
|
+
dataSuffix?: `0x${string}`;
|
|
291
|
+
gas?: bigint;
|
|
292
|
+
gasPrice?: bigint;
|
|
293
|
+
maxFeePerGas?: bigint;
|
|
294
|
+
maxPriorityFeePerGas?: bigint;
|
|
295
|
+
nonce?: number;
|
|
296
|
+
value?: bigint;
|
|
297
|
+
}): Promise<`0x${string}`> {
|
|
298
|
+
if (!this.contract.write) {
|
|
299
|
+
throw new Error('Wallet client is required for write operations');
|
|
300
|
+
}
|
|
301
|
+
return this.contract.write.updateAndCall([_newProxyTo, data] as const, options) as Promise<`0x${string}`>;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* updateImplementation
|
|
306
|
+
* nonpayable
|
|
307
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
308
|
+
*/
|
|
309
|
+
async updateImplementation(_newProxyTo: `0x${string}`, options?: {
|
|
310
|
+
accessList?: import('viem').AccessList;
|
|
311
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
312
|
+
chain?: import('viem').Chain | null;
|
|
313
|
+
dataSuffix?: `0x${string}`;
|
|
314
|
+
gas?: bigint;
|
|
315
|
+
gasPrice?: bigint;
|
|
316
|
+
maxFeePerGas?: bigint;
|
|
317
|
+
maxPriorityFeePerGas?: bigint;
|
|
318
|
+
nonce?: number;
|
|
319
|
+
value?: bigint;
|
|
320
|
+
}): Promise<`0x${string}`> {
|
|
321
|
+
if (!this.contract.write) {
|
|
322
|
+
throw new Error('Wallet client is required for write operations');
|
|
323
|
+
}
|
|
324
|
+
return this.contract.write.updateImplementation([_newProxyTo] as const, options) as Promise<`0x${string}`>;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Simulate contract write operations (dry-run without sending transaction)
|
|
331
|
+
*
|
|
332
|
+
* @example
|
|
333
|
+
* const result = await contract.simulate.transfer('0x...', 1000n);
|
|
334
|
+
* console.log('Gas estimate:', result.request.gas);
|
|
335
|
+
* console.log('Would succeed:', result.result);
|
|
336
|
+
*/
|
|
337
|
+
get simulate() {
|
|
338
|
+
const contract = this.contract;
|
|
339
|
+
if (!contract.simulate) {
|
|
340
|
+
throw new Error('Public client is required for simulation');
|
|
341
|
+
}
|
|
342
|
+
return {
|
|
343
|
+
/**
|
|
344
|
+
* Simulate transferProxyOwnership
|
|
345
|
+
* Returns gas estimate and result without sending transaction
|
|
346
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
347
|
+
*/
|
|
348
|
+
async transferProxyOwnership(newOwner: `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<void> {
|
|
360
|
+
return contract.simulate.transferProxyOwnership([newOwner] as const, options) as Promise<void>;
|
|
361
|
+
},
|
|
362
|
+
/**
|
|
363
|
+
* Simulate updateAndCall
|
|
364
|
+
* Returns gas estimate and result without sending transaction
|
|
365
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
366
|
+
*/
|
|
367
|
+
async updateAndCall(_newProxyTo: `0x${string}`, data: `0x${string}`, options?: {
|
|
368
|
+
accessList?: import('viem').AccessList;
|
|
369
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
370
|
+
chain?: import('viem').Chain | null;
|
|
371
|
+
dataSuffix?: `0x${string}`;
|
|
372
|
+
gas?: bigint;
|
|
373
|
+
gasPrice?: bigint;
|
|
374
|
+
maxFeePerGas?: bigint;
|
|
375
|
+
maxPriorityFeePerGas?: bigint;
|
|
376
|
+
nonce?: number;
|
|
377
|
+
value?: bigint;
|
|
378
|
+
}): Promise<void> {
|
|
379
|
+
return contract.simulate.updateAndCall([_newProxyTo, data] as const, options) as Promise<void>;
|
|
380
|
+
},
|
|
381
|
+
/**
|
|
382
|
+
* Simulate updateImplementation
|
|
383
|
+
* Returns gas estimate and result without sending transaction
|
|
384
|
+
* @param options Optional transaction parameters (value, gas, nonce, etc.)
|
|
385
|
+
*/
|
|
386
|
+
async updateImplementation(_newProxyTo: `0x${string}`, options?: {
|
|
387
|
+
accessList?: import('viem').AccessList;
|
|
388
|
+
authorizationList?: import('viem').AuthorizationList;
|
|
389
|
+
chain?: import('viem').Chain | null;
|
|
390
|
+
dataSuffix?: `0x${string}`;
|
|
391
|
+
gas?: bigint;
|
|
392
|
+
gasPrice?: bigint;
|
|
393
|
+
maxFeePerGas?: bigint;
|
|
394
|
+
maxPriorityFeePerGas?: bigint;
|
|
395
|
+
nonce?: number;
|
|
396
|
+
value?: bigint;
|
|
397
|
+
}): Promise<void> {
|
|
398
|
+
return contract.simulate.updateImplementation([_newProxyTo] as const, options) as Promise<void>;
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Watch contract events
|
|
405
|
+
*
|
|
406
|
+
* @example
|
|
407
|
+
* // Watch all Transfer events
|
|
408
|
+
* const unwatch = contract.watch.Transfer((event) => {
|
|
409
|
+
* console.log('Transfer:', event);
|
|
410
|
+
* });
|
|
411
|
+
*
|
|
412
|
+
* // Stop watching
|
|
413
|
+
* unwatch();
|
|
414
|
+
*/
|
|
415
|
+
get watch() {
|
|
416
|
+
return {
|
|
417
|
+
/**
|
|
418
|
+
* Watch ProxyOwnerUpdate events
|
|
419
|
+
* @param callback Function to call when event is emitted
|
|
420
|
+
* @param filter Optional filter for indexed parameters
|
|
421
|
+
* @returns Unwatch function to stop listening
|
|
422
|
+
*/
|
|
423
|
+
ProxyOwnerUpdate: (callback: (event: { _new: `0x${string}`; _old: `0x${string}` }) => void) => {
|
|
424
|
+
return this.publicClient.watchContractEvent({
|
|
425
|
+
address: this.contractAddress,
|
|
426
|
+
abi: ERC20PredicateProxy_jsonAbi,
|
|
427
|
+
eventName: 'ProxyOwnerUpdate',
|
|
428
|
+
|
|
429
|
+
onLogs: (logs: any[]) => {
|
|
430
|
+
logs.forEach((log: any) => {
|
|
431
|
+
callback(log.args as any);
|
|
432
|
+
});
|
|
433
|
+
},
|
|
434
|
+
}) as () => void;
|
|
435
|
+
},
|
|
436
|
+
/**
|
|
437
|
+
* Watch ProxyUpdated events
|
|
438
|
+
* @param callback Function to call when event is emitted
|
|
439
|
+
* @param filter Optional filter for indexed parameters
|
|
440
|
+
* @returns Unwatch function to stop listening
|
|
441
|
+
*/
|
|
442
|
+
ProxyUpdated: (callback: (event: { _new: `0x${string}`; _old: `0x${string}` }) => void, filter?: { _new: `0x${string}`; _old: `0x${string}` }) => {
|
|
443
|
+
return this.publicClient.watchContractEvent({
|
|
444
|
+
address: this.contractAddress,
|
|
445
|
+
abi: ERC20PredicateProxy_jsonAbi,
|
|
446
|
+
eventName: 'ProxyUpdated',
|
|
447
|
+
args: filter,
|
|
448
|
+
onLogs: (logs: any[]) => {
|
|
449
|
+
logs.forEach((log: any) => {
|
|
450
|
+
callback(log.args as any);
|
|
451
|
+
});
|
|
452
|
+
},
|
|
453
|
+
}) as () => void;
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
}
|