* Bump dev

* type linting

* linting

* linting

* missed
This commit is contained in:
Jaco Greeff
2020-09-03 15:47:29 +02:00
committed by GitHub
parent 5a48a2a3f7
commit 6ae75ba92e
33 changed files with 756 additions and 658 deletions
@@ -17,6 +17,7 @@ import Abi from '../Abi';
import Contract from './Contract';
import { BaseWithTx } from './util';
// eslint-disable-next-line no-use-before-define
type BlueprintCreateResultSubscription<ApiType extends ApiTypes> = Observable<BlueprintCreateResult<ApiType>>;
export interface BlueprintCreate<ApiType extends ApiTypes> {
+1
View File
@@ -17,6 +17,7 @@ import Abi from '../Abi';
import Blueprint from './Blueprint';
import { BaseWithTx } from './util';
// eslint-disable-next-line no-use-before-define
type CodePutCodeResultSubscription<ApiType extends ApiTypes> = Observable<CodePutCodeResult<ApiType>>;
export interface CodePutCode<ApiType extends ApiTypes> {
@@ -18,7 +18,9 @@ import { BaseWithTxAndRpcCall } from './util';
type ContractCallTypes = 'tx' | 'rpc';
type ContractCallResultSubscription<ApiType extends ApiTypes, CallType extends ContractCallTypes> = ApiType extends 'rxjs'
// eslint-disable-next-line no-use-before-define
? Observable<ContractCallResult<CallType>>
// eslint-disable-next-line no-use-before-define
: Promise<ObsInnerType<ContractCallResult<CallType>>>;
export interface ContractCall<ApiType extends ApiTypes, CallType extends ContractCallTypes> {
+4
View File
@@ -4,11 +4,15 @@
import { ApiTypes, DecorateMethod } from '@polkadot/api/types';
import { AccountId, Address, ContractExecResult } from '@polkadot/types/interfaces';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Codec, CodecArg } from '@polkadot/types/types';
import { MetaRegistryJson, StringIndex, TypeIndex, TypeDef } from '@polkadot/types/create/types';
import { ApiPromise, ApiRx } from '@polkadot/api';
// I give up, too hard to untangle atm... and is basically deprecated
/* eslint-disable no-use-before-define */
export type ApiObject<ApiType extends ApiTypes> = ApiType extends 'rxjs'
? ApiRx
: ApiPromise;
+7 -7
View File
@@ -17,13 +17,6 @@ export interface DeriveDemocracyLock {
vote: Vote;
}
export interface DeriveDispatch {
at: BlockNumber;
index: ReferendumIndex;
imageHash: Hash;
image?: DeriveProposalImage;
}
export interface DeriveProposalImage {
at: BlockNumber;
balance: Balance;
@@ -31,6 +24,13 @@ export interface DeriveProposalImage {
proposer: AccountId;
}
export interface DeriveDispatch {
at: BlockNumber;
index: ReferendumIndex;
imageHash: Hash;
image?: DeriveProposalImage;
}
export interface DeriveProposal {
balance?: Balance;
index: PropIndex;
+27 -27
View File
@@ -40,6 +40,17 @@ export interface DeriveStakerPoints {
points: RewardPoint;
}
export interface DeriveOwnExposure {
clipped: Exposure;
era: EraIndex;
exposure: Exposure;
}
export interface DeriveEraExposureNominating {
validatorId: string;
validatorIndex: number;
}
export type DeriveEraNominatorExposure = Record<string, DeriveEraExposureNominating[]>;
export type DeriveEraValidatorExposure = Record<string, Exposure>;
@@ -50,19 +61,6 @@ export interface DeriveEraExposure {
validators: DeriveEraValidatorExposure;
}
export interface DeriveOwnExposure {
clipped: Exposure;
era: EraIndex;
exposure: Exposure;
}
export type DeriveOwnSlashes = DeriveStakerSlashes;
export interface DeriveEraExposureNominating {
validatorId: string;
validatorIndex: number;
}
export interface DeriveStakerExposure {
era: EraIndex;
isEmpty: boolean;
@@ -91,15 +89,7 @@ export interface DeriveStakerSlashes {
total: Balance;
}
export interface DeriveStakingElected {
nextElected: AccountId[];
info: DeriveStakingQuery[];
}
export interface DeriveStakingWaiting {
info: DeriveStakingQuery[];
waiting: AccountId[];
}
export type DeriveOwnSlashes = DeriveStakerSlashes;
export interface DeriveStakingValidators {
nextElected: AccountId[];
@@ -124,6 +114,21 @@ export interface DeriveStakingQuery extends DeriveStakingStash {
stakingLedger?: StakingLedger;
}
export interface DeriveStakingElected {
nextElected: AccountId[];
info: DeriveStakingQuery[];
}
export interface DeriveStakingWaiting {
info: DeriveStakingQuery[];
waiting: AccountId[];
}
export interface DeriveUnlocking {
remainingEras: BN;
value: Balance;
}
export interface DeriveStakingAccount extends DeriveStakingQuery {
redeemable?: Balance;
unlocking?: DeriveUnlocking[];
@@ -133,8 +138,3 @@ export interface DeriveStakingOverview extends DeriveSessionIndexes {
nextElected: AccountId[];
validators: AccountId[];
}
export type DeriveUnlocking = {
remainingEras: BN;
value: Balance;
};
+1 -1
View File
@@ -37,7 +37,7 @@
"@polkadot/util": "^3.4.1",
"@polkadot/util-crypto": "^3.4.1",
"bn.js": "^5.1.3",
"eventemitter3": "^4.0.6",
"eventemitter3": "^4.0.7",
"rxjs": "^6.6.2"
},
"devDependencies": {
+4
View File
@@ -3,10 +3,12 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import type { Observable } from 'rxjs';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { AnyFunction, Callback, Codec, CodecArg } from '@polkadot/types/types';
// Prepend an element V onto the beginning of a tuple T.
// Cons<1, [2,3,4]> is [1,2,3,4]
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export type Cons<V, T extends any[]> = ((v: V, ...t: T) => void) extends ((...r: infer R) => void)
? R
: never;
@@ -56,6 +58,7 @@ 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>;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
<T extends Codec | Codec[]>(...args: Push<Parameters<F>, Callback<T>>): UnsubscribePromise;
}
@@ -79,4 +82,5 @@ export interface PaginationOptions<ArgType = CodecArg> {
startKey?: string;
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export type DecorateMethod<ApiType extends ApiTypes> = <Method extends (...args: any[]) => Observable<any>>(method: Method, options?: DecorateMethodOptions) => any;
+2 -1
View File
@@ -9,9 +9,10 @@ import { Codec } from '@polkadot/types/types';
import { ApiTypes } from './base';
// import { ApiTypes, PromiseOrObs } from './base';
// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-interface,@typescript-eslint/no-unused-vars
export interface AugmentedConsts<ApiType extends ApiTypes> { }
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export interface AugmentedConst<ApiType extends ApiTypes> {
// at: (hash: Hash | Uint8Array | string) => PromiseOrObs<ApiType, T>;
meta: ModuleConstantMetadataLatest;
+2
View File
@@ -2,10 +2,12 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { AnyFunction, Callback, Codec } from '@polkadot/types/types';
import { Observable } from 'rxjs';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { ApiTypes, Push, PromiseResult, RxResult, UnsubscribePromise } from './base';
export interface RpcRxResult<F extends AnyFunction> extends RxResult<F> {
+36 -34
View File
@@ -10,40 +10,6 @@ import StorageKey, { StorageEntry } from '@polkadot/types/primitive/StorageKey';
import { ApiTypes, MethodResult, ObsInnerType, PaginationOptions, PromiseOrObs, UnsubscribePromise } from './base';
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface AugmentedQueries<ApiType extends ApiTypes> { }
export type AugmentedQuery<ApiType extends ApiTypes, F extends AnyFunction> = MethodResult<ApiType, F> & StorageEntryBase<ApiType, F>
export type AugmentedQueryDoubleMap<ApiType extends ApiTypes, F extends AnyFunction> = MethodResult<ApiType, F> & StorageEntryDoubleMap<ApiType, F>
// This is the most generic typings we can have for a storage entry function
type GenericStorageEntryFunction = (arg1?: CodecArg, arg2?: CodecArg) => Observable<Codec>
export type QueryableStorageEntry<ApiType extends ApiTypes> =
ApiType extends 'rxjs'
? AugmentedQuery<'rxjs', GenericStorageEntryFunction>
: AugmentedQuery<'promise', GenericStorageEntryFunction> & StorageEntryPromiseOverloads;
export interface StorageEntryBase<ApiType extends ApiTypes, F extends AnyFunction> {
at: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(hash: Hash | Uint8Array | string, ...args: Parameters<F>) => PromiseOrObs<ApiType, T>;
creator: StorageEntry;
entries: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(arg?: Parameters<F>[0]) => PromiseOrObs<ApiType, [StorageKey, T][]>;
entriesPaged: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, [StorageKey, T][]>;
hash: (...args: Parameters<F>) => PromiseOrObs<ApiType, Hash>;
key: (...args: Parameters<F>) => string;
keyPrefix: () => string;
keys: (arg?: any) => PromiseOrObs<ApiType, StorageKey[]>;
keysPaged: (opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, StorageKey[]>;
range: <T extends Codec | any = ObsInnerType<ReturnType<F>>>([from, to]: [Hash | Uint8Array | string, Hash | Uint8Array | string | undefined] | [Hash | Uint8Array | string], ...args: Parameters<F>) => PromiseOrObs<ApiType, [Hash, T][]>;
size: (...args: Parameters<F>) => PromiseOrObs<ApiType, u64>;
multi: ApiType extends 'rxjs' ? StorageEntryObservableMulti : StorageEntryPromiseMulti;
}
export interface StorageEntryDoubleMap<ApiType extends ApiTypes, F extends AnyFunction> extends StorageEntryBase<ApiType, F> {
keyPrefix: (key1?: Parameters<F>[0]) => string;
}
interface StorageEntryObservableMulti {
<T extends Codec>(args: (CodecArg[] | CodecArg)[]): Observable<T[]>;
}
@@ -61,6 +27,31 @@ export interface StorageEntryPromiseOverloads {
<T extends Codec>(arg1: CodecArg, arg2: CodecArg, callback: Callback<T>): UnsubscribePromise;
}
// This is the most generic typings we can have for a storage entry function
type GenericStorageEntryFunction = (arg1?: CodecArg, arg2?: CodecArg) => Observable<Codec>
export type QueryableStorageEntry<ApiType extends ApiTypes> =
ApiType extends 'rxjs'
// eslint-disable-next-line no-use-before-define
? AugmentedQuery<'rxjs', GenericStorageEntryFunction>
// eslint-disable-next-line no-use-before-define
: AugmentedQuery<'promise', GenericStorageEntryFunction> & StorageEntryPromiseOverloads;
export interface StorageEntryBase<ApiType extends ApiTypes, F extends AnyFunction> {
at: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(hash: Hash | Uint8Array | string, ...args: Parameters<F>) => PromiseOrObs<ApiType, T>;
creator: StorageEntry;
entries: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(arg?: Parameters<F>[0]) => PromiseOrObs<ApiType, [StorageKey, T][]>;
entriesPaged: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, [StorageKey, T][]>;
hash: (...args: Parameters<F>) => PromiseOrObs<ApiType, Hash>;
key: (...args: Parameters<F>) => string;
keyPrefix: () => string;
keys: (arg?: any) => PromiseOrObs<ApiType, StorageKey[]>;
keysPaged: (opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, StorageKey[]>;
range: <T extends Codec | any = ObsInnerType<ReturnType<F>>>([from, to]: [Hash | Uint8Array | string, Hash | Uint8Array | string | undefined] | [Hash | Uint8Array | string], ...args: Parameters<F>) => PromiseOrObs<ApiType, [Hash, T][]>;
size: (...args: Parameters<F>) => PromiseOrObs<ApiType, u64>;
multi: ApiType extends 'rxjs' ? StorageEntryObservableMulti : StorageEntryPromiseMulti;
}
export interface QueryableModuleStorage<ApiType extends ApiTypes> {
[index: string]: QueryableStorageEntry<ApiType>;
}
@@ -82,3 +73,14 @@ export type QueryableStorageMulti<ApiType extends ApiTypes> =
ApiType extends 'rxjs'
? QueryableStorageMultiBase<ApiType>
: QueryableStorageMultiPromise<ApiType>;
// eslint-disable-next-line @typescript-eslint/no-empty-interface,@typescript-eslint/no-unused-vars
export interface AugmentedQueries<ApiType extends ApiTypes> { }
export interface StorageEntryDoubleMap<ApiType extends ApiTypes, F extends AnyFunction> extends StorageEntryBase<ApiType, F> {
keyPrefix: (key1?: Parameters<F>[0]) => string;
}
export type AugmentedQuery<ApiType extends ApiTypes, F extends AnyFunction> = MethodResult<ApiType, F> & StorageEntryBase<ApiType, F>
export type AugmentedQueryDoubleMap<ApiType extends ApiTypes, F extends AnyFunction> = MethodResult<ApiType, F> & StorageEntryDoubleMap<ApiType, F>
+1 -1
View File
@@ -7,7 +7,7 @@ import { AnyFunction, CallBase } from '@polkadot/types/types';
import { SubmittableExtrinsic } from '../submittable/types';
import { ApiTypes } from './base';
// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-interface,@typescript-eslint/no-unused-vars
export interface AugmentedSubmittables<ApiType extends ApiTypes> { }
export type AugmentedSubmittable<T extends AnyFunction> = T & CallBase;
@@ -1,4 +1,3 @@
// Copyright 2017-2020 @polkadot/metadata authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
+2 -2
View File
@@ -32,9 +32,9 @@
"@polkadot/util": "^3.4.1",
"@polkadot/util-crypto": "^3.4.1",
"bn.js": "^5.1.3",
"eventemitter3": "^4.0.6",
"eventemitter3": "^4.0.7",
"isomorphic-fetch": "^2.2.1",
"websocket": "^1.0.31"
"websocket": "^1.0.32"
},
"devDependencies": {
"@polkadot/keyring": "^3.4.1",
+3 -3
View File
@@ -33,8 +33,8 @@
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/typegen#readme",
"dependencies": {
"@babel/core": "^7.11.4",
"@babel/register": "^7.10.5",
"@babel/core": "^7.11.5",
"@babel/register": "^7.11.5",
"@babel/runtime": "^7.11.2",
"@polkadot/api": "1.32.0-beta.15",
"@polkadot/metadata": "1.32.0-beta.15",
@@ -42,7 +42,7 @@
"@polkadot/types": "1.32.0-beta.15",
"@polkadot/util": "^3.4.1",
"handlebars": "^4.7.6",
"websocket": "^1.0.31",
"websocket": "^1.0.32",
"yargs": "^15.4.1"
},
"devDependencies": {
-2
View File
@@ -102,8 +102,6 @@ function decodeStruct <T> (registry: Registry, Types: ConstructorDef, value: unk
export default class Struct<
// The actual Class structure, i.e. key -> Class
S extends TypesDef = TypesDef,
// internal type, instance of classes mapped by key
T extends { [K in keyof S]: Codec } = { [K in keyof S]: Codec },
// input values, mapped by key can be anything (construction)
V extends { [K in keyof S]: any } = { [K in keyof S]: any },
// type names, mapped by key, name of Class in S
+2 -3
View File
@@ -1,14 +1,13 @@
// Copyright 2017-2020 @polkadot/types authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
/* eslint-disable @typescript-eslint/no-use-before-define */
type Mapper = (value: string, options?: SanitizeOptions) => string;
interface SanitizeOptions {
allowNamespaces?: boolean;
}
type Mapper = (value: string, options?: SanitizeOptions) => string;
const ALLOWED_BOXES = ['BTreeMap', 'BTreeSet', 'Compact', 'DoNotConstruct', 'HashMap', 'Int', 'Linkage', 'Result', 'Option', 'UInt', 'Vec'];
const BOX_PRECEDING = ['<', '(', '[', '"', ',', ' ']; // start of vec, tuple, fixed array, part of struct def or in tuple
+5 -5
View File
@@ -108,6 +108,11 @@ export interface MetaTypeDefEnumVariantTupleStruct {
'tuple_struct_variant.types': TypeIndex[];
}
export interface MetaTypeDefStructField {
name: StringIndex;
type: TypeIndex;
}
export interface MetaTypeDefEnumVariantStruct {
'struct_variant.name': StringIndex;
'struct_variant.fields': MetaTypeDefStructField[];
@@ -119,11 +124,6 @@ export interface MetaTypeDefEnum {
'enum.variants': MetaTypeDefEnumVariant[];
}
export interface MetaTypeDefStructField {
name: StringIndex;
type: TypeIndex;
}
export type MetaTypeDefUnionField = MetaTypeDefStructField;
export interface MetaTypeDefStruct {
@@ -12,6 +12,7 @@ import Base from '../codec/Base';
import AccountIndex from '../generic/AccountIndex';
import EthereumAccountId from './AccountId';
// eslint-disable-next-line no-use-before-define
type AnyAddress = BN | LookupSource | EthereumAccountId | AccountIndex | number[] | Uint8Array | number | string;
export const ACCOUNT_ID_PREFIX = new Uint8Array([0xff]);
+1
View File
@@ -13,6 +13,7 @@ import U8aFixed from '../codec/U8aFixed';
interface DecodeMethodInput {
args: unknown;
// eslint-disable-next-line no-use-before-define
callIndex: CallIndex | Uint8Array;
}
@@ -12,6 +12,7 @@ import Base from '../codec/Base';
import AccountId from './AccountId';
import AccountIndex from './AccountIndex';
// eslint-disable-next-line no-use-before-define
type AnyAddress = BN | LookupSource | AccountId | AccountIndex | number[] | Uint8Array | number | string;
export const ACCOUNT_ID_PREFIX = new Uint8Array([0xff]);
@@ -1,4 +1,3 @@
// Copyright 2017-2020 @polkadot/types authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
+16 -15
View File
@@ -8,23 +8,8 @@ import { Registry } from './registry';
import BN from 'bn.js';
export type ArgsDef = Record<string, Constructor>;
// We cannot inline this into CodecArg, TS thrws up when building docs
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface CodecArgArray extends Array<CodecArg> {}
export type CodecArg = Codec | BN | boolean | string | Uint8Array | boolean | number | string | undefined | CodecArgArray | { [index: string]: CodecArg };
export type CodecTo = 'toHex' | 'toJSON' | 'toString' | 'toU8a';
export interface Constructor<T = Codec> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
new(registry: Registry, ...value: any[]): T;
}
export type ConstructorDef<T = Codec> = Record<string, Constructor<T>>;
/**
* @name Codec
* @description
@@ -89,3 +74,19 @@ export interface Codec {
*/
toU8a (isBare?: BareOpts): Uint8Array;
}
// eslint-disable-next-line no-use-before-define
export type CodecArg = Codec | BN | boolean | string | Uint8Array | boolean | number | string | undefined | CodecArgArray | { [index: string]: CodecArg };
// We cannot inline this into CodecArg, TS throws up when building docs
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface CodecArgArray extends Array<CodecArg> {}
export interface Constructor<T = Codec> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
new(registry: Registry, ...value: any[]): T;
}
export type ConstructorDef<T = Codec> = Record<string, Constructor<T>>;
export type ArgsDef = Record<string, Constructor>;
+90 -90
View File
@@ -24,96 +24,6 @@ export interface ISubmittableResult {
toHuman (isExtended?: boolean): AnyJson;
}
export interface SignerResult {
/**
* @description The id for this request
*/
id: number;
/**
* @description The resulting signature in hex
*/
signature: string;
}
export interface Signer {
/**
* @description signs an extrinsic payload from a serialized form
*/
signPayload?: (payload: SignerPayloadJSON) => Promise<SignerResult>;
/**
* @description signs a raw payload, only the bytes data as supplied
*/
signRaw?: (raw: SignerPayloadRaw) => Promise<SignerResult>;
/**
* @description Receives an update for the extrinsic signed by a `signer.sign`
*/
update?: (id: number, status: H256 | ISubmittableResult) => void;
}
export interface SignatureOptions {
blockHash: AnyU8a;
era?: IExtrinsicEra;
genesisHash: AnyU8a;
nonce: AnyNumber;
runtimeVersion: IRuntimeVersion;
signedExtensions?: string[];
signer?: Signer;
tip?: AnyNumber;
}
interface ExtrinsicSignatureBase {
readonly isSigned: boolean;
readonly era: IExtrinsicEra;
readonly nonce: ICompact<Index>;
readonly signature: EcdsaSignature | Ed25519Signature | Sr25519Signature;
readonly signer: Address;
readonly tip: ICompact<Balance>;
}
export interface ExtrinsicPayloadValue {
blockHash: AnyU8a;
era: AnyU8a | IExtrinsicEra;
genesisHash: AnyU8a;
method: AnyU8a | IMethod;
nonce: AnyNumber;
specVersion: AnyNumber;
tip: AnyNumber;
transactionVersion: AnyNumber;
}
export interface IExtrinsicSignature extends ExtrinsicSignatureBase, Codec {
addSignature (signer: Address | Uint8Array | string, signature: Uint8Array | string, payload: Uint8Array | string): IExtrinsicSignature;
sign (method: Call, account: IKeyringPair, options: SignatureOptions): IExtrinsicSignature;
signFake (method: Call, address: Address | Uint8Array | string, options: SignatureOptions): IExtrinsicSignature;
}
export interface IExtrinsicEra extends Codec {
asImmortalEra: Codec;
asMortalEra: Codec;
}
interface IExtrinsicSignable<T> {
addSignature (signer: Address | Uint8Array | string, signature: Uint8Array | string, payload: ExtrinsicPayloadValue | Uint8Array | string): T;
sign (account: IKeyringPair, options: SignatureOptions): T;
signFake (address: Address | Uint8Array | string, options: SignatureOptions): T;
}
export interface IExtrinsicImpl extends IExtrinsicSignable<IExtrinsicImpl>, Codec {
readonly method: Call;
readonly signature: IExtrinsicSignature;
readonly version: number;
}
export interface IExtrinsic extends IExtrinsicSignable<IExtrinsic>, ExtrinsicSignatureBase, IMethod {
readonly length: number;
readonly method: Call;
readonly type: number;
readonly version: number;
}
export interface SignerPayloadJSON {
/**
* @description The ss-58 encoded address
@@ -204,3 +114,93 @@ export interface ISignerPayload {
toPayload (): SignerPayloadJSON;
toRaw (): SignerPayloadRaw;
}
export interface SignerResult {
/**
* @description The id for this request
*/
id: number;
/**
* @description The resulting signature in hex
*/
signature: string;
}
export interface Signer {
/**
* @description signs an extrinsic payload from a serialized form
*/
signPayload?: (payload: SignerPayloadJSON) => Promise<SignerResult>;
/**
* @description signs a raw payload, only the bytes data as supplied
*/
signRaw?: (raw: SignerPayloadRaw) => Promise<SignerResult>;
/**
* @description Receives an update for the extrinsic signed by a `signer.sign`
*/
update?: (id: number, status: H256 | ISubmittableResult) => void;
}
export interface IExtrinsicEra extends Codec {
asImmortalEra: Codec;
asMortalEra: Codec;
}
export interface SignatureOptions {
blockHash: AnyU8a;
era?: IExtrinsicEra;
genesisHash: AnyU8a;
nonce: AnyNumber;
runtimeVersion: IRuntimeVersion;
signedExtensions?: string[];
signer?: Signer;
tip?: AnyNumber;
}
interface ExtrinsicSignatureBase {
readonly isSigned: boolean;
readonly era: IExtrinsicEra;
readonly nonce: ICompact<Index>;
readonly signature: EcdsaSignature | Ed25519Signature | Sr25519Signature;
readonly signer: Address;
readonly tip: ICompact<Balance>;
}
export interface ExtrinsicPayloadValue {
blockHash: AnyU8a;
era: AnyU8a | IExtrinsicEra;
genesisHash: AnyU8a;
method: AnyU8a | IMethod;
nonce: AnyNumber;
specVersion: AnyNumber;
tip: AnyNumber;
transactionVersion: AnyNumber;
}
export interface IExtrinsicSignature extends ExtrinsicSignatureBase, Codec {
addSignature (signer: Address | Uint8Array | string, signature: Uint8Array | string, payload: Uint8Array | string): IExtrinsicSignature;
sign (method: Call, account: IKeyringPair, options: SignatureOptions): IExtrinsicSignature;
signFake (method: Call, address: Address | Uint8Array | string, options: SignatureOptions): IExtrinsicSignature;
}
interface IExtrinsicSignable<T> {
addSignature (signer: Address | Uint8Array | string, signature: Uint8Array | string, payload: ExtrinsicPayloadValue | Uint8Array | string): T;
sign (account: IKeyringPair, options: SignatureOptions): T;
signFake (address: Address | Uint8Array | string, options: SignatureOptions): T;
}
export interface IExtrinsicImpl extends IExtrinsicSignable<IExtrinsicImpl>, Codec {
readonly method: Call;
readonly signature: IExtrinsicSignature;
readonly version: number;
}
export interface IExtrinsic extends IExtrinsicSignable<IExtrinsic>, ExtrinsicSignatureBase, IMethod {
readonly length: number;
readonly method: Call;
readonly type: number;
readonly version: number;
}
+3 -2
View File
@@ -10,11 +10,12 @@ import BN from 'bn.js';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type AnyFunction = (...args: any[]) => any;
// eslint-disable-next-line no-use-before-define
export type AnyJson = string | number | boolean | null | undefined | AnyJsonArray | { [index: string]: AnyJson };
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface AnyJsonArray extends Array<AnyJson> {}
export type AnyJson = string | number | boolean | null | undefined | AnyJsonArray | { [index: string]: AnyJson };
export type AnyNumber = BN | BigInt | Uint8Array | number | string;
export type AnyString = string | string;
+18 -18
View File
@@ -13,11 +13,6 @@ import { AnyJson } from './helpers';
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface InterfaceTypes { }
export interface OverrideVersionedType {
minmax: [number?, number?]; // min (v >= min) and max (v <= max)
types: RegistryTypes;
}
export interface ChainUpgradeVersion {
blockNumber: BN;
specVersion: BN;
@@ -28,19 +23,6 @@ export interface ChainUpgrades {
versions: ChainUpgradeVersion[];
}
export type OverrideModuleType = Record<string, string>;
export interface OverrideBundleDefinition {
alias?: Record<string, OverrideModuleType>;
rpc?: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>;
types?: OverrideVersionedType[];
}
export interface OverrideBundleType {
chain?: Record<string, OverrideBundleDefinition>;
spec?: Record<string, OverrideBundleDefinition>;
}
export type RegistryTypes = Record<string, Constructor | string | Record<string, string> | { _enum: string[] | Record<string, string | null> } | { _set: Record<string, number> }>;
export interface RegistryMetadataText extends String, Codec {
@@ -109,6 +91,24 @@ export interface RegistryMetadata {
asLatest: RegistryMetadataLatest;
}
export interface OverrideVersionedType {
minmax: [number?, number?]; // min (v >= min) and max (v <= max)
types: RegistryTypes;
}
export type OverrideModuleType = Record<string, string>;
export interface OverrideBundleDefinition {
alias?: Record<string, OverrideModuleType>;
rpc?: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>;
types?: OverrideVersionedType[];
}
export interface OverrideBundleType {
chain?: Record<string, OverrideBundleDefinition>;
spec?: Record<string, OverrideBundleDefinition>;
}
export interface RegisteredTypes {
/**
* @description Additional types used by runtime modules. This is necessary if the runtime modules