verifyingPaymaster function

UserOperationMiddlewareFn verifyingPaymaster(
  1. String paymasterRpc,
  2. Map<String, dynamic> context
)

Implementation

UserOperationMiddlewareFn verifyingPaymaster(
  String paymasterRpc,
  Map<String, dynamic> context,
) {
  return (ctx) async {
    ctx.op.verificationGasLimit = ctx.op.verificationGasLimit * BigInt.from(3);

    final provider = BundlerJsonRpcProvider(paymasterRpc, Client());
    final rpcResponse = await provider.call(
      'pm_sponsorUserOperation',
      [ctx.op.opToJson(), ctx.entryPoint.toString(), context],
    );

    final pm = VerifyingPaymasterResult.fromJson(
      rpcResponse.result as Map<String, dynamic>,
    );

    ctx.op.paymasterAndData = pm.paymasterAndData;
    ctx.op.preVerificationGas = BigInt.parse(pm.preVerificationGas);
    ctx.op.verificationGasLimit = BigInt.parse(pm.verificationGasLimit);
    ctx.op.callGasLimit = BigInt.parse(pm.callGasLimit);
  };
}