Ejemplo n.º 1
0
        /// <summary>
        /// Executes a new message call immediately without creating a transaction on the block chain.
        /// </summary>
        public async Task <TReturn> Call(CallParams callParams = null, DefaultBlockParameter blockParameter = null)
        {
            var callResult = await CallRaw(callParams, blockParameter);

            var result = ParseReturnData(callResult);

            return(result);
        }
Ejemplo n.º 2
0
        public async Task <UInt256> EstimateGas(CallParams callParams = null, DefaultBlockParameter blockParameter = null)
        {
            callParams      = _contract.GetCallParams(callParams);
            callParams.Data = _callData;
            blockParameter  = blockParameter ?? BlockParameterType.Latest;
            var result = await _contract.JsonRpcClient.EstimateGas(callParams, blockParameter);

            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Executes a new message call immediately without creating a transaction on the block chain.
        /// Returns the raw ABI encoded response.
        /// </summary>
        public async Task <byte[]> CallRaw(CallParams callParams = null, DefaultBlockParameter blockParameter = null)
        {
            callParams      = _contract.GetCallParams(callParams);
            callParams.Data = _callData;
            blockParameter  = blockParameter ?? BlockParameterType.Latest;

            byte[] callResult;

            try
            {
                callResult = await _contract.JsonRpcClient.Call(callParams, blockParameter);
            }
            catch (JsonRpcErrorException rpcEx) when(_contract.JsonRpcClient.ErrorFormatter != null)
            {
                var formattedException = await _contract.JsonRpcClient.ErrorFormatter(_contract.JsonRpcClient, rpcEx.Error);

                throw formattedException;
            }

            return(callResult);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Executes a new message call immediately without creating a transaction on the block chain and expects a revert.
        /// Throws an exception if call does not revert.
        /// </summary>
        public async Task ExpectRevertCall(CallParams callParams = null, DefaultBlockParameter blockParameter = null)
        {
            callParams             = _contract.GetCallParams(callParams);
            callParams.Data        = _callData;
            blockParameter         = blockParameter ?? BlockParameterType.Latest;
            var(error, callResult) = await _contract.JsonRpcClient.TryCall(callParams, blockParameter, expectingException : true);

            if (error == null)
            {
                // Check if call is void (no return value)
                if (this is EthFunc)
                {
                    throw new Exception("Expected call to revert");
                }
                else
                {
                    var result = ParseReturnData(callResult);
                    throw new Exception($"Expected call to revert but got back result: {result}");
                }
            }
        }
Ejemplo n.º 5
0
 public virtual Task <ulong> GetBlockTransactionCountByNumber(DefaultBlockParameter blockParameter)
 {
     return(_proxyClient.GetBlockTransactionCountByNumber(blockParameter));
 }
Ejemplo n.º 6
0
 public virtual Task <Block> GetBlockByNumber(bool getFullTransactionObjects, DefaultBlockParameter blockParameter)
 {
     return(_proxyClient.GetBlockByNumber(getFullTransactionObjects, blockParameter));
 }
Ejemplo n.º 7
0
 public Task <ulong> GetTransactionCount(Address address, DefaultBlockParameter blockParameter)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 8
0
 public virtual Task <UInt256> EstimateGas(CallParams callParams, DefaultBlockParameter blockParameter)
 {
     return(_proxyClient.EstimateGas(callParams, blockParameter));
 }
Ejemplo n.º 9
0
 public virtual Task <UInt256> GetBalance(Address account, DefaultBlockParameter blockParameter)
 {
     return(_proxyClient.GetBalance(account, blockParameter));
 }
Ejemplo n.º 10
0
 public virtual Task <ulong> GetTransactionCount(Address address, DefaultBlockParameter blockParameter)
 {
     return(_proxyClient.GetTransactionCount(address, blockParameter));
 }
Ejemplo n.º 11
0
 public virtual Task <byte[]> Call(CallParams callParams, DefaultBlockParameter blockParameter)
 {
     return(_proxyClient.Call(callParams, blockParameter));
 }
Ejemplo n.º 12
0
 public Task <byte[]> Call(CallParams ethCallParam, DefaultBlockParameter blockParameter)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 13
0
        public Task <UInt256> GetBalance(Address account, DefaultBlockParameter blockParameter)
        {
            var balance = _accounts[account];

            return(Task.FromResult(balance));
        }
Ejemplo n.º 14
0
 public Task <byte[]> GetCode(Address address, DefaultBlockParameter blockParameter)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 15
0
 public Task <ulong> GetBlockTransactionCountByNumber(DefaultBlockParameter blockParameter)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 16
0
 public Task <Block> GetBlockByNumber(DefaultBlockParameter blockParameter, bool getFullTransactionObjects)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 17
0
 public Task <UInt256> GetBalance(Address account, DefaultBlockParameter blockParameter)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 18
0
 public Task <UInt256> EstimateGas(CallParams callParams, DefaultBlockParameter blockParameter)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 19
0
 public virtual Task <byte[]> GetCode(Address address, DefaultBlockParameter blockParameter)
 {
     return(_proxyClient.GetCode(address, blockParameter));
 }
Ejemplo n.º 20
0
 public Task <byte[]> Call(CallParams callParams, DefaultBlockParameter blockParameter)
 {
     throw new NotImplementedException();
 }