Swap to registry.createType (#1947)

This commit is contained in:
Jaco Greeff
2020-02-26 11:17:11 +01:00
committed by GitHub
parent 333ff8528b
commit 8598002801
62 changed files with 209 additions and 235 deletions
@@ -7,7 +7,7 @@ import { AnyJson, Constructor, Registry } from '@polkadot/types/types';
import BN from 'bn.js';
import democracyTypes from '@polkadot/types/interfaces/democracy/definitions';
import { Struct, createType } from '@polkadot/types';
import { Struct } from '@polkadot/types';
// We can ignore the properties, added via Struct.with
const _ReferendumInfo: Constructor<ReferendumInfo> = Struct.with(democracyTypes.types.ReferendumInfo as any) as any;
@@ -25,7 +25,7 @@ export default class ReferendumInfoExtended extends _ReferendumInfo {
this.#index = value instanceof ReferendumInfoExtended
? value.index
: createType(registry, 'ReferendumIndex', index);
: registry.createType('ReferendumIndex', index);
}
/**
@@ -4,7 +4,7 @@
import { ApprovalFlag } from '@polkadot/types/interfaces';
import { createType, TypeRegistry } from '@polkadot/types';
import { TypeRegistry } from '@polkadot/types';
import { approvalFlagsToBools } from './approvalFlagsToBools';
@@ -20,7 +20,7 @@ describe('approvalFlagsToBools', (): void => {
it('translates a single input', (): void => {
expect(
approvalFlagsToBools([
createType(registry, 'ApprovalFlag', 0b1010)
registry.createType('ApprovalFlag', 0b1010)
])
).toEqual([false, true, false, true]);
});
@@ -28,8 +28,8 @@ describe('approvalFlagsToBools', (): void => {
it('translates multiple inputs', (): void => {
expect(
approvalFlagsToBools([
createType(registry, 'ApprovalFlag', 0b0000),
createType(registry, 'ApprovalFlag', 0b1100)
registry.createType('ApprovalFlag', 0b0000),
registry.createType('ApprovalFlag', 0b1100)
])
).toEqual([false, false, false, true, true]);
});