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: zenrock integration #8731

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
15 changes: 15 additions & 0 deletions .changeset/stupid-eggs-fry.md
Original file line number Diff line number Diff line change
@@ -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
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 @@ -103,6 +103,7 @@ setSupportedCurrencies([
"zksync_sepolia",
"mantra",
"xion",
"zenrock",
]);

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 @@ -97,4 +97,5 @@ setSupportedCurrencies([
"zksync_sepolia",
"mantra",
"xion",
"zenrock",
]);
Original file line number Diff line number Diff line change
Expand Up @@ -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<Record<CryptoCurrencyId, Feature<unknown> | null>> => ({
Expand Down Expand Up @@ -140,6 +141,7 @@ const StepChooseCurrency = ({ currency, setCurrency }: StepProps) => {
zksync_sepolia: zksyncSepolia,
mantra,
xion,
zenrock,
}),
[
axelar,
Expand Down Expand Up @@ -193,6 +195,7 @@ const StepChooseCurrency = ({ currency, setCurrency }: StepProps) => {
zksyncSepolia,
mantra,
xion,
zenrock,
],
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -817,5 +817,14 @@
"family": "cosmos",
"color": "#000000",
"decimals": 6
},
{
"type": "CryptoCurrency",
"id": "zenrock",
"ticker": "ROCK",
"name": "Zenrock",
"family": "cosmos",
"color": "#080c44",
"decimals": 6
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -817,5 +817,14 @@
"family": "cosmos",
"color": "#000000",
"decimals": 6
},
{
"type": "CryptoCurrency",
"id": "zenrock",
"ticker": "ROCK",
"name": "Zenrock",
"family": "cosmos",
"color": "#080c44",
"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 @@ -130,6 +130,7 @@ setSupportedCurrencies([
"zksync_sepolia",
"mantra",
"xion",
"zenrock",
]);

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 @@ -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<Record<CryptoCurrencyId, Feature<unknown> | null>> => ({
Expand Down Expand Up @@ -162,6 +163,7 @@ export default function AddAccountsSelectCrypto({ navigation, route }: Props) {
zksync_sepolia: zksyncSepolia,
mantra,
xion,
zenrock,
}),
[
axelar,
Expand Down Expand Up @@ -215,6 +217,7 @@ export default function AddAccountsSelectCrypto({ navigation, route }: Props) {
zksyncSepolia,
mantra,
xion,
zenrock,
],
);

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 @@ -71,4 +71,5 @@ setSupportedCurrencies([
"linea_sepolia",
"mantra",
"xion",
"zenrock",
]);
Original file line number Diff line number Diff line change
Expand Up @@ -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"`;
Expand Down Expand Up @@ -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"`;
Expand Down Expand Up @@ -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"`;
Expand Down Expand Up @@ -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"`;
Expand Down Expand Up @@ -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"`;
Expand Down Expand Up @@ -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"`;
Expand Down Expand Up @@ -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"`;
Expand Down Expand Up @@ -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"`;
Expand Down Expand Up @@ -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"`;
Expand Down Expand Up @@ -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"`;
Expand Down Expand Up @@ -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"`;
Expand Down
20 changes: 20 additions & 0 deletions libs/coin-modules/coin-cosmos/src/chain/Zenrock.ts
Original file line number Diff line number Diff line change
@@ -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;
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 @@ -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 {
Expand Down Expand Up @@ -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`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe("cryptoFactory test", () => {
"mantra",
"crypto_org",
"xion",
"zenrock",
];
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 @@ -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";
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 @@ -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,
Expand All @@ -636,4 +645,5 @@ export default {
mantra,
cryptoOrg,
xion,
zenrock,
};
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ setSupportedCurrencies([
"zksync_sepolia",
"mantra",
"xion",
"zenrock",
]);
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 @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,7 @@ exports[`sortCurrenciesByIds snapshot 1`] = `
"binance_beacon_chain",
"mantra",
"xion",
"zenrock",
"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 @@ -42,6 +42,7 @@ export const IDS = [
"mantra",
"crypto_org",
"xion",
"zenrock",
];

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