diff --git a/packages/common/src/chaindata/queries/ChainMeta.ts b/packages/common/src/chaindata/queries/ChainMeta.ts index e7786ae42..3509529c7 100644 --- a/packages/common/src/chaindata/queries/ChainMeta.ts +++ b/packages/common/src/chaindata/queries/ChainMeta.ts @@ -31,13 +31,10 @@ export const getDenom = async ( try { const api = await chaindata.handler.getApi(); - const chainType = await api.rpc.system.chain(); - if (!chainType) { - return null; - } - const denom = - chainType.toString() == "Polkadot" ? 10000000000 : 1000000000000; - return denom; + const chainProps = await api.registry.getChainProperties(); + const decimals = chainProps.tokenDecimals.toJSON()[0]; + + return 10 ** decimals; } catch (e) { await handleError(chaindata, e, "getDenom", HandlerType.RelayHandler); return null; diff --git a/packages/common/test/scorekeeper/NumNominations.unit.test.ts b/packages/common/test/scorekeeper/NumNominations.unit.test.ts index e1192c919..9acca94e1 100644 --- a/packages/common/test/scorekeeper/NumNominations.unit.test.ts +++ b/packages/common/test/scorekeeper/NumNominations.unit.test.ts @@ -63,6 +63,13 @@ describe("autoNumNominations", () => { }), }, }, + registry: { + getChainProperties: vi.fn().mockResolvedValue({ + tokenDecimals: { + toJSON: vi.fn().mockImplementation(() => [10]), + }, + }), + }, }); const relayApiHandler = new ApiHandler(KusamaEndpoints);