Workflow updating files of floethereum

This commit is contained in:
RanchiMall Dev 2026-01-23 18:57:41 +00:00
parent 139dba4cd9
commit 2278af46ed

View File

@ -92,66 +92,65 @@
</button>
<theme-toggle></theme-toggle>
</header>
<nav id="main_navbar">
<ul>
<li>
<a class="nav-item nav-item--active interactive" href="#/balance">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24"
width="24px" fill="#000000">
<path d="M0 0h24v24H0V0z" fill="none" />
<path
d="M21 7.28V5c0-1.1-.9-2-2-2H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-2.28c.59-.35 1-.98 1-1.72V9c0-.74-.41-1.37-1-1.72zM20 9v6h-7V9h7zM5 19V5h14v2h-6c-1.1 0-2 .9-2 2v6c0 1.1.9 2 2 2h6v2H5z" />
<circle cx="16" cy="12" r="1.5" />
</svg>
<span class="nav-item__title">
Balance
</span>
<div class="nav-item__indicator"></div>
</a>
</li>
<li>
<a class="nav-item interactive" href="#/send">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24"
width="24px" fill="#000000">
<path d="M0 0h24v24H0V0z" fill="none"></path>
<path
d="M4.01 6.03l7.51 3.22-7.52-1 .01-2.22m7.5 8.72L4 17.97v-2.22l7.51-1M2.01 3L2 10l15 2-15 2 .01 7L23 12 2.01 3z">
</path>
</svg>
<span class="nav-item__title">
Send
</span>
</a>
</li>
<li>
<a class="nav-item interactive" href="#/create">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24"
width="24px" fill="#000000">
<path d="M0 0h24v24H0V0z" fill="none"></path>
<path
d="M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4V7zm-1-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z">
</path>
</svg>
<span class="nav-item__title">
Create
</span>
</a>
</li>
<li>
<a class="nav-item interactive" href="#/retrieve">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24"
width="24px" fill="#000000">
<path d="M0 0h24v24H0V0z" fill="none" />
<path
d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z" />
</svg>
<span class="nav-item__title">
Retrieve
</span>
</a>
</li>
</ul>
</nav>
<nav id="main_navbar">
<ul>
<li>
<a class="nav-item nav-item--active interactive" href="#/balance">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24"
width="24px" fill="#000000">
<path d="M0 0h24v24H0V0z" fill="none" />
<path
d="M21 7.28V5c0-1.1-.9-2-2-2H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-2.28c.59-.35 1-.98 1-1.72V9c0-.74-.41-1.37-1-1.72zM20 9v6h-7V9h7zM5 19V5h14v2h-6c-1.1 0-2 .9-2 2v6c0 1.1.9 2 2 2h6v2H5z" />
<circle cx="16" cy="12" r="1.5" />
</svg>
<span class="nav-item__title">
Balance
</span>
<div class="nav-item__indicator"></div>
</a>
</li>
<li>
<a class="nav-item interactive" href="#/send">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24"
width="24px" fill="#000000">
<path d="M0 0h24v24H0V0z" fill="none"></path>
<path
d="M4.01 6.03l7.51 3.22-7.52-1 .01-2.22m7.5 8.72L4 17.97v-2.22l7.51-1M2.01 3L2 10l15 2-15 2 .01 7L23 12 2.01 3z">
</path>
</svg>
<span class="nav-item__title">
Send
</span>
</a>
</li>
<li>
<a class="nav-item interactive" href="#/create">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24"
width="24px" fill="#000000">
<path d="M0 0h24v24H0V0z" fill="none"></path>
<path
d="M13 7h-2v4H7v2h4v4h2v-4h4v-2h-4V7zm-1-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z">
</path>
</svg>
<span class="nav-item__title">
Create
</span>
</a>
</li>
<li>
<a class="nav-item interactive" href="#/retrieve">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24"
width="24px" fill="#000000">
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z" />
</svg>
<span class="nav-item__title">
Retrieve
</span>
</a>
</li>
</ul>
</nav>
<div id="page_container"></div>
</main>
@ -460,37 +459,37 @@
}
}
//Moving notification draw so that it does not overlap the menu item
(function placeToasts() {
const drawer = document.getElementById('notification_drawer');
const panel = drawer?.shadowRoot?.querySelector('.notification-panel');
if (!panel) return;
//Moving notification draw so that it does not overlap the menu item
(function placeToasts() {
const drawer = document.getElementById('notification_drawer');
const panel = drawer?.shadowRoot?.querySelector('.notification-panel');
if (!panel) return;
const apply = () => {
if (window.matchMedia('(min-width: 640px)').matches) {
// Desktop: offset from left navbar
Object.assign(panel.style, {
left: 'calc(10rem + 1rem)',
bottom: '1rem',
top: 'auto',
right: '1rem', // optional, lets long toasts wrap before content edge
zIndex: '1000'
});
} else {
// Mobile: keep top-right or top-left as you prefer
Object.assign(panel.style, {
left: '0.5rem',
top: '0.5rem',
right: '0.5rem',
bottom: 'auto',
zIndex: '1000'
});
}
};
const apply = () => {
if (window.matchMedia('(min-width: 640px)').matches) {
// Desktop: top-right corner
Object.assign(panel.style, {
left: 'auto',
top: '1rem',
right: '1rem',
bottom: 'auto',
zIndex: '1000'
});
} else {
// Mobile: top-center
Object.assign(panel.style, {
left: '0.5rem',
top: '0.5rem',
right: '0.5rem',
bottom: 'auto',
zIndex: '1000'
});
}
};
apply();
window.addEventListener('resize', apply);
})();
apply();
window.addEventListener('resize', apply);
})();
</script>
<script>
@ -567,79 +566,79 @@
let idbReady;
window.addEventListener('load', () => {
// Initialize the database before any routing or data reads
idbReady = compactIDB.initDB('floEthereum', { contacts: {} })
.then((res) => { console.log(res); })
.catch((err) => { console.error(err); });
// Initialize the database before any routing or data reads
idbReady = compactIDB.initDB('floEthereum', { contacts: {} })
.then((res) => { console.log(res); })
.catch((err) => { console.error(err); });
// Set up event listeners and routing after database is ready
idbReady.then(() => {
const routeNow = () => router.routeTo(location.hash);
// Set up event listeners and routing after database is ready
idbReady.then(() => {
const routeNow = () => router.routeTo(location.hash);
// Set up UI event listeners for copy notifications and ripple effects
document.addEventListener('copy', () => notify('copied', 'success'));
document.addEventListener('pointerdown', (e) => {
const target = e.target.closest('button:not(:disabled), .interactive:not(:disabled)');
if (target) createRipple(e, target);
});
// Handle Ethereum provider and MetaMask connection
if (window.ethereum) {
window.ethereum.on('chainChanged', (chainId) => {
window.currentChainId = chainId;
if (chainId !== '0x1') {
renderError('Please switch MetaMask to Ethereum Mainnet');
} else {
routeNow();
}
});
window.ethereum.request({ method: 'eth_chainId' })
.then((chainId) => {
window.currentChainId = chainId;
if (chainId !== '0x1') {
renderError('Please switch MetaMask to Ethereum Mainnet');
} else {
routeNow();
}
})
.catch(() => {
// If reading chain id fails, still render the app
routeNow();
// Set up UI event listeners for copy notifications and ripple effects
document.addEventListener('copy', () => notify('copied', 'success'));
document.addEventListener('pointerdown', (e) => {
const target = e.target.closest('button:not(:disabled), .interactive:not(:disabled)');
if (target) createRipple(e, target);
});
// Listen for MetaMask account changes
ethereum.on('accountsChanged', (accounts) => {
getRef('eth_balance_wrapper').classList.add('hidden');
setMetaMaskStatus(accounts.length > 0);
});
ethereum.on('connect', (accounts) => {
setMetaMaskStatus(accounts.length > 0);
});
ethereum.on('disconnect', (accounts) => {
setMetaMaskStatus(false);
});
} else {
// No MetaMask detected, proceed with normal routing
routeNow();
}
// Handle Ethereum provider and MetaMask connection
if (window.ethereum) {
window.ethereum.on('chainChanged', (chainId) => {
window.currentChainId = chainId;
if (chainId !== '0x1') {
renderError('Please switch MetaMask to Ethereum Mainnet');
} else {
routeNow();
}
});
// 3) Reveal UI only after were safe to render
document.body.classList.remove('hidden');
});
window.ethereum.request({ method: 'eth_chainId' })
.then((chainId) => {
window.currentChainId = chainId;
if (chainId !== '0x1') {
renderError('Please switch MetaMask to Ethereum Mainnet');
} else {
routeNow();
}
})
.catch(() => {
// If reading chain id fails, still render the app
routeNow();
});
// Listen for MetaMask account changes
ethereum.on('accountsChanged', (accounts) => {
getRef('eth_balance_wrapper').classList.add('hidden');
setMetaMaskStatus(accounts.length > 0);
});
ethereum.on('connect', (accounts) => {
setMetaMaskStatus(accounts.length > 0);
});
ethereum.on('disconnect', (accounts) => {
setMetaMaskStatus(false);
});
} else {
// No MetaMask detected, proceed with normal routing
routeNow();
}
// 3) Reveal UI only after were safe to render
document.body.classList.remove('hidden');
});
});
// Process pending notifications after a delay to ensure custom elements are ready
setTimeout(() => {
if (window._pendingNotifications && window._pendingNotifications.length > 0) {
const notificationDrawer = getRef("notification_drawer");
if (notificationDrawer && typeof notificationDrawer.push === 'function') {
window._pendingNotifications.forEach(({ message, icon, options }) => {
notificationDrawer.push(message, { icon, ...options });
});
window._pendingNotifications = [];
if (window._pendingNotifications && window._pendingNotifications.length > 0) {
const notificationDrawer = getRef("notification_drawer");
if (notificationDrawer && typeof notificationDrawer.push === 'function') {
window._pendingNotifications.forEach(({ message, icon, options }) => {
notificationDrawer.push(message, { icon, ...options });
});
window._pendingNotifications = [];
}
}
}
}, 1000); // Give custom elements time to fully initialize
@ -665,7 +664,7 @@
</h2>
<sm-form oninvalid="handleInvalidSearch()">
<div id="input_wrapper">
<sm-input id="check_balance_input" class="password-field flex-1" placeholder="Address, private key, or tx hash"
<sm-input id="check_balance_input" class="password-field flex-1" placeholder="ETH address, private key, or tx hash"
type="password" animate>
<svg class="icon" slot="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"> <g> <rect fill="none" height="24" width="24"></rect> </g> <g> <path d="M21,10h-8.35C11.83,7.67,9.61,6,7,6c-3.31,0-6,2.69-6,6s2.69,6,6,6c2.61,0,4.83-1.67,5.65-4H13l2,2l2-2l2,2l4-4.04L21,10z M7,15c-1.65,0-3-1.35-3-3c0-1.65,1.35-3,3-3s3,1.35,3,3C10,13.65,8.65,15,7,15z"> </path> </g> </svg>
<label slot="right" class="interact">
@ -777,6 +776,18 @@
return;
}
// Reject FLO addresses (start with F)
if (/^F[a-km-zA-HJ-NP-Z1-9]{26,34}$/.test(keyToConvert)) {
notify('FLO addresses are not supported. Please use an ETH 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 an ETH address or private key.', 'error');
return;
}
// Check if it's a valid Ethereum address
if (ethOperator.isValidAddress(keyToConvert)) {
ethAddress = keyToConvert
@ -914,9 +925,9 @@
<div class="flex align-center space-between">
<h4>Transactions</h4>
<sm-chips id="tx_filter_chips" onchange=${(e) => {
const selectedValue = e.detail?.value || e.target.value || 'all';
filterTransactions(selectedValue, transactions, ethAddress);
}}>
const selectedValue = e.detail?.value || e.target.value || 'all';
filterTransactions(selectedValue, transactions, ethAddress);
}}>
<sm-chip value="all" selected>All</sm-chip>
<sm-chip value="sent">Sent</sm-chip>
<sm-chip value="received">Received</sm-chip>
@ -1086,13 +1097,13 @@
<div class="flex align-center space-between">
<h3>Transaction Details</h3>
<button class="button button--small" onclick=${() => {
const url = new URL(window.location);
url.searchParams.delete('tx');
window.history.pushState({}, '', url.pathname + url.search + url.hash);
const url = new URL(window.location);
url.searchParams.delete('tx');
window.history.pushState({}, '', url.pathname + url.search + url.hash);
// Go back to address view
handleUrlParams();
}}>
// Go back to address view
handleUrlParams();
}}>
Back
</button>
</div>
@ -1628,10 +1639,10 @@
// ROUTE: Retrieve
router.addRoute('retrieve', (state) => {
const container = getRef('page_container');
container.dataset.page = 'retrieve';
const container = getRef('page_container');
container.dataset.page = 'retrieve';
renderElem(container, html`
renderElem(container, html`
<sm-form id="retrieve_form" style="width: min(32rem, 100%)">
<!-- Block 1 (like Sender block) -->
<fieldset class="flex flex-direction-column gap-0-5">
@ -1678,70 +1689,70 @@
}
function retrieveAddress() {
const outEl = getRef('retrieve_result');
const inpEl = getRef('retrieve_key_input');
let input = getRef('retrieve_key_input').value?.trim();
let usedSecret = false;
const outEl = getRef('retrieve_result');
const inpEl = getRef('retrieve_key_input');
let input = getRef('retrieve_key_input').value?.trim();
let usedSecret = false;
let wif = '';
let ethPriv = '';
if (!input) {
notify('Please enter an ETH address, WIF, or 64-hex private key', 'error');
renderElem(outEl, html``);
outEl.classList.add('hidden');
return;
}
if (!input) {
notify('Please enter an ETH address, WIF, or 64-hex private key', 'error');
renderElem(outEl, html``);
outEl.classList.add('hidden');
return;
}
try {
// Loading hint
renderElem(outEl, html`<div class="muted">Resolving…</div>`);
outEl.classList.remove('hidden');
try {
// Loading hint
renderElem(outEl, html`<div class="muted">Resolving…</div>`);
outEl.classList.remove('hidden');
// Detect ETH address (without private key)
const isEthAddrRegex = /^0x[0-9a-fA-F]{40}$/;
const isEthAddress = (typeof ethOperator !== 'undefined' && ethOperator.isValidAddress?.(input))
|| isEthAddrRegex.test(input);
// Detect ETH address (without private key)
const isEthAddrRegex = /^0x[0-9a-fA-F]{40}$/;
const isEthAddress = (typeof ethOperator !== 'undefined' && ethOperator.isValidAddress?.(input))
|| isEthAddrRegex.test(input);
if (isEthAddress) {
// We cannot derive BTC/FLO from an address alone (no private key)
const normalizedEth = input.toLowerCase();
renderElem(outEl, html`
if (isEthAddress) {
// We cannot derive BTC/FLO from an address alone (no private key)
const normalizedEth = input.toLowerCase();
renderElem(outEl, html`
<div class="card grid gap-0-5">
<span class="label">Resolved</span>
<div><strong>ETH address</strong>: <sm-copy value="${normalizedEth}"></sm-copy></div>
<div class="muted">BTC/FLO cannot be derived from an address without the private key.</div>
</div>
`);
return;
}
return;
}
// Normalize to WIF if the input is a raw 64-hex private key
usedSecret = true;
// Normalize to WIF if the input is a raw 64-hex private key
usedSecret = true;
let wif = input;
const is64Hex = /^[0-9a-fA-F]{64}$/.test(input);
if (is64Hex) {
wif = coinjs.privkey2wif(input); // hex → WIF
}
let wif = input;
const is64Hex = /^[0-9a-fA-F]{64}$/.test(input);
if (is64Hex) {
wif = coinjs.privkey2wif(input); // hex → WIF
}
// From WIF, derive ETH private key (hex)
const ethPriv = coinjs.wif2privkey(wif).privkey;
// From WIF, derive ETH private key (hex)
const ethPriv = coinjs.wif2privkey(wif).privkey;
// ETH address from private key
const ethAddress = floEthereum.ethAddressFromPrivateKey(ethPriv);
// ETH address from private key
const ethAddress = floEthereum.ethAddressFromPrivateKey(ethPriv);
// BTC bech32 from WIF
const btcBech32 = btcOperator.bech32Address(wif);
//const btcPriv = btcOperator.convert.wif(wif);
//const floPriv = btcOperator.convert.wif(wif, 0xa3);
// BTC bech32 from WIF
const btcBech32 = btcOperator.bech32Address(wif);
//const btcPriv = btcOperator.convert.wif(wif);
//const floPriv = btcOperator.convert.wif(wif, 0xa3);
// FLO from WIF
const floAddress = floCrypto.getFloID(wif);
// FLO from WIF
const floAddress = floCrypto.getFloID(wif);
// Render results
renderElem(outEl, html`
// Render results
renderElem(outEl, html`
<div class="card grid gap-1">
@ -1755,29 +1766,29 @@
</div>
`);
} catch (e) {
notify('Could not retrieve from the provided value', 'error');
renderElem(outEl, html``);
outEl.classList.add('hidden');
}
} catch (e) {
notify('Could not retrieve from the provided value', 'error');
renderElem(outEl, html``);
outEl.classList.add('hidden');
}
finally {
if (usedSecret && inpEl) {
const wipe = (s) => (typeof s === 'string' ? s.replace(/./g, '\0') : s);
input = typeof input === 'string' && input.length ? (wipe(input), null) : input;
wif = typeof wif === 'string' && wif.length ? (wipe(wif), null) : wif;
ethPriv = typeof ethPriv === 'string' && ethPriv.length ? (wipe(ethPriv), null) : ethPriv;
finally {
if (usedSecret && inpEl) {
const wipe = (s) => (typeof s === 'string' ? s.replace(/./g, '\0') : s);
input = typeof input === 'string' && input.length ? (wipe(input), null) : input;
wif = typeof wif === 'string' && wif.length ? (wipe(wif), null) : wif;
ethPriv = typeof ethPriv === 'string' && ethPriv.length ? (wipe(ethPriv), null) : ethPriv;
const inner = inpEl.shadowRoot?.querySelector('input[part="input"]');
if (inner) {
inner.value = '';
inner.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
if (typeof handleRetrieveInput === 'function') {
const inner = inpEl.shadowRoot?.querySelector('input[part="input"]');
if (inner) {
inner.value = '';
inner.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
if (typeof handleRetrieveInput === 'function') {
handleRetrieveInput({ target: inpEl });
}
}
}
}
}
}
}
}
@ -1812,6 +1823,9 @@
const { floID, privKey } = floCrypto.generateNewID();
const ethPrivateKey = coinjs.wif2privkey(privKey).privkey;
const ethAddress = floEthereum.ethAddressFromPrivateKey(ethPrivateKey)
const btcBech32 = btcOperator.bech32Address(privKey);
// Convert FLO WIF to Bitcoin WIF format (L/K prefix)
const btcPrivKey = btcOperator.convert.wif(privKey);
renderElem(getRef('created_address_wrapper'), html`
<ul id="generated_addresses" class="grid gap-1-5">
<li class="grid gap-0-5">
@ -1824,6 +1838,16 @@
<sm-copy value="${privKey}"></sm-copy>
</div>
</li>
<li class="grid gap-0-5">
<div>
<h5>Bitcoin Address</h5>
<sm-copy value="${btcBech32}"></sm-copy>
</div>
<div>
<h5>Private Key</h5>
<sm-copy value="${btcPrivKey}"></sm-copy>
</div>
</li>
<li class="grid gap-0-5">
<div>
<h5>Equivalent Ethereum Address</h5>