From 073414f3e191bc92fa9a26c7dfd60e8f632a19a1 Mon Sep 17 00:00:00 2001 From: Canestin Date: Wed, 18 Dec 2024 15:47:23 +0100 Subject: [PATCH 1/4] feat: zenrock integration --- apps/cli/src/live-common-setup-base.ts | 1 + .../live-common-set-supported-currencies.ts | 1 + .../AddAccounts/steps/StepChooseCurrency.tsx | 3 + .../wallet-api-currencies-darwin.json | 9 +++ .../wallet-api-currencies-linux.json | 9 +++ .../src/live-common-setup.ts | 1 + .../screens/AddAccounts/01-SelectCrypto.tsx | 3 + apps/web-tools/live-common-setup.ts | 1 + .../formatCurrencyUnit.test.ts.snap | 22 ++++++ .../coin-cosmos/src/chain/Zenrock.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 +++ .../src/__tests__/test-helpers/environment.ts | 1 + .../ledger-live-common/src/account/helpers.ts | 1 + .../sortByMarketcap.test.ts.snap | 1 + .../ledger-live-common/src/currencies/mock.ts | 1 + .../src/currencies/sortByMarketcap.test.ts | 1 + .../zenrock.integration.test.ts.snap | 28 ++++++++ .../datasets/zenrock.integration.test.ts | 14 ++++ .../src/families/cosmos/datasets/zenrock.ts | 67 +++++++++++++++++++ .../src/featureFlags/defaultFeatures.ts | 1 + .../packages/cryptoassets/src/abandonseed.ts | 1 + .../packages/cryptoassets/src/currencies.ts | 29 ++++++++ .../packages/types-cryptoassets/src/index.ts | 1 + .../packages/types-live/src/feature.ts | 1 + .../ui/packages/crypto-icons/src/svg/ROCK.svg | 10 +++ 28 files changed, 252 insertions(+) create mode 100644 libs/coin-modules/coin-cosmos/src/chain/Zenrock.ts create mode 100644 libs/ledger-live-common/src/families/cosmos/datasets/__snapshots__/zenrock.integration.test.ts.snap create mode 100644 libs/ledger-live-common/src/families/cosmos/datasets/zenrock.integration.test.ts create mode 100644 libs/ledger-live-common/src/families/cosmos/datasets/zenrock.ts create mode 100644 libs/ui/packages/crypto-icons/src/svg/ROCK.svg diff --git a/apps/cli/src/live-common-setup-base.ts b/apps/cli/src/live-common-setup-base.ts index 631f9ec6fdf..f3eddbad9ac 100644 --- a/apps/cli/src/live-common-setup-base.ts +++ b/apps/cli/src/live-common-setup-base.ts @@ -103,6 +103,7 @@ setSupportedCurrencies([ "zksync_sepolia", "mantra", "xion", + "zenrock", ]); for (const k in process.env) setEnvUnsafe(k as EnvName, process.env[k]); diff --git a/apps/ledger-live-desktop/src/live-common-set-supported-currencies.ts b/apps/ledger-live-desktop/src/live-common-set-supported-currencies.ts index a9ad1858c4b..1a774f69138 100644 --- a/apps/ledger-live-desktop/src/live-common-set-supported-currencies.ts +++ b/apps/ledger-live-desktop/src/live-common-set-supported-currencies.ts @@ -97,4 +97,5 @@ setSupportedCurrencies([ "zksync_sepolia", "mantra", "xion", + "zenrock", ]); 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 50d28cde6e2..c87fa2cd3f9 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 @@ -86,6 +86,7 @@ const StepChooseCurrency = ({ currency, setCurrency }: StepProps) => { const zksyncSepolia = useFeature("currencyZkSyncSepolia"); const mantra = useFeature("currencyMantra"); const xion = useFeature("currencyXion"); + const zenrock = useFeature("currencyZenrock"); const featureFlaggedCurrencies = useMemo( (): Partial | null>> => ({ @@ -140,6 +141,7 @@ const StepChooseCurrency = ({ currency, setCurrency }: StepProps) => { zksync_sepolia: zksyncSepolia, mantra, xion, + zenrock, }), [ axelar, @@ -193,6 +195,7 @@ const StepChooseCurrency = ({ currency, setCurrency }: StepProps) => { zksyncSepolia, mantra, xion, + zenrock, ], ); 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 efcbd915c44..a8c7bf73315 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 @@ -817,5 +817,14 @@ "family": "cosmos", "color": "#000000", "decimals": 6 + }, + { + "type": "CryptoCurrency", + "id": "zenrock", + "ticker": "ROCK", + "name": "Zenrock", + "family": "cosmos", + "color": "#080c44", + "decimals": 6 } ] \ No newline at end of file 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 efcbd915c44..a8c7bf73315 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 @@ -817,5 +817,14 @@ "family": "cosmos", "color": "#000000", "decimals": 6 + }, + { + "type": "CryptoCurrency", + "id": "zenrock", + "ticker": "ROCK", + "name": "Zenrock", + "family": "cosmos", + "color": "#080c44", + "decimals": 6 } ] \ No newline at end of file diff --git a/apps/ledger-live-mobile/src/live-common-setup.ts b/apps/ledger-live-mobile/src/live-common-setup.ts index 9010091d902..d63b0d66a0c 100644 --- a/apps/ledger-live-mobile/src/live-common-setup.ts +++ b/apps/ledger-live-mobile/src/live-common-setup.ts @@ -130,6 +130,7 @@ setSupportedCurrencies([ "zksync_sepolia", "mantra", "xion", + "zenrock", ]); if (Config.BLE_LOG_LEVEL) BluetoothTransport.setLogLevel(Config.BLE_LOG_LEVEL); diff --git a/apps/ledger-live-mobile/src/screens/AddAccounts/01-SelectCrypto.tsx b/apps/ledger-live-mobile/src/screens/AddAccounts/01-SelectCrypto.tsx index 6e930fb44c8..94cfbe72e39 100644 --- a/apps/ledger-live-mobile/src/screens/AddAccounts/01-SelectCrypto.tsx +++ b/apps/ledger-live-mobile/src/screens/AddAccounts/01-SelectCrypto.tsx @@ -108,6 +108,7 @@ export default function AddAccountsSelectCrypto({ navigation, route }: Props) { const zksyncSepolia = useFeature("currencyZkSyncSepolia"); const mantra = useFeature("currencyMantra"); const xion = useFeature("currencyXion"); + const zenrock = useFeature("currencyZenrock"); const featureFlaggedCurrencies = useMemo( (): Partial | null>> => ({ @@ -162,6 +163,7 @@ export default function AddAccountsSelectCrypto({ navigation, route }: Props) { zksync_sepolia: zksyncSepolia, mantra, xion, + zenrock, }), [ axelar, @@ -215,6 +217,7 @@ export default function AddAccountsSelectCrypto({ navigation, route }: Props) { zksyncSepolia, mantra, xion, + zenrock, ], ); diff --git a/apps/web-tools/live-common-setup.ts b/apps/web-tools/live-common-setup.ts index b5d7c10cd3f..233f85d4959 100644 --- a/apps/web-tools/live-common-setup.ts +++ b/apps/web-tools/live-common-setup.ts @@ -71,4 +71,5 @@ setSupportedCurrencies([ "linea_sepolia", "mantra", "xion", + "zenrock", ]); diff --git a/libs/coin-framework/src/currencies/__snapshots__/formatCurrencyUnit.test.ts.snap b/libs/coin-framework/src/currencies/__snapshots__/formatCurrencyUnit.test.ts.snap index 79f5a23ede1..1859ee14ddd 100644 --- a/libs/coin-framework/src/currencies/__snapshots__/formatCurrencyUnit.test.ts.snap +++ b/libs/coin-framework/src/currencies/__snapshots__/formatCurrencyUnit.test.ts.snap @@ -326,6 +326,8 @@ exports[`formatCurrencyUnit with custom options with locale de-DE should correct exports[`formatCurrencyUnit with custom options with locale de-DE should correctly format Zcash unit (zcash) 1`] = `"123.456.789,00000000- -ZEC"`; +exports[`formatCurrencyUnit with custom options with locale de-DE should correctly format Zenrock unit (Zenrock) 1`] = `"12.345.678.900,000000- -ROCK"`; + exports[`formatCurrencyUnit with custom options with locale de-DE should correctly format Zilliqa unit (ZIL) 1`] = `"12.345,678900000000- -ZIL"`; exports[`formatCurrencyUnit with custom options with locale de-DE should correctly format dYdX unit (dYdX) 1`] = `"0,012345678900000000- -dydx"`; @@ -660,6 +662,8 @@ exports[`formatCurrencyUnit with custom options with locale en-US should correct exports[`formatCurrencyUnit with custom options with locale en-US should correctly format Zcash unit (zcash) 1`] = `"123,456,789.00000000- -ZEC"`; +exports[`formatCurrencyUnit with custom options with locale en-US should correctly format Zenrock unit (Zenrock) 1`] = `"12,345,678,900.000000- -ROCK"`; + exports[`formatCurrencyUnit with custom options with locale en-US should correctly format Zilliqa unit (ZIL) 1`] = `"12,345.678900000000- -ZIL"`; exports[`formatCurrencyUnit with custom options with locale en-US should correctly format dYdX unit (dYdX) 1`] = `"0.012345678900000000- -dydx"`; @@ -994,6 +998,8 @@ exports[`formatCurrencyUnit with custom options with locale es-ES should correct exports[`formatCurrencyUnit with custom options with locale es-ES should correctly format Zcash unit (zcash) 1`] = `"123.456.789,00000000- -ZEC"`; +exports[`formatCurrencyUnit with custom options with locale es-ES should correctly format Zenrock unit (Zenrock) 1`] = `"12.345.678.900,000000- -ROCK"`; + exports[`formatCurrencyUnit with custom options with locale es-ES should correctly format Zilliqa unit (ZIL) 1`] = `"12.345,678900000000- -ZIL"`; exports[`formatCurrencyUnit with custom options with locale es-ES should correctly format dYdX unit (dYdX) 1`] = `"0,012345678900000000- -dydx"`; @@ -1328,6 +1334,8 @@ exports[`formatCurrencyUnit with custom options with locale fr-FR should correct exports[`formatCurrencyUnit with custom options with locale fr-FR should correctly format Zcash unit (zcash) 1`] = `"123 456 789,00000000- -ZEC"`; +exports[`formatCurrencyUnit with custom options with locale fr-FR should correctly format Zenrock unit (Zenrock) 1`] = `"12 345 678 900,000000- -ROCK"`; + exports[`formatCurrencyUnit with custom options with locale fr-FR should correctly format Zilliqa unit (ZIL) 1`] = `"12 345,678900000000- -ZIL"`; exports[`formatCurrencyUnit with custom options with locale fr-FR should correctly format dYdX unit (dYdX) 1`] = `"0,012345678900000000- -dydx"`; @@ -1662,6 +1670,8 @@ exports[`formatCurrencyUnit with custom options with locale ja-JP should correct exports[`formatCurrencyUnit with custom options with locale ja-JP should correctly format Zcash unit (zcash) 1`] = `"123,456,789.00000000- -ZEC"`; +exports[`formatCurrencyUnit with custom options with locale ja-JP should correctly format Zenrock unit (Zenrock) 1`] = `"12,345,678,900.000000- -ROCK"`; + exports[`formatCurrencyUnit with custom options with locale ja-JP should correctly format Zilliqa unit (ZIL) 1`] = `"12,345.678900000000- -ZIL"`; exports[`formatCurrencyUnit with custom options with locale ja-JP should correctly format dYdX unit (dYdX) 1`] = `"0.012345678900000000- -dydx"`; @@ -1996,6 +2006,8 @@ exports[`formatCurrencyUnit with custom options with locale ko-KR should correct exports[`formatCurrencyUnit with custom options with locale ko-KR should correctly format Zcash unit (zcash) 1`] = `"123,456,789.00000000- -ZEC"`; +exports[`formatCurrencyUnit with custom options with locale ko-KR should correctly format Zenrock unit (Zenrock) 1`] = `"12,345,678,900.000000- -ROCK"`; + exports[`formatCurrencyUnit with custom options with locale ko-KR should correctly format Zilliqa unit (ZIL) 1`] = `"12,345.678900000000- -ZIL"`; exports[`formatCurrencyUnit with custom options with locale ko-KR should correctly format dYdX unit (dYdX) 1`] = `"0.012345678900000000- -dydx"`; @@ -2330,6 +2342,8 @@ exports[`formatCurrencyUnit with custom options with locale pt-BR should correct exports[`formatCurrencyUnit with custom options with locale pt-BR should correctly format Zcash unit (zcash) 1`] = `"123.456.789,00000000- -ZEC"`; +exports[`formatCurrencyUnit with custom options with locale pt-BR should correctly format Zenrock unit (Zenrock) 1`] = `"12.345.678.900,000000- -ROCK"`; + exports[`formatCurrencyUnit with custom options with locale pt-BR should correctly format Zilliqa unit (ZIL) 1`] = `"12.345,678900000000- -ZIL"`; exports[`formatCurrencyUnit with custom options with locale pt-BR should correctly format dYdX unit (dYdX) 1`] = `"0,012345678900000000- -dydx"`; @@ -2664,6 +2678,8 @@ exports[`formatCurrencyUnit with custom options with locale ru-RU should correct exports[`formatCurrencyUnit with custom options with locale ru-RU should correctly format Zcash unit (zcash) 1`] = `"123 456 789,00000000- -ZEC"`; +exports[`formatCurrencyUnit with custom options with locale ru-RU should correctly format Zenrock unit (Zenrock) 1`] = `"12 345 678 900,000000- -ROCK"`; + exports[`formatCurrencyUnit with custom options with locale ru-RU should correctly format Zilliqa unit (ZIL) 1`] = `"12 345,678900000000- -ZIL"`; exports[`formatCurrencyUnit with custom options with locale ru-RU should correctly format dYdX unit (dYdX) 1`] = `"0,012345678900000000- -dydx"`; @@ -2998,6 +3014,8 @@ exports[`formatCurrencyUnit with custom options with locale tr-TR should correct exports[`formatCurrencyUnit with custom options with locale tr-TR should correctly format Zcash unit (zcash) 1`] = `"123.456.789,00000000- -ZEC"`; +exports[`formatCurrencyUnit with custom options with locale tr-TR should correctly format Zenrock unit (Zenrock) 1`] = `"12.345.678.900,000000- -ROCK"`; + exports[`formatCurrencyUnit with custom options with locale tr-TR should correctly format Zilliqa unit (ZIL) 1`] = `"12.345,678900000000- -ZIL"`; exports[`formatCurrencyUnit with custom options with locale tr-TR should correctly format dYdX unit (dYdX) 1`] = `"0,012345678900000000- -dydx"`; @@ -3332,6 +3350,8 @@ exports[`formatCurrencyUnit with custom options with locale zh-CN should correct exports[`formatCurrencyUnit with custom options with locale zh-CN should correctly format Zcash unit (zcash) 1`] = `"123,456,789.00000000- -ZEC"`; +exports[`formatCurrencyUnit with custom options with locale zh-CN should correctly format Zenrock unit (Zenrock) 1`] = `"12,345,678,900.000000- -ROCK"`; + exports[`formatCurrencyUnit with custom options with locale zh-CN should correctly format Zilliqa unit (ZIL) 1`] = `"12,345.678900000000- -ZIL"`; exports[`formatCurrencyUnit with custom options with locale zh-CN should correctly format dYdX unit (dYdX) 1`] = `"0.012345678900000000- -dydx"`; @@ -3666,6 +3686,8 @@ exports[`formatCurrencyUnit with default options should correctly format ZKsync exports[`formatCurrencyUnit with default options should correctly format Zcash unit (zcash) 1`] = `"123,456,789"`; +exports[`formatCurrencyUnit with default options should correctly format Zenrock unit (Zenrock) 1`] = `"12,345,678,900"`; + exports[`formatCurrencyUnit with default options should correctly format Zilliqa unit (ZIL) 1`] = `"12,345.6"`; exports[`formatCurrencyUnit with default options should correctly format dYdX unit (dYdX) 1`] = `"0.0123456"`; diff --git a/libs/coin-modules/coin-cosmos/src/chain/Zenrock.ts b/libs/coin-modules/coin-cosmos/src/chain/Zenrock.ts new file mode 100644 index 00000000000..c243537e964 --- /dev/null +++ b/libs/coin-modules/coin-cosmos/src/chain/Zenrock.ts @@ -0,0 +1,20 @@ +import CosmosBase from "./cosmosBase"; + +class Zenrock extends CosmosBase { + stakingDocUrl: string; + unbondingPeriod: number; + prefix: string; + validatorPrefix: string; + // Provided by coin config + ledgerValidator!: string; + lcd!: string; + constructor() { + super(); + this.stakingDocUrl = ""; + this.unbondingPeriod = 21; + this.prefix = "zen"; + this.validatorPrefix = `${this.prefix}valoper`; + } +} + +export default Zenrock; diff --git a/libs/coin-modules/coin-cosmos/src/chain/chain.ts b/libs/coin-modules/coin-cosmos/src/chain/chain.ts index ccbfdee3c57..04458274701 100644 --- a/libs/coin-modules/coin-cosmos/src/chain/chain.ts +++ b/libs/coin-modules/coin-cosmos/src/chain/chain.ts @@ -19,6 +19,7 @@ import Dydx from "./Dydx"; import Mantra from "./Mantra"; import CryptoOrg from "./CryptoOrg"; import Xion from "./Xion"; +import Zenrock from "./Zenrock"; const cosmosChainParams: { [key: string]: CosmosBase } = {}; export default function cryptoFactory(currencyId: string): CosmosBase { @@ -86,6 +87,9 @@ export default function cryptoFactory(currencyId: string): CosmosBase { case "xion": cosmosChainParams[currencyId] = new Xion(); break; + case "zenrock": + cosmosChainParams[currencyId] = new Zenrock(); + break; default: throw new Error(`${currencyId} is not supported`); } diff --git a/libs/coin-modules/coin-cosmos/src/chain/chain.unit.test.ts b/libs/coin-modules/coin-cosmos/src/chain/chain.unit.test.ts index 5be6d778d19..812cc180a18 100644 --- a/libs/coin-modules/coin-cosmos/src/chain/chain.unit.test.ts +++ b/libs/coin-modules/coin-cosmos/src/chain/chain.unit.test.ts @@ -23,6 +23,7 @@ describe("cryptoFactory test", () => { "mantra", "crypto_org", "xion", + "zenrock", ]; currencies.forEach(currency => { expect(cryptoFactory(currency)).not.toBeNull(); diff --git a/libs/coin-modules/coin-cosmos/src/config.ts b/libs/coin-modules/coin-cosmos/src/config.ts index 12cd96bdc73..57dce0ad479 100644 --- a/libs/coin-modules/coin-cosmos/src/config.ts +++ b/libs/coin-modules/coin-cosmos/src/config.ts @@ -189,6 +189,16 @@ export const cosmosConfig: CosmosConfig = { }, }, }, + config_currency_zenrock: { + type: "object", + default: { + lcd: "https://api.diamond.zenrocklabs.io", + minGasPrice: 0.1, + status: { + type: "active", + }, + }, + }, }; import buildCoinConfig, { type CurrencyConfig } from "@ledgerhq/coin-framework/config"; diff --git a/libs/coin-modules/coin-cosmos/src/specs.ts b/libs/coin-modules/coin-cosmos/src/specs.ts index b463b772c7c..7eebed45c16 100644 --- a/libs/coin-modules/coin-cosmos/src/specs.ts +++ b/libs/coin-modules/coin-cosmos/src/specs.ts @@ -618,6 +618,15 @@ const xion = { }), }; +const zenrockMinimalTransactionAmount = new BigNumber(20000); +const zenrock = { + ...generateGenericCosmosTest("zenrock", false, { + minViableAmount: zenrockMinimalTransactionAmount, + mutations: cosmosLikeMutations(zenrockMinimalTransactionAmount), + skipOperationHistory: true, + }), +}; + export default { axelar, cosmos, @@ -636,4 +645,5 @@ export default { mantra, cryptoOrg, xion, + zenrock, }; diff --git a/libs/ledger-live-common/src/__tests__/test-helpers/environment.ts b/libs/ledger-live-common/src/__tests__/test-helpers/environment.ts index 42528c9f699..3e638e4c760 100644 --- a/libs/ledger-live-common/src/__tests__/test-helpers/environment.ts +++ b/libs/ledger-live-common/src/__tests__/test-helpers/environment.ts @@ -105,6 +105,7 @@ setSupportedCurrencies([ "zksync_sepolia", "mantra", "xion", + "zenrock", ]); LiveConfig.setConfig(liveConfig); diff --git a/libs/ledger-live-common/src/account/helpers.ts b/libs/ledger-live-common/src/account/helpers.ts index 057d254e1d9..73bf0247cdf 100644 --- a/libs/ledger-live-common/src/account/helpers.ts +++ b/libs/ledger-live-common/src/account/helpers.ts @@ -81,6 +81,7 @@ export const getVotesCount = ( case "mantra": case "crypto_org": case "xion": + case "zenrock": return (mainAccount as CosmosAccount)?.cosmosResources?.delegations.length || 0; default: return 0; diff --git a/libs/ledger-live-common/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap b/libs/ledger-live-common/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap index 05b1ea249f8..666df5bf438 100644 --- a/libs/ledger-live-common/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +++ b/libs/ledger-live-common/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap @@ -1637,6 +1637,7 @@ exports[`sortCurrenciesByIds snapshot 1`] = ` "binance_beacon_chain", "mantra", "xion", + "zenrock", "ethereum/erc20/$aapl", "ethereum/erc20/$based", "ethereum/erc20/$die", diff --git a/libs/ledger-live-common/src/currencies/mock.ts b/libs/ledger-live-common/src/currencies/mock.ts index 01637d93a4a..8d45ea3becf 100644 --- a/libs/ledger-live-common/src/currencies/mock.ts +++ b/libs/ledger-live-common/src/currencies/mock.ts @@ -42,6 +42,7 @@ export const IDS = [ "mantra", "crypto_org", "xion", + "zenrock", ]; export const CURRENCIES_LIST: CryptoCurrency[] = [ diff --git a/libs/ledger-live-common/src/currencies/sortByMarketcap.test.ts b/libs/ledger-live-common/src/currencies/sortByMarketcap.test.ts index fa07d54e6af..62e0639ffaf 100644 --- a/libs/ledger-live-common/src/currencies/sortByMarketcap.test.ts +++ b/libs/ledger-live-common/src/currencies/sortByMarketcap.test.ts @@ -34,6 +34,7 @@ test("sortCurrenciesByIds simulate staking from portfolio", () => { "mantra", "crypto_org", "xion", + "zenrock", "quicksilver", ]); }); diff --git a/libs/ledger-live-common/src/families/cosmos/datasets/__snapshots__/zenrock.integration.test.ts.snap b/libs/ledger-live-common/src/families/cosmos/datasets/__snapshots__/zenrock.integration.test.ts.snap new file mode 100644 index 00000000000..3251a02d849 --- /dev/null +++ b/libs/ledger-live-common/src/families/cosmos/datasets/__snapshots__/zenrock.integration.test.ts.snap @@ -0,0 +1,28 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`zenrock currency bridge scanAccounts zenrock seed 1 1`] = ` +[ + { + "balance": "0", + "currencyId": "zenrock", + "derivationMode": "", + "freshAddress": "zen1gyauvl44q2apn3u3aujm36q8zrj74vry04vkrc", + "freshAddressPath": "44'/118'/0'/0/0", + "id": "js:2:zenrock:zen1gyauvl44q2apn3u3aujm36q8zrj74vry04vkrc:", + "index": 0, + "pendingOperations": [], + "seedIdentifier": "03d5e0ebb3f1ae2afe87e5d5a24b5029a59cc12f8fd1056840091b2f0b97e54e83", + "spendableBalance": "0", + "swapHistory": [], + "syncHash": undefined, + "used": false, + "xpub": "zen1gyauvl44q2apn3u3aujm36q8zrj74vry04vkrc", + }, +] +`; + +exports[`zenrock currency bridge scanAccounts zenrock seed 1 2`] = ` +[ + [], +] +`; diff --git a/libs/ledger-live-common/src/families/cosmos/datasets/zenrock.integration.test.ts b/libs/ledger-live-common/src/families/cosmos/datasets/zenrock.integration.test.ts new file mode 100644 index 00000000000..72d528893fa --- /dev/null +++ b/libs/ledger-live-common/src/families/cosmos/datasets/zenrock.integration.test.ts @@ -0,0 +1,14 @@ +import { DatasetTest } from "@ledgerhq/types-live"; +import { testBridge } from "../../../__tests__/test-helpers/bridge"; +import "../../../__tests__/test-helpers/setup"; +import type { Transaction } from "../types"; +import zenrock from "./zenrock"; + +const dataset: DatasetTest = { + implementations: ["js"], + currencies: { + zenrock, + }, +}; + +testBridge(dataset); diff --git a/libs/ledger-live-common/src/families/cosmos/datasets/zenrock.ts b/libs/ledger-live-common/src/families/cosmos/datasets/zenrock.ts new file mode 100644 index 00000000000..2056fd9b9e9 --- /dev/null +++ b/libs/ledger-live-common/src/families/cosmos/datasets/zenrock.ts @@ -0,0 +1,67 @@ +import { fromTransactionRaw } from "@ledgerhq/coin-cosmos/transaction"; +import { CurrenciesData } from "@ledgerhq/types-live"; +import { BigNumber } from "bignumber.js"; +import type { Transaction } from "../types"; + +const dataset: CurrenciesData = { + FIXME_ignoreAccountFields: ["cosmosResources", "operationsCount", "operations"], + FIXME_ignorePreloadFields: ["validators"], + scanAccounts: [ + { + name: "zenrock seed 1", + apdus: ` + => 5504000018037a656e2c00008076000080000000800000000000000000 + <= 03d5e0ebb3f1ae2afe87e5d5a24b5029a59cc12f8fd1056840091b2f0b97e54e837a656e3167796175766c3434713261706e33753361756a6d333671387a726a37347672793034766b72639000 + => 5504000018037a656e2c00008076000080000000800000000000000000 + <= 03d5e0ebb3f1ae2afe87e5d5a24b5029a59cc12f8fd1056840091b2f0b97e54e837a656e3167796175766c3434713261706e33753361756a6d333671387a726a37347672793034766b72639000 + `, + }, + ], + accounts: [ + { + FIXME_tests: ["balance is sum of ops", "pendingOperations are cleaned up"], + raw: { + id: "js:2:zenrock:zen1gyauvl44q2apn3u3aujm36q8zrj74vry04vkrc:", + seedIdentifier: "03d5e0ebb3f1ae2afe87e5d5a24b5029a59cc12f8fd1056840091b2f0b97e54e83", + freshAddress: "zen1gyauvl44q2apn3u3aujm36q8zrj74vry04vkrc", + xpub: "zen1gyauvl44q2apn3u3aujm36q8zrj74vry04vkrc", + freshAddressPath: "44'/118'/0'/0/0", + derivationMode: "", + index: 0, + currencyId: "zenrock", + operationsCount: 0, + operations: [], + pendingOperations: [], + lastSyncDate: "", + balance: "0", + spendableBalance: "0", + blockHeight: 431928, + }, + transactions: [ + { + name: "Normal transaction", + transaction: fromTransactionRaw({ + amount: "10000", + recipient: "zen1704dk997ccmk5x8smn8secphckfvbgxxfd99ssr", + useAllAmount: false, + family: "cosmos", + mode: "send", + networkInfo: null, + fees: "8744", + gas: "87440", + validators: [], + memo: "", + sourceValidator: "", + }), + expectedStatus: () => ({ + errors: {}, + warnings: {}, + amount: BigNumber("10000"), + }), + }, + ], + }, + ], +}; + +export default dataset; diff --git a/libs/ledger-live-common/src/featureFlags/defaultFeatures.ts b/libs/ledger-live-common/src/featureFlags/defaultFeatures.ts index 6656a08f798..ec05e9b528b 100644 --- a/libs/ledger-live-common/src/featureFlags/defaultFeatures.ts +++ b/libs/ledger-live-common/src/featureFlags/defaultFeatures.ts @@ -84,6 +84,7 @@ export const CURRENCY_DEFAULT_FEATURES = { currencyZkSyncSepolia: DEFAULT_FEATURE, currencyMantra: DEFAULT_FEATURE, currencyXion: DEFAULT_FEATURE, + currencyZenrock: DEFAULT_FEATURE, }; /** diff --git a/libs/ledgerjs/packages/cryptoassets/src/abandonseed.ts b/libs/ledgerjs/packages/cryptoassets/src/abandonseed.ts index 7be448eae23..82d0a1b63d5 100644 --- a/libs/ledgerjs/packages/cryptoassets/src/abandonseed.ts +++ b/libs/ledgerjs/packages/cryptoassets/src/abandonseed.ts @@ -114,6 +114,7 @@ const abandonSeedAddresses: Partial> = { zksync_sepolia: EVM_DEAD_ADDRESS, mantra: "mantra12jypwtxm7npfszx5x9780fhz0j3ken696fdp33", xion: "xion19rl4cm2hmr8afy4kldpxz3fka4jguq0a5xyz123", + zenrock: "zen1704dk997ccmk5x8smn8secphckfvbgxxfd99xxr", }; /** diff --git a/libs/ledgerjs/packages/cryptoassets/src/currencies.ts b/libs/ledgerjs/packages/cryptoassets/src/currencies.ts index 7a20ab850e8..4fd00f1e4e5 100644 --- a/libs/ledgerjs/packages/cryptoassets/src/currencies.ts +++ b/libs/ledgerjs/packages/cryptoassets/src/currencies.ts @@ -4377,6 +4377,35 @@ export const cryptocurrenciesById: Record = { }, ], }, + zenrock: { + type: "CryptoCurrency", + id: "zenrock", + coinType: CoinType.ATOM, + name: "Zenrock", + managerAppName: "Cosmos", + ticker: "ROCK", + scheme: "zenrock", + color: "#080c44", + family: "cosmos", + units: [ + { + name: "Zenrock", + code: "ROCK", + magnitude: 6, + }, + { + name: "Micro-Zenrock", + code: "urock", + magnitude: 0, + }, + ], + explorerViews: [ + { + tx: "https://explorer.diamond.zenrocklabs.io/transactions/$hash", + address: "https://explorer.diamond.zenrocklabs.io/validators/$address", + }, + ], + }, }; const cryptocurrenciesByScheme: Record = {}; diff --git a/libs/ledgerjs/packages/types-cryptoassets/src/index.ts b/libs/ledgerjs/packages/types-cryptoassets/src/index.ts index 939757d0e20..44524842219 100644 --- a/libs/ledgerjs/packages/types-cryptoassets/src/index.ts +++ b/libs/ledgerjs/packages/types-cryptoassets/src/index.ts @@ -168,6 +168,7 @@ export type CryptoCurrencyId = | "zksync_sepolia" | "mantra" | "xion"; + | "zenrock"; export type LedgerExplorerId = | "btc" diff --git a/libs/ledgerjs/packages/types-live/src/feature.ts b/libs/ledgerjs/packages/types-live/src/feature.ts index 51f1676513d..e065f601aae 100644 --- a/libs/ledgerjs/packages/types-live/src/feature.ts +++ b/libs/ledgerjs/packages/types-live/src/feature.ts @@ -125,6 +125,7 @@ export type CurrencyFeatures = { currencyZkSyncSepolia: DefaultFeature; currencyMantra: DefaultFeature; currencyXion: DefaultFeature; + currencyZenrock: DefaultFeature; }; /** diff --git a/libs/ui/packages/crypto-icons/src/svg/ROCK.svg b/libs/ui/packages/crypto-icons/src/svg/ROCK.svg new file mode 100644 index 00000000000..dd39dd79692 --- /dev/null +++ b/libs/ui/packages/crypto-icons/src/svg/ROCK.svg @@ -0,0 +1,10 @@ + + + + + + + + + + From ff552003fca381933cf8bd2621b4e90565821308 Mon Sep 17 00:00:00 2001 From: qperrot Date: Thu, 19 Dec 2024 09:40:34 +0100 Subject: [PATCH 2/4] fix: add zenrock mock --- .../ledger-live-common/src/currencies/mock.ts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/libs/ledger-live-common/src/currencies/mock.ts b/libs/ledger-live-common/src/currencies/mock.ts index 8d45ea3becf..425e7e792a1 100644 --- a/libs/ledger-live-common/src/currencies/mock.ts +++ b/libs/ledger-live-common/src/currencies/mock.ts @@ -596,4 +596,33 @@ export const CURRENCIES_LIST: CryptoCurrency[] = [ }, ], }, + { + type: "CryptoCurrency", + id: "zenrock", + coinType: 118, + name: "Zenrock", + managerAppName: "Cosmos", + ticker: "ROCK", + scheme: "zenrock", + color: "#000000", + family: "cosmos", + units: [ + { + name: "Zenrock", + code: "ROCK", + magnitude: 6, + }, + { + name: "Micro-Zenrock", + code: "urock", + magnitude: 0, + }, + ], + explorerViews: [ + { + tx: "https://explorer.diamond.zenrocklabs.io/transactions/$hash", + address: "https://explorer.diamond.zenrocklabs.io/validators/$address", + }, + ], + }, ]; From a1a8768900cff6c2a3be5cc12922fed053747515 Mon Sep 17 00:00:00 2001 From: qperrot Date: Fri, 20 Dec 2024 15:52:10 +0100 Subject: [PATCH 3/4] fix: remove extra dot --- libs/ledgerjs/packages/types-cryptoassets/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/ledgerjs/packages/types-cryptoassets/src/index.ts b/libs/ledgerjs/packages/types-cryptoassets/src/index.ts index 44524842219..15624125384 100644 --- a/libs/ledgerjs/packages/types-cryptoassets/src/index.ts +++ b/libs/ledgerjs/packages/types-cryptoassets/src/index.ts @@ -167,7 +167,7 @@ export type CryptoCurrencyId = | "zksync" | "zksync_sepolia" | "mantra" - | "xion"; + | "xion" | "zenrock"; export type LedgerExplorerId = From c2d24cd0299ea04e39306279b6f833696bc4f4fb Mon Sep 17 00:00:00 2001 From: qperrot Date: Mon, 23 Dec 2024 16:37:41 +0100 Subject: [PATCH 4/4] chore: add changeset --- .changeset/stupid-eggs-fry.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .changeset/stupid-eggs-fry.md diff --git a/.changeset/stupid-eggs-fry.md b/.changeset/stupid-eggs-fry.md new file mode 100644 index 00000000000..fbc9383f077 --- /dev/null +++ b/.changeset/stupid-eggs-fry.md @@ -0,0 +1,15 @@ +--- +"@ledgerhq/types-cryptoassets": minor +"@ledgerhq/cryptoassets": minor +"@ledgerhq/types-live": minor +"@ledgerhq/coin-cosmos": minor +"@ledgerhq/crypto-icons-ui": minor +"ledger-live-desktop": minor +"live-mobile": minor +"@ledgerhq/live-common": minor +"@ledgerhq/coin-framework": minor +"@ledgerhq/web-tools": minor +"@ledgerhq/live-cli": minor +--- + +Zenrock integration