"use strict";
// Copyright 2017-2020 @polkadot/api authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
Object.defineProperty(exports, "__esModule", { value: true });
class SubmittableResult {
    constructor({ events, status }) {
        this.events = events || [];
        this.status = status;
    }
    get isCompleted() {
        return this.isError || this.isFinalized;
    }
    get isError() {
        return this.status.isDropped || this.status.isInvalid || this.status.isUsurped;
    }
    get isFinalized() {
        return this.status.isFinalized;
    }
    /**
     * @description Filters EventRecords for the specified method & section (there could be multiple)
     */
    filterRecords(section, method) {
        return this.events.filter(({ event }) => event.section === section && event.method === method);
    }
    /**
     * @description Finds an EventRecord for the specified method & section
     */
    findRecord(section, method) {
        return this.events.find(({ event }) => event.section === section && event.method === method);
    }
}
exports.default = SubmittableResult;
