diff --git a/src/components/Earn.jsx b/src/components/Earn.jsx index 90812a43e..4d249cca4 100644 --- a/src/components/Earn.jsx +++ b/src/components/Earn.jsx @@ -29,8 +29,11 @@ const RELOAD_FIDELITY_BONDS_DELAY_MS = 2_000 const OFFERTYPE_REL = 'sw0reloffer' const OFFERTYPE_ABS = 'sw0absoffer' -const isRelativeOffer = (offertype) => offertype === OFFERTYPE_REL -const isAbsoluteOffer = (offertype) => offertype === OFFERTYPE_ABS +// can be any of ['sw0reloffer', 'swreloffer', 'reloffer'] +const isRelativeOffer = (offertype) => offertype.includes('reloffer') + +// can be any of ['sw0absoffer', 'swabsoffer', 'absoffer'] +const isAbsoluteOffer = (offertype) => offertype.includes('absoffer') const FORM_INPUT_LOCAL_STORAGE_KEYS = { offertype: 'jm-offertype', @@ -85,10 +88,10 @@ const factorToPercentage = (val, precision = 6) => { } const renderOrderType = (val, t) => { - if (val.includes('absoffer')) { + if (isAbsoluteOffer(val)) { return {t('earn.current.text_offer_type_absolute')} } - if (val.includes('reloffer')) { + if (isRelativeOffer(val)) { return {t('earn.current.text_offer_type_relative')} } return {val} @@ -112,7 +115,7 @@ function CurrentOffer({ offer, nickname }) {
{t('earn.current.text_cjfee')}
- {offer.ordertype.includes('reloffer') ? ( + {isRelativeOffer(offer.ordertype) ? ( <>{factorToPercentage(offer.cjfee)}% ) : ( <> diff --git a/src/libs/JmWalletApi.ts b/src/libs/JmWalletApi.ts index dd5871090..ce875ab1c 100644 --- a/src/libs/JmWalletApi.ts +++ b/src/libs/JmWalletApi.ts @@ -64,7 +64,9 @@ interface WalletUnlockRequest { password: string } -type OrderType = 'sw0reloffer' | 'sw0absoffer' +type RelOfferType = 'sw0reloffer' | 'swreloffer' | 'reloffer' +type AbsOfferType = 'sw0absoffer' | 'swabsoffer' | 'absoffer' +type OrderType = RelOfferType | AbsOfferType interface StartMakerRequest { cjfee_a: AmountSats