예제 #1
0
        public ResultWrapper <Data> eth_sendTransaction(Transaction transaction)
        {
            Core.Transaction tx     = _modelMapper.MapTransaction(transaction);
            Keccak           txHash = _blockchainBridge.SendTransaction(tx);

            return(ResultWrapper <Data> .Success(new Data(txHash)));
        }
예제 #2
0
        public Block MapBlock(Core.Block block, bool returnFullTransactionObjects)
        {
            Transaction[] transactions      = null;
            Data[]        transactionHashes = null;
            if (returnFullTransactionObjects)
            {
                transactions = new Transaction[block.Transactions.Length];
            }
            else
            {
                transactionHashes = new Data[block.Transactions.Length];
            }

            for (int i = 0; i < block.Transactions.Length; i++)
            {
                if (returnFullTransactionObjects)
                {
                    transactions[i] = MapTransaction(block.Hash, block.Number, i, block.Transactions[i]);
                }
                else
                {
                    transactionHashes[i] = new Data(block.Transactions[i].Hash);
                }
            }

            var blockModel = new Block
            {
                Hash              = new Data(block.Hash.Bytes),
                Uncles            = block.Ommers?.Select(x => new Data(x.Hash)).ToArray(),
                Transactions      = transactions,
                TransactionHashes = transactionHashes
            };

            if (block.Header == null)
            {
                return(blockModel);
            }

            blockModel.Number           = new Quantity(block.Header.Number);
            blockModel.ParentHash       = new Data(block.Header.ParentHash);
            blockModel.Nonce            = new Data(block.Header.Nonce.ToString());
            blockModel.MixHash          = new Data(block.Header.MixHash?.ToString());
            blockModel.Sha3Uncles       = new Data(block.Header.OmmersHash);
            blockModel.LogsBloom        = new Data(block.Header.Bloom?.Bytes);
            blockModel.TransactionsRoot = new Data(block.Header.TransactionsRoot);
            blockModel.StateRoot        = new Data(block.Header.StateRoot);
            blockModel.ReceiptsRoot     = new Data(block.Header.ReceiptsRoot);
            blockModel.Miner            = block.Header.Beneficiary != null ? new Data(block.Header.Beneficiary) : null;
            blockModel.Difficulty       = new Quantity(block.Header.Difficulty);
            blockModel.TotalDifficulty  = new Quantity(block.Header.TotalDifficulty ?? 0);
            blockModel.ExtraData        = new Data(block.Header.ExtraData);
            //Size = new Quantity(block.Header.)
            blockModel.GasLimit  = new Quantity(block.Header.GasLimit);
            blockModel.GasUsed   = new Quantity(block.Header.GasUsed);
            blockModel.Timestamp = new Quantity(block.Header.Timestamp);

            return(blockModel);
        }
예제 #3
0
        public Core.Transaction MapTransaction(Transaction transaction)
        {
            Core.Transaction tx = new Core.Transaction();
            tx.GasLimit      = transaction.Gas?.Value.ToUInt256() ?? 90000;
            tx.GasPrice      = transaction.GasPrice?.Value.ToUInt256() ?? 0;
            tx.Nonce         = transaction.Nonce?.Value.ToUInt256() ?? 0; // here pick the last nonce?
            tx.To            = transaction.To == null ? null : new Address(transaction.To.Value);
            tx.SenderAddress = transaction.From == null ? null : new Address(transaction.From.Value);
            tx.Value         = transaction.Value?.Value.ToUInt256() ?? UInt256.Zero;
            if (tx.To == null)
            {
                tx.Init = transaction.Data.Value;
            }
            else
            {
                tx.Data = transaction.Data.Value;
            }

            return(tx);
        }
예제 #4
0
 public ResultWrapper <Quantity> eth_estimateGas(Transaction transactionCall, BlockParameter blockParameter)
 {
     throw new NotImplementedException();
 }
예제 #5
0
 public ResultWrapper <Data> eth_call(Transaction transactionCall, BlockParameter blockParameter)
 {
     throw new NotImplementedException();
 }
예제 #6
0
 public ResultWrapper <Data> eth_sendTransaction(Transaction transaction)
 {
     throw new NotImplementedException();
 }
예제 #7
0
 public ResultWrapper <Quantity> eth_estimateGas(Transaction transactionCall, BlockParameter blockParameter)
 {
     return(ResultWrapper <Quantity> .Fail("eth_estimateGas not supported"));
 }
예제 #8
0
 public ResultWrapper <Data> eth_call(Transaction transactionCall, BlockParameter blockParameter)
 {
     Core.Block block  = GetBlock(blockParameter).Data;
     byte[]     result = _blockchainBridge.Call(block, _modelMapper.MapTransaction(transactionCall));
     return(ResultWrapper <Data> .Success(new Data(result)));
 }
예제 #9
0
 public ResultWrapper <ParityLikeTxTrace> trace_call(Transaction message, string[] traceTypes, BlockParameter quantity)
 {
     throw new NotImplementedException();
 }