@dgpub/prime-sdk
Version:
Etherspot Prime (Account Abstraction) SDK
47 lines (46 loc) • 2.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getVerifyingPaymaster = exports.BiconomyPaymasterAPI = void 0;
const ethers_1 = require("ethers");
const calcPreVerificationGas_1 = require("./calcPreVerificationGas");
const PaymasterAPI_1 = require("./PaymasterAPI");
const paymaster_1 = require("@biconomy/paymaster");
const DUMMY_PAYMASTER_AND_DATA = '0x0101010101010101010101010101010101010101000000000000000000000000000000000000000000000000000001010101010100000000000000000000000000000000000000000000000000000000000000000101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101';
class BiconomyPaymasterAPI extends PaymasterAPI_1.PaymasterAPI {
constructor(paymasterUrl, paymasterServiceData) {
super();
this.paymasterUrl = paymasterUrl;
this.paymasterServiceData = paymasterServiceData;
}
async getPaymasterAndData(userOp) {
var _a;
try {
await ethers_1.ethers.utils.resolveProperties(userOp);
}
catch (_) { }
const pmOp = {
sender: userOp.sender,
nonce: userOp.nonce,
initCode: userOp.initCode,
callData: userOp.callData,
callGasLimit: userOp.callGasLimit,
verificationGasLimit: userOp.verificationGasLimit,
maxFeePerGas: userOp.maxFeePerGas,
maxPriorityFeePerGas: userOp.maxPriorityFeePerGas,
paymasterAndData: DUMMY_PAYMASTER_AND_DATA,
signature: (_a = userOp.signature) !== null && _a !== void 0 ? _a : '0x',
};
const op = await ethers_1.ethers.utils.resolveProperties(pmOp);
op.preVerificationGas = (0, calcPreVerificationGas_1.calcPreVerificationGas)(op);
const biconomyPaymaster = await (0, paymaster_1.createPaymaster)({
paymasterUrl: this.paymasterUrl,
});
const paymasterAndDataResponse = await biconomyPaymaster.getPaymasterAndData(op, this.paymasterServiceData);
return {
result: Object.assign({}, paymasterAndDataResponse),
};
}
}
exports.BiconomyPaymasterAPI = BiconomyPaymasterAPI;
const getVerifyingPaymaster = (paymasterUrl, paymasterServiceData) => new BiconomyPaymasterAPI(paymasterUrl, paymasterServiceData);
exports.getVerifyingPaymaster = getVerifyingPaymaster;