Use palletId correctly for nominationPools (#7533)
This commit is contained in:
parent
b265c7f3ff
commit
97344da107
@ -11,20 +11,14 @@ import { createNamedHook, useApi } from '@polkadot/react-hooks';
|
||||
import { bnToU8a, stringToU8a, u8aConcat } from '@polkadot/util';
|
||||
|
||||
const EMPTY_H256 = new Uint8Array(32);
|
||||
const ADDR_PREFIX_SUB = stringToU8a('modlpy/npols');
|
||||
const ADDR_PREFIX_POL = stringToU8a('modlpy/nopls');
|
||||
const MOD_PREFIX = stringToU8a('modl');
|
||||
|
||||
export function createAccount (api: ApiPromise, poolId: BN, index: number): string {
|
||||
return api.registry.createType(
|
||||
'AccountId32',
|
||||
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 (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,
|
||||
MOD_PREFIX,
|
||||
api.consts.nominationPools.palletId.toU8a(),
|
||||
new Uint8Array([index]),
|
||||
bnToU8a(poolId, { bitLength: 32 }),
|
||||
EMPTY_H256
|
||||
|
||||
Loading…
Reference in New Issue
Block a user