mirror of
https://github.com/pezkuwichain/pezkuwi-api.git
synced 2026-04-22 11:27:57 +00:00
Rebrand: polkadot → pezkuwi, substrate → bizinikiwi, kusama → dicle
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
// Copyright 2017-2025 @pezkuwi/api-base authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { packageInfo } from './packageInfo.js';
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2025 @pezkuwi/api-base authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './packageDetect.js';
|
||||
|
||||
export * from './bundle.js';
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2017-2025 @pezkuwi/api-base authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './index.js';
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright 2017-2026 @pezkuwi/api-base authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @pezkuwi/dev
|
||||
// (packageInfo imports will be kept as-is, user-editable)
|
||||
|
||||
import { packageInfo as rpcInfo } from '@pezkuwi/rpc-core/packageInfo';
|
||||
import { packageInfo as typesInfo } from '@pezkuwi/types/packageInfo';
|
||||
import { detectPackage } from '@pezkuwi/util';
|
||||
|
||||
import { packageInfo } from './packageInfo.js';
|
||||
|
||||
detectPackage(packageInfo, null, [rpcInfo, typesInfo]);
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2026 @pezkuwi/api-base authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @pezkuwi/dev
|
||||
|
||||
export const packageInfo = { name: '@pezkuwi/api-base', path: 'auto', type: 'auto', version: '16.5.4' };
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright 2017-2025 @pezkuwi/api-base authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { DecoratedRpc, QueryableCalls, QueryableConsts, QueryableStorage, QueryableStorageMulti, SubmittableExtrinsics } from '@pezkuwi/api-base/types';
|
||||
import type { RpcInterface } from '@pezkuwi/rpc-core/types';
|
||||
import type { Metadata } from '@pezkuwi/types';
|
||||
import type { Hash, RuntimeVersion } from '@pezkuwi/types/interfaces';
|
||||
import type { Registry, Signer } from '@pezkuwi/types/types';
|
||||
|
||||
// A smaller interface of ApiRx, used in derive and in SubmittableExtrinsic
|
||||
export interface ApiInterfaceRx {
|
||||
call: QueryableCalls<'rxjs'>;
|
||||
consts: QueryableConsts<'rxjs'>;
|
||||
extrinsicType: number;
|
||||
genesisHash?: Hash | undefined;
|
||||
hasSubscriptions: boolean;
|
||||
registry: Registry;
|
||||
runtimeMetadata: Metadata;
|
||||
runtimeVersion: RuntimeVersion;
|
||||
query: QueryableStorage<'rxjs'>;
|
||||
queryMulti: QueryableStorageMulti<'rxjs'>;
|
||||
rpc: DecoratedRpc<'rxjs', RpcInterface>;
|
||||
tx: SubmittableExtrinsics<'rxjs'>;
|
||||
signer?: Signer | undefined;
|
||||
|
||||
callAt: (blockHash: Uint8Array | string, knownVersion?: RuntimeVersion) => Observable<QueryableCalls<'rxjs'>>;
|
||||
queryAt: (blockHash: Uint8Array | string, knownVersion?: RuntimeVersion) => Observable<QueryableStorage<'rxjs'>>;
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
// Copyright 2017-2025 @pezkuwi/api-base authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { AnyFunction, Callback, Codec } from '@pezkuwi/types/types';
|
||||
|
||||
export type Push<T extends readonly unknown[], V> = [...T, V]
|
||||
|
||||
export type DropLast<T extends readonly unknown[]> = T extends readonly [...infer U, any?] ? U : [...T];
|
||||
|
||||
export type ApiTypes = 'promise' | 'rxjs';
|
||||
|
||||
// Returns the inner type of an Observable
|
||||
export type ObsInnerType<O extends Observable<any>> = O extends Observable<infer U> ? U : never;
|
||||
|
||||
export type VoidFn = () => void;
|
||||
|
||||
export type UnsubscribePromise = Promise<VoidFn>;
|
||||
|
||||
export type PromiseOrObs<ApiType extends ApiTypes, T> =
|
||||
ApiType extends 'rxjs'
|
||||
? Observable<T>
|
||||
: Promise<T>;
|
||||
|
||||
export type MethodResult<ApiType extends ApiTypes, F extends AnyFunction> =
|
||||
ApiType extends 'rxjs'
|
||||
? RxResult<F>
|
||||
: PromiseResult<F>;
|
||||
|
||||
// Here are the return types of these parts of the api:
|
||||
// - api.query.*.*: no exact typings
|
||||
// - api.tx.*.*: SubmittableExtrinsic<ApiType extends ApiTypes>
|
||||
// - api.derive.*.*: MethodResult<ApiType, F>
|
||||
// - api.rpc.*.*: no exact typings (for now, FIXME: should be MethodResult<ApiType, F>, like in derive)
|
||||
|
||||
// These are the types that don't lose type information (used for api.derive.*)
|
||||
// Also use these for api.rpc.* https://github.com/pezkuwichain/pezkuwi-api/issues/1009
|
||||
export interface RxResult<F extends AnyFunction> {
|
||||
(...args: Parameters<F>): Observable<ObsInnerType<ReturnType<F>>>;
|
||||
<T>(...args: Parameters<F>): Observable<T>;
|
||||
}
|
||||
|
||||
export interface PromiseResult<F extends AnyFunction> {
|
||||
(...args: Parameters<F>): Promise<ObsInnerType<ReturnType<F>>>;
|
||||
(...args: Push<Parameters<F>, Callback<ObsInnerType<ReturnType<F>>>>): UnsubscribePromise;
|
||||
<T extends Codec | Codec[]>(...args: Parameters<F>): Promise<T>;
|
||||
<T extends Codec | Codec[]>(...args: Push<Parameters<F>, Callback<T>>): UnsubscribePromise;
|
||||
}
|
||||
|
||||
// In the abstract `decorateMethod` in Base.ts, we can also pass in some meta-
|
||||
// information. This describes it.
|
||||
export interface DecorateMethodOptions {
|
||||
methodName?: string;
|
||||
overrideNoSub?: (...args: unknown[]) => Observable<Codec>;
|
||||
}
|
||||
|
||||
export type DecorateFn <T extends Codec> = (...args: any[]) => Observable<T>;
|
||||
|
||||
export interface PaginationOptions<A = unknown> {
|
||||
args: A[];
|
||||
pageSize: number;
|
||||
startKey?: string;
|
||||
}
|
||||
|
||||
export type DecorateMethod<_ApiType extends ApiTypes, T = any> =
|
||||
<M extends (...args: any[]) => Observable<any>>(method: M, options?: DecorateMethodOptions) => T;
|
||||
|
||||
type AsCodec<R> = R extends Codec
|
||||
? R
|
||||
: Codec;
|
||||
|
||||
export type ReturnCodec<F extends AnyFunction> = AsCodec<ObsInnerType<ReturnType<F>>>;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface EmptyBase<_> {
|
||||
// this is use to allow use to have unused vars in augmented interfaces,
|
||||
// so intentionally left empty
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright 2017-2025 @pezkuwi/api-base authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { AnyFunction, Codec, DefinitionCallNamed } from '@pezkuwi/types/types';
|
||||
import type { ApiTypes, EmptyBase, ReturnCodec } from './base.js';
|
||||
|
||||
export type DecoratedCallBase<ApiType extends ApiTypes, F extends AnyFunction = (...args: any[]) => Observable<Codec>> =
|
||||
ApiType extends 'rxjs'
|
||||
? <T = ReturnCodec<F>> (...args: Parameters<F>) => Observable<T>
|
||||
: <T = ReturnCodec<F>> (...args: Parameters<F>) => Promise<T>;
|
||||
|
||||
export type AugmentedCall<ApiType extends ApiTypes, F extends AnyFunction = (...args: any[]) => Observable<Codec>> = DecoratedCallBase<ApiType, F> & {
|
||||
/** The metadata/description/definition for this method */
|
||||
meta: DefinitionCallNamed
|
||||
};
|
||||
|
||||
// augmented interfaces
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface AugmentedCalls<ApiType extends ApiTypes> extends EmptyBase<ApiType> {
|
||||
// augmented
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style
|
||||
export interface QueryableCalls<ApiType extends ApiTypes> extends AugmentedCalls<ApiType> {
|
||||
// when non-augmented, we need to at least have Codec results
|
||||
[key: string]: QueryableModuleCalls<ApiType>;
|
||||
}
|
||||
|
||||
export type QueryableModuleCalls<ApiType extends ApiTypes> = Record<string, DecoratedCallBase<ApiType>>;
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright 2017-2025 @pezkuwi/api-base authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { PezpalletConstantMetadataLatest } from '@pezkuwi/types/interfaces';
|
||||
import type { Codec } from '@pezkuwi/types/types';
|
||||
import type { ApiTypes, EmptyBase } from './base.js';
|
||||
|
||||
export interface AugmentedConst<_ extends ApiTypes> {
|
||||
meta: PezpalletConstantMetadataLatest;
|
||||
}
|
||||
|
||||
// augmented interfaces
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface AugmentedConsts<ApiType extends ApiTypes> extends EmptyBase<ApiType> {
|
||||
// augmented
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style
|
||||
export interface QueryableConsts<ApiType extends ApiTypes> extends AugmentedConsts<ApiType> {
|
||||
// when non-augmented, we need to at least have Codec results
|
||||
[key: string]: QueryableModuleConsts;
|
||||
}
|
||||
|
||||
export type QueryableModuleConsts = Record<string, Codec>;
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright 2017-2025 @pezkuwi/api-base authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Observable } from 'rxjs';
|
||||
|
||||
type DeriveCreator = (instanceId: string, api: unknown) => (...args: unknown[]) => Observable<any>;
|
||||
|
||||
export type DeriveCustom = Record<string, Record<string, DeriveCreator>>;
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright 2017-2025 @pezkuwi/api-base authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { IsError } from '@pezkuwi/types/metadata/decorate/types';
|
||||
import type { ApiTypes, EmptyBase } from './base.js';
|
||||
|
||||
export type AugmentedError<_ extends ApiTypes> = IsError;
|
||||
|
||||
// augmented interfaces
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface AugmentedErrors<ApiType extends ApiTypes> extends EmptyBase<ApiType> {
|
||||
// augmented
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style
|
||||
export interface DecoratedErrors<ApiType extends ApiTypes> extends AugmentedErrors<ApiType> {
|
||||
// when non-augmented, we need to at least have Codec results
|
||||
[key: string]: ModuleErrors<ApiType>;
|
||||
}
|
||||
|
||||
export type ModuleErrors<ApiType extends ApiTypes> = Record<string, AugmentedError<ApiType>>;
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright 2017-2025 @pezkuwi/api-base authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { IsEvent } from '@pezkuwi/types/metadata/decorate/types';
|
||||
import type { AnyTuple } from '@pezkuwi/types/types';
|
||||
import type { ApiTypes, EmptyBase } from './base.js';
|
||||
|
||||
export type AugmentedEvent<_ extends ApiTypes, T extends AnyTuple = AnyTuple, N = unknown> = IsEvent<T, N>;
|
||||
|
||||
// augmented interfaces
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface AugmentedEvents<ApiType extends ApiTypes> extends EmptyBase<ApiType> {
|
||||
// augmented
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style
|
||||
export interface DecoratedEvents<ApiType extends ApiTypes> extends AugmentedEvents<ApiType> {
|
||||
// when non-augmented, we need to at least have Codec results
|
||||
[key: string]: ModuleEvents<ApiType>;
|
||||
}
|
||||
|
||||
export type ModuleEvents<ApiType extends ApiTypes> = Record<string, AugmentedEvent<ApiType>>;
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright 2017-2025 @pezkuwi/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// These are augmented, do an augmentation export
|
||||
export * from '@pezkuwi/api-base/types/calls';
|
||||
export * from '@pezkuwi/api-base/types/consts';
|
||||
export * from '@pezkuwi/api-base/types/errors';
|
||||
export * from '@pezkuwi/api-base/types/events';
|
||||
export * from '@pezkuwi/api-base/types/storage';
|
||||
export * from '@pezkuwi/api-base/types/submittable';
|
||||
|
||||
// normal exports
|
||||
export * from './api.js';
|
||||
export * from './base.js';
|
||||
export * from './derive.js';
|
||||
export * from './rpc.js';
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright 2017-2025 @pezkuwi/api-base authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { AnyFunction, AnyJson, Callback, DefinitionRpc } from '@pezkuwi/types/types';
|
||||
import type { ApiTypes, PromiseResult, Push, RxResult, UnsubscribePromise } from './base.js';
|
||||
|
||||
export type { AugmentedRpc } from '@pezkuwi/rpc-core/types';
|
||||
|
||||
export interface RxRpcResult<F extends AnyFunction> extends RxResult<F> {
|
||||
raw <T> (...args: Parameters<F>): Observable<T>;
|
||||
meta: DefinitionRpc;
|
||||
}
|
||||
|
||||
export interface PromiseRpcResult<F extends AnyFunction> extends PromiseResult<F> {
|
||||
raw <T> (...args: Parameters<F>): Promise<T>;
|
||||
raw <T> (...args: Push<Parameters<F>, Callback<T>>): UnsubscribePromise;
|
||||
meta: DefinitionRpc;
|
||||
}
|
||||
|
||||
export type RpcMethodResult<ApiType extends ApiTypes, F extends AnyFunction> = ApiType extends 'rxjs'
|
||||
? RxRpcResult<F>
|
||||
: PromiseRpcResult<F>;
|
||||
|
||||
export type DecoratedRpcSection<ApiType extends ApiTypes, Section> = {
|
||||
[M in keyof Section]: Section[M] extends AnyFunction
|
||||
? RpcMethodResult<ApiType, Section[M]>
|
||||
: never
|
||||
}
|
||||
|
||||
export type RawRpcType<ApiType extends ApiTypes> = (method: string, ...params: unknown[]) => ApiType extends 'rxjs' ? Observable<AnyJson> : Promise<AnyJson>;
|
||||
|
||||
export type DecoratedRpc<ApiType extends ApiTypes, AllSections> = {
|
||||
[S in keyof AllSections]: DecoratedRpcSection<ApiType, AllSections[S]>
|
||||
} & RawRpcType<ApiType>
|
||||
@@ -0,0 +1,123 @@
|
||||
// Copyright 2017-2025 @pezkuwi/api-base authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { StorageKey, u64 } from '@pezkuwi/types';
|
||||
import type { Hash } from '@pezkuwi/types/interfaces';
|
||||
import type { StorageEntry } from '@pezkuwi/types/primitive/types';
|
||||
import type { AnyFunction, AnyTuple, Callback, Codec, IStorageKey } from '@pezkuwi/types/types';
|
||||
import type { ApiTypes, DropLast, EmptyBase, MethodResult, PaginationOptions, PromiseOrObs, ReturnCodec, UnsubscribePromise } from './base.js';
|
||||
|
||||
type StorageEntryObservableMulti<R extends Codec = Codec> = <T extends Codec = R>(args: unknown[]) => Observable<T[]>;
|
||||
|
||||
interface StorageEntryPromiseMulti<R extends Codec = Codec> {
|
||||
<T extends Codec = R>(args: unknown[]): Promise<T[]>;
|
||||
<T extends Codec = R>(args: unknown[], callback: Callback<T[]>): UnsubscribePromise;
|
||||
}
|
||||
|
||||
export interface StorageEntryPromiseOverloads {
|
||||
(arg1?: unknown, arg2?: unknown, arg3?: unknown): Promise<Codec>;
|
||||
<T extends Codec>(arg1?: unknown, arg2?: unknown, arg3?: unknown): Promise<T>;
|
||||
<T extends Codec>(callback: Callback<T>): UnsubscribePromise;
|
||||
<T extends Codec>(arg: unknown, callback: Callback<T>): UnsubscribePromise;
|
||||
<T extends Codec>(arg1: unknown, arg2: unknown, callback: Callback<T>): UnsubscribePromise;
|
||||
<T extends Codec>(arg1: unknown, arg2: unknown, arg3: unknown, callback: Callback<T>): UnsubscribePromise;
|
||||
}
|
||||
|
||||
export interface StorageEntryPromiseOverloadsAt {
|
||||
(arg1?: unknown, arg2?: unknown, arg3?: unknown): Promise<Codec>;
|
||||
<T extends Codec>(arg1?: unknown, arg2?: unknown, arg3?: unknown): Promise<T>;
|
||||
}
|
||||
|
||||
// This is the most generic typings we can have for a storage entry function
|
||||
export type GenericStorageEntryFunction = (...args: unknown[]) => Observable<Codec>
|
||||
|
||||
export type QueryableStorageEntry<ApiType extends ApiTypes, A extends AnyTuple = AnyTuple> =
|
||||
ApiType extends 'rxjs'
|
||||
? AugmentedQuery<'rxjs', GenericStorageEntryFunction, A>
|
||||
: AugmentedQuery<'promise', GenericStorageEntryFunction, A> & StorageEntryPromiseOverloads;
|
||||
|
||||
export type QueryableStorageEntryAt<ApiType extends ApiTypes, A extends AnyTuple = AnyTuple> =
|
||||
ApiType extends 'rxjs'
|
||||
? AugmentedQueryAt<'rxjs', GenericStorageEntryFunction, A>
|
||||
: AugmentedQueryAt<'promise', GenericStorageEntryFunction, A> & StorageEntryPromiseOverloadsAt;
|
||||
|
||||
export interface StorageEntryBase<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> extends StorageEntryBaseAt<ApiType, F, A> {
|
||||
/**
|
||||
* @deprecated Use api.at(<blockHash>)
|
||||
*/
|
||||
at: <T = ReturnCodec<F>>(hash: Hash | Uint8Array | string, ...args: Parameters<F>) => PromiseOrObs<ApiType, T>;
|
||||
creator: StorageEntry;
|
||||
/**
|
||||
* @deprecated Use api.at(<blockHash>)
|
||||
*/
|
||||
entriesAt: <T = ReturnCodec<F>, K extends AnyTuple = A>(hash: Hash | Uint8Array | string, ...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
|
||||
/**
|
||||
* @deprecated Use api.at(<blockHash>)
|
||||
*/
|
||||
keysAt: <K extends AnyTuple = A> (hash: Hash | Uint8Array | string, ...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, StorageKey<K>[]>;
|
||||
/**
|
||||
* @deprecated Use api.at(<blockHash>)
|
||||
*/
|
||||
sizeAt: (hash: Hash | Uint8Array | string, ...args: Parameters<F>) => PromiseOrObs<ApiType, u64>;
|
||||
multi: ApiType extends 'rxjs'
|
||||
? StorageEntryObservableMulti<ReturnCodec<F>>
|
||||
: StorageEntryPromiseMulti<ReturnCodec<F>>;
|
||||
}
|
||||
|
||||
export interface StorageEntryBaseAt<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> {
|
||||
entries: <T = ReturnCodec<F>, K extends AnyTuple = A>(...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
|
||||
entriesPaged: <T = ReturnCodec<F>, K extends AnyTuple = A>(opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
|
||||
hash: (...args: Parameters<F>) => PromiseOrObs<ApiType, Hash>;
|
||||
is: (key: IStorageKey<AnyTuple>) => key is IStorageKey<A>;
|
||||
key: (...args: Parameters<F>) => string;
|
||||
keyPrefix: (...args: DropLast<Parameters<F>>) => string;
|
||||
keys: <K extends AnyTuple = A> (...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, StorageKey<K>[]>;
|
||||
keysPaged: <K extends AnyTuple = A> (opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, StorageKey<K>[]>;
|
||||
size: (...args: Parameters<F>) => PromiseOrObs<ApiType, u64>;
|
||||
}
|
||||
|
||||
export type QueryableModuleStorage<ApiType extends ApiTypes> = Record<string, QueryableStorageEntry<ApiType, AnyTuple>>;
|
||||
|
||||
export type QueryableModuleStorageAt<ApiType extends ApiTypes> = Record<string, QueryableStorageEntryAt<ApiType, AnyTuple>>;
|
||||
|
||||
export type QueryableStorageMultiArg<ApiType extends ApiTypes> =
|
||||
QueryableStorageEntry<ApiType> |
|
||||
[QueryableStorageEntry<ApiType>, ...unknown[]];
|
||||
|
||||
export type QueryableStorageMultiBase<ApiType extends ApiTypes> = <T extends Codec[]>(calls: QueryableStorageMultiArg<ApiType>[]) => Observable<T>;
|
||||
|
||||
export interface QueryableStorageMultiPromise<ApiType extends ApiTypes> {
|
||||
<T extends Codec[]>(calls: QueryableStorageMultiArg<ApiType>[], callback: Callback<T>): UnsubscribePromise;
|
||||
<T extends Codec[]>(calls: QueryableStorageMultiArg<ApiType>[]): Promise<T>;
|
||||
}
|
||||
|
||||
export type QueryableStorageMulti<ApiType extends ApiTypes> =
|
||||
ApiType extends 'rxjs'
|
||||
? QueryableStorageMultiBase<ApiType>
|
||||
: QueryableStorageMultiPromise<ApiType>;
|
||||
|
||||
export type AugmentedQuery<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> = MethodResult<ApiType, F> & StorageEntryBase<ApiType, F, A>;
|
||||
|
||||
export type AugmentedQueryAt<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> = MethodResult<ApiType, F> & StorageEntryBaseAt<ApiType, F, A>;
|
||||
|
||||
// backwards compatibility-only
|
||||
export type AugmentedQueryDoubleMap<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> = AugmentedQuery<ApiType, F, A>;
|
||||
|
||||
// augmented interfaces
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface AugmentedQueries<ApiType extends ApiTypes> extends EmptyBase<ApiType> {
|
||||
// augmented
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style
|
||||
export interface QueryableStorage<ApiType extends ApiTypes> extends AugmentedQueries<ApiType> {
|
||||
// when non-augmented, we need to at least have Codec results
|
||||
[key: string]: QueryableModuleStorage<ApiType>;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style
|
||||
export interface QueryableStorageAt<ApiType extends ApiTypes> extends AugmentedQueries<ApiType> {
|
||||
[key: string]: QueryableModuleStorageAt<ApiType>;
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
// Copyright 2017-2025 @pezkuwi/api-base authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { AccountId, Address, ApplyExtrinsicResult, BlockNumber, Call, DispatchError, DispatchInfo, EventRecord, Extrinsic, ExtrinsicStatus, Hash, RuntimeDispatchInfo } from '@pezkuwi/types/interfaces';
|
||||
import type { AnyFunction, AnyNumber, AnyTuple, AnyU8a, Callback, CallBase, Codec, IExtrinsicEra, IKeyringPair, ISubmittableResult, Signer } from '@pezkuwi/types/types';
|
||||
import type { ApiTypes, EmptyBase, PromiseOrObs } from './base.js';
|
||||
|
||||
export type AugmentedSubmittable<T extends AnyFunction, A extends AnyTuple = AnyTuple> = T & CallBase<A>;
|
||||
|
||||
export type AddressOrPair = IKeyringPair | string | AccountId | Address;
|
||||
|
||||
export interface SignerOptions {
|
||||
blockHash: Uint8Array | string;
|
||||
era?: IExtrinsicEra | number;
|
||||
nonce: AnyNumber | Codec;
|
||||
signer?: Signer;
|
||||
tip?: AnyNumber;
|
||||
assetId?: AnyNumber | object;
|
||||
mode?: AnyNumber;
|
||||
metadataHash?: AnyU8a;
|
||||
withSignedTransaction?: boolean;
|
||||
}
|
||||
|
||||
export type SubmittableDryRunResult<ApiType extends ApiTypes> =
|
||||
ApiType extends 'rxjs'
|
||||
? Observable<ApplyExtrinsicResult>
|
||||
: Promise<ApplyExtrinsicResult>;
|
||||
|
||||
export type SubmittableResultResult<ApiType extends ApiTypes, R extends ISubmittableResult = ISubmittableResult> =
|
||||
ApiType extends 'rxjs'
|
||||
? Observable<R>
|
||||
: Promise<Hash>;
|
||||
|
||||
export type SubmittableResultSubscription<ApiType extends ApiTypes, R extends ISubmittableResult = ISubmittableResult> =
|
||||
ApiType extends 'rxjs'
|
||||
? Observable<R>
|
||||
: Promise<() => void>;
|
||||
|
||||
export type SubmittablePaymentResult<ApiType extends ApiTypes> =
|
||||
ApiType extends 'rxjs'
|
||||
? Observable<RuntimeDispatchInfo>
|
||||
: Promise<RuntimeDispatchInfo>;
|
||||
|
||||
export interface SubmittableResultValue {
|
||||
dispatchError?: DispatchError | undefined;
|
||||
dispatchInfo?: DispatchInfo | undefined;
|
||||
events?: EventRecord[];
|
||||
internalError?: Error | undefined;
|
||||
status: ExtrinsicStatus;
|
||||
txHash: Hash;
|
||||
txIndex?: number | undefined;
|
||||
blockNumber?: BlockNumber;
|
||||
}
|
||||
|
||||
export interface SubmittableExtrinsic<ApiType extends ApiTypes, R extends ISubmittableResult = ISubmittableResult> extends Extrinsic {
|
||||
/** true if api.rpc.system.dryRun is available, enabling dryRun(...) */
|
||||
hasDryRun: boolean;
|
||||
/** true if api.call.transactionPaymentApi.queryInfo is available, enabling paymentInfo(...) */
|
||||
hasPaymentInfo: boolean;
|
||||
|
||||
dryRun (account: AddressOrPair, options?: Partial<SignerOptions>): SubmittableDryRunResult<ApiType>;
|
||||
|
||||
paymentInfo (account: AddressOrPair, options?: Partial<SignerOptions>): SubmittablePaymentResult<ApiType>;
|
||||
|
||||
send (): SubmittableResultResult<ApiType>;
|
||||
|
||||
send (statusCb: Callback<R>): SubmittableResultSubscription<ApiType, R>;
|
||||
|
||||
/**
|
||||
* @description Sign the constructed transaction asynchronously.
|
||||
*
|
||||
* The result is a signed extrinsic that is ready to be broadcast to the network via `.send()`, `rpc.author.submitExtrinsic()`, or
|
||||
* any custom submission logic.
|
||||
*/
|
||||
signAsync (account: AddressOrPair, _options?: Partial<SignerOptions>): PromiseOrObs<ApiType, this>;
|
||||
|
||||
/**
|
||||
* @description Sign and broadcast the constructued transaction.
|
||||
*
|
||||
* Note for injected signers:
|
||||
* As of v12.0.1 and up the `SignerResult` return type for `signPayload` allows for the `signedTransaction` field.
|
||||
* This allows the signer to input a signed transaction that will be directly broadcasted. This
|
||||
* bypasses the api adding the signature to the payload. The api will ensure that the Call Data is not changed before it broadcasts the
|
||||
* transaction. This allows for the signer to modify the payload to add things like `mode`, and `metadataHash` for
|
||||
* signedExtensions such as `CheckMetadataHash`.
|
||||
*/
|
||||
signAndSend (account: AddressOrPair, options?: Partial<SignerOptions>): SubmittableResultResult<ApiType, R>;
|
||||
|
||||
signAndSend (account: AddressOrPair, statusCb: Callback<R>): SubmittableResultSubscription<ApiType>;
|
||||
|
||||
signAndSend (account: AddressOrPair, options: Partial<SignerOptions>, statusCb?: Callback<R>): SubmittableResultSubscription<ApiType, R>;
|
||||
|
||||
withResultTransform (transform: (input: ISubmittableResult) => ISubmittableResult): this;
|
||||
}
|
||||
|
||||
export interface SubmittableExtrinsicFunction<ApiType extends ApiTypes, A extends AnyTuple = AnyTuple> extends CallBase<A> {
|
||||
(...params: any[]): SubmittableExtrinsic<ApiType>;
|
||||
}
|
||||
|
||||
// augmented interfaces
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface AugmentedSubmittables<ApiType extends ApiTypes> extends EmptyBase<ApiType> {
|
||||
// augmented
|
||||
}
|
||||
|
||||
export interface SubmittableExtrinsics<ApiType extends ApiTypes> extends AugmentedSubmittables<ApiType> {
|
||||
(extrinsic: Call | Extrinsic | Uint8Array | string): SubmittableExtrinsic<ApiType>;
|
||||
// when non-augmented, we need to at least have Codec results
|
||||
[key: string]: SubmittableModuleExtrinsics<ApiType>;
|
||||
}
|
||||
|
||||
export type SubmittableModuleExtrinsics<ApiType extends ApiTypes> = Record<string, SubmittableExtrinsicFunction<ApiType>>;
|
||||
Reference in New Issue
Block a user