Skip to content

Commit

Permalink
Merge branch 'master' into soroban-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaptic committed Sep 15, 2023
2 parents 455fab8 + a32a450 commit 4a6cdc6
Show file tree
Hide file tree
Showing 9 changed files with 211 additions and 35 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/bundle_size.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Bundle Size

on:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16

# Workaround for some `yarn` nonsense, see:
# https://github.com/yarnpkg/yarn/issues/6312#issuecomment-429685210
- name: Install Dependencies
run: yarn install --network-concurrency 1

- name: Build All
run: yarn build:prod

- name: Report Bundle Size
uses: preactjs/compressed-size-action@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
pattern: "dist/*.js"
compression: "none"
70 changes: 57 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,61 @@ 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 ([#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 ([#845](https://github.com/stellar/js-stellar-sdk/pull/845)):
* `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 {};
```


### Breaking Changes

- Certain effects have been renamed to align better with the "tense" that other structures have ([#844](https://github.com/stellar/js-stellar-sdk/pull/844)):
* `DepositLiquidityEffect` -> `LiquidityPoolDeposited`
* `WithdrawLiquidityEffect` -> `LiquidityPoolWithdrew`
* `LiquidityPoolTradeEffect` -> `LiquidityPoolTrade`
* `LiquidityPoolCreatedEffect` -> `LiquidityPoolCreated`
* `LiquidityPoolRevokedEffect` -> `LiquidityPoolRevoked`
* `LiquidityPoolRemovedEffect` -> `LiquidityPoolRemoved`

### Add

- New effects have been added to support Protocol 20 (Soroban) ([#842](https://github.com/stellar/js-stellar-sdk/pull/842)):
* `ContractCredited` occurs when a Stellar asset moves **into** its corresponding Stellar Asset Contract instance
* `ContractDebited` occurs when a Stellar asset moves **out of** its corresponding Stellar Asset Contract instance
- 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
* `num_contracts` - the integer quantity of contracts that hold this asset
* `contracts_amount` - the total units of that asset held by contracts

### Fixed

- Some effect definitions that were missing have been added ([#842](https://github.com/stellar/js-stellar-sdk/pull/842)):
* `ClaimableBalanceClawedBack` is now defined
* `type EffectRecord` now has all of the effect types


## [v11.0.0-beta.1](https://github.com/stellar/js-stellar-sdk/compare/v11.0.0-beta.0...v11.0.0-beta.1)
Expand All @@ -27,7 +79,6 @@ This version is marked by a major version bump because of the significant upgrad
### Update

- Build system has been overhauled to support Webpack 5 ([#814](https://github.com/stellar/js-stellar-sdk/pull/814)).

- `stellar-base` has been updated to its corresponding overhaul ([#818](https://github.com/stellar/js-stellar-sdk/pull/818)).

### Fix
Expand All @@ -47,7 +98,6 @@ This version is marked by a major version bump because of the significant upgrad
### Add

- Add [SEP-1](https://stellar.org/protocol/sep-1) fields to `StellarTomlResolver` for type checks ([#794](https://github.com/stellar/js-stellar-sdk/pull/794)).

- Add support for passing `X-Auth-Token` as a custom header ([#795](https://github.com/stellar/js-stellar-sdk/pull/795)).

### Update
Expand Down Expand Up @@ -89,7 +139,6 @@ This version is marked by a major version bump because of the significant upgrad
### Fix

- Reverts a change from [v10.1.0](#v10.1.0) which caused streams to die prematurely ([#780](https://github.com/stellar/js-stellar-sdk/pull/780)).

- Bumps `stellar-base` version to [v8.0.1](https://github.com/stellar/js-stellar-base/releases/tag/v8.0.1) to include latest bugfixes.


Expand All @@ -107,17 +156,14 @@ This is a promotion from the beta version without changes, besides upgrading the
### Add

- Support for Protocol 19 ([#775](https://github.com/stellar/js-stellar-sdk/pull/775)):

* new precondition fields on a `TransactionResponse`
* new account fields on `AccountResponse` and `AccountRecord`
* bumping `stellar-base` to the latest beta version

### Fix

- Add missing field to account responses: `last_modified_time` which is the time equivalent of the existing `last_modified_ledger` ([#770](https://github.com/stellar/js-stellar-sdk/pull/770)).

- Stop opening extra connections when SSE streams receive `event: close` events ([#772](https://github.com/stellar/js-stellar-sdk/pull/772)).

- Fix SSE streams not loading under React Native (thank you, @hunterpetersen!) ([#761](https://github.com/stellar/js-stellar-sdk/pull/761)).


Expand All @@ -126,16 +172,14 @@ This is a promotion from the beta version without changes, besides upgrading the
### Fix

- Add missing fields to the `LedgerRecord`: `successful_transaction_count` and `failed_transaction_count` ([#740](https://github.com/stellar/js-stellar-sdk/pull/740)). Note that this also marks several fields as _deprecated_ because they don't actually exist in the Horizon API response:

- `transaction_count`: superceded by the sum of the aforementioned fields
- `base_fee`: superceded by the `base_fee_in_stroops` field
- `base_reserve`: superceded by the `base_reserve_in_stroops` field
* `transaction_count`: superceded by the sum of the aforementioned fields
* `base_fee`: superceded by the `base_fee_in_stroops` field
* `base_reserve`: superceded by the `base_reserve_in_stroops` field

These deprecated fields will be removed in the next major version. It's unlikely that this breaking change should affect anyone, as these fields have likely been missing/invalid for some time.

### Update
- Update a number of dependencies that needed various security updates:

* several dependencies bumped their patch version ([#736](https://github.com/stellar/js-stellar-sdk/pull/736), [#684](https://github.com/stellar/js-stellar-sdk/pull/684), [#672](https://github.com/stellar/js-stellar-sdk/pull/672), [#666](https://github.com/stellar/js-stellar-sdk/pull/666), [#644](https://github.com/stellar/js-stellar-sdk/pull/644), [#622](https://github.com/stellar/js-stellar-sdk/pull/622))
* axios has been bumped to 0.25.0 without causing breaking changes ([#742](https://github.com/stellar/js-stellar-sdk/pull/742))
* the `karma` suite of packages has been updated to the latest major version ([#743](https://github.com/stellar/js-stellar-sdk/pull/743))
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const server = new StellarSdk.Server('https://horizon-testnet.stellar.org');
console.log('\nSuccess! View the transaction at: ');
console.log(transactionResult._links.transaction.href);
} catch (e) {
console.log('An error has occured:');
console.log('An error has occurred:');
console.log(e);
}
})();
Expand Down
46 changes: 46 additions & 0 deletions src/horizon/horizon_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -563,6 +569,46 @@ export namespace Horizon {
reserves_received: Reserve[];
}

export interface BalanceChange {
asset_type: string;
asset_code?: string;
asset_issuer?: string;

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
> {
ledgers_to_expire: number;
}

export interface RestoreFootprintOperationResponse
extends BaseOperationResponse<
OperationResponseType.restoreFootprint,
OperationResponseTypeI.restoreFootprint
> {};

export interface ResponseCollection<T extends BaseResponse = BaseResponse> {
_links: {
self: ResponseLink;
Expand Down
74 changes: 65 additions & 9 deletions src/horizon/server_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ export namespace ServerApi {
| Effects.SignerSponsorshipCreated
| Effects.SignerSponsorshipUpdated
| Effects.SignerSponsorshipRemoved
| Effects.DepositLiquidityEffect
| Effects.WithdrawLiquidityEffect
| Effects.LiquidityPoolCreatedEffect
| Effects.LiquidityPoolRemovedEffect
| Effects.LiquidityPoolRevokedEffect
| Effects.LiquidityPoolTradeEffect
| Effects.ContractCreditedEffect
| Effects.ContractDebitedEffect
| Effects.LiquidityPoolDeposited
| Effects.LiquidityPoolWithdrew
| Effects.LiquidityPoolCreated
| Effects.LiquidityPoolRemoved
| Effects.LiquidityPoolRevoked
| Effects.LiquidityPoolTrade
| Effects.ContractCredited
| Effects.ContractDebited
| Trade;

export type EffectRecord = BaseEffectRecordFromTypes & EffectRecordMethods;
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down
16 changes: 8 additions & 8 deletions src/horizon/types/effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,33 +275,33 @@ export interface LiquidityPoolEffectRecord extends Horizon.BaseResponse {
total_shares: string;
reserves: Horizon.Reserve[];
}
export interface DepositLiquidityEffect extends BaseEffectRecord {
export interface LiquidityPoolDeposited extends BaseEffectRecord {
type_i: EffectType.liquidity_pool_deposited;
liquidity_pool: LiquidityPoolEffectRecord;
reserves_deposited: Horizon.Reserve[];
shares_received: string;
}
export interface WithdrawLiquidityEffect extends BaseEffectRecord {
export interface LiquidityPoolWithdrew extends BaseEffectRecord {
type_i: EffectType.liquidity_pool_withdrew;
liquidity_pool: LiquidityPoolEffectRecord;
reserves_received: Horizon.Reserve[];
shares_redeemed: string;
}
export interface LiquidityPoolTradeEffect extends BaseEffectRecord {
export interface LiquidityPoolTrade extends BaseEffectRecord {
type_i: EffectType.liquidity_pool_trade;
liquidity_pool: LiquidityPoolEffectRecord;
sold: Horizon.Reserve;
bought: Horizon.Reserve;
}
export interface LiquidityPoolCreatedEffect extends BaseEffectRecord {
export interface LiquidityPoolCreated extends BaseEffectRecord {
type_i: EffectType.liquidity_pool_created;
liquidity_pool: LiquidityPoolEffectRecord;
}
export interface LiquidityPoolRemovedEffect extends BaseEffectRecord {
export interface LiquidityPoolRemoved extends BaseEffectRecord {
type_i: EffectType.liquidity_pool_removed;
liquidity_pool_id: string;
}
export interface LiquidityPoolRevokedEffect extends BaseEffectRecord {
export interface LiquidityPoolRevoked extends BaseEffectRecord {
type_i: EffectType.liquidity_pool_revoked;
liquidity_pool: LiquidityPoolEffectRecord;
reserves_revoked: [
Expand All @@ -314,12 +314,12 @@ export interface LiquidityPoolRevokedEffect extends BaseEffectRecord {
shares_revoked: string;
}

export interface ContractCreditedEffect extends BaseEffectRecord, OfferAsset {
export interface ContractCredited extends BaseEffectRecord, OfferAsset {
type_i: EffectType.contract_credited;
contract: string;
amount: string;
}
export interface ContractDebitedEffect extends BaseEffectRecord, OfferAsset {
export interface ContractDebited extends BaseEffectRecord, OfferAsset {
type_i: EffectType.contract_debited;
contract: string;
amount: string;
Expand Down
2 changes: 1 addition & 1 deletion test/unit/horizon_axios_client_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe("getCurrentServerTime", () => {
clock.restore();
});

it("returns null when the hostname hasnt been hit", () => {
it("returns null when the hostname hasn't been hit", () => {
expect(getCurrentServerTime("host")).to.be.null;
});

Expand Down
Loading

0 comments on commit 4a6cdc6

Please sign in to comment.