From b74db7d484c9437b4d0213edf13357dc620386bc Mon Sep 17 00:00:00 2001 From: George Kudrayvtsev Date: Wed, 12 Jul 2023 13:25:22 -0700 Subject: [PATCH 1/5] Add operation responses --- src/horizon_api.ts | 42 +++++++++++++++++++++++++++++++++ src/server_api.ts | 58 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 99 insertions(+), 1 deletion(-) diff --git a/src/horizon_api.ts b/src/horizon_api.ts index 7b206905a..37cb23756 100644 --- a/src/horizon_api.ts +++ b/src/horizon_api.ts @@ -218,6 +218,9 @@ export namespace Horizon { setTrustLineFlags = "set_trust_line_flags", liquidityPoolDeposit = "liquidity_pool_deposit", liquidityPoolWithdraw = "liquidity_pool_withdraw", + invokeHostFunction = "invoke_host_function", + bumpFootprintExpiration = "bump_footprint_expiration", + restoreFootprint = "restore_footprint", } export enum OperationResponseTypeI { createAccount = 0, @@ -244,6 +247,9 @@ export namespace Horizon { setTrustLineFlags = 21, liquidityPoolDeposit = 22, liquidityPoolWithdraw = 23, + invokeHostFunction = 24, + bumpFootprintExpiration = 25, + restoreFootprint = 26, } export interface BaseOperationResponse< T extends OperationResponseType = OperationResponseType, @@ -563,6 +569,42 @@ export namespace Horizon { reserves_received: Reserve[]; } + export interface BalanceChange { + type: string; + from: string; + to: string; + amount: string; + } + + export interface InvokeHostFunctionOperationResponse + extends BaseOperationResponse< + OperationResponseType.invokeHostFunction, + OperationResponseTypeI.invokeHostFunction + > { + function: string; + parameters: { + value: string; + type: string; + }[]; + address: string; + salt: string; + asset_balance_changes: BalanceChange[]; + } + + export interface BumpFootprintExpirationOperationResponse + extends BaseOperationResponse< + OperationResponseType.bumpFootprintExpiration, + OperationResponseTypeI.bumpFootprintExpiration + > { + ledgersToExpire: string; + } + + export interface RestoreFootprintOperationResponse + extends BaseOperationResponse< + OperationResponseType.restoreFootprint, + OperationResponseTypeI.restoreFootprint + > {}; + export interface ResponseCollection { _links: { self: ResponseLink; diff --git a/src/server_api.ts b/src/server_api.ts index bb210b09d..5c3d4f2a2 100644 --- a/src/server_api.ts +++ b/src/server_api.ts @@ -304,6 +304,54 @@ export namespace ServerApi { OperationResponseTypeI.revokeSponsorship >, Horizon.RevokeSponsorshipOperationResponse {} + export interface ClawbackOperationRecord + extends BaseOperationRecord< + OperationResponseType.clawback, + OperationResponseTypeI.clawback + >, + Horizon.ClawbackOperationResponse {} + export interface ClawbackClaimableBalanceOperationRecord + extends BaseOperationRecord< + OperationResponseType.clawbackClaimableBalance, + OperationResponseTypeI.clawbackClaimableBalance + >, + Horizon.ClawbackClaimableBalanceOperationResponse {} + export interface SetTrustLineFlagsOperationRecord + extends BaseOperationRecord< + OperationResponseType.setTrustLineFlags, + OperationResponseTypeI.setTrustLineFlags + >, + Horizon.SetTrustLineFlagsOperationResponse {} + export interface DepositLiquidityOperationRecord + extends BaseOperationRecord< + OperationResponseType.liquidityPoolDeposit, + OperationResponseTypeI.liquidityPoolDeposit + >, + Horizon.DepositLiquidityOperationResponse {} + export interface WithdrawLiquidityOperationRecord + extends BaseOperationRecord< + OperationResponseType.liquidityPoolWithdraw, + OperationResponseTypeI.liquidityPoolWithdraw + >, + Horizon.WithdrawLiquidityOperationResponse {} + export interface InvokeHostFunctionOperationRecord + extends BaseOperationRecord< + OperationResponseType.invokeHostFunction, + OperationResponseTypeI.invokeHostFunction + >, + Horizon.InvokeHostFunctionOperationResponse {} + export interface BumpFootprintExpirationOperationRecord + extends BaseOperationRecord< + OperationResponseType.bumpFootprintExpiration, + OperationResponseTypeI.bumpFootprintExpiration + >, + Horizon.BumpFootprintExpirationOperationResponse {} + export interface RestoreFootprintOperationRecord + extends BaseOperationRecord< + OperationResponseType.restoreFootprint, + OperationResponseTypeI.restoreFootprint + >, + Horizon.RestoreFootprintOperationResponse {} export type OperationRecord = | CreateAccountOperationRecord @@ -323,7 +371,15 @@ export namespace ServerApi { | ClaimClaimableBalanceOperationRecord | BeginSponsoringFutureReservesOperationRecord | EndSponsoringFutureReservesOperationRecord - | RevokeSponsorshipOperationRecord; + | RevokeSponsorshipOperationRecord + | ClawbackClaimableBalanceOperationRecord + | ClawbackOperationRecord + | SetTrustLineFlagsOperationRecord + | DepositLiquidityOperationRecord + | WithdrawLiquidityOperationRecord + | InvokeHostFunctionOperationRecord + | BumpFootprintExpirationOperationRecord + | RestoreFootprintOperationRecord; export namespace TradeRecord { interface Base extends Horizon.BaseResponse { From fab28ab0a88dc2af59da84e7ba2bedb7ce05c5fc Mon Sep 17 00:00:00 2001 From: George Kudrayvtsev Date: Wed, 12 Jul 2023 13:30:02 -0700 Subject: [PATCH 2/5] Add changelog entry --- CHANGELOG.md | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b4136679..78450b238 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,35 @@ A breaking change will get clearly marked in this log. ### Add -- Asset stat records (`ServerApi.AssetRecord`) contain two new fields to support the Protocol 20 (Soroban) release ([#TODO](https://github.com/stellar/js-stellar-sdk/pulls/)): - * `num_contracts` - the integer quantity of contracts that hold this asset - * `contracts_amount` - the total units of that asset held by contracts - +- Asset stat records (`ServerApi.AssetRecord`) contain two new fields to support the Protocol 20 (Soroban) release ([#841](https://github.com/stellar/js-stellar-sdk/pull/841)): + * `num_contracts` - the integer quantity of contracts that hold this asset + * `contracts_amount` - the total units of that asset held by contracts +- New operation responses ([#TODO](https://github.com/stellar/js-stellar-sdk/pull/843)): + * `invokeHostFunction`: see `Horizon.InvokeHostFunctionOperationResponse` + * `bumpFootprintExpiration`: see `Horizon.BumpFootprintExpirationOperationResponse` + * `restoreFootprint`: see `Horizon.RestoreFootprintOperationResponse` + * You can refer to the actual definitions for details, but the gist of the schemas is below: +```ts +interface InvokeHostFunctionOperationResponse { + function: string; + parameters: { + value: string; + type: string; + }[]; + address: string; + salt: string; + asset_balance_changes: { + type: string; + from: string; + to: string; + amount: string; + }[]; +} +interface BumpFootprintExpirationOperationResponse { + ledgersToExpire: string; +} +interface RestoreFootprintOperationResponse {}; +``` ## [v11.0.0-beta.1](https://github.com/stellar/js-stellar-sdk/compare/v11.0.0-beta.0...v11.0.0-beta.1) From 479eb41935678d5c165cb738139030ea099b0957 Mon Sep 17 00:00:00 2001 From: George Kudrayvtsev Date: Wed, 12 Jul 2023 13:30:57 -0700 Subject: [PATCH 3/5] Fixup changelog link --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78450b238..27b519e71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ A breaking change will get clearly marked in this log. - Asset stat records (`ServerApi.AssetRecord`) contain two new fields to support the Protocol 20 (Soroban) release ([#841](https://github.com/stellar/js-stellar-sdk/pull/841)): * `num_contracts` - the integer quantity of contracts that hold this asset * `contracts_amount` - the total units of that asset held by contracts -- New operation responses ([#TODO](https://github.com/stellar/js-stellar-sdk/pull/843)): +- New operation responses ([#845](https://github.com/stellar/js-stellar-sdk/pull/845)): * `invokeHostFunction`: see `Horizon.InvokeHostFunctionOperationResponse` * `bumpFootprintExpiration`: see `Horizon.BumpFootprintExpirationOperationResponse` * `restoreFootprint`: see `Horizon.RestoreFootprintOperationResponse` @@ -37,6 +37,7 @@ interface BumpFootprintExpirationOperationResponse { interface RestoreFootprintOperationResponse {}; ``` + ## [v11.0.0-beta.1](https://github.com/stellar/js-stellar-sdk/compare/v11.0.0-beta.0...v11.0.0-beta.1) ### Update From b19ab71a907e314eaf3bb7a8604f7f1f366f8182 Mon Sep 17 00:00:00 2001 From: George Kudrayvtsev Date: Mon, 21 Aug 2023 12:42:15 -0700 Subject: [PATCH 4/5] Fixup interfaces based on later schema changes --- src/horizon_api.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/horizon_api.ts b/src/horizon_api.ts index 37cb23756..e3d471386 100644 --- a/src/horizon_api.ts +++ b/src/horizon_api.ts @@ -570,6 +570,10 @@ export namespace Horizon { } export interface BalanceChange { + asset_type: string; + asset_code?: string; + asset_issuer?: string; + type: string; from: string; to: string; @@ -596,7 +600,7 @@ export namespace Horizon { OperationResponseType.bumpFootprintExpiration, OperationResponseTypeI.bumpFootprintExpiration > { - ledgersToExpire: string; + ledgersToExpire: number; } export interface RestoreFootprintOperationResponse From 0e2d1dc2aa5506837951efcd6a60f1214962969b Mon Sep 17 00:00:00 2001 From: George Kudrayvtsev Date: Mon, 21 Aug 2023 12:44:14 -0700 Subject: [PATCH 5/5] Fixup field name to match json schema --- src/horizon_api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/horizon_api.ts b/src/horizon_api.ts index e3d471386..cb4116195 100644 --- a/src/horizon_api.ts +++ b/src/horizon_api.ts @@ -600,7 +600,7 @@ export namespace Horizon { OperationResponseType.bumpFootprintExpiration, OperationResponseTypeI.bumpFootprintExpiration > { - ledgersToExpire: number; + ledgers_to_expire: number; } export interface RestoreFootprintOperationResponse