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