Skip to content

Commit

Permalink
Update org.stellar.sdk.responses, add missing fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
overcat committed Jan 31, 2024
1 parent 76b7f8e commit a84f757
Show file tree
Hide file tree
Showing 22 changed files with 583 additions and 158 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
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.

## Pending
### Update
* Update `org.stellar.sdk.responses`, add missing fields. ([#570](https://github.com/stellar/java-stellar-sdk/pull/570))

## 0.43.0
### Update
Expand Down
41 changes: 28 additions & 13 deletions src/main/java/org/stellar/sdk/responses/AccountResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,24 @@
@Getter
@EqualsAndHashCode(callSuper = false)
public class AccountResponse extends Response implements org.stellar.sdk.TransactionBuilderAccount {
@SerializedName("id")
private String id;

@SerializedName("account_id")
private String accountId;

@SerializedName("sequence")
private Long sequenceNumber;

@SerializedName("subentry_count")
private Integer subentryCount;

@SerializedName("sequence_ledger")
private Long sequenceUpdatedAtLedger;

@SerializedName("sequence_time")
private Long sequenceUpdatedAtTime;

@SerializedName("subentry_count")
private Integer subentryCount;

@SerializedName("inflation_destination")
private String inflationDestination;

Expand Down Expand Up @@ -68,9 +71,6 @@ public class AccountResponse extends Response implements org.stellar.sdk.Transac
@SerializedName("data")
private Data data;

@SerializedName("_links")
private Links links;

@SerializedName("num_sponsoring")
private Integer numSponsoring;

Expand All @@ -80,6 +80,12 @@ public class AccountResponse extends Response implements org.stellar.sdk.Transac
@SerializedName("sponsor")
private String sponsor;

@SerializedName("paging_token")
private String pagingToken;

@SerializedName("_links")
private Links links;

AccountResponse(String accountId) {
this.accountId = accountId;
}
Expand Down Expand Up @@ -307,19 +313,28 @@ public byte[] getDecoded(String key) {
/** Links connected to account. */
@Value
public static class Links {
@SerializedName("self")
Link self;

@SerializedName("transactions")
Link transactions;

@SerializedName("operations")
Link operations;

@SerializedName("payments")
Link payments;

@SerializedName("effects")
Link effects;

@SerializedName("offers")
Link offers;

@SerializedName("operations")
Link operations;
@SerializedName("trades")
Link trades;

@SerializedName("self")
Link self;

@SerializedName("transactions")
Link transactions;
@SerializedName("data")
Link data;
}
}
44 changes: 30 additions & 14 deletions src/main/java/org/stellar/sdk/responses/AssetResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,31 @@ public class AssetResponse extends Response implements Pageable {
@SerializedName("contract_id")
String contractID;

@SerializedName("accounts")
AssetResponse.Accounts accounts;
// TODO: The following fields will be removed in Horizon 3.0,
// and we should also remove them at that time.
@SerializedName("num_accounts")
int numAccounts;

@SerializedName("balances")
AssetResponse.Balances balances;
@SerializedName("num_claimable_balances")
int numClaimableBalances;

@SerializedName("num_liquidity_pools")
int numLiquidityPools;

@SerializedName("num_contracts")
int numContracts;

@SerializedName("num_archived_contracts")
int numArchivedContracts;

// TODO: remove the above fields when Horizon 3.0 is released.

@SerializedName("amount")
String amount;

@SerializedName("accounts")
AssetResponse.Accounts accounts;

@SerializedName("claimable_balances_amount")
String claimableBalancesAmount;

Expand All @@ -42,17 +58,11 @@ public class AssetResponse extends Response implements Pageable {
@SerializedName("contracts_amount")
String contractsAmount;

@SerializedName("num_accounts")
int numAccounts;

@SerializedName("num_claimable_balances")
int numClaimableBalances;

@SerializedName("num_liquidity_pools")
int numLiquidityPools;
@SerializedName("archived_contracts_amount")
String archivedContractsAmount;

@SerializedName("num_contracts")
int numContracts;
@SerializedName("balances")
AssetResponse.Balances balances;

@SerializedName("flags")
AssetResponse.Flags flags;
Expand Down Expand Up @@ -124,6 +134,12 @@ public static class Flags {

@SerializedName("auth_revocable")
boolean authRevocable;

@SerializedName("auth_immutable")
boolean authImmutable;

@SerializedName("auth_clawback_enabled")
boolean authClawbackEnabled;
}

/** Links connected to asset. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
@Value
@EqualsAndHashCode(callSuper = false)
public class ClaimableBalanceResponse extends Response implements Pageable {

@SerializedName("id")
String id;

Expand All @@ -36,15 +35,18 @@ public class ClaimableBalanceResponse extends Response implements Pageable {
@SerializedName("last_modified_time")
String lastModifiedTime;

@SerializedName("claimants")
List<Claimant> claimants;

@SerializedName("flags")
Flags flags;

@SerializedName("paging_token")
String pagingToken;

@SerializedName("_links")
Links links;

@SerializedName("claimants")
List<Claimant> claimants;

public Asset getAsset() {
return Asset.create(assetString);
}
Expand All @@ -53,10 +55,22 @@ public Optional<String> getSponsor() {
return Optional.ofNullable(this.sponsor);
}

@Value
public static class Flags {
@SerializedName("clawback_enabled")
Boolean clawbackEnabled;
}

/** Links connected to claimable balance. */
@Value
public static class Links {
@SerializedName("self")
Link self;

@SerializedName("transactions")
Link transactions;

@SerializedName("operations")
Link operations;
}
}
8 changes: 4 additions & 4 deletions src/main/java/org/stellar/sdk/responses/FeeStatsResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
@Value
@EqualsAndHashCode(callSuper = false)
public class FeeStatsResponse extends Response {
@SerializedName("ledger_capacity_usage")
Float ledgerCapacityUsage;
@SerializedName("last_ledger")
Long lastLedger;

@SerializedName("last_ledger_base_fee")
Long lastLedgerBaseFee;

@SerializedName("last_ledger")
Long lastLedger;
@SerializedName("ledger_capacity_usage")
Float ledgerCapacityUsage;

@SerializedName("fee_charged")
FeeDistribution feeCharged;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ public class LiquidityPoolResponse extends Response {
@SerializedName("reserves")
Reserve[] reserves;

@SerializedName("last_modified_ledger")
Long lastModifiedLedger;

@SerializedName("last_modified_time")
String lastModifiedTime;

@SerializedName("_links")
Links links;

Expand All @@ -67,15 +73,12 @@ public Reserve(@NonNull String amount, @NonNull String asset) {
/** Links connected to account. */
@Value
public static class Links {
@SerializedName("effects")
Link effects;
@SerializedName("self")
Link self;

@SerializedName("operations")
Link operations;

@SerializedName("self")
Link self;

@SerializedName("transactions")
Link transactions;
}
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/org/stellar/sdk/responses/OfferResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public class OfferResponse extends Response implements Pageable {
@SerializedName("amount")
String amount;

@SerializedName("price_r")
TradePrice priceR;

@SerializedName("price")
String price;

Expand All @@ -45,12 +48,12 @@ public class OfferResponse extends Response implements Pageable {
@SerializedName("last_modified_time")
String lastModifiedTime;

@SerializedName("_links")
Links links;

@SerializedName("sponsor")
String sponsor;

@SerializedName("_links")
Links links;

public Optional<String> getSponsor() {
// For backwards compatibility
return Optional.ofNullable(this.sponsor);
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/org/stellar/sdk/responses/PathResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,11 @@ public class PathResponse extends Response {
@SerializedName("path")
ArrayList<Asset> path;

@SerializedName("_links")
Links links;

public Asset getDestinationAsset() {
return create(destinationAssetType, destinationAssetCode, destinationAssetIssuer);
}

public Asset getSourceAsset() {
return create(sourceAssetType, sourceAssetCode, sourceAssetIssuer);
}

/** Links connected to path. */
@Value
public static class Links {
@SerializedName("self")
Link self;
}
}
Loading

0 comments on commit a84f757

Please sign in to comment.