@aastar/paymaster 0.16.7

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.
Files changed (106) hide show
  1. package/LICENSE +21 -0
  2. package/dist/core/src/abis/BLSAggregator.json +686 -0
  3. package/dist/core/src/abis/BLSValidator.json +42 -0
  4. package/dist/core/src/abis/DVTValidator.json +368 -0
  5. package/dist/core/src/abis/EntryPoint.json +1382 -0
  6. package/dist/core/src/abis/GToken.json +513 -0
  7. package/dist/core/src/abis/GTokenStaking.json +949 -0
  8. package/dist/core/src/abis/MySBT.json +1518 -0
  9. package/dist/core/src/abis/Paymaster.json +1143 -0
  10. package/dist/core/src/abis/PaymasterFactory.json +640 -0
  11. package/dist/core/src/abis/Registry.json +1942 -0
  12. package/dist/core/src/abis/ReputationSystem.json +699 -0
  13. package/dist/core/src/abis/SimpleAccount.json +560 -0
  14. package/dist/core/src/abis/SimpleAccountFactory.json +111 -0
  15. package/dist/core/src/abis/SuperPaymaster.json +1781 -0
  16. package/dist/core/src/abis/index.d.ts +1126 -0
  17. package/dist/core/src/abis/index.js +91 -0
  18. package/dist/core/src/abis/xPNTsFactory.json +718 -0
  19. package/dist/core/src/abis/xPNTsToken.json +1280 -0
  20. package/dist/core/src/actions/StateValidator.d.ts +68 -0
  21. package/dist/core/src/actions/StateValidator.js +187 -0
  22. package/dist/core/src/actions/account.d.ts +55 -0
  23. package/dist/core/src/actions/account.js +133 -0
  24. package/dist/core/src/actions/aggregator.d.ts +17 -0
  25. package/dist/core/src/actions/aggregator.js +31 -0
  26. package/dist/core/src/actions/dvt.d.ts +30 -0
  27. package/dist/core/src/actions/dvt.js +41 -0
  28. package/dist/core/src/actions/entryPoint.d.ts +90 -0
  29. package/dist/core/src/actions/entryPoint.js +211 -0
  30. package/dist/core/src/actions/factory.d.ts +215 -0
  31. package/dist/core/src/actions/factory.js +442 -0
  32. package/dist/core/src/actions/faucet.d.ts +48 -0
  33. package/dist/core/src/actions/faucet.js +337 -0
  34. package/dist/core/src/actions/gtokenExtended.d.ts +39 -0
  35. package/dist/core/src/actions/gtokenExtended.js +115 -0
  36. package/dist/core/src/actions/index.d.ts +15 -0
  37. package/dist/core/src/actions/index.js +17 -0
  38. package/dist/core/src/actions/paymasterV4.d.ts +170 -0
  39. package/dist/core/src/actions/paymasterV4.js +334 -0
  40. package/dist/core/src/actions/registry.d.ts +246 -0
  41. package/dist/core/src/actions/registry.js +667 -0
  42. package/dist/core/src/actions/reputation.d.ts +129 -0
  43. package/dist/core/src/actions/reputation.js +281 -0
  44. package/dist/core/src/actions/sbt.d.ts +191 -0
  45. package/dist/core/src/actions/sbt.js +533 -0
  46. package/dist/core/src/actions/staking.d.ts +132 -0
  47. package/dist/core/src/actions/staking.js +330 -0
  48. package/dist/core/src/actions/superPaymaster.d.ts +237 -0
  49. package/dist/core/src/actions/superPaymaster.js +644 -0
  50. package/dist/core/src/actions/tokens.d.ts +229 -0
  51. package/dist/core/src/actions/tokens.js +415 -0
  52. package/dist/core/src/branding.d.ts +30 -0
  53. package/dist/core/src/branding.js +30 -0
  54. package/dist/core/src/clients/BaseClient.d.ts +25 -0
  55. package/dist/core/src/clients/BaseClient.js +66 -0
  56. package/dist/core/src/clients/types.d.ts +60 -0
  57. package/dist/core/src/clients/types.js +1 -0
  58. package/dist/core/src/clients.d.ts +5 -0
  59. package/dist/core/src/clients.js +11 -0
  60. package/dist/core/src/communities.d.ts +52 -0
  61. package/dist/core/src/communities.js +73 -0
  62. package/dist/core/src/config/ContractConfigManager.d.ts +20 -0
  63. package/dist/core/src/config/ContractConfigManager.js +48 -0
  64. package/dist/core/src/constants.d.ts +88 -0
  65. package/dist/core/src/constants.js +125 -0
  66. package/dist/core/src/contract-addresses.d.ts +110 -0
  67. package/dist/core/src/contract-addresses.js +99 -0
  68. package/dist/core/src/contracts.d.ts +424 -0
  69. package/dist/core/src/contracts.js +343 -0
  70. package/dist/core/src/crypto/blsSigner.d.ts +64 -0
  71. package/dist/core/src/crypto/blsSigner.js +98 -0
  72. package/dist/core/src/crypto/index.d.ts +1 -0
  73. package/dist/core/src/crypto/index.js +1 -0
  74. package/dist/core/src/index.d.ts +21 -0
  75. package/dist/core/src/index.js +21 -0
  76. package/dist/core/src/networks.d.ts +127 -0
  77. package/dist/core/src/networks.js +118 -0
  78. package/dist/core/src/requirementChecker.d.ts +38 -0
  79. package/dist/core/src/requirementChecker.js +139 -0
  80. package/dist/core/src/roles.d.ts +204 -0
  81. package/dist/core/src/roles.js +211 -0
  82. package/dist/core/src/utils/validation.d.ts +24 -0
  83. package/dist/core/src/utils/validation.js +56 -0
  84. package/dist/paymaster/src/SuperPaymaster/index.d.ts +44 -0
  85. package/dist/paymaster/src/SuperPaymaster/index.js +133 -0
  86. package/dist/paymaster/src/V4/PaymasterClient.d.ts +79 -0
  87. package/dist/paymaster/src/V4/PaymasterClient.js +315 -0
  88. package/dist/paymaster/src/V4/PaymasterClient.test.d.ts +1 -0
  89. package/dist/paymaster/src/V4/PaymasterClient.test.js +80 -0
  90. package/dist/paymaster/src/V4/PaymasterOperator.d.ts +41 -0
  91. package/dist/paymaster/src/V4/PaymasterOperator.js +241 -0
  92. package/dist/paymaster/src/V4/PaymasterOperator.test.d.ts +1 -0
  93. package/dist/paymaster/src/V4/PaymasterOperator.test.js +66 -0
  94. package/dist/paymaster/src/V4/PaymasterUtils.d.ts +55 -0
  95. package/dist/paymaster/src/V4/PaymasterUtils.js +124 -0
  96. package/dist/paymaster/src/V4/PaymasterUtils.test.d.ts +1 -0
  97. package/dist/paymaster/src/V4/PaymasterUtils.test.js +43 -0
  98. package/dist/paymaster/src/V4/SuperPaymasterClient.d.ts +21 -0
  99. package/dist/paymaster/src/V4/SuperPaymasterClient.js +73 -0
  100. package/dist/paymaster/src/V4/SuperPaymasterClient.test.d.ts +1 -0
  101. package/dist/paymaster/src/V4/SuperPaymasterClient.test.js +53 -0
  102. package/dist/paymaster/src/V4/index.d.ts +4 -0
  103. package/dist/paymaster/src/V4/index.js +4 -0
  104. package/dist/paymaster/src/index.d.ts +2 -0
  105. package/dist/paymaster/src/index.js +4 -0
  106. package/package.json +26 -0
