getSignedPaymasterData method
Implementation
Future<String> getSignedPaymasterData(UserOperation userOp) async {
try {
var paymasterAddress = this.paymasterConfig.address;
if (this.paymasterConfig.paymasterType == PaymasterType.Allowlist) {
print("Getting signed allowlist paymaster data");
var paymasterContract =
AllowListPaymaster(contractAddress: paymasterAddress);
var paymasterhash = await paymasterContract.getHash2(
userOp: [
EthereumAddress.fromHex(userOp.sender as String),
BigInt.from(userOp.nonce!),
hex.decode((userOp.initCode as String).substring(2)),
hex.decode((userOp.callData as String).substring(2)),
BigInt.from(userOp.callGasLimit!),
BigInt.from(userOp.verificationGasLimit!),
BigInt.from(userOp.preVerificationGas!),
BigInt.from(userOp.maxFeePerGas!),
BigInt.from(userOp.maxPriorityFeePerGas!),
Uint8List.fromList([]),
hex.decode((userOp.signature as String).substring(2)),
],
);
print("paymaster hash " + hex.encode(paymasterhash[0] as List<int>));
// var acc=
var signedPaymasterData = await fetchSignature(
hex.encode(paymasterhash[0] as List<int>), this.signer, true);
// var signedPaymasterData = await getSignatureFromServer(paymasterhash);
print(signedPaymasterData);
return signedPaymasterData;
}
return "";
} on Exception catch (e) {
print(e);
throw Exception("Could not get signed paymaster data");
}
}