From e7be21c715d0af610902cf91c2b59a88f940ab86 Mon Sep 17 00:00:00 2001 From: Samy RABAH-MONTAROU Date: Tue, 14 Jan 2025 12:43:15 +0100 Subject: [PATCH 1/3] make sure all non-cli broadcasts use broadcast config param --- .../src/renderer/components/Web3AppWebview/LiveAppSDKLogic.ts | 4 ++++ apps/ledger-live-mobile/src/logic/screenTransactionHooks.ts | 3 +++ 2 files changed, 7 insertions(+) diff --git a/apps/ledger-live-desktop/src/renderer/components/Web3AppWebview/LiveAppSDKLogic.ts b/apps/ledger-live-desktop/src/renderer/components/Web3AppWebview/LiveAppSDKLogic.ts index 3744ccffb1de..2be53315eb31 100644 --- a/apps/ledger-live-desktop/src/renderer/components/Web3AppWebview/LiveAppSDKLogic.ts +++ b/apps/ledger-live-desktop/src/renderer/components/Web3AppWebview/LiveAppSDKLogic.ts @@ -1,4 +1,5 @@ import { Dispatch } from "redux"; +import { useSelector } from "react-redux"; import { TFunction } from "i18next"; import { Account, AccountLike, Operation, SignedOperation } from "@ledgerhq/types-live"; import { addPendingOperation, getMainAccount } from "@ledgerhq/live-common/account/index"; @@ -17,6 +18,7 @@ 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); @@ -70,6 +72,7 @@ export const broadcastTransactionLogic = ( ): Promise => { const bridge = getAccountBridge(account, parentAccount); const mainAccount = getMainAccount(account, parentAccount); + const mevProtected = useSelector(mevProtectionSelector); let optimisticOperation: Operation = signedOperation.operation; @@ -79,6 +82,7 @@ export const broadcastTransactionLogic = ( optimisticOperation = await bridge.broadcast({ account: mainAccount, signedOperation, + broadcastConfig: { mevProtected }, }); tracking.platformBroadcastSuccess(manifest); } catch (error) { diff --git a/apps/ledger-live-mobile/src/logic/screenTransactionHooks.ts b/apps/ledger-live-mobile/src/logic/screenTransactionHooks.ts index 1d39a05b9231..6c6be91da3d3 100644 --- a/apps/ledger-live-mobile/src/logic/screenTransactionHooks.ts +++ b/apps/ledger-live-mobile/src/logic/screenTransactionHooks.ts @@ -92,6 +92,8 @@ export const useSignWithDevice = ({ const { deviceId, transaction } = route.params || {}; const bridge = getAccountBridge(account, parentAccount); const mainAccount = getMainAccount(account, parentAccount); + const mevProtected = useSelector(mevProtectionSelector); + navigation.setOptions({ gestureEnabled: false, }); @@ -122,6 +124,7 @@ export const useSignWithDevice = ({ .broadcast({ account: mainAccount, signedOperation: (e as { signedOperation: SignedOperation }).signedOperation, + broadcastConfig: { mevProtected }, }) .then(operation => ({ type: "broadcasted", From 9d82aa67e75cce7c4caf0d74d3d707a190520848 Mon Sep 17 00:00:00 2001 From: Samy RABAH-MONTAROU Date: Tue, 14 Jan 2025 12:44:25 +0100 Subject: [PATCH 2/3] changeset --- .changeset/red-actors-explode.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/red-actors-explode.md diff --git a/.changeset/red-actors-explode.md b/.changeset/red-actors-explode.md new file mode 100644 index 000000000000..c3337da8e944 --- /dev/null +++ b/.changeset/red-actors-explode.md @@ -0,0 +1,6 @@ +--- +"ledger-live-desktop": patch +"live-mobile": patch +--- + +feat: make sure all transaction broadcast use the broadcastconfig parameter From 4cba0600690602f0f52058a1d477e34fbe064b6b Mon Sep 17 00:00:00 2001 From: Samy RABAH-MONTAROU Date: Fri, 17 Jan 2025 16:50:26 +0100 Subject: [PATCH 3/3] lint --- .../src/logic/screenTransactionHooks.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/ledger-live-mobile/src/logic/screenTransactionHooks.ts b/apps/ledger-live-mobile/src/logic/screenTransactionHooks.ts index 6c6be91da3d3..2f60e1004e84 100644 --- a/apps/ledger-live-mobile/src/logic/screenTransactionHooks.ts +++ b/apps/ledger-live-mobile/src/logic/screenTransactionHooks.ts @@ -88,11 +88,11 @@ export const useSignWithDevice = ({ const [signing, setSigning] = useState(false); const [signed, setSigned] = useState(false); const subscription = useRef(null); + const mevProtected = useSelector(mevProtectionSelector); const signWithDevice = useCallback(() => { const { deviceId, transaction } = route.params || {}; const bridge = getAccountBridge(account, parentAccount); const mainAccount = getMainAccount(account, parentAccount); - const mevProtected = useSelector(mevProtectionSelector); navigation.setOptions({ gestureEnabled: false, @@ -187,7 +187,15 @@ export const useSignWithDevice = ({ ); }, }); - }, [context, account, navigation, parentAccount, updateAccountWithUpdater, route.params]); + }, [ + context, + account, + navigation, + parentAccount, + updateAccountWithUpdater, + route.params, + mevProtected, + ]); useEffect(() => { signWithDevice(); return () => {