@gitmyabi/basewallet 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,596 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseWallet_json = exports.BaseWallet_jsonAbi = void 0;
4
+ const viem_1 = require("viem");
5
+ /**
6
+ * BaseWallet_json ABI
7
+ *
8
+ * This ABI is typed using viem's type system for full type safety.
9
+ */
10
+ exports.BaseWallet_jsonAbi = [
11
+ {
12
+ "constant": false,
13
+ "inputs": [
14
+ {
15
+ "name": "_newOwner",
16
+ "type": "address"
17
+ }
18
+ ],
19
+ "name": "setOwner",
20
+ "outputs": [],
21
+ "payable": false,
22
+ "stateMutability": "nonpayable",
23
+ "type": "function"
24
+ },
25
+ {
26
+ "constant": false,
27
+ "inputs": [
28
+ {
29
+ "name": "_module",
30
+ "type": "address"
31
+ },
32
+ {
33
+ "name": "_method",
34
+ "type": "bytes4"
35
+ }
36
+ ],
37
+ "name": "enableStaticCall",
38
+ "outputs": [],
39
+ "payable": false,
40
+ "stateMutability": "nonpayable",
41
+ "type": "function"
42
+ },
43
+ {
44
+ "constant": false,
45
+ "inputs": [
46
+ {
47
+ "name": "_module",
48
+ "type": "address"
49
+ },
50
+ {
51
+ "name": "_value",
52
+ "type": "bool"
53
+ }
54
+ ],
55
+ "name": "authoriseModule",
56
+ "outputs": [],
57
+ "payable": false,
58
+ "stateMutability": "nonpayable",
59
+ "type": "function"
60
+ },
61
+ {
62
+ "constant": false,
63
+ "inputs": [
64
+ {
65
+ "name": "_owner",
66
+ "type": "address"
67
+ },
68
+ {
69
+ "name": "_modules",
70
+ "type": "address[]"
71
+ }
72
+ ],
73
+ "name": "init",
74
+ "outputs": [],
75
+ "payable": false,
76
+ "stateMutability": "nonpayable",
77
+ "type": "function"
78
+ },
79
+ {
80
+ "constant": true,
81
+ "inputs": [],
82
+ "name": "implementation",
83
+ "outputs": [
84
+ {
85
+ "name": "",
86
+ "type": "address"
87
+ }
88
+ ],
89
+ "payable": false,
90
+ "stateMutability": "view",
91
+ "type": "function"
92
+ },
93
+ {
94
+ "constant": true,
95
+ "inputs": [
96
+ {
97
+ "name": "",
98
+ "type": "bytes4"
99
+ }
100
+ ],
101
+ "name": "enabled",
102
+ "outputs": [
103
+ {
104
+ "name": "",
105
+ "type": "address"
106
+ }
107
+ ],
108
+ "payable": false,
109
+ "stateMutability": "view",
110
+ "type": "function"
111
+ },
112
+ {
113
+ "constant": true,
114
+ "inputs": [],
115
+ "name": "owner",
116
+ "outputs": [
117
+ {
118
+ "name": "",
119
+ "type": "address"
120
+ }
121
+ ],
122
+ "payable": false,
123
+ "stateMutability": "view",
124
+ "type": "function"
125
+ },
126
+ {
127
+ "constant": false,
128
+ "inputs": [
129
+ {
130
+ "name": "_target",
131
+ "type": "address"
132
+ },
133
+ {
134
+ "name": "_value",
135
+ "type": "uint256"
136
+ },
137
+ {
138
+ "name": "_data",
139
+ "type": "bytes"
140
+ }
141
+ ],
142
+ "name": "invoke",
143
+ "outputs": [],
144
+ "payable": false,
145
+ "stateMutability": "nonpayable",
146
+ "type": "function"
147
+ },
148
+ {
149
+ "constant": true,
150
+ "inputs": [
151
+ {
152
+ "name": "",
153
+ "type": "address"
154
+ }
155
+ ],
156
+ "name": "authorised",
157
+ "outputs": [
158
+ {
159
+ "name": "",
160
+ "type": "bool"
161
+ }
162
+ ],
163
+ "payable": false,
164
+ "stateMutability": "view",
165
+ "type": "function"
166
+ },
167
+ {
168
+ "constant": true,
169
+ "inputs": [],
170
+ "name": "modules",
171
+ "outputs": [
172
+ {
173
+ "name": "",
174
+ "type": "uint256"
175
+ }
176
+ ],
177
+ "payable": false,
178
+ "stateMutability": "view",
179
+ "type": "function"
180
+ },
181
+ {
182
+ "payable": true,
183
+ "stateMutability": "payable",
184
+ "type": "fallback"
185
+ },
186
+ {
187
+ "anonymous": false,
188
+ "inputs": [
189
+ {
190
+ "indexed": true,
191
+ "name": "module",
192
+ "type": "address"
193
+ },
194
+ {
195
+ "indexed": false,
196
+ "name": "value",
197
+ "type": "bool"
198
+ }
199
+ ],
200
+ "name": "AuthorisedModule",
201
+ "type": "event"
202
+ },
203
+ {
204
+ "anonymous": false,
205
+ "inputs": [
206
+ {
207
+ "indexed": true,
208
+ "name": "module",
209
+ "type": "address"
210
+ },
211
+ {
212
+ "indexed": true,
213
+ "name": "method",
214
+ "type": "bytes4"
215
+ }
216
+ ],
217
+ "name": "EnabledStaticCall",
218
+ "type": "event"
219
+ },
220
+ {
221
+ "anonymous": false,
222
+ "inputs": [
223
+ {
224
+ "indexed": true,
225
+ "name": "module",
226
+ "type": "address"
227
+ },
228
+ {
229
+ "indexed": true,
230
+ "name": "target",
231
+ "type": "address"
232
+ },
233
+ {
234
+ "indexed": true,
235
+ "name": "value",
236
+ "type": "uint256"
237
+ },
238
+ {
239
+ "indexed": false,
240
+ "name": "data",
241
+ "type": "bytes"
242
+ }
243
+ ],
244
+ "name": "Invoked",
245
+ "type": "event"
246
+ },
247
+ {
248
+ "anonymous": false,
249
+ "inputs": [
250
+ {
251
+ "indexed": true,
252
+ "name": "value",
253
+ "type": "uint256"
254
+ },
255
+ {
256
+ "indexed": true,
257
+ "name": "sender",
258
+ "type": "address"
259
+ },
260
+ {
261
+ "indexed": false,
262
+ "name": "data",
263
+ "type": "bytes"
264
+ }
265
+ ],
266
+ "name": "Received",
267
+ "type": "event"
268
+ },
269
+ {
270
+ "anonymous": false,
271
+ "inputs": [
272
+ {
273
+ "indexed": false,
274
+ "name": "owner",
275
+ "type": "address"
276
+ }
277
+ ],
278
+ "name": "OwnerChanged",
279
+ "type": "event"
280
+ }
281
+ ];
282
+ /**
283
+ * BaseWallet_json Contract Class
284
+ *
285
+ * Provides a class-based API similar to TypeChain for interacting with the contract.
286
+ *
287
+ * @example
288
+ * ```typescript
289
+ * import { createPublicClient, createWalletClient, http } from 'viem';
290
+ * import { mainnet } from 'viem/chains';
291
+ * import { BaseWallet_json } from 'BaseWallet_json';
292
+ *
293
+ * const publicClient = createPublicClient({ chain: mainnet, transport: http() });
294
+ * const walletClient = createWalletClient({ chain: mainnet, transport: http() });
295
+ *
296
+ * const contract = new BaseWallet_json('0x...', { publicClient, walletClient });
297
+ *
298
+ * // Read functions
299
+ * const result = await contract.balanceOf('0x...');
300
+ *
301
+ * // Write functions
302
+ * const hash = await contract.transfer('0x...', 1000n);
303
+ *
304
+ * // Simulate transactions (dry-run)
305
+ * const simulation = await contract.simulate.transfer('0x...', 1000n);
306
+ * console.log('Gas estimate:', simulation.request.gas);
307
+ *
308
+ * // Watch events
309
+ * const unwatch = contract.watch.Transfer((event) => {
310
+ * console.log('Transfer event:', event);
311
+ * });
312
+ * ```
313
+ */
314
+ class BaseWallet_json {
315
+ constructor(address, clients) {
316
+ this.contractAddress = address;
317
+ this.publicClient = clients.publicClient;
318
+ this.contract = (0, viem_1.getContract)({
319
+ address,
320
+ abi: exports.BaseWallet_jsonAbi,
321
+ client: {
322
+ public: clients.publicClient,
323
+ wallet: clients.walletClient,
324
+ },
325
+ });
326
+ }
327
+ /**
328
+ * Get the contract address
329
+ */
330
+ get address() {
331
+ return this.contractAddress;
332
+ }
333
+ /**
334
+ * Get the underlying viem contract instance
335
+ */
336
+ getContract() {
337
+ return this.contract;
338
+ }
339
+ /**
340
+ * implementation
341
+ * view
342
+ */
343
+ async implementation() {
344
+ return this.contract.read.implementation();
345
+ }
346
+ /**
347
+ * enabled
348
+ * view
349
+ */
350
+ async enabled(arg0) {
351
+ return this.contract.read.enabled([arg0]);
352
+ }
353
+ /**
354
+ * owner
355
+ * view
356
+ */
357
+ async owner() {
358
+ return this.contract.read.owner();
359
+ }
360
+ /**
361
+ * authorised
362
+ * view
363
+ */
364
+ async authorised(arg0) {
365
+ return this.contract.read.authorised([arg0]);
366
+ }
367
+ /**
368
+ * modules
369
+ * view
370
+ */
371
+ async modules() {
372
+ return this.contract.read.modules();
373
+ }
374
+ /**
375
+ * setOwner
376
+ * nonpayable
377
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
378
+ */
379
+ async setOwner(_newOwner, options) {
380
+ if (!this.contract.write) {
381
+ throw new Error('Wallet client is required for write operations');
382
+ }
383
+ return this.contract.write.setOwner([_newOwner], options);
384
+ }
385
+ /**
386
+ * enableStaticCall
387
+ * nonpayable
388
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
389
+ */
390
+ async enableStaticCall(_module, _method, options) {
391
+ if (!this.contract.write) {
392
+ throw new Error('Wallet client is required for write operations');
393
+ }
394
+ return this.contract.write.enableStaticCall([_module, _method], options);
395
+ }
396
+ /**
397
+ * authoriseModule
398
+ * nonpayable
399
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
400
+ */
401
+ async authoriseModule(_module, _value, options) {
402
+ if (!this.contract.write) {
403
+ throw new Error('Wallet client is required for write operations');
404
+ }
405
+ return this.contract.write.authoriseModule([_module, _value], options);
406
+ }
407
+ /**
408
+ * init
409
+ * nonpayable
410
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
411
+ */
412
+ async init(_owner, _modules, options) {
413
+ if (!this.contract.write) {
414
+ throw new Error('Wallet client is required for write operations');
415
+ }
416
+ return this.contract.write.init([_owner, _modules], options);
417
+ }
418
+ /**
419
+ * invoke
420
+ * nonpayable
421
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
422
+ */
423
+ async invoke(_target, _value, _data, options) {
424
+ if (!this.contract.write) {
425
+ throw new Error('Wallet client is required for write operations');
426
+ }
427
+ return this.contract.write.invoke([_target, _value, _data], options);
428
+ }
429
+ /**
430
+ * Simulate contract write operations (dry-run without sending transaction)
431
+ *
432
+ * @example
433
+ * const result = await contract.simulate.transfer('0x...', 1000n);
434
+ * console.log('Gas estimate:', result.request.gas);
435
+ * console.log('Would succeed:', result.result);
436
+ */
437
+ get simulate() {
438
+ const contract = this.contract;
439
+ if (!contract.simulate) {
440
+ throw new Error('Public client is required for simulation');
441
+ }
442
+ return {
443
+ /**
444
+ * Simulate setOwner
445
+ * Returns gas estimate and result without sending transaction
446
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
447
+ */
448
+ async setOwner(_newOwner, options) {
449
+ return contract.simulate.setOwner([_newOwner], options);
450
+ },
451
+ /**
452
+ * Simulate enableStaticCall
453
+ * Returns gas estimate and result without sending transaction
454
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
455
+ */
456
+ async enableStaticCall(_module, _method, options) {
457
+ return contract.simulate.enableStaticCall([_module, _method], options);
458
+ },
459
+ /**
460
+ * Simulate authoriseModule
461
+ * Returns gas estimate and result without sending transaction
462
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
463
+ */
464
+ async authoriseModule(_module, _value, options) {
465
+ return contract.simulate.authoriseModule([_module, _value], options);
466
+ },
467
+ /**
468
+ * Simulate init
469
+ * Returns gas estimate and result without sending transaction
470
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
471
+ */
472
+ async init(_owner, _modules, options) {
473
+ return contract.simulate.init([_owner, _modules], options);
474
+ },
475
+ /**
476
+ * Simulate invoke
477
+ * Returns gas estimate and result without sending transaction
478
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
479
+ */
480
+ async invoke(_target, _value, _data, options) {
481
+ return contract.simulate.invoke([_target, _value, _data], options);
482
+ }
483
+ };
484
+ }
485
+ /**
486
+ * Watch contract events
487
+ *
488
+ * @example
489
+ * // Watch all Transfer events
490
+ * const unwatch = contract.watch.Transfer((event) => {
491
+ * console.log('Transfer:', event);
492
+ * });
493
+ *
494
+ * // Stop watching
495
+ * unwatch();
496
+ */
497
+ get watch() {
498
+ return {
499
+ /**
500
+ * Watch AuthorisedModule events
501
+ * @param callback Function to call when event is emitted
502
+ * @param filter Optional filter for indexed parameters
503
+ * @returns Unwatch function to stop listening
504
+ */
505
+ AuthorisedModule: (callback, filter) => {
506
+ return this.publicClient.watchContractEvent({
507
+ address: this.contractAddress,
508
+ abi: exports.BaseWallet_jsonAbi,
509
+ eventName: 'AuthorisedModule',
510
+ args: filter,
511
+ onLogs: (logs) => {
512
+ logs.forEach((log) => {
513
+ callback(log.args);
514
+ });
515
+ },
516
+ });
517
+ },
518
+ /**
519
+ * Watch EnabledStaticCall events
520
+ * @param callback Function to call when event is emitted
521
+ * @param filter Optional filter for indexed parameters
522
+ * @returns Unwatch function to stop listening
523
+ */
524
+ EnabledStaticCall: (callback, filter) => {
525
+ return this.publicClient.watchContractEvent({
526
+ address: this.contractAddress,
527
+ abi: exports.BaseWallet_jsonAbi,
528
+ eventName: 'EnabledStaticCall',
529
+ args: filter,
530
+ onLogs: (logs) => {
531
+ logs.forEach((log) => {
532
+ callback(log.args);
533
+ });
534
+ },
535
+ });
536
+ },
537
+ /**
538
+ * Watch Invoked events
539
+ * @param callback Function to call when event is emitted
540
+ * @param filter Optional filter for indexed parameters
541
+ * @returns Unwatch function to stop listening
542
+ */
543
+ Invoked: (callback, filter) => {
544
+ return this.publicClient.watchContractEvent({
545
+ address: this.contractAddress,
546
+ abi: exports.BaseWallet_jsonAbi,
547
+ eventName: 'Invoked',
548
+ args: filter,
549
+ onLogs: (logs) => {
550
+ logs.forEach((log) => {
551
+ callback(log.args);
552
+ });
553
+ },
554
+ });
555
+ },
556
+ /**
557
+ * Watch Received events
558
+ * @param callback Function to call when event is emitted
559
+ * @param filter Optional filter for indexed parameters
560
+ * @returns Unwatch function to stop listening
561
+ */
562
+ Received: (callback, filter) => {
563
+ return this.publicClient.watchContractEvent({
564
+ address: this.contractAddress,
565
+ abi: exports.BaseWallet_jsonAbi,
566
+ eventName: 'Received',
567
+ args: filter,
568
+ onLogs: (logs) => {
569
+ logs.forEach((log) => {
570
+ callback(log.args);
571
+ });
572
+ },
573
+ });
574
+ },
575
+ /**
576
+ * Watch OwnerChanged events
577
+ * @param callback Function to call when event is emitted
578
+ * @param filter Optional filter for indexed parameters
579
+ * @returns Unwatch function to stop listening
580
+ */
581
+ OwnerChanged: (callback) => {
582
+ return this.publicClient.watchContractEvent({
583
+ address: this.contractAddress,
584
+ abi: exports.BaseWallet_jsonAbi,
585
+ eventName: 'OwnerChanged',
586
+ onLogs: (logs) => {
587
+ logs.forEach((log) => {
588
+ callback(log.args);
589
+ });
590
+ },
591
+ });
592
+ }
593
+ };
594
+ }
595
+ }
596
+ exports.BaseWallet_json = BaseWallet_json;