const { TOKENOMICS_CONFIG } = require('./tokenomicsConfig');

const COIN_CONFIG = Object.freeze({
  assetRole: 'legacy-application-point',
  canonical: false,
  chainName: TOKENOMICS_CONFIG.chainName,
  networkId: process.env.AISFOR_CHAIN_NETWORK_ID || 'plai-testnet-0',
  name: TOKENOMICS_CONFIG.tokenDisplayName,
  symbol: TOKENOMICS_CONFIG.symbol,
  decimals: TOKENOMICS_CONFIG.decimals,
  totalSupply: TOKENOMICS_CONFIG.maxSupply,
  issuance: process.env.AISFOR_COIN_ISSUANCE || 'legacy-simulation-locked',
  convertibleToCanonical: false,
  genesisLabel: process.env.AISFOR_GENESIS_LABEL || 'plais Foundation Treasury',
  addressPrefix: process.env.AISFOR_WALLET_ADDRESS_PREFIX || 'plai'
});

function toDisplayAmount(amount) {
  const value = Number(amount || 0);
  return Number.isFinite(value) ? value.toFixed(6).replace(/\.0+$/, '').replace(/(\.\d*?)0+$/, '$1') : '0';
}

module.exports = {
  COIN_CONFIG,
  toDisplayAmount
};
