UNPKG

@biconomy/abstractjs

Version:

SDK for Biconomy integration with support for account abstraction, smart accounts, ERC-4337.

61 lines 2.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getPermitQuote = void 0; const resolveInstructions_1 = require("../../../account/utils/resolveInstructions.js"); const getFusionQuote_1 = require("./getFusionQuote.js"); const getQuote_1 = require("./getQuote.js"); const getPermitQuote = async (client, parameters) => { const { account: account_ = client.account, trigger, cleanUps, instructions, batch = true, gasLimit, ...rest } = parameters; if (trigger.call) { throw new Error("Custom call trigger is not supported for permit quotes"); } const owner = account_.signer.address; const spender = account_.addressOn(trigger.chainId, true); const recipient = trigger.recipientAddress || spender; const resolvedInstructions = await (0, resolveInstructions_1.resolveInstructions)(instructions); const { triggerGasLimit, triggerAmount, batchedInstructions } = await (0, getFusionQuote_1.prepareInstructions)(client, { resolvedInstructions, trigger, owner, spender, recipient, account: account_, batch }); const eoa = account_.signer.address; const triggerInfo = { tokenAddress: trigger.tokenAddress, chainId: trigger.chainId, gasLimit: triggerGasLimit, amount: triggerAmount, ...(trigger.approvalAmount ? { approvalAmount: trigger.approvalAmount } : {}), ...(trigger.recipientAddress ? { recipientAddress: trigger.recipientAddress } : {}) }; const quote = await (0, getQuote_1.getQuote)(client, { path: "quote-permit", eoa, batch, instructions: batchedInstructions, gasLimit: gasLimit || triggerGasLimit, ...(cleanUps ? { cleanUps } : {}), ...rest }, "permit", triggerInfo); let fees = trigger.useMaxAvailableFunds ? 0n : BigInt(quote.paymentInfo.tokenWeiAmount); if (rest.sponsorship) { fees = 0n; } triggerInfo.amount += fees; return { quote, trigger: triggerInfo }; }; exports.getPermitQuote = getPermitQuote; exports.default = exports.getPermitQuote; //# sourceMappingURL=getPermitQuote.js.map