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="shortcut icon" href="flo-favicon.png" type="image/png">
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
<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 href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap" rel="stylesheet">
|
||||||
<link rel="stylesheet" href="css/main.min.css">
|
<link rel="stylesheet" href="css/main.min.css">
|
||||||
<script id="floGlobals">
|
<script id="floGlobals">
|
||||||
@ -291,11 +294,26 @@
|
|||||||
<span>BTC</span>
|
<span>BTC</span>
|
||||||
<span id="btc_balance"></span>
|
<span id="btc_balance"></span>
|
||||||
</div>
|
</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>
|
||||||
</div>
|
</div>
|
||||||
<sm-chips id="wallet_section__asset_selector" class="user-element">
|
<sm-chips id="wallet_section__asset_selector" class="user-element">
|
||||||
<sm-chip value="rupee" selected>Rupee</sm-chip>
|
<sm-chip value="rupee" selected>Rupee</sm-chip>
|
||||||
<sm-chip value="btc">BTC</sm-chip>
|
<sm-chip value="btc">BTC</sm-chip>
|
||||||
|
<sm-chip value="usdt_erc20">USDT ERC20</sm-chip>
|
||||||
</sm-chips>
|
</sm-chips>
|
||||||
<div id="asset_actions_wrapper" class="user-element">
|
<div id="asset_actions_wrapper" class="user-element">
|
||||||
<div class="grid gap-1-5">
|
<div class="grid gap-1-5">
|
||||||
@ -430,6 +448,33 @@
|
|||||||
Convert to Rupee
|
Convert to Rupee
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</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>
|
||||||
</div>
|
</div>
|
||||||
@ -1567,7 +1612,7 @@
|
|||||||
floGlobals.loaded = true
|
floGlobals.loaded = true
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
detectAdBlocker(error)
|
//detectAdBlocker(error)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
@ -3503,6 +3548,7 @@
|
|||||||
if (transactionsHistoryLoader) {
|
if (transactionsHistoryLoader) {
|
||||||
transactionsHistoryLoader.update(transactions)
|
transactionsHistoryLoader.update(transactions)
|
||||||
} else {
|
} else {
|
||||||
|
console.log(transactions);
|
||||||
transactionsHistoryLoader = new LazyLoader('#payments_history', transactions, render.transactionCard)
|
transactionsHistoryLoader = new LazyLoader('#payments_history', transactions, render.transactionCard)
|
||||||
}
|
}
|
||||||
transactionsHistoryLoader.init()
|
transactionsHistoryLoader.init()
|
||||||
@ -3710,6 +3756,7 @@
|
|||||||
.catch(reject);
|
.catch(reject);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBtcTransactions(type = 'all') {
|
function getBtcTransactions(type = 'all') {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (!floGlobals.myBtcID) {
|
if (!floGlobals.myBtcID) {
|
||||||
@ -3761,33 +3808,107 @@
|
|||||||
if (potentialTarget) potentialTarget.remove();
|
if (potentialTarget) potentialTarget.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function refreshBalance(button) {
|
|
||||||
if (button)
|
// Best-effort derivation of user's Ethereum address
|
||||||
buttonLoader(button, true)
|
async function getUserEthAddress() {
|
||||||
floTokenAPI.getBalance(floGlobals.myFloID).then((balance = 0) => {
|
try {
|
||||||
getRef('rupee_balance').textContent = formatAmount(balance)
|
// 1) Try explicit value if you already store it
|
||||||
if (button)
|
if (floGlobals.myEthID) return floGlobals.myEthID;
|
||||||
buttonLoader(button, false)
|
|
||||||
})
|
// 2) Derive from the same private key you already use elsewhere
|
||||||
btcOperator.getBalance(floGlobals.myBtcID).then((btcBalance = 0) => {
|
// Requires coinjs.wif2privkey and floEthereum.ethAddressFromPrivateKey
|
||||||
getRef('btc_balance').textContent = formatAmount(btcBalance, 'btc')
|
const privateKeyWIF = await floDapps.user.private;
|
||||||
})
|
if (!privateKeyWIF) return null;
|
||||||
try {
|
|
||||||
const [floBal, floRates] = await Promise.all([floBlockchainAPI.getBalance(floGlobals.myFloID), floExchangeAPI.getRates('FLO')])
|
if (window.coinjs && window.floEthereum) {
|
||||||
getRef('flo_balance').textContent = formatAmount(floBal, 'flo')
|
const { privkey } = coinjs.wif2privkey(privateKeyWIF);
|
||||||
if (floBal < floGlobals.settings.user_flo_threshold) {
|
return floEthereum.ethAddressFromPrivateKey(privkey);
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
} 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() {
|
function getArrayOfSavedIds() {
|
||||||
const arr = [];
|
const arr = [];
|
||||||
for (const key in floGlobals.contacts) {
|
for (const key in floGlobals.contacts) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user