From c17718d55011de136918dcc479e26d3711972a75 Mon Sep 17 00:00:00 2001 From: George Date: Fri, 1 Dec 2023 13:48:33 -0800 Subject: [PATCH] Extend `.payments()` call builder to encompass add'l non-payment types (#885) --- CHANGELOG.md | 3 +++ src/horizon/payment_call_builder.ts | 15 +++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ecd0405f6..3dacea598 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ A breaking change will get clearly marked in this log. ### Fixed * The `SorobanRpc.Server.getEvents` method now correctly parses responses without a `contractId` field set. The `events[i].contractId` field on an event is now optional, omitted if there was no ID for the event (e.g. system events; ([#883](https://github.com/stellar/js-stellar-sdk/pull/883))). +### Breaking Changes +* The `PaymentCallBuilder` was incorrectly indicating that it would return a collection of `Payment` records, while [in reality](https://developers.stellar.org/api/horizon/resources/list-all-payments) it can return a handful of "payment-like" records ([#885](https://github.com/stellar/js-stellar-sdk/pull/885)). + ## [v11.0.0-beta.6](https://github.com/stellar/js-stellar-sdk/compare/v11.0.0-beta.5...v11.0.0-beta.6) diff --git a/src/horizon/payment_call_builder.ts b/src/horizon/payment_call_builder.ts index f50748e7b..82e103fb1 100644 --- a/src/horizon/payment_call_builder.ts +++ b/src/horizon/payment_call_builder.ts @@ -5,13 +5,20 @@ import { ServerApi } from "./server_api"; * Creates a new {@link PaymentCallBuilder} pointed to server defined by serverUrl. * * Do not create this object directly, use {@link Server#payments}. - * @see [All Payments](https://developers.stellar.org/api/resources/payments/) + * @see [All Payments](https://developers.stellar.org/api/horizon/resources/list-all-payments/) * @constructor * @extends CallBuilder * @param {string} serverUrl Horizon server URL. */ export class PaymentCallBuilder extends CallBuilder< - ServerApi.CollectionPage + ServerApi.CollectionPage< + | ServerApi.PaymentOperationRecord + | ServerApi.CreateAccountOperationRecord + | ServerApi.AccountMergeOperationRecord + | ServerApi.PathPaymentOperationRecord + | ServerApi.PathPaymentStrictSendOperationRecord + | ServerApi.InvokeHostFunctionOperationRecord + > > { constructor(serverUrl: URI) { super(serverUrl, "payments"); @@ -20,7 +27,7 @@ export class PaymentCallBuilder extends CallBuilder< /** * This endpoint responds with a collection of Payment operations where the given account was either the sender or receiver. - * @see [Payments for Account](https://developers.stellar.org/api/resources/accounts/payments/) + * @see [Payments for Account](https://developers.stellar.org/api/horizon/resources/get-payments-by-account-id) * @param {string} accountId For example: `GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD` * @returns {PaymentCallBuilder} this PaymentCallBuilder instance */ @@ -30,7 +37,7 @@ export class PaymentCallBuilder extends CallBuilder< /** * This endpoint represents all payment operations that are part of a valid transactions in a given ledger. - * @see [Payments for Ledger](https://developers.stellar.org/api/resources/ledgers/payments/) + * @see [Payments for Ledger](https://developers.stellar.org/api/horizon/resources/retrieve-a-ledgers-payments) * @param {number|string} sequence Ledger sequence * @returns {PaymentCallBuilder} this PaymentCallBuilder instance */