Skip to content

Commit

Permalink
Updates for /assets and /claimable_balances/*/(operations|transaction…
Browse files Browse the repository at this point in the history
…s) endpoints (#628)

* add new endpoints for /claimable_balances

* Add new /asset balances and accounts fields

* Update server_test for new asset fields

* Add tests for new claimable_balances endpoints

* update changelog
  • Loading branch information
Paul Bellamy committed Apr 15, 2021
1 parent 2b79e8b commit de24cf5
Show file tree
Hide file tree
Showing 6 changed files with 345 additions and 40 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,9 @@ A breaking change will get clearly marked in this log.

## Unreleased

- Added TransactionCallBuilder.forClaimableBalance(), and OperationCallBuilder.forClaimableBalance().
- Added support for new `accounts`, `balances`, `claimable_balances_amount`, and `num_claimable_balances` fields on Assets.


## [v8.1.1](https://github.com/stellar/js-stellar-sdk/compare/v8.1.0...v8.1.1)

Expand Down
11 changes: 11 additions & 0 deletions src/horizon_api.ts
Expand Up @@ -88,6 +88,17 @@ export namespace Horizon {
? BalanceLineAsset<T>
: BalanceLineNative | BalanceLineAsset;

export interface AssetAccounts {
authorized: number;
authorized_to_maintain_liabilities: number;
unauthorized: number;
}
export interface AssetBalances {
authorized: string;
authorized_to_maintain_liabilities: string;
unauthorized: string;
}

export interface PriceR {
numerator: number;
denominator: number;
Expand Down
11 changes: 11 additions & 0 deletions src/operation_call_builder.ts
Expand Up @@ -47,6 +47,17 @@ export class OperationCallBuilder extends CallBuilder<
return this;
}

/**
* This endpoint represents all operations that reference a given claimable_balance.
* @see [Operations for Claimable Balance](https://www.stellar.org/developers/horizon/reference/endpoints/operations-for-claimable-balance.html)
* @param {string} claimableBalanceId Claimable Balance ID
* @returns {OperationCallBuilder} this OperationCallBuilder instance
*/
public forClaimableBalance(claimableBalanceId: string): this {
this.filter.push(["claimable_balances", claimableBalanceId, "operations"]);
return this;
}

/**
* This endpoint returns all operations that occurred in a given ledger.
*
Expand Down
4 changes: 4 additions & 0 deletions src/server_api.ts
Expand Up @@ -393,6 +393,10 @@ export namespace ServerApi {
asset_code: string;
asset_issuer: string;
paging_token: string;
accounts: Horizon.AssetAccounts;
num_claimable_balances: number;
balances: Horizon.AssetBalances;
claimable_balances_amount: string;
amount: string;
num_accounts: number;
flags: Horizon.Flags;
Expand Down
11 changes: 11 additions & 0 deletions src/transaction_call_builder.ts
Expand Up @@ -46,6 +46,17 @@ export class TransactionCallBuilder extends CallBuilder<
return this;
}

/**
* This endpoint represents all transactions that reference a given claimable_balance.
* @see [Operations for Claimable Balance](https://www.stellar.org/developers/horizon/reference/endpoints/transactions-for-claimable-balance.html)
* @param {string} claimableBalanceId Claimable Balance ID
* @returns {TransactionCallBuilder} this TransactionCallBuilder instance
*/
public forClaimableBalance(claimableBalanceId: string): this {
this.filter.push(["claimable_balances", claimableBalanceId, "transactions"]);
return this;
}

/**
* This endpoint represents all transactions in a given ledger.
* @see [Transactions for Ledger](https://www.stellar.org/developers/horizon/reference/endpoints/transactions-for-ledger.html)
Expand Down

0 comments on commit de24cf5

Please sign in to comment.