Skip to content

Commit

Permalink
Migrate all "ethereum" family currencies to "evm" and remove ethereum…
Browse files Browse the repository at this point in the history
… family code (#4275)
  • Loading branch information
chabroA committed Aug 10, 2023
1 parent 397e08d commit 15d6b16
Show file tree
Hide file tree
Showing 19 changed files with 102 additions and 204 deletions.
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
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
2 changes: 0 additions & 2 deletions apps/ledger-live-mobile/src/live-common-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { Transaction } from "../../types";
export const dataset: DatasetTest<Transaction> = {
implementations: ["mock", "js"],
currencies: {
ethereum_as_evm_test_only: {
ethereum: {
accounts: [
{
FIXME_tests: ["balance is sum of ops"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from "axios";
import { AssertionError, fail } from "assert";
import { delay } from "@ledgerhq/live-promise";
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
import { CryptoCurrency, EthereumLikeInfo } from "@ledgerhq/types-cryptoassets";
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
import * as ETHERSCAN_API from "../../../../api/explorer/etherscan";
import { makeAccount } from "../../../fixtures/common.fixtures";
Expand Down Expand Up @@ -33,6 +33,10 @@ const currency: CryptoCurrency = {
type: "etherscan",
uri: "mock",
},
node: {
type: "external",
uri: "mock",
},
},
};
const account = makeAccount("0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d", currency);
Expand Down Expand Up @@ -122,7 +126,7 @@ describe("EVM Family", () => {
ethereumLikeInfo: {
chainId: 1,
// no explorer
},
} as EthereumLikeInfo,
},
account.freshAddress,
account.id,
Expand Down Expand Up @@ -249,7 +253,7 @@ describe("EVM Family", () => {
ethereumLikeInfo: {
chainId: 1,
// no explorer
},
} as EthereumLikeInfo,
},
account.freshAddress,
account.id,
Expand Down Expand Up @@ -385,7 +389,7 @@ describe("EVM Family", () => {
ethereumLikeInfo: {
chainId: 1,
// no explorer
},
} as EthereumLikeInfo,
},
account.freshAddress,
account.id,
Expand Down Expand Up @@ -521,7 +525,7 @@ describe("EVM Family", () => {
ethereumLikeInfo: {
chainId: 1,
// no explorer
},
} as EthereumLikeInfo,
},
account.freshAddress,
account.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ const fakeCurrency: Partial<CryptoCurrency> = {
id: "my_new_chain" as CryptoCurrencyId,
ethereumLikeInfo: {
chainId: 1,
node: {
type: "ledger",
explorerId: "eth",
},
gasTracker: {
type: "ledger",
explorerId: "eth",
Expand All @@ -17,6 +21,10 @@ const fakeCurrencyWithoutGasTracker: Partial<CryptoCurrency> = {
id: "my_new_chain" as CryptoCurrencyId,
ethereumLikeInfo: {
chainId: 1,
node: {
type: "ledger",
explorerId: "eth",
},
},
units: [{ code: "ETH", name: "ETH", magnitude: 18 }],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ const fakeCurrency: Partial<CryptoCurrency> = {
id: "ethereum" as CryptoCurrencyId,
ethereumLikeInfo: {
chainId: 1,
node: {
type: "ledger",
explorerId: "eth",
},
gasTracker: {
type: "ledger",
explorerId: "eth",
Expand Down
4 changes: 2 additions & 2 deletions libs/coin-evm/src/__tests__/unit/api/node/rpc.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ethers } from "ethers";
import BigNumber from "bignumber.js";
import { AssertionError, fail } from "assert";
import { delay } from "@ledgerhq/live-promise";
import { CryptoCurrency, CryptoCurrencyId } from "@ledgerhq/types-cryptoassets";
import { CryptoCurrency, CryptoCurrencyId, EthereumLikeInfo } from "@ledgerhq/types-cryptoassets";
import { EvmTransactionLegacy, Transaction as EvmTransaction } from "../../../../types";
import { GasEstimationError, InsufficientFunds } from "../../../../errors";
import { makeAccount } from "../../../fixtures/common.fixtures";
Expand All @@ -25,7 +25,7 @@ const fakeCurrencyWithoutRPC: Partial<CryptoCurrency> = {
id: "my_new_chain" as CryptoCurrencyId,
ethereumLikeInfo: {
chainId: 1,
},
} as EthereumLikeInfo,
units: [{ code: "ETH", name: "ETH", magnitude: 18 }],
};
const account = makeAccount(
Expand Down
20 changes: 16 additions & 4 deletions libs/coin-evm/src/__tests__/unit/logic.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,19 +500,31 @@ describe("EVM Family", () => {
it("should provide a new hash if currency is using a new explorer config", () => {
const hash1 = getSyncHash({
...currency,
ethereumLikeInfo: { chainId: 1, explorer: { type: "ledger", explorerId: "eth" } },
ethereumLikeInfo: {
...currency.ethereumLikeInfo!,
explorer: { type: "ledger", explorerId: "eth" },
},
});
const hash2 = getSyncHash({
...currency,
ethereumLikeInfo: { chainId: 1, explorer: { type: "ledger", explorerId: "matic" } },
ethereumLikeInfo: {
...currency.ethereumLikeInfo!,
explorer: { type: "ledger", explorerId: "matic" },
},
});
const hash3 = getSyncHash({
...currency,
ethereumLikeInfo: { chainId: 1, explorer: { type: "etherscan", uri: "anything" } },
ethereumLikeInfo: {
...currency.ethereumLikeInfo!,
explorer: { type: "etherscan", uri: "anything" },
},
});
const hash4 = getSyncHash({
...currency,
ethereumLikeInfo: { chainId: 1, explorer: { type: "blockscout", uri: "somethingelse" } },
ethereumLikeInfo: {
...currency.ethereumLikeInfo!,
explorer: { type: "blockscout", uri: "somethingelse" },
},
});

const hashes = [hash1, hash2, hash3, hash4];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe("EVM Family", () => {

describe("applyEIP155", () => {
const chainIds = listCryptoCurrencies(true)
.filter(c => c.family === "evm")
.filter(c => c.family === "evm" && c.ethereumLikeInfo !== undefined)
.map(c => c.ethereumLikeInfo!.chainId)
.sort((a, b) => a - b);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describe("EVM Family", () => {
uri: "http://nope.com",
type: "unsupported" as any,
},
},
} as any,
},
},
{} as any,
Expand Down
4 changes: 2 additions & 2 deletions libs/coin-evm/src/api/node/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type NodeConfig = EthereumLikeInfo["node"];
* Type guard
*/
export const isLedgerNodeConfig = (
nodeConfig: NodeConfig,
nodeConfig?: NodeConfig,
): nodeConfig is NodeConfig & { type: "ledger" } => {
return nodeConfig?.type === "ledger";
};
Expand All @@ -48,7 +48,7 @@ export const isLedgerNodeConfig = (
* Type guard
*/
export const isExternalNodeConfig = (
nodeConfig: NodeConfig,
nodeConfig?: NodeConfig,
): nodeConfig is NodeConfig & { type: "external" } => {
return nodeConfig?.type === "external";
};
4 changes: 2 additions & 2 deletions libs/coin-evm/src/datasets/ethereum1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { AccountRaw } from "@ledgerhq/types-live";

export const ethereum1: AccountRaw = {
id: "js:1:ethereum_as_evm_test_only:0x0E3F0bb9516F01f2C34c25E0957518b8aC9414c5:",
id: "js:1:ethereum:0x0E3F0bb9516F01f2C34c25E0957518b8aC9414c5:",
seedIdentifier: "0x0E3F0bb9516F01f2C34c25E0957518b8aC9414c5",
name: "Ethereum legacy xpub6Bem...JyAdpYZy",
derivationMode: "",
Expand All @@ -13,7 +13,7 @@ export const ethereum1: AccountRaw = {
freshAddresses: [],
pendingOperations: [],
operations: [],
currencyId: "ethereum_as_evm_test_only",
currencyId: "ethereum",
unitMagnitude: 18,
balance: "",
blockHeight: 0,
Expand Down
2 changes: 1 addition & 1 deletion libs/env/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ const envDefinitions: Record<string, EnvDef<boolean | string | number | string[]
desc: "if defined, avoids bypass of the currentDevice in the store.",
},
NFT_CURRENCIES: {
def: "ethereum,polygon,ethereum_as_evm_test_only,polygon_as_evm_test_only",
def: "ethereum,polygon",
parser: stringParser,
desc: "set the currencies where NFT is active",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,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
4 changes: 4 additions & 0 deletions libs/ledger-live-common/src/families/evm/react.react.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ const fakeCurrency: Partial<CryptoCurrency> = {
id: "my_new_chain" as CryptoCurrencyId,
ethereumLikeInfo: {
chainId: 1,
node: {
type: "ledger",
explorerId: "eth",
},
gasTracker: {
type: "ledger",
explorerId: "eth",
Expand Down
2 changes: 0 additions & 2 deletions libs/ledgerjs/packages/cryptoassets/src/abandonseed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ const abandonSeedAddresses: Partial<Record<CryptoCurrency["id"], string>> = {
quicksilver: "cosmos19rl4cm2hmr8afy4kldpxz3fka4jguq0auqdal4",
persistence: "cosmos19rl4cm2hmr8afy4kldpxz3fka4jguq0auqdal4",
internet_computer: "454109defbdd79d7283cdde63b8dab4d48f590b8b2923574cca0356ab6958b2b",
ethereum_as_evm_test_only: "0x0000000000000000000000000000000000000000",
polygon_as_evm_test_only: "0x0000000000000000000000000000000000000000",
telos_evm: "0x0000000000000000000000000000000000000000",
klaytn: "0x0000000000000000000000000000000000000000",
polygon_zk_evm: "0x0000000000000000000000000000000000000000",
Expand Down
Loading

0 comments on commit 15d6b16

Please sign in to comment.