@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.
Files changed (60) hide show
  1. package/dist/abis/PaymasterV4_2.json +1193 -0
  2. package/dist/abis/SuperPaymaster.json +1 -1
  3. package/dist/abis/aPNTs.json +1160 -0
  4. package/dist/abis/abi.config.json +3 -3
  5. package/dist/abis/index.d.ts +15 -104
  6. package/dist/abis/index.js +22 -46
  7. package/dist/actions/account.d.ts +0 -15
  8. package/dist/actions/account.js +143 -108
  9. package/dist/actions/aggregator.d.ts +68 -7
  10. package/dist/actions/aggregator.js +328 -28
  11. package/dist/actions/dvt.d.ts +33 -5
  12. package/dist/actions/dvt.js +238 -38
  13. package/dist/actions/entryPoint.d.ts +3 -63
  14. package/dist/actions/entryPoint.js +52 -184
  15. package/dist/actions/factory.d.ts +48 -115
  16. package/dist/actions/factory.js +638 -438
  17. package/dist/actions/faucet.d.ts +23 -27
  18. package/dist/actions/faucet.js +150 -289
  19. package/dist/actions/index.d.ts +1 -2
  20. package/dist/actions/index.js +2 -4
  21. package/dist/actions/paymaster.d.ts +147 -0
  22. package/dist/actions/paymaster.js +706 -0
  23. package/dist/actions/paymasterV4.d.ts +26 -95
  24. package/dist/actions/paymasterV4.js +28 -121
  25. package/dist/actions/registry.d.ts +116 -165
  26. package/dist/actions/registry.js +855 -654
  27. package/dist/actions/reputation.d.ts +74 -52
  28. package/dist/actions/reputation.js +548 -242
  29. package/dist/actions/sbt.d.ts +90 -100
  30. package/dist/actions/sbt.js +801 -518
  31. package/dist/actions/staking.d.ts +45 -32
  32. package/dist/actions/staking.js +431 -260
  33. package/dist/actions/superPaymaster.d.ts +140 -158
  34. package/dist/actions/superPaymaster.js +965 -631
  35. package/dist/actions/tokens.d.ts +130 -108
  36. package/dist/actions/tokens.js +470 -414
  37. package/dist/actions/validators.d.ts +0 -73
  38. package/dist/actions/validators.js +0 -94
  39. package/dist/clients/BaseClient.d.ts +3 -3
  40. package/dist/clients/BundlerClient.d.ts +55 -0
  41. package/dist/clients/BundlerClient.js +92 -0
  42. package/dist/communities.js +2 -2
  43. package/dist/constants.js +1 -28
  44. package/dist/contract-addresses.d.ts +5 -14
  45. package/dist/contract-addresses.js +3 -9
  46. package/dist/contract-versions.d.ts +138 -0
  47. package/dist/contract-versions.js +328 -0
  48. package/dist/contracts.d.ts +6 -24
  49. package/dist/contracts.js +2 -2
  50. package/dist/errors/index.d.ts +57 -0
  51. package/dist/errors/index.js +123 -0
  52. package/dist/index.d.ts +2 -1
  53. package/dist/index.js +2 -1
  54. package/dist/requirementChecker.d.ts +35 -1
  55. package/dist/requirementChecker.js +39 -1
  56. package/dist/roles.d.ts +50 -61
  57. package/dist/roles.js +50 -61
  58. package/dist/validators/index.d.ts +35 -0
  59. package/dist/validators/index.js +60 -0
  60. package/package.json +5 -13
@@ -1,533 +1,816 @@
1
1
  import { MySBTABI } from '../abis/index.js';
