Skip to content

Commit

Permalink
Merge branch 'main' into fix/sign-in-conditions-after-onboarding
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieuartu authored Jan 13, 2025
2 parents 13d82c9 + a55c0ce commit 908535f
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/scripts/controllers/bridge-status/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export const getMockStartPollingForBridgeTxStatusArgs = ({
},
approval: null,
estimatedProcessingTimeInSeconds: 15,
sentAmount: { amount: '1.234', fiat: null },
sentAmount: { amount: '1.234', valueInCurrency: null },
},
startTime: 1729964825189,
slippagePercentage: 0,
Expand Down
8 changes: 6 additions & 2 deletions shared/types/bridge-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,8 @@ export enum BridgeStatusAction {
GET_STATE = 'getState',
}

// The BigNumber values are serialized to strings
export type QuoteMetadataSerialized = {
sentAmount: { amount: string; fiat: string | null };
sentAmount: { amount: string; valueInCurrency: string | null };
};

export type StartPollingForBridgeTxStatusArgs = {
Expand All @@ -161,6 +160,11 @@ export type StartPollingForBridgeTxStatusArgs = {
targetContractAddress?: BridgeHistoryItem['targetContractAddress'];
};

/**
* Chrome: The BigNumber values are automatically serialized to strings when sent to the background
* Firefox: The BigNumber values are not serialized to strings when sent to the background,
* so we force the ui to do it manually, by using StartPollingForBridgeTxStatusArgsSerialized type on the startPollingForBridgeTxStatus action
*/
export type StartPollingForBridgeTxStatusArgsSerialized = Omit<
StartPollingForBridgeTxStatusArgs,
'quoteResponse'
Expand Down
20 changes: 20 additions & 0 deletions test/data/bridge/dummy-quotes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
export const DummyQuotesNoApproval = {
OP_0_005_ETH_TO_ARB: [
{
sentAmount: {
amount: '0.005',
valueInCurrency: null,
},
quote: {
requestId: 'be448070-7849-4d14-bb35-8dcdaf7a4d69',
srcChainId: 10,
Expand Down Expand Up @@ -392,6 +396,10 @@ export const DummyQuotesNoApproval = {
export const DummyQuotesWithApproval = {
ETH_11_USDC_TO_ARB: [
{
sentAmount: {
amount: '1.0903750',
valueInCurrency: null,
},
quote: {
requestId: '0cd5caf6-9844-465b-89ad-9c89b639f432',
srcChainId: 1,
Expand Down Expand Up @@ -812,6 +820,10 @@ export const DummyQuotesWithApproval = {
],
ARB_11_USDC_TO_ETH: [
{
sentAmount: {
amount: '1.0903750',
valueInCurrency: null,
},
quote: {
requestId: 'edbef62a-d3e6-4b33-aad5-9cdb81f85f53',
srcChainId: 42161,
Expand Down Expand Up @@ -911,6 +923,10 @@ export const DummyQuotesWithApproval = {
],
ARB_11_USDC_TO_OP: [
{
sentAmount: {
amount: '1.0903750',
valueInCurrency: null,
},
quote: {
requestId: 'dc63e7e6-dc9b-4aa8-80bb-714192ecd801',
srcChainId: 42161,
Expand Down Expand Up @@ -2461,6 +2477,10 @@ export const DummyQuotesWithApproval = {
],
OP_11_USDC_TO_ARB: [
{
sentAmount: {
amount: '1.1000000',
valueInCurrency: null,
},
quote: {
requestId: '01fa78fd-ed49-42b3-ab0e-94c7108feea9',
srcChainId: 10,
Expand Down
13 changes: 7 additions & 6 deletions ui/ducks/bridge-status/actions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
StartPollingForBridgeTxStatusArgs,
BridgeStatusAction,
StartPollingForBridgeTxStatusArgsSerialized,
} from '../../../shared/types/bridge-status';
import { forceUpdateMetamaskState } from '../../store/actions';
import { submitRequestToBackground } from '../../store/background-connection';
Expand All @@ -17,14 +17,15 @@ const callBridgeStatusControllerMethod = <T extends unknown[]>(
};

export const startPollingForBridgeTxStatus = (
startPollingForBridgeTxStatusArgs: StartPollingForBridgeTxStatusArgs,
startPollingForBridgeTxStatusArgs: StartPollingForBridgeTxStatusArgsSerialized,
) => {
return async (dispatch: MetaMaskReduxDispatch) => {
return dispatch(
callBridgeStatusControllerMethod<[StartPollingForBridgeTxStatusArgs]>(
BridgeStatusAction.START_POLLING_FOR_BRIDGE_TX_STATUS,
[startPollingForBridgeTxStatusArgs],
),
callBridgeStatusControllerMethod<
[StartPollingForBridgeTxStatusArgsSerialized]
>(BridgeStatusAction.START_POLLING_FOR_BRIDGE_TX_STATUS, [
startPollingForBridgeTxStatusArgs,
]),
);
};
};
10 changes: 9 additions & 1 deletion ui/pages/bridge/hooks/useSubmitBridgeTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,15 @@ export default function useSubmitBridgeTransaction() {
startPollingForBridgeTxStatus({
bridgeTxMeta,
statusRequest,
quoteResponse,
quoteResponse: {
...quoteResponse,
sentAmount: {
amount: quoteResponse.sentAmount.amount.toString(),
valueInCurrency: quoteResponse.sentAmount.valueInCurrency
? quoteResponse.sentAmount.valueInCurrency.toString()
: null,
},
},
slippagePercentage: slippage ?? 0,
startTime: bridgeTxMeta.time,
}),
Expand Down

0 comments on commit 908535f

Please sign in to comment.