Move Event, Address, AccountId, AccountIndex to generic (#1202)
* Move Event, Address, AccountId, AccountIndex to generic * Move AccountId, AccountIndex, Address & Event to generic * Move Vote
This commit is contained in:
@@ -23,7 +23,7 @@ import { Storage } from '@polkadot/api-metadata/storage/types';
|
||||
import storageFromMeta from '@polkadot/api-metadata/storage/fromMetadata';
|
||||
import RpcCore from '@polkadot/rpc-core';
|
||||
import { WsProvider } from '@polkadot/rpc-provider';
|
||||
import { Event, getTypeRegistry, Metadata, Method, Null, u64 } from '@polkadot/types';
|
||||
import { getTypeRegistry, GenericEvent, Metadata, Method, Null, u64 } from '@polkadot/types';
|
||||
import Linkage, { LinkageResult } from '@polkadot/types/codec/Linkage';
|
||||
import { DEFAULT_VERSION as EXTRINSIC_DEFAULT_VERSION } from '@polkadot/types/primitive/Extrinsic/constants';
|
||||
import { MethodFunction, ModulesWithMethods } from '@polkadot/types/primitive/Method';
|
||||
@@ -533,7 +533,7 @@ export default abstract class ApiBase<ApiType> {
|
||||
|
||||
// only inject if we are not a clone (global init)
|
||||
if (!this._options.source) {
|
||||
Event.injectMetadata(this.runtimeMetadata);
|
||||
GenericEvent.injectMetadata(this.runtimeMetadata);
|
||||
Method.injectMethods(extrinsics);
|
||||
|
||||
// detect the extrinsic version in-use based on the last block
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Balance, BlockNumber, Hash, Index } from '@polkadot/types/interfaces';
|
||||
import { Address, Balance, BlockNumber, Hash, Index } from '@polkadot/types/interfaces';
|
||||
import { SignerPayload as ISignerPayload } from './types';
|
||||
|
||||
import { Address, ClassOf, Compact, ExtrinsicEra, Struct, u8, Method } from '@polkadot/types';
|
||||
import { ClassOf, Compact, ExtrinsicEra, Struct, u8, Method } from '@polkadot/types';
|
||||
|
||||
export interface SignerPayloadType {
|
||||
address: Address;
|
||||
@@ -20,7 +20,7 @@ export interface SignerPayloadType {
|
||||
}
|
||||
|
||||
export default class SignerPayload extends Struct.with({
|
||||
address: Address,
|
||||
address: ClassOf('Address'),
|
||||
blockHash: ClassOf('Hash'),
|
||||
blockNumber: ClassOf('BlockNumber'),
|
||||
era: ExtrinsicEra,
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ExtrinsicStatus, EventRecord, Hash, Header, Index, SignedBlock } from '@polkadot/types/interfaces';
|
||||
import { AccountId, Address, ExtrinsicStatus, EventRecord, Hash, Header, Index, SignedBlock } from '@polkadot/types/interfaces';
|
||||
import { AnyNumber, AnyU8a, Callback, Codec, IExtrinsic, IExtrinsicEra, IKeyringPair, SignatureOptions } from '@polkadot/types/types';
|
||||
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, AccountId, Address, getTypeRegistry, Method, Vec, ExtrinsicEra } from '@polkadot/types';
|
||||
import { createType, ClassOf, Method, Vec, ExtrinsicEra } 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 (getTypeRegistry().getOrThrow('Extrinsic'))(extrinsic, { version: api.extrinsicType }) as SubmittableExtrinsic<ApiType>;
|
||||
const _extrinsic = new (ClassOf('Extrinsic'))(extrinsic, { version: api.extrinsicType }) as unknown as SubmittableExtrinsic<ApiType>;
|
||||
const _noStatusCb = type === 'rxjs';
|
||||
|
||||
function updateSigner (updateId: number, status: Hash | ISubmittableResult): void {
|
||||
|
||||
@@ -9,7 +9,7 @@ import BN from 'bn.js';
|
||||
import ApiRx from '@polkadot/api/rx/Api';
|
||||
import { HeaderExtended } from '@polkadot/api-derive';
|
||||
import { DerivedBalances, DerivedContractFees, DerivedElectionsInfo, DerivedFees, DerivedSessionInfo } from '@polkadot/api-derive/types';
|
||||
import { AccountId, AccountIndex, ClassOf } from '@polkadot/types';
|
||||
import { createType, ClassOf } from '@polkadot/types';
|
||||
import { WsProvider } from '@polkadot/rpc-provider';
|
||||
|
||||
const WS = 'ws://127.0.0.1:9944/';
|
||||
@@ -74,7 +74,7 @@ describe.skip('Api-RX derive e2e', (): void => {
|
||||
api.derive.accounts.indexToId(IX).subscribe((accountId): void => {
|
||||
// The first emitted value for accountId is undefined when passing the IX
|
||||
if (accountId) {
|
||||
expect(accountId instanceof AccountId).toBe(true);
|
||||
expect(accountId instanceof ClassOf('AccountId')).toBe(true);
|
||||
expect(accountId.toString()).toEqual(ID);
|
||||
} else {
|
||||
expect(accountId).toEqual(undefined);
|
||||
@@ -90,7 +90,7 @@ describe.skip('Api-RX derive e2e', (): void => {
|
||||
api.derive.accounts.idToIndex(ID).subscribe((accountIndex): void => {
|
||||
// The first emitted value for AccountIndex is undefined when passing the ID
|
||||
if (accountIndex) {
|
||||
expect(accountIndex instanceof AccountIndex).toBe(true);
|
||||
expect(accountIndex instanceof ClassOf('AccountIndex')).toBe(true);
|
||||
expect(accountIndex.toString()).toEqual(IX);
|
||||
} else {
|
||||
expect(accountIndex).toEqual(undefined);
|
||||
@@ -107,7 +107,7 @@ describe.skip('Api-RX derive e2e', (): void => {
|
||||
// A local dev chain should have the AccountIndex of Alice
|
||||
expect(accountIndexes).toHaveProperty(
|
||||
ID,
|
||||
new AccountIndex(IX)
|
||||
createType('AccountIndex', IX)
|
||||
);
|
||||
done();
|
||||
});
|
||||
@@ -122,7 +122,7 @@ describe.skip('Api-RX derive e2e', (): void => {
|
||||
it('It returns an object with all relevant balance information of an account', async (done): Promise<void> => {
|
||||
api.derive.balances.all(ID).subscribe((balances: DerivedBalances): void => {
|
||||
expect(balances).toEqual(expect.objectContaining({
|
||||
accountId: expect.any(AccountId),
|
||||
accountId: expect.any(ClassOf('AccountId')),
|
||||
accountNonce: expect.any(ClassOf('Index')),
|
||||
availableBalance: expect.any(BN),
|
||||
freeBalance: expect.any(BN),
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { EventRecord, Header } from '@polkadot/types/interfaces';
|
||||
import { AccountId, EventRecord, Header } from '@polkadot/types/interfaces';
|
||||
|
||||
import WsProvider from '@polkadot/rpc-provider/ws';
|
||||
import { AccountId, ClassOf, Option, Vec } from '@polkadot/types';
|
||||
import { ClassOf, Option, Vec } from '@polkadot/types';
|
||||
|
||||
import ApiPromise from '../../../src/promise';
|
||||
import describeE2E from '../../util/describeE2E';
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Hash } from '@polkadot/types/interfaces';
|
||||
import { Address, Hash } from '@polkadot/types/interfaces';
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
@@ -10,7 +10,6 @@ import path from 'path';
|
||||
import { Abi } from '@polkadot/api-contract';
|
||||
import testingPairs from '@polkadot/keyring/testingPairs';
|
||||
import WsProvider from '@polkadot/rpc-provider/ws';
|
||||
import { Address } from '@polkadot/types';
|
||||
|
||||
import { SubmittableResult } from '../../../src';
|
||||
import ApiPromise from '../../../src/promise';
|
||||
|
||||
Reference in New Issue
Block a user