Ejemplo n.º 1
0
 /// <summary>
 /// Generates transaction.
 /// That transaction can be added to a produced block or broadcasted - if <see cref="GeneratedTransaction"/> is used as <see cref="T"/>.
 /// That transaction can be used in <see cref="CallableContract.Call(Nethermind.Core.BlockHeader,string,Nethermind.Core.Transaction)"/> if <see cref="SystemTransaction"/> is used as <see cref="T"/>.
 /// </summary>
 /// <param name="functionName">Function in contract that is called by the transaction.</param>
 /// <param name="sender">Sender of the transaction - caller of the function.</param>
 /// <param name="gasLimit">Gas limit for generated transaction.</param>
 /// <param name="arguments">Arguments to the function.</param>
 /// <typeparam name="T">Type of <see cref="Transaction"/>.</typeparam>
 /// <returns>Transaction.</returns>
 protected Transaction GenerateTransaction <T>(string functionName, Address sender, long gasLimit, params object[] arguments) where T : Transaction, new()
 => GenerateTransaction <T>(ContractAddress, AbiEncoder.Encode(AbiDefinition.GetFunction(functionName).GetCallInfo(), arguments), sender, gasLimit);
Ejemplo n.º 2
0
 protected object[] DecodeReturnData(string functionName, byte[] data)
 {
     return(_abiEncoder.Decode(AbiDefinition.GetFunction(functionName).GetReturnInfo(), data));
 }
Ejemplo n.º 3
0
        protected object[] DecodeReturnData(string functionName, byte[] data)
        {
            AbiEncodingInfo abiEncodingInfo = AbiDefinition.GetFunction(functionName).GetReturnInfo();

            return(DecodeData(abiEncodingInfo, data));
        }
Ejemplo n.º 4
0
 protected LogEntry GetSearchLogEntry(string eventName, byte[] data = null, params Keccak[] topics)
 {
     Keccak[] eventNameTopic = { AbiDefinition.GetEvent(eventName).GetHash() };
     topics = topics.Length == 0 ? eventNameTopic : eventNameTopic.Concat(topics).ToArray();
     return(new LogEntry(ContractAddress, data ?? Array.Empty <byte>(), topics));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates contract
 /// </summary>
 /// <param name="abiEncoder">Binary interface encoder/decoder.</param>
 /// <param name="contractAddress">Address where contract is deployed.</param>
 /// <param name="abiDefinition">Binary definition of contract.</param>
 protected Contract(IAbiEncoder abiEncoder, Address contractAddress, AbiDefinition abiDefinition = null)
 {
     AbiEncoder      = abiEncoder ?? throw new ArgumentNullException(nameof(abiEncoder));
     ContractAddress = contractAddress ?? throw new ArgumentNullException(nameof(contractAddress));
     AbiDefinition   = abiDefinition ?? new AbiDefinitionParser().Parse(GetType());
 }