@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
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Error handling utilities for SDK
3
+ * Provides consistent error types and error transformation from viem
4
+ */
5
+ export var ErrorCode;
6
+ (function (ErrorCode) {
7
+ // Validation Errors (1xxx)
8
+ ErrorCode["INVALID_ADDRESS"] = "E1001";
9
+ ErrorCode["INVALID_AMOUNT"] = "E1002";
10
+ ErrorCode["INVALID_PARAMETER"] = "E1003";
11
+ ErrorCode["REQUIRED_PARAMETER"] = "E1004";
12
+ ErrorCode["INVALID_HEX"] = "E1005";
13
+ // Contract Errors (2xxx)
14
+ ErrorCode["CONTRACT_REVERT"] = "E2001";
15
+ ErrorCode["INSUFFICIENT_BALANCE"] = "E2002";
16
+ ErrorCode["UNAUTHORIZED"] = "E2003";
17
+ ErrorCode["PAUSED"] = "E2004";
18
+ ErrorCode["ROLE_NOT_CONFIGURED"] = "E2005";
19
+ ErrorCode["TOKEN_NOT_FOUND"] = "E2006";
20
+ // Network Errors (3xxx)
21
+ ErrorCode["NETWORK_TIMEOUT"] = "E3001";
22
+ ErrorCode["RPC_ERROR"] = "E3002";
23
+ ErrorCode["CONNECTION_REFUSED"] = "E3003";
24
+ // SDK Errors (4xxx)
25
+ ErrorCode["NOT_IMPLEMENTED"] = "E4001";
26
+ ErrorCode["INTERNAL_ERROR"] = "E4002";
27
+ ErrorCode["INVALID_CONFIGURATION"] = "E4003";
28
+ // Bundler & AA Errors (5xxx)
29
+ ErrorCode["BUNDLER_ERROR"] = "E5001";
30
+ ErrorCode["BUNDLER_USER_OP_REVERTED"] = "E5002";
31
+ ErrorCode["BUNDLER_SIGNATURE_INVALID"] = "E5003";
32
+ ErrorCode["BUNDLER_INSUFFICIENT_FUNDS"] = "E5004";
33
+ ErrorCode["BUNDLER_NONCE_TOO_LOW"] = "E5005";
34
+ ErrorCode["BUNDLER_RATE_LIMIT"] = "E5006";
35
+ })(ErrorCode || (ErrorCode = {}));
36
+ /**
37
+ * Base SDK error class with structured error information
38
+ */
39
+ export class AAStarError extends Error {
40
+ code;
41
+ cause;
42
+ data;
43
+ constructor(code, message, cause, data) {
44
+ super(message);
45
+ this.code = code;
46
+ this.cause = cause;
47
+ this.data = data;
48
+ this.name = 'AAStarError';
49
+ // Maintains proper stack trace
50
+ if (Error.captureStackTrace) {
51
+ Error.captureStackTrace(this, AAStarError);
52
+ }
53
+ }
54
+ /**
55
+ * Convert viem error to AAStarError with appropriate error code
56
+ */
57
+ static fromViemError(error, context) {
58
+ const msg = error.message.toLowerCase();
59
+ // Contract revert patterns
60
+ if (msg.includes('insufficient balance') || msg.includes('insufficient funds')) {
61
+ return new AAStarError(ErrorCode.INSUFFICIENT_BALANCE, 'Insufficient token balance for this operation', error);
62
+ }
63
+ if (msg.includes('paused')) {
64
+ return new AAStarError(ErrorCode.PAUSED, 'Contract is currently paused', error);
65
+ }
66
+ if (msg.includes('unauthorized') || msg.includes('not authorized')) {
67
+ return new AAStarError(ErrorCode.UNAUTHORIZED, 'Unauthorized to perform this action', error);
68
+ }
69
+ if (msg.includes('role not configured')) {
70
+ return new AAStarError(ErrorCode.ROLE_NOT_CONFIGURED, 'Role has not been configured in registry', error);
71
+ }
72
+ // Network errors
73
+ if (msg.includes('timeout') || msg.includes('etimedout')) {
74
+ return new AAStarError(ErrorCode.NETWORK_TIMEOUT, 'Network request timed out', error);
75
+ }
76
+ if (msg.includes('econnrefused') || msg.includes('connection refused')) {
77
+ return new AAStarError(ErrorCode.CONNECTION_REFUSED, 'Could not connect to RPC endpoint', error);
78
+ }
79
+ if (msg.includes('rpc')) {
80
+ return new AAStarError(ErrorCode.RPC_ERROR, 'RPC request failed', error);
81
+ }
82
+ // Default to contract revert
83
+ return new AAStarError(ErrorCode.CONTRACT_REVERT, context ? `Contract call failed: ${context}` : error.message, error);
84
+ }
85
+ /**
86
+ * Parse bundler error strings into structured AAStarError
87
+ */
88
+ static fromBundlerError(error) {
89
+ const message = typeof error === 'string' ? error : (error.message || JSON.stringify(error));
90
+ const code = error.code;
91
+ const msgLower = message.toLowerCase();
92
+ // Mapping ERC-4337 Error Codes (AAxx)
93
+ if (msgLower.includes('aa10') || msgLower.includes('invalid signature')) {
94
+ return new AAStarError(ErrorCode.BUNDLER_SIGNATURE_INVALID, `AA10: Invalid UserOperation signature`, error);
95
+ }
96
+ if (msgLower.includes('aa21') || msgLower.includes('aa25') || msgLower.includes('reverted')) {
97
+ return new AAStarError(ErrorCode.BUNDLER_USER_OP_REVERTED, `AA2x: UserOperation execution reverted`, error);
98
+ }
99
+ if (msgLower.includes('aa31') || msgLower.includes('aa33') || msgLower.includes('paymaster deposit too low')) {
100
+ return new AAStarError(ErrorCode.BUNDLER_INSUFFICIENT_FUNDS, `AA3x: Paymaster or account insufficient funds`, error);
101
+ }
102
+ if (msgLower.includes('aa24') || msgLower.includes('nonce too low')) {
103
+ return new AAStarError(ErrorCode.BUNDLER_NONCE_TOO_LOW, `AA24: Nonce too low or already used`, error);
104
+ }
105
+ if (code === -32604 || msgLower.includes('rate limit')) {
106
+ return new AAStarError(ErrorCode.BUNDLER_RATE_LIMIT, `Bundler rate limit exceeded (429)`, error);
107
+ }
108
+ return new AAStarError(ErrorCode.BUNDLER_ERROR, `Bundler error: ${message}`, error);
109
+ }
110
+ /**
111
+ * Convert to JSON for logging/reporting
112
+ */
113
+ toJSON() {
114
+ return {
115
+ name: this.name,
116
+ code: this.code,
117
+ message: this.message,
118
+ data: this.data,
119
+ cause: this.cause?.message,
120
+ stack: this.stack,
121
+ };
122
+ }
123
+ }
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@
6
6
  export * from './branding.js';
