From ba45df8780c9394123f1194613a4f8cc5dfc5fad Mon Sep 17 00:00:00 2001 From: David Hernando Date: Fri, 12 Jul 2024 12:21:14 +0200 Subject: [PATCH] replace existing `int blockHeight` arguments with the proper `ulong blockheight`. Signed-off-by: David Hernando --- Casper.Network.SDK.Test/NctlGetXTest.cs | 14 ++++---- Casper.Network.SDK/ICasperClient.cs | 38 ++++++++++++++++----- Casper.Network.SDK/JsonRpc/CasperMethods.cs | 18 +++++----- Casper.Network.SDK/JsonRpc/RpcMethod.cs | 4 +-- Casper.Network.SDK/NetCasperClient.cs | 18 +++++----- 5 files changed, 57 insertions(+), 35 deletions(-) diff --git a/Casper.Network.SDK.Test/NctlGetXTest.cs b/Casper.Network.SDK.Test/NctlGetXTest.cs index 6a144a8..34a28c9 100644 --- a/Casper.Network.SDK.Test/NctlGetXTest.cs +++ b/Casper.Network.SDK.Test/NctlGetXTest.cs @@ -47,7 +47,7 @@ public async Task GetAccountTest() try { var block = (await _client.GetBlock()).Parse().Block; - var blockHeight = (int) block.Height; + var blockHeight = block.Height; var blockHash = block.Hash; var stateRootHash = await _client.GetStateRootHash(blockHash); @@ -147,13 +147,13 @@ public async Task GetBlockTest() var result2 = response2.Parse(); Assert.IsNotNull(result2.Block.Hash); - Assert.AreEqual(result2.Block.Proposer.IsSystem, result2.Block.Proposer.isSystem); + Assert.AreEqual(result2.Block.Proposer.IsSystem, result2.Block.Proposer.IsSystem); var response3 = await _client.GetBlock(result2.Block.Hash); var result3 = response3.Parse(); Assert.AreEqual(result2.Block.Hash, result3.Block.Hash); - var response4 = await _client.GetBlock((int)result2.Block.Height); + var response4 = await _client.GetBlock(result2.Block.Height); var result4 = response4.Parse(); Assert.AreEqual(result2.Block.Hash, result4.Block.Hash); @@ -161,14 +161,14 @@ public async Task GetBlockTest() var result5 = response5.Parse(); Assert.AreEqual(0, result5.Transfers.Count); - var response6 = await _client.GetBlockTransfers((int)result2.Block.Height); + var response6 = await _client.GetBlockTransfers(result2.Block.Height); var result6 = response6.Parse(); Assert.AreEqual(0, result6.Transfers.Count); var hash1 = await _client.GetStateRootHash(result2.Block.Hash); Assert.AreEqual(32*2, hash1.Length); - var hash2 = await _client.GetStateRootHash((int)result2.Block.Height); + var hash2 = await _client.GetStateRootHash(result2.Block.Height); Assert.AreEqual(hash1, hash2); var hash3 = await _client.GetStateRootHash(); @@ -202,7 +202,7 @@ public async Task GetSystemBlockProposerTest() var result = response.Parse(); Assert.IsNotNull(result.Block.Hash); Assert.IsTrue(result.Block.Proposer.IsSystem); - Assert.AreEqual(result.Block.Proposer.IsSystem, result.Block.Proposer.isSystem); + Assert.AreEqual(result.Block.Proposer.IsSystem, result.Block.Proposer.IsSystem); } catch (RpcClientException e) { @@ -261,7 +261,7 @@ public async Task GetEraSummaryTest() var result3 = response3.Parse(); Assert.IsNotNull(result3.Block.Hash); - var response4 = await _client.GetEraSummary((int)result3.Block.Height); + var response4 = await _client.GetEraSummary(result3.Block.Height); var result4 = response4.Parse(); Assert.IsTrue(result4.EraSummary.EraId > 0); Assert.IsNotNull(result4.EraSummary.StoredValue.EraInfo); diff --git a/Casper.Network.SDK/ICasperClient.cs b/Casper.Network.SDK/ICasperClient.cs index f6ded09..aaa9713 100644 --- a/Casper.Network.SDK/ICasperClient.cs +++ b/Casper.Network.SDK/ICasperClient.cs @@ -10,7 +10,7 @@ public interface ICasperClient { Task GetStateRootHash(string blockHash = null); - Task GetStateRootHash(int blockHeight); + Task GetStateRootHash(ulong blockHeight); Task> GetNodeStatus(); @@ -18,19 +18,19 @@ public interface ICasperClient Task> GetAuctionInfo(string blockHash = null); - Task> GetAuctionInfo(int blockHeight); + Task> GetAuctionInfo(ulong blockHeight); Task> GetAccountInfo(PublicKey publicKey, string blockHash = null); Task> GetAccountInfo(string publicKey, string blockHash = null); - Task> GetAccountInfo(PublicKey publicKey, int blockHeight); + Task> GetAccountInfo(PublicKey publicKey, ulong blockHeight); - Task> GetAccountInfo(string publicKey, int blockHeight); + Task> GetAccountInfo(string publicKey, ulong blockHeight); Task> GetAccountInfo(AccountHashKey accountHash, string blockHash = null); - Task> GetAccountInfo(AccountHashKey accountHash, int blockHeight); + Task> GetAccountInfo(AccountHashKey accountHash, ulong blockHeight); Task> GetEntity(IEntityIdentifier entityIdentifier, string blockHash = null); @@ -40,6 +40,8 @@ public interface ICasperClient Task> GetEntity(string entityAddr, ulong blockHeight); + Task> QueryGlobalState(string key, ulong height, + string path = null); Task> QueryGlobalState(string key, string stateRootHash = null, string path = null); @@ -77,23 +79,37 @@ Task> QueryBalanceDetailsWithStateRootHas Task> GetDeploy(string deployHash, CancellationToken cancellationToken = default(CancellationToken)); + + Task> GetDeploy(string deployHash, + bool finalizedApprovals, + CancellationToken cancellationToken = default(CancellationToken)); + + Task> PutTransaction(TransactionV1 transaction); Task> GetTransaction(TransactionHash transactionHash, bool finalizedApprovals = false, CancellationToken cancellationToken = default(CancellationToken)); + + Task> GetTransaction(string version1Hash, + bool finalizedApprovals = false, + CancellationToken cancellationToken = default(CancellationToken)); Task> GetBlock(string blockHash = null); - Task> GetBlock(int blockHeight); + Task> GetBlock(ulong blockHeight); Task> GetBlockTransfers(string blockHash = null); - Task> GetBlockTransfers(int blockHeight); + Task> GetBlockTransfers(ulong blockHeight); Task> GetEraInfoBySwitchBlock(string blockHash = null); - Task> GetEraInfoBySwitchBlock(int blockHeight); + Task> GetEraInfoBySwitchBlock(ulong blockHeight); + + Task> GetEraSummary(string blockHash = null); + Task> GetEraSummary(ulong blockHeight); + Task> GetDictionaryItem(string dictionaryItem, string stateRootHash = null); Task> GetDictionaryItemByAccount(string accountKey, string dictionaryName, @@ -108,5 +124,11 @@ Task> GetDictionaryItemByURef(string seedUR Task> GetValidatorChanges(); Task GetRpcSchema(); + + Task> GetChainspec(); + + Task> SpeceulativeExecution(Deploy deploy, string stateRootHash = null); + + Task> SpeceulativeExecutionWithBlockHash(Deploy deploy, string blockHash = null); } } diff --git a/Casper.Network.SDK/JsonRpc/CasperMethods.cs b/Casper.Network.SDK/JsonRpc/CasperMethods.cs index dee8ca8..846d822 100644 --- a/Casper.Network.SDK/JsonRpc/CasperMethods.cs +++ b/Casper.Network.SDK/JsonRpc/CasperMethods.cs @@ -20,7 +20,7 @@ public GetStateRootHash(string blockHash = null) : base("chain_get_state_root_ha /// Returns the state root hash at a given Block /// /// Block height for which the state root is queried. - public GetStateRootHash(int height) : base("chain_get_state_root_hash", height) + public GetStateRootHash(ulong height) : base("chain_get_state_root_hash", height) { } } @@ -59,7 +59,7 @@ public GetAuctionInfo(string blockHash) : base("state_get_auction_info", blockHa /// Returns the bids and validators at a given block. /// /// Block height for which the auction info is queried. - public GetAuctionInfo(int height) : base("state_get_auction_info", height) + public GetAuctionInfo(ulong height) : base("state_get_auction_info", height) { } } @@ -81,7 +81,7 @@ public GetAccountInfo(PublicKey publicKey, string blockHash = null) : base("stat /// /// The public key of the account. /// A block height for which the information of the account is queried. - public GetAccountInfo(PublicKey publicKey, int height) : base("state_get_account_info", height) + public GetAccountInfo(PublicKey publicKey, ulong height) : base("state_get_account_info", height) { this.Parameters.Add("account_identifier", publicKey); } @@ -101,7 +101,7 @@ public GetAccountInfo(AccountHashKey accountHash, string blockHash = null) : bas /// /// The account hash of the account. /// A block height for which the information of the account is queried. - public GetAccountInfo(AccountHashKey accountHash, int height) : base("state_get_account_info", height) + public GetAccountInfo(AccountHashKey accountHash, ulong height) : base("state_get_account_info", height) { // this.Parameters.Add("account_identifier", Hex.ToHexString(accountHash.GetBytes())); this.Parameters.Add("account_identifier", accountHash.ToString()); @@ -124,7 +124,7 @@ public GetAccountInfo(string publicKey, string blockHash = null) : base("state_g /// The public key of the account. /// A block height for which the information of the account is queried. [Obsolete("For Casper node v1.5.5 or newer use the new method signature with PublicKey or AccountHashKey", false)] - public GetAccountInfo(string publicKey, int height) : base("state_get_account_info", height) + public GetAccountInfo(string publicKey, ulong height) : base("state_get_account_info", height) { this.Parameters.Add("public_key", publicKey); } @@ -358,7 +358,7 @@ public GetBlock(string blockHash) : base("chain_get_block", blockHash) /// Retrieves a Block from the network by its height number. /// /// Height of the block to retrieve. - public GetBlock(int height) : base("chain_get_block", height) + public GetBlock(ulong height) : base("chain_get_block", height) { } } @@ -377,7 +377,7 @@ public GetBlockTransfers(string blockHash) : base("chain_get_block_transfers", b /// Retrieves all transfers for a Block from the network /// /// Height of the block to retrieve the transfers from. - public GetBlockTransfers(int height) : base("chain_get_block_transfers", height) + public GetBlockTransfers(ulong height) : base("chain_get_block_transfers", height) { } } @@ -396,7 +396,7 @@ public GetEraInfoBySwitchBlock(string blockHash) : base("chain_get_era_info_by_s /// Retrieves an EraInfo from the network given a switch block. /// /// Block height of a switch block. - public GetEraInfoBySwitchBlock(int height) : base("chain_get_era_info_by_switch_block", height) + public GetEraInfoBySwitchBlock(ulong height) : base("chain_get_era_info_by_switch_block", height) { } } @@ -415,7 +415,7 @@ public GetEraSummary(string blockHash) : base("chain_get_era_summary", blockHash /// Retrieves current era info from the network given a block height /// /// Block height. - public GetEraSummary(int height) : base("chain_get_era_summary", height) + public GetEraSummary(ulong height) : base("chain_get_era_summary", height) { } } diff --git a/Casper.Network.SDK/JsonRpc/RpcMethod.cs b/Casper.Network.SDK/JsonRpc/RpcMethod.cs index 3e17c8d..ba99d5b 100644 --- a/Casper.Network.SDK/JsonRpc/RpcMethod.cs +++ b/Casper.Network.SDK/JsonRpc/RpcMethod.cs @@ -76,11 +76,11 @@ public RpcMethod(string method, string blockHash) }; } - public RpcMethod(string method, int blockHeight) + public RpcMethod(string method, ulong blockHeight) { this.Method = method; - var blockIdentifier = new Dictionary + var blockIdentifier = new Dictionary { {"Height", blockHeight} }; diff --git a/Casper.Network.SDK/NetCasperClient.cs b/Casper.Network.SDK/NetCasperClient.cs index b79aa53..0a68507 100644 --- a/Casper.Network.SDK/NetCasperClient.cs +++ b/Casper.Network.SDK/NetCasperClient.cs @@ -61,7 +61,7 @@ public async Task GetStateRootHash(string blockHash = null) /// /// Block height for which the state root is queried. /// - public async Task GetStateRootHash(int blockHeight) + public async Task GetStateRootHash(ulong blockHeight) { var method = new GetStateRootHash(blockHeight); var rpcResponse = await SendRpcRequestAsync(method); @@ -101,7 +101,7 @@ public async Task> GetAuctionInfo(string block /// Request the bids and validators at a given block. /// /// Block height for which the auction info is queried. - public async Task> GetAuctionInfo(int blockHeight) + public async Task> GetAuctionInfo(ulong blockHeight) { var method = new GetAuctionInfo(blockHeight); return await SendRpcRequestAsync(method); @@ -149,7 +149,7 @@ public async Task> GetAccountInfo(string publi /// /// The public key of the account. /// A block height for which the information of the account is queried. - public async Task> GetAccountInfo(PublicKey publicKey, int blockHeight) + public async Task> GetAccountInfo(PublicKey publicKey, ulong blockHeight) { var method = new GetAccountInfo(publicKey, blockHeight); return await SendRpcRequestAsync(method); @@ -160,7 +160,7 @@ public async Task> GetAccountInfo(PublicKey pu /// /// The account hash of the account. /// A block height for which the information of the account is queried. - public async Task> GetAccountInfo(AccountHashKey accountHash, int blockHeight) + public async Task> GetAccountInfo(AccountHashKey accountHash, ulong blockHeight) { var method = new GetAccountInfo(accountHash, blockHeight); return await SendRpcRequestAsync(method); @@ -172,7 +172,7 @@ public async Task> GetAccountInfo(AccountHashK /// The public key of the account formatted as an hex-string. /// A block height for which the information of the account is queried. [Obsolete("For Casper node v1.5.5 or newer use the new method signature with PublicKey or AccountHashKey, ", false)] - public async Task> GetAccountInfo(string publicKey, int blockHeight) + public async Task> GetAccountInfo(string publicKey, ulong blockHeight) { var method = new GetAccountInfo(publicKey, blockHeight); return await SendRpcRequestAsync(method); @@ -537,7 +537,7 @@ public async Task> GetBlock(string blockHash = null) /// Request a Block from the network by its height number. /// /// Height of the block to retrieve. - public async Task> GetBlock(int blockHeight) + public async Task> GetBlock(ulong blockHeight) { var method = new GetBlock(blockHeight); return await SendRpcRequestAsync(method); @@ -557,7 +557,7 @@ public async Task> GetBlockTransfers(string /// Request all transfers for a Block by its height number. /// /// Height of the block to retrieve the transfers from. - public async Task> GetBlockTransfers(int blockHeight) + public async Task> GetBlockTransfers(ulong blockHeight) { var method = new GetBlockTransfers(blockHeight); return await SendRpcRequestAsync(method); @@ -579,7 +579,7 @@ public async Task> GetEraInfoBySwitch /// For a non-switch block this method returns an empty response. /// /// Block height of a switch block. - public async Task> GetEraInfoBySwitchBlock(int blockHeight) + public async Task> GetEraInfoBySwitchBlock(ulong blockHeight) { var method = new GetEraInfoBySwitchBlock(blockHeight); return await SendRpcRequestAsync(method); @@ -599,7 +599,7 @@ public async Task> GetEraSummary(string blockHa /// Request current Era Info from the network given a block hash /// /// Block height. - public async Task> GetEraSummary(int blockHeight) + public async Task> GetEraSummary(ulong blockHeight) { var method = new GetEraSummary(blockHeight); return await SendRpcRequestAsync(method);