import hre from "hardhat";
/**
 * Minimal replacement for hardhat-deploy's createFixture.
 * Runs the setup function once, takes an evm_snapshot, and restores it on subsequent calls.
 */
export function createFixture(setup) {
    let result;
    let snapshotId;
    return async () => {
        if (snapshotId !== undefined) {
            const reverted = await hre.network.provider.send("evm_revert", [snapshotId]);
            if (reverted) {
                // evm_revert consumes the snapshot, so take a fresh one for the next call.
                snapshotId = (await hre.network.provider.send("evm_snapshot", []));
                return result;
            }
            // Snapshot was invalidated (e.g. another fixture reverted past it). Re-run setup.
        }
        result = await setup();
        snapshotId = (await hre.network.provider.send("evm_snapshot", []));
        return result;
    };
}
//# sourceMappingURL=utils.js.map