"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.printEvents = exports.delay = void 0;
function delay(ms) {
    return new Promise((resolve) => setTimeout(resolve, ms));
}
exports.delay = delay;
function printEvents(api, testType, events) {
    console.log(`\n${testType} events:`);
    let foundErrorEvent = false;
    events.forEach(({ event }) => {
        event.data.forEach((eventData) => {
            if (eventData.isModule) {
                try {
                    const parsedEventData = eventData;
                    const decoded = api.registry.findMetaError(parsedEventData.asModule);
                    const { docs: documentation, name, section } = decoded;
                    if (documentation) {
                        console.log(`\t${section}.${name}: ${documentation.join(" ")}`);
                    }
                    else {
                        console.log(`\t${section}.${name}`);
                    }
                    foundErrorEvent = true;
                }
                catch (err) {
                    console.log("\tCould not find transaction failure details.");
                }
            }
        });
    });
    if (!foundErrorEvent) {
        events.forEach(({ phase, event: { data, method, section } }) => {
            console.log(`\t' ${phase}: ${section}.${method}:: ${data}`);
        });
    }
}
exports.printEvents = printEvents;
//# sourceMappingURL=helpers.js.map