Skip to content

Commit

Permalink
feat: zenrock integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Canestin authored and qperrot committed Dec 19, 2024
1 parent 202a351 commit d94faf8
Show file tree
Hide file tree
Showing 30 changed files with 632 additions and 130 deletions.
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",
"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 @@ -96,4 +96,5 @@ setSupportedCurrencies([
"zksync",
"zksync_sepolia",
"mantra",
"zenrock",
]);
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 zenrock = useFeature("currencyZenrock");

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,
zenrock,
}),
[
axelar,
Expand Down Expand Up @@ -190,6 +192,7 @@ const StepChooseCurrency = ({ currency, setCurrency }: StepProps) => {
zksync,
zksyncSepolia,
mantra,
zenrock,
],
);

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": "zenrock",
"ticker": "ROCK",
"name": "Zenrock",
"family": "cosmos",
"color": "#080c44",
"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": "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 @@ -129,6 +129,7 @@ setSupportedCurrencies([
"zksync",
"zksync_sepolia",
"mantra",
"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 @@ -107,6 +107,7 @@ export default function AddAccountsSelectCrypto({ navigation, route }: Props) {
const zksync = useFeature("currencyZkSync");
const zksyncSepolia = useFeature("currencyZkSyncSepolia");
const mantra = useFeature("currencyMantra");
const zenrock = useFeature("currencyZenrock");

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,
zenrock,
}),
[
axelar,
Expand Down Expand Up @@ -212,6 +214,7 @@ export default function AddAccountsSelectCrypto({ navigation, route }: Props) {
zksync,
zksyncSepolia,
mantra,
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 @@ -70,4 +70,5 @@ setSupportedCurrencies([
"linea",
"linea_sepolia",
"mantra",
"zenrock",
]);
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,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 @@ -656,6 +658,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 @@ -988,6 +992,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 @@ -1320,6 +1326,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 @@ -1652,6 +1660,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 @@ -1984,6 +1994,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 @@ -2316,6 +2328,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 @@ -2648,6 +2662,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 @@ -2980,6 +2996,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 @@ -3312,6 +3330,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 @@ -3644,6 +3664,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 @@ -17,6 +17,7 @@ import Coreum from "./Coreum";
import Injective from "./Injective";
import Dydx from "./Dydx";
import Mantra from "./Mantra";
import Zenrock from "./Zenrock";

const cosmosChainParams: { [key: string]: CosmosBase } = {};
export default function cryptoFactory(currencyId: string): CosmosBase {
Expand Down Expand Up @@ -78,6 +79,9 @@ export default function cryptoFactory(currencyId: string): CosmosBase {
case "mantra":
cosmosChainParams[currencyId] = new Mantra();
break;
case "zenrock":
cosmosChainParams[currencyId] = new Zenrock();
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 @@ -21,6 +21,7 @@ describe("cryptoFactory test", () => {
"stargaze",
"stride",
"mantra",
"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 @@ -168,6 +168,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 @@ -599,6 +599,15 @@ const mantra = {
}),
};

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

export default {
axelar,
cosmos,
Expand All @@ -615,4 +624,5 @@ export default {
coreum,
injective,
mantra,
zenrock,
};
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ setSupportedCurrencies([
"zksync",
"zksync_sepolia",
"mantra",
"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 @@ -79,6 +79,7 @@ export const getVotesCount = (
case "cosmos":
case "coreum":
case "mantra":
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 @@ -1636,6 +1636,7 @@ exports[`sortCurrenciesByIds snapshot 1`] = `
"zksync_sepolia",
"binance_beacon_chain",
"mantra",
"zenrock",
"ethereum/erc20/$aapl",
"ethereum/erc20/$based",
"ethereum/erc20/$die",
Expand Down
1 change: 1 addition & 0 deletions libs/ledger-live-common/src/currencies/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const IDS = [
"persistence",
"onomy",
"mantra",
"zenrock",
];

export const CURRENCIES_LIST: CryptoCurrency[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ test("sortCurrenciesByIds simulate staking from portfolio", () => {
"persistence",
"onomy",
"mantra",
"zenrock",
"quicksilver",
]);
});
Loading

0 comments on commit d94faf8

Please sign in to comment.