Support ABI files with wasm (.contract output) (#2841)
* Support ABI files with wasm (.contract output) * AbiBase exports * Additional default exports * Remove any * Fix build
This commit is contained in:
@@ -24,10 +24,10 @@ import { unwrapStorageType } from '@polkadot/types/primitive/StorageKey';
|
||||
import { assert, compactStripLength, logger, u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { createSubmittable } from '../submittable';
|
||||
import augmentObject from '../util/augmentObject';
|
||||
import { augmentObject } from '../util/augmentObject';
|
||||
import { decorateSections, DeriveAllSections } from '../util/decorate';
|
||||
import { extractStorageArgs } from '../util/validate';
|
||||
import Events from './Events';
|
||||
import { Events } from './Events';
|
||||
|
||||
interface MetaDecoration {
|
||||
callIndex?: Uint8Array;
|
||||
@@ -44,7 +44,7 @@ const l = logger('api/init');
|
||||
|
||||
let instanceCounter = 0;
|
||||
|
||||
export default abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
readonly #instanceId: string;
|
||||
|
||||
#registry: Registry;
|
||||
|
||||
@@ -5,7 +5,7 @@ import { ApiInterfaceEvents } from '../types';
|
||||
|
||||
import EventEmitter from 'eventemitter3';
|
||||
|
||||
export default class Events {
|
||||
export class Events {
|
||||
#eventemitter = new EventEmitter();
|
||||
|
||||
protected emit (type: ApiInterfaceEvents, ...args: any[]): boolean {
|
||||
|
||||
@@ -9,7 +9,7 @@ import { Metadata } from '@polkadot/metadata';
|
||||
import { Text } from '@polkadot/types';
|
||||
import { assertReturn } from '@polkadot/util';
|
||||
|
||||
import Init from './Init';
|
||||
import { Init } from './Init';
|
||||
|
||||
interface PkgJson {
|
||||
name: string;
|
||||
@@ -30,7 +30,7 @@ function assertResult<T> (value: T | undefined): T {
|
||||
return assertReturn(value, 'Api needs to be initialized before using, listen on \'ready\'');
|
||||
}
|
||||
|
||||
export default abstract class Getters<ApiType extends ApiTypes> extends Init<ApiType> {
|
||||
export abstract class Getters<ApiType extends ApiTypes> extends Init<ApiType> {
|
||||
/**
|
||||
* @description Contains the parameter types (constants) of all modules.
|
||||
*
|
||||
|
||||
@@ -17,14 +17,14 @@ import { getSpecAlias, getSpecTypes, getUpgradeVersion } from '@polkadot/types-k
|
||||
import { BN_ZERO, assert, logger, u8aEq, u8aToU8a } from '@polkadot/util';
|
||||
import { cryptoWaitReady } from '@polkadot/util-crypto';
|
||||
|
||||
import Decorate from './Decorate';
|
||||
import { Decorate } from './Decorate';
|
||||
|
||||
const KEEPALIVE_INTERVAL = 15000;
|
||||
const DEFAULT_BLOCKNUMBER = { unwrap: () => BN_ZERO };
|
||||
|
||||
const l = logger('api/init');
|
||||
|
||||
export default abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
#healthTimer: NodeJS.Timeout | null = null;
|
||||
|
||||
#registries: VersionedRegistry[] = [];
|
||||
|
||||
@@ -6,7 +6,7 @@ import { ApiOptions, ApiTypes, DecorateMethod, Signer } from '../types';
|
||||
|
||||
import { assert, isString, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import Getters from './Getters';
|
||||
import { Getters } from './Getters';
|
||||
|
||||
interface KeyringSigner {
|
||||
sign (message: Uint8Array): Uint8Array;
|
||||
@@ -16,7 +16,7 @@ interface SignerRawOptions {
|
||||
signer?: Signer;
|
||||
}
|
||||
|
||||
export default abstract class ApiBase<ApiType extends ApiTypes> extends Getters<ApiType> {
|
||||
export abstract class ApiBase<ApiType extends ApiTypes> extends Getters<ApiType> {
|
||||
/**
|
||||
* @description Create an instance of the class
|
||||
*
|
||||
|
||||
@@ -8,7 +8,7 @@ import { EMPTY, Observable, Subscription } from 'rxjs';
|
||||
import { catchError, tap } from 'rxjs/operators';
|
||||
import { isFunction, assert } from '@polkadot/util';
|
||||
|
||||
import ApiBase from '../base';
|
||||
import { ApiBase } from '../base';
|
||||
import { Combinator, CombinatorCallback, CombinatorFunction } from './Combinator';
|
||||
|
||||
interface Tracker<T> {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { ApiOptions, DecorateFn } from '../types';
|
||||
|
||||
import { from, Observable } from 'rxjs';
|
||||
|
||||
import ApiBase from '../base';
|
||||
import { ApiBase } from '../base';
|
||||
|
||||
export function decorateMethod <Method extends DecorateFn<Codec>> (method: Method): Method {
|
||||
return method;
|
||||
|
||||
@@ -13,7 +13,7 @@ import { first, map, mapTo, mergeMap, switchMap, tap } from 'rxjs/operators';
|
||||
import { assert, isBn, isFunction, isNumber, isString, isU8a } from '@polkadot/util';
|
||||
|
||||
import { filterEvents, isKeyringPair } from '../util';
|
||||
import ApiBase from '../base';
|
||||
import { ApiBase } from '../base';
|
||||
import { SubmittableResult } from './Result';
|
||||
|
||||
interface SubmittableOptions<ApiType extends ApiTypes> {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { Call, Extrinsic } from '@polkadot/types/interfaces';
|
||||
import { ApiInterfaceRx, ApiTypes } from '../types';
|
||||
import { SubmittableExtrinsic } from './types';
|
||||
|
||||
import ApiBase from '../base';
|
||||
import { ApiBase } from '../base';
|
||||
import { createClass } from './createClass';
|
||||
|
||||
type Creator<ApiType extends ApiTypes> = (extrinsic: Call | Uint8Array | string) => SubmittableExtrinsic<ApiType>;
|
||||
|
||||
@@ -13,14 +13,14 @@ import { Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
import { DefinitionRpc, DefinitionRpcSub, Signer, SignatureOptions, Registry, RegisteredTypes } from '@polkadot/types/types';
|
||||
|
||||
import { DeriveAllSections } from '../util/decorate';
|
||||
import ApiBase from '../base';
|
||||
import { ApiBase } from '../base';
|
||||
import { QueryableConsts } from './consts';
|
||||
import { DecoratedRpc } from './rpc';
|
||||
import { QueryableStorage, QueryableStorageMulti } from './storage';
|
||||
import { SubmittableExtrinsics } from './submittable';
|
||||
|
||||
export { Signer, SignerResult } from '@polkadot/types/types';
|
||||
export { default as ApiBase } from '../base';
|
||||
export { ApiBase } from '../base';
|
||||
export * from '../submittable/types';
|
||||
export * from './base';
|
||||
export * from './consts';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import augmentObject from './augmentObject';
|
||||
import { augmentObject } from './augmentObject';
|
||||
|
||||
describe('augmentObject', (): void => {
|
||||
let spy: any;
|
||||
|
||||
@@ -73,7 +73,7 @@ function extractMethods (src: Record<string, Record<string, any>>, dst: Record<s
|
||||
* already available, but rather just adds new missing ites into the result object.
|
||||
* @internal
|
||||
*/
|
||||
export default function augmentObject (prefix: string | null, src: Record<string, Record<string, unknown>>, dst: Record<string, Record<string, unknown>>, fromEmpty = false): Record<string, Record<string, any>> {
|
||||
export function augmentObject (prefix: string | null, src: Record<string, Record<string, unknown>>, dst: Record<string, Record<string, unknown>>, fromEmpty = false): Record<string, Record<string, any>> {
|
||||
if (fromEmpty) {
|
||||
Object.keys(dst).forEach((key): void => {
|
||||
delete dst[key];
|
||||
|
||||
Reference in New Issue
Block a user