@aastar/core 0.16.8 → 0.16.11

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,17 +1,78 @@
1
1
  import { type Address, type PublicClient, type WalletClient, type Hex, type Hash, type Account } from 'viem';
2
2
  export type AggregatorActions = {
3
3
  registerBLSPublicKey: (args: {
4
- address: Address;
4
+ validator: Address;
5
5
  publicKey: Hex;
6
6
  account?: Account | Address;
7
7
  }) => Promise<Hash>;
8
- setBLSThreshold: (args: {
9
- address: Address;
10
- threshold: number;
8
+ blsPublicKeys: (args: {
9
+ validator: Address;
10
+ }) => Promise<{
11
+ publicKey: Hex;
12
+ isActive: boolean;
13
+ }>;
14
+ setDefaultThreshold: (args: {
15
+ newThreshold: bigint;
16
+ account?: Account | Address;
17
+ }) => Promise<Hash>;
18
+ setMinThreshold: (args: {
19
+ newThreshold: bigint;
20
+ account?: Account | Address;
21
+ }) => Promise<Hash>;
22
+ defaultThreshold: () => Promise<bigint>;
23
+ minThreshold: () => Promise<bigint>;
24
+ executeProposal: (args: {
25
+ proposalId: bigint;
26
+ target: Address;
27
+ callData: Hex;
28
+ requiredThreshold: bigint;
29
+ proof: Hex;
30
+ account?: Account | Address;
31
+ }) => Promise<Hash>;
32
+ verifyAndExecute: (args: {
33
+ proposalId: bigint;
34
+ operator: Address;
35
+ slashLevel: number;
36
+ repUsers: Address[];
37
+ newScores: bigint[];
38
+ epoch: bigint;
39
+ proof: Hex;
11
40
  account?: Account | Address;
12
41
  }) => Promise<Hash>;
13
- getBLSThreshold: (args: {
14
- address: Address;
42
+ executedProposals: (args: {
43
+ proposalId: bigint;
44
+ }) => Promise<boolean>;
45
+ proposalNonces: (args: {
46
+ proposalId: bigint;
15
47
  }) => Promise<bigint>;
48
+ aggregatedSignatures: (args: {
49
+ index: bigint;
50
+ }) => Promise<{
51
+ aggregatedSig: Hex;
52
+ messageHash: Hex;
53
+ timestamp: bigint;
54
+ verified: boolean;
55
+ }>;
56
+ setDVTValidator: (args: {
57
+ dv: Address;
58
+ account?: Account | Address;
59
+ }) => Promise<Hash>;
60
+ setSuperPaymaster: (args: {
61
+ paymaster: Address;
62
+ account?: Account | Address;
63
+ }) => Promise<Hash>;
64
+ DVT_VALIDATOR: () => Promise<Address>;
65
+ SUPERPAYMASTER: () => Promise<Address>;
66
+ REGISTRY: () => Promise<Address>;
67
+ MAX_VALIDATORS: () => Promise<bigint>;
68
+ owner: () => Promise<Address>;
69
+ transferOwnership: (args: {
70
+ newOwner: Address;
71
+ account?: Account | Address;
72
+ }) => Promise<Hash>;
73
+ renounceOwnership: (args: {
74
+ account?: Account | Address;
75
+ }) => Promise<Hash>;
76
+ version: () => Promise<string>;
16
77
  };
17
- export declare const aggregatorActions: () => (client: PublicClient | WalletClient) => AggregatorActions;
78
+ export declare const aggregatorActions: (address: Address) => (client: PublicClient | WalletClient) => AggregatorActions;
@@ -1,31 +1,331 @@
1
1
  import { BLSAggregatorABI } from '../abis/index.js';
2
- export const aggregatorActions = () => (client) => ({
3
- async registerBLSPublicKey({ address, publicKey, account }) {
4
- return client.writeContract({
5
- address,
6
- abi: BLSAggregatorABI,
7
- functionName: 'registerBLSPublicKey',
8
- args: [publicKey],
9
- account: account,
10
- chain: client.chain
11
- });
12
- },
13
- async setBLSThreshold({ address, threshold, account }) {
14
- return client.writeContract({
15
- address,
16
- abi: BLSAggregatorABI,
17
- functionName: 'setThreshold',
18
- args: [BigInt(threshold)],
19
- account: account,
20
- chain: client.chain
21
- });
22
- },
23
- async getBLSThreshold({ address }) {
24
- return client.readContract({
25
- address,
26
- abi: BLSAggregatorABI,
27
- functionName: 'threshold',
28
- args: []
29
- });
2
+ import { validateAddress, validateRequired } from '../validators/index.js';
3
+ import { AAStarError } from '../errors/index.js';
4
+ export const aggregatorActions = (address) => (client) => ({
5
+ // BLS Public Key Management
6
+ async registerBLSPublicKey({ validator, publicKey, account }) {
7
+ try {
8
+ validateAddress(validator, 'validator');
9
+ validateRequired(publicKey, 'publicKey');
10
+ return await client.writeContract({
11
+ address,
12
+ abi: BLSAggregatorABI,
13
+ functionName: 'registerBLSPublicKey',
14
+ args: [validator, publicKey],
15
+ account: account,
16
+ chain: client.chain
17
+ });
18
+ }
19
+ catch (error) {
20
+ throw AAStarError.fromViemError(error, 'registerBLSPublicKey');
21
+ }
22
+ },
23
+ async blsPublicKeys({ validator }) {
24
+ try {
25
+ validateAddress(validator, 'validator');
26
+ const result = await client.readContract({
27
+ address,
28
+ abi: BLSAggregatorABI,
29
+ functionName: 'blsPublicKeys',
30
+ args: [validator]
31
+ });
32
+ return { publicKey: result[0], isActive: result[1] };
33
+ }
34
+ catch (error) {
35
+ throw AAStarError.fromViemError(error, 'blsPublicKeys');
36
+ }
37
+ },
38
+ // Threshold Management
39
+ async setDefaultThreshold({ newThreshold, account }) {
40
+ try {
41
+ validateRequired(newThreshold, 'newThreshold');
42
+ return await client.writeContract({
43
+ address,
44
+ abi: BLSAggregatorABI,
45
+ functionName: 'setDefaultThreshold',
46
+ args: [newThreshold],
47
+ account: account,
48
+ chain: client.chain
49
+ });
50
+ }
51
+ catch (error) {
52
+ throw AAStarError.fromViemError(error, 'setDefaultThreshold');
53
+ }
54
+ },
55
+ async setMinThreshold({ newThreshold, account }) {
56
+ try {
57
+ validateRequired(newThreshold, 'newThreshold');
58
+ return await client.writeContract({
59
+ address,
60
+ abi: BLSAggregatorABI,
61
+ functionName: 'setMinThreshold',
62
+ args: [newThreshold],
63
+ account: account,
64
+ chain: client.chain
65
+ });
66
+ }
67
+ catch (error) {
68
+ throw AAStarError.fromViemError(error, 'setMinThreshold');
69
+ }
70
+ },
71
+ async defaultThreshold() {
72
+ try {
73
+ return await client.readContract({
74
+ address,
75
+ abi: BLSAggregatorABI,
76
+ functionName: 'defaultThreshold',
77
+ args: []
78
+ });
79
+ }
80
+ catch (error) {
81
+ throw AAStarError.fromViemError(error, 'defaultThreshold');
82
+ }
83
+ },
84
+ async minThreshold() {
85
+ try {
86
+ return await client.readContract({
87
+ address,
88
+ abi: BLSAggregatorABI,
89
+ functionName: 'minThreshold',
90
+ args: []
91
+ });
92
+ }
93
+ catch (error) {
94
+ throw AAStarError.fromViemError(error, 'minThreshold');
95
+ }
96
+ },
97
+ // Proposal & Execution
98
+ async executeProposal({ proposalId, target, callData, requiredThreshold, proof, account }) {
99
+ try {
100
+ validateRequired(proposalId, 'proposalId');
101
+ validateAddress(target, 'target');
102
+ validateRequired(callData, 'callData');
103
+ validateRequired(requiredThreshold, 'requiredThreshold');
104
+ validateRequired(proof, 'proof');
105
+ return await client.writeContract({
106
+ address,
107
+ abi: BLSAggregatorABI,
108
+ functionName: 'executeProposal',
109
+ args: [proposalId, target, callData, requiredThreshold, proof],
110
+ account: account,
111
+ chain: client.chain
112
+ });
113
+ }
114
+ catch (error) {
115
+ throw AAStarError.fromViemError(error, 'executeProposal');
116
+ }
117
+ },
118
+ async verifyAndExecute({ proposalId, operator, slashLevel, repUsers, newScores, epoch, proof, account }) {
119
+ try {
120
+ validateRequired(proposalId, 'proposalId');
121
+ validateAddress(operator, 'operator');
122
+ validateRequired(slashLevel, 'slashLevel');
123
+ validateRequired(repUsers, 'repUsers');
124
+ validateRequired(newScores, 'newScores');
125
+ validateRequired(epoch, 'epoch');
126
+ validateRequired(proof, 'proof');
127
+ return await client.writeContract({
128
+ address,
129
+ abi: BLSAggregatorABI,
130
+ functionName: 'verifyAndExecute',
131
+ args: [proposalId, operator, slashLevel, repUsers, newScores, epoch, proof],
132
+ account: account,
133
+ chain: client.chain
134
+ });
135
+ }
136
+ catch (error) {
137
+ throw AAStarError.fromViemError(error, 'verifyAndExecute');
138
+ }
139
+ },
140
+ async executedProposals({ proposalId }) {
141
+ try {
142
+ validateRequired(proposalId, 'proposalId');
143
+ return await client.readContract({
144
+ address,
145
+ abi: BLSAggregatorABI,
146
+ functionName: 'executedProposals',
147
+ args: [proposalId]
148
+ });
149
+ }
150
+ catch (error) {
151
+ throw AAStarError.fromViemError(error, 'executedProposals');
152
+ }
153
+ },
154
+ async proposalNonces({ proposalId }) {
155
+ try {
156
+ validateRequired(proposalId, 'proposalId');
157
+ return await client.readContract({
158
+ address,
159
+ abi: BLSAggregatorABI,
160
+ functionName: 'proposalNonces',
161
+ args: [proposalId]
162
+ });
163
+ }
164
+ catch (error) {
165
+ throw AAStarError.fromViemError(error, 'proposalNonces');
166
+ }
167
+ },
168
+ // Aggregated Signatures
169
+ async aggregatedSignatures({ index }) {
170
+ try {
171
+ validateRequired(index, 'index');
172
+ const result = await client.readContract({
173
+ address,
174
+ abi: BLSAggregatorABI,
175
+ functionName: 'aggregatedSignatures',
176
+ args: [index]
177
+ });
178
+ return {
179
+ aggregatedSig: result[0],
180
+ messageHash: result[1],
181
+ timestamp: result[2],
182
+ verified: result[3]
183
+ };
184
+ }
185
+ catch (error) {
186
+ throw AAStarError.fromViemError(error, 'aggregatedSignatures');
187
+ }
188
+ },
189
+ // Config
190
+ async setDVTValidator({ dv, account }) {
191
+ try {
192
+ validateAddress(dv, 'dv');
193
+ return await client.writeContract({
194
+ address,
195
+ abi: BLSAggregatorABI,
196
+ functionName: 'setDVTValidator',
197
+ args: [dv],
198
+ account: account,
199
+ chain: client.chain
200
+ });
201
+ }
202
+ catch (error) {
203
+ throw AAStarError.fromViemError(error, 'setDVTValidator');
204
+ }
205
+ },
206
+ async setSuperPaymaster({ paymaster, account }) {
207
+ try {
208
+ validateAddress(paymaster, 'paymaster');
209
+ return await client.writeContract({
210
+ address,
211
+ abi: BLSAggregatorABI,
212
+ functionName: 'setSuperPaymaster',
213
+ args: [paymaster],
214
+ account: account,
215
+ chain: client.chain
216
+ });
217
+ }
218
+ catch (error) {
219
+ throw AAStarError.fromViemError(error, 'setSuperPaymaster');
220
+ }
221
+ },
222
+ async DVT_VALIDATOR() {
223
+ try {
224
+ return await client.readContract({
225
+ address,
226
+ abi: BLSAggregatorABI,
227
+ functionName: 'DVT_VALIDATOR',
228
+ args: []
229
+ });
230
+ }
231
+ catch (error) {
232
+ throw AAStarError.fromViemError(error, 'DVT_VALIDATOR');
233
+ }
234
+ },
235
+ async SUPERPAYMASTER() {
236
+ try {
237
+ return await client.readContract({
238
+ address,
239
+ abi: BLSAggregatorABI,
240
+ functionName: 'SUPERPAYMASTER',
241
+ args: []
242
+ });
243
+ }
244
+ catch (error) {
245
+ throw AAStarError.fromViemError(error, 'SUPERPAYMASTER');
246
+ }
247
+ },
248
+ async REGISTRY() {
249
+ try {
250
+ return await client.readContract({
251
+ address,
252
+ abi: BLSAggregatorABI,
253
+ functionName: 'REGISTRY',
254
+ args: []
255
+ });
256
+ }
257
+ catch (error) {
258
+ throw AAStarError.fromViemError(error, 'REGISTRY');
259
+ }
260
+ },
261
+ async MAX_VALIDATORS() {
262
+ try {
263
+ return await client.readContract({
264
+ address,
265
+ abi: BLSAggregatorABI,
266
+ functionName: 'MAX_VALIDATORS',
267
+ args: []
268
+ });
269
+ }
270
+ catch (error) {
271
+ throw AAStarError.fromViemError(error, 'MAX_VALIDATORS');
272
+ }
273
+ },
274
+ async owner() {
275
+ try {
276
+ return await client.readContract({
277
+ address,
278
+ abi: BLSAggregatorABI,
279
+ functionName: 'owner',
280
+ args: []
281
+ });
282
+ }
283
+ catch (error) {
284
+ throw AAStarError.fromViemError(error, 'owner');
285
+ }
286
+ },
287
+ async transferOwnership({ newOwner, account }) {
288
+ try {
289
+ validateAddress(newOwner, 'newOwner');
290
+ return await client.writeContract({
291
+ address,
292
+ abi: BLSAggregatorABI,
293
+ functionName: 'transferOwnership',
294
+ args: [newOwner],
295
+ account: account,
296
+ chain: client.chain
297
+ });
298
+ }
299
+ catch (error) {
300
+ throw AAStarError.fromViemError(error, 'transferOwnership');
301
+ }
302
+ },
303
+ async renounceOwnership({ account }) {
304
+ try {
305
+ return await client.writeContract({
306
+ address,
307
+ abi: BLSAggregatorABI,
308
+ functionName: 'renounceOwnership',
309
+ args: [],
310
+ account: account,
311
+ chain: client.chain
312
+ });
313
+ }
314
+ catch (error) {
315
+ throw AAStarError.fromViemError(error, 'renounceOwnership');
316
+ }
317
+ },
318
+ async version() {
319
+ try {
320
+ return await client.readContract({
321
+ address,
322
+ abi: BLSAggregatorABI,
323
+ functionName: 'version',
324
+ args: []
325
+ });
326
+ }
327
+ catch (error) {
328
+ throw AAStarError.fromViemError(error, 'version');
329
+ }
30
330
  }
31
331
  });
@@ -1,20 +1,17 @@
1
1
  import { type Address, type PublicClient, type WalletClient, type Hex, type Hash, type Account } from 'viem';
2
2
  export type DVTActions = {
3
3
  createSlashProposal: (args: {
4
- address: Address;
5
4
  operator: Address;
6
5
  level: number;
7
6
  reason: string;
8
7
  account?: Account | Address;
9
8
  }) => Promise<Hash>;
10
9
  signSlashProposal: (args: {
11
- address: Address;
12
10
  proposalId: bigint;
13
11
  signature: Hex;
14
12
  account?: Account | Address;
15
13
  }) => Promise<Hash>;
16
14
  executeSlashWithProof: (args: {
17
- address: Address;
18
15
  proposalId: bigint;
19
16
  repUsers: Address[];
20
17
  newScores: bigint[];
@@ -22,9 +19,40 @@ export type DVTActions = {
22
19
  proof: Hex;
23
20
  account?: Account | Address;
24
21
  }) => Promise<Hash>;
22
+ markProposalExecuted: (args: {
23
+ id: bigint;
24
+ account?: Account | Address;
25
+ }) => Promise<Hash>;
26
+ proposals: (args: {
27
+ proposalId: bigint;
28
+ }) => Promise<{
29
+ operator: Address;
30
+ slashLevel: number;
31
+ reason: string;
32
+ executed: boolean;
33
+ }>;
34
+ nextProposalId: () => Promise<bigint>;
25
35
  isValidator: (args: {
26
- address: Address;
27
36
  user: Address;
28
37
  }) => Promise<boolean>;
38
+ addValidator: (args: {
39
+ v: Address;
40
+ account?: Account | Address;
41
+ }) => Promise<Hash>;
42
+ setBLSAggregator: (args: {
43
+ aggregator: Address;
44
+ account?: Account | Address;
45
+ }) => Promise<Hash>;
46
+ BLS_AGGREGATOR: () => Promise<Address>;
47
+ REGISTRY: () => Promise<Address>;
48
+ owner: () => Promise<Address>;
49
+ transferOwnership: (args: {
50
+ newOwner: Address;
51
+ account?: Account | Address;
52
+ }) => Promise<Hash>;
53
+ renounceOwnership: (args: {
54
+ account?: Account | Address;
55
+ }) => Promise<Hash>;
56
+ version: () => Promise<string>;
29
57
  };
30
- export declare const dvtActions: () => (client: PublicClient | WalletClient) => DVTActions;
58
+ export declare const dvtActions: (address: Address) => (client: PublicClient | WalletClient) => DVTActions;