@aastar/core 0.16.8 → 0.16.12
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.
- package/dist/abis/PaymasterV4_2.json +1193 -0
- package/dist/abis/SuperPaymaster.json +1 -1
- package/dist/abis/aPNTs.json +1160 -0
- package/dist/abis/abi.config.json +3 -3
- package/dist/abis/index.d.ts +15 -104
- package/dist/abis/index.js +22 -46
- package/dist/actions/account.d.ts +0 -15
- package/dist/actions/account.js +143 -108
- package/dist/actions/aggregator.d.ts +68 -7
- package/dist/actions/aggregator.js +328 -28
- package/dist/actions/dvt.d.ts +33 -5
- package/dist/actions/dvt.js +238 -38
- package/dist/actions/entryPoint.d.ts +3 -63
- package/dist/actions/entryPoint.js +52 -184
- package/dist/actions/factory.d.ts +48 -115
- package/dist/actions/factory.js +638 -438
- package/dist/actions/faucet.d.ts +23 -27
- package/dist/actions/faucet.js +150 -289
- package/dist/actions/index.d.ts +1 -2
- package/dist/actions/index.js +2 -4
- package/dist/actions/paymaster.d.ts +147 -0
- package/dist/actions/paymaster.js +706 -0
- package/dist/actions/paymasterV4.d.ts +26 -95
- package/dist/actions/paymasterV4.js +28 -121
- package/dist/actions/registry.d.ts +116 -165
- package/dist/actions/registry.js +855 -654
- package/dist/actions/reputation.d.ts +74 -52
- package/dist/actions/reputation.js +548 -242
- package/dist/actions/sbt.d.ts +90 -100
- package/dist/actions/sbt.js +801 -518
- package/dist/actions/staking.d.ts +45 -32
- package/dist/actions/staking.js +431 -260
- package/dist/actions/superPaymaster.d.ts +140 -158
- package/dist/actions/superPaymaster.js +965 -631
- package/dist/actions/tokens.d.ts +130 -108
- package/dist/actions/tokens.js +470 -414
- package/dist/actions/validators.d.ts +0 -73
- package/dist/actions/validators.js +0 -94
- package/dist/clients/BaseClient.d.ts +3 -3
- package/dist/clients/BundlerClient.d.ts +55 -0
- package/dist/clients/BundlerClient.js +92 -0
- package/dist/communities.js +2 -2
- package/dist/constants.js +1 -28
- package/dist/contract-addresses.d.ts +5 -14
- package/dist/contract-addresses.js +3 -9
- package/dist/contract-versions.d.ts +138 -0
- package/dist/contract-versions.js +328 -0
- package/dist/contracts.d.ts +6 -24
- package/dist/contracts.js +2 -2
- package/dist/errors/index.d.ts +57 -0
- package/dist/errors/index.js +123 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/requirementChecker.d.ts +35 -1
- package/dist/requirementChecker.js +39 -1
- package/dist/roles.d.ts +50 -61
- package/dist/roles.js +50 -61
- package/dist/validators/index.d.ts +35 -0
- package/dist/validators/index.js +60 -0
- package/package.json +5 -13
package/dist/actions/registry.js
CHANGED
|
@@ -1,667 +1,868 @@
|
|
|
1
1
|
import { RegistryABI } from '../abis/index.js';
|
|
2
|
+
import { validateAddress, validateRequired, validateAmount } from '../validators/index.js';
|
|
3
|
+
import { AAStarError } from '../errors/index.js';
|
|
2
4
|
export const registryActions = (address) => (client) => ({
|
|
3
5
|
// Role Management
|
|
4
|
-
async
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
6
|
+
async configureRole({ roleId, config, account }) {
|
|
7
|
+
try {
|
|
8
|
+
validateRequired(roleId, 'roleId');
|
|
9
|
+
validateRequired(config, 'config');
|
|
10
|
+
return await client.writeContract({
|
|
11
|
+
address,
|
|
12
|
+
abi: RegistryABI,
|
|
13
|
+
functionName: 'configureRole',
|
|
14
|
+
args: [roleId, config],
|
|
15
|
+
account: account,
|
|
16
|
+
chain: client.chain
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
throw AAStarError.fromViemError(error, 'configureRole');
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
async adminConfigureRole({ roleId, minStake, entryBurn, exitFeePercent, minExitFee, account }) {
|
|
24
|
+
try {
|
|
25
|
+
validateRequired(roleId, 'roleId');
|
|
26
|
+
return await client.writeContract({
|
|
27
|
+
address,
|
|
28
|
+
abi: RegistryABI,
|
|
29
|
+
functionName: 'adminConfigureRole',
|
|
30
|
+
args: [roleId, minStake, entryBurn, exitFeePercent, minExitFee],
|
|
31
|
+
account: account,
|
|
32
|
+
chain: client.chain
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
throw AAStarError.fromViemError(error, 'adminConfigureRole');
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
async createNewRole({ roleId, config, roleOwner, account }) {
|
|
40
|
+
try {
|
|
41
|
+
validateRequired(roleId, 'roleId');
|
|
42
|
+
validateRequired(config, 'config');
|
|
43
|
+
validateAddress(roleOwner, 'roleOwner');
|
|
44
|
+
return await client.writeContract({
|
|
45
|
+
address,
|
|
46
|
+
abi: RegistryABI,
|
|
47
|
+
functionName: 'createNewRole',
|
|
48
|
+
args: [roleId, config, roleOwner],
|
|
49
|
+
account: account,
|
|
50
|
+
chain: client.chain
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
throw AAStarError.fromViemError(error, 'createNewRole');
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
async registerRole({ roleId, user, data, account }) {
|
|
58
|
+
try {
|
|
59
|
+
validateRequired(roleId, 'roleId');
|
|
60
|
+
validateAddress(user, 'user');
|
|
61
|
+
return await client.writeContract({
|
|
62
|
+
address,
|
|
63
|
+
abi: RegistryABI,
|
|
64
|
+
functionName: 'registerRole',
|
|
65
|
+
args: [roleId, user, data],
|
|
66
|
+
account: account,
|
|
67
|
+
chain: client.chain
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
throw AAStarError.fromViemError(error, 'registerRole');
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
async registerRoleSelf({ roleId, data, account }) {
|
|
75
|
+
try {
|
|
76
|
+
validateRequired(roleId, 'roleId');
|
|
77
|
+
return await client.writeContract({
|
|
78
|
+
address,
|
|
79
|
+
abi: RegistryABI,
|
|
80
|
+
functionName: 'registerRoleSelf',
|
|
81
|
+
args: [roleId, data],
|
|
82
|
+
account: account,
|
|
83
|
+
chain: client.chain
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
throw AAStarError.fromViemError(error, 'registerRoleSelf');
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
async safeMintForRole({ roleId, user, data, account }) {
|
|
91
|
+
try {
|
|
92
|
+
validateRequired(roleId, 'roleId');
|
|
93
|
+
validateAddress(user, 'user');
|
|
94
|
+
return await client.writeContract({
|
|
95
|
+
address,
|
|
96
|
+
abi: RegistryABI,
|
|
97
|
+
functionName: 'safeMintForRole',
|
|
98
|
+
args: [roleId, user, data],
|
|
99
|
+
account: account,
|
|
100
|
+
chain: client.chain
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
throw AAStarError.fromViemError(error, 'safeMintForRole');
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
async hasRole({ roleId, user }) {
|
|
108
|
+
try {
|
|
109
|
+
validateRequired(roleId, 'roleId');
|
|
110
|
+
validateAddress(user, 'user');
|
|
111
|
+
return await client.readContract({
|
|
112
|
+
address,
|
|
113
|
+
abi: RegistryABI,
|
|
114
|
+
functionName: 'hasRole',
|
|
115
|
+
args: [roleId, user]
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
throw AAStarError.fromViemError(error, 'hasRole');
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
async getRoleConfig({ roleId }) {
|
|
123
|
+
try {
|
|
124
|
+
validateRequired(roleId, 'roleId');
|
|
125
|
+
const result = await client.readContract({
|
|
126
|
+
address,
|
|
127
|
+
abi: RegistryABI,
|
|
128
|
+
functionName: 'getRoleConfig',
|
|
129
|
+
args: [roleId]
|
|
130
|
+
});
|
|
131
|
+
if (Array.isArray(result)) {
|
|
132
|
+
return {
|
|
133
|
+
minStake: result[0],
|
|
134
|
+
entryBurn: result[1],
|
|
135
|
+
slashThreshold: result[2],
|
|
136
|
+
slashBase: result[3],
|
|
137
|
+
slashInc: result[4],
|
|
138
|
+
slashMax: result[5],
|
|
139
|
+
exitFeePercent: result[6],
|
|
140
|
+
isActive: result[7],
|
|
141
|
+
minExitFee: result[8],
|
|
142
|
+
description: result[9],
|
|
143
|
+
owner: result[10],
|
|
144
|
+
roleLockDuration: result[11]
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
throw AAStarError.fromViemError(error, 'getRoleConfig');
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
async setRoleLockDuration({ roleId, duration, account }) {
|
|
154
|
+
try {
|
|
155
|
+
validateRequired(roleId, 'roleId');
|
|
156
|
+
validateRequired(duration, 'duration');
|
|
157
|
+
return await client.writeContract({
|
|
158
|
+
address,
|
|
159
|
+
abi: RegistryABI,
|
|
160
|
+
functionName: 'setRoleLockDuration',
|
|
161
|
+
args: [roleId, duration],
|
|
162
|
+
account: account,
|
|
163
|
+
chain: client.chain
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
throw AAStarError.fromViemError(error, 'setRoleLockDuration');
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
async setRoleOwner({ roleId, newOwner, account }) {
|
|
171
|
+
try {
|
|
172
|
+
validateRequired(roleId, 'roleId');
|
|
173
|
+
validateAddress(newOwner, 'newOwner');
|
|
174
|
+
return await client.writeContract({
|
|
175
|
+
address,
|
|
176
|
+
abi: RegistryABI,
|
|
177
|
+
functionName: 'setRoleOwner',
|
|
178
|
+
args: [roleId, newOwner],
|
|
179
|
+
account: account,
|
|
180
|
+
chain: client.chain
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
throw AAStarError.fromViemError(error, 'setRoleOwner');
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
async exitRole({ roleId, account }) {
|
|
188
|
+
try {
|
|
189
|
+
validateRequired(roleId, 'roleId');
|
|
190
|
+
return await client.writeContract({
|
|
191
|
+
address,
|
|
192
|
+
abi: RegistryABI,
|
|
193
|
+
functionName: 'exitRole',
|
|
194
|
+
args: [roleId],
|
|
195
|
+
account: account,
|
|
196
|
+
chain: client.chain
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
throw AAStarError.fromViemError(error, 'exitRole');
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
// Community Management
|
|
204
|
+
async communityByName({ name }) {
|
|
205
|
+
try {
|
|
206
|
+
validateRequired(name, 'name');
|
|
207
|
+
return await client.readContract({
|
|
208
|
+
address,
|
|
209
|
+
abi: RegistryABI,
|
|
210
|
+
functionName: 'communityByName',
|
|
211
|
+
args: [name]
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
throw AAStarError.fromViemError(error, 'communityByName');
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
async communityByENS({ ensName }) {
|
|
219
|
+
try {
|
|
220
|
+
validateRequired(ensName, 'ensName');
|
|
221
|
+
return await client.readContract({
|
|
222
|
+
address,
|
|
223
|
+
abi: RegistryABI,
|
|
224
|
+
functionName: 'communityByENS',
|
|
225
|
+
args: [ensName]
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
catch (error) {
|
|
229
|
+
throw AAStarError.fromViemError(error, 'communityByENS');
|
|
230
|
+
}
|
|
83
231
|
},
|
|
84
232
|
// Credit & Reputation
|
|
85
|
-
async
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
233
|
+
async getCreditLimit({ user }) {
|
|
234
|
+
try {
|
|
235
|
+
validateAddress(user, 'user');
|
|
236
|
+
return await client.readContract({
|
|
237
|
+
address,
|
|
238
|
+
abi: RegistryABI,
|
|
239
|
+
functionName: 'getCreditLimit',
|
|
240
|
+
args: [user]
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
throw AAStarError.fromViemError(error, 'getCreditLimit');
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
async globalReputation({ user }) {
|
|
248
|
+
try {
|
|
249
|
+
validateAddress(user, 'user');
|
|
250
|
+
return await client.readContract({
|
|
251
|
+
address,
|
|
252
|
+
abi: RegistryABI,
|
|
253
|
+
functionName: 'globalReputation',
|
|
254
|
+
args: [user]
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
throw AAStarError.fromViemError(error, 'globalReputation');
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
async addLevelThreshold({ threshold, account }) {
|
|
262
|
+
try {
|
|
263
|
+
validateAmount(threshold, 'threshold');
|
|
264
|
+
return await client.writeContract({
|
|
265
|
+
address,
|
|
266
|
+
abi: RegistryABI,
|
|
267
|
+
functionName: 'addLevelThreshold',
|
|
268
|
+
args: [threshold],
|
|
269
|
+
account: account,
|
|
270
|
+
chain: client.chain
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
catch (error) {
|
|
274
|
+
throw AAStarError.fromViemError(error, 'addLevelThreshold');
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
async batchUpdateGlobalReputation({ proposalId, users, newScores, epoch, proof, account }) {
|
|
278
|
+
try {
|
|
279
|
+
validateAmount(proposalId, 'proposalId');
|
|
280
|
+
validateRequired(users, 'users');
|
|
281
|
+
validateRequired(newScores, 'newScores');
|
|
282
|
+
validateAmount(epoch, 'epoch');
|
|
283
|
+
validateRequired(proof, 'proof');
|
|
284
|
+
return await client.writeContract({
|
|
285
|
+
address,
|
|
286
|
+
abi: RegistryABI,
|
|
287
|
+
functionName: 'batchUpdateGlobalReputation',
|
|
288
|
+
args: [proposalId, users, newScores, epoch, proof],
|
|
289
|
+
account: account,
|
|
290
|
+
chain: client.chain
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
catch (error) {
|
|
294
|
+
throw AAStarError.fromViemError(error, 'batchUpdateGlobalReputation');
|
|
295
|
+
}
|
|
121
296
|
},
|
|
122
297
|
// Contract References
|
|
123
|
-
async
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
async
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
298
|
+
async setBLSValidator({ validator, account }) {
|
|
299
|
+
try {
|
|
300
|
+
validateAddress(validator, 'validator');
|
|
301
|
+
return await client.writeContract({
|
|
302
|
+
address,
|
|
303
|
+
abi: RegistryABI,
|
|
304
|
+
functionName: 'setBLSValidator',
|
|
305
|
+
args: [validator],
|
|
306
|
+
account: account,
|
|
307
|
+
chain: client.chain
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
catch (error) {
|
|
311
|
+
throw AAStarError.fromViemError(error, 'setBLSValidator');
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
async setBLSAggregator({ aggregator, account }) {
|
|
315
|
+
try {
|
|
316
|
+
validateAddress(aggregator, 'aggregator');
|
|
317
|
+
return await client.writeContract({
|
|
318
|
+
address,
|
|
319
|
+
abi: RegistryABI,
|
|
320
|
+
functionName: 'setBLSAggregator',
|
|
321
|
+
args: [aggregator],
|
|
322
|
+
account: account,
|
|
323
|
+
chain: client.chain
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
catch (error) {
|
|
327
|
+
throw AAStarError.fromViemError(error, 'setBLSAggregator');
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
async setMySBT({ sbt, account }) {
|
|
331
|
+
try {
|
|
332
|
+
validateAddress(sbt, 'sbt');
|
|
333
|
+
return await client.writeContract({
|
|
334
|
+
address,
|
|
335
|
+
abi: RegistryABI,
|
|
336
|
+
functionName: 'setMySBT',
|
|
337
|
+
args: [sbt],
|
|
338
|
+
account: account,
|
|
339
|
+
chain: client.chain
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
catch (error) {
|
|
343
|
+
throw AAStarError.fromViemError(error, 'setMySBT');
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
async setSuperPaymaster({ paymaster, account }) {
|
|
347
|
+
try {
|
|
348
|
+
validateAddress(paymaster, 'paymaster');
|
|
349
|
+
return await client.writeContract({
|
|
350
|
+
address,
|
|
351
|
+
abi: RegistryABI,
|
|
352
|
+
functionName: 'setSuperPaymaster',
|
|
353
|
+
args: [paymaster],
|
|
354
|
+
account: account,
|
|
355
|
+
chain: client.chain
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
catch (error) {
|
|
359
|
+
throw AAStarError.fromViemError(error, 'setSuperPaymaster');
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
async setStaking({ staking, account }) {
|
|
363
|
+
try {
|
|
364
|
+
validateAddress(staking, 'staking');
|
|
365
|
+
return await client.writeContract({
|
|
366
|
+
address,
|
|
367
|
+
abi: RegistryABI,
|
|
368
|
+
functionName: 'setStaking',
|
|
369
|
+
args: [staking],
|
|
370
|
+
account: account,
|
|
371
|
+
chain: client.chain
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
catch (error) {
|
|
375
|
+
throw AAStarError.fromViemError(error, 'setStaking');
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
async setReputationSource({ source, account }) {
|
|
379
|
+
try {
|
|
380
|
+
validateAddress(source, 'source');
|
|
381
|
+
return await client.writeContract({
|
|
382
|
+
address,
|
|
383
|
+
abi: RegistryABI,
|
|
384
|
+
functionName: 'setReputationSource',
|
|
385
|
+
args: [source],
|
|
386
|
+
account: account,
|
|
387
|
+
chain: client.chain
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
catch (error) {
|
|
391
|
+
throw AAStarError.fromViemError(error, 'setReputationSource');
|
|
392
|
+
}
|
|
393
|
+
},
|
|
394
|
+
async blsValidator() {
|
|
395
|
+
try {
|
|
396
|
+
return await client.readContract({
|
|
397
|
+
address,
|
|
398
|
+
abi: RegistryABI,
|
|
399
|
+
functionName: 'blsValidator',
|
|
400
|
+
args: []
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
catch (error) {
|
|
404
|
+
throw AAStarError.fromViemError(error, 'blsValidator');
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
async blsAggregator() {
|
|
408
|
+
try {
|
|
409
|
+
return await client.readContract({
|
|
410
|
+
address,
|
|
411
|
+
abi: RegistryABI,
|
|
412
|
+
functionName: 'blsAggregator',
|
|
413
|
+
args: []
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
catch (error) {
|
|
417
|
+
throw AAStarError.fromViemError(error, 'blsAggregator');
|
|
418
|
+
}
|
|
419
|
+
},
|
|
420
|
+
async MYSBT() {
|
|
421
|
+
try {
|
|
422
|
+
return await client.readContract({
|
|
423
|
+
address,
|
|
424
|
+
abi: RegistryABI,
|
|
425
|
+
functionName: 'MYSBT',
|
|
426
|
+
args: []
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
catch (error) {
|
|
430
|
+
throw AAStarError.fromViemError(error, 'MYSBT');
|
|
431
|
+
}
|
|
432
|
+
},
|
|
433
|
+
async SUPER_PAYMASTER() {
|
|
434
|
+
try {
|
|
435
|
+
return await client.readContract({
|
|
436
|
+
address,
|
|
437
|
+
abi: RegistryABI,
|
|
438
|
+
functionName: 'SUPER_PAYMASTER',
|
|
439
|
+
args: []
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
catch (error) {
|
|
443
|
+
throw AAStarError.fromViemError(error, 'SUPER_PAYMASTER');
|
|
444
|
+
}
|
|
445
|
+
},
|
|
446
|
+
async GTOKEN_STAKING() {
|
|
447
|
+
try {
|
|
448
|
+
return await client.readContract({
|
|
449
|
+
address,
|
|
450
|
+
abi: RegistryABI,
|
|
451
|
+
functionName: 'GTOKEN_STAKING',
|
|
452
|
+
args: []
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
catch (error) {
|
|
456
|
+
throw AAStarError.fromViemError(error, 'GTOKEN_STAKING');
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
async reputationSource() {
|
|
460
|
+
try {
|
|
461
|
+
return await client.readContract({
|
|
462
|
+
address,
|
|
463
|
+
abi: RegistryABI,
|
|
464
|
+
functionName: 'reputationSource',
|
|
465
|
+
args: []
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
catch (error) {
|
|
469
|
+
throw AAStarError.fromViemError(error, 'reputationSource');
|
|
470
|
+
}
|
|
471
|
+
},
|
|
472
|
+
async isReputationSource({ source }) {
|
|
473
|
+
try {
|
|
474
|
+
validateAddress(source, 'source');
|
|
475
|
+
return await client.readContract({
|
|
476
|
+
address,
|
|
477
|
+
abi: RegistryABI,
|
|
478
|
+
functionName: 'isReputationSource',
|
|
479
|
+
args: [source]
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
catch (error) {
|
|
483
|
+
throw AAStarError.fromViemError(error, 'isReputationSource');
|
|
484
|
+
}
|
|
485
|
+
},
|
|
486
|
+
async lastReputationEpoch({ user }) {
|
|
487
|
+
try {
|
|
488
|
+
validateAddress(user, 'user');
|
|
489
|
+
return await client.readContract({
|
|
490
|
+
address,
|
|
491
|
+
abi: RegistryABI,
|
|
492
|
+
functionName: 'lastReputationEpoch',
|
|
493
|
+
args: [user]
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
catch (error) {
|
|
497
|
+
throw AAStarError.fromViemError(error, 'lastReputationEpoch');
|
|
498
|
+
}
|
|
259
499
|
},
|
|
260
500
|
// View Functions
|
|
261
|
-
async
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
},
|
|
349
|
-
async
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
}
|
|
405
|
-
},
|
|
406
|
-
async
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
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;
|
|
501
|
+
async roleConfigs({ roleId }) {
|
|
502
|
+
try {
|
|
503
|
+
validateRequired(roleId, 'roleId');
|
|
504
|
+
const result = await client.readContract({
|
|
505
|
+
address,
|
|
506
|
+
abi: RegistryABI,
|
|
507
|
+
functionName: 'roleConfigs',
|
|
508
|
+
args: [roleId]
|
|
509
|
+
});
|
|
510
|
+
if (Array.isArray(result)) {
|
|
511
|
+
return {
|
|
512
|
+
minStake: result[0],
|
|
513
|
+
entryBurn: result[1],
|
|
514
|
+
slashThreshold: result[2],
|
|
515
|
+
slashBase: result[3],
|
|
516
|
+
slashInc: result[4],
|
|
517
|
+
slashMax: result[5],
|
|
518
|
+
exitFeePercent: result[6],
|
|
519
|
+
isActive: result[7],
|
|
520
|
+
minExitFee: result[8],
|
|
521
|
+
description: result[9],
|
|
522
|
+
owner: result[10],
|
|
523
|
+
roleLockDuration: result[11]
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
return result;
|
|
527
|
+
}
|
|
528
|
+
catch (error) {
|
|
529
|
+
throw AAStarError.fromViemError(error, 'roleConfigs');
|
|
530
|
+
}
|
|
531
|
+
},
|
|
532
|
+
async getRoleUserCount({ roleId }) {
|
|
533
|
+
try {
|
|
534
|
+
validateRequired(roleId, 'roleId');
|
|
535
|
+
return await client.readContract({
|
|
536
|
+
address,
|
|
537
|
+
abi: RegistryABI,
|
|
538
|
+
functionName: 'getRoleUserCount',
|
|
539
|
+
args: [roleId]
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
catch (error) {
|
|
543
|
+
throw AAStarError.fromViemError(error, 'getRoleUserCount');
|
|
544
|
+
}
|
|
545
|
+
},
|
|
546
|
+
async getRoleMembers({ roleId }) {
|
|
547
|
+
try {
|
|
548
|
+
validateRequired(roleId, 'roleId');
|
|
549
|
+
return await client.readContract({
|
|
550
|
+
address,
|
|
551
|
+
abi: RegistryABI,
|
|
552
|
+
functionName: 'getRoleMembers',
|
|
553
|
+
args: [roleId]
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
catch (error) {
|
|
557
|
+
throw AAStarError.fromViemError(error, 'getRoleMembers');
|
|
558
|
+
}
|
|
559
|
+
},
|
|
560
|
+
async getUserRoles({ user }) {
|
|
561
|
+
try {
|
|
562
|
+
validateAddress(user, 'user');
|
|
563
|
+
return await client.readContract({
|
|
564
|
+
address,
|
|
565
|
+
abi: RegistryABI,
|
|
566
|
+
functionName: 'getUserRoles',
|
|
567
|
+
args: [user]
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
catch (error) {
|
|
571
|
+
throw AAStarError.fromViemError(error, 'getUserRoles');
|
|
572
|
+
}
|
|
573
|
+
},
|
|
574
|
+
async roleMembers({ roleId, index }) {
|
|
575
|
+
try {
|
|
576
|
+
validateRequired(roleId, 'roleId');
|
|
577
|
+
validateRequired(index, 'index');
|
|
578
|
+
return await client.readContract({
|
|
579
|
+
address,
|
|
580
|
+
abi: RegistryABI,
|
|
581
|
+
functionName: 'roleMembers',
|
|
582
|
+
args: [roleId, index]
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
catch (error) {
|
|
586
|
+
throw AAStarError.fromViemError(error, 'roleMembers');
|
|
587
|
+
}
|
|
588
|
+
},
|
|
589
|
+
async userRoles({ user, index }) {
|
|
590
|
+
try {
|
|
591
|
+
validateAddress(user, 'user');
|
|
592
|
+
validateRequired(index, 'index');
|
|
593
|
+
return await client.readContract({
|
|
594
|
+
address,
|
|
595
|
+
abi: RegistryABI,
|
|
596
|
+
functionName: 'userRoles',
|
|
597
|
+
args: [user, index]
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
catch (error) {
|
|
601
|
+
throw AAStarError.fromViemError(error, 'userRoles');
|
|
602
|
+
}
|
|
603
|
+
},
|
|
604
|
+
async userRoleCount({ user }) {
|
|
605
|
+
try {
|
|
606
|
+
validateAddress(user, 'user');
|
|
607
|
+
return await client.readContract({
|
|
608
|
+
address,
|
|
609
|
+
abi: RegistryABI,
|
|
610
|
+
functionName: 'userRoleCount',
|
|
611
|
+
args: [user]
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
catch (error) {
|
|
615
|
+
throw AAStarError.fromViemError(error, 'userRoleCount');
|
|
616
|
+
}
|
|
617
|
+
},
|
|
618
|
+
async creditTierConfig({ tierIndex }) {
|
|
619
|
+
try {
|
|
620
|
+
validateAmount(tierIndex, 'tierIndex');
|
|
621
|
+
return await client.readContract({
|
|
622
|
+
address,
|
|
623
|
+
abi: RegistryABI,
|
|
624
|
+
functionName: 'creditTierConfig',
|
|
625
|
+
args: [tierIndex]
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
catch (error) {
|
|
629
|
+
throw AAStarError.fromViemError(error, 'creditTierConfig');
|
|
630
|
+
}
|
|
631
|
+
},
|
|
632
|
+
async levelThresholds({ levelIndex }) {
|
|
633
|
+
try {
|
|
634
|
+
validateAmount(levelIndex, 'levelIndex');
|
|
635
|
+
return await client.readContract({
|
|
636
|
+
address,
|
|
637
|
+
abi: RegistryABI,
|
|
638
|
+
functionName: 'levelThresholds',
|
|
639
|
+
args: [levelIndex]
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
catch (error) {
|
|
643
|
+
throw AAStarError.fromViemError(error, 'levelThresholds');
|
|
644
|
+
}
|
|
645
|
+
},
|
|
646
|
+
async calculateExitFee({ roleId, amount }) {
|
|
647
|
+
try {
|
|
648
|
+
validateRequired(roleId, 'roleId');
|
|
649
|
+
validateAmount(amount, 'amount');
|
|
650
|
+
return await client.readContract({
|
|
651
|
+
address,
|
|
652
|
+
abi: RegistryABI,
|
|
653
|
+
functionName: 'calculateExitFee',
|
|
654
|
+
args: [roleId, amount]
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
catch (error) {
|
|
658
|
+
throw AAStarError.fromViemError(error, 'calculateExitFee');
|
|
659
|
+
}
|
|
660
|
+
},
|
|
661
|
+
async accountToUser({ account }) {
|
|
662
|
+
try {
|
|
663
|
+
validateAddress(account, 'account');
|
|
664
|
+
return await client.readContract({
|
|
665
|
+
address,
|
|
666
|
+
abi: RegistryABI,
|
|
667
|
+
functionName: 'accountToUser',
|
|
668
|
+
args: [account]
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
catch (error) {
|
|
672
|
+
throw AAStarError.fromViemError(error, 'accountToUser');
|
|
673
|
+
}
|
|
674
|
+
},
|
|
675
|
+
async roleOwners({ roleId }) {
|
|
676
|
+
try {
|
|
677
|
+
validateRequired(roleId, 'roleId');
|
|
678
|
+
return await client.readContract({
|
|
679
|
+
address,
|
|
680
|
+
abi: RegistryABI,
|
|
681
|
+
functionName: 'roleOwners',
|
|
682
|
+
args: [roleId]
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
catch (error) {
|
|
686
|
+
throw AAStarError.fromViemError(error, 'roleOwners');
|
|
687
|
+
}
|
|
688
|
+
},
|
|
689
|
+
async roleStakes({ roleId, user }) {
|
|
690
|
+
try {
|
|
691
|
+
validateRequired(roleId, 'roleId');
|
|
692
|
+
validateAddress(user, 'user');
|
|
693
|
+
return await client.readContract({
|
|
694
|
+
address,
|
|
695
|
+
abi: RegistryABI,
|
|
696
|
+
functionName: 'roleStakes',
|
|
697
|
+
args: [roleId, user]
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
catch (error) {
|
|
701
|
+
throw AAStarError.fromViemError(error, 'roleStakes');
|
|
702
|
+
}
|
|
703
|
+
},
|
|
704
|
+
async roleLockDurations({ roleId }) {
|
|
705
|
+
try {
|
|
706
|
+
validateRequired(roleId, 'roleId');
|
|
707
|
+
return await client.readContract({
|
|
708
|
+
address,
|
|
709
|
+
abi: RegistryABI,
|
|
710
|
+
functionName: 'roleLockDurations',
|
|
711
|
+
args: [roleId]
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
catch (error) {
|
|
715
|
+
throw AAStarError.fromViemError(error, 'roleLockDurations');
|
|
716
|
+
}
|
|
560
717
|
},
|
|
561
718
|
// Constants (Role IDs)
|
|
562
|
-
async
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
}
|
|
719
|
+
async ROLE_COMMUNITY() {
|
|
720
|
+
try {
|
|
721
|
+
return await client.readContract({
|
|
722
|
+
address,
|
|
723
|
+
abi: RegistryABI,
|
|
724
|
+
functionName: 'ROLE_COMMUNITY',
|
|
725
|
+
args: []
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
catch (error) {
|
|
729
|
+
throw AAStarError.fromViemError(error, 'ROLE_COMMUNITY');
|
|
730
|
+
}
|
|
731
|
+
},
|
|
732
|
+
async ROLE_ENDUSER() {
|
|
733
|
+
try {
|
|
734
|
+
return await client.readContract({
|
|
735
|
+
address,
|
|
736
|
+
abi: RegistryABI,
|
|
737
|
+
functionName: 'ROLE_ENDUSER',
|
|
738
|
+
args: []
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
catch (error) {
|
|
742
|
+
throw AAStarError.fromViemError(error, 'ROLE_ENDUSER');
|
|
743
|
+
}
|
|
744
|
+
},
|
|
745
|
+
async ROLE_PAYMASTER_SUPER() {
|
|
746
|
+
try {
|
|
747
|
+
return await client.readContract({
|
|
748
|
+
address,
|
|
749
|
+
abi: RegistryABI,
|
|
750
|
+
functionName: 'ROLE_PAYMASTER_SUPER',
|
|
751
|
+
args: []
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
catch (error) {
|
|
755
|
+
throw AAStarError.fromViemError(error, 'ROLE_PAYMASTER_SUPER');
|
|
756
|
+
}
|
|
757
|
+
},
|
|
758
|
+
async ROLE_PAYMASTER_AOA() {
|
|
759
|
+
try {
|
|
760
|
+
return await client.readContract({
|
|
761
|
+
address,
|
|
762
|
+
abi: RegistryABI,
|
|
763
|
+
functionName: 'ROLE_PAYMASTER_AOA',
|
|
764
|
+
args: []
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
catch (error) {
|
|
768
|
+
throw AAStarError.fromViemError(error, 'ROLE_PAYMASTER_AOA');
|
|
769
|
+
}
|
|
770
|
+
},
|
|
771
|
+
async ROLE_DVT() {
|
|
772
|
+
try {
|
|
773
|
+
return await client.readContract({
|
|
774
|
+
address,
|
|
775
|
+
abi: RegistryABI,
|
|
776
|
+
functionName: 'ROLE_DVT',
|
|
777
|
+
args: []
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
catch (error) {
|
|
781
|
+
throw AAStarError.fromViemError(error, 'ROLE_DVT');
|
|
782
|
+
}
|
|
783
|
+
},
|
|
784
|
+
async ROLE_KMS() {
|
|
785
|
+
try {
|
|
786
|
+
return await client.readContract({
|
|
787
|
+
address,
|
|
788
|
+
abi: RegistryABI,
|
|
789
|
+
functionName: 'ROLE_KMS',
|
|
790
|
+
args: []
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
catch (error) {
|
|
794
|
+
throw AAStarError.fromViemError(error, 'ROLE_KMS');
|
|
795
|
+
}
|
|
796
|
+
},
|
|
797
|
+
async ROLE_ANODE() {
|
|
798
|
+
try {
|
|
799
|
+
return await client.readContract({
|
|
800
|
+
address,
|
|
801
|
+
abi: RegistryABI,
|
|
802
|
+
functionName: 'ROLE_ANODE',
|
|
803
|
+
args: []
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
catch (error) {
|
|
807
|
+
throw AAStarError.fromViemError(error, 'ROLE_ANODE');
|
|
808
|
+
}
|
|
809
|
+
},
|
|
810
|
+
// Ownership
|
|
811
|
+
async owner() {
|
|
812
|
+
try {
|
|
813
|
+
return await client.readContract({
|
|
814
|
+
address,
|
|
815
|
+
abi: RegistryABI,
|
|
816
|
+
functionName: 'owner',
|
|
817
|
+
args: []
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
catch (error) {
|
|
821
|
+
throw AAStarError.fromViemError(error, 'owner');
|
|
822
|
+
}
|
|
823
|
+
},
|
|
824
|
+
async transferOwnership({ newOwner, account }) {
|
|
825
|
+
try {
|
|
826
|
+
validateAddress(newOwner, 'newOwner');
|
|
827
|
+
return await client.writeContract({
|
|
828
|
+
address,
|
|
829
|
+
abi: RegistryABI,
|
|
830
|
+
functionName: 'transferOwnership',
|
|
831
|
+
args: [newOwner],
|
|
832
|
+
account: account,
|
|
833
|
+
chain: client.chain
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
catch (error) {
|
|
837
|
+
throw AAStarError.fromViemError(error, 'transferOwnership');
|
|
838
|
+
}
|
|
839
|
+
},
|
|
840
|
+
async renounceOwnership({ account }) {
|
|
841
|
+
try {
|
|
842
|
+
return await client.writeContract({
|
|
843
|
+
address,
|
|
844
|
+
abi: RegistryABI,
|
|
845
|
+
functionName: 'renounceOwnership',
|
|
846
|
+
args: [],
|
|
847
|
+
account: account,
|
|
848
|
+
chain: client.chain
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
catch (error) {
|
|
852
|
+
throw AAStarError.fromViemError(error, 'renounceOwnership');
|
|
853
|
+
}
|
|
854
|
+
},
|
|
855
|
+
async version() {
|
|
856
|
+
try {
|
|
857
|
+
return await client.readContract({
|
|
858
|
+
address,
|
|
859
|
+
abi: RegistryABI,
|
|
860
|
+
functionName: 'version',
|
|
861
|
+
args: []
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
catch (error) {
|
|
865
|
+
throw AAStarError.fromViemError(error, 'version');
|
|
866
|
+
}
|
|
666
867
|
}
|
|
667
868
|
});
|