@vechain/vebetterdao-contracts
Version:
Open-source repository that houses the smart contracts powering the decentralized VeBetterDAO on the VeChain Thor blockchain.
26 lines (25 loc) • 924 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.catchOutOfGas = exports.catchRevert = void 0;
const chai_1 = require("chai");
const hardhat_1 = require("hardhat");
async function tryCatch(promise, reason) {
try {
const tx = await promise;
await tx.wait();
throw null;
}
catch (error) {
(0, chai_1.assert)(error, "Expected an error but did not get one");
(0, chai_1.assert)(error.message.includes(reason), `Expected an ${reason} error`);
}
}
const revertReason = hardhat_1.network.name === "hardhat" ? "VM Exception while processing transaction" : "execution reverted";
const catchRevert = async function (promise) {
await tryCatch(promise, revertReason);
};
exports.catchRevert = catchRevert;
const catchOutOfGas = async function (promise) {
await tryCatch(promise, "out of gas");
};
exports.catchOutOfGas = catchOutOfGas;