@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,30 @@
1
+ /**
2
+ * AAStar Community Branding Configuration
3
+ */
4
+ export const BRANDING = {
5
+ logo: "https://raw.githubusercontent.com/jhfnetboy/MarkDownImg/main/img/202505031325963.png",
6
+ icon: "https://www.aastar.io/favicon.ico",
7
+ colors: {
8
+ primary: "#FF6B35",
9
+ primaryLight: "#FF8C42",
10
+ secondary: "#4A90E2",
11
+ secondaryDark: "#357ABD",
12
+ success: "#4CAF50",
13
+ warning: "#FFC107",
14
+ error: "#F44336",
15
+ gray50: "#F9FAFB",
16
+ gray100: "#F3F4F6",
17
+ gray700: "#374151",
18
+ gray800: "#1F2937",
19
+ gray900: "#111827",
20
+ },
21
+ };
22
+ export const LINKS = {
23
+ main: "https://aastar.io",
24
+ airAccount: "https://airAccount.aastar.io",
25
+ superPaymaster: "https://superpaymaster.aastar.io",
26
+ demo: "https://aastar.io/demo",
27
+ github: "https://github.com/AAStarCommunity",
28
+ discord: "https://discord.gg/aastar",
29
+ twitter: "https://twitter.com/AAStarCommunity",
30
+ };
@@ -0,0 +1,25 @@
1
+ import { type Address, type PublicClient, type WalletClient, type Chain, type Transport, type Account } from 'viem';
2
+ import { type ClientConfig } from './types.js';
3
+ export declare abstract class BaseClient {
4
+ protected client: WalletClient<Transport, Chain, Account>;
5
+ protected publicClient?: PublicClient;
6
+ protected registryAddress?: Address;
7
+ protected gTokenAddress?: Address;
8
+ protected gTokenStakingAddress?: Address;
9
+ protected paymasterFactoryAddress?: Address;
10
+ protected entryPointAddress?: Address;
11
+ constructor(config: ClientConfig);
12
+ /**
13
+ * Get the account address of the connected wallet
14
+ */
15
+ getAddress(): Address;
16
+ /**
17
+ * Helper to ensure public client exists or fallback to wallet client (if it supports read)
18
+ */
19
+ protected getStartPublicClient(): PublicClient | WalletClient<Transport, Chain, Account>;
20
+ protected requireRegistry(): Address;
21
+ protected requireGToken(): Address;
22
+ protected requireGTokenStaking(): Address;
23
+ protected requirePaymasterFactory(): Address;
24
+ protected requireEntryPoint(): Address;
25
+ }
@@ -0,0 +1,66 @@
1
+ export class BaseClient {
2
+ client;
3
+ publicClient;
4
+ registryAddress;
5
+ gTokenAddress;
6
+ gTokenStakingAddress;
7
+ paymasterFactoryAddress;
8
+ entryPointAddress;
9
+ constructor(config) {
10
+ if (!config.client) {
11
+ throw new Error('WalletClient is required for Business Clients');
12
+ }
13
+ if (!config.client.account) {
14
+ throw new Error('WalletClient must have an account attached');
15
+ }
16
+ this.client = config.client;
17
+ this.publicClient = config.publicClient;
18
+ this.registryAddress = config.registryAddress;
19
+ this.gTokenAddress = config.gTokenAddress;
20
+ this.gTokenStakingAddress = config.gTokenStakingAddress;
21
+ this.paymasterFactoryAddress = config.paymasterFactoryAddress;
22
+ this.entryPointAddress = config.entryPointAddress;
23
+ }
24
+ /**
25
+ * Get the account address of the connected wallet
26
+ */
27
+ getAddress() {
28
+ return this.client.account.address;
29
+ }
30
+ /**
31
+ * Helper to ensure public client exists or fallback to wallet client (if it supports read)
32
+ */
33
+ getStartPublicClient() {
34
+ return this.publicClient || this.client;
35
+ }
36
+ requireRegistry() {
37
+ if (!this.registryAddress) {
38
+ throw new Error('Registry address is not configured for this client');
39
+ }
40
+ return this.registryAddress;
41
+ }
42
+ requireGToken() {
43
+ if (!this.gTokenAddress) {
44
+ throw new Error('GToken address is not configured for this client');
45
+ }
46
+ return this.gTokenAddress;
47
+ }
48
+ requireGTokenStaking() {
49
+ if (!this.gTokenStakingAddress) {
50
+ throw new Error('GTokenStaking address is not configured for this client');
51
+ }
52
+ return this.gTokenStakingAddress;
53
+ }
54
+ requirePaymasterFactory() {
55
+ if (!this.paymasterFactoryAddress) {
56
+ throw new Error('PaymasterFactory address is not configured for this client');
57
+ }
58
+ return this.paymasterFactoryAddress;
59
+ }
60
+ requireEntryPoint() {
61
+ if (!this.entryPointAddress) {
62
+ throw new Error('EntryPoint address is not configured for this client');
63
+ }
64
+ return this.entryPointAddress;
65
+ }
66
+ }
@@ -0,0 +1,60 @@
1
+ import { type Address, type PublicClient, type WalletClient, type Chain, type Transport, type Account } from 'viem';
2
+ /**
3
+ * Base configuration for all L2 Business Clients
4
+ */
5
+ export interface ClientConfig {
6
+ /**
7
+ * Viem WalletClient for write operations.
8
+ * Must have an account attached.
9
+ */
10
+ client: WalletClient<Transport, Chain, Account>;
11
+ /**
12
+ * Optional PublicClient for read operations.
13
+ * If not provided, one will be derived from the WalletClient or created internally if possible (but usually explicit is better).
14
+ * Currently L1 actions use PublicClient | WalletClient, so WalletClient is enough for both if it has a provider.
15
+ * However, explicitly accepting PublicClient encourages separation.
16
+ */
17
+ publicClient?: PublicClient;
18
+ /**
19
+ * Registry contract address.
20
+ * Essential for looking up other contracts if not provided explicitly.
21
+ */
22
+ registryAddress?: Address;
23
+ /**
24
+ * GToken contract address.
25
+ * Required for operations involving token approvals and transfers.
26
+ */
27
+ gTokenAddress?: Address;
28
+ /**
29
+ * GTokenStaking contract address.
30
+ * Required for role registration that involves staking.
31
+ */
32
+ gTokenStakingAddress?: Address;
33
+ /**
34
+ * PaymasterFactory contract address.
35
+ * Required for deploying new PaymasterV4 instances.
36
+ */
37
+ paymasterFactoryAddress?: Address;
38
+ xpntsFactoryAddress?: Address;
39
+ ethUsdPriceFeedAddress?: Address;
40
+ entryPointAddress?: Address;
41
+ }
42
+ /**
43
+ * Common options for transaction methods
44
+ */
45
+ export interface TransactionOptions {
46
+ /**
47
+ * Override the account to use for the transaction.
48
+ * If not provided, uses the account from the WalletClient.
49
+ */
50
+ account?: Account | Address;
51
+ /**
52
+ * Optional value to send with the transaction (in wei)
53
+ */
54
+ value?: bigint;
55
+ }
56
+ /**
57
+ * Generic result wrapper for business operations
58
+ * Currently just returns the type directly, but can be expanded for metadata.
59
+ */
60
+ export type BusinessResult<T> = Promise<T>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import { type Chain, type PublicClient } from 'viem';
2
+ /**
3
+ * Creates a standard AAStar public client for any given chain.
4
+ */
5
+ export declare function createAAStarPublicClient(rpcUrl: string, chain?: Chain): PublicClient;
@@ -0,0 +1,11 @@
1
+ import { createPublicClient, http } from 'viem';
2
+ import { sepolia } from 'viem/chains';
3
+ /**
4
+ * Creates a standard AAStar public client for any given chain.
5
+ */
6
+ export function createAAStarPublicClient(rpcUrl, chain = sepolia) {
7
+ return createPublicClient({
8
+ chain,
9
+ transport: http(rpcUrl)
10
+ });
11
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Community Configurations
3
+ * Registry v2.2.0 deployed on 2025-11-08
4
+ */
5
+ export declare enum NodeType {
6
+ PAYMASTER_AOA = 0,// AOA independent Paymaster
7
+ PAYMASTER_SUPER = 1,// SuperPaymaster v2 shared mode
8
+ ANODE = 2,// Community computation node
9
+ KMS = 3
10
+ }
11
+ export interface CommunityConfig {
12
+ name: string;
13
+ ensName: string;
14
+ address: string;
15
+ xPNTsToken: string;
16
+ supportedSBTs: string[];
17
+ nodeType: NodeType;
18
+ isActive: boolean;
19
+ allowPermissionlessMint: boolean;
20
+ stakedAmount: string;
21
+ registeredAt: number;
22
+ }
23
+ /**
24
+ * AAstar Community
25
+ * - SuperPaymaster shared mode (AOA+)
26
+ * - Uses aPNTs for gas payments
27
+ * - MySBT for identity verification
28
+ */
29
+ export declare const AASTAR_COMMUNITY: CommunityConfig;
30
+ /**
31
+ * Bread Community
32
+ * - Independent AOA Paymaster mode
33
+ * - Uses bPNTs for gas payments
34
+ * - MySBT for identity verification
35
+ */
36
+ export declare const BREAD_COMMUNITY: CommunityConfig;
37
+ /**
38
+ * All communities indexed by address
39
+ */
40
+ export declare const COMMUNITIES: Record<string, CommunityConfig>;
41
+ /**
42
+ * Get community configuration by address
43
+ */
44
+ export declare function getCommunityConfig(address: string): CommunityConfig | undefined;
45
+ /**
46
+ * Get all community configurations
47
+ */
48
+ export declare function getAllCommunityConfigs(): CommunityConfig[];
49
+ /**
50
+ * Check if address is a registered community
51
+ */
52
+ export declare function isRegisteredCommunity(address: string): boolean;
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Community Configurations
3
+ * Registry v2.2.0 deployed on 2025-11-08
4
+ */
5
+ import { TEST_COMMUNITIES, TEST_TOKEN_ADDRESSES, CORE_ADDRESSES } from './contract-addresses.js';
6
+ export var NodeType;
7
+ (function (NodeType) {
8
+ NodeType[NodeType["PAYMASTER_AOA"] = 0] = "PAYMASTER_AOA";
9
+ NodeType[NodeType["PAYMASTER_SUPER"] = 1] = "PAYMASTER_SUPER";
10
+ NodeType[NodeType["ANODE"] = 2] = "ANODE";
11
+ NodeType[NodeType["KMS"] = 3] = "KMS";
12
+ })(NodeType || (NodeType = {}));
13
+ /**
14
+ * AAstar Community
15
+ * - SuperPaymaster shared mode (AOA+)
16
+ * - Uses aPNTs for gas payments
17
+ * - MySBT for identity verification
18
+ */
19
+ export const AASTAR_COMMUNITY = {
20
+ name: 'AAstar Community',
21
+ ensName: 'aastar.eth',
22
+ address: TEST_COMMUNITIES.aastar,
23
+ xPNTsToken: TEST_TOKEN_ADDRESSES.apnts,
24
+ supportedSBTs: [CORE_ADDRESSES.mySBT],
25
+ nodeType: NodeType.PAYMASTER_SUPER,
26
+ isActive: true,
27
+ allowPermissionlessMint: true,
28
+ stakedAmount: '50', // 50 GT
29
+ registeredAt: 1762588812, // 2025-11-08
30
+ };
31
+ /**
32
+ * Bread Community
33
+ * - Independent AOA Paymaster mode
34
+ * - Uses bPNTs for gas payments
35
+ * - MySBT for identity verification
36
+ */
37
+ export const BREAD_COMMUNITY = {
38
+ name: 'Bread Community',
39
+ ensName: 'bread.eth',
40
+ address: TEST_COMMUNITIES.bread,
41
+ xPNTsToken: TEST_TOKEN_ADDRESSES.bpnts,
42
+ supportedSBTs: [CORE_ADDRESSES.mySBT],
43
+ nodeType: NodeType.PAYMASTER_AOA,
44
+ isActive: true,
45
+ allowPermissionlessMint: false,
46
+ stakedAmount: '50', // 50 GT
47
+ registeredAt: 1762588812, // 2025-11-08
48
+ };
49
+ /**
50
+ * All communities indexed by address
51
+ */
52
+ export const COMMUNITIES = {
53
+ [TEST_COMMUNITIES.aastar]: AASTAR_COMMUNITY,
54
+ [TEST_COMMUNITIES.bread]: BREAD_COMMUNITY,
55
+ };
56
+ /**
57
+ * Get community configuration by address
58
+ */
59
+ export function getCommunityConfig(address) {
60
+ return COMMUNITIES[address.toLowerCase()];
61
+ }
62
+ /**
63
+ * Get all community configurations
64
+ */
65
+ export function getAllCommunityConfigs() {
66
+ return Object.values(COMMUNITIES);
67
+ }
68
+ /**
69
+ * Check if address is a registered community
70
+ */
71
+ export function isRegisteredCommunity(address) {
72
+ return address.toLowerCase() in COMMUNITIES;
73
+ }
@@ -0,0 +1,20 @@
1
+ import { Address } from 'viem';
2
+ export interface SuperPaymasterConfig {
3
+ registry: Address;
4
+ gToken: Address;
5
+ gTokenStaking: Address;
6
+ superPaymaster: Address;
7
+ paymasterFactory: Address;
8
+ paymasterV4: Address;
9
+ entryPoint: Address;
10
+ }
11
+ export declare class ContractConfigManager {
12
+ /**
13
+ * Get validated core configuration
14
+ */
15
+ static getConfig(): SuperPaymasterConfig;
16
+ /**
17
+ * Validate configuration addresses
18
+ */
19
+ private static validate;
20
+ }
@@ -0,0 +1,48 @@
1
+ import { isAddress } from 'viem';
2
+ import { CORE_ADDRESSES } from '../contract-addresses.js';
3
+ export class ContractConfigManager {
4
+ /**
5
+ * Get validated core configuration
6
+ */
7
+ static getConfig() {
8
+ const config = {
9
+ registry: CORE_ADDRESSES.registry,
10
+ gToken: CORE_ADDRESSES.gToken,
11
+ gTokenStaking: CORE_ADDRESSES.gTokenStaking,
12
+ superPaymaster: CORE_ADDRESSES.superPaymaster,
13
+ paymasterV4: CORE_ADDRESSES.paymasterV4,
14
+ paymasterFactory: CORE_ADDRESSES.paymasterFactory,
15
+ entryPoint: CORE_ADDRESSES.entryPoint || '0x0000000071727De22E5E9d8BAf0edAc6f37da032'
16
+ };
17
+ this.validate(config);
18
+ return config;
19
+ }
20
+ /**
21
+ * Validate configuration addresses
22
+ */
23
+ static validate(config) {
24
+ const missing = [];
25
+ const invalid = [];
26
+ // Critical contracts that MUST exist for experiments
27
+ const critical = ['registry', 'gToken', 'superPaymaster', 'paymasterV4'];
28
+ for (const [key, addr] of Object.entries(config)) {
29
+ if (!addr) {
30
+ if (critical.includes(key)) {
31
+ missing.push(key);
32
+ }
33
+ }
34
+ else if (!isAddress(addr)) {
35
+ invalid.push(`${key} (${addr})`);
36
+ }
37
+ }
38
+ if (missing.length > 0 || invalid.length > 0) {
39
+ throw new Error(`
40
+ Invalid Contract Configuration:
41
+ Missing: ${missing.join(', ')}
42
+ Invalid Format: ${invalid.join(', ')}
43
+
44
+ Please ensure your .env file is correctly sourced from 'projects/SuperPaymaster/.env.sepolia'
45
+ `);
46
+ }
47
+ }
48
+ }
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Contract Addresses (loaded from config.{network}.json)
3
+ */
4
+ export declare const CONTRACT_SRC_HASH: any;
5
+ export declare const REGISTRY_ADDRESS: `0x${string}`;
6
+ export declare const GTOKEN_ADDRESS: `0x${string}`;
7
+ export declare const GTOKEN_STAKING_ADDRESS: `0x${string}`;
8
+ export declare const SBT_ADDRESS: `0x${string}`;
9
+ export declare const REPUTATION_SYSTEM_ADDRESS: `0x${string}`;
10
+ export declare const SUPER_PAYMASTER_ADDRESS: `0x${string}`;
11
+ export declare const PAYMASTER_FACTORY_ADDRESS: `0x${string}`;
12
+ export declare const PAYMASTER_V4_IMPL_ADDRESS: `0x${string}`;
13
+ export declare const XPNTS_FACTORY_ADDRESS: `0x${string}`;
14
+ export declare const BLS_AGGREGATOR_ADDRESS: `0x${string}`;
15
+ export declare const BLS_VALIDATOR_ADDRESS: `0x${string}`;
16
+ export declare const DVT_VALIDATOR_ADDRESS: `0x${string}`;
17
+ export declare const ENTRY_POINT_ADDRESS: `0x${string}`;
18
+ export declare const ENTRY_POINT_0_8_ADDRESS: `0x${string}`;
19
+ export declare const ENTRY_POINT_0_9_ADDRESS: `0x${string}`;
20
+ export declare const APNTS_ADDRESS: `0x${string}`;
21
+ /**
22
+ * Common Constants
23
+ */
24
+ /**
25
+ * Default faucet API URL for testnet token requests
26
+ */
27
+ export declare const FAUCET_API_URL = "https://faucet-aastar.vercel.app";
28
+ /**
29
+ * Service fee rate in basis points (200 = 2%)
30
+ */
31
+ export declare const SERVICE_FEE_RATE = 200;
32
+ /**
33
+ * Maximum service fee in basis points (1000 = 10%)
34
+ */
35
+ export declare const MAX_SERVICE_FEE = 1000;
36
+ /**
37
+ * Basis points denominator (100% = 10000 basis points)
38
+ */
39
+ export declare const BPS_DENOMINATOR = 10000;
40
+ /**
41
+ * Default amount of gas tokens to mint for testing (in token units)
42
+ */
43
+ export declare const DEFAULT_GAS_TOKEN_MINT_AMOUNT = "100";
44
+ /**
45
+ * Default amount of USDT to mint for testing (in USDT)
46
+ */
47
+ export declare const DEFAULT_USDT_MINT_AMOUNT = "10";
48
+ /**
49
+ * Size of test account pool
50
+ */
51
+ export declare const TEST_ACCOUNT_POOL_SIZE = 20;
52
+ /**
53
+ * Minimum stake amounts for different node types (in sGT)
54
+ */
55
+ export declare const NODE_STAKE_AMOUNTS: {
56
+ /** Lite Node: 30 sGT minimum stake */
57
+ readonly LITE: 30;
58
+ /** Standard Node: 100 sGT minimum stake */
59
+ readonly STANDARD: 100;
60
+ /** Super Node: 300 sGT minimum stake */
61
+ readonly SUPER: 300;
62
+ /** Enterprise Node: 1000 sGT minimum stake */
63
+ readonly ENTERPRISE: 1000;
64
+ };
65
+ /**
66
+ * Default aPNTs price in USD (0.02 USD per aPNT)
67
+ */
68
+ export declare const DEFAULT_APNTS_PRICE_USD = "0.02";
69
+ /**
70
+ * Network Chain IDs
71
+ */
72
+ export declare const CHAIN_SEPOLIA = 11155111;
73
+ export declare const CHAIN_MAINNET = 1;
74
+ /**
75
+ * Default Values
76
+ */
77
+ export declare const DEFAULT_TOKEN_SYMBOL = "GT";
78
+ export declare const DEFAULT_TOKEN_NAME = "Governance Token";
79
+ /**
80
+ * Gas Limits
81
+ */
82
+ export declare const DEFAULT_VERIFICATION_GAS_LIMIT = 200000n;
83
+ export declare const DEFAULT_CALL_GAS_LIMIT = 100000n;
84
+ export declare const DEFAULT_PRE_VERIFICATION_GAS = 50000n;
85
+ /**
86
+ * Timeouts
87
+ */
88
+ export declare const DEFAULT_TIMEOUT_MS = 30000;
@@ -0,0 +1,125 @@
1
+ import { createRequire } from 'module';
2
+ const require = createRequire(import.meta.url);
3
+ // 智能网络检测: 优先级 EXPERIMENT_NETWORK > NETWORK > RPC URL检测 > anvil
4
+ function detectNetwork() {
5
+ // 1. 优先使用 EXPERIMENT_NETWORK (脚本常用)
6
+ if (process.env.EXPERIMENT_NETWORK) {
7
+ return process.env.EXPERIMENT_NETWORK;
8
+ }
9
+ // 2. 其次使用 NETWORK
10
+ if (process.env.NETWORK && process.env.NETWORK !== 'anvil') {
11
+ return process.env.NETWORK;
12
+ }
13
+ // 3. 通过 RPC URL 推断
14
+ const rpcUrl = process.env.SEPOLIA_RPC_URL || process.env.RPC_URL || process.env.OP_SEPOLIA_RPC_URL;
15
+ if (rpcUrl) {
16
+ if (rpcUrl.includes('sepolia') && !rpcUrl.includes('op-sepolia')) {
17
+ return 'sepolia';
18
+ }
19
+ if (rpcUrl.includes('op-sepolia') || rpcUrl.includes('optimism-sepolia')) {
20
+ return 'op-sepolia';
21
+ }
22
+ if (rpcUrl.includes('optimism') && !rpcUrl.includes('sepolia')) {
23
+ return 'optimism';
24
+ }
25
+ }
26
+ // 4. 默认 anvil
27
+ return 'anvil';
28
+ }
29
+ const network = detectNetwork();
30
+ let config = {};
31
+ try {
32
+ config = require(`../../../config.${network}.json`);
33
+ console.log(`[SDK] Loaded contract config from: config.${network}.json`);
34
+ }
35
+ catch (e) {
36
+ console.warn(`Warning: Could not load config.${network}.json. Contract addresses may be undefined.`);
37
+ }
38
+ /**
39
+ * Contract Addresses (loaded from config.{network}.json)
40
+ */
41
+ export const CONTRACT_SRC_HASH = config.srcHash;
42
+ export const REGISTRY_ADDRESS = config.registry;
43
+ export const GTOKEN_ADDRESS = config.gToken;
44
+ export const GTOKEN_STAKING_ADDRESS = config.staking;
45
+ export const SBT_ADDRESS = config.sbt;
46
+ export const REPUTATION_SYSTEM_ADDRESS = config.reputationSystem;
47
+ export const SUPER_PAYMASTER_ADDRESS = config.superPaymaster;
48
+ export const PAYMASTER_FACTORY_ADDRESS = config.paymasterFactory;
49
+ export const PAYMASTER_V4_IMPL_ADDRESS = config.paymasterV4Impl;
50
+ export const XPNTS_FACTORY_ADDRESS = config.xPNTsFactory;
51
+ export const BLS_AGGREGATOR_ADDRESS = config.blsAggregator;
52
+ export const BLS_VALIDATOR_ADDRESS = config.blsValidator;
53
+ export const DVT_VALIDATOR_ADDRESS = config.dvtValidator;
54
+ export const ENTRY_POINT_ADDRESS = config.entryPoint;
55
+ export const ENTRY_POINT_0_8_ADDRESS = config.entryPoint08;
56
+ export const ENTRY_POINT_0_9_ADDRESS = config.entryPoint09;
57
+ export const APNTS_ADDRESS = config.aPNTs;
58
+ /**
59
+ * Common Constants
60
+ */
61
+ /**
62
+ * Default faucet API URL for testnet token requests
63
+ */
64
+ export const FAUCET_API_URL = "https://faucet-aastar.vercel.app";
65
+ /**
66
+ * Service fee rate in basis points (200 = 2%)
67
+ */
68
+ export const SERVICE_FEE_RATE = 200;
69
+ /**
70
+ * Maximum service fee in basis points (1000 = 10%)
71
+ */
72
+ export const MAX_SERVICE_FEE = 1000;
73
+ /**
74
+ * Basis points denominator (100% = 10000 basis points)
75
+ */
76
+ export const BPS_DENOMINATOR = 10000;
77
+ /**
78
+ * Default amount of gas tokens to mint for testing (in token units)
79
+ */
80
+ export const DEFAULT_GAS_TOKEN_MINT_AMOUNT = "100";
81
+ /**
82
+ * Default amount of USDT to mint for testing (in USDT)
83
+ */
84
+ export const DEFAULT_USDT_MINT_AMOUNT = "10";
85
+ /**
86
+ * Size of test account pool
87
+ */
88
+ export const TEST_ACCOUNT_POOL_SIZE = 20;
89
+ /**
90
+ * Minimum stake amounts for different node types (in sGT)
91
+ */
92
+ export const NODE_STAKE_AMOUNTS = {
93
+ /** Lite Node: 30 sGT minimum stake */
94
+ LITE: 30,
95
+ /** Standard Node: 100 sGT minimum stake */
96
+ STANDARD: 100,
97
+ /** Super Node: 300 sGT minimum stake */
98
+ SUPER: 300,
99
+ /** Enterprise Node: 1000 sGT minimum stake */
100
+ ENTERPRISE: 1000,
101
+ };
102
+ /**
103
+ * Default aPNTs price in USD (0.02 USD per aPNT)
104
+ */
105
+ export const DEFAULT_APNTS_PRICE_USD = "0.02";
106
+ /**
107
+ * Network Chain IDs
108
+ */
109
+ export const CHAIN_SEPOLIA = 11155111;
110
+ export const CHAIN_MAINNET = 1;
111
+ /**
112
+ * Default Values
113
+ */
114
+ export const DEFAULT_TOKEN_SYMBOL = 'GT';
115
+ export const DEFAULT_TOKEN_NAME = 'Governance Token';
116
+ /**
117
+ * Gas Limits
118
+ */
119
+ export const DEFAULT_VERIFICATION_GAS_LIMIT = 200000n;
120
+ export const DEFAULT_CALL_GAS_LIMIT = 100000n;
121
+ export const DEFAULT_PRE_VERIFICATION_GAS = 50000n;
122
+ /**
123
+ * Timeouts
124
+ */
125
+ export const DEFAULT_TIMEOUT_MS = 30000;