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