diff options
Diffstat (limited to 'src/features')
| -rw-r--r-- | src/features/ark.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/features/ark.js b/src/features/ark.js index 538246d..39936ac 100644 --- a/src/features/ark.js +++ b/src/features/ark.js @@ -27,6 +27,7 @@ import { getNetwork, setNetwork, getArkProviderId, getArkConfig, setArkProviderId, arkPresets, getArkCustom, setArkCustom, } from '../api.js'; import { t } from '../i18n.js'; +import { rateNow } from '../rates.js'; import { resolveBip353, parsePaymentName, parseBip21 as parseBip21Uri } from '../bip353.js'; import { parseZapTarget, fetchPayParams, requestInvoice } from '../lnurl.js'; import { shortAddr, shortTxid, timeAgo, fmtSats, ARK_ICON, ARK_MARK, BITCOIN_ICON } from '../format.js'; @@ -370,6 +371,13 @@ export function adoptArkSnapshot(manager, snapshot) { export function arkFeature(ctx) { const { h, ui, render, wallet, blankSend, fmtAmount, unitLabel, unitTag, copyBtn, toast, openExternal } = ctx; + // Auto-pay budgets on offer: round money in the user's currency when that's + // the unit on screen ($1, $5, $10, $100, kept as sats at today's rate), + // round sats otherwise. + const budgetChoices = () => { + const rate = ctx.getUnit && ctx.getUnit() === 'fiat' && rateNow(); + return rate ? [1, 5, 10, 100].map((f) => Math.ceil((f / rate) * 1e8)) : [1000, 5000, 10000, 100000]; + }; installArkWallet(wallet); // ark state storage lives outside the core wallet // Ride the encrypted sync snapshot so ark funds follow the seed across @@ -1298,7 +1306,7 @@ export function arkFeature(ctx) { ? h('div', { class: 'col', style: 'gap:6px' }, h('span', { class: 'small muted' }, t('lnAutopaySetLabel', { name: zap.name || zap.address || '' })), h('div', { class: 'row gap6', style: 'flex-wrap:wrap' }, - ...[1000, 5000, 10000, 100000].map((amt) => + ...budgetChoices().map((amt) => h('button', { type: 'button', class: (p.setBudget === amt ? 'btn-primary' : 'btn-ghost') + ' btn-sm', onClick: () => { p.setBudget = p.setBudget === amt ? 0 : amt; render(); } }, |
