diff --git a/cronoswallet/index.html b/cronoswallet/index.html index e226d67..aa9f96e 100644 --- a/cronoswallet/index.html +++ b/cronoswallet/index.html @@ -469,14 +469,14 @@ if (window.matchMedia('(min-width: 640px)').matches) { // Desktop: offset from left navbar Object.assign(panel.style, { - left: 'calc(10rem + 1rem)', - bottom: '1rem', - top: 'auto', + left: 'auto', + bottom: 'auto', + top: '1rem', right: '1rem', // optional, lets long toasts wrap before content edge zIndex: '1000' }); } else { - // Mobile: keep top-right or top-left as you prefer + // Mobile: keep top-right or top-center as you prefer Object.assign(panel.style, { left: '0.5rem', top: '0.5rem', @@ -497,6 +497,7 @@ cro: ` `, usdc: ` `, usdt: `tether-usdt-logo`, + wcro: ` `, } window.smCompConfig = { 'sm-input': [ @@ -664,7 +665,7 @@ - @@ -735,12 +736,13 @@ } const renderedContacts = [] for (const floAddress in contacts) { - const { ethAddress } = contacts[floAddress] + const { ethAddress, btcAddress } = contacts[floAddress] renderedContacts.push(html` ${floAddress === ethAddress ? html` `: html` e.target.closest('.contact').querySelector('sm-copy').value = e.target.value}> + ${btcAddress ? html`BTC` : ''} FLO CRO @@ -766,7 +768,7 @@ let allTransactions = []; const TRANSACTIONS_PER_PAGE = 10; - function checkBalance(ethAddress, floAddress) { + function checkBalance(ethAddress, floAddress, btcAddress) { if (ethAddress) { // If address is provided sync the input box const searchInput = document.querySelector('#check_balance_input'); @@ -786,6 +788,18 @@ return; } + // Reject FLO addresses (start with F and len 34) + if (/^[F][a-km-zA-HJ-NP-Z1-9]{26,34}$/.test(keyToConvert)) { + notify('FLO addresses are not supported. Please use a Cronos address or private key.', 'error'); + return; + } + + // Reject BTC addresses (legacy 1/3, segwit bc1) + if (/^(1|3)[a-km-zA-HJ-NP-Z1-9]{25,34}$/.test(keyToConvert) || /^bc1[a-z0-9]{39,59}$/i.test(keyToConvert)) { + notify('BTC addresses are not supported. Please use a Cronos address or private key.', 'error'); + return; + } + // Check if it's a valid Ethereum address if (ethOperator.isValidAddress(keyToConvert)) { ethAddress = keyToConvert @@ -804,8 +818,9 @@ const ethPrivateKey = coinjs.wif2privkey(keyToConvert).privkey; ethAddress = floEthereum.ethAddressFromPrivateKey(ethPrivateKey) floAddress = floCrypto.getFloID(keyToConvert) + btcAddress = btcOperator.bech32Address(keyToConvert) } catch (error) { - notify('Invalid input. Please enter a valid Ethereum address or private key.', 'error'); + notify('Invalid input. Please enter a valid Cronos address, private key, or tx hash.', 'error'); return; } } @@ -817,10 +832,10 @@ currentAddress = ethAddress; currentFloAddress = floAddress; - loadTransactionsPage(ethAddress, floAddress, currentPage); + loadTransactionsPage(ethAddress, floAddress, currentPage, btcAddress); } - async function loadTransactionsPage(ethAddress, floAddress, page) { + async function loadTransactionsPage(ethAddress, floAddress, page, btcAddress) { buttonLoader('check_balance_button', true); try { @@ -867,6 +882,7 @@ if (result) return compactIDB.addData('contacts', { ethAddress, + btcAddress }, floAddress || ethAddress).then(() => { renderSearchedAddressList() }).catch((error) => { @@ -1768,7 +1784,7 @@ // BTC bech32 from WIF const btcBech32 = btcOperator.bech32Address(wif); //const btcPriv = btcOperator.convert.wif(wif); - //const floPriv = btcOperator.convert.wif(wif, 0xa3); + //const floPriv = btcOperator.convert.wif(wif, 0xa3); // FLO from WIF const floAddress = floCrypto.getFloID(wif); @@ -1778,14 +1794,12 @@ renderElem(outEl, html` - BTC Address: FLO Address: CRO Address: - `); @@ -1846,24 +1860,31 @@ const { floID, privKey } = floCrypto.generateNewID(); const ethPrivateKey = coinjs.wif2privkey(privKey).privkey; const ethAddress = floEthereum.ethAddressFromPrivateKey(ethPrivateKey) + const btcAddress = btcOperator.bech32Address(privKey); + const btcPrivKey = btcOperator.convert.wif(privKey, 0x80); // 0x80 for BTC Mainnet + renderElem(getRef('created_address_wrapper'), html` - + FLO Address - - Private Key - - - Equivalent Cronos Address - + + + Bitcoin Address + + Private Key + - + + + + Cronos Address + Private Key