Skip to content

Commit

Permalink
mevprotection selector used in react context and passed down as conte…
Browse files Browse the repository at this point in the history
…xt arg in LiveAppSdk
  • Loading branch information
Wozacosta committed Jan 20, 2025
1 parent 4cba060 commit 1dc3cef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { OperationDetails } from "~/renderer/drawers/OperationDetails";
import { setDrawer } from "~/renderer/drawers/Provider";
import { track } from "~/renderer/analytics/segment";
import { WalletState } from "@ledgerhq/live-wallet/store";
import { mevProtectionSelector } from "~/renderer/reducers/settings";

const trackingLiveAppSDKLogic = trackingWrapper(track);

Expand All @@ -27,6 +26,7 @@ type WebPlatformContext = {
dispatch: Dispatch;
accounts: AccountLike[];
tracking: typeof trackingLiveAppSDKLogic;
mevProtected: boolean;
};

export type RequestAccountParams = {
Expand Down Expand Up @@ -55,7 +55,7 @@ export const requestAccountLogic = async (
};

export const broadcastTransactionLogic = (
{ manifest, dispatch, accounts, tracking }: WebPlatformContext,
{ manifest, dispatch, accounts, tracking, mevProtected }: WebPlatformContext,
accountId: string,
signedTransaction: RawPlatformSignedTransaction,
pushToast: (data: ToastData) => void,
Expand All @@ -72,7 +72,6 @@ export const broadcastTransactionLogic = (
): Promise<string> => {
const bridge = getAccountBridge(account, parentAccount);
const mainAccount = getMainAccount(account, parentAccount);
const mevProtected = useSelector(mevProtectionSelector);

let optimisticOperation: Operation = signedOperation.operation;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { Loader } from "./styled";
import { WebviewAPI, WebviewProps } from "./types";
import { useWebviewState } from "./helpers";
import { currentRouteNameRef } from "~/renderer/analytics/screenRefs";
import { mevProtectionSelector } from "~/renderer/reducers/settings";
import { walletSelector } from "~/renderer/reducers/wallet";

export const PlatformAPIWebview = forwardRef<WebviewAPI, WebviewProps>(
Expand Down Expand Up @@ -77,6 +78,7 @@ export const PlatformAPIWebview = forwardRef<WebviewAPI, WebviewProps>(

const dispatch = useDispatch();
const accounts = useSelector(flattenAccountsSelector);
const mevProtected = useSelector(mevProtectionSelector);
const { pushToast } = useToasts();
const { t } = useTranslation();

Expand Down Expand Up @@ -178,14 +180,14 @@ export const PlatformAPIWebview = forwardRef<WebviewAPI, WebviewProps>(
signedTransaction: RawPlatformSignedTransaction;
}) => {
return broadcastTransactionLogic(
{ manifest, dispatch, accounts, tracking },
{ manifest, dispatch, accounts, tracking, mevProtected },
accountId,
signedTransaction,
pushToast,
t,
);
},
[manifest, accounts, pushToast, dispatch, t, tracking],
[manifest, accounts, pushToast, dispatch, t, tracking, mevProtected],
);

const startExchange = useCallback(
Expand Down

0 comments on commit 1dc3cef

Please sign in to comment.