Example #1
0
        public void Encode(RlpStream stream, UserOperationWithEntryPoint?opWithEntryPoint, RlpBehaviors rlpBehaviors = RlpBehaviors.None)
        {
            if (opWithEntryPoint is null)
            {
                stream.EncodeNullObject();
                return;
            }

            int contentLength = GetContentLength(opWithEntryPoint);

            UserOperation op         = opWithEntryPoint.UserOperation;
            Address       entryPoint = opWithEntryPoint.EntryPoint;

            stream.StartSequence(contentLength);

            stream.Encode(op.Sender);
            stream.Encode(op.Nonce);
            stream.Encode(op.InitCode);
            stream.Encode(op.CallData);
            stream.Encode(op.CallGas);
            stream.Encode(op.VerificationGas);
            stream.Encode(op.PreVerificationGas);
            stream.Encode(op.MaxFeePerGas);
            stream.Encode(op.MaxPriorityFeePerGas);
            stream.Encode(op.Paymaster);
            stream.Encode(op.PaymasterData);
            stream.Encode(op.Signature);
            stream.Encode(entryPoint);
        }
Example #2
0
        public byte[] Pack(UserOperation op)
        {
            UserOperationAbi abi = op.Abi;

            abi.Signature = Bytes.Empty;
            byte[] encodedBytes = _abiEncoder.Encode(AbiEncodingStyle.None, _opSignature, abi);
            byte[] slicedBytes  = encodedBytes.Slice(32, encodedBytes.Length - 64);
            return(slicedBytes);
        }
 public UserOperationRpc(UserOperation userOperation)
 {
     Sender               = userOperation.Sender;
     Nonce                = userOperation.Nonce;
     CallData             = userOperation.CallData;
     InitCode             = userOperation.InitCode;
     CallGas              = userOperation.CallGas;
     VerificationGas      = userOperation.VerificationGas;
     PreVerificationGas   = userOperation.PreVerificationGas;
     MaxFeePerGas         = userOperation.MaxFeePerGas;
     MaxPriorityFeePerGas = userOperation.MaxPriorityFeePerGas;
     Paymaster            = userOperation.Paymaster;
     Signature            = userOperation.Signature;
     PaymasterData        = userOperation.PaymasterData;
 }
Example #4
0
        private static int GetContentLength(UserOperationWithEntryPoint opWithEntryPoint)
        {
            UserOperation op         = opWithEntryPoint.UserOperation;
            Address       entryPoint = opWithEntryPoint.EntryPoint;

            return(Rlp.LengthOf(op.Sender)
                   + Rlp.LengthOf(op.Nonce)
                   + Rlp.LengthOf(op.InitCode)
                   + Rlp.LengthOf(op.CallData)
                   + Rlp.LengthOf(op.CallGas)
                   + Rlp.LengthOf(op.VerificationGas)
                   + Rlp.LengthOf(op.PreVerificationGas)
                   + Rlp.LengthOf(op.MaxFeePerGas)
                   + Rlp.LengthOf(op.MaxPriorityFeePerGas)
                   + Rlp.LengthOf(op.Paymaster)
                   + Rlp.LengthOf(op.PaymasterData)
                   + Rlp.LengthOf(op.Signature)
                   + Rlp.LengthOf(entryPoint));
        }