@aastar/core 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 (136) hide show
  1. package/LICENSE +21 -0
  2. package/dist/abis/BLSAggregator.json +686 -0
  3. package/dist/abis/BLSValidator.json +42 -0
  4. package/dist/abis/DVTValidator.json +368 -0
  5. package/dist/abis/Eip7702Support.json +24 -0
  6. package/dist/abis/EntryPoint.json +1382 -0
  7. package/dist/abis/GToken.json +513 -0
  8. package/dist/abis/GTokenStaking.json +949 -0
  9. package/dist/abis/LegacyAccount.json +625 -0
  10. package/dist/abis/MySBT.json +1518 -0
  11. package/dist/abis/Paymaster.json +1143 -0
  12. package/dist/abis/PaymasterFactory.json +640 -0
  13. package/dist/abis/Registry.json +1942 -0
  14. package/dist/abis/ReputationSystem.json +699 -0
  15. package/dist/abis/SenderCreator.json +99 -0
  16. package/dist/abis/Simple7702Account.json +395 -0
  17. package/dist/abis/SimpleAccount.json +560 -0
  18. package/dist/abis/SimpleAccountFactory.json +111 -0
  19. package/dist/abis/SimpleAccountFactoryV08.json +87 -0
  20. package/dist/abis/SimpleAccountV08.json +557 -0
  21. package/dist/abis/SuperPaymaster.json +1781 -0
  22. package/dist/abis/UserOperationLib.json +57 -0
  23. package/dist/abis/abi.config.json +24 -0
  24. package/dist/abis/index.d.ts +1126 -0
  25. package/dist/abis/index.js +91 -0
  26. package/dist/abis/xPNTsFactory.json +718 -0
  27. package/dist/abis/xPNTsToken.json +1280 -0
  28. package/dist/actions/StateValidator.d.ts +68 -0
  29. package/dist/actions/StateValidator.js +187 -0
  30. package/dist/actions/StateValidator.test.d.ts +1 -0
  31. package/dist/actions/StateValidator.test.js +144 -0
  32. package/dist/actions/account.d.ts +55 -0
  33. package/dist/actions/account.js +133 -0
  34. package/dist/actions/account.test.d.ts +1 -0
  35. package/dist/actions/account.test.js +118 -0
  36. package/dist/actions/aggregator.d.ts +17 -0
  37. package/dist/actions/aggregator.js +31 -0
  38. package/dist/actions/aggregator.test.d.ts +1 -0
  39. package/dist/actions/aggregator.test.js +67 -0
  40. package/dist/actions/dvt.d.ts +30 -0
  41. package/dist/actions/dvt.js +41 -0
  42. package/dist/actions/dvt.test.d.ts +1 -0
  43. package/dist/actions/dvt.test.js +98 -0
  44. package/dist/actions/entryPoint.d.ts +90 -0
  45. package/dist/actions/entryPoint.js +211 -0
  46. package/dist/actions/entryPoint.test.d.ts +1 -0
  47. package/dist/actions/entryPoint.test.js +139 -0
  48. package/dist/actions/factory.d.ts +215 -0
  49. package/dist/actions/factory.js +442 -0
  50. package/dist/actions/factory.test.d.ts +1 -0
  51. package/dist/actions/factory.test.js +197 -0
  52. package/dist/actions/faucet.d.ts +48 -0
  53. package/dist/actions/faucet.js +337 -0
  54. package/dist/actions/faucet.test.d.ts +1 -0
  55. package/dist/actions/faucet.test.js +120 -0
  56. package/dist/actions/gtokenExtended.d.ts +39 -0
  57. package/dist/actions/gtokenExtended.js +115 -0
  58. package/dist/actions/gtokenExtended.test.d.ts +1 -0
  59. package/dist/actions/gtokenExtended.test.js +118 -0
  60. package/dist/actions/index.d.ts +15 -0
  61. package/dist/actions/index.js +17 -0
  62. package/dist/actions/paymasterV4.d.ts +170 -0
  63. package/dist/actions/paymasterV4.js +334 -0
  64. package/dist/actions/paymasterV4.test.d.ts +1 -0
  65. package/dist/actions/paymasterV4.test.js +159 -0
  66. package/dist/actions/registry.d.ts +246 -0
  67. package/dist/actions/registry.js +667 -0
  68. package/dist/actions/registry.test.d.ts +1 -0
  69. package/dist/actions/registry.test.js +360 -0
  70. package/dist/actions/reputation.d.ts +129 -0
  71. package/dist/actions/reputation.js +281 -0
  72. package/dist/actions/reputation.test.d.ts +1 -0
  73. package/dist/actions/reputation.test.js +169 -0
  74. package/dist/actions/sbt.d.ts +191 -0
  75. package/dist/actions/sbt.js +533 -0
  76. package/dist/actions/sbt.test.d.ts +1 -0
  77. package/dist/actions/sbt.test.js +256 -0
  78. package/dist/actions/staking.d.ts +132 -0
  79. package/dist/actions/staking.js +330 -0
  80. package/dist/actions/staking.test.d.ts +1 -0
  81. package/dist/actions/staking.test.js +223 -0
  82. package/dist/actions/superPaymaster.d.ts +237 -0
  83. package/dist/actions/superPaymaster.js +644 -0
  84. package/dist/actions/superPaymaster.test.d.ts +1 -0
  85. package/dist/actions/superPaymaster.test.js +287 -0
  86. package/dist/actions/tokens.d.ts +229 -0
  87. package/dist/actions/tokens.js +415 -0
  88. package/dist/actions/tokens.test.d.ts +1 -0
  89. package/dist/actions/tokens.test.js +53 -0
  90. package/dist/actions/validators.d.ts +194 -0
  91. package/dist/actions/validators.js +433 -0
  92. package/dist/actions/validators.test.d.ts +1 -0
  93. package/dist/actions/validators.test.js +215 -0
  94. package/dist/branding.d.ts +30 -0
  95. package/dist/branding.js +30 -0
  96. package/dist/clients/BaseClient.d.ts +25 -0
  97. package/dist/clients/BaseClient.js +66 -0
  98. package/dist/clients/types.d.ts +60 -0
  99. package/dist/clients/types.js +1 -0
  100. package/dist/clients.d.ts +5 -0
  101. package/dist/clients.js +11 -0
  102. package/dist/communities.d.ts +52 -0
  103. package/dist/communities.js +73 -0
  104. package/dist/config/ContractConfigManager.d.ts +20 -0
  105. package/dist/config/ContractConfigManager.js +48 -0
  106. package/dist/constants.d.ts +88 -0
  107. package/dist/constants.js +125 -0
  108. package/dist/contract-addresses.d.ts +110 -0
  109. package/dist/contract-addresses.js +99 -0
  110. package/dist/contracts.d.ts +424 -0
  111. package/dist/contracts.js +343 -0
  112. package/dist/contracts.test.d.ts +1 -0
  113. package/dist/contracts.test.js +40 -0
  114. package/dist/crypto/blsSigner.d.ts +64 -0
  115. package/dist/crypto/blsSigner.js +98 -0
  116. package/dist/crypto/index.d.ts +1 -0
  117. package/dist/crypto/index.js +1 -0
  118. package/dist/index.d.ts +21 -0
  119. package/dist/index.js +21 -0
  120. package/dist/networks.d.ts +127 -0
  121. package/dist/networks.js +118 -0
  122. package/dist/requirementChecker.d.ts +38 -0
  123. package/dist/requirementChecker.js +139 -0
  124. package/dist/requirementChecker.test.d.ts +1 -0
  125. package/dist/requirementChecker.test.js +60 -0
  126. package/dist/roles.d.ts +204 -0
  127. package/dist/roles.js +211 -0
  128. package/dist/roles.test.d.ts +1 -0
  129. package/dist/roles.test.js +23 -0
  130. package/dist/utils/validation.d.ts +24 -0
  131. package/dist/utils/validation.js +56 -0
  132. package/dist/utils/validation.test.d.ts +1 -0
  133. package/dist/utils/validation.test.js +40 -0
  134. package/dist/utils.d.ts +12 -0
  135. package/dist/utils.js +14 -0
  136. package/package.json +33 -0
