diff --git a/apps/cli/src/live-common-setup-base.ts b/apps/cli/src/live-common-setup-base.ts index 397bf4a700d0..631f9ec6fdf4 100644 --- a/apps/cli/src/live-common-setup-base.ts +++ b/apps/cli/src/live-common-setup-base.ts @@ -102,6 +102,7 @@ setSupportedCurrencies([ "zksync", "zksync_sepolia", "mantra", + "xion", ]); 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 6f0ee7060dad..a9ad1858c4bc 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 @@ -96,4 +96,5 @@ setSupportedCurrencies([ "zksync", "zksync_sepolia", "mantra", + "xion", ]); 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..50d28cde6e2c 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 xion = useFeature("currencyXion"); const featureFlaggedCurrencies = useMemo( (): Partial | null>> => ({ @@ -138,6 +139,7 @@ const StepChooseCurrency = ({ currency, setCurrency }: StepProps) => { zksync, zksync_sepolia: zksyncSepolia, mantra, + xion, }), [ axelar, @@ -190,6 +192,7 @@ const StepChooseCurrency = ({ currency, setCurrency }: StepProps) => { zksync, zksyncSepolia, mantra, + xion, ], ); 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..5f0e9ac1f1f4 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 @@ -808,5 +808,14 @@ "family": "cosmos", "color": "#ffb386", "decimals": 6 + }, + { + "type": "CryptoCurrency", + "id": "xion", + "ticker": "XION", + "name": "Xion", + "family": "cosmos", + "color": "#000000", + "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 b68c11c448b1..5f0e9ac1f1f4 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 @@ -808,5 +808,14 @@ "family": "cosmos", "color": "#ffb386", "decimals": 6 + }, + { + "type": "CryptoCurrency", + "id": "xion", + "ticker": "XION", + "name": "Xion", + "family": "cosmos", + "color": "#000000", + "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 0509a0de73a2..9010091d9022 100644 --- a/apps/ledger-live-mobile/src/live-common-setup.ts +++ b/apps/ledger-live-mobile/src/live-common-setup.ts @@ -129,6 +129,7 @@ setSupportedCurrencies([ "zksync", "zksync_sepolia", "mantra", + "xion", ]); 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 8423433e7f6d..6e930fb44c88 100644 --- a/apps/ledger-live-mobile/src/screens/AddAccounts/01-SelectCrypto.tsx +++ b/apps/ledger-live-mobile/src/screens/AddAccounts/01-SelectCrypto.tsx @@ -107,6 +107,7 @@ export default function AddAccountsSelectCrypto({ navigation, route }: Props) { const zksync = useFeature("currencyZkSync"); const zksyncSepolia = useFeature("currencyZkSyncSepolia"); const mantra = useFeature("currencyMantra"); + const xion = useFeature("currencyXion"); const featureFlaggedCurrencies = useMemo( (): Partial | null>> => ({ @@ -160,6 +161,7 @@ export default function AddAccountsSelectCrypto({ navigation, route }: Props) { zksync, zksync_sepolia: zksyncSepolia, mantra, + xion, }), [ axelar, @@ -212,6 +214,7 @@ export default function AddAccountsSelectCrypto({ navigation, route }: Props) { zksync, zksyncSepolia, mantra, + xion, ], ); diff --git a/apps/web-tools/live-common-setup.ts b/apps/web-tools/live-common-setup.ts index c9d959db1272..b5d7c10cd3f7 100644 --- a/apps/web-tools/live-common-setup.ts +++ b/apps/web-tools/live-common-setup.ts @@ -70,4 +70,5 @@ setSupportedCurrencies([ "linea", "linea_sepolia", "mantra", + "xion", ]); diff --git a/libs/coin-modules/coin-cosmos/src/chain/Xion.ts b/libs/coin-modules/coin-cosmos/src/chain/Xion.ts new file mode 100644 index 000000000000..af3217300daa --- /dev/null +++ b/libs/coin-modules/coin-cosmos/src/chain/Xion.ts @@ -0,0 +1,20 @@ +import CosmosBase from "./cosmosBase"; + +class Xion 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 = "xion"; + this.validatorPrefix = `${this.prefix}valoper`; + } +} + +export default Xion; diff --git a/libs/coin-modules/coin-cosmos/src/chain/chain.ts b/libs/coin-modules/coin-cosmos/src/chain/chain.ts index 0eb41b83ad07..f197cac00289 100644 --- a/libs/coin-modules/coin-cosmos/src/chain/chain.ts +++ b/libs/coin-modules/coin-cosmos/src/chain/chain.ts @@ -17,6 +17,7 @@ import Coreum from "./Coreum"; import Injective from "./Injective"; import Dydx from "./Dydx"; import Mantra from "./Mantra"; +import Xion from "./Xion"; const cosmosChainParams: { [key: string]: CosmosBase } = {}; export default function cryptoFactory(currencyId: string): CosmosBase { @@ -78,6 +79,9 @@ export default function cryptoFactory(currencyId: string): CosmosBase { case "mantra": cosmosChainParams[currencyId] = new Mantra(); break; + case "xion": + cosmosChainParams[currencyId] = new Xion(); + 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 0e129ac5e43e..e98e73f6c9d8 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 @@ -21,6 +21,7 @@ describe("cryptoFactory test", () => { "stargaze", "stride", "mantra", + "xion", ]; 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 01e6c0611c4a..4af59ef3f0c4 100644 --- a/libs/coin-modules/coin-cosmos/src/config.ts +++ b/libs/coin-modules/coin-cosmos/src/config.ts @@ -168,6 +168,17 @@ export const cosmosConfig: CosmosConfig = { }, }, }, + config_currency_xion: { + type: "object", + default: { + lcd: "https://xion-api.polkachu.com", + minGasPrice: 0.04, + ledgerValidator: "xionvaloper1t8ysd9cg6s38ak9xfadkjtvfv9uczvrn8wzv77", + 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 3bc3414d37ee..435d0fedbd9d 100644 --- a/libs/coin-modules/coin-cosmos/src/specs.ts +++ b/libs/coin-modules/coin-cosmos/src/specs.ts @@ -599,6 +599,15 @@ const mantra = { }), }; +const xionMinimalTransactionAmount = new BigNumber(20000); +const xion = { + ...generateGenericCosmosTest("xion", false, { + minViableAmount: xionMinimalTransactionAmount, + mutations: cosmosLikeMutations(xionMinimalTransactionAmount), + skipOperationHistory: true, + }), +}; + export default { axelar, cosmos, @@ -615,4 +624,5 @@ export default { coreum, injective, mantra, + xion, }; 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 20286d62377d..42528c9f6990 100644 --- a/libs/ledger-live-common/src/__tests__/test-helpers/environment.ts +++ b/libs/ledger-live-common/src/__tests__/test-helpers/environment.ts @@ -104,6 +104,7 @@ setSupportedCurrencies([ "zksync", "zksync_sepolia", "mantra", + "xion", ]); LiveConfig.setConfig(liveConfig); diff --git a/libs/ledger-live-common/src/account/helpers.ts b/libs/ledger-live-common/src/account/helpers.ts index a08c1db8f86f..30a3c1c89a12 100644 --- a/libs/ledger-live-common/src/account/helpers.ts +++ b/libs/ledger-live-common/src/account/helpers.ts @@ -79,6 +79,7 @@ export const getVotesCount = ( case "cosmos": case "coreum": case "mantra": + case "xion": return (mainAccount as CosmosAccount)?.cosmosResources?.delegations.length || 0; default: return 0; diff --git a/libs/ledger-live-common/src/currencies/mock.ts b/libs/ledger-live-common/src/currencies/mock.ts index f05492cca109..13709f56feea 100644 --- a/libs/ledger-live-common/src/currencies/mock.ts +++ b/libs/ledger-live-common/src/currencies/mock.ts @@ -40,6 +40,7 @@ export const IDS = [ "persistence", "onomy", "mantra", + "xion", ]; export const CURRENCIES_LIST: CryptoCurrency[] = [ @@ -535,4 +536,33 @@ export const CURRENCIES_LIST: CryptoCurrency[] = [ }, ], }, + { + type: "CryptoCurrency", + id: "xion", + coinType: 118, + name: "Xion", + managerAppName: "Cosmos", + ticker: "XION", + scheme: "xion", + color: "#000000", + family: "cosmos", + units: [ + { + name: "Xion", + code: "XION", + magnitude: 6, + }, + { + name: "Micro-XION", + code: "uxion", + magnitude: 0, + }, + ], + explorerViews: [ + { + tx: "https://www.mintscan.io/xion/txs/$hash", + address: "https://www.mintscan.io/xion/validators/$address", + }, + ], + }, ]; diff --git a/libs/ledger-live-common/src/families/cosmos/datasets/xion.integration.test.ts b/libs/ledger-live-common/src/families/cosmos/datasets/xion.integration.test.ts new file mode 100644 index 000000000000..aa8aafaf55d0 --- /dev/null +++ b/libs/ledger-live-common/src/families/cosmos/datasets/xion.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 xion from "./xion"; + +const dataset: DatasetTest = { + implementations: ["js"], + currencies: { + xion, + }, +}; + +testBridge(dataset); diff --git a/libs/ledger-live-common/src/families/cosmos/datasets/xion.ts b/libs/ledger-live-common/src/families/cosmos/datasets/xion.ts new file mode 100644 index 000000000000..8368a1a2f4dd --- /dev/null +++ b/libs/ledger-live-common/src/families/cosmos/datasets/xion.ts @@ -0,0 +1,66 @@ +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: "xion seed 1", + // apdus: ` + // => 55040000190478696f6e2c00008076000080000000800000000000000000 + // <= 0x0301a5bc0d94728a62db72b7e162add7767a58f10a5013543637694b2c4a66cc5078696f6e316738343933346a70753376356465357971756b6b6b68786d637673773375326173306b726d359000 + // `, + // }, + // ], + accounts: [ + { + FIXME_tests: ["balance is sum of ops", "pendingOperations are cleaned up"], + raw: { + id: "js:2:xion:xion1g84934jpu3v5de5yqukkkhxmcvsw3u2as0krm5:", + seedIdentifier: "0388459b2653519948b12492f1a0b464720110c147a8155d23d423a5cc3c21d89a", + xpub: "xion1g84934jpu3v5de5yqukkkhxmcvsw3u2as0krm5", + freshAddress: "xion1g84934jpu3v5de5yqukkkhxmcvsw3u2as0krm5", + freshAddressPath: "44'/118'/0'/0/0", + name: "Xion 1", + derivationMode: "", + index: 0, + operationsCount: 3, + operations: [], + balance: "715838", + spendableBalance: "715838", + blockHeight: 4476555, + pendingOperations: [], + currencyId: "xion", + lastSyncDate: "", + }, + transactions: [ + { + name: "Normal transaction", + transaction: fromTransactionRaw({ + amount: "10000", + recipient: "xion108uy5q9jt59gwugq5yrdhkzcd9jryslmr32fql", + 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 38e52e64b3c2..6656a08f7986 100644 --- a/libs/ledger-live-common/src/featureFlags/defaultFeatures.ts +++ b/libs/ledger-live-common/src/featureFlags/defaultFeatures.ts @@ -83,6 +83,7 @@ export const CURRENCY_DEFAULT_FEATURES = { currencyZkSync: DEFAULT_FEATURE, currencyZkSyncSepolia: DEFAULT_FEATURE, currencyMantra: DEFAULT_FEATURE, + currencyXion: DEFAULT_FEATURE, }; /** diff --git a/libs/ledgerjs/packages/cryptoassets/src/abandonseed.ts b/libs/ledgerjs/packages/cryptoassets/src/abandonseed.ts index 0eed424a6c34..7be448eae23c 100644 --- a/libs/ledgerjs/packages/cryptoassets/src/abandonseed.ts +++ b/libs/ledgerjs/packages/cryptoassets/src/abandonseed.ts @@ -113,6 +113,7 @@ const abandonSeedAddresses: Partial> = { zksync: EVM_DEAD_ADDRESS, zksync_sepolia: EVM_DEAD_ADDRESS, mantra: "mantra12jypwtxm7npfszx5x9780fhz0j3ken696fdp33", + xion: "xion19rl4cm2hmr8afy4kldpxz3fka4jguq0a5xyz123", }; /** diff --git a/libs/ledgerjs/packages/cryptoassets/src/currencies.ts b/libs/ledgerjs/packages/cryptoassets/src/currencies.ts index d329e4269816..29cb3a123b1a 100644 --- a/libs/ledgerjs/packages/cryptoassets/src/currencies.ts +++ b/libs/ledgerjs/packages/cryptoassets/src/currencies.ts @@ -4348,6 +4348,35 @@ export const cryptocurrenciesById: Record = { }, ], }, + xion: { + type: "CryptoCurrency", + id: "xion", + coinType: CoinType.ATOM, + name: "Xion", + managerAppName: "Cosmos", + ticker: "XION", + scheme: "xion", + color: "#000000", + family: "cosmos", + units: [ + { + name: "Xion", + code: "XION", + magnitude: 6, + }, + { + name: "Micro-XION", + code: "uxion", + magnitude: 0, + }, + ], + explorerViews: [ + { + tx: "https://www.mintscan.io/xion/txs/$hash", + address: "https://www.mintscan.io/xion/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 b9b0bc1d672e..939757d0e208 100644 --- a/libs/ledgerjs/packages/types-cryptoassets/src/index.ts +++ b/libs/ledgerjs/packages/types-cryptoassets/src/index.ts @@ -148,7 +148,6 @@ export type CryptoCurrencyId = | "syscoin" | "internet_computer" | "injective" - | "mantra" | "telos_evm" | "klaytn" | "polygon_zk_evm" @@ -167,7 +166,8 @@ export type CryptoCurrencyId = | "etherlink" | "zksync" | "zksync_sepolia" - | "mantra"; + | "mantra" + | "xion"; 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 67c5ff181e93..51f1676513d5 100644 --- a/libs/ledgerjs/packages/types-live/src/feature.ts +++ b/libs/ledgerjs/packages/types-live/src/feature.ts @@ -124,6 +124,7 @@ export type CurrencyFeatures = { currencyZkSync: DefaultFeature; currencyZkSyncSepolia: DefaultFeature; currencyMantra: DefaultFeature; + currencyXion: DefaultFeature; }; /** diff --git a/libs/ui/packages/crypto-icons/src/svg/XION.svg b/libs/ui/packages/crypto-icons/src/svg/XION.svg new file mode 100644 index 000000000000..ffae41c41c1c --- /dev/null +++ b/libs/ui/packages/crypto-icons/src/svg/XION.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file