import * as mockInterface from "./mock-interface";
import * as biconomyInterface from "./biconomy-interface";
export async function getNonce(args) {
    const isMock = args.forwarderAbi === mockInterface.abi;
    const data = isMock
        ? mockInterface.encodeGetNonce(args.user)
        : biconomyInterface.encodeGetNonce(args.user, args.batchId || "0");
    const result = await args.web3Lib.call({
        to: args.contractAddress,
        data
    });
    const nonceResult = isMock
        ? mockInterface.decodeGetNonce(result)
        : biconomyInterface.decodeGetNonce(result);
    const [nonce] = nonceResult;
    return String(nonce);
}
export async function verifyEIP712(args) {
    const isMock = args.forwarderAbi === mockInterface.abi;
    if (isMock) {
        // TODO: call mockForwarder.verify(request, signature)
        return true;
    }
    const data = biconomyInterface.encodeVerifyEIP712(args.request, args.domainSeparator, args.signature);
    try {
        await args.web3Lib.call({
            to: args.contractAddress,
            data
        });
        return true;
    }
    catch (e) {
        return false;
    }
}
//# sourceMappingURL=handler.js.map