* Single put_code/deploy (new & backwards compat.) * new-style * old-style deploy? * notice * Cleanups * linting * grrr... Mac case-sensistivity * Add createContract on BluePrint * Adjust contracts check * Adjust * Adjust tests
32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
// Copyright 2017-2021 @polkadot/api authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
|
import type { AnyJson, Registry } from '@polkadot/types/types';
|
|
|
|
import { ApiBase } from '@polkadot/api/base';
|
|
import { assert } from '@polkadot/util';
|
|
|
|
import { Abi } from '../Abi';
|
|
|
|
export abstract class Base<ApiType extends ApiTypes> {
|
|
public readonly abi: Abi;
|
|
|
|
public readonly api: ApiBase<ApiType>;
|
|
|
|
public readonly registry: Registry;
|
|
|
|
protected readonly _decorateMethod: DecorateMethod<ApiType>;
|
|
|
|
constructor (api: ApiBase<ApiType>, abi: AnyJson | Abi, decorateMethod: DecorateMethod<ApiType>) {
|
|
this.abi = abi instanceof Abi
|
|
? abi
|
|
: new Abi(abi, api.registry.getChainProperties());
|
|
this.api = api;
|
|
this.registry = this.abi.registry;
|
|
this._decorateMethod = decorateMethod;
|
|
|
|
assert(api.rx.tx.contracts?.instantiate, 'You need to connect to a node with the contracts module, the metadata does not enable api.tx.contracts on this instance');
|
|
}
|
|
}
|