7
7
  export * from './contract-addresses.js';
8
8
  export * from './contracts.js';
9
+ export * from './contract-versions.js';
9
10
  export * from './networks.js';
10
11
  export * from './constants.js';
11
12
  export * from './communities.js';
@@ -13,9 +14,9 @@ export * from './abis/index.js';
13
14
  export * from './clients.js';
14
15
  export * from './clients/types.js';
15
16
  export * from './clients/BaseClient.js';
17
+ export * from './clients/BundlerClient.js';
16
18
  export * from './actions/index.js';
17
19
  export * from './crypto/index.js';
18
20
  export * from './roles.js';
19
21
  export * from './requirementChecker.js';
20
22
  export * from './config/ContractConfigManager.js';
21
- export * from './utils/validation.js';
package/dist/index.js CHANGED
@@ -6,6 +6,7 @@
6
6
  export * from './branding.js';
7
7
  export * from './contract-addresses.js'; // Single source of truth for all contract addresses
8
8
  export * from './contracts.js';
9
+ export * from './contract-versions.js';
9
10
  export * from './networks.js';
10
11
  export * from './constants.js';
11
12
  export * from './communities.js'; // Community configurations
@@ -13,9 +14,9 @@ export * from './abis/index.js'; // Assuming abis is a folder with index.ts
13
14
  export * from './clients.js';
14
15
  export * from './clients/types.js';
15
16
  export * from './clients/BaseClient.js';
17
+ export * from './clients/BundlerClient.js';
16
18
  export * from './actions/index.js';
17
19
  export * from './crypto/index.js';
18
20
  export * from './roles.js'; // Role system
19
21
  export * from './requirementChecker.js'; // Requirement validation
20
22
  export * from './config/ContractConfigManager.js';
