Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#375: Fix missing Liquidity Pool ID in AccountResponse Balance #379

Merged
merged 3 commits into from
Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

As this project is pre 1.0, breaking changes may happen for minor version bumps. A breaking change will get clearly notified in this log.

## Unreleased

* Fixed missing Liquidity Pool ID in AccountResponse Balance ([#379](https://github.com/stellar/java-stellar-sdk/pull/379)).

## 0.29.0

* Fixed bug in parsing liquidity pool operation and effect responses ([#373](https://github.com/stellar/java-stellar-sdk/pull/373)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public static class Balance {
private String assetCode;
@SerializedName("asset_issuer")
private String assetIssuer;
@SerializedName("liquidity_pool_shares")
@SerializedName("liquidity_pool_id")
private LiquidityPoolID liquidityPoolID;
@SerializedName("limit")
private final String limit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,27 @@ public void testDeserializeV9() {
assertEquals(account.getBalances()[1].getLimit(), null);
}

@Test
public void testDeserializeLiquidityPoolBalanc() {
AccountResponse account = GsonSingleton.getInstance().fromJson(jsonLiquidityPoolBalance, AccountResponse.class);

assertEquals(account.getBalances()[0].getAssetType(), "liquidity_pool_shares");
assertEquals(account.getBalances()[0].getAssetCode(), Optional.absent());
assertEquals(account.getBalances()[0].getAssetIssuer(), Optional.<String>absent());
assertEquals(account.getBalances()[0].getBalance(), "223.6067977");
assertEquals(account.getBalances()[0].getLimit(), "10000.00000");
assertEquals(account.getBalances()[0].getBuyingLiabilities(), Optional.absent());
assertEquals(account.getBalances()[0].getSellingLiabilities(), Optional.absent());
assertTrue(account.getBalances()[0].getLiquidityPoolID().isPresent());
assertEquals(account.getBalances()[0].getLiquidityPoolID().get().toString(),"02449937ed825805b7a945bb6c027b53dfaf140983c1a1a64c42a81edd89b5e0");

assertEquals(account.getBalances()[1].getAssetType(), "native");
assertEquals(account.getBalances()[1].getBalance(), "20.0000300");
assertEquals(account.getBalances()[1].getBuyingLiabilities(), Optional.absent());
assertEquals(account.getBalances()[1].getSellingLiabilities(), Optional.absent());
assertEquals(account.getBalances()[1].getLimit(), null);
}

String jsonAuthorizedToMaintainLiabilities = "{\n" +
" \"_links\": {\n" +
" \"effects\": {\n" +
Expand Down Expand Up @@ -333,6 +354,70 @@ public void testDeserializeV9() {
" ]\n" +
"}";

String jsonLiquidityPoolBalance = "{\n" +
" \"_links\": {\n" +
" \"effects\": {\n" +
" \"href\": \"/accounts/GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7/effects{?cursor,limit,order}\",\n" +
" \"templated\": true\n" +
" },\n" +
" \"offers\": {\n" +
" \"href\": \"/accounts/GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7/offers{?cursor,limit,order}\",\n" +
" \"templated\": true\n" +
" },\n" +
" \"operations\": {\n" +
" \"href\": \"/accounts/GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7/operations{?cursor,limit,order}\",\n" +
" \"templated\": true\n" +
" },\n" +
" \"self\": {\n" +
" \"href\": \"/accounts/GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7\"\n" +
" },\n" +
" \"transactions\": {\n" +
" \"href\": \"/accounts/GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7/transactions{?cursor,limit,order}\",\n" +
" \"templated\": true\n" +
" }\n" +
" },"+
" \"id\": \"GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7\",\n" +
" \"paging_token\": \"1\",\n" +
" \"account_id\": \"GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7\",\n" +
" \"sequence\": 2319149195853854,\n" +
" \"subentry_count\": 0,\n" +
" \"home_domain\": \"stellar.org\",\n" +
" \"thresholds\": {\n" +
" \"low_threshold\": 0,\n" +
" \"med_threshold\": 0,\n" +
" \"high_threshold\": 0\n" +
" },\n" +
" \"flags\": {\n" +
" \"auth_required\": false,\n" +
" \"auth_revocable\": false\n" +
" },\n" +
" \"balances\": [\n" +
" {\n" +
" \"balance\": \"223.6067977\",\n" +
" \"liquidity_pool_id\": \"02449937ed825805b7a945bb6c027b53dfaf140983c1a1a64c42a81edd89b5e0\",\n" +
" \"limit\": \"10000.00000\",\n" +
" \"last_modified_ledger\": 799014,\n" +
" \"is_authorized\": false,\n" +
" \"is_authorized_to_maintain_liabilities\": false,\n" +
" \"asset_type\": \"liquidity_pool_shares\"\n" +
" },\n" +
" {\n" +
" \"asset_type\": \"native\",\n" +
" \"balance\": \"20.0000300\"\n" +
" }\n" +
" ],\n" +
" \"signers\": [\n" +
" {\n" +
" \"public_key\": \"GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7\",\n" +
" \"weight\": 0\n" +
" },\n" +
" {\n" +
" \"public_key\": \"GCR2KBCIU6KQXSQY5F5GZYC4WLNHCHCKW4NEGXNEZRYWLTNZIRJJY7D2\",\n" +
" \"weight\": 1\n" +
" }\n" +
" ]\n" +
"}";

String withSponsor = "{\n" +
" \"_links\": {\n" +
" \"self\": {\n" +
Expand Down