@aastar/core 0.16.16 → 0.16.18

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.
@@ -37,4 +37,4 @@ export type AccountFactoryActions = {
37
37
  }) => Promise<Address>;
38
38
  };
39
39
  export declare const accountActions: (address: Address) => (client: PublicClient | WalletClient) => AccountActions;
40
- export declare const accountFactoryActions: (address: Address) => (client: PublicClient | WalletClient) => AccountFactoryActions;
40
+ export declare const accountFactoryActions: (address: Address, abi?: any) => (client: PublicClient | WalletClient) => AccountFactoryActions;
@@ -132,14 +132,14 @@ export const accountActions = (address) => (client) => ({
132
132
  }
133
133
  }
134
134
  });
135
- export const accountFactoryActions = (address) => (client) => ({
135
+ export const accountFactoryActions = (address, abi = SimpleAccountFactoryABI) => (client) => ({
136
136
  async createAccount({ owner, salt, account }) {
137
137
  try {
138
138
  validateAddress(owner, 'owner');
139
139
  validateRequired(salt, 'salt');
140
140
  return await client.writeContract({
141
141
  address,
142
- abi: SimpleAccountFactoryABI,
142
+ abi: abi || SimpleAccountFactoryABI,
143
143
  functionName: 'createAccount',
144
144
  args: [owner, salt],
145
145
  account: account,
@@ -156,7 +156,7 @@ export const accountFactoryActions = (address) => (client) => ({
156
156
  validateRequired(salt, 'salt');
157
157
  return await client.readContract({
158
158
  address,
159
- abi: SimpleAccountFactoryABI,
159
+ abi: abi || SimpleAccountFactoryABI,
160
160
  functionName: 'getAddress',
161
161
  args: [owner, salt]
162
162
  });
@@ -1,86 +1,47 @@
1
1
  /**
2
2
  * Contract Addresses (Priority: ENV > Local Config > Canonical Defaults)
3
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 APNTS_ADDRESS: `0x${string}`;
4
+ export declare let CONTRACT_SRC_HASH: any;
5
+ export declare let REGISTRY_ADDRESS: `0x${string}`;
6
+ export declare let GTOKEN_ADDRESS: `0x${string}`;
7
+ export declare let GTOKEN_STAKING_ADDRESS: `0x${string}`;
8
+ export declare let SBT_ADDRESS: `0x${string}`;
9
+ export declare let REPUTATION_SYSTEM_ADDRESS: `0x${string}`;
10
+ export declare let SUPER_PAYMASTER_ADDRESS: `0x${string}`;
11
+ export declare let PAYMASTER_FACTORY_ADDRESS: `0x${string}`;
12
+ export declare let PAYMASTER_V4_IMPL_ADDRESS: `0x${string}`;
13
+ export declare let XPNTS_FACTORY_ADDRESS: `0x${string}`;
14
+ export declare let BLS_AGGREGATOR_ADDRESS: `0x${string}`;
15
+ export declare let BLS_VALIDATOR_ADDRESS: `0x${string}`;
16
+ export declare let DVT_VALIDATOR_ADDRESS: `0x${string}`;
17
+ export declare let ENTRY_POINT_ADDRESS: `0x${string}`;
18
+ export declare let APNTS_ADDRESS: `0x${string}`;
19
+ /**
20
+ * Apply external configuration (for Node.js environment)
21
+ */
22
+ export declare function applyConfig(newConfig: any): void;
19
23
  /**
20
24
  * Common Constants
21
25
  */
22
- /**
23
- * Default faucet API URL for testnet token requests
24
- */
25
26
  export declare const FAUCET_API_URL = "https://faucet-aastar.vercel.app";
26
- /**
27
- * Service fee rate in basis points (200 = 2%)
28
- */
29
27
  export declare const SERVICE_FEE_RATE = 200;
30
- /**
31
- * Maximum service fee in basis points (1000 = 10%)
32
- */
33
28
  export declare const MAX_SERVICE_FEE = 1000;
34
- /**
35
- * Basis points denominator (100% = 10000 basis points)
36
- */
37
29
  export declare const BPS_DENOMINATOR = 10000;
38
- /**
39
- * Default amount of gas tokens to mint for testing (in token units)
40
- */
41
30
  export declare const DEFAULT_GAS_TOKEN_MINT_AMOUNT = "100";
42
- /**
43
- * Default amount of USDT to mint for testing (in USDT)
44
- */
45
31
  export declare const DEFAULT_USDT_MINT_AMOUNT = "10";
46
- /**
47
- * Size of test account pool
48
- */
49
32
  export declare const TEST_ACCOUNT_POOL_SIZE = 20;
50
- /**
51
- * Minimum stake amounts for different node types (in sGT)
52
- */
53
33
  export declare const NODE_STAKE_AMOUNTS: {
54
- /** Lite Node: 30 sGT minimum stake */
55
34
  readonly LITE: 30;
56
- /** Standard Node: 100 sGT minimum stake */
57
35
  readonly STANDARD: 100;
58
- /** Super Node: 300 sGT minimum stake */
59
36
  readonly SUPER: 300;
60
- /** Enterprise Node: 1000 sGT minimum stake */
61
37
  readonly ENTERPRISE: 1000;
62
38
  };
63
- /**
64
- * Default aPNTs price in USD (0.02 USD per aPNT)
65
- */
66
39
  export declare const DEFAULT_APNTS_PRICE_USD = "0.02";
67
- /**
68
- * Network Chain IDs
69
- */
70
40
  export declare const CHAIN_SEPOLIA = 11155111;
71
41
  export declare const CHAIN_MAINNET = 1;
72
- /**
73
- * Default Values
74
- */
75
42
  export declare const DEFAULT_TOKEN_SYMBOL = "GT";
76
43
  export declare const DEFAULT_TOKEN_NAME = "Governance Token";
77
- /**
78
- * Gas Limits
79
- */
80
44
  export declare const DEFAULT_VERIFICATION_GAS_LIMIT = 200000n;
81
45
  export declare const DEFAULT_CALL_GAS_LIMIT = 100000n;
82
46
  export declare const DEFAULT_PRE_VERIFICATION_GAS = 50000n;
83
- /**
84
- * Timeouts
85
- */
86
47
  export declare const DEFAULT_TIMEOUT_MS = 30000;
package/dist/constants.js CHANGED
@@ -1,102 +1,89 @@
1
- import { createRequire } from 'module';
2
1
  import { CANONICAL_ADDRESSES } from './addresses.js';
3
- const require = createRequire(import.meta.url);
4
- const network = process.env.NETWORK || 'anvil';
5
- let config = {};
6
- // 1. Try to load local config (for development/monorepo use)
7
- try {
8
- config = require(`../../../config.${network}.json`);
2
+ // Browser-safe network detection
3
+ const network = (typeof process !== 'undefined' && process.env && process.env.NETWORK) || 'anvil';
4
+ let internalConfig = {};
5
+ // 2. Identify Chain ID and resolve canonical defaults
6
+ let chainIdStr = (typeof process !== 'undefined' && process.env && process.env.CHAIN_ID) || internalConfig.chainId;
7
+ let chainId = chainIdStr ? Number(chainIdStr) : (network === 'sepolia' ? 11155111 : (network === 'op-sepolia' ? 11155420 : 0));
8
+ let defaults = CANONICAL_ADDRESSES[chainId] || {};
9
+ /**
10
+ * Helper to resolve address
11
+ */
12
+ function resolveAddr(envKey, configKey) {
13
+ const envVal = (typeof process !== 'undefined' && process.env) ? process.env[envKey] : undefined;
14
+ return (envVal || internalConfig[configKey] || defaults[configKey]);
9
15
  }
10
- catch (e) {
11
- // console.warn(`Warning: Could not load config.${network}.json. Falling back to code defaults.`);
16
+ function resolveVal(envKey, configKey) {
17
+ const envVal = (typeof process !== 'undefined' && process.env) ? process.env[envKey] : undefined;
18
+ return envVal || internalConfig[configKey] || defaults[configKey];
12
19
  }
13
- // 2. Identify Chain ID and resolve canonical defaults
14
- const chainIdStr = process.env.CHAIN_ID || config.chainId;
15
- const chainId = chainIdStr ? Number(chainIdStr) : (network === 'sepolia' ? 11155111 : (network === 'op-sepolia' ? 11155420 : 0));
16
- const defaults = CANONICAL_ADDRESSES[chainId] || {};
17
20
  /**
18
21
  * Contract Addresses (Priority: ENV > Local Config > Canonical Defaults)
19
22
  */
20
- export const CONTRACT_SRC_HASH = process.env.SRC_HASH || config.srcHash || defaults.srcHash;
21
- export const REGISTRY_ADDRESS = (process.env.REGISTRY || config.registry || defaults.registry);
22
- export const GTOKEN_ADDRESS = (process.env.GTOKEN || config.gToken || defaults.gToken);
23
- export const GTOKEN_STAKING_ADDRESS = (process.env.STAKING || config.staking || defaults.staking);
24
- export const SBT_ADDRESS = (process.env.SBT || config.sbt || defaults.sbt);
25
- export const REPUTATION_SYSTEM_ADDRESS = (process.env.REPUTATION_SYSTEM || config.reputationSystem || defaults.reputationSystem);
26
- export const SUPER_PAYMASTER_ADDRESS = (process.env.SUPER_PAYMASTER || config.superPaymaster || defaults.superPaymaster);
27
- export const PAYMASTER_FACTORY_ADDRESS = (process.env.PAYMASTER_FACTORY || config.paymasterFactory || defaults.paymasterFactory);
28
- export const PAYMASTER_V4_IMPL_ADDRESS = (process.env.PAYMASTER_V4_IMPL || config.paymasterV4Impl || defaults.paymasterV4Impl);
29
- export const XPNTS_FACTORY_ADDRESS = (process.env.XPNTS_FACTORY || config.xPNTsFactory || defaults.xPNTsFactory);
30
- export const BLS_AGGREGATOR_ADDRESS = (process.env.BLS_AGGREGATOR || config.blsAggregator || defaults.blsAggregator);
31
- export const BLS_VALIDATOR_ADDRESS = (process.env.BLS_VALIDATOR || config.blsValidator || defaults.blsValidator);
32
- export const DVT_VALIDATOR_ADDRESS = (process.env.DVT_VALIDATOR || config.dvtValidator || defaults.dvtValidator);
33
- export const ENTRY_POINT_ADDRESS = (process.env.ENTRY_POINT || config.entryPoint || defaults.entryPoint);
34
- export const APNTS_ADDRESS = (process.env.APNTS || config.aPNTs || defaults.aPNTs);
23
+ export let CONTRACT_SRC_HASH = resolveVal('SRC_HASH', 'srcHash');
24
+ export let REGISTRY_ADDRESS = resolveAddr('REGISTRY', 'registry');
25
+ export let GTOKEN_ADDRESS = resolveAddr('GTOKEN', 'gToken');
26
+ export let GTOKEN_STAKING_ADDRESS = resolveAddr('STAKING', 'staking');
27
+ export let SBT_ADDRESS = resolveAddr('SBT', 'sbt');
28
+ export let REPUTATION_SYSTEM_ADDRESS = resolveAddr('REPUTATION_SYSTEM', 'reputationSystem');
29
+ export let SUPER_PAYMASTER_ADDRESS = resolveAddr('SUPER_PAYMASTER', 'superPaymaster');
30
+ export let PAYMASTER_FACTORY_ADDRESS = resolveAddr('PAYMASTER_FACTORY', 'paymasterFactory');
31
+ export let PAYMASTER_V4_IMPL_ADDRESS = resolveAddr('PAYMASTER_V4_IMPL', 'paymasterV4Impl');
32
+ export let XPNTS_FACTORY_ADDRESS = resolveAddr('XPNTS_FACTORY', 'xPNTsFactory');
33
+ export let BLS_AGGREGATOR_ADDRESS = resolveAddr('BLS_AGGREGATOR', 'blsAggregator');
34
+ export let BLS_VALIDATOR_ADDRESS = resolveAddr('BLS_VALIDATOR', 'blsValidator');
35
+ export let DVT_VALIDATOR_ADDRESS = resolveAddr('DVT_VALIDATOR', 'dvtValidator');
36
+ export let ENTRY_POINT_ADDRESS = resolveAddr('ENTRY_POINT', 'entryPoint');
37
+ export let APNTS_ADDRESS = resolveAddr('APNTS', 'aPNTs');
35
38
  /**
36
- * Common Constants
39
+ * Apply external configuration (for Node.js environment)
37
40
  */
41
+ export function applyConfig(newConfig) {
42
+ internalConfig = newConfig;
43
+ // Re-calculate derived values
44
+ const envChainId = (typeof process !== 'undefined' && process.env) ? process.env.CHAIN_ID : undefined;
45
+ chainIdStr = envChainId || internalConfig.chainId;
46
+ chainId = chainIdStr ? Number(chainIdStr) : (network === 'sepolia' ? 11155111 : (network === 'op-sepolia' ? 11155420 : 0));
47
+ defaults = CANONICAL_ADDRESSES[chainId] || {};
48
+ // Re-assign exports
49
+ CONTRACT_SRC_HASH = resolveVal('SRC_HASH', 'srcHash');
50
+ REGISTRY_ADDRESS = resolveAddr('REGISTRY', 'registry');
51
+ GTOKEN_ADDRESS = resolveAddr('GTOKEN', 'gToken');
52
+ GTOKEN_STAKING_ADDRESS = resolveAddr('STAKING', 'staking');
53
+ SBT_ADDRESS = resolveAddr('SBT', 'sbt');
54
+ REPUTATION_SYSTEM_ADDRESS = resolveAddr('REPUTATION_SYSTEM', 'reputationSystem');
55
+ SUPER_PAYMASTER_ADDRESS = resolveAddr('SUPER_PAYMASTER', 'superPaymaster');
56
+ PAYMASTER_FACTORY_ADDRESS = resolveAddr('PAYMASTER_FACTORY', 'paymasterFactory');
57
+ PAYMASTER_V4_IMPL_ADDRESS = resolveAddr('PAYMASTER_V4_IMPL', 'paymasterV4Impl');
58
+ XPNTS_FACTORY_ADDRESS = resolveAddr('XPNTS_FACTORY', 'xPNTsFactory');
59
+ BLS_AGGREGATOR_ADDRESS = resolveAddr('BLS_AGGREGATOR', 'blsAggregator');
60
+ BLS_VALIDATOR_ADDRESS = resolveAddr('BLS_VALIDATOR', 'blsValidator');
61
+ DVT_VALIDATOR_ADDRESS = resolveAddr('DVT_VALIDATOR', 'dvtValidator');
62
+ ENTRY_POINT_ADDRESS = resolveAddr('ENTRY_POINT', 'entryPoint');
63
+ APNTS_ADDRESS = resolveAddr('APNTS', 'aPNTs');
64
+ }
38
65
  /**
39
- * Default faucet API URL for testnet token requests
66
+ * Common Constants
40
67
  */
41
68
  export const FAUCET_API_URL = "https://faucet-aastar.vercel.app";
42
- /**
43
- * Service fee rate in basis points (200 = 2%)
44
- */
45
69
  export const SERVICE_FEE_RATE = 200;
46
- /**
47
- * Maximum service fee in basis points (1000 = 10%)
48
- */
49
70
  export const MAX_SERVICE_FEE = 1000;
50
- /**
51
- * Basis points denominator (100% = 10000 basis points)
52
- */
53
71
  export const BPS_DENOMINATOR = 10000;
54
- /**
55
- * Default amount of gas tokens to mint for testing (in token units)
56
- */
57
72
  export const DEFAULT_GAS_TOKEN_MINT_AMOUNT = "100";
58
- /**
59
- * Default amount of USDT to mint for testing (in USDT)
60
- */
61
73
  export const DEFAULT_USDT_MINT_AMOUNT = "10";
62
- /**
63
- * Size of test account pool
64
- */
65
74
  export const TEST_ACCOUNT_POOL_SIZE = 20;
66
- /**
67
- * Minimum stake amounts for different node types (in sGT)
68
- */
69
75
  export const NODE_STAKE_AMOUNTS = {
70
- /** Lite Node: 30 sGT minimum stake */
71
76
  LITE: 30,
72
- /** Standard Node: 100 sGT minimum stake */
73
77
  STANDARD: 100,
74
- /** Super Node: 300 sGT minimum stake */
75
78
  SUPER: 300,
76
- /** Enterprise Node: 1000 sGT minimum stake */
77
79
  ENTERPRISE: 1000,
78
80
  };
79
- /**
80
- * Default aPNTs price in USD (0.02 USD per aPNT)
81
- */
82
81
  export const DEFAULT_APNTS_PRICE_USD = "0.02";
83
- /**
84
- * Network Chain IDs
85
- */
86
82
  export const CHAIN_SEPOLIA = 11155111;
87
83
  export const CHAIN_MAINNET = 1;
88
- /**
89
- * Default Values
90
- */
91
84
  export const DEFAULT_TOKEN_SYMBOL = 'GT';
92
85
  export const DEFAULT_TOKEN_NAME = 'Governance Token';
93
- /**
94
- * Gas Limits
95
- */
96
86
  export const DEFAULT_VERIFICATION_GAS_LIMIT = 200000n;
97
87
  export const DEFAULT_CALL_GAS_LIMIT = 100000n;
98
88
  export const DEFAULT_PRE_VERIFICATION_GAS = 50000n;
99
- /**
100
- * Timeouts
101
- */
102
89
  export const DEFAULT_TIMEOUT_MS = 30000;
@@ -0,0 +1,2 @@
1
+ import './node-init.js';
2
+ export * from './index.js';
@@ -0,0 +1,2 @@
1
+ import './node-init.js';
2
+ export * from './index.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import { createRequire } from 'module';
2
+ import { applyConfig } from './constants.js';
3
+ const require = createRequire(import.meta.url);
4
+ const network = process.env.NETWORK || 'anvil';
5
+ try {
6
+ const config = require(`../../../config.${network}.json`);
7
+ applyConfig(config);
8
+ }
9
+ catch (e) {
10
+ // console.warn(`Warning: Could not load config.${network}.json`);
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aastar/core",
3
- "version": "0.16.16",
3
+ "version": "0.16.18",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -8,6 +8,13 @@
8
8
  "type": "module",
9
9
  "main": "dist/index.js",
10
10
  "types": "dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "browser": "./dist/index.js",
14
+ "import": "./dist/index.node.js",
15
+ "require": "./dist/index.node.js"
16
+ }
17
+ },
11
18
  "files": [
12
19
  "dist"
13
20
  ],