From 76becbbd99330ec0e7dce63437d437ce6c559cb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Prohaszka?= <104785785+sprohaszka-ledger@users.noreply.github.com> Date: Thu, 27 Jun 2024 17:44:22 +0200 Subject: [PATCH] [DOT] Temporary remove all node calls (#7218) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: temporary remove all node calls Signed-off-by: Stéphane Prohaszka * chore: add changeset Signed-off-by: Stéphane Prohaszka --------- Signed-off-by: Stéphane Prohaszka --- .changeset/tidy-fireants-sit.md | 5 ++ .../coin-polkadot/.unimportedrc.json | 13 +++- .../coin-polkadot/src/network/sidecar.ts | 59 ++++++++++++++++--- 3 files changed, 68 insertions(+), 9 deletions(-) create mode 100644 .changeset/tidy-fireants-sit.md diff --git a/.changeset/tidy-fireants-sit.md b/.changeset/tidy-fireants-sit.md new file mode 100644 index 000000000000..b0f05916f0c0 --- /dev/null +++ b/.changeset/tidy-fireants-sit.md @@ -0,0 +1,5 @@ +--- +"@ledgerhq/coin-polkadot": patch +--- + +Revert call from node to sidecar diff --git a/libs/coin-modules/coin-polkadot/.unimportedrc.json b/libs/coin-modules/coin-polkadot/.unimportedrc.json index 51af4eab090f..476dc26de876 100644 --- a/libs/coin-modules/coin-polkadot/.unimportedrc.json +++ b/libs/coin-modules/coin-polkadot/.unimportedrc.json @@ -20,9 +20,18 @@ "src/test/coin-tester/indexer.ts", "src/test/coin-tester/scenarios/basic.ts", "src/test/coin-tester/scenarios/utils.ts", - "src/test/fixtures.ts" + "src/test/fixtures.ts", + "src/network/node/apiPromise.ts", + "src/network/node/constants.ts", + "src/network/node/identities.ts", + "src/network/node/index.ts", + "src/network/node/nominations.ts", + "src/network/node/stakingInfo.ts", + "src/network/node/validators.ts" ], "ignoreUnused": [ - "@polkadot/api" + "@polkadot/api", + "@polkadot/api-augment", + "@polkadot/api-derive" ] } diff --git a/libs/coin-modules/coin-polkadot/src/network/sidecar.ts b/libs/coin-modules/coin-polkadot/src/network/sidecar.ts index 7a124b7d929f..4874ae8f1833 100644 --- a/libs/coin-modules/coin-polkadot/src/network/sidecar.ts +++ b/libs/coin-modules/coin-polkadot/src/network/sidecar.ts @@ -1,4 +1,5 @@ import { BigNumber } from "bignumber.js"; +import querystring from "querystring"; import { TypeRegistry } from "@polkadot/types"; import { Extrinsics } from "@polkadot/types/metadata/decorate/types"; import network from "@ledgerhq/live-network/network"; @@ -23,9 +24,9 @@ import type { SidecarTransactionBroadcast, SidecarPaymentInfo, SidecarRuntimeSpec, + SidecarConstants, } from "./sidecar.types"; import { createRegistryAndExtrinsics } from "./common"; -import node from "./node"; /** * Returns the full indexer url for en route endpoint. @@ -114,8 +115,16 @@ const fetchControllerAddr = async (addr: string): Promise => { * * @returns {SidecarStakingInfo} */ -const fetchStakingInfo = async (addr: string): Promise => - node.fetchStakingInfo(addr); +const fetchStakingInfo = async (addr: string): Promise => { + //LIVE-13136: commented for the time being + // return node.fetchStakingInfo(addr); + const { + data, + }: { + data: SidecarStakingInfo; + } = await callSidecar(`/accounts/${addr}/staking-info`); + return data; +}; /** * Returns the list of nominations for an account, with status and associated stake if relevant. @@ -125,8 +134,16 @@ const fetchStakingInfo = async (addr: string): Promise => * * @returns {SidecarNominations} */ -const fetchNominations = async (addr: string): Promise => - node.fetchNominations(addr); +const fetchNominations = async (addr: string): Promise => { + //LIVE-13136: commented for the time being + // return node.fetchNominations(addr); + const { + data, + }: { + data: SidecarNominations; + } = await callSidecar(`/accounts/${addr}/nominations`); + return data; +}; /** * Returns the blockchain's runtime constants. @@ -135,7 +152,16 @@ const fetchNominations = async (addr: string): Promise => * * @returns {Object} */ -const fetchConstants = async (): Promise> => node.fetchConstants(); +const fetchConstants = async (): Promise> => { + //LIVE-13136: commented for the time being + // return node.fetchConstants(); + const { + data, + }: { + data: SidecarConstants; + } = await callSidecar(`/runtime/constants`); + return data.consts; +}; /** * Returns the activeEra info @@ -183,7 +209,26 @@ export const getMinimumBondBalance = async (): Promise => { const fetchValidators = async ( status: SidecarValidatorsParamStatus = "all", addresses?: SidecarValidatorsParamAddresses, -): Promise => node.fetchValidators(status, addresses); +): Promise => { + //LIVE-13136: commented for the time being + // return node.fetchValidators(status, addresses); + let params = {}; + + if (status) { + params = { ...params, status }; + } + + if (addresses && addresses.length) { + params = { ...params, addresses: addresses.join(",") }; + } + + const { + data, + }: { + data: SidecarValidators; + } = await callSidecar(`/validators?${querystring.stringify(params)}`); + return data; +}; /** * Fetch the progress info concerning staking.