From 68e3e8286eafeb3f1e4fa9d6aecbeb1cee100989 Mon Sep 17 00:00:00 2001 From: qperrot Date: Fri, 15 Nov 2024 11:19:11 +0100 Subject: [PATCH 01/25] fix: move crypto org into cosmos coin module --- .../families/crypto_org/AccountSubHeader.tsx | 5 - .../families/crypto_org/MemoValueField.tsx | 48 - .../crypto_org/SendRecipientFields.tsx | 18 - .../src/renderer/families/crypto_org/index.ts | 10 - .../src/renderer/families/crypto_org/types.ts | 14 - .../AddAccounts/steps/StepChooseCurrency.tsx | 3 + .../wallet-api-currencies-darwin.json | 4 +- .../wallet-api-currencies-linux.json | 4 +- .../RootNavigator/types/SendFundsNavigator.ts | 18 - .../types/SignTransactionNavigator.ts | 18 - .../RootNavigator/types/SwapNavigator.ts | 18 - .../src/const/navigation.ts | 3 - .../families/crypto_org/AccountSubHeader.tsx | 8 - .../src/families/crypto_org/EditMemo.tsx | 101 - .../src/families/crypto_org/MemoTagInput.tsx | 12 - .../families/crypto_org/SendRowsCustom.tsx | 88 - .../src/families/crypto_org/index.ts | 3 - .../screens/AddAccounts/01-SelectCrypto.tsx | 3 + .../coin-cosmos/src/chain/CryptoOrg.ts | 20 + .../coin-cosmos/src/chain/chain.ts | 4 + .../coin-cosmos/src/chain/chain.unit.test.ts | 1 + libs/coin-modules/coin-cosmos/src/config.ts | 10 + libs/coin-modules/coin-cosmos/src/specs.ts | 10 + .../ledger-live-common/src/account/helpers.ts | 1 + .../src/config/sharedConfig.ts | 2 - .../ledger-live-common/src/currencies/mock.ts | 30 + .../families/casper/speculos-deviceActions.ts | 4 +- .../datasets/croeseid.integration.test.ts | 14 + .../datasets/croeseid.ts | 0 .../src/families/crypto_org/NOTES.md | 10 - .../bridge.integration.test.ts.snap | 2462 ----------------- .../src/families/crypto_org/account.ts | 46 - .../src/families/crypto_org/api/index.ts | 1 - .../src/families/crypto_org/api/sdk.ts | 217 -- .../src/families/crypto_org/api/sdk.types.ts | 45 - .../crypto_org/bridge.integration.test.ts | 14 - .../src/families/crypto_org/broadcast.ts | 29 - .../crypto_org/buildOptimisticOperation.ts | 30 - .../families/crypto_org/buildTransaction.ts | 61 - .../families/crypto_org/cli-transaction.ts | 51 - .../src/families/crypto_org/config.ts | 12 - .../families/crypto_org/createTransaction.ts | 18 - .../crypto_org/deviceTransactionConfig.ts | 52 - .../src/families/crypto_org/errors.ts | 6 - .../crypto_org/estimateMaxSpendable.ts | 21 - .../crypto_org/getFeesForTransaction.ts | 13 - .../crypto_org/getTransactionStatus.ts | 61 - .../src/families/crypto_org/hw-getAddress.ts | 16 - .../src/families/crypto_org/logic.ts | 50 - .../families/crypto_org/prepareTransaction.ts | 28 - .../families/crypto_org/serialization.test.ts | 86 - .../src/families/crypto_org/serialization.ts | 43 - .../src/families/crypto_org/signOperation.ts | 130 - .../src/families/crypto_org/specs.ts | 75 - .../crypto_org/speculos-deviceActions.ts | 61 - .../families/crypto_org/synchronisation.ts | 52 - .../src/families/crypto_org/transaction.ts | 56 - .../src/families/crypto_org/types.ts | 57 - .../src/featureFlags/defaultFeatures.ts | 1 + .../src/generated/bridge/js.ts | 4 + .../src/generated/deviceTransactionConfig.ts | 4 + .../src/generated/hw-getAddress.ts | 4 + .../ledger-live-common/src/generated/specs.ts | 4 + .../src/generated/transaction.ts | 4 + .../ledger-live-common/src/generated/types.ts | 10 - .../packages/cryptoassets/src/currencies.ts | 10 +- .../packages/types-live/src/feature.ts | 1 + 67 files changed, 129 insertions(+), 4190 deletions(-) delete mode 100644 apps/ledger-live-desktop/src/renderer/families/crypto_org/AccountSubHeader.tsx delete mode 100644 apps/ledger-live-desktop/src/renderer/families/crypto_org/MemoValueField.tsx delete mode 100644 apps/ledger-live-desktop/src/renderer/families/crypto_org/SendRecipientFields.tsx delete mode 100644 apps/ledger-live-desktop/src/renderer/families/crypto_org/index.ts delete mode 100644 apps/ledger-live-desktop/src/renderer/families/crypto_org/types.ts delete mode 100644 apps/ledger-live-mobile/src/families/crypto_org/AccountSubHeader.tsx delete mode 100644 apps/ledger-live-mobile/src/families/crypto_org/EditMemo.tsx delete mode 100644 apps/ledger-live-mobile/src/families/crypto_org/MemoTagInput.tsx delete mode 100644 apps/ledger-live-mobile/src/families/crypto_org/SendRowsCustom.tsx delete mode 100644 apps/ledger-live-mobile/src/families/crypto_org/index.ts create mode 100644 libs/coin-modules/coin-cosmos/src/chain/CryptoOrg.ts create mode 100644 libs/ledger-live-common/src/families/cosmos/datasets/croeseid.integration.test.ts rename libs/ledger-live-common/src/families/{crypto_org => cosmos}/datasets/croeseid.ts (100%) delete mode 100644 libs/ledger-live-common/src/families/crypto_org/NOTES.md delete mode 100644 libs/ledger-live-common/src/families/crypto_org/__snapshots__/bridge.integration.test.ts.snap delete mode 100644 libs/ledger-live-common/src/families/crypto_org/account.ts delete mode 100644 libs/ledger-live-common/src/families/crypto_org/api/index.ts delete mode 100644 libs/ledger-live-common/src/families/crypto_org/api/sdk.ts delete mode 100644 libs/ledger-live-common/src/families/crypto_org/api/sdk.types.ts delete mode 100644 libs/ledger-live-common/src/families/crypto_org/bridge.integration.test.ts delete mode 100644 libs/ledger-live-common/src/families/crypto_org/broadcast.ts delete mode 100644 libs/ledger-live-common/src/families/crypto_org/buildOptimisticOperation.ts delete mode 100644 libs/ledger-live-common/src/families/crypto_org/buildTransaction.ts delete mode 100644 libs/ledger-live-common/src/families/crypto_org/cli-transaction.ts delete mode 100644 libs/ledger-live-common/src/families/crypto_org/config.ts delete mode 100644 libs/ledger-live-common/src/families/crypto_org/createTransaction.ts delete mode 100644 libs/ledger-live-common/src/families/crypto_org/deviceTransactionConfig.ts delete mode 100644 libs/ledger-live-common/src/families/crypto_org/errors.ts delete mode 100644 libs/ledger-live-common/src/families/crypto_org/estimateMaxSpendable.ts delete mode 100644 libs/ledger-live-common/src/families/crypto_org/getFeesForTransaction.ts delete mode 100644 libs/ledger-live-common/src/families/crypto_org/getTransactionStatus.ts delete mode 100644 libs/ledger-live-common/src/families/crypto_org/hw-getAddress.ts delete mode 100644 libs/ledger-live-common/src/families/crypto_org/logic.ts delete mode 100644 libs/ledger-live-common/src/families/crypto_org/prepareTransaction.ts delete mode 100644 libs/ledger-live-common/src/families/crypto_org/serialization.test.ts delete mode 100644 libs/ledger-live-common/src/families/crypto_org/serialization.ts delete mode 100644 libs/ledger-live-common/src/families/crypto_org/signOperation.ts delete mode 100644 libs/ledger-live-common/src/families/crypto_org/specs.ts delete mode 100644 libs/ledger-live-common/src/families/crypto_org/speculos-deviceActions.ts delete mode 100644 libs/ledger-live-common/src/families/crypto_org/synchronisation.ts delete mode 100644 libs/ledger-live-common/src/families/crypto_org/transaction.ts delete mode 100644 libs/ledger-live-common/src/families/crypto_org/types.ts diff --git a/apps/ledger-live-desktop/src/renderer/families/crypto_org/AccountSubHeader.tsx b/apps/ledger-live-desktop/src/renderer/families/crypto_org/AccountSubHeader.tsx deleted file mode 100644 index 696e14f16821..000000000000 --- a/apps/ledger-live-desktop/src/renderer/families/crypto_org/AccountSubHeader.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import React from "react"; -import AccountSubHeader from "../../components/AccountSubHeader/index"; -export default function CryptoOrgAccountSubHeader() { - return ; -} diff --git a/apps/ledger-live-desktop/src/renderer/families/crypto_org/MemoValueField.tsx b/apps/ledger-live-desktop/src/renderer/families/crypto_org/MemoValueField.tsx deleted file mode 100644 index 4d7b3eb8d3f5..000000000000 --- a/apps/ledger-live-desktop/src/renderer/families/crypto_org/MemoValueField.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import React, { useCallback } from "react"; -import { getAccountBridge } from "@ledgerhq/live-common/bridge/index"; -import { - CryptoOrgAccount, - Transaction, - TransactionStatus, -} from "@ledgerhq/live-common/families/crypto_org/types"; -import MemoTagField from "LLD/features/MemoTag/components/MemoTagField"; - -const MemoValueField = ({ - onChange, - account, - transaction, - status, - autoFocus, -}: { - onChange: (t: Transaction) => void; - account: CryptoOrgAccount; - transaction: Transaction; - status: TransactionStatus; - autoFocus?: boolean; -}) => { - const bridge = getAccountBridge(account); - const onMemoValueChange = useCallback( - (memo: string) => { - onChange( - bridge.updateTransaction(transaction, { - memo, - }), - ); - }, - [onChange, transaction, bridge], - ); - - // We use transaction as an error here. - // It will be usefull to block a memo wrong format - // on the ledger-live mobile - return ( - - ); -}; -export default MemoValueField; diff --git a/apps/ledger-live-desktop/src/renderer/families/crypto_org/SendRecipientFields.tsx b/apps/ledger-live-desktop/src/renderer/families/crypto_org/SendRecipientFields.tsx deleted file mode 100644 index 94e39c35b959..000000000000 --- a/apps/ledger-live-desktop/src/renderer/families/crypto_org/SendRecipientFields.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import React from "react"; -import Box from "~/renderer/components/Box"; -import MemoValueField from "./MemoValueField"; -import { CryptoOrgFamily } from "./types"; - -const Root: NonNullable["component"] = props => { - return ( - - - - ); -}; -export default { - component: Root, - // Transaction is used here to prevent user to forward - // If he format a memo incorrectly - fields: ["memo", "transaction"], -}; diff --git a/apps/ledger-live-desktop/src/renderer/families/crypto_org/index.ts b/apps/ledger-live-desktop/src/renderer/families/crypto_org/index.ts deleted file mode 100644 index 2bbd4db6f381..000000000000 --- a/apps/ledger-live-desktop/src/renderer/families/crypto_org/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -import AccountSubHeader from "./AccountSubHeader"; -import sendRecipientFields from "./SendRecipientFields"; -import { CryptoOrgFamily } from "./types"; - -const family: CryptoOrgFamily = { - AccountSubHeader, - sendRecipientFields, -}; - -export default family; diff --git a/apps/ledger-live-desktop/src/renderer/families/crypto_org/types.ts b/apps/ledger-live-desktop/src/renderer/families/crypto_org/types.ts deleted file mode 100644 index aa9f26eca2d9..000000000000 --- a/apps/ledger-live-desktop/src/renderer/families/crypto_org/types.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { - CryptoOrgAccount, - CryptoOrgOperation, - Transaction, - TransactionStatus, -} from "@ledgerhq/live-common/families/crypto_org/types"; -import { LLDCoinFamily } from "../types"; - -export type CryptoOrgFamily = LLDCoinFamily< - CryptoOrgAccount, - Transaction, - TransactionStatus, - CryptoOrgOperation ->; diff --git a/apps/ledger-live-desktop/src/renderer/modals/AddAccounts/steps/StepChooseCurrency.tsx b/apps/ledger-live-desktop/src/renderer/modals/AddAccounts/steps/StepChooseCurrency.tsx index ff8771d32721..b31cf47f5415 100644 --- a/apps/ledger-live-desktop/src/renderer/modals/AddAccounts/steps/StepChooseCurrency.tsx +++ b/apps/ledger-live-desktop/src/renderer/modals/AddAccounts/steps/StepChooseCurrency.tsx @@ -85,6 +85,7 @@ const StepChooseCurrency = ({ currency, setCurrency }: StepProps) => { const zksync = useFeature("currencyZkSync"); const zksyncSepolia = useFeature("currencyZkSyncSepolia"); const mantra = useFeature("currencyMantra"); + const cryptoOrg = useFeature("currencyCryptoOrg"); const featureFlaggedCurrencies = useMemo( (): Partial | null>> => ({ @@ -138,6 +139,7 @@ const StepChooseCurrency = ({ currency, setCurrency }: StepProps) => { zksync, zksync_sepolia: zksyncSepolia, mantra, + crypto_org: cryptoOrg, }), [ axelar, @@ -190,6 +192,7 @@ const StepChooseCurrency = ({ currency, setCurrency }: StepProps) => { zksync, zksyncSepolia, mantra, + cryptoOrg, ], ); diff --git a/apps/ledger-live-desktop/tests/specs/services/wallet-api.spec.ts-snapshots/wallet-api-currencies-darwin.json b/apps/ledger-live-desktop/tests/specs/services/wallet-api.spec.ts-snapshots/wallet-api-currencies-darwin.json index b68c11c448b1..eee2e9e5feb1 100644 --- a/apps/ledger-live-desktop/tests/specs/services/wallet-api.spec.ts-snapshots/wallet-api-currencies-darwin.json +++ b/apps/ledger-live-desktop/tests/specs/services/wallet-api.spec.ts-snapshots/wallet-api-currencies-darwin.json @@ -211,7 +211,7 @@ "id": "crypto_org", "ticker": "CRO", "name": "Cronos POS Chain", - "family": "crypto_org", + "family": "cosmos", "color": "#0e1c37", "decimals": 8 }, @@ -220,7 +220,7 @@ "id": "crypto_org_croeseid", "ticker": "CRO", "name": "Cronos POS Chain Croeseid", - "family": "crypto_org", + "family": "cosmos", "color": "#0e1c37", "decimals": 8 }, diff --git a/apps/ledger-live-desktop/tests/specs/services/wallet-api.spec.ts-snapshots/wallet-api-currencies-linux.json b/apps/ledger-live-desktop/tests/specs/services/wallet-api.spec.ts-snapshots/wallet-api-currencies-linux.json index b68c11c448b1..eee2e9e5feb1 100644 --- a/apps/ledger-live-desktop/tests/specs/services/wallet-api.spec.ts-snapshots/wallet-api-currencies-linux.json +++ b/apps/ledger-live-desktop/tests/specs/services/wallet-api.spec.ts-snapshots/wallet-api-currencies-linux.json @@ -211,7 +211,7 @@ "id": "crypto_org", "ticker": "CRO", "name": "Cronos POS Chain", - "family": "crypto_org", + "family": "cosmos", "color": "#0e1c37", "decimals": 8 }, @@ -220,7 +220,7 @@ "id": "crypto_org_croeseid", "ticker": "CRO", "name": "Cronos POS Chain Croeseid", - "family": "crypto_org", + "family": "cosmos", "color": "#0e1c37", "decimals": 8 }, diff --git a/apps/ledger-live-mobile/src/components/RootNavigator/types/SendFundsNavigator.ts b/apps/ledger-live-mobile/src/components/RootNavigator/types/SendFundsNavigator.ts index ea80b326f7ba..cad605f2a3c0 100644 --- a/apps/ledger-live-mobile/src/components/RootNavigator/types/SendFundsNavigator.ts +++ b/apps/ledger-live-mobile/src/components/RootNavigator/types/SendFundsNavigator.ts @@ -22,10 +22,6 @@ import { CosmosAccount, Transaction as CosmosTransaction, } from "@ledgerhq/live-common/families/cosmos/types"; -import { - CryptoOrgAccount, - Transaction as CryptoOrgTransaction, -} from "@ledgerhq/live-common/families/crypto_org/types"; import { Transaction as HederaTransaction } from "@ledgerhq/live-common/families/hedera/types"; import { SolanaAccount, @@ -248,20 +244,6 @@ export type SendFundsNavigatorStackParamList = { | ScreenName.SendSelectDevice | ScreenName.SwapForm; }; - [ScreenName.CryptoOrgEditMemo]: { - accountId: string; - parentId?: string; - account: CryptoOrgAccount; - transaction: CryptoOrgTransaction; - currentNavigation: - | ScreenName.SignTransactionSummary - | ScreenName.SendSummary - | ScreenName.SwapForm; - nextNavigation: - | ScreenName.SignTransactionSelectDevice - | ScreenName.SendSelectDevice - | ScreenName.SwapForm; - }; [ScreenName.HederaEditMemo]: { accountId: string; parentId?: string; diff --git a/apps/ledger-live-mobile/src/components/RootNavigator/types/SignTransactionNavigator.ts b/apps/ledger-live-mobile/src/components/RootNavigator/types/SignTransactionNavigator.ts index 8b81d49ddf40..9dd7e2e9e4a0 100644 --- a/apps/ledger-live-mobile/src/components/RootNavigator/types/SignTransactionNavigator.ts +++ b/apps/ledger-live-mobile/src/components/RootNavigator/types/SignTransactionNavigator.ts @@ -17,10 +17,6 @@ import { CosmosAccount, Transaction as CosmosTransaction, } from "@ledgerhq/live-common/families/cosmos/types"; -import { - CryptoOrgAccount, - Transaction as CryptoOrgTransaction, -} from "@ledgerhq/live-common/families/crypto_org/types"; import { SolanaAccount, Transaction as SolanaTransaction, @@ -210,20 +206,6 @@ export type SignTransactionNavigatorParamList = { | ScreenName.SendSelectDevice | ScreenName.SwapForm; }; - [ScreenName.CryptoOrgEditMemo]: { - accountId: string; - parentId?: string; - account: CryptoOrgAccount; - transaction: CryptoOrgTransaction; - currentNavigation: - | ScreenName.SignTransactionSummary - | ScreenName.SendSummary - | ScreenName.SwapForm; - nextNavigation: - | ScreenName.SignTransactionSelectDevice - | ScreenName.SendSelectDevice - | ScreenName.SwapForm; - }; [ScreenName.HederaEditMemo]: { accountId: string; parentId?: string; diff --git a/apps/ledger-live-mobile/src/components/RootNavigator/types/SwapNavigator.ts b/apps/ledger-live-mobile/src/components/RootNavigator/types/SwapNavigator.ts index fabdb2249ade..7bc8272f5b3e 100644 --- a/apps/ledger-live-mobile/src/components/RootNavigator/types/SwapNavigator.ts +++ b/apps/ledger-live-mobile/src/components/RootNavigator/types/SwapNavigator.ts @@ -27,10 +27,6 @@ import { CosmosAccount, Transaction as CosmosTransaction, } from "@ledgerhq/live-common/families/cosmos/types"; -import { - CryptoOrgAccount, - Transaction as CryptoOrgTransaction, -} from "@ledgerhq/live-common/families/crypto_org/types"; import { SolanaAccount, Transaction as SolanaTransaction, @@ -208,20 +204,6 @@ export type SwapNavigatorParamList = { | ScreenName.SendSelectDevice | ScreenName.SwapForm; }; - [ScreenName.CryptoOrgEditMemo]: { - accountId: string; - parentId?: string; - account: CryptoOrgAccount; - transaction: CryptoOrgTransaction; - currentNavigation: - | ScreenName.SignTransactionSummary - | ScreenName.SendSummary - | ScreenName.SwapForm; - nextNavigation: - | ScreenName.SignTransactionSelectDevice - | ScreenName.SendSelectDevice - | ScreenName.SwapForm; - }; [ScreenName.HederaEditMemo]: { accountId: string; parentId?: string; diff --git a/apps/ledger-live-mobile/src/const/navigation.ts b/apps/ledger-live-mobile/src/const/navigation.ts index 8006569c73a5..e57a7a95944b 100644 --- a/apps/ledger-live-mobile/src/const/navigation.ts +++ b/apps/ledger-live-mobile/src/const/navigation.ts @@ -320,9 +320,6 @@ export enum ScreenName { // ton TonEditComment = "TonEditComment", - // crypto_org - CryptoOrgEditMemo = "CryptoOrgEditMemo", - // Algorand AlgorandEditMemo = "AlgorandEditMemo", AlgorandClaimRewardsInfo = "AlgorandClaimRewardsInfo", diff --git a/apps/ledger-live-mobile/src/families/crypto_org/AccountSubHeader.tsx b/apps/ledger-live-mobile/src/families/crypto_org/AccountSubHeader.tsx deleted file mode 100644 index 25a23826567c..000000000000 --- a/apps/ledger-live-mobile/src/families/crypto_org/AccountSubHeader.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import React from "react"; -import AccountSubHeader from "~/components/AccountSubHeader"; - -function CryptoOrgAccountSubHeader() { - return ; -} - -export default CryptoOrgAccountSubHeader; diff --git a/apps/ledger-live-mobile/src/families/crypto_org/EditMemo.tsx b/apps/ledger-live-mobile/src/families/crypto_org/EditMemo.tsx deleted file mode 100644 index 5fb77c4ae388..000000000000 --- a/apps/ledger-live-mobile/src/families/crypto_org/EditMemo.tsx +++ /dev/null @@ -1,101 +0,0 @@ -import React, { useCallback, useState } from "react"; -import { View, StyleSheet, ScrollView } from "react-native"; -import { SafeAreaView } from "react-native-safe-area-context"; -import { useTranslation } from "react-i18next"; -import i18next from "i18next"; -import { getAccountBridge } from "@ledgerhq/live-common/bridge/index"; -import { useTheme } from "@react-navigation/native"; -import KeyboardView from "~/components/KeyboardView"; -import Button from "~/components/Button"; -import { ScreenName } from "~/const"; -import TextInput from "~/components/FocusedTextInput"; -import { StackNavigatorProps } from "~/components/RootNavigator/types/helpers"; -import { SendFundsNavigatorStackParamList } from "~/components/RootNavigator/types/SendFundsNavigator"; - -type Props = StackNavigatorProps; - -function CryptoOrgEditMemo({ navigation, route }: Props) { - const { colors } = useTheme(); - const { t } = useTranslation(); - const [memo, setMemo] = useState(route.params.transaction.memo); - const account = route.params.account; - const onValidateText = useCallback(() => { - const bridge = getAccountBridge(account); - const { transaction } = route.params; - navigation.navigate(ScreenName.SendSummary, { - ...route.params, - accountId: account.id, - transaction: bridge.updateTransaction(transaction, { - memo, - }), - }); - }, [navigation, route.params, account, memo]); - return ( - - - - - - -