Swap createType to registry.createType (#268)

This commit is contained in:
Jaco Greeff 2020-03-16 16:03:42 +01:00 committed by GitHub
parent 80d66c4d40
commit 3f2e1ae172
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -7,7 +7,7 @@ import { AccountJson, RequestSign } from '@polkadot/extension/background/types';
import { SignerPayloadJSON, SignerPayloadRaw } from '@polkadot/types/types';
import React, { useContext, useState, useEffect } from 'react';
import { TypeRegistry, createType } from '@polkadot/types';
import { TypeRegistry } from '@polkadot/types';
import { ActionBar, ActionContext, Address, ButtonArea, Link, VerticalSpace } from '../../components';
import { approveSignPassword, approveSignSignature, cancelSignRequest } from '../../messaging';
@ -40,7 +40,7 @@ export default function Request ({ account: { isExternal }, request, signId, url
setHexBytes((inner as SignerPayloadRaw).data);
setExtrinsic(null);
} else {
setExtrinsic(createType(registry, 'ExtrinsicPayload', inner, { version: (inner as SignerPayloadJSON).version }));
setExtrinsic(registry.createType('ExtrinsicPayload', inner, { version: (inner as SignerPayloadJSON).version }));
setHexBytes(null);
}
}, [request]);

View File

@ -2,10 +2,11 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { createType, TypeRegistry } from '@polkadot/types';
import { KeyringPair } from '@polkadot/keyring/types';
import { RequestSign } from './types';
import { SignerPayloadJSON, SignerPayloadRaw } from '@polkadot/types/types';
import { RequestSign } from './types';
import { TypeRegistry } from '@polkadot/types';
export default class RequestExtrinsicSign implements RequestSign {
public readonly inner: SignerPayloadJSON | SignerPayloadRaw;
@ -16,7 +17,7 @@ export default class RequestExtrinsicSign implements RequestSign {
sign (registry: TypeRegistry, pair: KeyringPair): { signature: string } {
const inner = this.inner as SignerPayloadJSON;
const extrinsic = createType(registry, 'ExtrinsicPayload', this.inner, { version: inner.version });
const extrinsic = registry.createType('ExtrinsicPayload', this.inner, { version: inner.version });
return extrinsic.sign(pair);
}