21
- export * from './utils/validation.js';
@@ -6,8 +6,24 @@ import { Address, PublicClient } from 'viem';
6
6
  import type { RoleRequirement } from './roles.js';
7
7
  /**
8
8
  * Requirement Checker Utility
9
+ * @description Centralized validation for all role requirements
9
10
  *
10
- * Centralized validation for all role requirements
11
+ * @example
12
+ * ```typescript
13
+ * const checker = new RequirementChecker(publicClient);
14
+ *
15
+ * // Check community launch requirements
16
+ * const result = await checker.checkRequirements({
17
+ * address: userAddress,
18
+ * roleId: ROLE_COMMUNITY,
19
+ * requiredGToken: parseEther("33"),
20
+ * requireSBT: false
21
+ * });
22
+ *
23
+ * if (!result.hasEnoughGToken) {
24
+ * console.error(result.missingRequirements.join('\n'));
25
+ * }
26
+ * ```
11
27
  */
12
28
  export declare class RequirementChecker {
13
29
  private publicClient;
@@ -18,6 +34,12 @@ export declare class RequirementChecker {
18
34
  apnts?: Address;
19
35
  mysbt?: Address;
20
36
  } | undefined);
37
+ /**
38
+ * Check all requirements for a user
39
+ *
40
+ * @param params Check parameters
41
+ * @returns Detailed requirement status
42
+ */
21
43
  checkRequirements(params: {
22
44
  address: Address;
23
45
  roleId?: `0x${string}`;
@@ -25,14 +47,26 @@ export declare class RequirementChecker {
25
47
  requiredAPNTs?: bigint;
26
48
  requireSBT?: boolean;
27
49
  }): Promise<RoleRequirement>;
50
+ /**
51
+ * Check GToken balance only (shortcut)
52
+ */
28
53
  checkGTokenBalance(address: Address, required: bigint): Promise<{
29
54
  balance: bigint;
30
55
  hasEnough: boolean;
31
56
  }>;
57
+ /**
58
+ * Check aPNTs balance only (shortcut)
59
+ */
32
60
  checkAPNTsBalance(address: Address, required: bigint): Promise<{
33
61
  balance: bigint;
34
62
  hasEnough: boolean;
35
63
  }>;
64
+ /**
65
+ * Check if user has MySBT (shortcut)
66
+ */
36
67
  checkHasSBT(address: Address): Promise<boolean>;
68
+ /**
69
+ * Check if user has specific role (shortcut)
70
+ */
37
71
  checkHasRole(roleId: `0x${string}`, address: Address): Promise<boolean>;
38
72
  }
@@ -15,8 +15,24 @@ const MYSBT_ABI = parseAbi([
15
15
  ]);
16
16
  /**
17
17
  * Requirement Checker Utility
18
+ * @description Centralized validation for all role requirements
18
19
  *
19
- * Centralized validation for all role requirements
20
+ * @example
21
+ * ```typescript
22
+ * const checker = new RequirementChecker(publicClient);
23
+ *
24
+ * // Check community launch requirements
25
+ * const result = await checker.checkRequirements({
26
+ * address: userAddress,
27
+ * roleId: ROLE_COMMUNITY,
28
+ * requiredGToken: parseEther("33"),
29
+ * requireSBT: false
30
+ * });
31
+ *
32
+ * if (!result.hasEnoughGToken) {
33
+ * console.error(result.missingRequirements.join('\n'));
34
+ * }
35
+ * ```
20
36
  */
