@gitmyabi/rolesauthority 0.0.0-stage → 1.0.3

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,908 @@
1
+ import type { Abi, Address, PublicClient, WalletClient, GetContractReturnType } from 'viem';
2
+ import { getContract } from 'viem';
3
+
4
+ /**
5
+ * RolesAuthority ABI
6
+ *
7
+ * This ABI is typed using viem's type system for full type safety.
8
+ */
9
+ export const RolesAuthorityAbi = [
10
+ {
11
+ "inputs": [
12
+ {
13
+ "internalType": "address",
14
+ "name": "_owner",
15
+ "type": "address"
16
+ },
17
+ {
18
+ "internalType": "contract Authority",
19
+ "name": "_authority",
20
+ "type": "address"
21
+ }
22
+ ],
23
+ "stateMutability": "nonpayable",
24
+ "type": "constructor"
25
+ },
26
+ {
27
+ "anonymous": false,
28
+ "inputs": [
29
+ {
30
+ "indexed": true,
31
+ "internalType": "address",
32
+ "name": "user",
33
+ "type": "address"
34
+ },
35
+ {
36
+ "indexed": true,
37
+ "internalType": "contract Authority",
38
+ "name": "newAuthority",
39
+ "type": "address"
40
+ }
41
+ ],
42
+ "name": "AuthorityUpdated",
43
+ "type": "event"
44
+ },
45
+ {
46
+ "anonymous": false,
47
+ "inputs": [
48
+ {
49
+ "indexed": true,
50
+ "internalType": "address",
51
+ "name": "user",
52
+ "type": "address"
53
+ },
54
+ {
55
+ "indexed": true,
56
+ "internalType": "address",
57
+ "name": "newOwner",
58
+ "type": "address"
59
+ }
60
+ ],
61
+ "name": "OwnershipTransferred",
62
+ "type": "event"
63
+ },
64
+ {
65
+ "anonymous": false,
66
+ "inputs": [
67
+ {
68
+ "indexed": true,
69
+ "internalType": "address",
70
+ "name": "target",
71
+ "type": "address"
72
+ },
73
+ {
74
+ "indexed": true,
75
+ "internalType": "bytes4",
76
+ "name": "functionSig",
77
+ "type": "bytes4"
78
+ },
79
+ {
80
+ "indexed": false,
81
+ "internalType": "bool",
82
+ "name": "enabled",
83
+ "type": "bool"
84
+ }
85
+ ],
86
+ "name": "PublicCapabilityUpdated",
87
+ "type": "event"
88
+ },
89
+ {
90
+ "anonymous": false,
91
+ "inputs": [
92
+ {
93
+ "indexed": true,
94
+ "internalType": "uint8",
95
+ "name": "role",
96
+ "type": "uint8"
97
+ },
98
+ {
99
+ "indexed": true,
100
+ "internalType": "address",
101
+ "name": "target",
102
+ "type": "address"
103
+ },
104
+ {
105
+ "indexed": true,
106
+ "internalType": "bytes4",
107
+ "name": "functionSig",
108
+ "type": "bytes4"
109
+ },
110
+ {
111
+ "indexed": false,
112
+ "internalType": "bool",
113
+ "name": "enabled",
114
+ "type": "bool"
115
+ }
116
+ ],
117
+ "name": "RoleCapabilityUpdated",
118
+ "type": "event"
119
+ },
120
+ {
121
+ "anonymous": false,
122
+ "inputs": [
123
+ {
124
+ "indexed": true,
125
+ "internalType": "address",
126
+ "name": "user",
127
+ "type": "address"
128
+ },
129
+ {
130
+ "indexed": true,
131
+ "internalType": "uint8",
132
+ "name": "role",
133
+ "type": "uint8"
134
+ },
135
+ {
136
+ "indexed": false,
137
+ "internalType": "bool",
138
+ "name": "enabled",
139
+ "type": "bool"
140
+ }
141
+ ],
142
+ "name": "UserRoleUpdated",
143
+ "type": "event"
144
+ },
145
+ {
146
+ "inputs": [],
147
+ "name": "authority",
148
+ "outputs": [
149
+ {
150
+ "internalType": "contract Authority",
151
+ "name": "",
152
+ "type": "address"
153
+ }
154
+ ],
155
+ "stateMutability": "view",
156
+ "type": "function"
157
+ },
158
+ {
159
+ "inputs": [
160
+ {
161
+ "internalType": "address",
162
+ "name": "user",
163
+ "type": "address"
164
+ },
165
+ {
166
+ "internalType": "address",
167
+ "name": "target",
168
+ "type": "address"
169
+ },
170
+ {
171
+ "internalType": "bytes4",
172
+ "name": "functionSig",
173
+ "type": "bytes4"
174
+ }
175
+ ],
176
+ "name": "canCall",
177
+ "outputs": [
178
+ {
179
+ "internalType": "bool",
180
+ "name": "",
181
+ "type": "bool"
182
+ }
183
+ ],
184
+ "stateMutability": "view",
185
+ "type": "function"
186
+ },
187
+ {
188
+ "inputs": [
189
+ {
190
+ "internalType": "uint8",
191
+ "name": "role",
192
+ "type": "uint8"
193
+ },
194
+ {
195
+ "internalType": "address",
196
+ "name": "target",
197
+ "type": "address"
198
+ },
199
+ {
200
+ "internalType": "bytes4",
201
+ "name": "functionSig",
202
+ "type": "bytes4"
203
+ }
204
+ ],
205
+ "name": "doesRoleHaveCapability",
206
+ "outputs": [
207
+ {
208
+ "internalType": "bool",
209
+ "name": "",
210
+ "type": "bool"
211
+ }
212
+ ],
213
+ "stateMutability": "view",
214
+ "type": "function"
215
+ },
216
+ {
217
+ "inputs": [
218
+ {
219
+ "internalType": "address",
220
+ "name": "user",
221
+ "type": "address"
222
+ },
223
+ {
224
+ "internalType": "uint8",
225
+ "name": "role",
226
+ "type": "uint8"
227
+ }
228
+ ],
229
+ "name": "doesUserHaveRole",
230
+ "outputs": [
231
+ {
232
+ "internalType": "bool",
233
+ "name": "",
234
+ "type": "bool"
235
+ }
236
+ ],
237
+ "stateMutability": "view",
238
+ "type": "function"
239
+ },
240
+ {
241
+ "inputs": [
242
+ {
243
+ "internalType": "address",
244
+ "name": "",
245
+ "type": "address"
246
+ },
247
+ {
248
+ "internalType": "bytes4",
249
+ "name": "",
250
+ "type": "bytes4"
251
+ }
252
+ ],
253
+ "name": "getRolesWithCapability",
254
+ "outputs": [
255
+ {
256
+ "internalType": "bytes32",
257
+ "name": "",
258
+ "type": "bytes32"
259
+ }
260
+ ],
261
+ "stateMutability": "view",
262
+ "type": "function"
263
+ },
264
+ {
265
+ "inputs": [
266
+ {
267
+ "internalType": "address",
268
+ "name": "",
269
+ "type": "address"
270
+ }
271
+ ],
272
+ "name": "getUserRoles",
273
+ "outputs": [
274
+ {
275
+ "internalType": "bytes32",
276
+ "name": "",
277
+ "type": "bytes32"
278
+ }
279
+ ],
280
+ "stateMutability": "view",
281
+ "type": "function"
282
+ },
283
+ {
284
+ "inputs": [
285
+ {
286
+ "internalType": "address",
287
+ "name": "",
288
+ "type": "address"
289
+ },
290
+ {
291
+ "internalType": "bytes4",
292
+ "name": "",
293
+ "type": "bytes4"
294
+ }
295
+ ],
296
+ "name": "isCapabilityPublic",
297
+ "outputs": [
298
+ {
299
+ "internalType": "bool",
300
+ "name": "",
301
+ "type": "bool"
302
+ }
303
+ ],
304
+ "stateMutability": "view",
305
+ "type": "function"
306
+ },
307
+ {
308
+ "inputs": [],
309
+ "name": "owner",
310
+ "outputs": [
311
+ {
312
+ "internalType": "address",
313
+ "name": "",
314
+ "type": "address"
315
+ }
316
+ ],
317
+ "stateMutability": "view",
318
+ "type": "function"
319
+ },
320
+ {
321
+ "inputs": [
322
+ {
323
+ "internalType": "contract Authority",
324
+ "name": "newAuthority",
325
+ "type": "address"
326
+ }
327
+ ],
328
+ "name": "setAuthority",
329
+ "outputs": [],
330
+ "stateMutability": "nonpayable",
331
+ "type": "function"
332
+ },
333
+ {
334
+ "inputs": [
335
+ {
336
+ "internalType": "address",
337
+ "name": "target",
338
+ "type": "address"
339
+ },
340
+ {
341
+ "internalType": "bytes4",
342
+ "name": "functionSig",
343
+ "type": "bytes4"
344
+ },
345
+ {
346
+ "internalType": "bool",
347
+ "name": "enabled",
348
+ "type": "bool"
349
+ }
350
+ ],
351
+ "name": "setPublicCapability",
352
+ "outputs": [],
353
+ "stateMutability": "nonpayable",
354
+ "type": "function"
355
+ },
356
+ {
357
+ "inputs": [
358
+ {
359
+ "internalType": "uint8",
360
+ "name": "role",
361
+ "type": "uint8"
362
+ },
363
+ {
364
+ "internalType": "address",
365
+ "name": "target",
366
+ "type": "address"
367
+ },
368
+ {
369
+ "internalType": "bytes4",
370
+ "name": "functionSig",
371
+ "type": "bytes4"
372
+ },
373
+ {
374
+ "internalType": "bool",
375
+ "name": "enabled",
376
+ "type": "bool"
377
+ }
378
+ ],
379
+ "name": "setRoleCapability",
380
+ "outputs": [],
381
+ "stateMutability": "nonpayable",
382
+ "type": "function"
383
+ },
384
+ {
385
+ "inputs": [
386
+ {
387
+ "internalType": "address",
388
+ "name": "user",
389
+ "type": "address"
390
+ },
391
+ {
392
+ "internalType": "uint8",
393
+ "name": "role",
394
+ "type": "uint8"
395
+ },
396
+ {
397
+ "internalType": "bool",
398
+ "name": "enabled",
399
+ "type": "bool"
400
+ }
401
+ ],
402
+ "name": "setUserRole",
403
+ "outputs": [],
404
+ "stateMutability": "nonpayable",
405
+ "type": "function"
406
+ },
407
+ {
408
+ "inputs": [
409
+ {
410
+ "internalType": "address",
411
+ "name": "newOwner",
412
+ "type": "address"
413
+ }
414
+ ],
415
+ "name": "transferOwnership",
416
+ "outputs": [],
417
+ "stateMutability": "nonpayable",
418
+ "type": "function"
419
+ }
420
+ ] as const satisfies Abi;
421
+
422
+ /**
423
+ * Type-safe ABI for RolesAuthority
424
+ */
425
+ export type RolesAuthorityAbi = typeof RolesAuthorityAbi;
426
+
427
+ /**
428
+ * Contract instance type for RolesAuthority
429
+ */
430
+ // Use any for contract type to avoid complex viem type issues
431
+ // The runtime behavior is type-safe through viem's ABI typing
432
+ export type RolesAuthorityContract = any;
433
+
434
+ /**
435
+ * RolesAuthority Contract Class
436
+ *
437
+ * Provides a class-based API similar to TypeChain for interacting with the contract.
438
+ *
439
+ * @example
440
+ * ```typescript
441
+ * import { createPublicClient, createWalletClient, http } from 'viem';
442
+ * import { mainnet } from 'viem/chains';
443
+ * import { RolesAuthority } from 'RolesAuthority';
444
+ *
445
+ * const publicClient = createPublicClient({ chain: mainnet, transport: http() });
446
+ * const walletClient = createWalletClient({ chain: mainnet, transport: http() });
447
+ *
448
+ * const contract = new RolesAuthority('0x...', { publicClient, walletClient });
449
+ *
450
+ * // Read functions
451
+ * const result = await contract.balanceOf('0x...');
452
+ *
453
+ * // Write functions
454
+ * const hash = await contract.transfer('0x...', 1000n);
455
+ *
456
+ * // Simulate transactions (dry-run)
457
+ * const simulation = await contract.simulate.transfer('0x...', 1000n);
458
+ * console.log('Gas estimate:', simulation.request.gas);
459
+ *
460
+ * // Watch events
461
+ * const unwatch = contract.watch.Transfer((event) => {
462
+ * console.log('Transfer event:', event);
463
+ * });
464
+ * ```
465
+ */
466
+ export class RolesAuthority {
467
+ private contract: RolesAuthorityContract;
468
+ private contractAddress: Address;
469
+ private publicClient: PublicClient;
470
+
471
+ constructor(
472
+ address: Address,
473
+ clients: {
474
+ publicClient: PublicClient;
475
+ walletClient?: WalletClient;
476
+ }
477
+ ) {
478
+ this.contractAddress = address;
479
+ this.publicClient = clients.publicClient;
480
+ this.contract = getContract({
481
+ address,
482
+ abi: RolesAuthorityAbi,
483
+ client: {
484
+ public: clients.publicClient,
485
+ wallet: clients.walletClient,
486
+ },
487
+ });
488
+ }
489
+
490
+ /**
491
+ * Get the contract address
492
+ */
493
+ get address(): Address {
494
+ return this.contractAddress;
495
+ }
496
+
497
+ /**
498
+ * Get the underlying viem contract instance.
499
+ */
500
+ getContract(): RolesAuthorityContract {
501
+ return this.contract;
502
+ }
503
+
504
+ /**
505
+ * authority
506
+ * view
507
+ */
508
+ async authority(): Promise<`0x${string}`> {
509
+ return this.contract.read.authority() as Promise<`0x${string}`>;
510
+ }
511
+
512
+ /**
513
+ * canCall
514
+ * view
515
+ */
516
+ async canCall(user: `0x${string}`, target: `0x${string}`, functionSig: `0x${string}`): Promise<boolean> {
517
+ return this.contract.read.canCall([user, target, functionSig] as const) as Promise<boolean>;
518
+ }
519
+
520
+ /**
521
+ * doesRoleHaveCapability
522
+ * view
523
+ */
524
+ async doesRoleHaveCapability(role: bigint, target: `0x${string}`, functionSig: `0x${string}`): Promise<boolean> {
525
+ return this.contract.read.doesRoleHaveCapability([role, target, functionSig] as const) as Promise<boolean>;
526
+ }
527
+
528
+ /**
529
+ * doesUserHaveRole
530
+ * view
531
+ */
532
+ async doesUserHaveRole(user: `0x${string}`, role: bigint): Promise<boolean> {
533
+ return this.contract.read.doesUserHaveRole([user, role] as const) as Promise<boolean>;
534
+ }
535
+
536
+ /**
537
+ * getRolesWithCapability
538
+ * view
539
+ */
540
+ async getRolesWithCapability(arg0: `0x${string}`, arg1: `0x${string}`): Promise<`0x${string}`> {
541
+ return this.contract.read.getRolesWithCapability([arg0, arg1] as const) as Promise<`0x${string}`>;
542
+ }
543
+
544
+ /**
545
+ * getUserRoles
546
+ * view
547
+ */
548
+ async getUserRoles(arg0: `0x${string}`): Promise<`0x${string}`> {
549
+ return this.contract.read.getUserRoles([arg0] as const) as Promise<`0x${string}`>;
550
+ }
551
+
552
+ /**
553
+ * isCapabilityPublic
554
+ * view
555
+ */
556
+ async isCapabilityPublic(arg0: `0x${string}`, arg1: `0x${string}`): Promise<boolean> {
557
+ return this.contract.read.isCapabilityPublic([arg0, arg1] as const) as Promise<boolean>;
558
+ }
559
+
560
+ /**
561
+ * owner
562
+ * view
563
+ */
564
+ async owner(): Promise<`0x${string}`> {
565
+ return this.contract.read.owner() as Promise<`0x${string}`>;
566
+ }
567
+
568
+ /**
569
+ * setAuthority
570
+ * nonpayable
571
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
572
+ */
573
+ async setAuthority(newAuthority: `0x${string}`, options?: {
574
+ accessList?: import('viem').AccessList;
575
+ authorizationList?: import('viem').AuthorizationList;
576
+ chain?: import('viem').Chain | null;
577
+ dataSuffix?: `0x${string}`;
578
+ gas?: bigint;
579
+ gasPrice?: bigint;
580
+ maxFeePerGas?: bigint;
581
+ maxPriorityFeePerGas?: bigint;
582
+ nonce?: number;
583
+ value?: bigint;
584
+ }): Promise<`0x${string}`> {
585
+ if (!this.contract.write) {
586
+ throw new Error('Wallet client is required for write operations');
587
+ }
588
+ return this.contract.write.setAuthority([newAuthority] as const, options) as Promise<`0x${string}`>;
589
+ }
590
+
591
+ /**
592
+ * setPublicCapability
593
+ * nonpayable
594
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
595
+ */
596
+ async setPublicCapability(target: `0x${string}`, functionSig: `0x${string}`, enabled: boolean, options?: {
597
+ accessList?: import('viem').AccessList;
598
+ authorizationList?: import('viem').AuthorizationList;
599
+ chain?: import('viem').Chain | null;
600
+ dataSuffix?: `0x${string}`;
601
+ gas?: bigint;
602
+ gasPrice?: bigint;
603
+ maxFeePerGas?: bigint;
604
+ maxPriorityFeePerGas?: bigint;
605
+ nonce?: number;
606
+ value?: bigint;
607
+ }): Promise<`0x${string}`> {
608
+ if (!this.contract.write) {
609
+ throw new Error('Wallet client is required for write operations');
610
+ }
611
+ return this.contract.write.setPublicCapability([target, functionSig, enabled] as const, options) as Promise<`0x${string}`>;
612
+ }
613
+
614
+ /**
615
+ * setRoleCapability
616
+ * nonpayable
617
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
618
+ */
619
+ async setRoleCapability(role: bigint, target: `0x${string}`, functionSig: `0x${string}`, enabled: boolean, options?: {
620
+ accessList?: import('viem').AccessList;
621
+ authorizationList?: import('viem').AuthorizationList;
622
+ chain?: import('viem').Chain | null;
623
+ dataSuffix?: `0x${string}`;
624
+ gas?: bigint;
625
+ gasPrice?: bigint;
626
+ maxFeePerGas?: bigint;
627
+ maxPriorityFeePerGas?: bigint;
628
+ nonce?: number;
629
+ value?: bigint;
630
+ }): Promise<`0x${string}`> {
631
+ if (!this.contract.write) {
632
+ throw new Error('Wallet client is required for write operations');
633
+ }
634
+ return this.contract.write.setRoleCapability([role, target, functionSig, enabled] as const, options) as Promise<`0x${string}`>;
635
+ }
636
+
637
+ /**
638
+ * setUserRole
639
+ * nonpayable
640
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
641
+ */
642
+ async setUserRole(user: `0x${string}`, role: bigint, enabled: boolean, options?: {
643
+ accessList?: import('viem').AccessList;
644
+ authorizationList?: import('viem').AuthorizationList;
645
+ chain?: import('viem').Chain | null;
646
+ dataSuffix?: `0x${string}`;
647
+ gas?: bigint;
648
+ gasPrice?: bigint;
649
+ maxFeePerGas?: bigint;
650
+ maxPriorityFeePerGas?: bigint;
651
+ nonce?: number;
652
+ value?: bigint;
653
+ }): Promise<`0x${string}`> {
654
+ if (!this.contract.write) {
655
+ throw new Error('Wallet client is required for write operations');
656
+ }
657
+ return this.contract.write.setUserRole([user, role, enabled] as const, options) as Promise<`0x${string}`>;
658
+ }
659
+
660
+ /**
661
+ * transferOwnership
662
+ * nonpayable
663
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
664
+ */
665
+ async transferOwnership(newOwner: `0x${string}`, options?: {
666
+ accessList?: import('viem').AccessList;
667
+ authorizationList?: import('viem').AuthorizationList;
668
+ chain?: import('viem').Chain | null;
669
+ dataSuffix?: `0x${string}`;
670
+ gas?: bigint;
671
+ gasPrice?: bigint;
672
+ maxFeePerGas?: bigint;
673
+ maxPriorityFeePerGas?: bigint;
674
+ nonce?: number;
675
+ value?: bigint;
676
+ }): Promise<`0x${string}`> {
677
+ if (!this.contract.write) {
678
+ throw new Error('Wallet client is required for write operations');
679
+ }
680
+ return this.contract.write.transferOwnership([newOwner] as const, options) as Promise<`0x${string}`>;
681
+ }
682
+
683
+
684
+
685
+ /**
686
+ * Simulate contract write operations (dry-run without sending transaction)
687
+ *
688
+ * @example
689
+ * const result = await contract.simulate.transfer('0x...', 1000n);
690
+ * console.log('Gas estimate:', result.request.gas);
691
+ * console.log('Would succeed:', result.result);
692
+ */
693
+ get simulate() {
694
+ const contract = this.contract;
695
+ if (!contract.simulate) {
696
+ throw new Error('Public client is required for simulation');
697
+ }
698
+ return {
699
+ /**
700
+ * Simulate setAuthority
701
+ * Returns gas estimate and result without sending transaction
702
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
703
+ */
704
+ async setAuthority(newAuthority: `0x${string}`, options?: {
705
+ accessList?: import('viem').AccessList;
706
+ authorizationList?: import('viem').AuthorizationList;
707
+ chain?: import('viem').Chain | null;
708
+ dataSuffix?: `0x${string}`;
709
+ gas?: bigint;
710
+ gasPrice?: bigint;
711
+ maxFeePerGas?: bigint;
712
+ maxPriorityFeePerGas?: bigint;
713
+ nonce?: number;
714
+ value?: bigint;
715
+ }): Promise<void> {
716
+ return contract.simulate.setAuthority([newAuthority] as const, options) as Promise<void>;
717
+ },
718
+ /**
719
+ * Simulate setPublicCapability
720
+ * Returns gas estimate and result without sending transaction
721
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
722
+ */
723
+ async setPublicCapability(target: `0x${string}`, functionSig: `0x${string}`, enabled: boolean, options?: {
724
+ accessList?: import('viem').AccessList;
725
+ authorizationList?: import('viem').AuthorizationList;
726
+ chain?: import('viem').Chain | null;
727
+ dataSuffix?: `0x${string}`;
728
+ gas?: bigint;
729
+ gasPrice?: bigint;
730
+ maxFeePerGas?: bigint;
731
+ maxPriorityFeePerGas?: bigint;
732
+ nonce?: number;
733
+ value?: bigint;
734
+ }): Promise<void> {
735
+ return contract.simulate.setPublicCapability([target, functionSig, enabled] as const, options) as Promise<void>;
736
+ },
737
+ /**
738
+ * Simulate setRoleCapability
739
+ * Returns gas estimate and result without sending transaction
740
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
741
+ */
742
+ async setRoleCapability(role: bigint, target: `0x${string}`, functionSig: `0x${string}`, enabled: boolean, options?: {
743
+ accessList?: import('viem').AccessList;
744
+ authorizationList?: import('viem').AuthorizationList;
745
+ chain?: import('viem').Chain | null;
746
+ dataSuffix?: `0x${string}`;
747
+ gas?: bigint;
748
+ gasPrice?: bigint;
749
+ maxFeePerGas?: bigint;
750
+ maxPriorityFeePerGas?: bigint;
751
+ nonce?: number;
752
+ value?: bigint;
753
+ }): Promise<void> {
754
+ return contract.simulate.setRoleCapability([role, target, functionSig, enabled] as const, options) as Promise<void>;
755
+ },
756
+ /**
757
+ * Simulate setUserRole
758
+ * Returns gas estimate and result without sending transaction
759
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
760
+ */
761
+ async setUserRole(user: `0x${string}`, role: bigint, enabled: boolean, options?: {
762
+ accessList?: import('viem').AccessList;
763
+ authorizationList?: import('viem').AuthorizationList;
764
+ chain?: import('viem').Chain | null;
765
+ dataSuffix?: `0x${string}`;
766
+ gas?: bigint;
767
+ gasPrice?: bigint;
768
+ maxFeePerGas?: bigint;
769
+ maxPriorityFeePerGas?: bigint;
770
+ nonce?: number;
771
+ value?: bigint;
772
+ }): Promise<void> {
773
+ return contract.simulate.setUserRole([user, role, enabled] as const, options) as Promise<void>;
774
+ },
775
+ /**
776
+ * Simulate transferOwnership
777
+ * Returns gas estimate and result without sending transaction
778
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
779
+ */
780
+ async transferOwnership(newOwner: `0x${string}`, options?: {
781
+ accessList?: import('viem').AccessList;
782
+ authorizationList?: import('viem').AuthorizationList;
783
+ chain?: import('viem').Chain | null;
784
+ dataSuffix?: `0x${string}`;
785
+ gas?: bigint;
786
+ gasPrice?: bigint;
787
+ maxFeePerGas?: bigint;
788
+ maxPriorityFeePerGas?: bigint;
789
+ nonce?: number;
790
+ value?: bigint;
791
+ }): Promise<void> {
792
+ return contract.simulate.transferOwnership([newOwner] as const, options) as Promise<void>;
793
+ }
794
+ };
795
+ }
796
+
797
+ /**
798
+ * Watch contract events
799
+ *
800
+ * @example
801
+ * // Watch all Transfer events
802
+ * const unwatch = contract.watch.Transfer((event) => {
803
+ * console.log('Transfer:', event);
804
+ * });
805
+ *
806
+ * // Stop watching
807
+ * unwatch();
808
+ */
809
+ get watch() {
810
+ return {
811
+ /**
812
+ * Watch AuthorityUpdated events
813
+ * @param callback Function to call when event is emitted
814
+ * @param filter Optional filter for indexed parameters
815
+ * @returns Unwatch function to stop listening
816
+ */
817
+ AuthorityUpdated: (callback: (event: { user: `0x${string}`; newAuthority: `0x${string}` }) => void, filter?: { user?: `0x${string}` | `0x${string}`[] | null; newAuthority?: `0x${string}` | `0x${string}`[] | null }) => {
818
+ return this.publicClient.watchContractEvent({
819
+ address: this.contractAddress,
820
+ abi: RolesAuthorityAbi,
821
+ eventName: 'AuthorityUpdated',
822
+ args: filter as any,
823
+ onLogs: (logs: any[]) => {
824
+ logs.forEach((log: any) => {
825
+ callback(log.args as any);
826
+ });
827
+ },
828
+ }) as () => void;
829
+ },
830
+ /**
831
+ * Watch OwnershipTransferred events
832
+ * @param callback Function to call when event is emitted
833
+ * @param filter Optional filter for indexed parameters
834
+ * @returns Unwatch function to stop listening
835
+ */
836
+ OwnershipTransferred: (callback: (event: { user: `0x${string}`; newOwner: `0x${string}` }) => void, filter?: { user?: `0x${string}` | `0x${string}`[] | null; newOwner?: `0x${string}` | `0x${string}`[] | null }) => {
837
+ return this.publicClient.watchContractEvent({
838
+ address: this.contractAddress,
839
+ abi: RolesAuthorityAbi,
840
+ eventName: 'OwnershipTransferred',
841
+ args: filter as any,
842
+ onLogs: (logs: any[]) => {
843
+ logs.forEach((log: any) => {
844
+ callback(log.args as any);
845
+ });
846
+ },
847
+ }) as () => void;
848
+ },
849
+ /**
850
+ * Watch PublicCapabilityUpdated events
851
+ * @param callback Function to call when event is emitted
852
+ * @param filter Optional filter for indexed parameters
853
+ * @returns Unwatch function to stop listening
854
+ */
855
+ PublicCapabilityUpdated: (callback: (event: { target: `0x${string}`; functionSig: `0x${string}`; enabled: boolean }) => void, filter?: { target?: `0x${string}` | `0x${string}`[] | null; functionSig?: `0x${string}` | `0x${string}`[] | null }) => {
856
+ return this.publicClient.watchContractEvent({
857
+ address: this.contractAddress,
858
+ abi: RolesAuthorityAbi,
859
+ eventName: 'PublicCapabilityUpdated',
860
+ args: filter as any,
861
+ onLogs: (logs: any[]) => {
862
+ logs.forEach((log: any) => {
863
+ callback(log.args as any);
864
+ });
865
+ },
866
+ }) as () => void;
867
+ },
868
+ /**
869
+ * Watch RoleCapabilityUpdated events
870
+ * @param callback Function to call when event is emitted
871
+ * @param filter Optional filter for indexed parameters
872
+ * @returns Unwatch function to stop listening
873
+ */
874
+ RoleCapabilityUpdated: (callback: (event: { role: bigint; target: `0x${string}`; functionSig: `0x${string}`; enabled: boolean }) => void, filter?: { role?: number | number[] | null; target?: `0x${string}` | `0x${string}`[] | null; functionSig?: `0x${string}` | `0x${string}`[] | null }) => {
875
+ return this.publicClient.watchContractEvent({
876
+ address: this.contractAddress,
877
+ abi: RolesAuthorityAbi,
878
+ eventName: 'RoleCapabilityUpdated',
879
+ args: filter as any,
880
+ onLogs: (logs: any[]) => {
881
+ logs.forEach((log: any) => {
882
+ callback(log.args as any);
883
+ });
884
+ },
885
+ }) as () => void;
886
+ },
887
+ /**
888
+ * Watch UserRoleUpdated events
889
+ * @param callback Function to call when event is emitted
890
+ * @param filter Optional filter for indexed parameters
891
+ * @returns Unwatch function to stop listening
892
+ */
893
+ UserRoleUpdated: (callback: (event: { user: `0x${string}`; role: bigint; enabled: boolean }) => void, filter?: { user?: `0x${string}` | `0x${string}`[] | null; role?: number | number[] | null }) => {
894
+ return this.publicClient.watchContractEvent({
895
+ address: this.contractAddress,
896
+ abi: RolesAuthorityAbi,
897
+ eventName: 'UserRoleUpdated',
898
+ args: filter as any,
899
+ onLogs: (logs: any[]) => {
900
+ logs.forEach((log: any) => {
901
+ callback(log.args as any);
902
+ });
903
+ },
904
+ }) as () => void;
905
+ }
906
+ };
907
+ }
908
+ }