HACK for both npols & nopls (#7527)
This commit is contained in:
parent
b3b52a4ab9
commit
59b1671075
@ -12,11 +12,22 @@ 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');
|
||||
|
||||
export function createAccount (api: ApiPromise, poolId: BN, index: number): string {
|
||||
return api.registry.createType(
|
||||
'AccountId32',
|
||||
u8aConcat(ADDR_PREFIX, new Uint8Array([index]), bnToU8a(poolId, { bitLength: 32 }), EMPTY_H256)
|
||||
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,
|
||||
new Uint8Array([index]),
|
||||
bnToU8a(poolId, { bitLength: 32 }),
|
||||
EMPTY_H256
|
||||
)
|
||||
).toString();
|
||||
}
|
||||
|
||||
|
||||
@ -62,8 +62,12 @@ const MATCHERS: AddrMatcher[] = [
|
||||
createAllMatcher('modlpy/socie', 'Society'),
|
||||
createAllMatcher('modlpy/trsry', 'Treasury'),
|
||||
createNumMatcher('modlpy/cfund', 'Crowdloan'),
|
||||
// Substrate master
|
||||
createNumMatcher('modlpy/npols\x00', 'Pool', 'Stash'),
|
||||
createNumMatcher('modlpy/npols\x01', 'Pool', 'Reward'),
|
||||
// Westend
|
||||
createNumMatcher('modlpy/nopls\x00', 'Pool', 'Stash'),
|
||||
createNumMatcher('modlpy/nopls\x01', 'Pool', 'Reward'),
|
||||
createNumMatcher('para', 'Parachain')
|
||||
];
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user