@cranberry-money/shared-constants
Version:
Shared constants for Blueberry platform
137 lines • 4.63 kB
JavaScript
export const WALLET_VERIFICATION_STATUS = {
PENDING: 'PENDING',
VERIFIED: 'VERIFIED',
};
export const WALLET_TYPE = {
HARDWARE: 'hardware',
SOFTWARE: 'software',
};
export const BLOCKCHAIN = {
ETHEREUM: 'ethereum',
BITCOIN: 'bitcoin',
POLYGON: 'polygon',
SOLANA: 'solana',
AVALANCHE: 'avalanche',
ARCA: 'arca',
};
export const SUPPORTED_CHAINS = [
{
code: BLOCKCHAIN.ETHEREUM,
name: 'Ethereum',
shortName: 'ETH',
isActive: true,
explorerTxUrl: 'https://etherscan.io/tx/',
addressPlaceholder: '0x...',
confirmationTime: '~2-3 minutes',
},
{
code: BLOCKCHAIN.BITCOIN,
name: 'Bitcoin',
shortName: 'BTC',
isActive: true,
explorerTxUrl: 'https://blockchain.com/btc/tx/',
addressPlaceholder: '1... or 3... or bc1...',
confirmationTime: '~10 minutes',
},
{
code: BLOCKCHAIN.POLYGON,
name: 'Polygon',
shortName: 'MATIC',
isActive: false,
explorerTxUrl: 'https://polygonscan.com/tx/',
addressPlaceholder: '0x...',
confirmationTime: '~2 minutes',
},
{
code: BLOCKCHAIN.SOLANA,
name: 'Solana',
shortName: 'SOL',
isActive: false,
explorerTxUrl: 'https://solscan.io/tx/',
addressPlaceholder: 'Enter address',
confirmationTime: '~1 minute',
},
{
code: BLOCKCHAIN.AVALANCHE,
name: 'Avalanche',
shortName: 'AVAX',
isActive: false,
explorerTxUrl: 'https://snowtrace.io/tx/',
addressPlaceholder: '0x...',
confirmationTime: '~2 minutes',
},
{
code: BLOCKCHAIN.ARCA,
name: 'Arca',
shortName: 'ARCA',
isActive: true,
explorerTxUrl: '', // Arca uses internal transaction display
addressPlaceholder: '0x...',
confirmationTime: '~2 seconds',
},
];
const chainByCode = new Map(SUPPORTED_CHAINS.map((c) => [c.code, c]));
const chainByShortName = new Map(SUPPORTED_CHAINS.map((c) => [c.shortName, c]));
export function getChainConfig(code) {
return chainByCode.get(code);
}
export function getChainByShortName(shortName) {
return chainByShortName.get(shortName);
}
export function getActiveChains() {
return SUPPORTED_CHAINS.filter((c) => c.isActive);
}
export function getChainName(chain) {
const normalized = chain?.toLowerCase() || '';
if (chainByCode.has(normalized))
return normalized;
const config = chainByShortName.get(chain?.toUpperCase() || '');
return config?.code || normalized;
}
export function getChainShortCode(chain) {
const normalized = chain?.toLowerCase() || '';
const config = chainByCode.get(normalized);
if (config)
return config.shortName;
const aliases = { btc: 'BTC', eth: 'ETH', sol: 'SOL', avax: 'AVAX' };
if (aliases[normalized])
return aliases[normalized];
const upper = chain?.toUpperCase() || '';
return chainByShortName.has(upper) ? upper : upper;
}
export function isEthereumChain(chainShortCode) {
return chainShortCode === 'ETH';
}
export function isBitcoinChain(chainShortCode) {
return chainShortCode === 'BTC';
}
export function getBlockchainDisplayName(chainShortCode) {
return chainByShortName.get(chainShortCode)?.name || chainShortCode;
}
export function getAddressPlaceholder(chainShortCode) {
return chainByShortName.get(chainShortCode)?.addressPlaceholder || 'Enter address';
}
export function getEstimatedConfirmationTime(chainShortCode) {
return chainByShortName.get(chainShortCode)?.confirmationTime || '~5 minutes';
}
export function getBlockExplorerTxUrl(chain, txHash) {
const normalized = chain?.toLowerCase() || '';
let config = chainByCode.get(normalized);
if (!config) {
const aliases = { btc: BLOCKCHAIN.BITCOIN, eth: BLOCKCHAIN.ETHEREUM };
if (aliases[normalized])
config = chainByCode.get(aliases[normalized]);
}
return `${config?.explorerTxUrl || 'https://etherscan.io/tx/'}${txHash}`;
}
export const BUYABLE_ASSETS = [
{ symbol: 'BTC', name: 'Bitcoin', chain: BLOCKCHAIN.BITCOIN },
{ symbol: 'ETH', name: 'Ethereum', chain: BLOCKCHAIN.ETHEREUM },
{ symbol: 'USDC', name: 'USD Coin', chain: BLOCKCHAIN.ETHEREUM },
{ symbol: 'USDT', name: 'Tether', chain: BLOCKCHAIN.ETHEREUM },
];
const TRANSFER_FEE_ESTIMATES = { BTC: 0.00005, ETH: 0.0005 };
export function getEstimatedFee(chainShortName) {
return TRANSFER_FEE_ESTIMATES[chainShortName] || TRANSFER_FEE_ESTIMATES.ETH;
}
//# sourceMappingURL=wallets.js.map