@aastar/paymaster 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/core/src/abis/BLSAggregator.json +686 -0
- package/dist/core/src/abis/BLSValidator.json +42 -0
- package/dist/core/src/abis/DVTValidator.json +368 -0
- package/dist/core/src/abis/EntryPoint.json +1382 -0
- package/dist/core/src/abis/GToken.json +513 -0
- package/dist/core/src/abis/GTokenStaking.json +949 -0
- package/dist/core/src/abis/MySBT.json +1518 -0
- package/dist/core/src/abis/Paymaster.json +1143 -0
- package/dist/core/src/abis/PaymasterFactory.json +640 -0
- package/dist/core/src/abis/Registry.json +1942 -0
- package/dist/core/src/abis/ReputationSystem.json +699 -0
- package/dist/core/src/abis/SimpleAccount.json +560 -0
- package/dist/core/src/abis/SimpleAccountFactory.json +111 -0
- package/dist/core/src/abis/SuperPaymaster.json +1781 -0
- package/dist/core/src/abis/index.d.ts +1126 -0
- package/dist/core/src/abis/index.js +91 -0
- package/dist/core/src/abis/xPNTsFactory.json +718 -0
- package/dist/core/src/abis/xPNTsToken.json +1280 -0
- package/dist/core/src/actions/StateValidator.d.ts +68 -0
- package/dist/core/src/actions/StateValidator.js +187 -0
- package/dist/core/src/actions/account.d.ts +55 -0
- package/dist/core/src/actions/account.js +133 -0
- package/dist/core/src/actions/aggregator.d.ts +17 -0
- package/dist/core/src/actions/aggregator.js +31 -0
- package/dist/core/src/actions/dvt.d.ts +30 -0
- package/dist/core/src/actions/dvt.js +41 -0
- package/dist/core/src/actions/entryPoint.d.ts +90 -0
- package/dist/core/src/actions/entryPoint.js +211 -0
- package/dist/core/src/actions/factory.d.ts +215 -0
- package/dist/core/src/actions/factory.js +442 -0
- package/dist/core/src/actions/faucet.d.ts +48 -0
- package/dist/core/src/actions/faucet.js +337 -0
- package/dist/core/src/actions/gtokenExtended.d.ts +39 -0
- package/dist/core/src/actions/gtokenExtended.js +115 -0
- package/dist/core/src/actions/index.d.ts +15 -0
- package/dist/core/src/actions/index.js +17 -0
- package/dist/core/src/actions/paymasterV4.d.ts +170 -0
- package/dist/core/src/actions/paymasterV4.js +334 -0
- package/dist/core/src/actions/registry.d.ts +246 -0
- package/dist/core/src/actions/registry.js +667 -0
- package/dist/core/src/actions/reputation.d.ts +129 -0
- package/dist/core/src/actions/reputation.js +281 -0
- package/dist/core/src/actions/sbt.d.ts +191 -0
- package/dist/core/src/actions/sbt.js +533 -0
- package/dist/core/src/actions/staking.d.ts +132 -0
- package/dist/core/src/actions/staking.js +330 -0
- package/dist/core/src/actions/superPaymaster.d.ts +237 -0
- package/dist/core/src/actions/superPaymaster.js +644 -0
- package/dist/core/src/actions/tokens.d.ts +229 -0
- package/dist/core/src/actions/tokens.js +415 -0
- package/dist/core/src/branding.d.ts +30 -0
- package/dist/core/src/branding.js +30 -0
- package/dist/core/src/clients/BaseClient.d.ts +25 -0
- package/dist/core/src/clients/BaseClient.js +66 -0
- package/dist/core/src/clients/types.d.ts +60 -0
- package/dist/core/src/clients/types.js +1 -0
- package/dist/core/src/clients.d.ts +5 -0
- package/dist/core/src/clients.js +11 -0
- package/dist/core/src/communities.d.ts +52 -0
- package/dist/core/src/communities.js +73 -0
- package/dist/core/src/config/ContractConfigManager.d.ts +20 -0
- package/dist/core/src/config/ContractConfigManager.js +48 -0
- package/dist/core/src/constants.d.ts +88 -0
- package/dist/core/src/constants.js +125 -0
- package/dist/core/src/contract-addresses.d.ts +110 -0
- package/dist/core/src/contract-addresses.js +99 -0
- package/dist/core/src/contracts.d.ts +424 -0
- package/dist/core/src/contracts.js +343 -0
- package/dist/core/src/crypto/blsSigner.d.ts +64 -0
- package/dist/core/src/crypto/blsSigner.js +98 -0
- package/dist/core/src/crypto/index.d.ts +1 -0
- package/dist/core/src/crypto/index.js +1 -0
- package/dist/core/src/index.d.ts +21 -0
- package/dist/core/src/index.js +21 -0
- package/dist/core/src/networks.d.ts +127 -0
- package/dist/core/src/networks.js +118 -0
- package/dist/core/src/requirementChecker.d.ts +38 -0
- package/dist/core/src/requirementChecker.js +139 -0
- package/dist/core/src/roles.d.ts +204 -0
- package/dist/core/src/roles.js +211 -0
- package/dist/core/src/utils/validation.d.ts +24 -0
- package/dist/core/src/utils/validation.js +56 -0
- package/dist/paymaster/src/SuperPaymaster/index.d.ts +44 -0
- package/dist/paymaster/src/SuperPaymaster/index.js +133 -0
- package/dist/paymaster/src/V4/PaymasterClient.d.ts +79 -0
- package/dist/paymaster/src/V4/PaymasterClient.js +315 -0
- package/dist/paymaster/src/V4/PaymasterClient.test.d.ts +1 -0
- package/dist/paymaster/src/V4/PaymasterClient.test.js +80 -0
- package/dist/paymaster/src/V4/PaymasterOperator.d.ts +41 -0
- package/dist/paymaster/src/V4/PaymasterOperator.js +241 -0
- package/dist/paymaster/src/V4/PaymasterOperator.test.d.ts +1 -0
- package/dist/paymaster/src/V4/PaymasterOperator.test.js +66 -0
- package/dist/paymaster/src/V4/PaymasterUtils.d.ts +55 -0
- package/dist/paymaster/src/V4/PaymasterUtils.js +124 -0
- package/dist/paymaster/src/V4/PaymasterUtils.test.d.ts +1 -0
- package/dist/paymaster/src/V4/PaymasterUtils.test.js +43 -0
- package/dist/paymaster/src/V4/SuperPaymasterClient.d.ts +21 -0
- package/dist/paymaster/src/V4/SuperPaymasterClient.js +73 -0
- package/dist/paymaster/src/V4/SuperPaymasterClient.test.d.ts +1 -0
- package/dist/paymaster/src/V4/SuperPaymasterClient.test.js +53 -0
- package/dist/paymaster/src/V4/index.d.ts +4 -0
- package/dist/paymaster/src/V4/index.js +4 -0
- package/dist/paymaster/src/index.d.ts +2 -0
- package/dist/paymaster/src/index.js +4 -0
- package/package.json +26 -0
|
@@ -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,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;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contract Addresses - Single Source of Truth
|
|
3
|
+
* All contract addresses for Sepolia testnet
|
|
4
|
+
*
|
|
5
|
+
* This file serves as the single source of truth for all contract addresses.
|
|
6
|
+
* All other files reference these constants to avoid duplication.
|
|
7
|
+
*/
|
|
8
|
+
import { type Address } from 'viem';
|
|
9
|
+
/**
|
|
10
|
+
* Core System Addresses
|
|
11
|
+
*/
|
|
12
|
+
export declare const CORE_ADDRESSES: {
|
|
13
|
+
readonly registry: `0x${string}`;
|
|
14
|
+
readonly gToken: `0x${string}`;
|
|
15
|
+
readonly gTokenStaking: `0x${string}`;
|
|
16
|
+
readonly superPaymaster: `0x${string}`;
|
|
17
|
+
readonly paymasterFactory: `0x${string}`;
|
|
18
|
+
readonly aPNTs: `0x${string}`;
|
|
19
|
+
readonly mySBT: `0x${string}`;
|
|
20
|
+
readonly paymasterV4: Address;
|
|
21
|
+
readonly dvtValidator: `0x${string}`;
|
|
22
|
+
readonly entryPoint: `0x${string}`;
|
|
23
|
+
readonly xPNTsFactory: `0x${string}`;
|
|
24
|
+
readonly reputationSystem: Address;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Token System Addresses
|
|
28
|
+
*/
|
|
29
|
+
export declare const TOKEN_ADDRESSES: {
|
|
30
|
+
readonly xPNTsFactory: `0x${string}`;
|
|
31
|
+
readonly aPNTs: `0x${string}`;
|
|
32
|
+
readonly gToken: `0x${string}`;
|
|
33
|
+
readonly pimToken: Address;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Test Token Addresses (For Development & Testing)
|
|
37
|
+
*/
|
|
38
|
+
export declare const TEST_TOKEN_ADDRESSES: {
|
|
39
|
+
readonly mockUSDT: Address;
|
|
40
|
+
readonly apnts: `0x${string}`;
|
|
41
|
+
readonly gToken: `0x${string}`;
|
|
42
|
+
readonly bpnts: `0x${string}`;
|
|
43
|
+
readonly pimToken: `0x${string}`;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Test Account Addresses (For Development & Testing)
|
|
47
|
+
*/
|
|
48
|
+
export declare const TEST_ACCOUNT_ADDRESSES: {
|
|
49
|
+
readonly simpleAccountFactory: Address;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Paymaster Addresses
|
|
53
|
+
*/
|
|
54
|
+
export declare const PAYMASTER_ADDRESSES: {
|
|
55
|
+
readonly paymasterV4_1: Address;
|
|
56
|
+
readonly paymasterV4_1iImplementation: `0x${string}`;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Monitoring System Addresses
|
|
60
|
+
*/
|
|
61
|
+
export declare const MONITORING_ADDRESSES: {
|
|
62
|
+
readonly dvtValidator: `0x${string}`;
|
|
63
|
+
readonly blsAggregator: `0x${string}`;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Official Contract Addresses
|
|
67
|
+
*/
|
|
68
|
+
export declare const OFFICIAL_ADDRESSES: {
|
|
69
|
+
readonly entryPoint: Address;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Community Owner Addresses
|
|
73
|
+
*/
|
|
74
|
+
export declare const COMMUNITY_OWNERS: {
|
|
75
|
+
readonly aastarOwner: "0x411BD567E46C0781248dbB6a9211891C032885e5";
|
|
76
|
+
readonly breadCommunityOwner: "0xe24b6f321B0140716a2b671ed0D983bb64E7DaFA";
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Test Community Addresses (Registered in Registry v2.2.0 on 2025-11-08)
|
|
80
|
+
*/
|
|
81
|
+
export declare const TEST_COMMUNITIES: {
|
|
82
|
+
readonly aastar: Address;
|
|
83
|
+
readonly bread: Address;
|
|
84
|
+
readonly mycelium: Address;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* All Addresses Combined (for reference)
|
|
88
|
+
*/
|
|
89
|
+
export declare const ALL_ADDRESSES: {
|
|
90
|
+
readonly entryPoint: Address;
|
|
91
|
+
readonly dvtValidator: `0x${string}`;
|
|
92
|
+
readonly blsAggregator: `0x${string}`;
|
|
93
|
+
readonly paymasterV4_1: Address;
|
|
94
|
+
readonly paymasterV4_1iImplementation: `0x${string}`;
|
|
95
|
+
readonly simpleAccountFactory: Address;
|
|
96
|
+
readonly mockUSDT: Address;
|
|
97
|
+
readonly apnts: `0x${string}`;
|
|
98
|
+
readonly gToken: `0x${string}`;
|
|
99
|
+
readonly bpnts: `0x${string}`;
|
|
100
|
+
readonly pimToken: `0x${string}`;
|
|
101
|
+
readonly xPNTsFactory: `0x${string}`;
|
|
102
|
+
readonly aPNTs: `0x${string}`;
|
|
103
|
+
readonly registry: `0x${string}`;
|
|
104
|
+
readonly gTokenStaking: `0x${string}`;
|
|
105
|
+
readonly superPaymaster: `0x${string}`;
|
|
106
|
+
readonly paymasterFactory: `0x${string}`;
|
|
107
|
+
readonly mySBT: `0x${string}`;
|
|
108
|
+
readonly paymasterV4: Address;
|
|
109
|
+
readonly reputationSystem: Address;
|
|
110
|
+
};
|