Poll palletId check & fallback ordering (#7532)
This commit is contained in:
parent
c971907c84
commit
d799786f65
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user