forked from hyli-org/wallet
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathconfig.example.js
More file actions
88 lines (72 loc) · 2.7 KB
/
config.example.js
File metadata and controls
88 lines (72 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Configuration template for the wallet registration script
// Copy this file to config.js and update the values
export const CONFIG = {
// Hyli Node Service URL
NODE_BASE_URL: process.env.NODE_BASE_URL || "http://localhost:4321",
// Hyli Indexer Service URL
INDEXER_BASE_URL: process.env.INDEXER_BASE_URL || "http://localhost:4322",
// Wallet Contract Name
WALLET_CONTRACT_NAME: "wallet",
// Default session key duration (24 hours in milliseconds)
DEFAULT_SESSION_KEY_DURATION: 24 * 60 * 60 * 1000,
// Default whitelist for session keys (empty array means no restrictions)
DEFAULT_SESSION_KEY_WHITELIST: [],
// Timeout for operations (in milliseconds)
OPERATION_TIMEOUT: 60000,
// Retry configuration
RETRY_CONFIG: {
maxRetries: 3,
retryDelay: 1000, // 1 second
backoffMultiplier: 2
},
// Logging configuration
LOGGING: {
level: "info", // debug, info, warn, error
enableConsole: true,
enableFile: false,
logFile: "registration.log"
}
};
// Environment-specific configurations
export const ENV_CONFIGS = {
local: {
NODE_BASE_URL: "http://localhost:4321",
INDEXER_BASE_URL: "http://localhost:4322",
WALLET_API_BASE_URL: "http://localhost:4000",
LOGGING: { level: "debug" }
},
devnet: {
NODE_BASE_URL: "https://node.devnet.hyli.org",
INDEXER_BASE_URL: "https://indexer.devnet.hyli.org",
WALLET_API_BASE_URL: "https://wallet.devnet.hyli.org",
LOGGING: { level: "info" }
},
testnet: {
NODE_BASE_URL: "https://node.testnet.hyli.org",
INDEXER_BASE_URL: "https://indexer.testnet.hyli.org",
WALLET_API_BASE_URL: "https://wallet.testnet.hyli.org",
LOGGING: { level: "warn" }
}
};
// Helper function to get configuration based on environment
export function getConfig(environment = process.env.NODE_ENV || "local") {
const envConfig = ENV_CONFIGS[environment] || {};
return { ...CONFIG, ...envConfig };
}
// Helper function to validate configuration
export function validateConfig(config) {
const required = ['NODE_BASE_URL', 'INDEXER_BASE_URL', 'WALLET_CONTRACT_NAME', 'WALLET_API_BASE_URL'];
const missing = required.filter(key => !config[key]);
if (missing.length > 0) {
throw new Error(`Missing required configuration: ${missing.join(', ')}`);
}
// Validate URLs
try {
new URL(config.NODE_BASE_URL);
new URL(config.INDEXER_BASE_URL);
new URL(config.WALLET_API_BASE_URL);
} catch (error) {
throw new Error(`Invalid URL in configuration: ${error.message}`);
}
return true;
}