Skip to content

Commit

Permalink
[FIX] invoices rates for erc20
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielbazan7 committed Feb 14, 2024
1 parent 71a3d7c commit 41ca237
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 14 deletions.
16 changes: 14 additions & 2 deletions src/navigation/bitpay-id/utils/bitpay-id-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ export function getCoinAndChainFromCurrencyCode(currencyCode: string): {
.split('_')
.map(item => item.toLowerCase());
if (suffix) {
// Special handling for usdc.e and usdc
if (coin.toLowerCase() === 'usdc' && chainSuffixMap[suffix] === 'matic') {
return {coin: 'usdc.e', chain: chainSuffixMap[suffix]};
} else if (
coin.toLowerCase() === 'usdcn' &&
chainSuffixMap[suffix] === 'matic'
) {
return {coin: 'usdc', chain: chainSuffixMap[suffix]};
}
return {coin, chain: chainSuffixMap[suffix]};
}
if (SUPPORTED_COINS.includes(coin)) {
Expand All @@ -36,9 +45,12 @@ export function getCurrencyCodeFromCoinAndChain(
);
if (suffix && (coinIsAnotherChain || chain.toLowerCase() !== 'eth')) {
// Special handling for usdc.e and usdc
if (coin.toLowerCase() === 'usdc.e') {
if (coin.toLowerCase() === 'usdc.e' && chain.toLowerCase() === 'matic') {
return 'USDC_m';
} else if (coin.toLowerCase() === 'usdc') {
} else if (
coin.toLowerCase() === 'usdc' &&
chain.toLowerCase() === 'matic'
) {
return 'USDCn_m';
}
return `${coin.toUpperCase()}_${suffix}`;
Expand Down
30 changes: 19 additions & 11 deletions src/navigation/wallet/screens/send/confirm/PayProConfirm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ import {sleep} from '../../../../../utils/helper-methods';
import {startOnGoingProcessModal} from '../../../../../store/app/app.effects';
import {dismissOnGoingProcessModal} from '../../../../../store/app/app.actions';
import {BuildPayProWalletSelectorList} from '../../../../../store/wallet/utils/wallet';
import {GetFeeUnits} from '../../../../../store/wallet/utils/currency';
import {
GetFeeUnits,
IsERCToken,
} from '../../../../../store/wallet/utils/currency';
import {
InfoDescription,
InfoHeader,
Expand Down Expand Up @@ -429,15 +432,21 @@ const PayProConfirm = () => {
) : null}
</>
) : null}
<Amount
description={'Total'}
amount={total}
height={83}
showInfoIcon={true}
infoIconOnPress={() => {
dispatch(showConfirmAmountInfoSheet('total'));
}}
/>
{wallet ? (
<Amount
description={'Total'}
amount={total}
height={
IsERCToken(wallet.currencyAbbreviation, wallet.chain)
? 110
: 83
}
showInfoIcon={true}
infoIconOnPress={() => {
dispatch(showConfirmAmountInfoSheet('total'));
}}
/>
) : null}
</>
) : null}
</DetailsList>
Expand Down Expand Up @@ -475,7 +484,6 @@ const PayProConfirm = () => {
walletId: wallet!.id,
key,
});

}}
/>
</ConfirmScrollView>
Expand Down
5 changes: 4 additions & 1 deletion src/store/wallet/effects/send/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,10 @@ export const buildTxDetails =

const selectedTransactionCurrency =
invoice?.buyerProvidedInfo!.selectedTransactionCurrency ||
wallet.currencyAbbreviation.toUpperCase();
getCurrencyCodeFromCoinAndChain(
wallet.currencyAbbreviation,
wallet.chain,
);

const isOffChain = !proposal;
if (invoice && selectedTransactionCurrency) {
Expand Down

0 comments on commit 41ca237

Please sign in to comment.