Skip to content

Commit 0e87ea9

Browse files
Catryagrunch
andauthored
fix: show sats amount on fixed orders (#852)
* fix: restore sats amount in fixed order title * test: add regression test for sats amount in order title * test: type-check unit under test via ES import in ordersActions spec --------- Co-authored-by: grunch <fjcalderon@gmail.com>
1 parent fea5d84 commit 0e87ea9

12 files changed

Lines changed: 175 additions & 45 deletions

File tree

bot/ordersActions.ts

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,14 @@ const buildDescription = (
248248

249249
const ageInDays = getUserAge(user);
250250

251-
const firstLine = getOrderTitleMessage(user, type, i18n);
251+
const firstLine = getOrderTitleMessage(
252+
user,
253+
type,
254+
amount,
255+
fiatCode,
256+
priceFromAPI,
257+
i18n,
258+
);
252259

253260
let description: string = `${firstLine}\n`;
254261
description += i18n.t('for') + ` ${currencyString}\n`;
@@ -269,19 +276,34 @@ const buildDescription = (
269276
const getOrderTitleMessage = (
270277
user: UserDocument,
271278
type: string,
279+
amount: number,
280+
fiatCode: string,
281+
priceFromAPI: boolean,
272282
i18n: I18nContext,
273283
) => {
274284
const isSell = type === 'sell';
275285

286+
// For fixed orders we show the sats amount; for market/range orders
287+
// (priceFromAPI, amount === 0) the amount is omitted.
288+
const amountText = priceFromAPI ? '' : `${numberFormat(fiatCode, amount)} `;
289+
276290
// Guard Clause: The user DOES want to show their name, we resolve and leave.
277291
if (user.show_username) {
278292
return isSell
279-
? i18n.t('showusername_selling_sats', { username: user.username })
280-
: i18n.t('showusername_buying_sats', { username: user.username });
293+
? i18n.t('showusername_selling_sats', {
294+
username: user.username,
295+
amount: amountText,
296+
})
297+
: i18n.t('showusername_buying_sats', {
298+
username: user.username,
299+
amount: amountText,
300+
});
281301
}
282302

283303
// The user DOES NOT want to show their name.
284-
return isSell ? i18n.t('selling_sats') : i18n.t('buying_sats');
304+
return isSell
305+
? i18n.t('selling_sats', { amount: amountText })
306+
: i18n.t('buying_sats', { amount: amountText });
285307
};
286308

287309
const getOrder = async (
@@ -378,4 +400,10 @@ const getNewRangeOrderPayload = async (order: IOrder) => {
378400
}
379401
};
380402

381-
export { createOrder, getOrder, getOrders, getNewRangeOrderPayload };
403+
export {
404+
createOrder,
405+
getOrder,
406+
getOrders,
407+
getNewRangeOrderPayload,
408+
getOrderTitleMessage,
409+
};

locales/de.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,11 +452,11 @@ pending_payment_failed_to_admin: |
452452
Zahlungsversuche: ${attempts}
453453
selling: Verkaufe
454454
buying: Kaufe
455-
selling_sats: Verkaufe Sats
456-
buying_sats: Kaufe Sats
455+
selling_sats: 'Verkaufe ${amount}Sats'
456+
buying_sats: 'Kaufe ${amount}Sats'
457457
receive_payment: Zahlung erhalten
458-
showusername_buying_sats: '@${username} kauft Sats'
459-
showusername_selling_sats: '@${username} verkauft Sats'
458+
showusername_buying_sats: '@${username} kauft ${amount}Sats'
459+
showusername_selling_sats: '@${username} verkauft ${amount}Sats'
460460
pay: Bezahlen
461461
is: ist
462462
trading_volume: 'Handelsvolumen: ${Volumen} Sats'

locales/en.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,10 +459,10 @@ pending_payment_failed_to_admin: |
459459
Payment attempts: ${attempts}
460460
selling: Selling
461461
buying: Buying
462-
selling_sats: Selling sats
463-
buying_sats: Buying sats
464-
showusername_selling_sats: '@${username} is selling sats'
465-
showusername_buying_sats: '@${username} is buying sats'
462+
selling_sats: 'Selling ${amount}sats'
463+
buying_sats: 'Buying ${amount}sats'
464+
showusername_selling_sats: '@${username} is selling ${amount}sats'
465+
showusername_buying_sats: '@${username} is buying ${amount}sats'
466466
receive_payment: Receive payment
467467
pay: Pay
468468
is: is

locales/es.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,10 +454,10 @@ pending_payment_failed_to_admin: |
454454
Intento de pago: ${attempts}
455455
selling: Vendiendo
456456
buying: Comprando
457-
selling_sats: Vendiendo sats
458-
buying_sats: Comprando sats
459-
showusername_buying_sats: '@${username} está comprando sats'
460-
showusername_selling_sats: '@${username} está vendiendo sats'
457+
selling_sats: 'Vendiendo ${amount}sats'
458+
buying_sats: 'Comprando ${amount}sats'
459+
showusername_buying_sats: '@${username} está comprando ${amount}sats'
460+
showusername_selling_sats: '@${username} está vendiendo ${amount}sats'
461461
receive_payment: Recibo pago
462462
pay: Pago
463463
is: está

locales/fa.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -535,14 +535,14 @@ pending_payment_failed_to_admin: |
535535
تعداد تلاش‌های پرداخت: ${attempts}
536536
selling: فروختن
537537
buying: خریدن
538-
selling_sats: فروش ساتوشی
539-
buying_sats: خرید ساتوشی
538+
selling_sats: 'فروش ${amount}ساتوشی'
539+
buying_sats: 'خرید ${amount}ساتوشی'
540540
receive_payment: دریافت وجه
541541
pay: پرداخت
542542
is: هست
543543
trading_volume: 'حجم معاملات: ${volume} sat'
544-
showusername_buying_sats: '@${username} در حال خرید ساتوشی است'
545-
showusername_selling_sats: '@${username} در حال فروش ساتوشی است'
544+
showusername_buying_sats: '@${username} در حال خرید ${amount}ساتوشی است'
545+
showusername_selling_sats: '@${username} در حال فروش ${amount}ساتوشی است'
546546
satoshis: ساتوشی‌ها
547547
by: توسط
548548
rate: نرخ

locales/fr.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,11 +451,11 @@ pending_payment_failed_to_admin: |
451451
Tentatives de paiement : ${attempts}
452452
selling: Vente
453453
buying: Achat
454-
selling_sats: Vente de sats
455-
buying_sats: Achat de sats
454+
selling_sats: 'Vente de ${amount}sats'
455+
buying_sats: 'Achat de ${amount}sats'
456456
receive_payment: Réception du paiement
457-
showusername_buying_sats: "@${username} achète des sats"
458-
showusername_selling_sats: "@${username} vend des sats"
457+
showusername_buying_sats: "@${username} achète ${amount}sats"
458+
showusername_selling_sats: "@${username} vend ${amount}sats"
459459
pay: Payer
460460
is: est
461461
trading_volume: 'Volume de transactions : ${volume} sats'

locales/it.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,14 +449,14 @@ pending_payment_failed_to_admin: |
449449
Payment attempts: ${attempts}
450450
selling: Vendita
451451
buying: Acquisto
452-
selling_sats: Vendita sats
453-
buying_sats: Acquisto sats
452+
selling_sats: 'Vendita ${amount}sats'
453+
buying_sats: 'Acquisto ${amount}sats'
454454
receive_payment: Ricezione del pagamento
455455
pay: Paga
456456
is: è
457457
trading_volume: 'Volume scambio: ${volume} sats'
458-
showusername_buying_sats: '@${username} sta comprando sats'
459-
showusername_selling_sats: '@${username} sta vendendo sats'
458+
showusername_buying_sats: '@${username} sta comprando ${amount}sats'
459+
showusername_selling_sats: '@${username} sta vendendo ${amount}sats'
460460
satoshis: satoshi
461461
by: da
462462
rate: Valutazione

locales/ko.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,14 +449,14 @@ pending_payment_failed_to_admin: |
449449
450450
selling: 팝니다
451451
buying: 삽니다
452-
selling_sats: sats 판매
453-
buying_sats: sats 구매
452+
selling_sats: '${amount}sats 판매'
453+
buying_sats: '${amount}sats 구매'
454454
receive_payment: 입금
455455
pay: 결제
456456
is: is
457457
trading_volume: '거래량: ${volume} sats'
458-
showusername_buying_sats: '@${username} 님이 sats를 구매합니다'
459-
showusername_selling_sats: '@${username} 님이 sats를 판매합니다'
458+
showusername_buying_sats: '@${username} 님이 ${amount}sats를 구매합니다'
459+
showusername_selling_sats: '@${username} 님이 ${amount}sats를 판매합니다'
460460
satoshis: 사토시
461461
by: 방법 -
462462
rate: 환율

locales/pt.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,12 +451,12 @@ pending_payment_failed_to_admin: |
451451
Tentativas de pagamento: ${attempts}
452452
selling: Vendendo
453453
buying: Comprando
454-
selling_sats: Vendendo sats
455-
buying_sats: Comprando sats
454+
selling_sats: 'Vendendo ${amount}sats'
455+
buying_sats: 'Comprando ${amount}sats'
456456
receive_payment: Receber pagamento
457457
pay: Pagar
458-
showusername_buying_sats: '@${username} está comprando sats'
459-
showusername_selling_sats: '@${username} está vendendo sats'
458+
showusername_buying_sats: '@${username} está comprando ${amount}sats'
459+
showusername_selling_sats: '@${username} está vendendo ${amount}sats'
460460
is: é
461461
trading_volume: 'Volume de negócios: ${volume} sats'
462462
satoshis: satoshis

locales/ru.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,11 +452,11 @@ pending_payment_failed_to_admin: |
452452
Попытка оплаты: ${attempts}
453453
selling: Продаю
454454
buying: Покупаю
455-
selling_sats: Продажа сат
456-
buying_sats: Покупка сат
455+
selling_sats: 'Продажа ${amount}сат'
456+
buying_sats: 'Покупка ${amount}сат'
457457
receive_payment: Расчет
458-
showusername_buying_sats: '@${username} покупает саты'
459-
showusername_selling_sats: '@${username} продает саты'
458+
showusername_buying_sats: '@${username} покупает ${amount}саты'
459+
showusername_selling_sats: '@${username} продает ${amount}саты'
460460
pay: Расчет
461461
is: Я
462462
trading_volume: 'Обьем торгов: ${volume} сат'

0 commit comments

Comments
 (0)