After confirming the succes withdrawal2
This commit is contained in:
parent
3eb39c2e4a
commit
a1a8a04984
@ -319,7 +319,6 @@ async function buildWalletOpCardPayload(
|
||||
|
||||
const decimals = ledgerWt?.decimals ?? STAKE_DECIMALS;
|
||||
const amountRaw = BigInt(tx.amount);
|
||||
const feeRaw = BigInt(tx.fee || '0');
|
||||
const amountDisplay = rawToDisplay(amountRaw, decimals);
|
||||
const assetCode = displayWt?.code ?? ledgerWt?.code ?? 'USDT';
|
||||
const assetSymbol = shortAssetSymbol(assetCode);
|
||||
@ -337,16 +336,13 @@ async function buildWalletOpCardPayload(
|
||||
? buildReferralRegisterLink(opts.referralCode)
|
||||
: `${getPublicWebBaseUrl()}/register`;
|
||||
|
||||
let signedDisplay: string;
|
||||
if (tx.type === 'withdrawal') {
|
||||
const totalDisplay =
|
||||
feeRaw > 0n ? rawToDisplay(amountRaw + feeRaw, decimals) : amountDisplay;
|
||||
signedDisplay = `-${totalDisplay}`;
|
||||
} else if (tx.type === 'transfer') {
|
||||
signedDisplay = amountDisplay;
|
||||
} else {
|
||||
signedDisplay = `+${amountDisplay}`;
|
||||
}
|
||||
// Share cards are marketing-facing: show received/sent principal only (no platform fee).
|
||||
const signedDisplay =
|
||||
tx.type === 'withdrawal'
|
||||
? `-${amountDisplay}`
|
||||
: tx.type === 'transfer'
|
||||
? amountDisplay
|
||||
: `+${amountDisplay}`;
|
||||
|
||||
return {
|
||||
kind: 'wallet' as const,
|
||||
@ -356,7 +352,7 @@ async function buildWalletOpCardPayload(
|
||||
amountRaw: tx.amount,
|
||||
amountDisplay,
|
||||
amountSignedDisplay: signedDisplay,
|
||||
feeRaw: tx.fee,
|
||||
feeRaw: '0',
|
||||
assetCode,
|
||||
assetSymbol,
|
||||
assetName: displayWt?.name ?? assetCode,
|
||||
|
||||
@ -292,18 +292,6 @@ class _WalletCard extends StatelessWidget {
|
||||
_KV(s.t('Asset', 'Actif'), payload.assetName ?? payload.assetSymbol ?? ''),
|
||||
if ((payload.network ?? '').isNotEmpty)
|
||||
_KV(s.t('Network', 'Réseau'), payload.network!),
|
||||
if (payload.operationType == 'withdrawal' &&
|
||||
(payload.feeRaw ?? '0') != '0' &&
|
||||
(payload.feeRaw ?? '').isNotEmpty) ...[
|
||||
_KV(
|
||||
s.t('Withdrawn', 'Retiré'),
|
||||
'${payload.amountDisplay ?? ''} ${payload.assetSymbol ?? ''}'.trim(),
|
||||
),
|
||||
_KV(
|
||||
s.t('Fee', 'Frais'),
|
||||
'${_formatMicroUsdt(payload.feeRaw!)} ${payload.assetSymbol ?? ''}'.trim(),
|
||||
),
|
||||
],
|
||||
if (created != null) _KV(s.t('Date', 'Date'), _fmt(created)),
|
||||
],
|
||||
verifyUrl: payload.verifyUrl,
|
||||
@ -311,16 +299,6 @@ class _WalletCard extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
String _formatMicroUsdt(String raw, {int decimals = 6}) {
|
||||
final n = BigInt.tryParse(raw.trim()) ?? BigInt.zero;
|
||||
final base = BigInt.from(10).pow(decimals);
|
||||
final whole = n ~/ base;
|
||||
final frac = n % base;
|
||||
if (frac == BigInt.zero) return whole.toString();
|
||||
final fracStr = frac.toString().padLeft(decimals, '0').replaceAll(RegExp(r'0+$'), '');
|
||||
return '$whole.$fracStr';
|
||||
}
|
||||
|
||||
class _CardShell extends StatelessWidget {
|
||||
const _CardShell({
|
||||
required this.title,
|
||||
|
||||
@ -96,19 +96,6 @@ function PredictionCard({
|
||||
);
|
||||
}
|
||||
|
||||
function formatMicroUsdt(raw: string, decimals = 6): string {
|
||||
try {
|
||||
const n = BigInt(raw);
|
||||
const base = 10n ** BigInt(decimals);
|
||||
const whole = n / base;
|
||||
const frac = n % base;
|
||||
if (frac === 0n) return whole.toString();
|
||||
return `${whole.toString()}.${frac.toString().padStart(decimals, '0').replace(/0+$/, '')}`;
|
||||
} catch {
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
|
||||
function WalletOpCard({
|
||||
payload,
|
||||
cardRef,
|
||||
@ -149,22 +136,6 @@ function WalletOpCard({
|
||||
/>
|
||||
<Row label={t('shareCard.asset')} value={payload.assetName} />
|
||||
{payload.network ? <Row label={t('shareCard.network')} value={payload.network} /> : null}
|
||||
{payload.operationType === 'withdrawal' &&
|
||||
payload.feeRaw &&
|
||||
payload.feeRaw !== '0' ? (
|
||||
<Row
|
||||
label={t('shareCard.fee', { defaultValue: 'Fee' })}
|
||||
value={`${formatMicroUsdt(payload.feeRaw)} ${payload.assetSymbol}`}
|
||||
/>
|
||||
) : null}
|
||||
{payload.operationType === 'withdrawal' &&
|
||||
payload.feeRaw &&
|
||||
payload.feeRaw !== '0' ? (
|
||||
<Row
|
||||
label={t('shareCard.withdrawn', { defaultValue: 'Withdrawn' })}
|
||||
value={`${payload.amountDisplay} ${payload.assetSymbol}`}
|
||||
/>
|
||||
) : null}
|
||||
<Row
|
||||
label={t('shareCard.date')}
|
||||
value={created.toLocaleString(undefined, { dateStyle: 'medium', timeStyle: 'short' })}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user