21
37
  export class RequirementChecker {
22
38
  publicClient;
@@ -25,9 +41,16 @@ export class RequirementChecker {
25
41
  this.publicClient = publicClient;
26
42
  this.addresses = addresses;
27
43
  }
44
+ /**
45
+ * Check all requirements for a user
46
+ *
47
+ * @param params Check parameters
48
+ * @returns Detailed requirement status
49
+ */
28
50
  async checkRequirements(params) {
29
51
  const { address, roleId, requiredGToken = 0n, requiredAPNTs = 0n, requireSBT = false } = params;
30
52
  const missingRequirements = [];
53
+ // Check role (if specified)
31
54
  let hasRole = false;
32
55
  if (roleId) {
33
56
  const { CORE_ADDRESSES } = await import('./contract-addresses.js');
@@ -41,6 +64,7 @@ export class RequirementChecker {
41
64
  missingRequirements.push(`Does not have required role`);
42
65
  }
43
66
  }
67
+ // Check GToken balance
44
68
  let hasEnoughGToken = true;
45
69
  if (requiredGToken > 0n) {
46
70
  const { CORE_ADDRESSES } = await import('./contract-addresses.js');
@@ -55,6 +79,7 @@ export class RequirementChecker {
55
79
  missingRequirements.push(`Need ${requiredGToken.toString()} GToken, have ${gtokenBalance.toString()}`);
56
80
  }
57
81
  }
82
+ // Check aPNTs balance
58
83
  let hasEnoughAPNTs = true;
59
84
  if (requiredAPNTs > 0n) {
60
85
  const { CORE_ADDRESSES } = await import('./contract-addresses.js');
@@ -69,6 +94,7 @@ export class RequirementChecker {
69
94
  missingRequirements.push(`Need ${requiredAPNTs.toString()} aPNTs, have ${apntsBalance.toString()}`);
70
95
  }
71
96
  }
97
+ // Check MySBT
72
98
  let hasSBT = false;
73
99
  if (requireSBT) {
74
100
  const { CORE_ADDRESSES } = await import('./contract-addresses.js');
@@ -91,6 +117,9 @@ export class RequirementChecker {
91
117
  missingRequirements
92
118
  };
93
119
  }
120
+ /**
121
+ * Check GToken balance only (shortcut)
122
+ */
94
123
  async checkGTokenBalance(address, required) {
95
124
  const { CORE_ADDRESSES } = await import('./contract-addresses.js');
96
125
  const balance = await this.publicClient.readContract({
@@ -104,6 +133,9 @@ export class RequirementChecker {
104
133
  hasEnough: balance >= required
105
134
  };
106
135
  }
136
+ /**
137
+ * Check aPNTs balance only (shortcut)
138
+ */
107
139
  async checkAPNTsBalance(address, required) {
108
140
  const { CORE_ADDRESSES } = await import('./contract-addresses.js');
109
141
  const balance = await this.publicClient.readContract({
@@ -117,6 +149,9 @@ export class RequirementChecker {
117
149
  hasEnough: balance >= required
118
150
  };
119
151
  }
152
+ /**
153
+ * Check if user has MySBT (shortcut)
154
+ */
120
155
  async checkHasSBT(address) {
121
156
  const { CORE_ADDRESSES } = await import('./contract-addresses.js');
122
157
  const balance = await this.publicClient.readContract({
@@ -127,6 +162,9 @@ export class RequirementChecker {
127
162
  });
128
163
  return balance > 0n;
129
164
  }
165
+ /**
166
+ * Check if user has specific role (shortcut)
167
+ */
130
168
  async checkHasRole(roleId, address) {
131
169
  const { CORE_ADDRESSES } = await import('./contract-addresses.js');
132
170
  return await this.publicClient.readContract({
package/dist/roles.d.ts CHANGED
@@ -1,96 +1,86 @@
1
1
  /**
2
2
  * Role constants and utilities for AAstar SDK
3
- * @remarks
4
- * All role hashes and configurations match exactly with Registry.sol v3.0.0
5
- *
6
- * **Source**: /contracts/src/core/Registry.sol
3
+ * @dev All role hashes and configurations match exactly with Registry.sol v3.0.0
4
+ * @source /contracts/src/core/Registry.sol
7
5
  */
8
6
  import { type Hash } from 'viem';
9
7
  /**
10
8
  * Default Admin Role (OpenZeppelin AccessControl)
11
- * @remarks
12
- * - **Description**: Highest privilege, can grant/revoke all roles
13
- * - **Permission**: Protocol governance only
14
- * - **Source**: OpenZeppelin AccessControl DEFAULT_ADMIN_ROLE
9
+ * @description Highest privilege, can grant/revoke all roles
10
+ * @permission Protocol governance only
11
+ * @source OpenZeppelin AccessControl DEFAULT_ADMIN_ROLE
15
12
  */
16
13
  export declare const DEFAULT_ADMIN_ROLE: Hash;
17
14
  /**
18
15
  * Community Role
19
- * @remarks
20
- * - **Description**: Community administrator, can issue xPNTs, configure SBT rules
21
- * - **Permission**: Community-level governance
22
- * - **Requirement**: minStake: 30 GT, entryBurn: 3 GT (line 99)
23
- * - **Exit Fee**: 5% (500 basis points), min 1 GT
24
- * - **Lock Duration**: 30 days
25
- * - **Source**: Registry.sol line 32: ROLE_COMMUNITY = keccak256("COMMUNITY")
16
+ * @description Community administrator, can issue xPNTs, configure SBT rules
17
+ * @permission Community-level governance
18
+ * @requirement minStake: 30 GT, entryBurn: 3 GT (line 99)
19
+ * @exitFee 5% (500 basis points), min 1 GT
20
+ * @lockDuration 30 days
21
+ * @source Registry.sol line 32: ROLE_COMMUNITY = keccak256("COMMUNITY")
26
22
  */
27
23
  export declare const ROLE_COMMUNITY: Hash;
28
24
  /**
29
25
  * End User Role
30
- * @remarks
31
- * - **Description**: Community member, can participate and use gasless transactions
32
- * - **Permission**: Basic user level
33
- * - **Requirement**: minStake: 0.3 GT, entryBurn: 0.05 GT (line 100)
34
- * - **Additional Requirement**: Must hold MySBT from community
35
- * - **Exit Fee**: 10% (1000 basis points), min 0.05 GT
36
- * - **Lock Duration**: 7 days
37
- * - **Source**: Registry.sol line 33: ROLE_ENDUSER = keccak256("ENDUSER")
26
+ * @description Community member, can participate and use gasless transactions
27
+ * @permission Basic user level
28
+ * @requirement minStake: 0.3 GT, entryBurn: 0.05 GT (line 100)
29
+ * @additionalRequirement Must hold MySBT from community
30
+ * @exitFee 10% (1000 basis points), min 0.05 GT
31
+ * @lockDuration 7 days
32
+ * @source Registry.sol line 33: ROLE_ENDUSER = keccak256("ENDUSER")
38
33
  */
39
34
  export declare const ROLE_ENDUSER: Hash;
40
35
  /**
41
36
  * Paymaster AOA Role (Account Ownership Authentication)
42
- * @remarks
43
- * - **Description**: Basic Paymaster node operator with account-based auth
44
- * - **Permission**: Infrastructure operator
45
- * - **Requirement**: minStake: 30 GT, entryBurn: 3 GT (line 92)
46
- * - **Exit Fee**: 10% (1000 basis points), min 1 GT
47
- * - **Lock Duration**: 30 days
48
- * - **Source**: Registry.sol line 34: ROLE_PAYMASTER_AOA = keccak256("PAYMASTER_AOA")
37
+ * @description Basic Paymaster node operator with account-based auth
38
+ * @permission Infrastructure operator
39
+ * @requirement minStake: 30 GT, entryBurn: 3 GT (line 92)
40
+ * @exitFee 10% (1000 basis points), min 1 GT
41
+ * @lockDuration 30 days
42
+ * @source Registry.sol line 34: ROLE_PAYMASTER_AOA = keccak256("PAYMASTER_AOA")
49
43
  */
50
44
  export declare const ROLE_PAYMASTER_AOA: Hash;
51
45
  /**
52
46
  * Paymaster Super Role
53
- * @remarks
54
- * - **Description**: Advanced Paymaster operator, can use SuperPaymaster with aPNTs collateral
55
- * - **Permission**: Infrastructure operator (higher tier)
56
- * - **Requirement**: minStake: 50 GT, entryBurn: 5 GT (line 93)
57
- * - **Additional Requirement**: aPNTs collateral in SuperPaymaster contract
58
- * - **Exit Fee**: 10% (1000 basis points), min 2 GT
59
- * - **Lock Duration**: 30 days
60
- * - **Source**: Registry.sol line 35: ROLE_PAYMASTER_SUPER = keccak256("PAYMASTER_SUPER")
47
+ * @description Advanced Paymaster operator, can use SuperPaymaster with aPNTs collateral
48
+ * @permission Infrastructure operator (higher tier)
49
+ * @requirement minStake: 50 GT, entryBurn: 5 GT (line 93)
50
+ * @additionalRequirement aPNTs collateral in SuperPaymaster contract
51
+ * @exitFee 10% (1000 basis points), min 2 GT
52
+ * @lockDuration 30 days
53
+ * @source Registry.sol line 35: ROLE_PAYMASTER_SUPER = keccak256("PAYMASTER_SUPER")
61
54
  */
62
55
  export declare const ROLE_PAYMASTER_SUPER: Hash;
63
56
  /**
64
57
  * DVT Role (Distributed Validator Technology)
65
- * @remarks
66
- * - **Description**: DVT node operator for consensus validation
67
- * - **Permission**: Infrastructure operator
68
- * - **Requirement**: minStake: 30 GT, entryBurn: 3 GT (line 94)
69
- * - **Exit Fee**: 10% (1000 basis points), min 1 GT
70
- * - **Lock Duration**: 30 days
71
- * - **Source**: Registry.sol line 36: ROLE_DVT = keccak256("DVT")
58
+ * @description DVT node operator for consensus validation
59
+ * @permission Infrastructure operator
60
+ * @requirement minStake: 30 GT, entryBurn: 3 GT (line 94)
61
+ * @exitFee 10% (1000 basis points), min 1 GT
62
+ * @lockDuration 30 days
63
+ * @source Registry.sol line 36: ROLE_DVT = keccak256("DVT")
72
64
  */
73
65
  export declare const ROLE_DVT: Hash;
74
66
  /**
75
67
  * ANODE Role (Anonymous Node)
76
- * @remarks
77
- * - **Description**: Anonymous infrastructure node operator
78
- * - **Permission**: Infrastructure operator
79
- * - **Requirement**: minStake: 20 GT, entryBurn: 2 GT (line 95)
80
- * - **Exit Fee**: 10% (1000 basis points), min 1 GT
81
- * - **Lock Duration**: 30 days
82
- * - **Source**: Registry.sol line 37: ROLE_ANODE = keccak256("ANODE")
68
+ * @description Anonymous infrastructure node operator
69
+ * @permission Infrastructure operator
70
+ * @requirement minStake: 20 GT, entryBurn: 2 GT (line 95)
71
+ * @exitFee 10% (1000 basis points), min 1 GT
72
+ * @lockDuration 30 days
73
+ * @source Registry.sol line 37: ROLE_ANODE = keccak256("ANODE")
83
74
  */
84
75
  export declare const ROLE_ANODE: Hash;
85
76
  /**
86
77
  * KMS Role (Key Management Service)
87
- * @remarks
88
- * - **Description**: KMS operator for secure key storage and management
89
- * - **Permission**: Infrastructure operator (highest stake)
90
- * - **Requirement**: minStake: 100 GT, entryBurn: 10 GT (line 98)
91
- * - **Exit Fee**: 10% (1000 basis points), min 5 GT
92
- * - **Lock Duration**: 30 days
93
- * - **Source**: Registry.sol line 38: ROLE_KMS = keccak256("KMS")
78
+ * @description KMS operator for secure key storage and management
79
+ * @permission Infrastructure operator (highest stake)
80
+ * @requirement minStake: 100 GT, entryBurn: 10 GT (line 98)
81
+ * @exitFee 10% (1000 basis points), min 5 GT
82
+ * @lockDuration 30 days
83
+ * @source Registry.sol line 38: ROLE_KMS = keccak256("KMS")
94
84
  */
95
85
  export declare const ROLE_KMS: Hash;
96
86
  /**
@@ -136,8 +126,7 @@ export declare enum RolePermissionLevel {
136
126
  export declare const ROLE_PERMISSION_LEVELS: Record<string, RolePermissionLevel>;
137
127
  /**
138
128
  * Exact stake requirements from Registry.sol constructor (lines 92-100)
139
- * @remarks
140
- * **Warning**: These are initial values, always query contract for current configuration
129
+ * @warning These are initial values, always query contract for current configuration
141
130
  */
142
131
  export declare const INITIAL_ROLE_STAKES: {
143
132
  readonly [x: string]: {
package/dist/roles.js CHANGED
@@ -1,97 +1,87 @@
1
1
  /**
2
2
  * Role constants and utilities for AAstar SDK
3
- * @remarks
4
- * All role hashes and configurations match exactly with Registry.sol v3.0.0
5
- *
6
- * **Source**: /contracts/src/core/Registry.sol
3
+ * @dev All role hashes and configurations match exactly with Registry.sol v3.0.0
4
+ * @source /contracts/src/core/Registry.sol
7
5
  */
8
6
  import { keccak256, toHex } from 'viem';
9
7
  // ========== Role Hash Constants (from Registry.sol lines 32-38) ==========
10
8
  /**
11
9
  * Default Admin Role (OpenZeppelin AccessControl)
12
- * @remarks
13
- * - **Description**: Highest privilege, can grant/revoke all roles
14
- * - **Permission**: Protocol governance only
15
- * - **Source**: OpenZeppelin AccessControl DEFAULT_ADMIN_ROLE
10
+ * @description Highest privilege, can grant/revoke all roles
11
+ * @permission Protocol governance only
12
+ * @source OpenZeppelin AccessControl DEFAULT_ADMIN_ROLE
16
13
  */
17
14
  export const DEFAULT_ADMIN_ROLE = '0x0000000000000000000000000000000000000000000000000000000000000000';
18
15
  /**
19
16
  * Community Role
20
- * @remarks
21
- * - **Description**: Community administrator, can issue xPNTs, configure SBT rules
22
- * - **Permission**: Community-level governance
23
- * - **Requirement**: minStake: 30 GT, entryBurn: 3 GT (line 99)
24
- * - **Exit Fee**: 5% (500 basis points), min 1 GT
25
- * - **Lock Duration**: 30 days
26
- * - **Source**: Registry.sol line 32: ROLE_COMMUNITY = keccak256("COMMUNITY")
17
+ * @description Community administrator, can issue xPNTs, configure SBT rules
18
+ * @permission Community-level governance
19
+ * @requirement minStake: 30 GT, entryBurn: 3 GT (line 99)
20
+ * @exitFee 5% (500 basis points), min 1 GT
21
+ * @lockDuration 30 days
22
+ * @source Registry.sol line 32: ROLE_COMMUNITY = keccak256("COMMUNITY")
27
23
  */
28
24
  export const ROLE_COMMUNITY = keccak256(toHex('COMMUNITY'));
29
25
  /**
30
26
  * End User Role
31
- * @remarks
32
- * - **Description**: Community member, can participate and use gasless transactions
33
- * - **Permission**: Basic user level
34
- * - **Requirement**: minStake: 0.3 GT, entryBurn: 0.05 GT (line 100)
35
- * - **Additional Requirement**: Must hold MySBT from community
36
- * - **Exit Fee**: 10% (1000 basis points), min 0.05 GT
37
- * - **Lock Duration**: 7 days
38
- * - **Source**: Registry.sol line 33: ROLE_ENDUSER = keccak256("ENDUSER")
27
+ * @description Community member, can participate and use gasless transactions
28
+ * @permission Basic user level
29
+ * @requirement minStake: 0.3 GT, entryBurn: 0.05 GT (line 100)
30
+ * @additionalRequirement Must hold MySBT from community
31
+ * @exitFee 10% (1000 basis points), min 0.05 GT
32
+ * @lockDuration 7 days
33
+ * @source Registry.sol line 33: ROLE_ENDUSER = keccak256("ENDUSER")
39
34
  */
40
35
  export const ROLE_ENDUSER = keccak256(toHex('ENDUSER'));
41
36
  /**
42
37
  * Paymaster AOA Role (Account Ownership Authentication)
43
- * @remarks
44
- * - **Description**: Basic Paymaster node operator with account-based auth
45
- * - **Permission**: Infrastructure operator
46
- * - **Requirement**: minStake: 30 GT, entryBurn: 3 GT (line 92)
47
- * - **Exit Fee**: 10% (1000 basis points), min 1 GT
48
- * - **Lock Duration**: 30 days
49
- * - **Source**: Registry.sol line 34: ROLE_PAYMASTER_AOA = keccak256("PAYMASTER_AOA")
38
+ * @description Basic Paymaster node operator with account-based auth
39
+ * @permission Infrastructure operator
40
+ * @requirement minStake: 30 GT, entryBurn: 3 GT (line 92)
41
+ * @exitFee 10% (1000 basis points), min 1 GT
42
+ * @lockDuration 30 days
43
+ * @source Registry.sol line 34: ROLE_PAYMASTER_AOA = keccak256("PAYMASTER_AOA")
50
44
  */
51
45
  export const ROLE_PAYMASTER_AOA = keccak256(toHex('PAYMASTER_AOA'));
52
46
  /**
53
47
  * Paymaster Super Role
54
- * @remarks
55
- * - **Description**: Advanced Paymaster operator, can use SuperPaymaster with aPNTs collateral
56
- * - **Permission**: Infrastructure operator (higher tier)
57
- * - **Requirement**: minStake: 50 GT, entryBurn: 5 GT (line 93)
58
- * - **Additional Requirement**: aPNTs collateral in SuperPaymaster contract
59
- * - **Exit Fee**: 10% (1000 basis points), min 2 GT
60
- * - **Lock Duration**: 30 days
61
- * - **Source**: Registry.sol line 35: ROLE_PAYMASTER_SUPER = keccak256("PAYMASTER_SUPER")
48
+ * @description Advanced Paymaster operator, can use SuperPaymaster with aPNTs collateral
49
+ * @permission Infrastructure operator (higher tier)
50
+ * @requirement minStake: 50 GT, entryBurn: 5 GT (line 93)
51
+ * @additionalRequirement aPNTs collateral in SuperPaymaster contract
52
+ * @exitFee 10% (1000 basis points), min 2 GT
53
+ * @lockDuration 30 days
54
+ * @source Registry.sol line 35: ROLE_PAYMASTER_SUPER = keccak256("PAYMASTER_SUPER")
62
55
  */
63
56
  export const ROLE_PAYMASTER_SUPER = keccak256(toHex('PAYMASTER_SUPER'));
64
57
  /**
65
58
  * DVT Role (Distributed Validator Technology)
66
- * @remarks
67
- * - **Description**: DVT node operator for consensus validation
68
- * - **Permission**: Infrastructure operator
69
- * - **Requirement**: minStake: 30 GT, entryBurn: 3 GT (line 94)
70
- * - **Exit Fee**: 10% (1000 basis points), min 1 GT
71
- * - **Lock Duration**: 30 days
72
- * - **Source**: Registry.sol line 36: ROLE_DVT = keccak256("DVT")
59
+ * @description DVT node operator for consensus validation
60
+ * @permission Infrastructure operator
61
+ * @requirement minStake: 30 GT, entryBurn: 3 GT (line 94)
62
+ * @exitFee 10% (1000 basis points), min 1 GT
63
+ * @lockDuration 30 days
64
+ * @source Registry.sol line 36: ROLE_DVT = keccak256("DVT")
73
65
  */
74
66
  export const ROLE_DVT = keccak256(toHex('DVT'));
75
67
  /**
76
68
  * ANODE Role (Anonymous Node)
77
- * @remarks
78
- * - **Description**: Anonymous infrastructure node operator
79
- * - **Permission**: Infrastructure operator
80
- * - **Requirement**: minStake: 20 GT, entryBurn: 2 GT (line 95)
81
- * - **Exit Fee**: 10% (1000 basis points), min 1 GT
82
- * - **Lock Duration**: 30 days
83
- * - **Source**: Registry.sol line 37: ROLE_ANODE = keccak256("ANODE")
69
+ * @description Anonymous infrastructure node operator
70
+ * @permission Infrastructure operator
71
+ * @requirement minStake: 20 GT, entryBurn: 2 GT (line 95)
72
+ * @exitFee 10% (1000 basis points), min 1 GT
73
+ * @lockDuration 30 days
74
+ * @source Registry.sol line 37: ROLE_ANODE = keccak256("ANODE")
84
75
  */
85
76
  export const ROLE_ANODE = keccak256(toHex('ANODE'));
86
77
  /**
87
78
  * KMS Role (Key Management Service)
88
- * @remarks
89
- * - **Description**: KMS operator for secure key storage and management
90
- * - **Permission**: Infrastructure operator (highest stake)
91
- * - **Requirement**: minStake: 100 GT, entryBurn: 10 GT (line 98)
92
- * - **Exit Fee**: 10% (1000 basis points), min 5 GT
93
- * - **Lock Duration**: 30 days
94
- * - **Source**: Registry.sol line 38: ROLE_KMS = keccak256("KMS")
79
+ * @description KMS operator for secure key storage and management
80
+ * @permission Infrastructure operator (highest stake)
81
+ * @requirement minStake: 100 GT, entryBurn: 10 GT (line 98)
82
+ * @exitFee 10% (1000 basis points), min 5 GT
83
+ * @lockDuration 30 days
84
+ * @source Registry.sol line 38: ROLE_KMS = keccak256("KMS")
95
85
  */
96
86
  export const ROLE_KMS = keccak256(toHex('KMS'));
97
87
  // ========== Role Name Mapping ==========
@@ -134,8 +124,7 @@ export const ROLE_PERMISSION_LEVELS = {
134
124
  };
135
125
  /**
136
126
  * Exact stake requirements from Registry.sol constructor (lines 92-100)
137
- * @remarks
138
- * **Warning**: These are initial values, always query contract for current configuration
127
+ * @warning These are initial values, always query contract for current configuration
139
128
  */
140
129
  export const INITIAL_ROLE_STAKES = {
141
130
  [ROLE_PAYMASTER_AOA]: {