createType allows multiple params (#1207)
This commit is contained in:
@@ -32,9 +32,9 @@
|
||||
"@polkadot/rpc-core": "^0.82.0-beta.96",
|
||||
"@polkadot/rpc-provider": "^0.82.0-beta.96",
|
||||
"@polkadot/types": "^0.82.0-beta.96",
|
||||
"@polkadot/util-crypto": "^0.94.1"
|
||||
"@polkadot/util-crypto": "^0.95.0-beta.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^0.94.1"
|
||||
"@polkadot/keyring": "^0.95.0-beta.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import extrinsics from '@polkadot/api-metadata/extrinsics/static';
|
||||
import { createType, ClassOf, GenericMethod } from '@polkadot/types';
|
||||
import { createType, GenericMethod } from '@polkadot/types';
|
||||
|
||||
import SignerPayload from './SignerPayload';
|
||||
|
||||
@@ -66,7 +66,7 @@ describe('SignerPayload', (): void => {
|
||||
|
||||
it('can be used as a feed to ExtrinsicPayload', (): void => {
|
||||
const signer = new SignerPayload(TEST).toPayload();
|
||||
const payload = new (ClassOf('ExtrinsicPayload'))(signer, { version: signer.version });
|
||||
const payload = createType('ExtrinsicPayload', signer, { version: signer.version });
|
||||
|
||||
expect(payload.era.toHex()).toEqual(TEST.era);
|
||||
expect(payload.method.toHex()).toEqual(TEST.method);
|
||||
|
||||
@@ -9,7 +9,7 @@ import { ApiInterfaceRx, ApiTypes } from './types';
|
||||
import BN from 'bn.js';
|
||||
import { Observable, combineLatest, of } from 'rxjs';
|
||||
import { first, map, mergeMap, switchMap, tap } from 'rxjs/operators';
|
||||
import { createType, ClassOf, Vec } from '@polkadot/types';
|
||||
import { createType, Vec } from '@polkadot/types';
|
||||
import { isBn, isFunction, isNumber, isUndefined } from '@polkadot/util';
|
||||
|
||||
import filterEvents from './util/filterEvents';
|
||||
@@ -113,7 +113,7 @@ export default function createSubmittableExtrinsic<ApiType> (
|
||||
extrinsic: Method | Uint8Array | string,
|
||||
trackingCb?: Callback<ISubmittableResult>
|
||||
): SubmittableExtrinsic<ApiType> {
|
||||
const _extrinsic = new (ClassOf('Extrinsic'))(extrinsic, { version: api.extrinsicType }) as unknown as SubmittableExtrinsic<ApiType>;
|
||||
const _extrinsic = createType('Extrinsic', extrinsic, { version: api.extrinsicType }) as unknown as SubmittableExtrinsic<ApiType>;
|
||||
const _noStatusCb = type === 'rxjs';
|
||||
|
||||
function updateSigner (updateId: number, status: Hash | ISubmittableResult): void {
|
||||
|
||||
@@ -99,7 +99,8 @@ export default async function test (): Promise<void> {
|
||||
const compact = createType('Compact<u32>', 2);
|
||||
// const random = createType('RandomType', 2); // This one should deliberately show a TS error
|
||||
|
||||
const gasUnsafe = createTypeUnsafe('Gas', 2);
|
||||
const overriddenUnsafe = createTypeUnsafe<Header>('Gas', 2);
|
||||
const gasUnsafe = createTypeUnsafe('Gas', [2]);
|
||||
const overriddenUnsafe = createTypeUnsafe<Header>('Gas', [2]);
|
||||
|
||||
console.log(balance, gas, compact, gasUnsafe, overriddenUnsafe);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { Signer, SignerPayload, SignerResult } from '@polkadot/api/types';
|
||||
import { KeyringPair } from '@polkadot/keyring/types';
|
||||
|
||||
import { ClassOf } from '@polkadot/types';
|
||||
import { createType } from '@polkadot/types';
|
||||
|
||||
let id = 0;
|
||||
|
||||
@@ -41,7 +41,7 @@ export default class SingleAccountSigner implements Signer {
|
||||
|
||||
return new Promise((resolve): void => {
|
||||
setTimeout((): void => {
|
||||
const signed = new (ClassOf('ExtrinsicPayload'))(payload, { version: payload.version }).sign(this.keyringPair);
|
||||
const signed = createType('ExtrinsicPayload', payload, { version: payload.version }).sign(this.keyringPair);
|
||||
const result: SignerResult = { id: ++id, ...signed };
|
||||
|
||||
resolve(result);
|
||||
|
||||
Reference in New Issue
Block a user