HACK for both npols & nopls (#7527)

This commit is contained in:
Jaco 2022-05-05 06:44:01 +02:00 committed by GitHub
parent b3b52a4ab9
commit 59b1671075
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -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();
}

View File

@ -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')
];