public void ReverseSortBy() { ArrayList arrayList = new ArrayList(); arrayList.Add(new BELInteger(1)); arrayList.Add(new BELInteger(2)); arrayList.Add(new BELInteger(3)); arrayList.Add(new BELInteger(0)); BELArray unsorted = new BELArray(arrayList); // Create a simple arithmetic mapping for the sort BehaviorParser parser = new BehaviorParser(""); ExposableParseTreeNode block = parser.Parse("4.Subtract(e)"); ArrayList parameters = new ArrayList(); BlockParameter parameter = new BlockParameter(null, "e"); parameters.Add(parameter); BELArray sorted = unsorted.ReverseSortBy(new ExecutionContext(), new Block(block, parameters, null)); Assert.AreEqual(4, sorted.Count, "Checking that the length was preserved."); for (int i = 0; i < 4; ++i) { Assert.AreEqual(i, ((BELInteger)sorted.Item(i)).Value, "Checking that sort order was correct."); } }
public Task <string> SellerQueryAsync(SellerFunction sellerFunction, BlockParameter blockParameter = null) { return(ContractHandler.QueryAsync <SellerFunction, string>(sellerFunction, blockParameter)); }
public Task <BigInteger> GetRestKopsPerOneUsdQueryAsync(BlockParameter blockParameter = null) { return(ContractHandler.QueryAsync <GetRestKopsPerOneUsdFunction, BigInteger>(null, blockParameter)); }
public Task <TReturn> CallDeserializingToObjectAsync <TReturn>(string from, HexBigInteger gas, HexBigInteger value, BlockParameter block, params object[] functionInput) where TReturn : new() { return(base.CallAsync(new TReturn(), CreateCallInput(from, gas, value, functionInput), block)); }
public Task <BigInteger> ExpirationQueryAsync(BlockParameter blockParameter = null) { return(ContractHandler.QueryAsync <ExpirationFunction, BigInteger>(null, blockParameter)); }
// https://github.com/ethereum/EIPs/issues/1186 public ResultWrapper <AccountProof> eth_getProof(Address accountAddress, byte[][] storageKeys, BlockParameter blockParameter) { BlockHeader header; try { header = _blockFinder.FindHeader(blockParameter); if (header == null) { return(ResultWrapper <AccountProof> .Fail($"{blockParameter} block not found", ErrorCodes.ResourceNotFound, null)); } if (!HasStateForBlock(header)) { return(ResultWrapper <AccountProof> .Fail($"No state available for block {header.Hash}", ErrorCodes.ResourceUnavailable)); } } catch (Exception ex) { return(ResultWrapper <AccountProof> .Fail(ex.Message, ErrorCodes.InternalError, null)); } AccountProofCollector accountProofCollector = new AccountProofCollector(accountAddress, storageKeys); _blockchainBridge.RunTreeVisitor(accountProofCollector, header.StateRoot); return(ResultWrapper <AccountProof> .Success(accountProofCollector.BuildResult())); }
public Task <TReturn> CallAsync <TReturn>(string from, HexBigInteger gas, HexBigInteger value, BlockParameter block, params object[] functionInput) { return(base.CallAsync <TReturn>(CreateCallInput(from, gas, value, functionInput), block)); }
public FilterBuilder FromBlock(BlockParameterType blockType) { _fromBlock = new BlockParameter(blockType); return(this); }
public FilterBuilder FromLatestBlock() { _fromBlock = new BlockParameter(BlockParameterType.Latest); return(this); }
public FilterBuilder ToLatestBlock() { _toBlock = new BlockParameter(BlockParameterType.Latest); return(this); }
public FilterBuilder ToPendingBlock() { _toBlock = new BlockParameter(BlockParameterType.Pending); return(this); }
public Task <string> GalleassQueryAsync(BlockParameter blockParameter = null) { return(ContractHandler.QueryAsync <GalleassFunction, string>(null, blockParameter)); }
public Task <ushort> TileTypesQueryAsync(TileTypesFunction tileTypesFunction, BlockParameter blockParameter = null) { return(ContractHandler.QueryAsync <TileTypesFunction, ushort>(tileTypesFunction, blockParameter)); }
public Task <ushort> TranslateToStartingTileQueryAsync(TranslateToStartingTileFunction translateToStartingTileFunction, BlockParameter blockParameter = null) { return(ContractHandler.QueryAsync <TranslateToStartingTileFunction, ushort>(translateToStartingTileFunction, blockParameter)); }
public Task <ushort> GetTotalWidthQueryAsync(GetTotalWidthFunction getTotalWidthFunction, BlockParameter blockParameter = null) { return(ContractHandler.QueryAsync <GetTotalWidthFunction, ushort>(getTotalWidthFunction, blockParameter)); }
public FilterBuilder FromFutureBlock() { _fromBlock = new BlockParameter(1000000); return(this); }
public ResultWrapper <BlockForRpc> eth_getUncleByBlockNumberAndIndex(BlockParameter blockParameter, UInt256 positionIndex) { return(GetUncle(blockParameter, positionIndex)); }
public FilterBuilder FromPendingBlock() { _fromBlock = new BlockParameter(BlockParameterType.Pending); return(this); }
protected Task <TReturn> CallAsync <TReturn>(TReturn functionOuput, CallInput callInput, BlockParameter block) { return(EthCall.SendRequestAsync(callInput, block).ContinueWith(result => { if (result.Exception != null) { throw result.Exception; } return FunctionBuilderBase.DecodeDTOTypeOutput <TReturn>(functionOuput, result.Result); })); }
public FilterBuilder ToBlock(long number) { _toBlock = new BlockParameter(number); return(this); }
public Task <TReturn> CallAsync <TReturn>(BlockParameter block, params object[] functionInput) { return(base.CallAsync <TReturn>(CreateCallInput(functionInput), block)); }
public ResultWrapper <byte[]> eth_getStorageAt(Address address, UInt256 positionIndex, BlockParameter blockParameter = null) { SearchResult <BlockHeader> searchResult = _blockFinder.SearchForHeader(blockParameter); if (searchResult.IsError) { return(ResultWrapper <byte[]> .Fail(searchResult)); } BlockHeader header = searchResult.Object; Account account = _stateReader.GetAccount(header.StateRoot, address); if (account == null) { return(ResultWrapper <byte[]> .Success(Array.Empty <byte>())); } var storage = _stateReader.GetStorage(account.StorageRoot, positionIndex); return(ResultWrapper <byte[]> .Success(storage.PadLeft(32))); }
public Task <TReturn> CallDeserializingToObjectAsync <TReturn>( BlockParameter blockParameter, params object[] functionInput) where TReturn : new() { return(base.CallAsync(new TReturn(), CreateCallInput(functionInput), blockParameter)); }
public Task <ResultWrapper <UInt256?> > eth_getTransactionCount(Address address, BlockParameter blockParameter) { SearchResult <BlockHeader> searchResult = _blockFinder.SearchForHeader(blockParameter); if (searchResult.IsError) { return(Task.FromResult(ResultWrapper <UInt256?> .Fail(searchResult))); } BlockHeader header = searchResult.Object; if (!HasStateForBlock(header)) { return(Task.FromResult(ResultWrapper <UInt256?> .Fail($"No state available for block {header.Hash}", ErrorCodes.ResourceUnavailable))); } Account account = _stateReader.GetAccount(header.StateRoot, address); UInt256 nonce = account?.Nonce ?? 0; return(Task.FromResult(ResultWrapper <UInt256?> .Success(nonce))); }
public Task <BigInteger> OwnershipQueryAsync(BlockParameter blockParameter = null) { return(ContractHandler.QueryAsync <OwnershipFunction, BigInteger>(null, blockParameter)); }
public ResultWrapper <UInt256?> eth_estimateGas(TransactionForRpc transactionCall, BlockParameter blockParameter) { SearchResult <BlockHeader> searchResult = _blockFinder.SearchForHeader(blockParameter); if (searchResult.IsError) { return(ResultWrapper <UInt256?> .Fail(searchResult)); } BlockHeader header = searchResult.Object; if (!HasStateForBlock(header)) { return(ResultWrapper <UInt256?> .Fail($"No state available for block {header.Hash}", ErrorCodes.ResourceUnavailable)); } return(EstimateGas(transactionCall, header)); }
public Task <string> BuyerQueryAsync(BlockParameter blockParameter = null) { return(ContractHandler.QueryAsync <BuyerFunction, string>(null, blockParameter)); }
public ResultWrapper <BlockForRpc> eth_getBlockByNumber(BlockParameter blockParameter, bool returnFullTransactionObjects) { return(GetBlock(blockParameter, returnFullTransactionObjects)); }
public Task <string> CalculatorsQueryAsync(CalculatorsFunction calculatorsFunction, BlockParameter blockParameter = null) { return(ContractHandler.QueryAsync <CalculatorsFunction, string>(calculatorsFunction, blockParameter)); }
public ResultWrapper <TransactionForRpc> eth_getTransactionByBlockNumberAndIndex(BlockParameter blockParameter, UInt256 positionIndex) { SearchResult <Block> searchResult = _blockFinder.SearchForBlock(blockParameter); if (searchResult.IsError) { return(ResultWrapper <TransactionForRpc> .Fail(searchResult)); } Block block = searchResult.Object; if (positionIndex < 0 || positionIndex > block.Transactions.Length - 1) { return(ResultWrapper <TransactionForRpc> .Fail("Position Index is incorrect", ErrorCodes.InvalidParams)); } Transaction transaction = block.Transactions[(int)positionIndex]; RecoverTxSenderIfNeeded(transaction); TransactionForRpc transactionModel = new TransactionForRpc(block.Hash, block.Number, (int)positionIndex, transaction); if (_logger.IsDebug) { _logger.Debug($"eth_getTransactionByBlockNumberAndIndex request {blockParameter}, index: {positionIndex}, result: {transactionModel.Hash}"); } return(ResultWrapper <TransactionForRpc> .Success(transactionModel)); }
public void ReverseSortByEmpty() { BELArray unsorted = new BELArray(); // Create a simple arithmetic mapping for the sort BehaviorParser parser = new BehaviorParser(""); ExposableParseTreeNode block = parser.Parse("4.Subtract(e)"); ArrayList parameters = new ArrayList(); BlockParameter parameter = new BlockParameter(null, "e"); parameters.Add(parameter); BELArray sorted = unsorted.ReverseSortBy(new ExecutionContext(), new Block(block, parameters, null)); Assert.IsNotNull(sorted, "Checking that result was returned for an empty array."); Assert.AreEqual(0, sorted.Count, "Checking that the result array was empty."); }
public Task <string> GetContractQueryAsync(GetContractFunction getContractFunction, BlockParameter blockParameter = null) { return(ContractHandler.QueryAsync <GetContractFunction, string>(getContractFunction, blockParameter)); }