@@ -0,0 +1,667 @@
1
+ import { RegistryABI } from '../abis/index.js';
2
+ export const registryActions = (address) => (client) => ({
3
+ // Role Management
4
+ async registryConfigureRole({ roleId, config, account }) {
5
+ return client.writeContract({
6
+ address,
7
+ abi: RegistryABI,
8
+ functionName: 'configureRole',
9
+ args: [roleId, config],
10
+ account: account,
11
+ chain: client.chain
12
+ });
13
+ },
14
+ async registryRegisterRole({ roleId, user, data, account }) {
15
+ return client.writeContract({
16
+ address,
17
+ abi: RegistryABI,
18
+ functionName: 'registerRole',
19
+ args: [roleId, user, data],
20
+ account: account,
21
+ chain: client.chain
22
+ });
23
+ },
24
+ async registryRegisterRoleSelf({ roleId, data, account }) {
25
+ return client.writeContract({
26
+ address,
27
+ abi: RegistryABI,
28
+ functionName: 'registerRoleSelf',
29
+ args: [roleId, data],
30
+ account: account,
31
+ chain: client.chain
32
+ });
33
+ },
34
+ async registryHasRole({ user, roleId }) {
35
+ return client.readContract({
36
+ address,
37
+ abi: RegistryABI,
38
+ functionName: 'hasRole',
39
+ args: [roleId, user]
40
+ });
41
+ },
42
+ async registryUnRegisterRole({ user, roleId, account }) {
43
+ return client.writeContract({
44
+ address,
45
+ abi: RegistryABI,
46
+ functionName: 'unregisterRole',
47
+ args: [user, roleId],
48
+ account: account,
49
+ chain: client.chain
50
+ });
51
+ },
52
+ async registryGetRoleConfig({ roleId }) {
53
+ return client.readContract({
54
+ address,
55
+ abi: RegistryABI,
56
+ functionName: 'getRoleConfig',
57
+ args: [roleId]
58
+ });
59
+ },
60
+ async registrySetRoleLockDuration({ roleId, duration, account }) {
61
+ return client.writeContract({
62
+ address,
63
+ abi: RegistryABI,
64
+ functionName: 'setRoleLockDuration',
65
+ args: [roleId, duration],
66
+ account: account,
67
+ chain: client.chain
68
+ });
69
+ },
70
+ async registrySetRoleOwner({ roleId, newOwner, account }) {
71
+ return client.writeContract({
72
+ address,
73
+ abi: RegistryABI,
74
+ functionName: 'setRoleOwner',
75
+ args: [roleId, newOwner],
76
+ account: account,
77
+ chain: client.chain
78
+ });
79
+ },
80
+ async registryIsCommunityMember({ community, user }) {
81
+ const ROLE_ENDUSER = await this.registryROLE_ENDUSER();
82
+ return this.registryHasRole({ user, roleId: ROLE_ENDUSER });
83
+ },
84
+ // Credit & Reputation
85
+ async registryGlobalReputation({ user }) {
86
+ return client.readContract({
87
+ address,
88
+ abi: RegistryABI,
89
+ functionName: 'globalReputation',
90
+ args: [user]
91
+ });
92
+ },
93
+ async registryBatchUpdateGlobalReputation({ users, scores, epoch, proof, account }) {
94
+ return client.writeContract({
95
+ address,
96
+ abi: RegistryABI,
97
+ functionName: 'batchUpdateGlobalReputation',
98
+ args: [users, scores, epoch, proof],
99
+ account: account,
100
+ chain: client.chain
101
+ });
102
+ },
103
+ // Blacklist Management
104
+ async registryUpdateOperatorBlacklist({ operator, users, statuses, proof, account }) {
105
+ return client.writeContract({
106
+ address,
107
+ abi: RegistryABI,
108
+ functionName: 'updateOperatorBlacklist',
109
+ args: [operator, users, statuses, proof],
110
+ account: account,
111
+ chain: client.chain
112
+ });
113
+ },
114
+ async registryIsOperatorBlacklisted({ operator }) {
115
+ return client.readContract({
116
+ address,
117
+ abi: RegistryABI,
118
+ functionName: 'isOperatorBlacklisted',
119
+ args: [operator]
120
+ });
121
+ },
122
+ // Contract References
123
+ async registrySetBLSValidator({ validator, account }) {
124
+ return client.writeContract({
125
+ address,
126
+ abi: RegistryABI,
127
+ functionName: 'setBLSValidator',
128
+ args: [validator],
129
+ account: account,
130
+ chain: client.chain
131
+ });
132
+ },
133
+ async registrySetBLSAggregator({ aggregator, account }) {
134
+ return client.writeContract({
135
+ address,
136
+ abi: RegistryABI,
137
+ functionName: 'setBLSAggregator',
138
+ args: [aggregator],
139
+ account: account,
140
+ chain: client.chain
141
+ });
142
+ },
143
+ async registrySetMySBT({ sbt, account }) {
144
+ return client.writeContract({
145
+ address,
146
+ abi: RegistryABI,
147
+ functionName: 'setMySBT',
148
+ args: [sbt],
149
+ account: account,
150
+ chain: client.chain
151
+ });
152
+ },
153
+ async registrySetSuperPaymaster({ paymaster, account }) {
154
+ return client.writeContract({
155
+ address,
156
+ abi: RegistryABI,
157
+ functionName: 'setSuperPaymaster',
158
+ args: [paymaster],
159
+ account: account,
160
+ chain: client.chain
161
+ });
162
+ },
163
+ async registrySetStaking({ staking, account }) {
164
+ return client.writeContract({
165
+ address,
166
+ abi: RegistryABI,
167
+ functionName: 'setStaking',
168
+ args: [staking],
169
+ account: account,
170
+ chain: client.chain
171
+ });
172
+ },
173
+ async registrySetReputationSource({ source, account }) {
174
+ return client.writeContract({
175
+ address,
176
+ abi: RegistryABI,
177
+ functionName: 'setReputationSource',
178
+ args: [source],
179
+ account: account,
180
+ chain: client.chain
181
+ });
182
+ },
183
+ async registryBlsValidator() {
184
+ return client.readContract({
185
+ address,
186
+ abi: RegistryABI,
187
+ functionName: 'blsValidator',
188
+ args: []
189
+ });
190
+ },
191
+ async registryBlsAggregator() {
192
+ return client.readContract({
193
+ address,
194
+ abi: RegistryABI,
195
+ functionName: 'blsAggregator',
196
+ args: []
197
+ });
198
+ },
199
+ async registryMySBT() {
200
+ return client.readContract({
201
+ address,
202
+ abi: RegistryABI,
203
+ functionName: 'MYSBT',
204
+ args: []
205
+ });
206
+ },
207
+ async registrySuperPaymaster() {
208
+ return client.readContract({
209
+ address,
210
+ abi: RegistryABI,
211
+ functionName: 'SUPER_PAYMASTER',
212
+ args: []
213
+ });
214
+ },
215
+ async registryStaking() {
216
+ return client.readContract({
217
+ address,
218
+ abi: RegistryABI,
219
+ functionName: 'GTOKEN_STAKING',
220
+ args: []
221
+ });
222
+ },
223
+ async registryReputationSource() {
224
+ return client.readContract({
225
+ address,
226
+ abi: RegistryABI,
227
+ functionName: 'reputationSource',
228
+ args: []
229
+ });
230
+ },
231
+ // Admin
232
+ async registryTransferOwnership({ newOwner, account }) {
233
+ return client.writeContract({
234
+ address,
235
+ abi: RegistryABI,
236
+ functionName: 'transferOwnership',
237
+ args: [newOwner],
238
+ account: account,
239
+ chain: client.chain
240
+ });
241
+ },
242
+ async registryOwner() {
243
+ return client.readContract({
244
+ address,
245
+ abi: RegistryABI,
246
+ functionName: 'owner',
247
+ args: []
248
+ });
249
+ },
250
+ async registryRenounceOwnership({ account }) {
251
+ return client.writeContract({
252
+ address,
253
+ abi: RegistryABI,
254
+ functionName: 'renounceOwnership',
255
+ args: [],
256
+ account: account,
257
+ chain: client.chain
258
+ });
259
+ },
260
+ // View Functions
261
+ async registryRoleConfigs({ roleId }) {
262
+ return client.readContract({
263
+ address,
264
+ abi: RegistryABI,
265
+ functionName: 'roleConfigs',
266
+ args: [roleId]
267
+ });
268
+ },
269
+ async registryRoleCounts({ roleId }) {
270
+ return client.readContract({
271
+ address,
272
+ abi: RegistryABI,
273
+ functionName: 'roleCounts',
274
+ args: [roleId]
275
+ });
276
+ },
277
+ // Alias: getRoleMemberCount maps to contract's getRoleUserCount
278
+ async registryGetRoleMemberCount({ roleId }) {
279
+ return client.readContract({
280
+ address,
281
+ abi: RegistryABI,
282
+ functionName: 'getRoleUserCount',
283
+ args: [roleId]
284
+ });
285
+ },
286
+ async registryRoleMembers({ roleId, index }) {
287
+ return client.readContract({
288
+ address,
289
+ abi: RegistryABI,
290
+ functionName: 'roleMembers',
291
+ args: [roleId, index]
292
+ });
293
+ },
294
+ async registryUserRoles({ user, index }) {
295
+ return client.readContract({
296
+ address,
297
+ abi: RegistryABI,
298
+ functionName: 'userRoles',
299
+ args: [user, index]
300
+ });
301
+ },
302
+ async registryUserRoleCount({ user }) {
303
+ return client.readContract({
304
+ address,
305
+ abi: RegistryABI,
306
+ functionName: 'userRoleCount',
307
+ args: [user]
308
+ });
309
+ },
310
+ async registryLevelThresholds({ level }) {
311
+ return client.readContract({
312
+ address,
313
+ abi: RegistryABI,
314
+ functionName: 'levelThresholds',
315
+ args: [level]
316
+ });
317
+ },
318
+ async registryExecutedProposals({ proposalId }) {
319
+ return client.readContract({
320
+ address,
321
+ abi: RegistryABI,
322
+ functionName: 'executedProposals',
323
+ args: [proposalId]
324
+ });
325
+ },
326
+ // Community lookup functions
327
+ async registryCommunityByName({ name }) {
328
+ return client.readContract({
329
+ address,
330
+ abi: RegistryABI,
331
+ functionName: 'communityByName',
332
+ args: [name]
333
+ });
334
+ },
335
+ async registryCommunityByENS({ ensName }) {
336
+ return client.readContract({
337
+ address,
338
+ abi: RegistryABI,
339
+ functionName: 'communityByENS',
340
+ args: [ensName]
341
+ });
342
+ },
343
+ async registryCommunityByNameV3({ name }) {
344
+ return this.registryCommunityByName({ name });
345
+ },
346
+ async registryCommunityByENSV3({ ensName }) {
347
+ return this.registryCommunityByENS({ ensName });
348
+ },
349
+ async registryProposedRoleNames({ roleId }) {
350
+ return client.readContract({
351
+ address,
352
+ abi: RegistryABI,
353
+ functionName: 'proposedRoleNames',
354
+ args: [roleId]
355
+ });
356
+ },
357
+ // Role Metadata & Members
358
+ async registryRoleLockDurations({ roleId }) {
359
+ return client.readContract({
360
+ address,
361
+ abi: RegistryABI,
362
+ functionName: 'roleLockDurations',
363
+ args: [roleId]
364
+ });
365
+ },
366
+ async registryRoleMetadata({ roleId, user }) {
367
+ return client.readContract({
368
+ address,
369
+ abi: RegistryABI,
370
+ functionName: 'roleMetadata',
371
+ args: user ? [roleId, user] : [roleId]
372
+ });
373
+ },
374
+ async registryRoleStakes({ roleId, user }) {
375
+ return client.readContract({
376
+ address,
377
+ abi: RegistryABI,
378
+ functionName: 'roleStakes',
379
+ args: [roleId, user]
380
+ });
381
+ },
382
+ async registryRoleSBTTokenIds({ roleId, user }) {
383
+ return client.readContract({
384
+ address,
385
+ abi: RegistryABI,
386
+ functionName: 'roleSBTTokenIds',
387
+ args: [roleId, user]
388
+ });
389
+ },
390
+ async registryRoleOwners({ roleId }) {
391
+ return client.readContract({
392
+ address,
393
+ abi: RegistryABI,
394
+ functionName: 'roleOwners',
395
+ args: [roleId]
396
+ });
397
+ },
398
+ async registryRoleMemberIndex({ roleId, user }) {
399
+ return client.readContract({
400
+ address,
401
+ abi: RegistryABI,
402
+ functionName: 'roleMemberIndex',
403
+ args: [roleId, user]
404
+ });
405
+ },
406
+ async registryGetRoleMembers({ roleId }) {
407
+ return client.readContract({
408
+ address,
409
+ abi: RegistryABI,
410
+ functionName: 'getRoleMembers',
411
+ args: [roleId]
412
+ });
413
+ },
414
+ async registryGetRoleUserCount({ roleId }) {
415
+ return client.readContract({
416
+ address,
417
+ abi: RegistryABI,
418
+ functionName: 'getRoleUserCount',
419
+ args: [roleId]
420
+ });
421
+ },
422
+ async registryGetUserRoles({ user }) {
423
+ return client.readContract({
424
+ address,
425
+ abi: RegistryABI,
426
+ functionName: 'getUserRoles',
427
+ args: [user]
428
+ });
429
+ },
430
+ async registryExitRole({ roleId, account }) {
431
+ return client.writeContract({
432
+ address,
433
+ abi: RegistryABI,
434
+ functionName: 'exitRole',
435
+ args: [roleId],
436
+ account: account,
437
+ chain: client.chain
438
+ });
439
+ },
440
+ async registryCalculateExitFee({ roleId, amount }) {
441
+ return client.readContract({
442
+ address,
443
+ abi: RegistryABI,
444
+ functionName: 'calculateExitFee',
445
+ args: [roleId, amount]
446
+ });
447
+ },
448
+ async registryAddLevelThreshold({ threshold, account }) {
449
+ return client.writeContract({
450
+ address,
451
+ abi: RegistryABI,
452
+ functionName: 'addLevelThreshold',
453
+ args: [threshold],
454
+ account: account,
455
+ chain: client.chain
456
+ });
457
+ },
458
+ async registrySetLevelThreshold({ index, threshold, account }) {
459
+ return client.writeContract({
460
+ address,
461
+ abi: RegistryABI,
462
+ functionName: 'setLevelThreshold',
463
+ args: [index, threshold],
464
+ account: account,
465
+ chain: client.chain
466
+ });
467
+ },
468
+ async registryAccountToUser({ account: userAccount }) {
469
+ return client.readContract({
470
+ address,
471
+ abi: RegistryABI,
472
+ functionName: 'accountToUser',
473
+ args: [userAccount]
474
+ });
475
+ },
476
+ // Credit & Tiers
477
+ async registryGetCreditLimit({ user }) {
478
+ return client.readContract({
479
+ address,
480
+ abi: RegistryABI,
481
+ functionName: 'getCreditLimit',
482
+ args: [user]
483
+ });
484
+ },
485
+ async registrySetCreditTier({ level, limit, account }) {
486
+ return client.writeContract({
487
+ address,
488
+ abi: RegistryABI,
489
+ functionName: 'setCreditTier',
490
+ args: [level, limit],
491
+ account: account,
492
+ chain: client.chain
493
+ });
494
+ },
495
+ async registryCreditTierConfig({ level }) {
496
+ return client.readContract({
497
+ address,
498
+ abi: RegistryABI,
499
+ functionName: 'creditTierConfig',
500
+ args: [level]
501
+ });
502
+ },
503
+ // Role Admin
504
+ async registryAdminConfigureRole({ roleId, minStake, entryBurn, exitFeePercent, minExitFee, account }) {
505
+ return client.writeContract({
506
+ address,
507
+ abi: RegistryABI,
508
+ functionName: 'adminConfigureRole',
509
+ args: [roleId, minStake, entryBurn, exitFeePercent, minExitFee],
510
+ account: account,
511
+ chain: client.chain
512
+ });
513
+ },
514
+ async registryCreateNewRole({ roleId, config, roleOwner, account }) {
515
+ return client.writeContract({
516
+ address,
517
+ abi: RegistryABI,
518
+ functionName: 'createNewRole',
519
+ args: [roleId, config, roleOwner],
520
+ account: account,
521
+ chain: client.chain
522
+ });
523
+ },
524
+ async registrySafeMintForRole({ roleId, user, data, account }) {
525
+ return client.writeContract({
526
+ address,
527
+ abi: RegistryABI,
528
+ functionName: 'safeMintForRole',
529
+ args: [roleId, user, data],
530
+ account: account,
531
+ chain: client.chain
532
+ });
533
+ },
534
+ async registryGetAccountCommunity({ account: userAccount }) {
535
+ // Check if user has COMMUNITY role
536
+ const COMMUNITY_ROLE_ID = '0x0000000000000000000000000000000000000000000000000000000000000002';
537
+ const hasRole = await client.readContract({
538
+ address,
539
+ abi: RegistryABI,
540
+ functionName: 'hasRole',
541
+ args: [userAccount, COMMUNITY_ROLE_ID]
542
+ });
543
+ if (!hasRole) {
544
+ return '0x0000000000000000000000000000000000000000';
545
+ }
546
+ // Get role data which contains the community token address
547
+ const roleData = await client.readContract({
548
+ address,
549
+ abi: RegistryABI,
550
+ functionName: 'getRoleData',
551
+ args: [userAccount, COMMUNITY_ROLE_ID]
552
+ });
553
+ // Parse community token from role data (first 20 bytes after removing 0x)
554
+ if (!roleData || roleData === '0x') {
555
+ return '0x0000000000000000000000000000000000000000';
556
+ }
557
+ // Community token is at bytes 0-19 of roleData
558
+ const tokenAddress = ('0x' + roleData.slice(2, 42));
559
+ return tokenAddress;
560
+ },
561
+ // Constants (Role IDs)
562
+ async registryROLE_COMMUNITY() {
563
+ return client.readContract({
564
+ address,
565
+ abi: RegistryABI,
566
+ functionName: 'ROLE_COMMUNITY',
567
+ args: []
568
+ });
569
+ },
570
+ async registryROLE_ENDUSER() {
571
+ return client.readContract({
572
+ address,
573
+ abi: RegistryABI,
574
+ functionName: 'ROLE_ENDUSER',
575
+ args: []
576
+ });
577
+ },
578
+ async registryROLE_PAYMASTER_SUPER() {
579
+ return client.readContract({
580
+ address,
581
+ abi: RegistryABI,
582
+ functionName: 'ROLE_PAYMASTER_SUPER',
583
+ args: []
584
+ });
585
+ },
586
+ async registryROLE_PAYMASTER_AOA() {
587
+ return client.readContract({
588
+ address,
589
+ abi: RegistryABI,
590
+ functionName: 'ROLE_PAYMASTER_AOA',
591
+ args: []
592
+ });
593
+ },
594
+ async registryROLE_DVT() {
595
+ return client.readContract({
596
+ address,
597
+ abi: RegistryABI,
598
+ functionName: 'ROLE_DVT',
599
+ args: []
600
+ });
601
+ },
602
+ async registryROLE_KMS() {
603
+ return client.readContract({
604
+ address,
605
+ abi: RegistryABI,
606
+ functionName: 'ROLE_KMS',
607
+ args: []
608
+ });
609
+ },
610
+ async registryROLE_ANODE() {
611
+ return client.readContract({
612
+ address,
613
+ abi: RegistryABI,
614
+ functionName: 'ROLE_ANODE',
615
+ args: []
616
+ });
617
+ },
618
+ async registryGTOKEN_STAKING() {
619
+ return client.readContract({
620
+ address,
621
+ abi: RegistryABI,
622
+ functionName: 'GTOKEN_STAKING',
623
+ args: []
624
+ });
625
+ },
626
+ async registryMYSBT() {
627
+ return client.readContract({
628
+ address,
629
+ abi: RegistryABI,
630
+ functionName: 'MYSBT',
631
+ args: []
632
+ });
633
+ },
634
+ async registrySUPER_PAYMASTER() {
635
+ return client.readContract({
636
+ address,
637
+ abi: RegistryABI,
638
+ functionName: 'SUPER_PAYMASTER',
639
+ args: []
640
+ });
641
+ },
642
+ async registryIsReputationSource({ source }) {
643
+ return client.readContract({
644
+ address,
645
+ abi: RegistryABI,
646
+ functionName: 'isReputationSource',
647
+ args: [source]
648
+ });
649
+ },
650
+ async registryLastReputationEpoch() {
651
+ return client.readContract({
652
+ address,
653
+ abi: RegistryABI,
654
+ functionName: 'lastReputationEpoch',
655
+ args: []
656
+ });
657
+ },
658
+ // Version
659
+ async registryVersion() {
660
+ return client.readContract({
661
+ address,
662
+ abi: RegistryABI,
663
+ functionName: 'version',
664
+ args: []
665
+ });
666
+ }
667
+ });