@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.
- package/LICENSE +21 -0
- package/dist/abis/BLSAggregator.json +686 -0
- package/dist/abis/BLSValidator.json +42 -0
- package/dist/abis/DVTValidator.json +368 -0
- package/dist/abis/Eip7702Support.json +24 -0
- package/dist/abis/EntryPoint.json +1382 -0
- package/dist/abis/GToken.json +513 -0
- package/dist/abis/GTokenStaking.json +949 -0
- package/dist/abis/LegacyAccount.json +625 -0
- package/dist/abis/MySBT.json +1518 -0
- package/dist/abis/Paymaster.json +1143 -0
- package/dist/abis/PaymasterFactory.json +640 -0
- package/dist/abis/Registry.json +1942 -0
- package/dist/abis/ReputationSystem.json +699 -0
- package/dist/abis/SenderCreator.json +99 -0
- package/dist/abis/Simple7702Account.json +395 -0
- package/dist/abis/SimpleAccount.json +560 -0
- package/dist/abis/SimpleAccountFactory.json +111 -0
- package/dist/abis/SimpleAccountFactoryV08.json +87 -0
- package/dist/abis/SimpleAccountV08.json +557 -0
- package/dist/abis/SuperPaymaster.json +1781 -0
- package/dist/abis/UserOperationLib.json +57 -0
- package/dist/abis/abi.config.json +24 -0
- package/dist/abis/index.d.ts +1126 -0
- package/dist/abis/index.js +91 -0
- package/dist/abis/xPNTsFactory.json +718 -0
- package/dist/abis/xPNTsToken.json +1280 -0
- package/dist/actions/StateValidator.d.ts +68 -0
- package/dist/actions/StateValidator.js +187 -0
- package/dist/actions/StateValidator.test.d.ts +1 -0
- package/dist/actions/StateValidator.test.js +144 -0
- package/dist/actions/account.d.ts +55 -0
- package/dist/actions/account.js +133 -0
- package/dist/actions/account.test.d.ts +1 -0
- package/dist/actions/account.test.js +118 -0
- package/dist/actions/aggregator.d.ts +17 -0
- package/dist/actions/aggregator.js +31 -0
- package/dist/actions/aggregator.test.d.ts +1 -0
- package/dist/actions/aggregator.test.js +67 -0
- package/dist/actions/dvt.d.ts +30 -0
- package/dist/actions/dvt.js +41 -0
- package/dist/actions/dvt.test.d.ts +1 -0
- package/dist/actions/dvt.test.js +98 -0
- package/dist/actions/entryPoint.d.ts +90 -0
- package/dist/actions/entryPoint.js +211 -0
- package/dist/actions/entryPoint.test.d.ts +1 -0
- package/dist/actions/entryPoint.test.js +139 -0
- package/dist/actions/factory.d.ts +215 -0
- package/dist/actions/factory.js +442 -0
- package/dist/actions/factory.test.d.ts +1 -0
- package/dist/actions/factory.test.js +197 -0
- package/dist/actions/faucet.d.ts +48 -0
- package/dist/actions/faucet.js +337 -0
- package/dist/actions/faucet.test.d.ts +1 -0
- package/dist/actions/faucet.test.js +120 -0
- package/dist/actions/gtokenExtended.d.ts +39 -0
- package/dist/actions/gtokenExtended.js +115 -0
- package/dist/actions/gtokenExtended.test.d.ts +1 -0
- package/dist/actions/gtokenExtended.test.js +118 -0
- package/dist/actions/index.d.ts +15 -0
- package/dist/actions/index.js +17 -0
- package/dist/actions/paymasterV4.d.ts +170 -0
- package/dist/actions/paymasterV4.js +334 -0
- package/dist/actions/paymasterV4.test.d.ts +1 -0
- package/dist/actions/paymasterV4.test.js +159 -0
- package/dist/actions/registry.d.ts +246 -0
- package/dist/actions/registry.js +667 -0
- package/dist/actions/registry.test.d.ts +1 -0
- package/dist/actions/registry.test.js +360 -0
- package/dist/actions/reputation.d.ts +129 -0
- package/dist/actions/reputation.js +281 -0
- package/dist/actions/reputation.test.d.ts +1 -0
- package/dist/actions/reputation.test.js +169 -0
- package/dist/actions/sbt.d.ts +191 -0
- package/dist/actions/sbt.js +533 -0
- package/dist/actions/sbt.test.d.ts +1 -0
- package/dist/actions/sbt.test.js +256 -0
- package/dist/actions/staking.d.ts +132 -0
- package/dist/actions/staking.js +330 -0
- package/dist/actions/staking.test.d.ts +1 -0
- package/dist/actions/staking.test.js +223 -0
- package/dist/actions/superPaymaster.d.ts +237 -0
- package/dist/actions/superPaymaster.js +644 -0
- package/dist/actions/superPaymaster.test.d.ts +1 -0
- package/dist/actions/superPaymaster.test.js +287 -0
- package/dist/actions/tokens.d.ts +229 -0
- package/dist/actions/tokens.js +415 -0
- package/dist/actions/tokens.test.d.ts +1 -0
- package/dist/actions/tokens.test.js +53 -0
- package/dist/actions/validators.d.ts +194 -0
- package/dist/actions/validators.js +433 -0
- package/dist/actions/validators.test.d.ts +1 -0
- package/dist/actions/validators.test.js +215 -0
- package/dist/branding.d.ts +30 -0
- package/dist/branding.js +30 -0
- package/dist/clients/BaseClient.d.ts +25 -0
- package/dist/clients/BaseClient.js +66 -0
- package/dist/clients/types.d.ts +60 -0
- package/dist/clients/types.js +1 -0
- package/dist/clients.d.ts +5 -0
- package/dist/clients.js +11 -0
- package/dist/communities.d.ts +52 -0
- package/dist/communities.js +73 -0
- package/dist/config/ContractConfigManager.d.ts +20 -0
- package/dist/config/ContractConfigManager.js +48 -0
- package/dist/constants.d.ts +88 -0
- package/dist/constants.js +125 -0
- package/dist/contract-addresses.d.ts +110 -0
- package/dist/contract-addresses.js +99 -0
- package/dist/contracts.d.ts +424 -0
- package/dist/contracts.js +343 -0
- package/dist/contracts.test.d.ts +1 -0
- package/dist/contracts.test.js +40 -0
- package/dist/crypto/blsSigner.d.ts +64 -0
- package/dist/crypto/blsSigner.js +98 -0
- package/dist/crypto/index.d.ts +1 -0
- package/dist/crypto/index.js +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +21 -0
- package/dist/networks.d.ts +127 -0
- package/dist/networks.js +118 -0
- package/dist/requirementChecker.d.ts +38 -0
- package/dist/requirementChecker.js +139 -0
- package/dist/requirementChecker.test.d.ts +1 -0
- package/dist/requirementChecker.test.js +60 -0
- package/dist/roles.d.ts +204 -0
- package/dist/roles.js +211 -0
- package/dist/roles.test.d.ts +1 -0
- package/dist/roles.test.js +23 -0
- package/dist/utils/validation.d.ts +24 -0
- package/dist/utils/validation.js +56 -0
- package/dist/utils/validation.test.d.ts +1 -0
- package/dist/utils/validation.test.js +40 -0
- package/dist/utils.d.ts +12 -0
- package/dist/utils.js +14 -0
- package/package.json +33 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AAstar Smart Contract Addresses
|
|
3
|
+
*
|
|
4
|
+
* IMPORTANT: Contract addresses are defined in contract-addresses.ts
|
|
5
|
+
* This file imports and uses those addresses to maintain a single source of truth.
|
|
6
|
+
*
|
|
7
|
+
* For detailed version information (VERSION, VERSION_CODE, features),
|
|
8
|
+
* see contract-versions.ts
|
|
9
|
+
*/
|
|
10
|
+
import { CORE_ADDRESSES, TOKEN_ADDRESSES, TEST_TOKEN_ADDRESSES, TEST_ACCOUNT_ADDRESSES, PAYMASTER_ADDRESSES, MONITORING_ADDRESSES, OFFICIAL_ADDRESSES, COMMUNITY_OWNERS, } from './contract-addresses.js';
|
|
11
|
+
/**
|
|
12
|
+
* Sepolia Testnet Contracts
|
|
13
|
+
*/
|
|
14
|
+
export const SEPOLIA_CONTRACTS = {
|
|
15
|
+
// ========================================
|
|
16
|
+
// Core System (AOA+ Mode)
|
|
17
|
+
// ========================================
|
|
18
|
+
core: CORE_ADDRESSES,
|
|
19
|
+
// ========================================
|
|
20
|
+
// Token System
|
|
21
|
+
// ========================================
|
|
22
|
+
tokens: TOKEN_ADDRESSES,
|
|
23
|
+
// ========================================
|
|
24
|
+
// Test Tokens (For Development & Testing)
|
|
25
|
+
// ========================================
|
|
26
|
+
testTokens: TEST_TOKEN_ADDRESSES,
|
|
27
|
+
// ========================================
|
|
28
|
+
// Test Accounts (For Development & Testing)
|
|
29
|
+
// ========================================
|
|
30
|
+
testAccounts: TEST_ACCOUNT_ADDRESSES,
|
|
31
|
+
// ========================================
|
|
32
|
+
// Paymaster V4_1 (AOA Mode - Independent Paymaster)
|
|
33
|
+
// ========================================
|
|
34
|
+
paymaster: PAYMASTER_ADDRESSES,
|
|
35
|
+
// ========================================
|
|
36
|
+
// DVT/BLS Monitoring System
|
|
37
|
+
// ========================================
|
|
38
|
+
monitoring: MONITORING_ADDRESSES,
|
|
39
|
+
// ========================================
|
|
40
|
+
// Official Dependencies
|
|
41
|
+
// ========================================
|
|
42
|
+
official: OFFICIAL_ADDRESSES,
|
|
43
|
+
// ========================================
|
|
44
|
+
// Test Communities (For Development & Testing)
|
|
45
|
+
// ========================================
|
|
46
|
+
communities: {
|
|
47
|
+
/** AAStar Community - Test community for development (registered: 2025-11-01) */
|
|
48
|
+
aastar: {
|
|
49
|
+
owner: COMMUNITY_OWNERS.aastarOwner,
|
|
50
|
+
gasToken: TEST_TOKEN_ADDRESSES.apnts,
|
|
51
|
+
ensName: 'aastar.eth',
|
|
52
|
+
name: 'AAStar',
|
|
53
|
+
stake: '50', // 50 GToken staked in Registry
|
|
54
|
+
},
|
|
55
|
+
/** BreadCommunity - Test community for development (registered: 2025-11-03) */
|
|
56
|
+
breadCommunity: {
|
|
57
|
+
owner: COMMUNITY_OWNERS.breadCommunityOwner,
|
|
58
|
+
gasToken: TEST_TOKEN_ADDRESSES.bpnts,
|
|
59
|
+
ensName: 'bread.eth',
|
|
60
|
+
name: 'BreadCommunity',
|
|
61
|
+
stake: '50', // 50 GToken staked in Registry
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* All supported networks
|
|
67
|
+
*/
|
|
68
|
+
export const CONTRACTS = {
|
|
69
|
+
sepolia: SEPOLIA_CONTRACTS,
|
|
70
|
+
// Future networks can be added here:
|
|
71
|
+
// optimism: OPTIMISM_CONTRACTS,
|
|
72
|
+
// mainnet: MAINNET_CONTRACTS,
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Get all contracts for a specific network
|
|
76
|
+
*
|
|
77
|
+
* @param network - Network name (e.g., 'sepolia')
|
|
78
|
+
* @returns All contract addresses for the network
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* const contracts = getContracts('sepolia');
|
|
83
|
+
* console.log(contracts.core.superPaymaster);
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export function getContracts(network) {
|
|
87
|
+
const contracts = CONTRACTS[network];
|
|
88
|
+
if (!contracts) {
|
|
89
|
+
throw new Error(`Network '${network}' is not supported`);
|
|
90
|
+
}
|
|
91
|
+
return contracts;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get a specific contract address
|
|
95
|
+
*
|
|
96
|
+
* @param network - Network name
|
|
97
|
+
* @param category - Contract category
|
|
98
|
+
* @param name - Contract name
|
|
99
|
+
* @returns Contract address
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* const address = getContract('sepolia', 'core', 'superPaymaster');
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export function getContract(network, category, name) {
|
|
107
|
+
const contracts = getContracts(network);
|
|
108
|
+
const categoryContracts = contracts[category];
|
|
109
|
+
if (!categoryContracts) {
|
|
110
|
+
throw new Error(`Category '${category}' not found in network '${network}'`);
|
|
111
|
+
}
|
|
112
|
+
const address = categoryContracts[name];
|
|
113
|
+
if (!address) {
|
|
114
|
+
throw new Error(`Contract '${name}' not found in category '${category}' for network '${network}'`);
|
|
115
|
+
}
|
|
116
|
+
return address;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get core system contracts
|
|
120
|
+
*
|
|
121
|
+
* @param network - Network name
|
|
122
|
+
* @returns Core contract addresses
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```ts
|
|
126
|
+
* const core = getCoreContracts('sepolia');
|
|
127
|
+
* console.log(core.superPaymaster);
|
|
128
|
+
* console.log(core.registry);
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
export function getCoreContracts(network) {
|
|
132
|
+
return getContracts(network).core;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Get token system contracts
|
|
136
|
+
*
|
|
137
|
+
* @param network - Network name
|
|
138
|
+
* @returns Token contract addresses
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* const tokens = getTokenContracts('sepolia');
|
|
143
|
+
* console.log(tokens.xPNTsFactory);
|
|
144
|
+
* console.log(tokens.mySBT);
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
export function getTokenContracts(network) {
|
|
148
|
+
return getContracts(network).tokens;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Get test token contracts (for development & testing)
|
|
152
|
+
*
|
|
153
|
+
* @param network - Network name
|
|
154
|
+
* @returns Test token contract addresses
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```ts
|
|
158
|
+
* const testTokens = getTestTokenContracts('sepolia');
|
|
159
|
+
* console.log(testTokens.mockUSDT);
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
export function getTestTokenContracts(network) {
|
|
163
|
+
return getContracts(network).testTokens;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Get PaymasterV4_1 address (AOA mode)
|
|
167
|
+
*
|
|
168
|
+
* @param network - Network name
|
|
169
|
+
* @returns PaymasterV4_1 address
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```ts
|
|
173
|
+
* const paymaster = getPaymasterV4_1('sepolia');
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
export function getPaymasterV4_1(network) {
|
|
177
|
+
return getContracts(network).paymaster.paymasterV4_1;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Get test account contracts (SimpleAccountFactory, etc.)
|
|
181
|
+
*
|
|
182
|
+
* @param network - Network name
|
|
183
|
+
* @returns Test account contract addresses
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```ts
|
|
187
|
+
* const testAccounts = getTestAccounts('sepolia');
|
|
188
|
+
* console.log(testAccounts.simpleAccountFactory);
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
export function getTestAccounts(network) {
|
|
192
|
+
return getContracts(network).testAccounts;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Get SimpleAccountFactory address
|
|
196
|
+
*
|
|
197
|
+
* @param network - Network name
|
|
198
|
+
* @returns SimpleAccountFactory address
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```ts
|
|
202
|
+
* const factory = getSimpleAccountFactory('sepolia');
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
export function getSimpleAccountFactory(network) {
|
|
206
|
+
return getContracts(network).testAccounts.simpleAccountFactory;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Get SuperPaymaster V2 address (AOA+ mode)
|
|
210
|
+
*
|
|
211
|
+
* @param network - Network name
|
|
212
|
+
* @returns SuperPaymaster V2 address
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```ts
|
|
216
|
+
* const superPaymaster = getSuperPaymasterV2('sepolia');
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
export function getSuperPaymasterV2(network) {
|
|
220
|
+
return getContracts(network).core.superPaymaster;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Get EntryPoint v0.7 address
|
|
224
|
+
*
|
|
225
|
+
* @param network - Network name
|
|
226
|
+
* @returns EntryPoint address
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* ```ts
|
|
230
|
+
* const entryPoint = getEntryPoint('sepolia');
|
|
231
|
+
* ```
|
|
232
|
+
*/
|
|
233
|
+
export function getEntryPoint(network) {
|
|
234
|
+
return getContracts(network).official.entryPoint;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Check if a network is supported for contracts
|
|
238
|
+
*
|
|
239
|
+
* @param network - Network name to check
|
|
240
|
+
* @returns True if network is supported
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* ```ts
|
|
244
|
+
* if (isContractNetworkSupported('sepolia')) {
|
|
245
|
+
* const contracts = getContracts('sepolia');
|
|
246
|
+
* }
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
export function isContractNetworkSupported(network) {
|
|
250
|
+
return network in CONTRACTS;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Get all supported contract network names
|
|
254
|
+
*
|
|
255
|
+
* @returns Array of supported network names
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* ```ts
|
|
259
|
+
* const networks = getContractNetworks();
|
|
260
|
+
* // ['sepolia']
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
export function getContractNetworks() {
|
|
264
|
+
return Object.keys(CONTRACTS);
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Contract deployment metadata
|
|
268
|
+
*/
|
|
269
|
+
export const CONTRACT_METADATA = {
|
|
270
|
+
sepolia: {
|
|
271
|
+
lastUpdated: '2025-11-02',
|
|
272
|
+
networkId: 11155111,
|
|
273
|
+
deploymentDates: {
|
|
274
|
+
// Core System
|
|
275
|
+
gToken: '2025-11-01', // v2.0.0 with VERSION interface
|
|
276
|
+
superPaymaster: '2025-11-01', // v2.0.0 with VERSION interface
|
|
277
|
+
registry: '2025-11-02', // v2.1.4 with allowPermissionlessMint default true
|
|
278
|
+
gTokenStaking: '2025-11-01', // v2.0.0 with VERSION interface
|
|
279
|
+
// Tokens
|
|
280
|
+
xPNTsFactory: '2025-11-01', // v2.0.0 with VERSION interface
|
|
281
|
+
mySBT: '2025-11-01', // v2.4.0 with VERSION interface + NFT refactor
|
|
282
|
+
// Paymaster
|
|
283
|
+
paymasterV4_1: '2025-10-15',
|
|
284
|
+
// Tokens
|
|
285
|
+
aPNTs: '2025-10-30',
|
|
286
|
+
// Factories
|
|
287
|
+
paymasterFactory: '2025-11-01', // v1.0.0
|
|
288
|
+
// Monitoring
|
|
289
|
+
dvtValidator: '2025-11-01', // v2.0.0 with VERSION interface
|
|
290
|
+
blsAggregator: '2025-11-01', // v2.0.0 with VERSION interface
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
};
|
|
294
|
+
/**
|
|
295
|
+
* Get contract deployment date
|
|
296
|
+
*
|
|
297
|
+
* @param network - Network name
|
|
298
|
+
* @param contractName - Contract name
|
|
299
|
+
* @returns Deployment date string (YYYY-MM-DD)
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```ts
|
|
303
|
+
* const date = getDeploymentDate('sepolia', 'superPaymaster');
|
|
304
|
+
* // '2025-10-25'
|
|
305
|
+
* ```
|
|
306
|
+
*/
|
|
307
|
+
export function getDeploymentDate(network, contractName) {
|
|
308
|
+
const metadata = CONTRACT_METADATA[network];
|
|
309
|
+
if (!metadata)
|
|
310
|
+
return undefined;
|
|
311
|
+
return metadata.deploymentDates[contractName];
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Get registered communities
|
|
315
|
+
*
|
|
316
|
+
* @param network - Network name
|
|
317
|
+
* @returns Communities object
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* ```ts
|
|
321
|
+
* const communities = getCommunities('sepolia');
|
|
322
|
+
* console.log(communities.aastar.owner);
|
|
323
|
+
* ```
|
|
324
|
+
*/
|
|
325
|
+
export function getCommunities(network) {
|
|
326
|
+
return getContracts(network).communities;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Get a specific community
|
|
330
|
+
*
|
|
331
|
+
* @param network - Network name
|
|
332
|
+
* @param communityName - Community name (aastar, builderDao)
|
|
333
|
+
* @returns Community information
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* ```ts
|
|
337
|
+
* const aastar = getCommunity('sepolia', 'aastar');
|
|
338
|
+
* console.log(aastar.gasToken); // aPNTs address
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
341
|
+
export function getCommunity(network, communityName) {
|
|
342
|
+
return getCommunities(network)[communityName];
|
|
343
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { getContracts, getContract, getCoreContracts, getTokenContracts, getEntryPoint, isContractNetworkSupported, getContractNetworks, getDeploymentDate } from './contracts.js';
|
|
3
|
+
describe('Contracts', () => {
|
|
4
|
+
it('should get contracts for sepolia', () => {
|
|
5
|
+
const contracts = getContracts('sepolia');
|
|
6
|
+
expect(contracts.core.registry).toBeDefined();
|
|
7
|
+
});
|
|
8
|
+
it('should throw for unsupported network', () => {
|
|
9
|
+
expect(() => getContracts('mainnet')).toThrow('not supported');
|
|
10
|
+
});
|
|
11
|
+
it('should get a specific contract', () => {
|
|
12
|
+
const addr = getContract('sepolia', 'official', 'entryPoint');
|
|
13
|
+
expect(addr).toBeDefined();
|
|
14
|
+
expect(addr.startsWith('0x')).toBe(true);
|
|
15
|
+
});
|
|
16
|
+
it('should throw for invalid category or contract', () => {
|
|
17
|
+
expect(() => getContract('sepolia', 'invalid', 'entryPoint')).toThrow('Category');
|
|
18
|
+
expect(() => getContract('sepolia', 'official', 'invalid')).toThrow('Contract');
|
|
19
|
+
});
|
|
20
|
+
it('should get core and token contracts', () => {
|
|
21
|
+
expect(getCoreContracts('sepolia').registry).toBeDefined();
|
|
22
|
+
expect(getTokenContracts('sepolia').xPNTsFactory).toBeDefined();
|
|
23
|
+
});
|
|
24
|
+
it('should get entry point', () => {
|
|
25
|
+
expect(getEntryPoint('sepolia')).toBeDefined();
|
|
26
|
+
});
|
|
27
|
+
it('should check network support', () => {
|
|
28
|
+
expect(isContractNetworkSupported('sepolia')).toBe(true);
|
|
29
|
+
expect(isContractNetworkSupported('mainnet')).toBe(false);
|
|
30
|
+
});
|
|
31
|
+
it('should list contract networks', () => {
|
|
32
|
+
const networks = getContractNetworks();
|
|
33
|
+
expect(networks).toContain('sepolia');
|
|
34
|
+
});
|
|
35
|
+
it('should get deployment date', () => {
|
|
36
|
+
const date = getDeploymentDate('sepolia', 'registry');
|
|
37
|
+
expect(date).toBeDefined();
|
|
38
|
+
expect(date).toMatch(/^\d{4}-\d{2}-\d{2}$/);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type Hex } from 'viem';
|
|
2
|
+
/**
|
|
3
|
+
* BLS Signer for Registry reputation updates and DVT operations
|
|
4
|
+
*
|
|
5
|
+
* Uses BLS12-381 curve for signature aggregation
|
|
6
|
+
*/
|
|
7
|
+
export declare class BLSSigner {
|
|
8
|
+
private privateKey;
|
|
9
|
+
constructor(privateKeyHex: Hex);
|
|
10
|
+
/**
|
|
11
|
+
* Sign a message with BLS private key
|
|
12
|
+
* @param message Message hash to sign
|
|
13
|
+
* @returns BLS signature as hex string
|
|
14
|
+
*/
|
|
15
|
+
sign(message: Hex): Hex;
|
|
16
|
+
/**
|
|
17
|
+
* Get BLS public key
|
|
18
|
+
* @returns Public key as hex string
|
|
19
|
+
*/
|
|
20
|
+
getPublicKey(): Hex;
|
|
21
|
+
/**
|
|
22
|
+
* Aggregate multiple BLS signatures
|
|
23
|
+
* @param signatures Array of BLS signatures
|
|
24
|
+
* @returns Aggregated signature
|
|
25
|
+
*/
|
|
26
|
+
static aggregateSignatures(signatures: Hex[]): Hex;
|
|
27
|
+
/**
|
|
28
|
+
* Aggregate multiple BLS public keys
|
|
29
|
+
* @param pubKeys Array of BLS public keys
|
|
30
|
+
* @returns Aggregated public key (uncompressed G1 - 96 bytes for EVM)
|
|
31
|
+
*/
|
|
32
|
+
static aggregatePublicKeys(pubKeys: Hex[]): Hex;
|
|
33
|
+
/**
|
|
34
|
+
* Verify a BLS signature
|
|
35
|
+
* @param message Message hash
|
|
36
|
+
* @param signature BLS signature
|
|
37
|
+
* @param publicKey BLS public key
|
|
38
|
+
* @returns True if signature is valid
|
|
39
|
+
*/
|
|
40
|
+
static verify(message: Hex, signature: Hex, publicKey: Hex): boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Helper functions for creating BLS proofs for Registry and BLSAggregator operations
|
|
44
|
+
*/
|
|
45
|
+
export declare const BLSHelpers: {
|
|
46
|
+
/**
|
|
47
|
+
* Create message hash for slash proposal
|
|
48
|
+
*/
|
|
49
|
+
createSlashProposalMessage(proposalId: bigint): Hex;
|
|
50
|
+
/**
|
|
51
|
+
* Create message hash for reputation update
|
|
52
|
+
*/
|
|
53
|
+
createReputationUpdateMessage(users: Hex[], scores: bigint[], epoch: bigint): Hex;
|
|
54
|
+
/**
|
|
55
|
+
* Encode BLS proof for Registry/Aggregator (v3 format)
|
|
56
|
+
* Proof structure: (bytes pkG1, bytes sigG2, bytes msgG2, uint256 signerMask)
|
|
57
|
+
*/
|
|
58
|
+
encodeBLSProof(aggregatedPublicKey: Hex, aggregatedSignature: Hex, messageMappingG2: Hex, signerMask: bigint): Hex;
|
|
59
|
+
/**
|
|
60
|
+
* Encode Reputation Proof (for test compatibility)
|
|
61
|
+
* Matches format: (signature, publicKey, signerMask)
|
|
62
|
+
*/
|
|
63
|
+
encodeReputationProof(signature: Hex, publicKey: Hex, signerMask: bigint): Hex;
|
|
64
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { bls12_381 as bls } from '@noble/curves/bls12-381';
|
|
2
|
+
import { toBytes, keccak256, encodePacked, encodeAbiParameters, parseAbiParameters } from 'viem';
|
|
3
|
+
/**
|
|
4
|
+
* BLS Signer for Registry reputation updates and DVT operations
|
|
5
|
+
*
|
|
6
|
+
* Uses BLS12-381 curve for signature aggregation
|
|
7
|
+
*/
|
|
8
|
+
export class BLSSigner {
|
|
9
|
+
privateKey;
|
|
10
|
+
constructor(privateKeyHex) {
|
|
11
|
+
this.privateKey = toBytes(privateKeyHex);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Sign a message with BLS private key
|
|
15
|
+
* @param message Message hash to sign
|
|
16
|
+
* @returns BLS signature as hex string
|
|
17
|
+
*/
|
|
18
|
+
sign(message) {
|
|
19
|
+
const messageBytes = toBytes(message);
|
|
20
|
+
const signature = bls.sign(messageBytes, this.privateKey);
|
|
21
|
+
return `0x${Buffer.from(signature).toString('hex')}`;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get BLS public key
|
|
25
|
+
* @returns Public key as hex string
|
|
26
|
+
*/
|
|
27
|
+
getPublicKey() {
|
|
28
|
+
const pubKey = bls.getPublicKey(this.privateKey);
|
|
29
|
+
return `0x${Buffer.from(pubKey).toString('hex')}`;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Aggregate multiple BLS signatures
|
|
33
|
+
* @param signatures Array of BLS signatures
|
|
34
|
+
* @returns Aggregated signature
|
|
35
|
+
*/
|
|
36
|
+
static aggregateSignatures(signatures) {
|
|
37
|
+
const sigBytes = signatures.map(sig => toBytes(sig));
|
|
38
|
+
const aggregated = bls.aggregateSignatures(sigBytes);
|
|
39
|
+
return `0x${Buffer.from(aggregated).toString('hex')}`;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Aggregate multiple BLS public keys
|
|
43
|
+
* @param pubKeys Array of BLS public keys
|
|
44
|
+
* @returns Aggregated public key (uncompressed G1 - 96 bytes for EVM)
|
|
45
|
+
*/
|
|
46
|
+
static aggregatePublicKeys(pubKeys) {
|
|
47
|
+
const pubKeyBytes = pubKeys.map(pk => toBytes(pk));
|
|
48
|
+
const aggregated = bls.aggregatePublicKeys(pubKeyBytes);
|
|
49
|
+
return `0x${Buffer.from(aggregated).toString('hex')}`;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Verify a BLS signature
|
|
53
|
+
* @param message Message hash
|
|
54
|
+
* @param signature BLS signature
|
|
55
|
+
* @param publicKey BLS public key
|
|
56
|
+
* @returns True if signature is valid
|
|
57
|
+
*/
|
|
58
|
+
static verify(message, signature, publicKey) {
|
|
59
|
+
const messageBytes = toBytes(message);
|
|
60
|
+
const sigBytes = toBytes(signature);
|
|
61
|
+
const pubKeyBytes = toBytes(publicKey);
|
|
62
|
+
return bls.verify(sigBytes, messageBytes, pubKeyBytes);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Helper functions for creating BLS proofs for Registry and BLSAggregator operations
|
|
67
|
+
*/
|
|
68
|
+
export const BLSHelpers = {
|
|
69
|
+
/**
|
|
70
|
+
* Create message hash for slash proposal
|
|
71
|
+
*/
|
|
72
|
+
createSlashProposalMessage(proposalId) {
|
|
73
|
+
return keccak256(encodePacked(['uint256'], [proposalId]));
|
|
74
|
+
},
|
|
75
|
+
/**
|
|
76
|
+
* Create message hash for reputation update
|
|
77
|
+
*/
|
|
78
|
+
createReputationUpdateMessage(users, scores, epoch) {
|
|
79
|
+
return keccak256(encodePacked(['address[]', 'uint256[]', 'uint256'], [users, scores, epoch]));
|
|
80
|
+
},
|
|
81
|
+
/**
|
|
82
|
+
* Encode BLS proof for Registry/Aggregator (v3 format)
|
|
83
|
+
* Proof structure: (bytes pkG1, bytes sigG2, bytes msgG2, uint256 signerMask)
|
|
84
|
+
*/
|
|
85
|
+
encodeBLSProof(aggregatedPublicKey, // G1 (48 bytes compressed or 96 bytes uncompressed)
|
|
86
|
+
aggregatedSignature, // G2 (96 bytes compressed or 192 bytes uncompressed)
|
|
87
|
+
messageMappingG2, // G2 (Mapping of hash to G2 point)
|
|
88
|
+
signerMask) {
|
|
89
|
+
return encodeAbiParameters(parseAbiParameters('bytes, bytes, bytes, uint256'), [aggregatedPublicKey, aggregatedSignature, messageMappingG2, signerMask]);
|
|
90
|
+
},
|
|
91
|
+
/**
|
|
92
|
+
* Encode Reputation Proof (for test compatibility)
|
|
93
|
+
* Matches format: (signature, publicKey, signerMask)
|
|
94
|
+
*/
|
|
95
|
+
encodeReputationProof(signature, publicKey, signerMask) {
|
|
96
|
+
return encodeAbiParameters(parseAbiParameters('bytes signature, bytes publicKey, uint256 signerMask'), [signature, publicKey, signerMask]);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './blsSigner.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './blsSigner.js';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AAStar Shared Configuration Package
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
export * from './branding.js';
|
|
7
|
+
export * from './contract-addresses.js';
|
|
8
|
+
export * from './contracts.js';
|
|
9
|
+
export * from './networks.js';
|
|
10
|
+
export * from './constants.js';
|
|
11
|
+
export * from './communities.js';
|
|
12
|
+
export * from './abis/index.js';
|
|
13
|
+
export * from './clients.js';
|
|
14
|
+
export * from './clients/types.js';
|
|
15
|
+
export * from './clients/BaseClient.js';
|
|
16
|
+
export * from './actions/index.js';
|
|
17
|
+
export * from './crypto/index.js';
|
|
18
|
+
export * from './roles.js';
|
|
19
|
+
export * from './requirementChecker.js';
|
|
20
|
+
export * from './config/ContractConfigManager.js';
|
|
21
|
+
export * from './utils/validation.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AAStar Shared Configuration Package
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
export * from './branding.js';
|
|
7
|
+
export * from './contract-addresses.js'; // Single source of truth for all contract addresses
|
|
8
|
+
export * from './contracts.js';
|
|
9
|
+
export * from './networks.js';
|
|
10
|
+
export * from './constants.js';
|
|
11
|
+
export * from './communities.js'; // Community configurations
|
|
12
|
+
export * from './abis/index.js'; // Assuming abis is a folder with index.ts
|
|
13
|
+
export * from './clients.js';
|
|
14
|
+
export * from './clients/types.js';
|
|
15
|
+
export * from './clients/BaseClient.js';
|
|
16
|
+
export * from './actions/index.js';
|
|
17
|
+
export * from './crypto/index.js';
|
|
18
|
+
export * from './roles.js'; // Role system
|
|
19
|
+
export * from './requirementChecker.js'; // Requirement validation
|
|
20
|
+
export * from './config/ContractConfigManager.js';
|
|
21
|
+
export * from './utils/validation.js';
|