Skip to content

Commit

Permalink
[LIVE-5135] Migrate Ethereum family implementation to EVM family (#4285)
Browse files Browse the repository at this point in the history
Co-authored-by: lvndry <lvndry@proton.me>
Co-authored-by: Alexandre Chabrolin <9203826+chabroA@users.noreply.github.com>
Co-authored-by: Landry Monga <lvndry@protonmail.com>
  • Loading branch information
3 people authored Sep 12, 2023
1 parent 834febb commit 533278e
Show file tree
Hide file tree
Showing 278 changed files with 3,295 additions and 16,693 deletions.
16 changes: 16 additions & 0 deletions .changeset/small-jars-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
"@ledgerhq/cryptoassets": major
"ledger-live-desktop": major
"live-mobile": major
"@ledgerhq/live-common": major
"@ledgerhq/types-cryptoassets": minor
"@ledgerhq/coin-framework": minor
"@ledgerhq/coin-evm": minor
"@ledgerhq/live-cli": minor
"@ledgerhq/live-env": minor
---

Migrate Ethereum family implementation to EVM family

Replace the legcay Ethereum familly implementation that was present in ledger-live-common by the coin-evm lib implementation.
This change was made in order to improve scalabillity and maintainability of the evm coins, as well as more easilly integrate new evm based chains in the future.
4 changes: 2 additions & 2 deletions .github/workflows/bot-staging-explorer-eth.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "[Bot] Ethereum on Staging"
name: "[Bot] Evm on Staging"
on:
workflow_dispatch:
schedule:
Expand Down Expand Up @@ -37,5 +37,5 @@ jobs:
SLACK_API_TOKEN: ${{secrets.SLACK_API_TOKEN}}
SLACK_ICON_EMOJI: ":bot-seed2:"
SLACK_CHANNEL: explorer-bot-stg
BOT_FILTER_FAMILIES: ethereum
BOT_FILTER_CURRENCIES: avalanche_c_chain,bsc,polygon,ethereum,ethereum_classic,ethereum_goerli
BOT_ENVIRONMENT: staging
2 changes: 0 additions & 2 deletions apps/cli/src/live-common-setup-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ setSupportedCurrencies([
"persistence",
"quicksilver",
"internet_computer",
"ethereum_as_evm_test_only",
"polygon_as_evm_test_only",
"klaytn",
"polygon_zk_evm",
"polygon_zk_evm_testnet",
Expand Down
1 change: 0 additions & 1 deletion apps/ledger-live-desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"@ledgerhq/devices": "workspace:^",
"@ledgerhq/domain-service": "workspace:^",
"@ledgerhq/errors": "workspace:^",
"@ledgerhq/evm-tools": "workspace:^",
"@ledgerhq/hw-transport": "workspace:^",
"@ledgerhq/hw-transport-http": "workspace:^",
"@ledgerhq/hw-transport-node-hid-singleton": "workspace:^",
Expand Down
2 changes: 2 additions & 0 deletions apps/ledger-live-desktop/src/config/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ export const urls = {
},
maxSpendable:
"https://support.ledger.com/hc/en-us/articles/360012960679?utm_source=ledger_live_desktop&utm_medium=self_referral&utm_content=max_spendable_alert",
stakingEthereum:
"https://www.ledger.com/staking-ethereum?utm_source=ledger_live_desktop&utm_medium=self_referral&utm_content=ethereum",
stakingTezos:
"https://www.ledger.com/staking-tezos?utm_source=ledger_live_desktop&utm_medium=self_referral&utm_content=tezos",
stakingTron:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ setSupportedCurrencies([
"velas_evm",
"syscoin",
"internet_computer",
"ethereum_as_evm_test_only",
"polygon_as_evm_test_only",
"klaytn",
"polygon_zk_evm",
"polygon_zk_evm_testnet",
Expand Down
20 changes: 16 additions & 4 deletions apps/ledger-live-desktop/src/renderer/actions/swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ type UPDATE_PROVIDERS_TYPE = {
/* ACTIONS */
export const updateProvidersAction =
createAction<UPDATE_PROVIDERS_TYPE["payload"]>("SWAP/UPDATE_PROVIDERS");

export const updateTransactionAction = createAction<Transaction | undefined | null>(
"SWAP/UPDATE_TRANSACTION",
);

export const updateRateAction = createAction<ExchangeRate | undefined | null>("SWAP/UPDATE_RATE");
export const resetSwapAction = createAction("SWAP/RESET_STATE");

Expand All @@ -27,6 +29,7 @@ export const providersSelector = createSelector(
(state: State) => state.swap,
swap => swap.providers,
);

export const filterAvailableToAssets = (pairs: Pair[] | null | undefined, fromId?: string) => {
if (pairs === null || pairs === undefined) return null;
const toAssets = [];
Expand All @@ -37,6 +40,7 @@ export const filterAvailableToAssets = (pairs: Pair[] | null | undefined, fromId
}
return toAssets;
};

const filterAvailableFromAssets = (
pairs: Pair[] | undefined | null,
allAccounts: Account[],
Expand All @@ -51,6 +55,7 @@ const filterAvailableFromAssets = (
};
}) as (Account & { disabled: boolean })[];
};

export const toSelector = createSelector(
(state: State) => state.swap.pairs,
pairs =>
Expand All @@ -60,13 +65,17 @@ export const toSelector = createSelector(
return uniqueAssetList;
}),
);

export const fromSelector = createSelector(
(state: State) => state.swap.pairs,
pairs =>
memoize(
(state: State) => {
return state.swap.pairs;
},
pairs => {
return memoize(
(allAccounts: Array<Account>): Array<Account | TokenAccount> =>
sortAccountsByStatus(filterAvailableFromAssets(pairs, allAccounts)),
),
);
},
);

// Put disabled accounts and subaccounts at the bottom of the list while preserving the parent/children position.
Expand Down Expand Up @@ -104,14 +113,17 @@ export function sortAccountsByStatus(accounts: (Account & { disabled: boolean })
}
return [...activeAccounts, ...disabledAccounts];
}

export const transactionSelector = createSelector(
(state: State) => state.swap,
swap => swap.transaction,
);

export const rateSelector = createSelector(
(state: State) => state.swap,
swap => swap.exchangeRate,
);

export const rateExpirationSelector = createSelector(
(state: State) => state.swap,
swap => swap.exchangeRateExpiration,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// FIXME: to update when implementing edit transaction on evm

import React, { useCallback, memo } from "react";
import { AccountLike, Account, Operation } from "@ledgerhq/types-live";
import { Trans } from "react-i18next";
import Alert from "~/renderer/components/Alert";
import Link from "~/renderer/components/Link";
import { openModal, closeModal } from "~/renderer/actions/modals";
import { closeModal } from "~/renderer/actions/modals";
import { useDispatch } from "react-redux";
import { useFeature } from "@ledgerhq/live-common/featureFlags/index";
import invariant from "invariant";
Expand All @@ -21,18 +23,21 @@ const EditOperationPanel = (props: Props) => {
const handleOpenEditModal = useCallback(() => {
invariant(operation.transactionRaw, "operation.transactionRaw is required");
dispatch(closeModal("MODAL_SEND"));
dispatch(
openModal("MODAL_EDIT_TRANSACTION", {
account,
parentAccount,
transactionRaw: operation.transactionRaw,
transactionHash: operation.hash,
}),
);
// dispatch(
// openModal("MODAL_EDIT_TRANSACTION", {
// account,
// parentAccount,
// transactionRaw: operation.transactionRaw,
// transactionHash: operation.hash,
// }),
// );
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [parentAccount, account, operation, dispatch]);

if (!editEthTx?.enabled) {
return null;
}

return (
<div style={{ marginBottom: "15px" }}>
<Alert type="warning">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,5 @@ const SendFeeMode = ({ isAdvanceMode, setAdvanceMode }: Props) => {
</Box>
);
};

export default SendFeeMode;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styled from "styled-components";
import { useTranslation } from "react-i18next";
import React, { useEffect, useState } from "react";
import { Account, AccountLike, AnyMessage } from "@ledgerhq/types-live";
import { Account, AccountLike, AnyMessage, MessageProperties } from "@ledgerhq/types-live";
import { getMainAccount } from "@ledgerhq/live-common/account/index";
import { Device } from "@ledgerhq/live-common/hw/actions/types";
import { DeviceTransactionField } from "@ledgerhq/live-common/transaction/index";
Expand All @@ -12,7 +12,6 @@ import useTheme from "~/renderer/hooks/useTheme";
import Text from "~/renderer/components/Text";
import Box from "~/renderer/components/Box";
import { getLLDCoinFamily } from "~/renderer/families";
import { MessageProperties } from "~/renderer/families/types";

const FieldText = styled(Text).attrs(() => ({
ml: 1,
Expand Down Expand Up @@ -63,9 +62,7 @@ const SignMessageConfirm = ({ device, account, parentAccount, signMessageRequest
useEffect(() => {
if (signMessageRequested.standard === "EIP712") {
const specific = getLLDCoinFamily(currency.family);
specific?.message
?.getMessageProperties(mainAccount, signMessageRequested)
.then(setMessageFields);
specific?.message?.getMessageProperties(signMessageRequested).then(setMessageFields);
}
}, [currency, mainAccount, signMessageRequested]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export type Step<T, StepProps> = {
id: T;
label?: React.ReactNode;
excludeFromBreadcrumb?: boolean;
component: React.ComponentType<StepProps>;
footer?: React.ComponentType<StepProps>;
component: React.FC<StepProps> | React.ComponentType<StepProps>;
footer?: React.FC<StepProps> | React.ComponentType<StepProps>;
onBack?: ((a: StepProps) => void) | null;
backButtonComponent?: React.ReactNode;
noScroll?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const FeesField = ({ account, parentAccount, status, field }: FieldComponentProp
<TransactionConfirmField label={field.label}>
<FormattedVal
color={"palette.text.shade80"}
disableRounding
unit={feesUnit}
val={estimatedFees}
fontSize={3}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// FIXME: to update when implementing edit transaction on evm

import React, { useMemo, Component, useCallback } from "react";
import { connect, useDispatch } from "react-redux";
import { connect } from "react-redux";
import { useHistory, useLocation } from "react-router-dom";
import { TFunction } from "i18next";
import { Trans, useTranslation } from "react-i18next";
Expand Down Expand Up @@ -71,7 +73,7 @@ import CryptoCurrencyIcon from "~/renderer/components/CryptoCurrencyIcon";
import AmountDetails from "./AmountDetails";
import NFTOperationDetails from "./NFTOperationDetails";
import { State } from "~/renderer/reducers";
import { openModal } from "~/renderer/actions/modals";
// import { openModal } from "~/renderer/actions/modals";
import { getLLDCoinFamily } from "~/renderer/families";

const mapStateToProps = (
Expand Down Expand Up @@ -235,34 +237,42 @@ const OperationD = (props: Props) => {
: undefined;
const editEthTx = useFeature("editEthTx");
const editable = editEthTx?.enabled && isEditableOperation(mainAccount, operation);
const dispatch = useDispatch();
const handleOpenEditModal = useCallback(
(account, parentAccount, transactionRaw, transactionHash) => {
setDrawer(undefined);
if (subOperations.length > 0 && isToken) {
// if the operation is a token operation,(ERC-20 send), in order to speedup/cancel we need to find the subAccount
const opAccount = findSubAccountById(account, subOperations[0].accountId);
dispatch(
openModal("MODAL_EDIT_TRANSACTION", {
account: opAccount,
parentAccount: account,
transactionRaw,
transactionHash,
}),
);
} else {
dispatch(
openModal("MODAL_EDIT_TRANSACTION", {
account,
parentAccount,
transactionRaw,
transactionHash,
}),
);
}
},
[dispatch, isToken, subOperations],
);
// const dispatch = useDispatch();
// const handleOpenEditModal = useCallback(
// (account, parentAccount, transactionRaw, transactionHash) => {
// setDrawer(undefined);
// if (subOperations.length > 0 && isToken) {
// // if the operation is a token operation,(ERC-20 send), in order to speedup/cancel we need to find the subAccount
// const opAccount = findSubAccountById(account, subOperations[0].accountId);
// dispatch(
// openModal("MODAL_EDIT_TRANSACTION", {
// account: opAccount,
// parentAccount: account,
// transactionRaw,
// transactionHash,
// }),
// );
// } else {
// dispatch(
// openModal("MODAL_EDIT_TRANSACTION", {
// account,
// parentAccount,
// transactionRaw,
// transactionHash,
// }),
// );
// }
// },
// [dispatch, isToken, subOperations],
// );

const handleOpenEditModal = (
_account: unknown,
_parentAccount: unknown,
_transactionRaw: unknown,
_transactionHash: unknown,
) => {};

// pending transactions that exceeds 5 minutes are considered as stuck transactions
const isStuck =
new Date().getTime() - operation.date.getTime() > getEnv("ETHEREUM_STUCK_TRANSACTION_TIMEOUT");
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 533278e

Please sign in to comment.