import { providers } from "ethers";
import { bnZero } from "../../utils/BigNumberUtils";
/**
 * @notice Class used to test GasPriceOracle which makes ethers provider calls to the following implemented
 * methods.
 */
export class MockedProvider extends providers.StaticJsonRpcProvider {
    stdLastBaseFeePerGas;
    stdMaxPriorityFeePerGas;
    defaultChainId;
    transactions = {};
    constructor(stdLastBaseFeePerGas, stdMaxPriorityFeePerGas, defaultChainId = 1) {
        super(undefined, defaultChainId);
        this.stdLastBaseFeePerGas = stdLastBaseFeePerGas;
        this.stdMaxPriorityFeePerGas = stdMaxPriorityFeePerGas;
        this.defaultChainId = defaultChainId;
    }
    getBlock(_blockHashOrBlockTag) {
        const mockBlock = {
            transactions: [],
            hash: "0x",
            parentHash: "0x",
            number: 0,
            nonce: "0",
            difficulty: 0,
            _difficulty: bnZero,
            timestamp: 0,
            gasLimit: bnZero,
            gasUsed: bnZero,
            baseFeePerGas: this.stdLastBaseFeePerGas,
            miner: "0x",
            extraData: "0x",
        };
        return Promise.resolve(mockBlock);
    }
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    send(method, _params) {
        switch (method) {
            case "eth_maxPriorityFeePerGas":
                return Promise.resolve(this.stdMaxPriorityFeePerGas);
            default:
                throw new Error(`MockedProvider#Unimplemented method: ${method}`);
        }
    }
    getFeeData() {
        return Promise.resolve({
            lastBaseFeePerGas: this.stdLastBaseFeePerGas,
            maxPriorityFeePerGas: this.stdMaxPriorityFeePerGas,
            // Following fields unused in GasPrice oracle
            maxFeePerGas: null,
            gasPrice: null,
        });
    }
    getTransaction(hash) {
        return Promise.resolve(this.transactions[hash]);
    }
    getGasPrice() {
        return Promise.resolve(this.stdLastBaseFeePerGas.add(this.stdMaxPriorityFeePerGas));
    }
    getNetwork() {
        return Promise.resolve({
            name: "mocknetwork",
            chainId: this.defaultChainId,
        });
    }
    _setTransaction(hash, transaction) {
        this.transactions[hash] = transaction;
    }
}
//# sourceMappingURL=mockEthersProvider.js.map