Account Abstraction #3338
-
Hey i was recalling my knowlwdge. so i was understanding the AA contract. And i did not get this two functions. function generatedSignedUserOps(bytes memory callData, Helper.NetworkConfig memory config, address minimalAccount)
public
view
returns (PackedUserOperation memory)
{
uint256 nonce = vm.getNonce(minimalAccount) - 1;
PackedUserOperation memory userOp = _generateUnsignedUserOps(callData, minimalAccount, nonce);
bytes32 userOpHash = IEntryPoint(config.entryPoint).getUserOpHash(userOp);
bytes32 digest = MessageHashUtils.toEthSignedMessageHash(userOpHash);
uint8 v;
bytes32 r;
bytes32 s;
uint256 ANVIL_DEFAULT_KEY = 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80;
if (block.chainid == 31337) {
(v, r, s) = vm.sign(ANVIL_DEFAULT_KEY, digest);
} else {
(v, r, s) = vm.sign(config.account, digest);
}
userOp.signature = abi.encodePacked(r, s, v);
return userOp;
}
function _generateUnsignedUserOps(bytes memory callData, address sender, uint256 nonce)
internal
pure
returns (PackedUserOperation memory)
{
uint128 verificationGasLimit = 16777216;
uint128 callGasLimit = verificationGasLimit;
uint128 maxPriorityFeePerGas = 256;
uint128 maxFeePerGas = maxPriorityFeePerGas;
return PackedUserOperation({
sender: sender,
nonce: nonce,
initCode: hex"",
callData: callData,
accountGasLimits: bytes32(uint256(verificationGasLimit) << 128 | callGasLimit),
preVerificationGas: verificationGasLimit,
gasFees: bytes32(uint256(maxPriorityFeePerGas) << 128 | maxFeePerGas),
paymasterAndData: hex"",
signature: hex""
});
} Can you explain me that what these two function is doing. Also i have a problem, if i am trying to develop code on my own then i am unable to do that. i want to become that master smart contract developer who can develop contract effectively. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Hello @GaurangBharadava, We use Please ask questions if anything is unclear. |
Beta Was this translation helpful? Give feedback.
Hello @GaurangBharadava, We use
generatedSignedUserOps
to generate a signed userOperation struct but then we firstly need to construct an unsigned userOperation before actually signing the unsigned userOperation to get a signed user operation and that is why we needed the_generateUnsignedUserOps
function. So basically we callgeneratedSignedUserOps
to construct a signed userOperation and send it back to us but it need an helper to first construct an unSignedUserOperation so that it can sign it and send it back to us so it delegate the work of creating an unSignedUserOperation to the_generateUnsignedUserOps
function then get the unSignedUserOperation and then sign it and then send us bac…