p-sdk-wallet
Version:
A comprehensive wallet SDK for React Native (pwc), supporting multi-chain and multi-account features.
110 lines (109 loc) • 4.08 kB
JavaScript
"use strict";
/**
* Configuration constants for PWC Wallet SDK
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.VALIDATION_CONFIG = exports.CACHE_CONFIG = exports.NETWORK_CONFIG = exports.SECURITY_CONFIG = exports.VANITY_WALLET_CONFIG = void 0;
exports.getPBKDF2Iterations = getPBKDF2Iterations;
/**
* Configuration object for vanity wallet generation.
* Contains default settings and limits for generating wallets with specific address prefixes.
*/
exports.VANITY_WALLET_CONFIG = {
/** Default prefix for vanity addresses (without '0x' for EVM chains) */
DEFAULT_PREFIX: 'aaa',
/** Maximum attempts for generating vanity wallet before giving up */
DEFAULT_MAX_ATTEMPTS: 1000000,
/** Whether prefix matching should be case sensitive (false = ignore case) */
DEFAULT_CASE_SENSITIVE: false,
/** Progress update interval in number of attempts (for progress callbacks) */
PROGRESS_UPDATE_INTERVAL: 1000,
/** Non-blocking interval to allow event loop to breathe (prevents UI freezing) */
NON_BLOCKING_INTERVAL: 10000,
/** Maximum prefix length allowed (for performance and security reasons) */
MAX_PREFIX_LENGTH: 10,
/** Maximum attempts limit as a safety cap to prevent infinite loops */
MAX_ATTEMPTS_LIMIT: 10000000,
// Mobile-optimized settings
/** Mobile-optimized prefix (much easier to find) */
MOBILE_DEFAULT_PREFIX: 'a',
/** Mobile-optimized max attempts (faster completion) */
MOBILE_DEFAULT_MAX_ATTEMPTS: 50000,
/** Mobile-optimized progress update interval (more frequent updates) */
MOBILE_PROGRESS_UPDATE_INTERVAL: 500,
/** Mobile-optimized non-blocking interval (more frequent yields) */
MOBILE_NON_BLOCKING_INTERVAL: 1000,
/** Batch size for mobile processing (process multiple attempts in batches) */
MOBILE_BATCH_SIZE: 100,
/** Mobile timeout in milliseconds (prevent infinite running) */
MOBILE_TIMEOUT_MS: 30000, // 30 seconds
};
/**
* Security configuration constants
*/
exports.SECURITY_CONFIG = {
/** AES key size in bits */
AES_KEY_SIZE: 256,
/** Salt length in bytes */
SALT_LENGTH: 16,
/** IV length in bytes */
IV_LENGTH: 12,
/** Minimum password length */
MIN_PASSWORD_LENGTH: 8,
/** Maximum vault unlock attempts before lockout */
MAX_UNLOCK_ATTEMPTS: 5,
/** Lockout duration in milliseconds */
LOCKOUT_DURATION: 300000, // 5 minutes
};
/**
* Get PBKDF2 iterations based on environment
* @returns Number of iterations (5000 for development, 10000 for production)
*/
function getPBKDF2Iterations() {
return process.env.NODE_ENV === 'production' ? 3000 : 2500;
}
/**
* Network configuration constants
*/
exports.NETWORK_CONFIG = {
/** Default timeout for RPC calls in milliseconds */
RPC_TIMEOUT: 30000,
/** Retry attempts for failed RPC calls */
RPC_RETRY_ATTEMPTS: 3,
/** Delay between retry attempts in milliseconds */
RPC_RETRY_DELAY: 1000,
/** Maximum batch size for multi-transfer operations */
MAX_BATCH_SIZE: 50,
/** Delay between batches in milliseconds */
BATCH_DELAY: 500,
};
/**
* Cache configuration constants
*/
exports.CACHE_CONFIG = {
/** Default cache TTL in milliseconds */
DEFAULT_TTL: 30000, // 30 seconds
/** Balance cache TTL in milliseconds */
BALANCE_TTL: 60000, // 1 minute
/** Token info cache TTL in milliseconds */
TOKEN_INFO_TTL: 300000, // 5 minutes
/** Transaction cache TTL in milliseconds */
TRANSACTION_TTL: 600000, // 10 minutes
/** Maximum cache size in number of entries */
MAX_CACHE_SIZE: 1000,
};
/**
* Validation configuration constants
*/
exports.VALIDATION_CONFIG = {
/** Minimum address length */
MIN_ADDRESS_LENGTH: 26,
/** Maximum address length */
MAX_ADDRESS_LENGTH: 44,
/** Minimum amount for transfers */
MIN_TRANSFER_AMOUNT: '0.000001',
/** Maximum amount for transfers (safety limit) */
MAX_TRANSFER_AMOUNT: '1000000',
/** Maximum decimal places for amounts */
MAX_DECIMAL_PLACES: 18,
};