import AbstractApiProvider from './abstract-api-provider.js';
import '../../../utils/types/array.js';
import 'crypto';
import { withExtendedPrototypeProperties, ensureInstanceOf } from '../../../utils/inheritance.js';
import 'bs58';
import 'multiformats/bases/base58';
import 'varint';
import '../../../utils/encoding/ss-58.js';
import '../../../utils/types/object.js';
import '../../../utils/types/iterable.js';
import '../../../utils/types/set.js';
import 'blake2b';
import '../../../utils/types/bytes.js';
import '../../../utils/interfaces.js';
import '../../../utils/assert.js';
import '../../../utils/error.js';
import '../../../utils/types/string.js';

class AbstractBaseModule {
  constructor(apiProvider) {
    if (apiProvider != null) {
      this.apiProvider = ensureInstanceOf(apiProvider, AbstractApiProvider);
    }
  }

  /**
   * Signs and sends provided extrinsic.
   *
   * @param {*} extrinsic
   * @param {*} params
   * @returns {Promise<*>}
   */
  async signAndSend(extrinsic, params) {
    if (this.apiProvider == null) {
      throw new Error(
        `Can't sign transaction because \`${this.constructor.name}\` doesn't have an associated \`apiProvider\``,
      );
    }

    return await this.apiProvider.signAndSend(extrinsic, params);
  }
}

/**
 * Base module class that must be extended by all modules.
 */
var AbstractBaseModule$1 = withExtendedPrototypeProperties(['methods'], AbstractBaseModule);

export { AbstractBaseModule$1 as default };
//# sourceMappingURL=abstract-base-module.js.map
