Skip to content

Commit

Permalink
Merge pull request #8704 from LedgerHQ/LIVE-11972-xion-integration
Browse files Browse the repository at this point in the history
feat: xion integration
  • Loading branch information
Wozacosta authored Dec 20, 2024
2 parents 72b3042 + bcad872 commit 9fce32f
Show file tree
Hide file tree
Showing 29 changed files with 489 additions and 2 deletions.
14 changes: 14 additions & 0 deletions .changeset/loud-spiders-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
"@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/web-tools": minor
"@ledgerhq/live-cli": minor
---

add xion currency
1 change: 1 addition & 0 deletions apps/cli/src/live-common-setup-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ setSupportedCurrencies([
"zksync",
"zksync_sepolia",
"mantra",
"xion",
]);

for (const k in process.env) setEnvUnsafe(k as EnvName, process.env[k]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,5 @@ setSupportedCurrencies([
"zksync",
"zksync_sepolia",
"mantra",
"xion",
]);
Original file line number Diff line number Diff line change
Expand Up @@ -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<Record<CryptoCurrencyId, Feature<unknown> | null>> => ({
Expand Down Expand Up @@ -138,6 +139,7 @@ const StepChooseCurrency = ({ currency, setCurrency }: StepProps) => {
zksync,
zksync_sepolia: zksyncSepolia,
mantra,
xion,
}),
[
axelar,
Expand Down Expand Up @@ -190,6 +192,7 @@ const StepChooseCurrency = ({ currency, setCurrency }: StepProps) => {
zksync,
zksyncSepolia,
mantra,
xion,
],
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -808,5 +808,14 @@
"family": "cosmos",
"color": "#ffb386",
"decimals": 6
},
{
"type": "CryptoCurrency",
"id": "xion",
"ticker": "XION",
"name": "Xion",
"family": "cosmos",
"color": "#000000",
"decimals": 6
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -808,5 +808,14 @@
"family": "cosmos",
"color": "#ffb386",
"decimals": 6
},
{
"type": "CryptoCurrency",
"id": "xion",
"ticker": "XION",
"name": "Xion",
"family": "cosmos",
"color": "#000000",
"decimals": 6
}
]
1 change: 1 addition & 0 deletions apps/ledger-live-mobile/src/live-common-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ setSupportedCurrencies([
"zksync",
"zksync_sepolia",
"mantra",
"xion",
]);

if (Config.BLE_LOG_LEVEL) BluetoothTransport.setLogLevel(Config.BLE_LOG_LEVEL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Record<CryptoCurrencyId, Feature<unknown> | null>> => ({
Expand Down Expand Up @@ -160,6 +161,7 @@ export default function AddAccountsSelectCrypto({ navigation, route }: Props) {
zksync,
zksync_sepolia: zksyncSepolia,
mantra,
xion,
}),
[
axelar,
Expand Down Expand Up @@ -212,6 +214,7 @@ export default function AddAccountsSelectCrypto({ navigation, route }: Props) {
zksync,
zksyncSepolia,
mantra,
xion,
],
);

Expand Down
1 change: 1 addition & 0 deletions apps/web-tools/live-common-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ setSupportedCurrencies([
"linea",
"linea_sepolia",
"mantra",
"xion",
]);
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ exports[`formatCurrencyUnit with custom options with locale de-DE should correct

exports[`formatCurrencyUnit with custom options with locale de-DE should correctly format XRP unit (XRP) 1`] = `"12.345.678.900,000000- -XRP"`;

exports[`formatCurrencyUnit with custom options with locale de-DE should correctly format Xion unit (Xion) 1`] = `"12.345.678.900,000000- -XION"`;

exports[`formatCurrencyUnit with custom options with locale de-DE should correctly format ZClassic unit (zclassic) 1`] = `"123.456.789,00000000- -ZCL"`;

exports[`formatCurrencyUnit with custom options with locale de-DE should correctly format ZCoin unit (XZC) 1`] = `"123.456.789,00000000- -XZC"`;
Expand Down Expand Up @@ -646,6 +648,8 @@ exports[`formatCurrencyUnit with custom options with locale en-US should correct

exports[`formatCurrencyUnit with custom options with locale en-US should correctly format XRP unit (XRP) 1`] = `"12,345,678,900.000000- -XRP"`;

exports[`formatCurrencyUnit with custom options with locale en-US should correctly format Xion unit (Xion) 1`] = `"12,345,678,900.000000- -XION"`;

exports[`formatCurrencyUnit with custom options with locale en-US should correctly format ZClassic unit (zclassic) 1`] = `"123,456,789.00000000- -ZCL"`;

exports[`formatCurrencyUnit with custom options with locale en-US should correctly format ZCoin unit (XZC) 1`] = `"123,456,789.00000000- -XZC"`;
Expand Down Expand Up @@ -978,6 +982,8 @@ exports[`formatCurrencyUnit with custom options with locale es-ES should correct

exports[`formatCurrencyUnit with custom options with locale es-ES should correctly format XRP unit (XRP) 1`] = `"12.345.678.900,000000- -XRP"`;

exports[`formatCurrencyUnit with custom options with locale es-ES should correctly format Xion unit (Xion) 1`] = `"12.345.678.900,000000- -XION"`;

exports[`formatCurrencyUnit with custom options with locale es-ES should correctly format ZClassic unit (zclassic) 1`] = `"123.456.789,00000000- -ZCL"`;

exports[`formatCurrencyUnit with custom options with locale es-ES should correctly format ZCoin unit (XZC) 1`] = `"123.456.789,00000000- -XZC"`;
Expand Down Expand Up @@ -1310,6 +1316,8 @@ exports[`formatCurrencyUnit with custom options with locale fr-FR should correct

exports[`formatCurrencyUnit with custom options with locale fr-FR should correctly format XRP unit (XRP) 1`] = `"12 345 678 900,000000- -XRP"`;

exports[`formatCurrencyUnit with custom options with locale fr-FR should correctly format Xion unit (Xion) 1`] = `"12 345 678 900,000000- -XION"`;

exports[`formatCurrencyUnit with custom options with locale fr-FR should correctly format ZClassic unit (zclassic) 1`] = `"123 456 789,00000000- -ZCL"`;

exports[`formatCurrencyUnit with custom options with locale fr-FR should correctly format ZCoin unit (XZC) 1`] = `"123 456 789,00000000- -XZC"`;
Expand Down Expand Up @@ -1642,6 +1650,8 @@ exports[`formatCurrencyUnit with custom options with locale ja-JP should correct

exports[`formatCurrencyUnit with custom options with locale ja-JP should correctly format XRP unit (XRP) 1`] = `"12,345,678,900.000000- -XRP"`;

exports[`formatCurrencyUnit with custom options with locale ja-JP should correctly format Xion unit (Xion) 1`] = `"12,345,678,900.000000- -XION"`;

exports[`formatCurrencyUnit with custom options with locale ja-JP should correctly format ZClassic unit (zclassic) 1`] = `"123,456,789.00000000- -ZCL"`;

exports[`formatCurrencyUnit with custom options with locale ja-JP should correctly format ZCoin unit (XZC) 1`] = `"123,456,789.00000000- -XZC"`;
Expand Down Expand Up @@ -1974,6 +1984,8 @@ exports[`formatCurrencyUnit with custom options with locale ko-KR should correct

exports[`formatCurrencyUnit with custom options with locale ko-KR should correctly format XRP unit (XRP) 1`] = `"12,345,678,900.000000- -XRP"`;

exports[`formatCurrencyUnit with custom options with locale ko-KR should correctly format Xion unit (Xion) 1`] = `"12,345,678,900.000000- -XION"`;

exports[`formatCurrencyUnit with custom options with locale ko-KR should correctly format ZClassic unit (zclassic) 1`] = `"123,456,789.00000000- -ZCL"`;

exports[`formatCurrencyUnit with custom options with locale ko-KR should correctly format ZCoin unit (XZC) 1`] = `"123,456,789.00000000- -XZC"`;
Expand Down Expand Up @@ -2306,6 +2318,8 @@ exports[`formatCurrencyUnit with custom options with locale pt-BR should correct

exports[`formatCurrencyUnit with custom options with locale pt-BR should correctly format XRP unit (XRP) 1`] = `"12.345.678.900,000000- -XRP"`;

exports[`formatCurrencyUnit with custom options with locale pt-BR should correctly format Xion unit (Xion) 1`] = `"12.345.678.900,000000- -XION"`;

exports[`formatCurrencyUnit with custom options with locale pt-BR should correctly format ZClassic unit (zclassic) 1`] = `"123.456.789,00000000- -ZCL"`;

exports[`formatCurrencyUnit with custom options with locale pt-BR should correctly format ZCoin unit (XZC) 1`] = `"123.456.789,00000000- -XZC"`;
Expand Down Expand Up @@ -2638,6 +2652,8 @@ exports[`formatCurrencyUnit with custom options with locale ru-RU should correct

exports[`formatCurrencyUnit with custom options with locale ru-RU should correctly format XRP unit (XRP) 1`] = `"12 345 678 900,000000- -XRP"`;

exports[`formatCurrencyUnit with custom options with locale ru-RU should correctly format Xion unit (Xion) 1`] = `"12 345 678 900,000000- -XION"`;

exports[`formatCurrencyUnit with custom options with locale ru-RU should correctly format ZClassic unit (zclassic) 1`] = `"123 456 789,00000000- -ZCL"`;

exports[`formatCurrencyUnit with custom options with locale ru-RU should correctly format ZCoin unit (XZC) 1`] = `"123 456 789,00000000- -XZC"`;
Expand Down Expand Up @@ -2970,6 +2986,8 @@ exports[`formatCurrencyUnit with custom options with locale tr-TR should correct

exports[`formatCurrencyUnit with custom options with locale tr-TR should correctly format XRP unit (XRP) 1`] = `"12.345.678.900,000000- -XRP"`;

exports[`formatCurrencyUnit with custom options with locale tr-TR should correctly format Xion unit (Xion) 1`] = `"12.345.678.900,000000- -XION"`;

exports[`formatCurrencyUnit with custom options with locale tr-TR should correctly format ZClassic unit (zclassic) 1`] = `"123.456.789,00000000- -ZCL"`;

exports[`formatCurrencyUnit with custom options with locale tr-TR should correctly format ZCoin unit (XZC) 1`] = `"123.456.789,00000000- -XZC"`;
Expand Down Expand Up @@ -3302,6 +3320,8 @@ exports[`formatCurrencyUnit with custom options with locale zh-CN should correct

exports[`formatCurrencyUnit with custom options with locale zh-CN should correctly format XRP unit (XRP) 1`] = `"12,345,678,900.000000- -XRP"`;

exports[`formatCurrencyUnit with custom options with locale zh-CN should correctly format Xion unit (Xion) 1`] = `"12,345,678,900.000000- -XION"`;

exports[`formatCurrencyUnit with custom options with locale zh-CN should correctly format ZClassic unit (zclassic) 1`] = `"123,456,789.00000000- -ZCL"`;

exports[`formatCurrencyUnit with custom options with locale zh-CN should correctly format ZCoin unit (XZC) 1`] = `"123,456,789.00000000- -XZC"`;
Expand Down Expand Up @@ -3634,6 +3654,8 @@ exports[`formatCurrencyUnit with default options should correctly format Waves u

exports[`formatCurrencyUnit with default options should correctly format XRP unit (XRP) 1`] = `"12,345,678,900"`;

exports[`formatCurrencyUnit with default options should correctly format Xion unit (Xion) 1`] = `"12,345,678,900"`;

exports[`formatCurrencyUnit with default options should correctly format ZClassic unit (zclassic) 1`] = `"123,456,789"`;

exports[`formatCurrencyUnit with default options should correctly format ZCoin unit (XZC) 1`] = `"123,456,789"`;
Expand Down
20 changes: 20 additions & 0 deletions libs/coin-modules/coin-cosmos/src/chain/Xion.ts
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 4 additions & 0 deletions libs/coin-modules/coin-cosmos/src/chain/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Injective from "./Injective";
import Dydx from "./Dydx";
import Mantra from "./Mantra";
import CryptoOrg from "./CryptoOrg";
import Xion from "./Xion";

const cosmosChainParams: { [key: string]: CosmosBase } = {};
export default function cryptoFactory(currencyId: string): CosmosBase {
Expand Down Expand Up @@ -82,6 +83,9 @@ export default function cryptoFactory(currencyId: string): CosmosBase {
case "crypto_org":
cosmosChainParams[currencyId] = new CryptoOrg();
break;
case "xion":
cosmosChainParams[currencyId] = new Xion();
break;
default:
throw new Error(`${currencyId} is not supported`);
}
Expand Down
1 change: 1 addition & 0 deletions libs/coin-modules/coin-cosmos/src/chain/chain.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe("cryptoFactory test", () => {
"stride",
"mantra",
"crypto_org",
"xion",
];
currencies.forEach(currency => {
expect(cryptoFactory(currency)).not.toBeNull();
Expand Down
11 changes: 11 additions & 0 deletions libs/coin-modules/coin-cosmos/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,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";
Expand Down
10 changes: 10 additions & 0 deletions libs/coin-modules/coin-cosmos/src/specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,15 @@ const cryptoOrg = {
}),
};

const xionMinimalTransactionAmount = new BigNumber(20000);
const xion = {
...generateGenericCosmosTest("xion", false, {
minViableAmount: xionMinimalTransactionAmount,
mutations: cosmosLikeMutations(xionMinimalTransactionAmount),
skipOperationHistory: true,
}),
};

export default {
axelar,
cosmos,
Expand All @@ -626,4 +635,5 @@ export default {
injective,
mantra,
cryptoOrg,
xion,
};
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ setSupportedCurrencies([
"zksync",
"zksync_sepolia",
"mantra",
"xion",
]);
LiveConfig.setConfig(liveConfig);

Expand Down
1 change: 1 addition & 0 deletions libs/ledger-live-common/src/account/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const getVotesCount = (
case "coreum":
case "mantra":
case "crypto_org":
case "xion":
return (mainAccount as CosmosAccount)?.cosmosResources?.delegations.length || 0;
default:
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1636,6 +1636,7 @@ exports[`sortCurrenciesByIds snapshot 1`] = `
"zksync_sepolia",
"binance_beacon_chain",
"mantra",
"xion",
"ethereum/erc20/$aapl",
"ethereum/erc20/$based",
"ethereum/erc20/$die",
Expand Down
30 changes: 30 additions & 0 deletions libs/ledger-live-common/src/currencies/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const IDS = [
"onomy",
"mantra",
"crypto_org",
"xion",
];

export const CURRENCIES_LIST: CryptoCurrency[] = [
Expand Down Expand Up @@ -565,4 +566,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",
},
],
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ test("sortCurrenciesByIds simulate staking from portfolio", () => {
"onomy",
"mantra",
"crypto_org",
"xion",
"quicksilver",
]);
});
Loading

0 comments on commit 9fce32f

Please sign in to comment.