From d799786f658eead7c38ebefeb97227a494285e66 Mon Sep 17 00:00:00 2001 From: Jaco Date: Thu, 5 May 2022 13:14:40 +0200 Subject: [PATCH] Poll palletId check & fallback ordering (#7532) --- packages/page-staking/src/usePoolAccounts.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/page-staking/src/usePoolAccounts.ts b/packages/page-staking/src/usePoolAccounts.ts index b7b4de1d80..9c66958a9e 100644 --- a/packages/page-staking/src/usePoolAccounts.ts +++ b/packages/page-staking/src/usePoolAccounts.ts @@ -11,8 +11,8 @@ import { createNamedHook, useApi } from '@polkadot/react-hooks'; import { bnToU8a, stringToU8a, u8aConcat } from '@polkadot/util'; const EMPTY_H256 = new Uint8Array(32); -const ADDR_PREFIX = stringToU8a('modlpy/npols'); -const ADDR_PREFIX_WST = stringToU8a('modlpy/nopls'); +const ADDR_PREFIX_SUB = stringToU8a('modlpy/npols'); +const ADDR_PREFIX_POL = stringToU8a('modlpy/nopls'); export function createAccount (api: ApiPromise, poolId: BN, index: number): string { return api.registry.createType( @@ -20,10 +20,11 @@ export function createAccount (api: ApiPromise, poolId: BN, index: number): stri u8aConcat( // HACK: We have a naming issue between Substrate master as well as Westend. Since // we don't quite have access to palletId, we here check the specName and adjust - // accordingly - api.runtimeVersion.specName.eq('westend') - ? ADDR_PREFIX_WST - : ADDR_PREFIX, + // accordingly (We assume that all Polkadot will follow Westend, so keep Substrate + // as the odd one out... this may bite us) + api.runtimeVersion.specName.eq('node') + ? ADDR_PREFIX_SUB + : ADDR_PREFIX_POL, new Uint8Array([index]), bnToU8a(poolId, { bitLength: 32 }), EMPTY_H256