From d8623784bfdc85cc8401168247e48b03e8f67492 Mon Sep 17 00:00:00 2001 From: Onur Uyanik Date: Tue, 12 Apr 2022 10:58:01 +0300 Subject: [PATCH 1/2] Implemented new "account balance query by denom" endpoint --- CosmosSharp/StargateApi.cs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/CosmosSharp/StargateApi.cs b/CosmosSharp/StargateApi.cs index 88f6a87..4b8e35d 100644 --- a/CosmosSharp/StargateApi.cs +++ b/CosmosSharp/StargateApi.cs @@ -33,11 +33,32 @@ public async Task GetAccount(string accountName, CancellationToken return await _httpHandler.GetJsonAsync(url, _config.HeaderKeyValues, cancellationToken); } - public async Task GetAccountBalance(string accountName, string denom, CancellationToken cancellationToken) + /// + /// Receives account balance via cosmos-sdk before v0.44.4. See more details about change in query account balance endpoint fix and release notes. + /// + /// address + /// denom or IBC denom + /// + /// + public async Task GetAccountBalanceLegacy(string accountName, string denom, CancellationToken cancellationToken) { var url = $"{_config.HttpEndpoint}/cosmos/bank/v1beta1/balances/{accountName}/{denom}"; return await _httpHandler.GetJsonAsync(url, _config.HeaderKeyValues, cancellationToken); } + + /// + /// Receives account balance via cosmos-sdk as from v0.44.4. See more details about query account balance endpoint fix and release notes. + /// + /// address + /// denom or IBC denom + /// + /// + public async Task GetAccountBalance(string accountName, string denom, CancellationToken cancellationToken) + { + // grpc-gateway query account balance by IBC denom had an incorrect endpoint + var url = $"{_config.HttpEndpoint}/cosmos/bank/v1beta1/balances/{accountName}/by_denom?denom={denom}"; + return await _httpHandler.GetJsonAsync(url, _config.HeaderKeyValues, cancellationToken); + } public async Task GetLatestBlock(CancellationToken cancellationToken) { From d444bdeb4f6d1bcb01d9e7edd33d7f9477f9808f Mon Sep 17 00:00:00 2001 From: Onur Uyanik Date: Tue, 12 Apr 2022 11:23:56 +0300 Subject: [PATCH 2/2] Increased package version (patch). --- CosmosSharp/CosmosSharp.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CosmosSharp/CosmosSharp.csproj b/CosmosSharp/CosmosSharp.csproj index 1d62e48..c0d28ff 100644 --- a/CosmosSharp/CosmosSharp.csproj +++ b/CosmosSharp/CosmosSharp.csproj @@ -11,7 +11,7 @@ Copyright (c) 2021 BTCTrader BTCTrader.CosmosSharp BTCTrader.CosmosSharp - 1.1.1 + 1.1.2