Workflow updating files of flopay
This commit is contained in:
parent
292736d701
commit
d4599b17e9
@ -10,6 +10,9 @@
|
||||
<link rel="shortcut icon" href="flo-favicon.png" type="image/png">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
|
||||
|
||||
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="css/main.min.css">
|
||||
<script id="floGlobals">
|
||||
@ -291,11 +294,26 @@
|
||||
<span>BTC</span>
|
||||
<span id="btc_balance"></span>
|
||||
</div>
|
||||
<div class="flex align-center space-between balance-card">
|
||||
<span>Ether</span>
|
||||
<span id="eth_balance"></span>
|
||||
</div>
|
||||
<div class="flex align-center space-between balance-card">
|
||||
<span>USDC (ERC-20)</span>
|
||||
<span id="usdc_erc20_balance"></span>
|
||||
</div>
|
||||
<!-- If you don’t already have it, keep the USDT line too -->
|
||||
<div class="flex align-center space-between balance-card">
|
||||
<span>USDT (ERC-20)</span>
|
||||
<span id="usdt_erc20_balance"></span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<sm-chips id="wallet_section__asset_selector" class="user-element">
|
||||
<sm-chip value="rupee" selected>Rupee</sm-chip>
|
||||
<sm-chip value="btc">BTC</sm-chip>
|
||||
<sm-chip value="usdt_erc20">USDT ERC20</sm-chip>
|
||||
</sm-chips>
|
||||
<div id="asset_actions_wrapper" class="user-element">
|
||||
<div class="grid gap-1-5">
|
||||
@ -430,6 +448,33 @@
|
||||
Convert to Rupee
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="actions-wrapper hidden">
|
||||
<button class="wallet-action" onclick="openPopup('send_usdt_erc20_popup')">
|
||||
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24"
|
||||
width="24px" fill="#000000">
|
||||
<path d="M0 0h24v24H0z" fill="none" />
|
||||
<path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z" />
|
||||
</svg>
|
||||
Send USDT
|
||||
</button>
|
||||
<button class="wallet-action" onclick="initConversion('rupee')">
|
||||
<svg class="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" />
|
||||
</g>
|
||||
<g>
|
||||
<g>
|
||||
<path
|
||||
d="M13.66,7C13.1,5.82,11.9,5,10.5,5L6,5V3h12v2l-3.26,0c0.48,0.58,0.84,1.26,1.05,2L18,7v2l-2.02,0c-0.25,2.8-2.61,5-5.48,5 H9.77l6.73,7h-2.77L7,14v-2h3.5c1.76,0,3.22-1.3,3.46-3L6,9V7L13.66,7z" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
Request USDT
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@ -1567,7 +1612,7 @@
|
||||
floGlobals.loaded = true
|
||||
}).catch(error => {
|
||||
console.error(error)
|
||||
detectAdBlocker(error)
|
||||
//detectAdBlocker(error)
|
||||
})
|
||||
}
|
||||
}).catch(error => {
|
||||
@ -3503,6 +3548,7 @@
|
||||
if (transactionsHistoryLoader) {
|
||||
transactionsHistoryLoader.update(transactions)
|
||||
} else {
|
||||
console.log(transactions);
|
||||
transactionsHistoryLoader = new LazyLoader('#payments_history', transactions, render.transactionCard)
|
||||
}
|
||||
transactionsHistoryLoader.init()
|
||||
@ -3710,6 +3756,7 @@
|
||||
.catch(reject);
|
||||
});
|
||||
}
|
||||
|
||||
function getBtcTransactions(type = 'all') {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!floGlobals.myBtcID) {
|
||||
@ -3761,33 +3808,107 @@
|
||||
if (potentialTarget) potentialTarget.remove();
|
||||
}
|
||||
}
|
||||
async function refreshBalance(button) {
|
||||
if (button)
|
||||
buttonLoader(button, true)
|
||||
floTokenAPI.getBalance(floGlobals.myFloID).then((balance = 0) => {
|
||||
getRef('rupee_balance').textContent = formatAmount(balance)
|
||||
if (button)
|
||||
buttonLoader(button, false)
|
||||
})
|
||||
btcOperator.getBalance(floGlobals.myBtcID).then((btcBalance = 0) => {
|
||||
getRef('btc_balance').textContent = formatAmount(btcBalance, 'btc')
|
||||
})
|
||||
try {
|
||||
const [floBal, floRates] = await Promise.all([floBlockchainAPI.getBalance(floGlobals.myFloID), floExchangeAPI.getRates('FLO')])
|
||||
getRef('flo_balance').textContent = formatAmount(floBal, 'flo')
|
||||
if (floBal < floGlobals.settings.user_flo_threshold) {
|
||||
getRef('low_user_flo_warning').textContent = `Your FLO balance is low. You will receive ${floGlobals.settings.send_user_flo} FLO of worth ₹${parseFloat(floRates.rate.toFixed(2))} deducted from top-up amount.`;
|
||||
getRef('low_user_flo_warning').classList.remove('hidden');
|
||||
} else {
|
||||
getRef('low_user_flo_warning').classList.add('hidden');
|
||||
}
|
||||
if (button)
|
||||
buttonLoader(button, false)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
|
||||
// Best-effort derivation of user's Ethereum address
|
||||
async function getUserEthAddress() {
|
||||
try {
|
||||
// 1) Try explicit value if you already store it
|
||||
if (floGlobals.myEthID) return floGlobals.myEthID;
|
||||
|
||||
// 2) Derive from the same private key you already use elsewhere
|
||||
// Requires coinjs.wif2privkey and floEthereum.ethAddressFromPrivateKey
|
||||
const privateKeyWIF = await floDapps.user.private;
|
||||
if (!privateKeyWIF) return null;
|
||||
|
||||
if (window.coinjs && window.floEthereum) {
|
||||
const { privkey } = coinjs.wif2privkey(privateKeyWIF);
|
||||
return floEthereum.ethAddressFromPrivateKey(privkey);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('Unable to derive ETH address:', e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
async function refreshBalance(button) {
|
||||
if (button) buttonLoader(button, true);
|
||||
|
||||
// Rupee (unchanged)
|
||||
floTokenAPI.getBalance(floGlobals.myFloID).then((balance = 0) => {
|
||||
getRef('rupee_balance').textContent = formatAmount(balance);
|
||||
if (button) buttonLoader(button, false);
|
||||
});
|
||||
|
||||
// BTC (unchanged)
|
||||
btcOperator.getBalance(floGlobals.myBtcID).then((btcBalance = 0) => {
|
||||
getRef('btc_balance').textContent = formatAmount(btcBalance, 'btc');
|
||||
});
|
||||
|
||||
// FLO (unchanged)
|
||||
try {
|
||||
const [floBal, floRates] = await Promise.all([
|
||||
floBlockchainAPI.getBalance(floGlobals.myFloID),
|
||||
floExchangeAPI.getRates('FLO')
|
||||
]);
|
||||
getRef('flo_balance').textContent = formatAmount(floBal, 'flo');
|
||||
if (floBal < floGlobals.settings.user_flo_threshold) {
|
||||
getRef('low_user_flo_warning').textContent =
|
||||
`Your FLO balance is low. You will receive ${floGlobals.settings.send_user_flo} ` +
|
||||
`FLO of worth ₹${parseFloat(floRates.rate.toFixed(2))} deducted from top-up amount.`;
|
||||
getRef('low_user_flo_warning').classList.remove('hidden');
|
||||
} else {
|
||||
getRef('low_user_flo_warning').classList.add('hidden');
|
||||
}
|
||||
if (button) buttonLoader(button, false);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
// === NEW: ETH + USDC + USDT (ERC-20) ===
|
||||
try {
|
||||
// neutral placeholders while fetching
|
||||
const ethOut = getRef('eth_balance');
|
||||
const usdcOut = getRef('usdc_erc20_balance');
|
||||
const usdtOut = getRef('usdt_erc20_balance');
|
||||
if (ethOut) ethOut.textContent = '—';
|
||||
if (usdcOut) usdcOut.textContent = '—';
|
||||
if (usdtOut) usdtOut.textContent = '—';
|
||||
|
||||
const ethAddr = await getUserEthAddress();
|
||||
if (ethAddr && window.ethOperator) {
|
||||
const [ethBal, usdcBal, usdtBal] = await Promise.all([
|
||||
ethOperator.getBalance(ethAddr),
|
||||
ethOperator.getTokenBalance(ethAddr, 'usdc'),
|
||||
ethOperator.getTokenBalance(ethAddr, 'usdt'),
|
||||
]);
|
||||
|
||||
// ETH
|
||||
if (ethOut) ethOut.textContent = formatAmount(
|
||||
typeof ethBal === 'string' ? Number(ethBal) : (ethBal || 0), 'eth'
|
||||
);
|
||||
|
||||
// USDC (6 decimals typically; assume helper already returns display units)
|
||||
if (usdcOut) usdcOut.textContent = formatAmount(
|
||||
typeof usdcBal === 'string' ? Number(usdcBal) : (usdcBal || 0), 'usd'
|
||||
);
|
||||
|
||||
// USDT
|
||||
if (usdtOut) usdtOut.textContent = formatAmount(
|
||||
typeof usdtBal === 'string' ? Number(usdtBal) : (usdtBal || 0), 'usd'
|
||||
);
|
||||
}
|
||||
// If no ETH stack, placeholders remain
|
||||
} catch (e) {
|
||||
console.error('ERC-20 balance fetch failed:', e);
|
||||
if (getRef('eth_balance')) getRef('eth_balance').textContent = '—';
|
||||
if (getRef('usdc_erc20_balance')) getRef('usdc_erc20_balance').textContent = '—';
|
||||
if (getRef('usdt_erc20_balance')) getRef('usdt_erc20_balance').textContent = '—';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getArrayOfSavedIds() {
|
||||
const arr = [];
|
||||
for (const key in floGlobals.contacts) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user