Skip to content

Commit

Permalink
make sure all non-cli broadcasts use broadcast config param (#8892)
Browse files Browse the repository at this point in the history
* make sure all non-cli broadcasts use broadcast config param

* mevprotection selector used in react context and passed down as context arg in LiveAppSdk
  • Loading branch information
Wozacosta authored Jan 21, 2025
1 parent c8f0c9a commit 694e041
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changeset/red-actors-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"ledger-live-desktop": patch
"live-mobile": patch
---

feat: make sure all transaction broadcast use the broadcastconfig parameter
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type WebPlatformContext = {
dispatch: Dispatch;
accounts: AccountLike[];
tracking: typeof trackingLiveAppSDKLogic;
mevProtected: boolean;
};

export type RequestAccountParams = {
Expand All @@ -34,7 +35,7 @@ export type RequestAccountParams = {
};
export const requestAccountLogic = async (
walletState: WalletState,
{ manifest }: Omit<WebPlatformContext, "accounts" | "dispatch" | "tracking">,
{ manifest }: Omit<WebPlatformContext, "accounts" | "dispatch" | "tracking" | "mevProtected">,
{ currencies, includeTokens }: RequestAccountParams,
) => {
trackingLiveAppSDKLogic.platformRequestAccountRequested(manifest);
Expand All @@ -53,7 +54,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 @@ -79,6 +80,7 @@ export const broadcastTransactionLogic = (
optimisticOperation = await bridge.broadcast({
account: mainAccount,
signedOperation,
broadcastConfig: { mevProtected },
});
tracking.platformBroadcastSuccess(manifest);
} catch (error) {
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
13 changes: 12 additions & 1 deletion apps/ledger-live-mobile/src/logic/screenTransactionHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ export const useSignWithDevice = ({
const [signing, setSigning] = useState(false);
const [signed, setSigned] = useState(false);
const subscription = useRef<null | Subscription>(null);
const mevProtected = useSelector(mevProtectionSelector);
const signWithDevice = useCallback(() => {
const { deviceId, transaction } = route.params || {};
const bridge = getAccountBridge(account, parentAccount);
const mainAccount = getMainAccount(account, parentAccount);

navigation.setOptions({
gestureEnabled: false,
});
Expand Down Expand Up @@ -122,6 +124,7 @@ export const useSignWithDevice = ({
.broadcast({
account: mainAccount,
signedOperation: (e as { signedOperation: SignedOperation }).signedOperation,
broadcastConfig: { mevProtected },
})
.then(operation => ({
type: "broadcasted",
Expand Down Expand Up @@ -184,7 +187,15 @@ export const useSignWithDevice = ({
);
},
});
}, [context, account, navigation, parentAccount, updateAccountWithUpdater, route.params]);
}, [
context,
account,
navigation,
parentAccount,
updateAccountWithUpdater,
route.params,
mevProtected,
]);
useEffect(() => {
signWithDevice();
return () => {
Expand Down

2 comments on commit 694e041

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Bot] Evm on Staging ($0.00) ⏲ 18.8s

What is the bot and how does it work? Everything is documented here!

3 critical spec errors

Spec Ethereum failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com

Spec Ethereum Sepolia failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com

Spec Ethereum Holesky failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com
Details of the 0 mutations

Spec Ethereum (failed)


Spec Ethereum Sepolia (failed)


Spec Ethereum Holesky (failed)


Details of the 9 uncovered mutations

Spec Ethereum (3)

  • move 50%:
  • send max:
  • move some ERC20 like (ERC20, BEP20, etc...):

Spec Ethereum Sepolia (3)

  • move 50%:
  • send max:
  • move some ERC20 like (ERC20, BEP20, etc...):

Spec Ethereum Holesky (3)

  • move 50%:
  • send max:
  • move some ERC20 like (ERC20, BEP20, etc...):
Portfolio ($0.00) – Details of the 3 currencies
Spec (accounts) State Remaining Runs (est) funds?
Ethereum (0) 0 ops , 🤷‍♂️ ``
Ethereum Sepolia (0) 0 ops , 🤷‍♂️ ``
Ethereum Holesky (0) 0 ops , 🤷‍♂️ ``

Performance ⏲ 18.8s

Time spent for each spec: (total across mutations)

Spec (accounts) preload scan re-sync tx status sign op broadcast test destination test
TOTAL 903ms N/A N/A N/A N/A N/A N/A N/A
Ethereum (0) 640ms N/A N/A N/A N/A N/A N/A N/A
Ethereum Sepolia (0) 171ms N/A N/A N/A N/A N/A N/A N/A
Ethereum Holesky (0) 92ms N/A N/A N/A N/A N/A N/A N/A

What is the bot and how does it work? Everything is documented here!

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Bot] Bitcoin on Staging ($0.00) ⏲ 53.3s

What is the bot and how does it work? Everything is documented here!

13 critical spec errors

Spec Bitcoin failed!

TransportStatusError: Ledger device: UNKNOWN_ERROR (0x6a86)

Spec Bitcoin Testnet failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com

Spec Bitcoin Cash failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com

Spec Bitcoin Gold failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com

Spec Dash failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com

Spec Digibyte failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com

Spec DogeCoin failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com

Spec Komodo failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com

Spec Litecoin failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com

Spec Qtum failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com

Spec ZCash failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com

Spec Horizen failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com

Spec Decred failed!

Error: getaddrinfo ENOTFOUND atlas-stg.ledger-test.com
Details of the 0 mutations

Spec Bitcoin (failed)


Spec Bitcoin Testnet (failed)


Spec Bitcoin Cash (failed)


Spec Bitcoin Gold (failed)


Spec Dash (failed)


Spec Digibyte (failed)


Spec DogeCoin (failed)


Spec Komodo (failed)


Spec Litecoin (failed)


Spec Qtum (failed)


Spec ZCash (failed)


Spec Horizen (failed)


Spec Decred (failed)


Details of the 65 uncovered mutations

Spec Bitcoin (5)

  • move ~50%:
  • optimize-size:
  • send 1 utxo:
  • send OP_RETURN transaction:
  • send max:

Spec Bitcoin Testnet (5)

  • move ~50%:
  • optimize-size:
  • send 1 utxo:
  • send OP_RETURN transaction:
  • send max:

Spec Bitcoin Cash (5)

  • move ~50%:
  • optimize-size:
  • send 1 utxo:
  • send OP_RETURN transaction:
  • send max:

Spec Bitcoin Gold (5)

  • move ~50%:
  • optimize-size:
  • send 1 utxo:
  • send OP_RETURN transaction:
  • send max:

Spec Dash (5)

  • move ~50%:
  • optimize-size:
  • send 1 utxo:
  • send OP_RETURN transaction:
  • send max:

Spec Digibyte (5)

  • move ~50%:
  • optimize-size:
  • send 1 utxo:
  • send OP_RETURN transaction:
  • send max:

Spec DogeCoin (5)

  • move ~50%:
  • optimize-size:
  • send 1 utxo:
  • send OP_RETURN transaction:
  • send max:

Spec Komodo (5)

  • move ~50%:
  • optimize-size:
  • send 1 utxo:
  • send OP_RETURN transaction:
  • send max:

Spec Litecoin (5)

  • move ~50%:
  • optimize-size:
  • send 1 utxo:
  • send OP_RETURN transaction:
  • send max:

Spec Qtum (5)

  • move ~50%:
  • optimize-size:
  • send 1 utxo:
  • send OP_RETURN transaction:
  • send max:

Spec ZCash (5)

  • move ~50%:
  • optimize-size:
  • send 1 utxo:
  • send OP_RETURN transaction:
  • send max:

Spec Horizen (5)

  • move ~50%:
  • optimize-size:
  • send 1 utxo:
  • send OP_RETURN transaction:
  • send max:

Spec Decred (5)

  • move ~50%:
  • optimize-size:
  • send 1 utxo:
  • send OP_RETURN transaction:
  • send max:
Portfolio ($0.00) – Details of the 13 currencies
Spec (accounts) State Remaining Runs (est) funds?
Bitcoin (0) 0 ops , 🤷‍♂️ ``
Bitcoin Testnet (0) 0 ops , 🤷‍♂️ ``
Bitcoin Cash (0) 0 ops , 🤷‍♂️ ``
Bitcoin Gold (0) 0 ops , 🤷‍♂️ ``
Dash (0) 0 ops , 🤷‍♂️ ``
Digibyte (0) 0 ops , 🤷‍♂️ ``
DogeCoin (0) 0 ops , 🤷‍♂️ ``
Komodo (0) 0 ops , 🤷‍♂️ ``
Litecoin (0) 0 ops , 🤷‍♂️ ``
Qtum (0) 0 ops , 🤷‍♂️ ``
ZCash (0) 0 ops , 🤷‍♂️ ``
Horizen (0) 0 ops , 🤷‍♂️ ``
Decred (0) 0 ops , 🤷‍♂️ ``

Performance ⏲ 53.3s

Time spent for each spec: (total across mutations)

Spec (accounts) preload scan re-sync tx status sign op broadcast test destination test
TOTAL 4.96ms N/A N/A N/A N/A N/A N/A N/A
Bitcoin (0) 0.18ms N/A N/A N/A N/A N/A N/A N/A
Bitcoin Testnet (0) 0.19ms N/A N/A N/A N/A N/A N/A N/A
Bitcoin Cash (0) 0.13ms N/A N/A N/A N/A N/A N/A N/A
Bitcoin Gold (0) 1.88ms N/A N/A N/A N/A N/A N/A N/A
Dash (0) 0.16ms N/A N/A N/A N/A N/A N/A N/A
Digibyte (0) 0.69ms N/A N/A N/A N/A N/A N/A N/A
DogeCoin (0) 0.24ms N/A N/A N/A N/A N/A N/A N/A
Komodo (0) 0.19ms N/A N/A N/A N/A N/A N/A N/A
Litecoin (0) 0.51ms N/A N/A N/A N/A N/A N/A N/A
Qtum (0) 0.19ms N/A N/A N/A N/A N/A N/A N/A
ZCash (0) 0.23ms N/A N/A N/A N/A N/A N/A N/A
Horizen (0) 0.16ms N/A N/A N/A N/A N/A N/A N/A
Decred (0) 0.20ms N/A N/A N/A N/A N/A N/A N/A

What is the bot and how does it work? Everything is documented here!

Please sign in to comment.