Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: mantra integration #8205

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -99,6 +99,7 @@ setSupportedCurrencies([
"scroll",
"scroll_sepolia",
"etherlink",
"mantra",
]);

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 @@ -93,4 +93,5 @@ setSupportedCurrencies([
"scroll_sepolia",
"ton",
"etherlink",
"mantra",
]);
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const StepChooseCurrency = ({ currency, setCurrency }: StepProps) => {
const icon = useFeature("currencyIcon");
const ton = useFeature("currencyTon");
const etherlink = useFeature("currencyEtherlink");
const mantra = useFeature("currencyMantra");

const featureFlaggedCurrencies = useMemo(
(): Partial<Record<CryptoCurrencyId, Feature<unknown> | null>> => ({
Expand Down Expand Up @@ -132,6 +133,7 @@ const StepChooseCurrency = ({ currency, setCurrency }: StepProps) => {
scroll_sepolia: scrollSepolia,
icon,
etherlink,
mantra,
}),
[
axelar,
Expand Down Expand Up @@ -181,6 +183,7 @@ const StepChooseCurrency = ({ currency, setCurrency }: StepProps) => {
scrollSepolia,
icon,
etherlink,
mantra,
],
);

Expand Down
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 @@ -126,6 +126,7 @@ setSupportedCurrencies([
"scroll_sepolia",
"ton",
"etherlink",
"mantra",
]);

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 @@ -104,6 +104,7 @@ export default function AddAccountsSelectCrypto({ navigation, route }: Props) {
const icon = useFeature("currencyIcon");
const ton = useFeature("currencyTon");
const etherlink = useFeature("currencyEtherlink");
const mantra = useFeature("currencyMantra");

const featureFlaggedCurrencies = useMemo(
(): Partial<Record<CryptoCurrencyId, Feature<unknown> | null>> => ({
Expand Down Expand Up @@ -154,6 +155,7 @@ export default function AddAccountsSelectCrypto({ navigation, route }: Props) {
scroll_sepolia: scrollSepolia,
icon,
etherlink,
mantra,
}),
[
axelar,
Expand Down Expand Up @@ -203,6 +205,7 @@ export default function AddAccountsSelectCrypto({ navigation, route }: Props) {
scrollSepolia,
icon,
etherlink,
mantra,
],
);

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 @@ -69,4 +69,5 @@ setSupportedCurrencies([
"optimism_sepolia",
"linea",
"linea_sepolia",
"mantra",
]);
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ exports[`formatCurrencyUnit with custom options with locale de-DE should correct

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

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

exports[`formatCurrencyUnit with custom options with locale de-DE should correctly format Metis unit (METIS) 1`] = `"0,012345678900000000- -METIS"`;

exports[`formatCurrencyUnit with custom options with locale de-DE should correctly format Monero unit (XMR) 1`] = `"12.345,678900000000- -XMR"`;
Expand Down Expand Up @@ -502,6 +504,8 @@ exports[`formatCurrencyUnit with custom options with locale en-US should correct

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

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

exports[`formatCurrencyUnit with custom options with locale en-US should correctly format Metis unit (METIS) 1`] = `"0.012345678900000000- -METIS"`;

exports[`formatCurrencyUnit with custom options with locale en-US should correctly format Monero unit (XMR) 1`] = `"12,345.678900000000- -XMR"`;
Expand Down Expand Up @@ -828,6 +832,8 @@ exports[`formatCurrencyUnit with custom options with locale es-ES should correct

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

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

exports[`formatCurrencyUnit with custom options with locale es-ES should correctly format Metis unit (METIS) 1`] = `"0,012345678900000000- -METIS"`;

exports[`formatCurrencyUnit with custom options with locale es-ES should correctly format Monero unit (XMR) 1`] = `"12.345,678900000000- -XMR"`;
Expand Down Expand Up @@ -1154,6 +1160,8 @@ exports[`formatCurrencyUnit with custom options with locale fr-FR should correct

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

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

exports[`formatCurrencyUnit with custom options with locale fr-FR should correctly format Metis unit (METIS) 1`] = `"0,012345678900000000- -METIS"`;

exports[`formatCurrencyUnit with custom options with locale fr-FR should correctly format Monero unit (XMR) 1`] = `"12 345,678900000000- -XMR"`;
Expand Down Expand Up @@ -1480,6 +1488,8 @@ exports[`formatCurrencyUnit with custom options with locale ja-JP should correct

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

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

exports[`formatCurrencyUnit with custom options with locale ja-JP should correctly format Metis unit (METIS) 1`] = `"0.012345678900000000- -METIS"`;

exports[`formatCurrencyUnit with custom options with locale ja-JP should correctly format Monero unit (XMR) 1`] = `"12,345.678900000000- -XMR"`;
Expand Down Expand Up @@ -1806,6 +1816,8 @@ exports[`formatCurrencyUnit with custom options with locale ko-KR should correct

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

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

exports[`formatCurrencyUnit with custom options with locale ko-KR should correctly format Metis unit (METIS) 1`] = `"0.012345678900000000- -METIS"`;

exports[`formatCurrencyUnit with custom options with locale ko-KR should correctly format Monero unit (XMR) 1`] = `"12,345.678900000000- -XMR"`;
Expand Down Expand Up @@ -2132,6 +2144,8 @@ exports[`formatCurrencyUnit with custom options with locale pt-BR should correct

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

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

exports[`formatCurrencyUnit with custom options with locale pt-BR should correctly format Metis unit (METIS) 1`] = `"0,012345678900000000- -METIS"`;

exports[`formatCurrencyUnit with custom options with locale pt-BR should correctly format Monero unit (XMR) 1`] = `"12.345,678900000000- -XMR"`;
Expand Down Expand Up @@ -2458,6 +2472,8 @@ exports[`formatCurrencyUnit with custom options with locale ru-RU should correct

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

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

exports[`formatCurrencyUnit with custom options with locale ru-RU should correctly format Metis unit (METIS) 1`] = `"0,012345678900000000- -METIS"`;

exports[`formatCurrencyUnit with custom options with locale ru-RU should correctly format Monero unit (XMR) 1`] = `"12 345,678900000000- -XMR"`;
Expand Down Expand Up @@ -2784,6 +2800,8 @@ exports[`formatCurrencyUnit with custom options with locale tr-TR should correct

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

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

exports[`formatCurrencyUnit with custom options with locale tr-TR should correctly format Metis unit (METIS) 1`] = `"0,012345678900000000- -METIS"`;

exports[`formatCurrencyUnit with custom options with locale tr-TR should correctly format Monero unit (XMR) 1`] = `"12.345,678900000000- -XMR"`;
Expand Down Expand Up @@ -3110,6 +3128,8 @@ exports[`formatCurrencyUnit with custom options with locale zh-CN should correct

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

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

exports[`formatCurrencyUnit with custom options with locale zh-CN should correctly format Metis unit (METIS) 1`] = `"0.012345678900000000- -METIS"`;

exports[`formatCurrencyUnit with custom options with locale zh-CN should correctly format Monero unit (XMR) 1`] = `"12,345.678900000000- -XMR"`;
Expand Down Expand Up @@ -3436,6 +3456,8 @@ exports[`formatCurrencyUnit with default options should correctly format Lukso u

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

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

exports[`formatCurrencyUnit with default options should correctly format Metis unit (METIS) 1`] = `"0.0123456"`;

exports[`formatCurrencyUnit with default options should correctly format Monero unit (XMR) 1`] = `"12,345.6"`;
Expand Down
20 changes: 20 additions & 0 deletions libs/coin-modules/coin-cosmos/src/chain/Mantra.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import CosmosBase from "./cosmosBase";

class Mantra 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 = "mantra";
this.validatorPrefix = `${this.prefix}valoper`;
}
}

export default Mantra;
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 @@ -16,6 +16,7 @@ import BinanceBeaconChain from "./BinanceBeaconChain";
import Coreum from "./Coreum";
import Injective from "./Injective";
import Dydx from "./Dydx";
import Mantra from "./Mantra";

const cosmosChainParams: { [key: string]: CosmosBase } = {};
export default function cryptoFactory(currencyId: string): CosmosBase {
Expand Down Expand Up @@ -74,6 +75,9 @@ export default function cryptoFactory(currencyId: string): CosmosBase {
case "injective":
cosmosChainParams[currencyId] = new Injective();
break;
case "mantra":
cosmosChainParams[currencyId] = new Mantra();
break;
default:
throw new Error(`${currencyId} is not supported`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe("cryptoFactory test", () => {
"sei_network",
"stargaze",
"stride",
"mantra",
];
currencies.forEach(currency => {
expect(cryptoFactory(currency)).not.toBeNull();
Expand Down
10 changes: 10 additions & 0 deletions libs/coin-modules/coin-cosmos/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ export const cosmosConfig: CosmosConfig = {
},
},
},
config_currency_mantra: {
type: "object",
default: {
lcd: "https://api.mantrachain.io",
minGasPrice: 0.01,
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 @@ -590,6 +590,15 @@ const injective = {
}),
};

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

export default {
axelar,
cosmos,
Expand All @@ -605,4 +614,5 @@ export default {
stargaze,
coreum,
injective,
mantra,
};
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ setSupportedCurrencies([
"telos_evm",
"coreum",
"injective",
"mantra",
"vechain",
"casper",
"neon_evm",
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 @@ -78,6 +78,7 @@ export const getVotesCount = (
case "osmosis":
case "cosmos":
case "coreum":
case "mantra":
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 @@ -1630,6 +1630,7 @@ exports[`sortCurrenciesByIds snapshot 1`] = `
"scroll",
"binance_beacon_chain",
"etherlink",
"mantra",
"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 @@ -39,6 +39,7 @@ export const IDS = [
"axelar",
"persistence",
"onomy",
"mantra",
];

export const CURRENCIES_LIST: CryptoCurrency[] = [
Expand Down Expand Up @@ -505,4 +506,33 @@ export const CURRENCIES_LIST: CryptoCurrency[] = [
},
],
},
{
type: "CryptoCurrency",
id: "mantra",
coinType: 118,
name: "Mantra",
managerAppName: "Cosmos",
ticker: "OM",
scheme: "mantra",
color: "#ffb386",
family: "cosmos",
units: [
{
name: "Mantra",
code: "OM",
magnitude: 6,
},
{
name: "Micro-Mantra",
code: "uom",
magnitude: 0,
},
],
explorerViews: [
{
tx: "https://www.mintscan.io/mantra/txs/$hash",
address: "https://www.mintscan.io/mantra/validators/$address",
},
],
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ test("sortCurrenciesByIds simulate staking from portfolio", () => {
"axelar",
"persistence",
"onomy",
"mantra",
"quicksilver",
]);
});
Loading
Loading