2
+ import { validateAddress, validateAmount, validateRequired } from '../validators/index.js';
3
+ import { AAStarError } from '../errors/index.js';
2
4
  export const sbtActions = (address) => (client) => ({
3
5
  // SBT specific
4
- async sbtSafeMintForRole({ roleId, to, tokenURI, account }) {
5
- return client.writeContract({
6
- address,
7
- abi: MySBTABI,
8
- functionName: 'safeMintForRole',
9
- args: [roleId, to, tokenURI],
10
- account: account,
11
- chain: client.chain
12
- });
13
- },
14
- async sbtAirdropMint({ roleId, to, tokenURI, account }) {
15
- return client.writeContract({
16
- address,
17
- abi: MySBTABI,
18
- functionName: 'airdropMint',
19
- args: [roleId, to, tokenURI],
20
- account: account,
21
- chain: client.chain
22
- });
23
- },
24
- async sbtGetUserSBT({ user, roleId }) {
25
- return client.readContract({
26
- address,
27
- abi: MySBTABI,
28
- functionName: 'getUserSBT',
29
- args: [user]
30
- });
31
- },
32
- async sbtGetSBTData({ tokenId }) {
33
- return client.readContract({
34
- address,
35
- abi: MySBTABI,
36
- functionName: 'getSBTData',
37
- args: [tokenId]
38
- });
39
- },
40
- async sbtGetCommunityMembership({ user, community }) {
41
- return client.readContract({
42
- address,
43
- abi: MySBTABI,
44
- functionName: 'getCommunityMembership',
45
- args: [user, community]
46
- });
6
+ async airdropMint({ user, roleId, roleData, account }) {
7
+ try {
8
+ validateAddress(user, 'user');
9
+ validateRequired(roleId, 'roleId');
10
+ validateRequired(roleData, 'roleData');
11
+ return await client.writeContract({
12
+ address,
13
+ abi: MySBTABI,
14
+ functionName: 'airdropMint',
15
+ args: [user, roleId, roleData],
16
+ account: account,
17
+ chain: client.chain
18
+ });
19
+ }
20
+ catch (error) {
21
+ throw AAStarError.fromViemError(error, 'airdropMint');
22
+ }
23
+ },
24
+ async mintForRole({ user, roleId, roleData, account }) {
25
+ try {
26
+ validateAddress(user, 'user');
27
+ validateRequired(roleId, 'roleId');
28
+ validateRequired(roleData, 'roleData');
29
+ return await client.writeContract({
30
+ address,
31
+ abi: MySBTABI,
32
+ functionName: 'mintForRole',
33
+ args: [user, roleId, roleData],
34
+ account: account,
35
+ chain: client.chain
36
+ });
37
+ }
38
+ catch (error) {
39
+ throw AAStarError.fromViemError(error, 'mintForRole');
40
+ }
41
+ },
42
+ async getUserSBT({ user }) {
43
+ try {
44
+ validateAddress(user, 'user');
45
+ return await client.readContract({
46
+ address,
47
+ abi: MySBTABI,
48
+ functionName: 'getUserSBT',
49
+ args: [user]
50
+ });
51
+ }
52
+ catch (error) {
53
+ throw AAStarError.fromViemError(error, 'getUserSBT');
54
+ }
55
+ },
56
+ async getSBTData({ tokenId }) {
57
+ try {
58
+ validateRequired(tokenId, 'tokenId');
59
+ const res = await client.readContract({
60
+ address,
61
+ abi: MySBTABI,
62
+ functionName: 'getSBTData',
63
+ args: [tokenId]
64
+ });
65
+ if (Array.isArray(res)) {
66
+ return {
67
+ holder: res[0],
68
+ firstCommunity: res[1],
69
+ mintedAt: res[2],
70
+ totalCommunities: res[3]
71
+ };
72
+ }
73
+ return res;
74
+ }
75
+ catch (error) {
76
+ throw AAStarError.fromViemError(error, 'getSBTData');
77
+ }
78
+ },
79
+ async getCommunityMembership({ tokenId, community }) {
80
+ try {
81
+ validateRequired(tokenId, 'tokenId');
82
+ validateAddress(community, 'community');
83
+ const res = await client.readContract({
84
+ address,
85
+ abi: MySBTABI,
86
+ functionName: 'getCommunityMembership',
87
+ args: [tokenId, community]
88
+ });
89
+ if (Array.isArray(res)) {
90
+ return {
91
+ community: res[0],
92
+ joinedAt: res[1],
93
+ lastActiveTime: res[2],
94
+ isActive: res[3],
95
+ metadata: res[4]
96
+ };
97
+ }
98
+ return res;
99
+ }
100
+ catch (error) {
101
+ throw AAStarError.fromViemError(error, 'getCommunityMembership');
102
+ }
103
+ },
104
+ async getMemberships({ tokenId }) {
105
+ try {
106
+ validateRequired(tokenId, 'tokenId');
107
+ const res = await client.readContract({
108
+ address,
109
+ abi: MySBTABI,
110
+ functionName: 'getMemberships',
111
+ args: [tokenId]
112
+ });
113
+ return res.map(m => {
114
+ if (Array.isArray(m)) {
115
+ return {
116
+ community: m[0],
117
+ joinedAt: m[1],
118
+ lastActiveTime: m[2],
119
+ isActive: m[3],
120
+ metadata: m[4]
121
+ };
122
+ }
123
+ return m;
124
+ });
125
+ }
126
+ catch (error) {
127
+ throw AAStarError.fromViemError(error, 'getMemberships');
128
+ }
129
+ },
130
+ async getActiveMemberships({ tokenId }) {
131
+ try {
132
+ validateRequired(tokenId, 'tokenId');
133
+ return await client.readContract({
134
+ address,
135
+ abi: MySBTABI,
136
+ functionName: 'getActiveMemberships',
137
+ args: [tokenId]
138
+ });
139
+ }
140
+ catch (error) {
141
+ throw AAStarError.fromViemError(error, 'getActiveMemberships');
142
+ }
143
+ },
144
+ async verifyCommunityMembership({ user, community }) {
145
+ try {
146
+ validateAddress(user, 'user');
147
+ validateAddress(community, 'community');
148
+ return await client.readContract({
149
+ address,
150
+ abi: MySBTABI,
151
+ functionName: 'verifyCommunityMembership',
152
+ args: [user, community]
153
+ });
154
+ }
155
+ catch (error) {
156
+ throw AAStarError.fromViemError(error, 'verifyCommunityMembership');
157
+ }
158
+ },
159
+ async userToSBT({ user }) {
160
+ try {
161
+ validateAddress(user, 'user');
162
+ return await client.readContract({
163
+ address,
164
+ abi: MySBTABI,
165
+ functionName: 'userToSBT',
166
+ args: [user]
167
+ });
168
+ }
169
+ catch (error) {
170
+ throw AAStarError.fromViemError(error, 'userToSBT');
171
+ }
172
+ },
173
+ async sbtData({ tokenId }) {
174
+ try {
175
+ validateRequired(tokenId, 'tokenId');
176
+ const res = await client.readContract({
177
+ address,
178
+ abi: MySBTABI,
179
+ functionName: 'sbtData',
180
+ args: [tokenId]
181
+ });
182
+ if (Array.isArray(res)) {
183
+ return {
184
+ holder: res[0],
185
+ firstCommunity: res[1],
186
+ mintedAt: res[2],
187
+ totalCommunities: res[3]
188
+ };
189
+ }
190
+ return res;
191
+ }
192
+ catch (error) {
193
+ throw AAStarError.fromViemError(error, 'sbtData');
194
+ }
195
+ },
196
+ async membershipIndex({ tokenId, community }) {
197
+ try {
198
+ validateRequired(tokenId, 'tokenId');
199
+ validateAddress(community, 'community');
200
+ return await client.readContract({
201
+ address,
202
+ abi: MySBTABI,
203
+ functionName: 'membershipIndex',
204
+ args: [tokenId, community]
205
+ });
206
+ }
207
+ catch (error) {
208
+ throw AAStarError.fromViemError(error, 'membershipIndex');
209
+ }
47
210
  },
48
211
  // ERC721 Standard
49
- async sbtBalanceOf({ owner }) {
50
- return client.readContract({
51
- address,
52
- abi: MySBTABI,
53
- functionName: 'balanceOf',
54
- args: [owner]
55
- });
56
- },
57
- async sbtOwnerOf({ tokenId }) {
58
- return client.readContract({
59
- address,
60
- abi: MySBTABI,
61
- functionName: 'ownerOf',
62
- args: [tokenId]
63
- });
64
- },
65
- async sbtSafeTransferFrom({ from, to, tokenId, account }) {
66
- return client.writeContract({
67
- address,
68
- abi: MySBTABI,
69
- functionName: 'safeTransferFrom',
70
- args: [from, to, tokenId],
71
- account: account,
72
- chain: client.chain
73
- });
74
- },
75
- async sbtTransferFrom({ from, to, tokenId, account }) {
76
- return client.writeContract({
77
- address,
78
- abi: MySBTABI,
79
- functionName: 'transferFrom',
80
- args: [from, to, tokenId],
81
- account: account,
82
- chain: client.chain
83
- });
84
- },
85
- async sbtApprove({ to, tokenId, account }) {
86
- return client.writeContract({
87
- address,
88
- abi: MySBTABI,
89
- functionName: 'approve',
90
- args: [to, tokenId],
91
- account: account,
92
- chain: client.chain
93
- });
94
- },
95
- async sbtSetApprovalForAll({ operator, approved, account }) {
96
- return client.writeContract({
97
- address,
98
- abi: MySBTABI,
99
- functionName: 'setApprovalForAll',
100
- args: [operator, approved],
101
- account: account,
102
- chain: client.chain
103
- });
104
- },
105
- async sbtGetApproved({ tokenId }) {
106
- return client.readContract({
107
- address,
108
- abi: MySBTABI,
109
- functionName: 'getApproved',
110
- args: [tokenId]
111
- });
112
- },
113
- async sbtIsApprovedForAll({ owner, operator }) {
114
- return client.readContract({
115
- address,
116
- abi: MySBTABI,
117
- functionName: 'isApprovedForAll',
118
- args: [owner, operator]
119
- });
212
+ async balanceOf({ owner }) {
213
+ try {
214
+ validateAddress(owner, 'owner');
215
+ return await client.readContract({
216
+ address,
217
+ abi: MySBTABI,
218
+ functionName: 'balanceOf',
219
+ args: [owner]
220
+ });
221
+ }
222
+ catch (error) {
223
+ throw AAStarError.fromViemError(error, 'balanceOf');
224
+ }
225
+ },
226
+ async ownerOf({ tokenId }) {
227
+ try {
228
+ validateRequired(tokenId, 'tokenId');
229
+ return await client.readContract({
230
+ address,
231
+ abi: MySBTABI,
232
+ functionName: 'ownerOf',
233
+ args: [tokenId]
234
+ });
235
+ }
236
+ catch (error) {
237
+ throw AAStarError.fromViemError(error, 'ownerOf');
238
+ }
239
+ },
240
+ async safeTransferFrom({ from, to, tokenId, data, account }) {
241
+ try {
242
+ validateAddress(from, 'from');
243
+ validateAddress(to, 'to');
244
+ validateRequired(tokenId, 'tokenId');
245
+ const args = data ? [from, to, tokenId, data] : [from, to, tokenId];
246
+ return await client.writeContract({
247
+ address,
248
+ abi: MySBTABI,
249
+ functionName: 'safeTransferFrom',
250
+ args,
251
+ account: account,
252
+ chain: client.chain
253
+ });
254
+ }
255
+ catch (error) {
256
+ throw AAStarError.fromViemError(error, 'safeTransferFrom');
257
+ }
258
+ },
259
+ async transferFrom({ from, to, tokenId, account }) {
260
+ try {
261
+ validateAddress(from, 'from');
262
+ validateAddress(to, 'to');
263
+ validateRequired(tokenId, 'tokenId');
264
+ return await client.writeContract({
265
+ address,
266
+ abi: MySBTABI,
267
+ functionName: 'transferFrom',
268
+ args: [from, to, tokenId],
269
+ account: account,
270
+ chain: client.chain
271
+ });
272
+ }
273
+ catch (error) {
274
+ throw AAStarError.fromViemError(error, 'transferFrom');
275
+ }
276
+ },
277
+ async approve({ to, tokenId, account }) {
278
+ try {
279
+ validateAddress(to, 'to');
280
+ validateRequired(tokenId, 'tokenId');
281
+ return await client.writeContract({
282
+ address,
283
+ abi: MySBTABI,
284
+ functionName: 'approve',
285
+ args: [to, tokenId],
286
+ account: account,
287
+ chain: client.chain
288
+ });
289
+ }
290
+ catch (error) {
291
+ throw AAStarError.fromViemError(error, 'approve');
292
+ }
293
+ },
294
+ async setApprovalForAll({ operator, approved, account }) {
295
+ try {
296
+ validateAddress(operator, 'operator');
297
+ return await client.writeContract({
298
+ address,
299
+ abi: MySBTABI,
300
+ functionName: 'setApprovalForAll',
301
+ args: [operator, approved],
302
+ account: account,
303
+ chain: client.chain
304
+ });
305
+ }
306
+ catch (error) {
307
+ throw AAStarError.fromViemError(error, 'setApprovalForAll');
308
+ }
309
+ },
310
+ async getApproved({ tokenId }) {
311
+ try {
312
+ validateRequired(tokenId, 'tokenId');
313
+ return await client.readContract({
314
+ address,
315
+ abi: MySBTABI,
316
+ functionName: 'getApproved',
317
+ args: [tokenId]
318
+ });
319
+ }
320
+ catch (error) {
321
+ throw AAStarError.fromViemError(error, 'getApproved');
322
+ }
323
+ },
324
+ async isApprovedForAll({ owner, operator }) {
325
+ try {
326
+ validateAddress(owner, 'owner');
327
+ validateAddress(operator, 'operator');
328
+ return await client.readContract({
329
+ address,
330
+ abi: MySBTABI,
331
+ functionName: 'isApprovedForAll',
332
+ args: [owner, operator]
333
+ });
334
+ }
335
+ catch (error) {
336
+ throw AAStarError.fromViemError(error, 'isApprovedForAll');
337
+ }
120
338
  },
121
339
  // ERC721 Metadata
122
- async sbtName() {
123
- return client.readContract({
124
- address,
125
- abi: MySBTABI,
126
- functionName: 'name',
127
- args: []
128
- });
129
- },
130
- async sbtSymbol() {
131
- return client.readContract({
132
- address,
133
- abi: MySBTABI,
134
- functionName: 'symbol',
135
- args: []
136
- });
137
- },
138
- async sbtTokenURI({ tokenId }) {
139
- return client.readContract({
140
- address,
141
- abi: MySBTABI,
142
- functionName: 'tokenURI',
143
- args: [tokenId]
144
- });
145
- },
146
- // ERC721 Enumerable
147
- async sbtTotalSupply() {
148
- return client.readContract({
149
- address,
150
- abi: MySBTABI,
151
- functionName: 'totalSupply',
152
- args: []
153
- });
154
- },
155
- async sbtTokenByIndex({ index }) {
156
- return client.readContract({
157
- address,
158
- abi: MySBTABI,
159
- functionName: 'tokenByIndex',
160
- args: [index]
161
- });
162
- },
163
- async sbtTokenOfOwnerByIndex({ owner, index }) {
164
- return client.readContract({
165
- address,
166
- abi: MySBTABI,
167
- functionName: 'tokenOfOwnerByIndex',
168
- args: [owner, index]
169
- });
340
+ async name() {
341
+ try {
342
+ return await client.readContract({
343
+ address,
344
+ abi: MySBTABI,
345
+ functionName: 'name',
346
+ args: []
347
+ });
348
+ }
349
+ catch (error) {
350
+ throw AAStarError.fromViemError(error, 'name');
351
+ }
352
+ },
353
+ async symbol() {
354
+ try {
355
+ return await client.readContract({
356
+ address,
357
+ abi: MySBTABI,
358
+ functionName: 'symbol',
359
+ args: []
360
+ });
361
+ }
362
+ catch (error) {
363
+ throw AAStarError.fromViemError(error, 'symbol');
364
+ }
365
+ },
366
+ async tokenURI({ tokenId }) {
367
+ try {
368
+ validateRequired(tokenId, 'tokenId');
369
+ return await client.readContract({
370
+ address,
371
+ abi: MySBTABI,
372
+ functionName: 'tokenURI',
373
+ args: [tokenId]
374
+ });
375
+ }
376
+ catch (error) {
377
+ throw AAStarError.fromViemError(error, 'tokenURI');
378
+ }
379
+ },
380
+ // View Functions
381
+ async nextTokenId() {
382
+ try {
383
+ return await client.readContract({
384
+ address,
385
+ abi: MySBTABI,
386
+ functionName: 'nextTokenId',
387
+ args: []
388
+ });
389
+ }
390
+ catch (error) {
391
+ throw AAStarError.fromViemError(error, 'nextTokenId');
392
+ }
393
+ },
394
+ async supportsInterface({ interfaceId }) {
395
+ try {
396
+ validateRequired(interfaceId, 'interfaceId');
397
+ return await client.readContract({
398
+ address,
399
+ abi: MySBTABI,
400
+ functionName: 'supportsInterface',
401
+ args: [interfaceId]
402
+ });
403
+ }
404
+ catch (error) {
405
+ throw AAStarError.fromViemError(error, 'supportsInterface');
406
+ }
170
407
  },
171
408
  // Admin/Minting
172
- async sbtMint({ to, tokenURI, account }) {
173
- return client.writeContract({
174
- address,
175
- abi: MySBTABI,
176
- functionName: 'mint',
177
- args: [to, tokenURI],
178
- account: account,
179
- chain: client.chain
180
- });
181
- },
182
- async sbtBurn({ tokenId, account }) {
183
- return client.writeContract({
184
- address,
185
- abi: MySBTABI,
186
- functionName: 'burn',
187
- args: [tokenId],
188
- account: account,
189
- chain: client.chain
190
- });
191
- },
192
- async sbtDeactivateAllMemberships({ user, account }) {
193
- return client.writeContract({
194
- address,
195
- abi: MySBTABI,
196
- functionName: 'deactivateAllMemberships',
197
- args: [user],
198
- account: account,
199
- chain: client.chain
200
- });
201
- },
202
- async sbtSetBaseURI({ baseURI, account }) {
203
- return client.writeContract({
204
- address,
205
- abi: MySBTABI,
206
- functionName: 'setBaseURI',
207
- args: [baseURI],
208
- account: account,
209
- chain: client.chain
210
- });
409
+ async burnSBT({ user, account }) {
410
+ try {
411
+ validateAddress(user, 'user');
412
+ return await client.writeContract({
413
+ address,
414
+ abi: MySBTABI,
415
+ functionName: 'burnSBT',
416
+ args: [user],
417
+ account: account,
418
+ chain: client.chain
419
+ });
420
+ }
421
+ catch (error) {
422
+ throw AAStarError.fromViemError(error, 'burnSBT');
423
+ }
424
+ },
425
+ async setBaseURI({ baseURI, account }) {
426
+ try {
427
+ validateRequired(baseURI, 'baseURI');
428
+ return await client.writeContract({
429
+ address,
430
+ abi: MySBTABI,
431
+ functionName: 'setBaseURI',
432
+ args: [baseURI],
433
+ account: account,
434
+ chain: client.chain
435
+ });
436
+ }
437
+ catch (error) {
438
+ throw AAStarError.fromViemError(error, 'setBaseURI');
439
+ }
440
+ },
441
+ // Membership Management
442
+ async leaveCommunity({ community, account }) {
443
+ try {
444
+ validateAddress(community, 'community');
445
+ return await client.writeContract({
446
+ address,
447
+ abi: MySBTABI,
448
+ functionName: 'leaveCommunity',
449
+ args: [community],
450
+ account: account,
451
+ chain: client.chain
452
+ });
453
+ }
454
+ catch (error) {
455
+ throw AAStarError.fromViemError(error, 'leaveCommunity');
456
+ }
457
+ },
458
+ async deactivateMembership({ user, community, account }) {
459
+ try {
460
+ validateAddress(user, 'user');
461
+ validateAddress(community, 'community');
462
+ return await client.writeContract({
463
+ address,
464
+ abi: MySBTABI,
465
+ functionName: 'deactivateMembership',
466
+ args: [user, community],
467
+ account: account,
468
+ chain: client.chain
469
+ });
470
+ }
471
+ catch (error) {
472
+ throw AAStarError.fromViemError(error, 'deactivateMembership');
473
+ }
474
+ },
475
+ async deactivateAllMemberships({ user, account }) {
476
+ try {
477
+ validateAddress(user, 'user');
478
+ return await client.writeContract({
479
+ address,
480
+ abi: MySBTABI,
481
+ functionName: 'deactivateAllMemberships',
482
+ args: [user],
483
+ account: account,
484
+ chain: client.chain
485
+ });
486
+ }
487
+ catch (error) {
488
+ throw AAStarError.fromViemError(error, 'deactivateAllMemberships');
489
+ }
490
+ },
491
+ // Activity & Reputation
492
+ async recordActivity({ user, account }) {
493
+ try {
494
+ validateAddress(user, 'user');
495
+ return await client.writeContract({
496
+ address,
497
+ abi: MySBTABI,
498
+ functionName: 'recordActivity',
499
+ args: [user],
500
+ account: account,
501
+ chain: client.chain
502
+ });
503
+ }
504
+ catch (error) {
505
+ throw AAStarError.fromViemError(error, 'recordActivity');
506
+ }
507
+ },
508
+ async lastActivityTime({ tokenId, community }) {
509
+ try {
510
+ validateRequired(tokenId, 'tokenId');
511
+ validateAddress(community, 'community');
512
+ return await client.readContract({
513
+ address,
514
+ abi: MySBTABI,
515
+ functionName: 'lastActivityTime',
516
+ args: [tokenId, community]
517
+ });
518
+ }
519
+ catch (error) {
520
+ throw AAStarError.fromViemError(error, 'lastActivityTime');
521
+ }
522
+ },
523
+ async weeklyActivity({ tokenId, community, week }) {
524
+ try {
525
+ validateRequired(tokenId, 'tokenId');
526
+ validateAddress(community, 'community');
527
+ validateRequired(week, 'week');
528
+ return await client.readContract({
529
+ address,
530
+ abi: MySBTABI,
531
+ functionName: 'weeklyActivity',
532
+ args: [tokenId, community, week]
533
+ });
534
+ }
535
+ catch (error) {
536
+ throw AAStarError.fromViemError(error, 'weeklyActivity');
537
+ }
538
+ },
539
+ async reputationCalculator() {
540
+ try {
541
+ return await client.readContract({
542
+ address,
543
+ abi: MySBTABI,
544
+ functionName: 'reputationCalculator',
545
+ args: []
546
+ });
547
+ }
548
+ catch (error) {
549
+ throw AAStarError.fromViemError(error, 'reputationCalculator');
550
+ }
551
+ },
552
+ async setReputationCalculator({ calculator, account }) {
553
+ try {
554
+ validateAddress(calculator, 'calculator');
555
+ return await client.writeContract({
556
+ address,
557
+ abi: MySBTABI,
558
+ functionName: 'setReputationCalculator',
559
+ args: [calculator],
560
+ account: account,
561
+ chain: client.chain
562
+ });
563
+ }
564
+ catch (error) {
565
+ throw AAStarError.fromViemError(error, 'setReputationCalculator');
566
+ }
567
+ },
568
+ // Mint Fee & Lock
569
+ async mintFee() {
570
+ try {
571
+ return await client.readContract({
572
+ address,
573
+ abi: MySBTABI,
574
+ functionName: 'mintFee',
575
+ args: []
576
+ });
577
+ }
578
+ catch (error) {
579
+ throw AAStarError.fromViemError(error, 'mintFee');
580
+ }
581
+ },
582
+ async setMintFee({ fee, account }) {
583
+ try {
584
+ validateAmount(fee, 'fee');
585
+ return await client.writeContract({
586
+ address,
587
+ abi: MySBTABI,
588
+ functionName: 'setMintFee',
589
+ args: [fee],
590
+ account: account,
591
+ chain: client.chain
592
+ });
593
+ }
594
+ catch (error) {
595
+ throw AAStarError.fromViemError(error, 'setMintFee');
596
+ }
597
+ },
598
+ async minLockAmount() {
599
+ try {
600
+ return await client.readContract({
601
+ address,
602
+ abi: MySBTABI,
603
+ functionName: 'minLockAmount',
604
+ args: []
605
+ });
606
+ }
607
+ catch (error) {
608
+ throw AAStarError.fromViemError(error, 'minLockAmount');
609
+ }
610
+ },
611
+ async setMinLockAmount({ amount, account }) {
612
+ try {
613
+ validateAmount(amount, 'amount');
614
+ return await client.writeContract({
615
+ address,
616
+ abi: MySBTABI,
617
+ functionName: 'setMinLockAmount',
618
+ args: [amount],
619
+ account: account,
620
+ chain: client.chain
621
+ });
622
+ }
623
+ catch (error) {
624
+ throw AAStarError.fromViemError(error, 'setMinLockAmount');
625
+ }
626
+ },
627
+ // Pause
628
+ async pause({ account }) {
629
+ try {
630
+ return await client.writeContract({
631
+ address,
632
+ abi: MySBTABI,
633
+ functionName: 'pause',
634
+ args: [],
635
+ account: account,
636
+ chain: client.chain
637
+ });
638
+ }
639
+ catch (error) {
640
+ throw AAStarError.fromViemError(error, 'pause');
641
+ }
642
+ },
643
+ async unpause({ account }) {
644
+ try {
645
+ return await client.writeContract({
646
+ address,
647
+ abi: MySBTABI,
648
+ functionName: 'unpause',
649
+ args: [],
650
+ account: account,
651
+ chain: client.chain
652
+ });
653
+ }
654
+ catch (error) {
655
+ throw AAStarError.fromViemError(error, 'unpause');
656
+ }
657
+ },
658
+ async paused() {
659
+ try {
660
+ return await client.readContract({
661
+ address,
662
+ abi: MySBTABI,
663
+ functionName: 'paused',
664
+ args: []
665
+ });
666
+ }
667
+ catch (error) {
668
+ throw AAStarError.fromViemError(error, 'paused');
669
+ }
670
+ },
671
+ // DAO & Config
672
+ async daoMultisig() {
673
+ try {
674
+ return await client.readContract({
675
+ address,
676
+ abi: MySBTABI,
677
+ functionName: 'daoMultisig',
678
+ args: []
679
+ });
680
+ }
681
+ catch (error) {
682
+ throw AAStarError.fromViemError(error, 'daoMultisig');
683
+ }
684
+ },
685
+ async setDAOMultisig({ multisig, account }) {
686
+ try {
687
+ validateAddress(multisig, 'multisig');
688
+ return await client.writeContract({
689
+ address,
690
+ abi: MySBTABI,
691
+ functionName: 'setDAOMultisig',
692
+ args: [multisig],
693
+ account: account,
694
+ chain: client.chain
695
+ });
696
+ }
697
+ catch (error) {
698
+ throw AAStarError.fromViemError(error, 'setDAOMultisig');
699
+ }
700
+ },
701
+ async setRegistry({ registry, account }) {
702
+ try {
703
+ validateAddress(registry, 'registry');
704
+ return await client.writeContract({
705
+ address,
706
+ abi: MySBTABI,
707
+ functionName: 'setRegistry',
708
+ args: [registry],
709
+ account: account,
710
+ chain: client.chain
711
+ });
712
+ }
713
+ catch (error) {
714
+ throw AAStarError.fromViemError(error, 'setRegistry');
715
+ }
716
+ },
717
+ // Version
718
+ async version() {
719
+ try {
720
+ return await client.readContract({
721
+ address,
722
+ abi: MySBTABI,
723
+ functionName: 'version',
724
+ args: []
725
+ });
726
+ }
727
+ catch (error) {
728
+ throw AAStarError.fromViemError(error, 'version');
729
+ }
211
730
  },
212
731
  // Constants
213
- async sbtREGISTRY() {
214
- return client.readContract({
215
- address,
216
- abi: MySBTABI,
217
- functionName: 'REGISTRY',
218
- args: []
219
- });
220
- },
221
- async sbtGTOKEN_STAKING() {
222
- return client.readContract({
223
- address,
224
- abi: MySBTABI,
225
- functionName: 'GTOKEN_STAKING',
226
- args: []
227
- });
228
- },
229
- async sbtGTOKEN() {
230
- return client.readContract({
231
- address,
232
- abi: MySBTABI,
233
- functionName: 'GTOKEN',
234
- args: []
235
- });
236
- },
237
- async sbtSUPER_PAYMASTER() {
238
- return client.readContract({
239
- address,
240
- abi: MySBTABI,
241
- functionName: 'SUPER_PAYMASTER',
242
- args: []
243
- });
732
+ async REGISTRY() {
733
+ try {
734
+ return await client.readContract({
735
+ address,
736
+ abi: MySBTABI,
737
+ functionName: 'REGISTRY',
738
+ args: []
739
+ });
740
+ }
741
+ catch (error) {
742
+ throw AAStarError.fromViemError(error, 'REGISTRY');
743
+ }
744
+ },
745
+ async GTOKEN_STAKING() {
746
+ try {
747
+ return await client.readContract({
748
+ address,
749
+ abi: MySBTABI,
750
+ functionName: 'GTOKEN_STAKING',
751
+ args: []
752
+ });
753
+ }
754
+ catch (error) {
755
+ throw AAStarError.fromViemError(error, 'GTOKEN_STAKING');
756
+ }
757
+ },
758
+ async GTOKEN() {
759
+ try {
760
+ return await client.readContract({
761
+ address,
762
+ abi: MySBTABI,
763
+ functionName: 'GTOKEN',
764
+ args: []
765
+ });
766
+ }
767
+ catch (error) {
768
+ throw AAStarError.fromViemError(error, 'GTOKEN');
769
+ }
244
770
  },
245
771
  // Ownership
246
- async sbtOwner() {
247
- return client.readContract({
248
- address,
249
- abi: MySBTABI,
250
- functionName: 'owner',
251
- args: []
252
- });
253
- },
254
- async sbtTransferSBTOwnership({ newOwner, account }) {
255
- return client.writeContract({
256
- address,
257
- abi: MySBTABI,
258
- functionName: 'transferOwnership',
259
- args: [newOwner],
260
- account: account,
261
- chain: client.chain
262
- });
263
- },
264
- async sbtRenounceOwnership({ account }) {
265
- return client.writeContract({
266
- address,
267
- abi: MySBTABI,
268
- functionName: 'renounceOwnership',
269
- args: [],
270
- account: account,
271
- chain: client.chain
272
- });
273
- },
274
- // Additional SBT-specific functions
275
- async sbtMintForRole({ roleId, to, account }) {
276
- return client.writeContract({
277
- address,
278
- abi: MySBTABI,
279
- functionName: 'mintForRole',
280
- args: [roleId, to],
281
- account: account,
282
- chain: client.chain
283
- });
284
- },
285
- async sbtGetMemberships({ user }) {
286
- return client.readContract({
287
- address,
288
- abi: MySBTABI,
289
- functionName: 'getMemberships',
290
- args: [user]
291
- });
292
- },
293
- async sbtGetActiveMemberships({ user }) {
294
- return client.readContract({
295
- address,
296
- abi: MySBTABI,
297
- functionName: 'getActiveMemberships',
298
- args: [user]
299
- });
300
- },
301
- async sbtVerifyCommunityMembership({ user, community }) {
302
- return client.readContract({
303
- address,
304
- abi: MySBTABI,
305
- functionName: 'verifyCommunityMembership',
306
- args: [user, community]
307
- });
308
- },
309
- async sbtUserToSBT({ user }) {
310
- return client.readContract({
311
- address,
312
- abi: MySBTABI,
313
- functionName: 'userToSBT',
314
- args: [user]
315
- });
316
- },
317
- async sbtSbtData({ tokenId }) {
318
- return client.readContract({
319
- address,
320
- abi: MySBTABI,
321
- functionName: 'sbtData',
322
- args: [tokenId]
323
- });
324
- },
325
- async sbtMembershipIndex({ user, index }) {
326
- return client.readContract({
327
- address,
328
- abi: MySBTABI,
329
- functionName: 'membershipIndex',
330
- args: [user, index]
331
- });
332
- },
333
- async sbtSupportsInterface({ interfaceId }) {
334
- return client.readContract({
335
- address,
336
- abi: MySBTABI,
337
- functionName: 'supportsInterface',
338
- args: [interfaceId]
339
- });
340
- },
341
- async sbtNextTokenId() {
342
- return client.readContract({
343
- address,
344
- abi: MySBTABI,
345
- functionName: 'nextTokenId',
346
- args: []
347
- });
348
- },
349
- async sbtBurnSBT({ tokenId, account }) {
350
- return client.writeContract({
351
- address,
352
- abi: MySBTABI,
353
- functionName: 'burnSBT',
354
- args: [tokenId],
355
- account: account,
356
- chain: client.chain
357
- });
358
- },
359
- async sbtLeaveCommunity({ community, account }) {
360
- return client.writeContract({
361
- address,
362
- abi: MySBTABI,
363
- functionName: 'leaveCommunity',
364
- args: [community],
365
- account: account,
366
- chain: client.chain
367
- });
368
- },
369
- async sbtDeactivateMembership({ tokenId, account }) {
370
- return client.writeContract({
371
- address,
372
- abi: MySBTABI,
373
- functionName: 'deactivateMembership',
374
- args: [tokenId],
375
- account: account,
376
- chain: client.chain
377
- });
378
- },
379
- async sbtRecordActivity({ user, account }) {
380
- return client.writeContract({
381
- address,
382
- abi: MySBTABI,
383
- functionName: 'recordActivity',
384
- args: [user],
385
- account: account,
386
- chain: client.chain
387
- });
388
- },
389
- async sbtLastActivityTime({ user }) {
390
- return client.readContract({
391
- address,
392
- abi: MySBTABI,
393
- functionName: 'lastActivityTime',
394
- args: [user]
395
- });
396
- },
397
- async sbtWeeklyActivity({ user }) {
398
- return client.readContract({
399
- address,
400
- abi: MySBTABI,
401
- functionName: 'weeklyActivity',
402
- args: [user]
403
- });
404
- },
405
- async sbtReputationCalculator() {
406
- return client.readContract({
407
- address,
408
- abi: MySBTABI,
409
- functionName: 'reputationCalculator',
410
- args: []
411
- });
412
- },
413
- async sbtSetReputationCalculator({ calculator, account }) {
414
- return client.writeContract({
415
- address,
416
- abi: MySBTABI,
417
- functionName: 'setReputationCalculator',
418
- args: [calculator],
419
- account: account,
420
- chain: client.chain
421
- });
422
- },
423
- async sbtMintFee() {
424
- return client.readContract({
425
- address,
426
- abi: MySBTABI,
427
- functionName: 'mintFee',
428
- args: []
429
- });
430
- },
431
- async sbtSetMintFee({ fee, account }) {
432
- return client.writeContract({
433
- address,
434
- abi: MySBTABI,
435
- functionName: 'setMintFee',
436
- args: [fee],
437
- account: account,
438
- chain: client.chain
439
- });
440
- },
441
- async sbtMinLockAmount() {
442
- return client.readContract({
443
- address,
444
- abi: MySBTABI,
445
- functionName: 'minLockAmount',
446
- args: []
447
- });
448
- },
449
- async sbtSetMinLockAmount({ amount, account }) {
450
- return client.writeContract({
451
- address,
452
- abi: MySBTABI,
453
- functionName: 'setMinLockAmount',
454
- args: [amount],
455
- account: account,
456
- chain: client.chain
457
- });
458
- },
459
- async sbtPause({ account }) {
460
- return client.writeContract({
461
- address,
462
- abi: MySBTABI,
463
- functionName: 'pause',
464
- args: [],
465
- account: account,
466
- chain: client.chain
467
- });
468
- },
469
- async sbtUnpause({ account }) {
470
- return client.writeContract({
471
- address,
472
- abi: MySBTABI,
473
- functionName: 'unpause',
474
- args: [],
475
- account: account,
476
- chain: client.chain
477
- });
478
- },
479
- async sbtPaused() {
480
- return client.readContract({
481
- address,
482
- abi: MySBTABI,
483
- functionName: 'paused',
484
- args: []
485
- });
486
- },
487
- async sbtDaoMultisig() {
488
- return client.readContract({
489
- address,
490
- abi: MySBTABI,
491
- functionName: 'daoMultisig',
492
- args: []
493
- });
494
- },
495
- async sbtSetDAOMultisig({ multisig, account }) {
496
- return client.writeContract({
497
- address,
498
- abi: MySBTABI,
499
- functionName: 'setDAOMultisig',
500
- args: [multisig],
501
- account: account,
502
- chain: client.chain
503
- });
504
- },
505
- async sbtSetRegistry({ registry, account }) {
506
- return client.writeContract({
507
- address,
508
- abi: MySBTABI,
509
- functionName: 'setRegistry',
510
- args: [registry],
511
- account: account,
512
- chain: client.chain
513
- });
514
- },
515
- async sbtSetSuperPaymaster({ paymaster, account }) {
516
- return client.writeContract({
517
- address,
518
- abi: MySBTABI,
519
- functionName: 'setSuperPaymaster',
520
- args: [paymaster],
521
- account: account,
522
- chain: client.chain
523
- });
524
- },
525
- async sbtVersion() {
526
- return client.readContract({
527
- address,
528
- abi: MySBTABI,
529
- functionName: 'version',
530
- args: []
531
- });
772
+ async owner() {
773
+ try {
774
+ return await client.readContract({
775
+ address,
776
+ abi: MySBTABI,
777
+ functionName: 'owner',
778
+ args: []
779
+ });
780
+ }
781
+ catch (error) {
782
+ throw AAStarError.fromViemError(error, 'owner');
783
+ }
784
+ },
785
+ async transferOwnership({ newOwner, account }) {
786
+ try {
787
+ validateAddress(newOwner, 'newOwner');
788
+ return await client.writeContract({
789
+ address,
790
+ abi: MySBTABI,
791
+ functionName: 'transferOwnership',
792
+ args: [newOwner],
793
+ account: account,
794
+ chain: client.chain
795
+ });
796
+ }
797
+ catch (error) {
798
+ throw AAStarError.fromViemError(error, 'transferOwnership');
799
+ }
800
+ },
801
+ async renounceOwnership({ account }) {
802
+ try {
803
+ return await client.writeContract({
804
+ address,
805
+ abi: MySBTABI,
806
+ functionName: 'renounceOwnership',
807
+ args: [],
808
+ account: account,
809
+ chain: client.chain
810
+ });
811
+ }
812
+ catch (error) {
813
+ throw AAStarError.fromViemError(error, 'renounceOwnership');
814
+ }
532
815
  }
533
816
  });