Remove API deprecated interfaces (#5109)
* Remove API deprecated interfaces * Adjust checkTypes * CHANGELOG
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
|
||||
## master
|
||||
|
||||
- **Breaking change** Deprecated interfaces have been removed including `tx.sign(...)` (use `signAsync`), `{is, as}Error` on Result (use `{is, as}Err`) as well as storage `.range(...)` operations.
|
||||
- **Breaking change** Deprecated interfaces on `api-contract` has been removed. Always ensure you pass an options options to construction and queries.
|
||||
|
||||
Changes:
|
||||
|
||||
- Convert `api-contract` usage of `api.rpc.*` to `api.call.*`
|
||||
|
||||
@@ -58,10 +58,6 @@ export interface StorageEntryBase<ApiType extends ApiTypes, F extends AnyFunctio
|
||||
* @deprecated Use api.at(<blockHash>)
|
||||
*/
|
||||
keysAt: <K extends AnyTuple = A> (hash: Hash | Uint8Array | string, ...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, StorageKey<K>[]>;
|
||||
/**
|
||||
* @deprecated The underlying RPC this been marked unsafe and is generally not exposed
|
||||
*/
|
||||
range: <T extends Codec | any = ReturnCodec<F>>([from, to]: [Hash | Uint8Array | string, Hash | Uint8Array | string | undefined] | [Hash | Uint8Array | string], ...args: Parameters<F>) => PromiseOrObs<ApiType, [Hash, T][]>;
|
||||
/**
|
||||
* @deprecated Use api.at(<blockHash>)
|
||||
*/
|
||||
|
||||
@@ -58,11 +58,6 @@ export interface SubmittableExtrinsic<ApiType extends ApiTypes, R extends ISubmi
|
||||
|
||||
send (statusCb: Callback<R>): SubmittableResultSubscription<ApiType, R>;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
sign (account: IKeyringPair, _options?: Partial<SignerOptions>): this;
|
||||
|
||||
signAsync (account: AddressOrPair, _options?: Partial<SignerOptions>): PromiseOrObs<ApiType, this>;
|
||||
|
||||
signAndSend (account: AddressOrPair, options?: Partial<SignerOptions>): SubmittableResultResult<ApiType, R>;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { AugmentedCall, DeriveCustom, QueryableCalls } from '@polkadot/api-base/types';
|
||||
import type { RpcInterface } from '@polkadot/rpc-core/types';
|
||||
import type { Option, Raw, StorageKey, Text, u64 } from '@polkadot/types';
|
||||
import type { StorageKey, Text, u64 } from '@polkadot/types';
|
||||
import type { Call, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
import type { DecoratedMeta } from '@polkadot/types/metadata/decorate/types';
|
||||
import type { StorageEntry } from '@polkadot/types/primitive/types';
|
||||
@@ -19,7 +19,7 @@ import { BehaviorSubject, combineLatest, from, map, of, switchMap, tap, toArray
|
||||
import { getAvailableDerives } from '@polkadot/api-derive';
|
||||
import { memo, RpcCore } from '@polkadot/rpc-core';
|
||||
import { WsProvider } from '@polkadot/rpc-provider';
|
||||
import { expandMetadata, Metadata, typeDefinitions, TypeRegistry, unwrapStorageType } from '@polkadot/types';
|
||||
import { expandMetadata, Metadata, typeDefinitions, TypeRegistry } from '@polkadot/types';
|
||||
import { getSpecRuntime } from '@polkadot/types-known';
|
||||
import { arrayChunk, arrayFlatten, assertReturn, BN, compactStripLength, lazyMethod, lazyMethods, logger, nextTick, objectSpread, stringCamelCase, stringUpperFirst, u8aConcatStrict, u8aToHex } from '@polkadot/util';
|
||||
import { blake2AsHex } from '@polkadot/util-crypto';
|
||||
@@ -707,9 +707,6 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
decorated.keyPrefix = (...args: unknown[]): string =>
|
||||
u8aToHex(creator.keyPrefix(...args));
|
||||
|
||||
decorated.range = decorateMethod((range: [Hash, Hash?], ...args: unknown[]): Observable<[Hash, Codec][]> =>
|
||||
this._decorateStorageRange(decorated, args, range));
|
||||
|
||||
decorated.size = decorateMethod((...args: unknown[]): Observable<u64> =>
|
||||
this._rpcCore.state.getStorageSize(getArgs(args)));
|
||||
|
||||
@@ -883,19 +880,6 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
});
|
||||
}
|
||||
|
||||
private _decorateStorageRange<ApiType extends ApiTypes> (decorated: QueryableStorageEntry<ApiType>, args: unknown[], range: [Hash, Hash?]): Observable<[Hash, Codec][]> {
|
||||
const outputType = unwrapStorageType(this.#registry, decorated.creator.meta.type, decorated.creator.meta.modifier.isOptional);
|
||||
|
||||
return this._rpcCore.state
|
||||
.queryStorage<[Option<Raw>]>([decorated.key(...args)], ...range)
|
||||
.pipe(map((result: [Hash, [Option<Raw>]][]): [Hash, Codec][] =>
|
||||
result.map(([blockHash, [value]]) => [
|
||||
blockHash,
|
||||
this.createType<Codec>(outputType, value.isSome ? value.unwrap().toHex() : undefined)
|
||||
])
|
||||
));
|
||||
}
|
||||
|
||||
// retrieve a set of values for a specific set of keys - here we chunk the keys into PAGE_SIZE sizes
|
||||
private _retrieveMulti (keys: [StorageEntry, unknown[]][], blockHash?: Uint8Array): Observable<Codec[]> {
|
||||
if (!keys.length) {
|
||||
|
||||
@@ -125,7 +125,7 @@ async function query (api: ApiPromise, pairs: TestKeyringMap): Promise<void> {
|
||||
console.log('query types:', bar, bal, bal2, override, oldBal, multia, multib);
|
||||
}
|
||||
|
||||
async function queryExtra (api: ApiPromise, pairs: TestKeyringMap): Promise<void> {
|
||||
async function queryExtra (api: ApiPromise): Promise<void> {
|
||||
// events destructing
|
||||
await api.query.system.events((records): void => {
|
||||
records.forEach(({ event, phase }): void => {
|
||||
@@ -155,14 +155,6 @@ async function queryExtra (api: ApiPromise, pairs: TestKeyringMap): Promise<void
|
||||
await api.query.assets.account.entries(123);
|
||||
await api.query.assets.blah.keys();
|
||||
|
||||
// check range
|
||||
await api.query.balances.freeBalance.range<Balance>(['0x1234'], pairs.bob.address);
|
||||
|
||||
// check range types
|
||||
const entries = await api.query.system.events.range(['0x12345', '0x7890']);
|
||||
|
||||
console.log(`Received ${entries.length} entries, ${entries.map(([hash, events]) => `${hash.toHex()}: ${events.length} events`).join(', ')}`);
|
||||
|
||||
// is
|
||||
const key = {} as StorageKey;
|
||||
|
||||
@@ -313,7 +305,7 @@ async function main (): Promise<void> {
|
||||
errors(api),
|
||||
events(api),
|
||||
query(api, pairs),
|
||||
queryExtra(api, pairs),
|
||||
queryExtra(api),
|
||||
queryMulti(api, pairs),
|
||||
rpc(api),
|
||||
types(api),
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { Address, ApplyExtrinsicResult, Call, Extrinsic, ExtrinsicEra, ExtrinsicStatus, Hash, Header, Index, RuntimeDispatchInfo, SignerPayload } from '@polkadot/types/interfaces';
|
||||
import type { Callback, Codec, Constructor, IKeyringPair, ISubmittableResult, SignatureOptions } from '@polkadot/types/types';
|
||||
import type { Callback, Codec, Constructor, ISubmittableResult, SignatureOptions } from '@polkadot/types/types';
|
||||
import type { Registry } from '@polkadot/types-codec/types';
|
||||
import type { ApiInterfaceRx, ApiTypes, PromiseOrObs, SignerResult } from '../types';
|
||||
import type { AddressOrPair, SignerOptions, SubmittableDryRunResult, SubmittableExtrinsic, SubmittablePaymentResult, SubmittableResultResult, SubmittableResultSubscription } from './types';
|
||||
@@ -170,17 +170,7 @@ export function createClass <ApiType extends ApiTypes> ({ api, apiType, blockHas
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Sign a transaction, returning the this to allow chaining, i.e. .sign(...).send(). When options, e.g. nonce/blockHash are not specified, it will be inferred. To retrieve eg. nonce use `signAsync` (the preferred interface, this is provided for backwards compatibility)
|
||||
* @deprecated
|
||||
*/
|
||||
public override sign (account: IKeyringPair, partialOptions?: Partial<SignerOptions>): this {
|
||||
super.sign(account, makeSignOptions(api, optionsOrNonce(partialOptions), {}));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Signs a transaction, returning `this` to allow chaining. E.g.: `sign(...).send()`. Like `.signAndSend` this will retrieve the nonce and blockHash to send the tx with.
|
||||
* @description Signs a transaction, returning `this` to allow chaining. E.g.: `signAsync(...).send()`. Like `.signAndSend` this will retrieve the nonce and blockHash to send the tx with.
|
||||
*/
|
||||
public signAsync (account: AddressOrPair, partialOptions?: Partial<SignerOptions>): PromiseOrObs<ApiType, this> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return,@typescript-eslint/no-unsafe-call
|
||||
|
||||
@@ -105,12 +105,12 @@ function tsNull (registry: Registry, definitions: Record<string, ModuleTypes>, {
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function tsResultGetter (registry: Registry, definitions: Record<string, ModuleTypes>, resultName = '', getter: 'Ok' | 'Err' | 'Error', def: TypeDef, imports: TypeImports): string {
|
||||
function tsResultGetter (registry: Registry, definitions: Record<string, ModuleTypes>, resultName = '', getter: 'Ok' | 'Err', def: TypeDef, imports: TypeImports): string {
|
||||
const { info, lookupName, type } = def;
|
||||
const asGetter = type === 'Null'
|
||||
? ''
|
||||
: (getter === 'Error' ? ' /** @deprecated Use asErr */\n' : '') + createGetter(definitions, `as${getter}`, lookupName || (info === TypeDefInfo.Tuple ? formatType(registry, definitions, def, imports, false) : type), imports);
|
||||
const isGetter = (getter === 'Error' ? ' /** @deprecated Use isErr */\n' : '') + createGetter(definitions, `is${getter}`, 'boolean', imports);
|
||||
: createGetter(definitions, `as${getter}`, lookupName || (info === TypeDefInfo.Tuple ? formatType(registry, definitions, def, imports, false) : type), imports);
|
||||
const isGetter = createGetter(definitions, `is${getter}`, 'boolean', imports);
|
||||
|
||||
switch (info) {
|
||||
case TypeDefInfo.Option:
|
||||
@@ -137,8 +137,6 @@ function tsResult (registry: Registry, definitions: Record<string, ModuleTypes>,
|
||||
const [okDef, errorDef] = (def.sub as TypeDef[]);
|
||||
const inner = [
|
||||
tsResultGetter(registry, definitions, def.name, 'Err', errorDef, imports),
|
||||
// @deprecated, use Err
|
||||
tsResultGetter(registry, definitions, def.name, 'Error', errorDef, imports),
|
||||
tsResultGetter(registry, definitions, def.name, 'Ok', okDef, imports)
|
||||
].join('');
|
||||
|
||||
|
||||
@@ -307,14 +307,6 @@ export class Enum implements IEnum {
|
||||
return this.#raw instanceof Null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Checks if the Enum points to a [[Null]] type
|
||||
* @deprecated use isNone
|
||||
*/
|
||||
public get isNull (): boolean {
|
||||
return this.isNone;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The available keys for this enum
|
||||
*/
|
||||
|
||||
@@ -39,9 +39,7 @@ describe('Result', (): void => {
|
||||
const result = new Type(registry, { Err: 'error' });
|
||||
|
||||
expect(result.isErr).toBe(true);
|
||||
expect(result.isError).toBe(true);
|
||||
expect(result.asErr.toString()).toEqual('error');
|
||||
expect(result.asError.toString()).toEqual('error');
|
||||
expect(result.toHex()).toEqual('0x01146572726f72');
|
||||
});
|
||||
|
||||
|
||||
@@ -36,13 +36,6 @@ export class Result<O extends Codec, E extends Codec> extends Enum implements IR
|
||||
return this.value as E;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use asErr
|
||||
*/
|
||||
public get asError (): E {
|
||||
return this.asErr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the wrapper Ok value (if isOk)
|
||||
*/
|
||||
@@ -68,13 +61,6 @@ export class Result<O extends Codec, E extends Codec> extends Enum implements IR
|
||||
return !this.isOk;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use isErr
|
||||
*/
|
||||
public get isError (): boolean {
|
||||
return this.isErr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Checks if the Result wraps an Ok value
|
||||
*/
|
||||
|
||||
@@ -41,10 +41,6 @@ export interface CodeUploadRequest extends Struct {
|
||||
export interface CodeUploadResult extends Result<CodeUploadResultValue, DispatchError> {
|
||||
readonly isErr: boolean;
|
||||
readonly asErr: DispatchError;
|
||||
/** @deprecated Use isErr */
|
||||
readonly isError: boolean;
|
||||
/** @deprecated Use asErr */
|
||||
readonly asError: DispatchError;
|
||||
readonly isOk: boolean;
|
||||
readonly asOk: CodeUploadResultValue;
|
||||
}
|
||||
@@ -92,10 +88,6 @@ export interface ContractExecResultOk extends Struct {
|
||||
export interface ContractExecResultResult extends Result<ContractExecResultOk, DispatchError> {
|
||||
readonly isErr: boolean;
|
||||
readonly asErr: DispatchError;
|
||||
/** @deprecated Use isErr */
|
||||
readonly isError: boolean;
|
||||
/** @deprecated Use asErr */
|
||||
readonly asError: DispatchError;
|
||||
readonly isOk: boolean;
|
||||
readonly asOk: ContractExecResultOk;
|
||||
}
|
||||
@@ -157,8 +149,6 @@ export interface ContractInstantiateResult extends Struct {
|
||||
/** @name ContractInstantiateResultTo267 */
|
||||
export interface ContractInstantiateResultTo267 extends Result<InstantiateReturnValueTo267, Null> {
|
||||
readonly isErr: boolean;
|
||||
/** @deprecated Use isErr */
|
||||
readonly isError: boolean;
|
||||
readonly isOk: boolean;
|
||||
readonly asOk: InstantiateReturnValueTo267;
|
||||
}
|
||||
@@ -166,8 +156,6 @@ export interface ContractInstantiateResultTo267 extends Result<InstantiateReturn
|
||||
/** @name ContractInstantiateResultTo299 */
|
||||
export interface ContractInstantiateResultTo299 extends Result<InstantiateReturnValueOk, Null> {
|
||||
readonly isErr: boolean;
|
||||
/** @deprecated Use isErr */
|
||||
readonly isError: boolean;
|
||||
readonly isOk: boolean;
|
||||
readonly asOk: InstantiateReturnValueOk;
|
||||
}
|
||||
@@ -336,10 +324,6 @@ export interface InstantiateRequestV2 extends Struct {
|
||||
export interface InstantiateReturnValue extends Result<InstantiateReturnValueOk, DispatchError> {
|
||||
readonly isErr: boolean;
|
||||
readonly asErr: DispatchError;
|
||||
/** @deprecated Use isErr */
|
||||
readonly isError: boolean;
|
||||
/** @deprecated Use asErr */
|
||||
readonly asError: DispatchError;
|
||||
readonly isOk: boolean;
|
||||
readonly asOk: InstantiateReturnValueOk;
|
||||
}
|
||||
|
||||
@@ -48,10 +48,6 @@ export interface AccountInfoWithTripleRefCount extends Struct {
|
||||
export interface ApplyExtrinsicResult extends Result<DispatchOutcome, TransactionValidityError> {
|
||||
readonly isErr: boolean;
|
||||
readonly asErr: TransactionValidityError;
|
||||
/** @deprecated Use isErr */
|
||||
readonly isError: boolean;
|
||||
/** @deprecated Use asErr */
|
||||
readonly asError: TransactionValidityError;
|
||||
readonly isOk: boolean;
|
||||
readonly asOk: DispatchOutcome;
|
||||
}
|
||||
@@ -60,10 +56,6 @@ export interface ApplyExtrinsicResult extends Result<DispatchOutcome, Transactio
|
||||
export interface ApplyExtrinsicResultPre6 extends Result<DispatchOutcomePre6, TransactionValidityError> {
|
||||
readonly isErr: boolean;
|
||||
readonly asErr: TransactionValidityError;
|
||||
/** @deprecated Use isErr */
|
||||
readonly isError: boolean;
|
||||
/** @deprecated Use asErr */
|
||||
readonly asError: TransactionValidityError;
|
||||
readonly isOk: boolean;
|
||||
readonly asOk: DispatchOutcomePre6;
|
||||
}
|
||||
@@ -219,10 +211,6 @@ export interface DispatchInfoTo244 extends Struct {
|
||||
export interface DispatchOutcome extends Result<ITuple<[]>, DispatchError> {
|
||||
readonly isErr: boolean;
|
||||
readonly asErr: DispatchError;
|
||||
/** @deprecated Use isErr */
|
||||
readonly isError: boolean;
|
||||
/** @deprecated Use asErr */
|
||||
readonly asError: DispatchError;
|
||||
readonly isOk: boolean;
|
||||
readonly asOk: ITuple<[]>;
|
||||
}
|
||||
@@ -231,10 +219,6 @@ export interface DispatchOutcome extends Result<ITuple<[]>, DispatchError> {
|
||||
export interface DispatchOutcomePre6 extends Result<ITuple<[]>, DispatchErrorPre6> {
|
||||
readonly isErr: boolean;
|
||||
readonly asErr: DispatchErrorPre6;
|
||||
/** @deprecated Use isErr */
|
||||
readonly isError: boolean;
|
||||
/** @deprecated Use asErr */
|
||||
readonly asError: DispatchErrorPre6;
|
||||
readonly isOk: boolean;
|
||||
readonly asOk: ITuple<[]>;
|
||||
}
|
||||
@@ -243,10 +227,6 @@ export interface DispatchOutcomePre6 extends Result<ITuple<[]>, DispatchErrorPre
|
||||
export interface DispatchResult extends Result<ITuple<[]>, DispatchError> {
|
||||
readonly isErr: boolean;
|
||||
readonly asErr: DispatchError;
|
||||
/** @deprecated Use isErr */
|
||||
readonly isError: boolean;
|
||||
/** @deprecated Use asErr */
|
||||
readonly asError: DispatchError;
|
||||
readonly isOk: boolean;
|
||||
readonly asOk: ITuple<[]>;
|
||||
}
|
||||
@@ -258,10 +238,6 @@ export interface DispatchResultOf extends DispatchResult {}
|
||||
export interface DispatchResultTo198 extends Result<ITuple<[]>, Text> {
|
||||
readonly isErr: boolean;
|
||||
readonly asErr: Text;
|
||||
/** @deprecated Use isErr */
|
||||
readonly isError: boolean;
|
||||
/** @deprecated Use asErr */
|
||||
readonly asError: Text;
|
||||
readonly isOk: boolean;
|
||||
readonly asOk: ITuple<[]>;
|
||||
}
|
||||
|
||||
@@ -17,10 +17,6 @@ export interface TransactionSource extends Enum {
|
||||
export interface TransactionValidity extends Result<ValidTransaction, TransactionValidityError> {
|
||||
readonly isErr: boolean;
|
||||
readonly asErr: TransactionValidityError;
|
||||
/** @deprecated Use isErr */
|
||||
readonly isError: boolean;
|
||||
/** @deprecated Use asErr */
|
||||
readonly asError: TransactionValidityError;
|
||||
readonly isOk: boolean;
|
||||
readonly asOk: ValidTransaction;
|
||||
}
|
||||
|
||||
@@ -554,10 +554,6 @@ export interface ResponseV2Error extends ITuple<[u32, XcmErrorV2]> {}
|
||||
export interface ResponseV2Result extends Result<Null, ResponseV2Error> {
|
||||
readonly isErr: boolean;
|
||||
readonly asErr: ResponseV2Error;
|
||||
/** @deprecated Use isErr */
|
||||
readonly isError: boolean;
|
||||
/** @deprecated Use asErr */
|
||||
readonly asError: ResponseV2Error;
|
||||
readonly isOk: boolean;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user