Skip to content

Commit

Permalink
[FIX] paypro handling and show all wallets in confirm view
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielbazan7 committed Feb 15, 2024
1 parent 71eb872 commit 1fef451
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,6 @@ const TransactionProposalDetails = () => {
</DetailContainer>
<Hr />


{txp.nonce ? (
<>
<DetailContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,11 +599,15 @@ const TransactionProposalNotifications = () => {
await sleep(400);
const count = countSuccessAndFailed(data);
if (count.failed > 0) {
const errMsgs = [`There was problem while trying to sign ${count.failed} of your transactions proposals. Please, try again`];
const errMsgs = [
`There was problem while trying to sign ${count.failed} of your transactions proposals. Please, try again`,
];
data.forEach((element, index) => {
if (element instanceof Error) {
errMsgs.push(`[ERROR ${index + 1}] ${BWCErrorMessage(element)}`);
}
errMsgs.push(
`[ERROR ${index + 1}] ${BWCErrorMessage(element)}`,
);
}
});
await showErrorMessage(
CustomErrorMessage({
Expand Down
26 changes: 3 additions & 23 deletions src/navigation/wallet/screens/send/SendTo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -396,38 +396,18 @@ const SendTo = () => {
GetInvoiceCurrency(currencyAbbreviation).toLowerCase(),
chain,
);
const OptSelected = payProOptions.paymentOptions.find(
(option: PayProPaymentOption) => option.selected,
);

let selected: PayProPaymentOption | undefined;
if (OptSelected) {
if (invoiceCurrency === OptSelected.currency) {
selected = OptSelected;
} else {
logger.warn(
'PayPro opt selected (v3) and wallet selected network/coin mismatch',
);
return Promise.resolve({
isValid: false,
invalidReason: 'invalidCurrency',
});
}
} else {
selected = payProOptions.paymentOptions.find(
const selected: PayProPaymentOption | undefined =
payProOptions.paymentOptions.find(
(option: PayProPaymentOption) =>
invoiceCurrency === option.currency,
);
}

if (selected) {
const isValid = dispatch(checkCoinAndNetwork(selected, true));
if (isValid) {
return Promise.resolve({isValid: true, invalidReason: undefined});
} else {
logger.warn(
'PayPro (v4) and wallet selected network/coin mismatch',
);
logger.warn('PayPro and wallet selected network/coin invalid');
return Promise.resolve({
isValid: false,
invalidReason: 'invalidCurrency',
Expand Down
49 changes: 27 additions & 22 deletions src/store/wallet/effects/send/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,11 @@ export const publishAndSignMultipleProposals =
}
}
// Process transactions with a nonce sequentially
const resultsWithNonce: (Partial<TransactionProposal> | void | Error)[] = [];
const resultsWithNonce: (
| Partial<TransactionProposal>
| void
| Error
)[] = [];
const evmTxsWithNonce = txps.filter(txp => txp.nonce !== undefined);
evmTxsWithNonce.sort((a, b) => (a.nonce || 0) - (b.nonce || 0));
for (const txp of evmTxsWithNonce) {
Expand Down Expand Up @@ -1195,28 +1199,29 @@ export const publishAndSignMultipleProposals =

// Process transactions without a nonce concurrently
const withoutNonce = txps.filter(txp => txp.nonce === undefined);
const promisesWithoutNonce: Promise<Partial<TransactionProposal> | void | Error>[] =
withoutNonce.map(txp =>
dispatch(
publishAndSign({
txp,
key,
wallet,
recipient,
password,
signingMultipleProposals,
}),
).catch(err => {
const errorStr =
err instanceof Error ? err.message : JSON.stringify(err);
dispatch(
LogActions.error(
`Error signing transaction proposal: ${errorStr}`,
),
);
return err;
const promisesWithoutNonce: Promise<
Partial<TransactionProposal> | void | Error
>[] = withoutNonce.map(txp =>
dispatch(
publishAndSign({
txp,
key,
wallet,
recipient,
password,
signingMultipleProposals,
}),
);
).catch(err => {
const errorStr =
err instanceof Error ? err.message : JSON.stringify(err);
dispatch(
LogActions.error(
`Error signing transaction proposal: ${errorStr}`,
),
);
return err;
}),
);
const resultsWithoutNonce = await Promise.all(promisesWithoutNonce);
return resolve([...resultsWithNonce, ...resultsWithoutNonce]);
} catch (err) {
Expand Down
7 changes: 1 addition & 6 deletions src/store/wallet/utils/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -517,12 +517,7 @@ export const BuildKeysAndWalletsList = ({
rates: Rates;
dispatch: AppDispatch;
}) => {
const selectedPaymentOptions = payProOptions?.paymentOptions?.filter(
option => option.selected,
);
const paymentOptions = selectedPaymentOptions?.length
? selectedPaymentOptions
: payProOptions?.paymentOptions;
const paymentOptions = payProOptions?.paymentOptions;
return Object.keys(keys)
.map(keyId => {
const keyObj = keys[keyId];
Expand Down

0 comments on commit 1fef451

Please sign in to comment.