コード例 #1
0
        private Function <TContractMessage> GetFunction(string contractAddress)
        {
            var contract = Eth.GetContract <TContractMessage>(contractAddress);
            var function = contract.GetFunction <TContractMessage>();

            return(function);
        }
コード例 #2
0
        public Task <HexBigInteger> EstimateGasAsync(TContractMessage functionMessage, string contractAddress)
        {
            ValidateContractMessage(functionMessage);
            var contract = Eth.GetContract <TContractMessage>(contractAddress);
            var function = contract.GetFunction <TContractMessage>();

            return(EstimateGasAsync(functionMessage, function));
        }
コード例 #3
0
        public async Task <string> SendRequestAsync(TContractMessage functionMessage, string contractAddress)
        {
            ValidateContractMessage(functionMessage);
            var contract = Eth.GetContract <TContractMessage>(contractAddress);
            var function = contract.GetFunction <TContractMessage>();

            var gasEstimate = await GetOrEstimateMaximumGas(functionMessage, function).ConfigureAwait(false);

            return(await ExecuteTransactionAsync(functionMessage, gasEstimate, function).ConfigureAwait(false));
        }
コード例 #4
0
        public async Task <TransactionReceipt> SendRequestAndWaitForReceiptAsync(TContractMessage functionMessage, string contractAddress, CancellationTokenSource tokenSource = null)
        {
            ValidateContractMessage(functionMessage);
            var contract = Eth.GetContract <TContractMessage>(contractAddress);
            var function = contract.GetFunction <TContractMessage>();

            var gasEstimate = await GetOrEstimateMaximumGas(functionMessage, function).ConfigureAwait(false);

            return(await ExecuteTransactionAsync(functionMessage, gasEstimate, function, tokenSource));
        }
コード例 #5
0
        public async Task <TFunctionOutput> QueryAsync <TFunctionOutput>(TContractMessage contractFunctionMessage, string contractAddress,
                                                                         BlockParameter block = null)

        {
            var contract = Eth.GetContract <TContractMessage>(contractAddress);
            var function = contract.GetFunction <TContractMessage>();

            ValidateContractMessage(contractFunctionMessage);
            return(await function.CallAsync <TFunctionOutput>(contractFunctionMessage, contractFunctionMessage.FromAddress,
                                                              GetMaximumGas(contractFunctionMessage), GetValue(contractFunctionMessage), block).ConfigureAwait(false));
        }
コード例 #6
0
        public async Task <TFunctionOutput> QueryDeserializingToObjectAsync <TFunctionOutput>(
            TContractMessage contractFunctionMessage, string contractAddress,
            BlockParameter block = null) where TFunctionOutput : new()

        {
            var contract = Eth.GetContract <TContractMessage>(contractAddress);
            var function = contract.GetFunction <TContractMessage>();

            ValidateContractMessage(contractFunctionMessage);
            return(await function.CallDeserializingToObjectAsync <TFunctionOutput>(contractFunctionMessage,
                                                                                   GetDefaultAddressFrom(contractFunctionMessage),
                                                                                   GetMaximumGas(contractFunctionMessage), GetValue(contractFunctionMessage), block).ConfigureAwait(false));
        }
コード例 #7
0
        public async Task <byte[]> QueryRawAsync(TContractMessage contractFunctionMessage,
                                                 string contractAddress,
                                                 BlockParameter block = null)

        {
            var contract = Eth.GetContract <TContractMessage>(contractAddress);
            var function = contract.GetFunction <TContractMessage>();

            ValidateContractMessage(contractFunctionMessage);
            return(await function.CallRawAsync(contractFunctionMessage,
                                               GetDefaultAddressFrom(contractFunctionMessage),
                                               GetMaximumGas(contractFunctionMessage), GetValue(contractFunctionMessage), block).ConfigureAwait(false));
        }
コード例 #8
0
        public async Task <TransactionInput> CreateTransactionInputAsync(TContractMessage functionMessage,
                                                                         string contractAddress)
        {
            ValidateContractMessage(functionMessage);
            var contract = Eth.GetContract <TContractMessage>(contractAddress);
            var function = contract.GetFunction <TContractMessage>();

            var gasEstimate = await GetOrEstimateMaximumGas(functionMessage, function).ConfigureAwait(false);

            return(function.CreateTransactionInput(
                       functionMessage,
                       GetDefaultAddressFrom(functionMessage),
                       gasEstimate,
                       GetGasPrice(functionMessage),
                       GetValue(functionMessage)));
        }
コード例 #9
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Eth != null)
         {
             hashCode = hashCode * 59 + Eth.GetHashCode();
         }
         if (Btc != null)
         {
             hashCode = hashCode * 59 + Btc.GetHashCode();
         }
         return(hashCode);
     }
 }
コード例 #10
0
        /// <summary>
        /// Returns true if Portfolio instances are equal
        /// </summary>
        /// <param name="other">Instance of Portfolio to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Portfolio other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Eth == other.Eth ||
                     Eth != null &&
                     Eth.Equals(other.Eth)
                     ) &&
                 (
                     Btc == other.Btc ||
                     Btc != null &&
                     Btc.Equals(other.Btc)
                 ));
        }