Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 41 additions & 22 deletions Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -897,28 +897,47 @@ private async Task<byte[]> HashAndSignUserOp(UserOperationV7 userOp, ThirdwebCon
Buffer.BlockCopy(maxPriorityFeePerGasBytes, 0, gasFeesBuffer, 0, 16);
Buffer.BlockCopy(maxFeePerGasBytes, 0, gasFeesBuffer, 16, 16);

var paymasterBytes = userOp.Paymaster.HexToBytes();
var paymasterVerificationGasLimitBytes = userOp.PaymasterVerificationGasLimit.ToHexBigInteger().HexValue.HexToBytes().PadBytes(16);
var paymasterPostOpGasLimitBytes = userOp.PaymasterPostOpGasLimit.ToHexBigInteger().HexValue.HexToBytes().PadBytes(16);
var paymasterDataBytes = userOp.PaymasterData;
var paymasterAndDataBuffer = new byte[20 + 16 + 16 + paymasterDataBytes.Length];
Buffer.BlockCopy(paymasterBytes, 0, paymasterAndDataBuffer, 0, 20);
Buffer.BlockCopy(paymasterVerificationGasLimitBytes, 0, paymasterAndDataBuffer, 20, 16);
Buffer.BlockCopy(paymasterPostOpGasLimitBytes, 0, paymasterAndDataBuffer, 20 + 16, 16);
Buffer.BlockCopy(paymasterDataBytes, 0, paymasterAndDataBuffer, 20 + 16 + 16, paymasterDataBytes.Length);

var packedOp = new PackedUserOperation()
{
Sender = userOp.Sender,
Nonce = userOp.Nonce,
InitCode = initCodeBuffer,
CallData = userOp.CallData,
AccountGasLimits = accountGasLimitsBuffer,
PreVerificationGas = userOp.PreVerificationGas,
GasFees = gasFeesBuffer,
PaymasterAndData = paymasterAndDataBuffer,
Signature = userOp.Signature
};
PackedUserOperation packedOp;
if (userOp.Paymaster is null or Constants.ADDRESS_ZERO or "0x")
{
packedOp = new PackedUserOperation()
{
Sender = userOp.Sender,
Nonce = userOp.Nonce,
InitCode = initCodeBuffer,
CallData = userOp.CallData,
AccountGasLimits = accountGasLimitsBuffer,
PreVerificationGas = userOp.PreVerificationGas,
GasFees = gasFeesBuffer,
PaymasterAndData = Array.Empty<byte>(),
Signature = userOp.Signature
};
}
else
{
var paymasterBytes = userOp.Paymaster.HexToBytes();
var paymasterVerificationGasLimitBytes = userOp.PaymasterVerificationGasLimit.ToHexBigInteger().HexValue.HexToBytes().PadBytes(16);
var paymasterPostOpGasLimitBytes = userOp.PaymasterPostOpGasLimit.ToHexBigInteger().HexValue.HexToBytes().PadBytes(16);
var paymasterDataBytes = userOp.PaymasterData;
var paymasterAndDataBuffer = new byte[20 + 16 + 16 + paymasterDataBytes.Length];
Buffer.BlockCopy(paymasterBytes, 0, paymasterAndDataBuffer, 0, 20);
Buffer.BlockCopy(paymasterVerificationGasLimitBytes, 0, paymasterAndDataBuffer, 20, 16);
Buffer.BlockCopy(paymasterPostOpGasLimitBytes, 0, paymasterAndDataBuffer, 20 + 16, 16);
Buffer.BlockCopy(paymasterDataBytes, 0, paymasterAndDataBuffer, 20 + 16 + 16, paymasterDataBytes.Length);

packedOp = new PackedUserOperation()
{
Sender = userOp.Sender,
Nonce = userOp.Nonce,
InitCode = initCodeBuffer,
CallData = userOp.CallData,
AccountGasLimits = accountGasLimitsBuffer,
PreVerificationGas = userOp.PreVerificationGas,
GasFees = gasFeesBuffer,
PaymasterAndData = paymasterAndDataBuffer,
Signature = userOp.Signature
};
}

var userOpHash = await ThirdwebContract.Read<byte[]>(entryPointContract, "getUserOpHash", packedOp).ConfigureAwait(false);

Expand Down