Skip to content

Commit

Permalink
Add minimum required params to orders (#4470)
Browse files Browse the repository at this point in the history
Co-authored-by: Gustavo Antunes <gantunes@uc.cl>
Co-authored-by: Curtis David <Curtis.David7@gmail.com>
Co-authored-by: Pedro Pablo Aste Kompen <wachunei@gmail.com>
Co-authored-by: metamaskbot <metamaskbot@users.noreply.github.com>
Co-authored-by: Cal Leung <cleun007@gmail.com>
Co-authored-by: André Fatia <andre@thecodeventure.com>
Co-authored-by: ricky <ricky.miller@gmail.com>
Co-authored-by: tommasini <46944231+tommasini@users.noreply.github.com>
Co-authored-by: Andrea Salvatore <andrea.salvatore@consensys.net>
Co-authored-by: Alaa Hadad <alaahd@gmail.com>
Co-authored-by: Vik Chawla <vik.chawla2@gmail.com>
  • Loading branch information
11 people authored Jun 14, 2022
1 parent 0fbc1b6 commit d0ac4de
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
20 changes: 13 additions & 7 deletions app/components/UI/FiatOnRampAggregator/Views/Checkout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,19 @@ const CheckoutWebView = () => {
);
}

const transformedOrder = await processAggregatorOrder(
aggregatorInitialFiatOrder({
id: orderId,
account: selectedAddress,
network: selectedChainId,
}),
);
const transformedOrder = {
...(await processAggregatorOrder(
aggregatorInitialFiatOrder({
id: orderId,
account: selectedAddress,
network: selectedChainId,
}),
)),
id: orderId,
account: selectedAddress,
network: selectedChainId,
};

// add the order to the redux global store
handleAddFiatOrder(transformedOrder);
// register the token automatically
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const ApplePayButton = ({
const fiatOrder: FiatOrder = {
...aggregatorOrderToFiatOrder(order),
network: chainId,
account: selectedAddress,
};
addOrder(fiatOrder);
// @ts-expect-error pop is not defined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ export const aggregatorOrderToFiatOrder = (aggregatorOrder: Order) => ({
currencySymbol: aggregatorOrder.fiatCurrency?.denomSymbol || '',
cryptocurrency: aggregatorOrder.cryptoCurrency?.symbol || '',
network:
aggregatorOrder.cryptoCurrency?.network?.chainId &&
String(aggregatorOrder.cryptoCurrency.network.chainId),
aggregatorOrder.network ||
(aggregatorOrder.cryptoCurrency?.network?.chainId &&
String(aggregatorOrder.cryptoCurrency.network.chainId)),
state: aggregatorOrderStateToFiatOrderState(aggregatorOrder.status),
account: aggregatorOrder.walletAddress,
txHash: aggregatorOrder.txHash,
Expand All @@ -88,9 +89,14 @@ export async function processAggregatorOrder(
throw new Error('Payment Request Failed: empty order response');
}

const transformedOrder = aggregatorOrderToFiatOrder(updatedOrder);

return {
...order,
...aggregatorOrderToFiatOrder(updatedOrder),
...transformedOrder,
id: order.id || transformedOrder.id,
network: order.network || transformedOrder.network,
account: order.account || transformedOrder.account,
};
} catch (error) {
Logger.error(error as Error, {
Expand Down

0 comments on commit d0ac4de

Please sign in to comment.