@@ -0,0 +1,433 @@
1
+ import { DVTValidatorABI, BLSAggregatorABI } from '../abis/index.js';
2
+ export const dvtActions = (address) => (client) => ({
3
+ async createProposal({ target, calldata, description, account }) {
4
+ return client.writeContract({
5
+ address,
6
+ abi: DVTValidatorABI,
7
+ functionName: 'createProposal',
8
+ args: [target, calldata, description],
9
+ account: account,
10
+ chain: client.chain
11
+ });
12
+ },
13
+ async signProposal({ proposalId, account }) {
14
+ return client.writeContract({
15
+ address,
16
+ abi: DVTValidatorABI,
17
+ functionName: 'signProposal',
18
+ args: [proposalId],
19
+ account: account,
20
+ chain: client.chain
21
+ });
22
+ },
23
+ async executeWithProof({ proposalId, signatures, account }) {
24
+ return client.writeContract({
25
+ address,
26
+ abi: DVTValidatorABI,
27
+ functionName: 'executeWithProof',
28
+ args: [proposalId, signatures],
29
+ account: account,
30
+ chain: client.chain
31
+ });
32
+ },
33
+ async cancelProposal({ proposalId, account }) {
34
+ return client.writeContract({
35
+ address,
36
+ abi: DVTValidatorABI,
37
+ functionName: 'cancelProposal',
38
+ args: [proposalId],
39
+ account: account,
40
+ chain: client.chain
41
+ });
42
+ },
43
+ async isValidator({ validator }) {
44
+ return client.readContract({
45
+ address,
46
+ abi: DVTValidatorABI,
47
+ functionName: 'isValidator',
48
+ args: [validator]
49
+ });
50
+ },
51
+ async addValidator({ validator, account }) {
52
+ return client.writeContract({
53
+ address,
54
+ abi: DVTValidatorABI,
55
+ functionName: 'addValidator',
56
+ args: [validator],
57
+ account: account,
58
+ chain: client.chain
59
+ });
60
+ },
61
+ async removeValidator({ validator, account }) {
62
+ return client.writeContract({
63
+ address,
64
+ abi: DVTValidatorABI,
65
+ functionName: 'removeValidator',
66
+ args: [validator],
67
+ account: account,
68
+ chain: client.chain
69
+ });
70
+ },
71
+ async getValidators() {
72
+ return client.readContract({
73
+ address,
74
+ abi: DVTValidatorABI,
75
+ functionName: 'getValidators',
76
+ args: []
77
+ });
78
+ },
79
+ async getValidatorCount() {
80
+ return client.readContract({
81
+ address,
82
+ abi: DVTValidatorABI,
83
+ functionName: 'getValidatorCount',
84
+ args: []
85
+ });
86
+ },
87
+ async getProposal({ proposalId }) {
88
+ return client.readContract({
89
+ address,
90
+ abi: DVTValidatorABI,
91
+ functionName: 'getProposal',
92
+ args: [proposalId]
93
+ });
94
+ },
95
+ async getProposalCount() {
96
+ return client.readContract({
97
+ address,
98
+ abi: DVTValidatorABI,
99
+ functionName: 'getProposalCount',
100
+ args: []
101
+ });
102
+ },
103
+ async getProposalState({ proposalId }) {
104
+ return client.readContract({
105
+ address,
106
+ abi: DVTValidatorABI,
107
+ functionName: 'getProposalState',
108
+ args: [proposalId]
109
+ });
110
+ },
111
+ async getSignatureCount({ proposalId }) {
112
+ return client.readContract({
113
+ address,
114
+ abi: DVTValidatorABI,
115
+ functionName: 'getSignatureCount',
116
+ args: [proposalId]
117
+ });
118
+ },
119
+ async hasVoted({ proposalId, validator }) {
120
+ return client.readContract({
121
+ address,
122
+ abi: DVTValidatorABI,
123
+ functionName: 'hasVoted',
124
+ args: [proposalId, validator]
125
+ });
126
+ },
127
+ async proposals({ proposalId }) {
128
+ return client.readContract({ address, abi: DVTValidatorABI, functionName: 'proposals', args: [proposalId] });
129
+ },
130
+ async nextProposalId() {
131
+ return client.readContract({ address, abi: DVTValidatorABI, functionName: 'nextProposalId', args: [] });
132
+ },
133
+ async threshold() {
134
+ return client.readContract({
135
+ address,
136
+ abi: DVTValidatorABI,
137
+ functionName: 'threshold',
138
+ args: []
139
+ });
140
+ },
141
+ async setThreshold({ newThreshold, account }) {
142
+ return client.writeContract({
143
+ address,
144
+ abi: DVTValidatorABI,
145
+ functionName: 'setThreshold',
146
+ args: [newThreshold],
147
+ account: account,
148
+ chain: client.chain
149
+ });
150
+ },
151
+ async setRegistry({ registry, account }) {
152
+ return client.writeContract({
153
+ address,
154
+ abi: DVTValidatorABI,
155
+ functionName: 'setRegistry',
156
+ args: [registry],
157
+ account: account,
158
+ chain: client.chain
159
+ });
160
+ },
161
+ async setBLSAggregator({ aggregator, account }) {
162
+ return client.writeContract({ address, abi: DVTValidatorABI, functionName: 'setBLSAggregator', args: [aggregator], account: account, chain: client.chain });
163
+ },
164
+ async markProposalExecuted({ proposalId, account }) {
165
+ return client.writeContract({ address, abi: DVTValidatorABI, functionName: 'markProposalExecuted', args: [proposalId], account: account, chain: client.chain });
166
+ },
167
+ async BLS_AGGREGATOR() {
168
+ return client.readContract({ address, abi: DVTValidatorABI, functionName: 'BLS_AGGREGATOR', args: [] });
169
+ },
170
+ async owner() {
171
+ return client.readContract({
172
+ address,
173
+ abi: DVTValidatorABI,
174
+ functionName: 'owner',
175
+ args: []
176
+ });
177
+ },
178
+ async transferOwnership({ newOwner, account }) {
179
+ return client.writeContract({
180
+ address,
181
+ abi: DVTValidatorABI,
182
+ functionName: 'transferOwnership',
183
+ args: [newOwner],
184
+ account: account,
185
+ chain: client.chain
186
+ });
187
+ },
188
+ async renounceOwnership({ account }) {
189
+ return client.writeContract({
190
+ address,
191
+ abi: DVTValidatorABI,
192
+ functionName: 'renounceOwnership',
193
+ args: [],
194
+ account: account,
195
+ chain: client.chain
196
+ });
197
+ },
198
+ async version() {
199
+ return client.readContract({
200
+ address,
201
+ abi: DVTValidatorABI,
202
+ functionName: 'version',
203
+ args: []
204
+ });
205
+ }
206
+ });
207
+ export const blsActions = (address) => (client) => ({
208
+ async aggregatedSignatures({ requestId }) {
209
+ return client.readContract({
210
+ address,
211
+ abi: BLSAggregatorABI,
212
+ functionName: 'aggregatedSignatures',
213
+ args: [requestId]
214
+ });
215
+ },
216
+ async registerBLSPublicKey({ publicKey, account }) {
217
+ return client.writeContract({
218
+ address,
219
+ abi: BLSAggregatorABI,
220
+ functionName: 'registerBLSPublicKey',
221
+ args: [publicKey],
222
+ account: account,
223
+ chain: client.chain
224
+ });
225
+ },
226
+ async registerOperator({ operator, blsPublicKey, account }) {
227
+ return client.writeContract({
228
+ address,
229
+ abi: BLSAggregatorABI,
230
+ functionName: 'registerOperator',
231
+ args: [operator, blsPublicKey],
232
+ account: account,
233
+ chain: client.chain
234
+ });
235
+ },
236
+ async deregisterBLSPublicKey({ account }) {
237
+ return client.writeContract({
238
+ address,
239
+ abi: BLSAggregatorABI,
240
+ functionName: 'deregisterBLSPublicKey',
241
+ args: [],
242
+ account: account,
243
+ chain: client.chain
244
+ });
245
+ },
246
+ async updatePublicKey({ newKey, account }) {
247
+ return client.writeContract({
248
+ address,
249
+ abi: BLSAggregatorABI,
250
+ functionName: 'updatePublicKey',
251
+ args: [newKey],
252
+ account: account,
253
+ chain: client.chain
254
+ });
255
+ },
256
+ async aggregateSignatures({ signatures }) {
257
+ return client.readContract({
258
+ address,
259
+ abi: BLSAggregatorABI,
260
+ functionName: 'aggregateSignatures',
261
+ args: [signatures]
262
+ });
263
+ },
264
+ async verifyAggregatedSignature({ message, aggregatedSignature, publicKeys }) {
265
+ return client.readContract({
266
+ address,
267
+ abi: BLSAggregatorABI,
268
+ functionName: 'verifyAggregatedSignature',
269
+ args: [message, aggregatedSignature, publicKeys]
270
+ });
271
+ },
272
+ async validateSignature({ message, signature, publicKey }) {
273
+ return client.readContract({
274
+ address,
275
+ abi: BLSAggregatorABI,
276
+ functionName: 'validateSignature',
277
+ args: [message, signature, publicKey]
278
+ });
279
+ },
280
+ async executeProposal({ proposalId, signatures, account }) {
281
+ return client.writeContract({ address, abi: BLSAggregatorABI, functionName: 'executeProposal', args: [proposalId, signatures], account: account, chain: client.chain });
282
+ },
283
+ async verifyAndExecute({ proposalId, signatures, account }) {
284
+ return client.writeContract({ address, abi: BLSAggregatorABI, functionName: 'verifyAndExecute', args: [proposalId, signatures], account: account, chain: client.chain });
285
+ },
286
+ async getPublicKey({ address: userAddress }) {
287
+ return client.readContract({
288
+ address,
289
+ abi: BLSAggregatorABI,
290
+ functionName: 'getPublicKey',
291
+ args: [userAddress]
292
+ });
293
+ },
294
+ async getPublicKeys({ addresses }) {
295
+ return client.readContract({
296
+ address,
297
+ abi: BLSAggregatorABI,
298
+ functionName: 'getPublicKeys',
299
+ args: [addresses]
300
+ });
301
+ },
302
+ async getAggregatedPublicKey({ addresses }) {
303
+ return client.readContract({
304
+ address,
305
+ abi: BLSAggregatorABI,
306
+ functionName: 'getAggregatedPublicKey',
307
+ args: [addresses]
308
+ });
309
+ },
310
+ async isKeyRegistered({ address: userAddress }) {
311
+ return client.readContract({
312
+ address,
313
+ abi: BLSAggregatorABI,
314
+ functionName: 'isKeyRegistered',
315
+ args: [userAddress]
316
+ });
317
+ },
318
+ async getRegisteredCount() {
319
+ return client.readContract({
320
+ address,
321
+ abi: BLSAggregatorABI,
322
+ functionName: 'getRegisteredCount',
323
+ args: []
324
+ });
325
+ },
326
+ async blsPublicKeys({ address: userAddress }) {
327
+ return client.readContract({ address, abi: BLSAggregatorABI, functionName: 'blsPublicKeys', args: [userAddress] });
328
+ },
329
+ async threshold() {
330
+ return client.readContract({
331
+ address,
332
+ abi: BLSAggregatorABI,
333
+ functionName: 'threshold',
334
+ args: []
335
+ });
336
+ },
337
+ async minThreshold() {
338
+ return client.readContract({ address, abi: BLSAggregatorABI, functionName: 'minThreshold', args: [] });
339
+ },
340
+ async defaultThreshold() {
341
+ return client.readContract({ address, abi: BLSAggregatorABI, functionName: 'defaultThreshold', args: [] });
342
+ },
343
+ async setThreshold({ newThreshold, account }) {
344
+ return client.writeContract({
345
+ address,
346
+ abi: BLSAggregatorABI,
347
+ functionName: 'setThreshold',
348
+ args: [newThreshold],
349
+ account: account,
350
+ chain: client.chain
351
+ });
352
+ },
353
+ async setMinThreshold({ newThreshold, account }) {
354
+ return client.writeContract({ address, abi: BLSAggregatorABI, functionName: 'setMinThreshold', args: [newThreshold], account: account, chain: client.chain });
355
+ },
356
+ async setDefaultThreshold({ newThreshold, account }) {
357
+ return client.writeContract({ address, abi: BLSAggregatorABI, functionName: 'setDefaultThreshold', args: [newThreshold], account: account, chain: client.chain });
358
+ },
359
+ async setRegistry({ registry, account }) {
360
+ return client.writeContract({
361
+ address,
362
+ abi: BLSAggregatorABI,
363
+ functionName: 'setRegistry',
364
+ args: [registry],
365
+ account: account,
366
+ chain: client.chain
367
+ });
368
+ },
369
+ async setDVTValidator({ validator, account }) {
370
+ return client.writeContract({ address, abi: BLSAggregatorABI, functionName: 'setDVTValidator', args: [validator], account: account, chain: client.chain });
371
+ },
372
+ async setSuperPaymaster({ paymaster, account }) {
373
+ return client.writeContract({ address, abi: BLSAggregatorABI, functionName: 'setSuperPaymaster', args: [paymaster], account: account, chain: client.chain });
374
+ },
375
+ async renounceOwnership({ account }) {
376
+ return client.writeContract({ address, abi: BLSAggregatorABI, functionName: 'renounceOwnership', args: [], account: account, chain: client.chain });
377
+ },
378
+ async REGISTRY() {
379
+ return client.readContract({
380
+ address,
381
+ abi: BLSAggregatorABI,
382
+ functionName: 'REGISTRY',
383
+ args: []
384
+ });
385
+ },
386
+ async DVT_VALIDATOR() {
387
+ return client.readContract({ address, abi: BLSAggregatorABI, functionName: 'DVT_VALIDATOR', args: [] });
388
+ },
389
+ async SUPERPAYMASTER() {
390
+ return client.readContract({ address, abi: BLSAggregatorABI, functionName: 'SUPERPAYMASTER', args: [] });
391
+ },
392
+ async MAX_VALIDATORS() {
393
+ return client.readContract({ address, abi: BLSAggregatorABI, functionName: 'MAX_VALIDATORS', args: [] });
394
+ },
395
+ async executedProposals({ proposalId }) {
396
+ return client.readContract({ address, abi: BLSAggregatorABI, functionName: 'executedProposals', args: [proposalId] });
397
+ },
398
+ async proposalNonces({ proposalId }) {
399
+ return client.readContract({ address, abi: BLSAggregatorABI, functionName: 'proposalNonces', args: [proposalId] });
400
+ },
401
+ async getRequestStatus({ requestId }) {
402
+ return client.readContract({ address, abi: BLSAggregatorABI, functionName: 'getRequestStatus', args: [requestId] });
403
+ },
404
+ async getOperatorId({ operator }) {
405
+ return client.readContract({ address, abi: BLSAggregatorABI, functionName: 'getOperatorId', args: [operator] });
406
+ },
407
+ async owner() {
408
+ return client.readContract({
409
+ address,
410
+ abi: BLSAggregatorABI,
411
+ functionName: 'owner',
412
+ args: []
413
+ });
414
+ },
415
+ async transferOwnership({ newOwner, account }) {
416
+ return client.writeContract({
417
+ address,
418
+ abi: BLSAggregatorABI,
419
+ functionName: 'transferOwnership',
420
+ args: [newOwner],
421
+ account: account,
422
+ chain: client.chain
423
+ });
424
+ },
425
+ async version() {
426
+ return client.readContract({
427
+ address,
428
+ abi: BLSAggregatorABI,
429
+ functionName: 'version',
430
+ args: []
431
+ });
432
+ }
433
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,215 @@
1
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+ import { dvtActions, blsActions } from './validators.js';
3
+ describe('Validator Actions', () => {
4
+ let mockPublicClient;
5
+ let mockWalletClient;
6
+ let mockAccount;
7
+ const MOCK_VALIDATOR = '0x1111111111111111111111111111111111111111';
8
+ const MOCK_TARGET = '0x2222222222222222222222222222222222222222';
9
+ const MOCK_USER = '0x3333333333333333333333333333333333333333';
10
+ const MOCK_PROPOSAL_ID = 1n;
11
+ beforeEach(() => {
12
+ mockAccount = {
13
+ address: MOCK_USER,
14
+ type: 'json-rpc'
15
+ };
16
+ mockPublicClient = {
17
+ readContract: vi.fn(),
18
+ };
19
+ mockWalletClient = {
20
+ writeContract: vi.fn(),
21
+ account: mockAccount,
22
+ };
23
+ });
24
+ describe('dvtActions', () => {
25
+ it('should create proposal', async () => {
26
+ const txHash = '0xhash';
27
+ mockWalletClient.writeContract.mockResolvedValue(txHash);
28
+ const actions = dvtActions(MOCK_VALIDATOR)(mockWalletClient);
29
+ const result = await actions.createProposal({
30
+ target: MOCK_TARGET,
31
+ calldata: '0x',
32
+ description: 'test',
33
+ account: mockAccount
34
+ });
35
+ expect(result).toBe(txHash);
36
+ });
37
+ it('should sign proposal', async () => {
38
+ const txHash = '0xhash';
39
+ mockWalletClient.writeContract.mockResolvedValue(txHash);
40
+ const actions = dvtActions(MOCK_VALIDATOR)(mockWalletClient);
41
+ const result = await actions.signProposal({ proposalId: MOCK_PROPOSAL_ID, account: mockAccount });
42
+ expect(result).toBe(txHash);
43
+ });
44
+ it('should execute with proof', async () => {
45
+ const txHash = '0xhash';
46
+ mockWalletClient.writeContract.mockResolvedValue(txHash);
47
+ const actions = dvtActions(MOCK_VALIDATOR)(mockWalletClient);
48
+ const result = await actions.executeWithProof({
49
+ proposalId: MOCK_PROPOSAL_ID,
50
+ signatures: ['0x123'],
51
+ account: mockAccount
52
+ });
53
+ expect(result).toBe(txHash);
54
+ });
55
+ it('should cancel proposal', async () => {
56
+ const txHash = '0xhash';
57
+ mockWalletClient.writeContract.mockResolvedValue(txHash);
58
+ const actions = dvtActions(MOCK_VALIDATOR)(mockWalletClient);
59
+ const result = await actions.cancelProposal({ proposalId: MOCK_PROPOSAL_ID, account: mockAccount });
60
+ expect(result).toBe(txHash);
61
+ });
62
+ it('should query validator info', async () => {
63
+ mockPublicClient.readContract
64
+ .mockResolvedValueOnce(true) // isValidator
65
+ .mockResolvedValueOnce(['0xV1']) // getValidators
66
+ .mockResolvedValueOnce(1n); // getValidatorCount
67
+ const actions = dvtActions(MOCK_VALIDATOR)(mockPublicClient);
68
+ expect(await actions.isValidator({ validator: MOCK_USER })).toBe(true);
69
+ expect(await actions.getValidators()).toEqual(['0xV1']);
70
+ expect(await actions.getValidatorCount()).toBe(1n);
71
+ });
72
+ it('should query proposal details', async () => {
73
+ mockPublicClient.readContract
74
+ .mockResolvedValueOnce({ id: 1n }) // getProposal
75
+ .mockResolvedValueOnce(1n) // getProposalCount
76
+ .mockResolvedValueOnce(1) // getProposalState
77
+ .mockResolvedValueOnce(5n) // getSignatureCount
78
+ .mockResolvedValueOnce(true); // hasVoted
79
+ const actions = dvtActions(MOCK_VALIDATOR)(mockPublicClient);
80
+ const prop = await actions.getProposal({ proposalId: MOCK_PROPOSAL_ID });
81
+ expect(prop.id).toBe(1n);
82
+ expect(await actions.getProposalCount()).toBe(1n);
83
+ expect(await actions.getProposalState({ proposalId: MOCK_PROPOSAL_ID })).toBe(1);
84
+ expect(await actions.getSignatureCount({ proposalId: MOCK_PROPOSAL_ID })).toBe(5n);
85
+ expect(await actions.hasVoted({ proposalId: MOCK_PROPOSAL_ID, validator: MOCK_USER })).toBe(true);
86
+ });
87
+ it('should manage validators and threshold', async () => {
88
+ const txHash = '0xhash';
89
+ mockWalletClient.writeContract.mockResolvedValue(txHash);
90
+ const actions = dvtActions(MOCK_VALIDATOR)(mockWalletClient);
91
+ expect(await actions.addValidator({ validator: MOCK_USER, account: mockAccount })).toBe(txHash);
92
+ expect(await actions.removeValidator({ validator: MOCK_USER, account: mockAccount })).toBe(txHash);
93
+ expect(await actions.setThreshold({ newThreshold: 2n, account: mockAccount })).toBe(txHash);
94
+ });
95
+ it('should system config and view', async () => {
96
+ mockPublicClient.readContract
97
+ .mockResolvedValueOnce(3n) // threshold
98
+ .mockResolvedValueOnce(MOCK_USER) // owner
99
+ .mockResolvedValueOnce('v1'); // version
100
+ const actions = dvtActions(MOCK_VALIDATOR)(mockPublicClient);
101
+ expect(await actions.threshold()).toBe(3n);
102
+ expect(await actions.owner()).toBe(MOCK_USER);
103
+ expect(await actions.version()).toBe('v1');
104
+ });
105
+ it('should call admin setters', async () => {
106
+ const txHash = '0xhash';
107
+ mockWalletClient.writeContract.mockResolvedValue(txHash);
108
+ const actions = dvtActions(MOCK_VALIDATOR)(mockWalletClient);
109
+ expect(await actions.setRegistry({ registry: MOCK_USER, account: mockAccount })).toBe(txHash);
110
+ expect(await actions.setBLSAggregator({ aggregator: MOCK_USER, account: mockAccount })).toBe(txHash);
111
+ expect(await actions.markProposalExecuted({ proposalId: 1n, account: mockAccount })).toBe(txHash);
112
+ expect(await actions.transferOwnership({ newOwner: MOCK_USER, account: mockAccount })).toBe(txHash);
113
+ expect(await actions.renounceOwnership({ account: mockAccount })).toBe(txHash);
114
+ });
115
+ it('should call views', async () => {
116
+ mockPublicClient.readContract
117
+ .mockResolvedValueOnce({}) // proposals
118
+ .mockResolvedValueOnce(2n) // nextProposalId
119
+ .mockResolvedValueOnce(MOCK_USER); // BLS_AGGREGATOR
120
+ const actions = dvtActions(MOCK_VALIDATOR)(mockPublicClient);
121
+ expect(await actions.proposals({ proposalId: 1n })).toEqual({});
122
+ expect(await actions.nextProposalId()).toBe(2n);
123
+ expect(await actions.BLS_AGGREGATOR()).toBe(MOCK_USER);
124
+ });
125
+ });
126
+ describe('blsActions', () => {
127
+ const MOCK_BLS = '0x4444444444444444444444444444444444444444';
128
+ const MOCK_KEY = '0x1234';
129
+ it('should manage BLS public keys', async () => {
130
+ const txHash = '0xhash';
131
+ mockWalletClient.writeContract.mockResolvedValue(txHash);
132
+ const actions = blsActions(MOCK_BLS)(mockWalletClient);
133
+ expect(await actions.registerBLSPublicKey({ publicKey: MOCK_KEY, account: mockAccount })).toBe(txHash);
134
+ expect(await actions.deregisterBLSPublicKey({ account: mockAccount })).toBe(txHash);
135
+ expect(await actions.updatePublicKey({ newKey: MOCK_KEY, account: mockAccount })).toBe(txHash);
136
+ });
137
+ it('should aggregate and verify signatures', async () => {
138
+ mockPublicClient.readContract
139
+ .mockResolvedValueOnce('0xagg') // aggregateSignatures
140
+ .mockResolvedValueOnce(true) // verifyAggregatedSignature
141
+ .mockResolvedValueOnce(true); // validateSignature
142
+ const actions = blsActions(MOCK_BLS)(mockPublicClient);
143
+ expect(await actions.aggregateSignatures({ signatures: ['0x1'] })).toBe('0xagg');
144
+ expect(await actions.verifyAggregatedSignature({ message: '0x', aggregatedSignature: '0x', publicKeys: ['0x'] })).toBe(true);
145
+ expect(await actions.validateSignature({ message: '0x', signature: '0x', publicKey: '0x' })).toBe(true);
146
+ });
147
+ it('should query public keys and status', async () => {
148
+ mockPublicClient.readContract
149
+ .mockResolvedValueOnce(MOCK_KEY) // getPublicKey
150
+ .mockResolvedValueOnce([MOCK_KEY]) // getPublicKeys
151
+ .mockResolvedValueOnce(MOCK_KEY) // getAggregatedPublicKey
152
+ .mockResolvedValueOnce(true) // isKeyRegistered
153
+ .mockResolvedValueOnce(10n); // getRegisteredCount
154
+ const actions = blsActions(MOCK_BLS)(mockPublicClient);
155
+ expect(await actions.getPublicKey({ address: MOCK_USER })).toBe(MOCK_KEY);
156
+ expect(await actions.getPublicKeys({ addresses: [MOCK_USER] })).toEqual([MOCK_KEY]);
157
+ expect(await actions.getAggregatedPublicKey({ addresses: [MOCK_USER] })).toBe(MOCK_KEY);
158
+ expect(await actions.isKeyRegistered({ address: MOCK_USER })).toBe(true);
159
+ expect(await actions.getRegisteredCount()).toBe(10n);
160
+ });
161
+ it('should manage threshold and system', async () => {
162
+ const txHash = '0xhash';
163
+ mockWalletClient.writeContract.mockResolvedValue(txHash);
164
+ const actions = blsActions(MOCK_BLS)(mockWalletClient);
165
+ expect(await actions.setThreshold({ newThreshold: 5n, account: mockAccount })).toBe(txHash);
166
+ expect(await actions.setRegistry({ registry: MOCK_USER, account: mockAccount })).toBe(txHash);
167
+ expect(await actions.transferOwnership({ newOwner: MOCK_USER, account: mockAccount })).toBe(txHash);
168
+ });
169
+ it('should call proposal execution extensions', async () => {
170
+ const txHash = '0xhash';
171
+ mockWalletClient.writeContract.mockResolvedValue(txHash);
172
+ const actions = blsActions(MOCK_BLS)(mockWalletClient);
173
+ expect(await actions.executeProposal({ proposalId: 1n, signatures: ['0x'], account: mockAccount })).toBe(txHash);
174
+ expect(await actions.verifyAndExecute({ proposalId: 1n, signatures: ['0x'], account: mockAccount })).toBe(txHash);
175
+ });
176
+ it('should manage thresholds extended', async () => {
177
+ const txHash = '0xhash';
178
+ mockWalletClient.writeContract.mockResolvedValue(txHash);
179
+ const actions = blsActions(MOCK_BLS)(mockWalletClient);
180
+ expect(await actions.setMinThreshold({ newThreshold: 2n, account: mockAccount })).toBe(txHash);
181
+ expect(await actions.setDefaultThreshold({ newThreshold: 3n, account: mockAccount })).toBe(txHash);
182
+ expect(await actions.setDVTValidator({ validator: MOCK_USER, account: mockAccount })).toBe(txHash);
183
+ expect(await actions.setSuperPaymaster({ paymaster: MOCK_USER, account: mockAccount })).toBe(txHash);
184
+ expect(await actions.renounceOwnership({ account: mockAccount })).toBe(txHash);
185
+ });
186
+ it('should call extended views', async () => {
187
+ mockPublicClient.readContract
188
+ .mockResolvedValueOnce(['0x']) // blsPublicKeys
189
+ .mockResolvedValueOnce(1n) // threshold
190
+ .mockResolvedValueOnce(1n) // minThreshold
191
+ .mockResolvedValueOnce(1n) // defaultThreshold
192
+ .mockResolvedValueOnce(MOCK_USER) // REGISTRY
193
+ .mockResolvedValueOnce(MOCK_USER) // DVT_VALIDATOR
194
+ .mockResolvedValueOnce(MOCK_USER) // SUPERPAYMASTER
195
+ .mockResolvedValueOnce(10n) // MAX_VALIDATORS
196
+ .mockResolvedValueOnce(true) // executedProposals
197
+ .mockResolvedValueOnce(0n) // proposalNonces
198
+ .mockResolvedValueOnce(MOCK_USER) // owner
199
+ .mockResolvedValueOnce('v1'); // version
200
+ const actions = blsActions(MOCK_BLS)(mockPublicClient);
201
+ expect(await actions.blsPublicKeys({ address: MOCK_USER })).toEqual(['0x']);
202
+ expect(await actions.threshold()).toBe(1n);
203
+ expect(await actions.minThreshold()).toBe(1n);
204
+ expect(await actions.defaultThreshold()).toBe(1n);
205
+ expect(await actions.REGISTRY()).toBe(MOCK_USER);
206
+ expect(await actions.DVT_VALIDATOR()).toBe(MOCK_USER);
207
+ expect(await actions.SUPERPAYMASTER()).toBe(MOCK_USER);
208
+ expect(await actions.MAX_VALIDATORS()).toBe(10n);
209
+ expect(await actions.executedProposals({ proposalId: 1n })).toBe(true);
210
+ expect(await actions.proposalNonces({ proposalId: 1n })).toBe(0n);
211
+ expect(await actions.owner()).toBe(MOCK_USER);
212
+ expect(await actions.version()).toBe('v1');
213
+ });
214
+ });
215
+ });
@@ -0,0 +1,30 @@
1
+ /**
2
+ * AAStar Community Branding Configuration
3
+ */
4
+ export declare const BRANDING: {
5
+ readonly logo: "https://raw.githubusercontent.com/jhfnetboy/MarkDownImg/main/img/202505031325963.png";
6
+ readonly icon: "https://www.aastar.io/favicon.ico";
7
+ readonly colors: {
8
+ readonly primary: "#FF6B35";
9
+ readonly primaryLight: "#FF8C42";
10
+ readonly secondary: "#4A90E2";
11
+ readonly secondaryDark: "#357ABD";
12
+ readonly success: "#4CAF50";
13
+ readonly warning: "#FFC107";
14
+ readonly error: "#F44336";
15
+ readonly gray50: "#F9FAFB";
16
+ readonly gray100: "#F3F4F6";
17
+ readonly gray700: "#374151";
18
+ readonly gray800: "#1F2937";
19
+ readonly gray900: "#111827";
20
+ };
21
+ };
22
+ export declare const LINKS: {
23
+ readonly main: "https://aastar.io";
24
+ readonly airAccount: "https://airAccount.aastar.io";
25
+ readonly superPaymaster: "https://superpaymaster.aastar.io";
26
+ readonly demo: "https://aastar.io/demo";
27
+ readonly github: "https://github.com/AAStarCommunity";
28
+ readonly discord: "https://discord.gg/aastar";
29
+ readonly twitter: "https://twitter.com/AAStarCommunity";
30
+ };