stellar-sdk
Advanced tools
Comparing version 8.2.5 to 9.0.0
@@ -5,5 +5,85 @@ # Changelog | ||
## Unreleased | ||
## [v9.0.0-beta.0](https://github.com/stellar/js-stellar-sdk/compare/v8.2.5...v9.0.0-beta.0) | ||
This beta release adds **support for Automated Market Makers**. For details, you can refer to [CAP-38](https://stellar.org/protocol/cap-38) for XDR changes and [this document](https://docs.google.com/document/d/1pXL8kr1a2vfYSap9T67R-g72B_WWbaE1YsLMa04OgoU/view) for detailed changes to the Horizon API. | ||
### Add | ||
- Introduced a `LiquidityPoolCallBuilder` to make calls to a new endpoint: | ||
* `/liquidity_pools[?reserves=...]` - a collection of liquidity pools, optionally filtered by one or more assets ([#682](https://github.com/stellar/js-stellar-sdk/pull/682)) | ||
* `/liquidity_pools/:id` - a specific liquidity pool ([#687](https://github.com/stellar/js-stellar-sdk/pull/687)) | ||
- Expanded the `TransactionCallBuilder`, `OperationCallBuilder`, and `EffectsCallBuilder`s to apply to specific liquidity pools ([#689](https://github.com/stellar/js-stellar-sdk/pull/689)). This corresponds to the following new endpoints: | ||
* `/liquidity_pools/:id/transactions` | ||
* `/liquidity_pools/:id/operations` | ||
* `/liquidity_pools/:id/effects` | ||
- Expanded the `TradesCallBuilder` to support fetching liquidity pool trades and accepts a new `trade_type` filter ([#685](https://github.com/stellar/js-stellar-sdk/pull/685)): | ||
* `/trades?trade_type={orderbook,liquidity_pools}` | ||
* A liquidity pool trade contains the following fields: | ||
- `liquidity_pool_fee_bp`: LP fee expressed in basis points, and *either* | ||
- `base_liquidity_pool_id` or `counter_liquidity_pool_id` | ||
- Added new effects related to liquidity pools ([#690](https://github.com/stellar/js-stellar-sdk/pull/690)): | ||
* `DepositLiquidityEffect` | ||
* `WithdrawLiquidityEffect` | ||
* `LiquidityPoolTradeEffect` | ||
* `LiquidityPoolCreatedEffect` | ||
* `LiquidityPoolRemovedEffect` | ||
* `LiquidityPoolRevokedEffect` | ||
- Added new responses related to liquidity pool operations ([#692](https://github.com/stellar/js-stellar-sdk/pull/692)): | ||
* `DepositLiquidityOperationResponse` | ||
* `WithdrawLiquidityOperationResponse` | ||
### Updates | ||
- Updated the underlying `stellar-base` library to [v6.0.1](https://github.com/stellar/js-stellar-base/releases/tag/v6.0.1) to include CAP-38 changes ([#681](https://github.com/stellar/js-stellar-sdk/pull/681)). | ||
- Updated various developer dependencies to secure versions ([#671](https://github.com/stellar/js-stellar-sdk/pull/671)). | ||
- Updated `AccountResponse` to include liquidity pool shares in its `balances` field ([#688](https://github.com/stellar/js-stellar-sdk/pull/688)). | ||
- Updated `AccountCallBuilder` to allow filtering based on participation in a certain liquidity pool ([#688](https://github.com/stellar/js-stellar-sdk/pull/688)), corresponding to the following new filter: | ||
* `/accounts?reserves=[...list of assets...]` | ||
- Updated `RevokeSponsorshipOperationResponse` to contain an optional attribute `trustline_liquidity_pool_id`, for when a liquidity pool trustline is revoked ([#690](https://github.com/stellar/js-stellar-sdk/pull/690)). | ||
### Breaking changes | ||
- A `TradeRecord` can now correspond to two different types of trades and has changed ([#685](https://github.com/stellar/js-stellar-sdk/pull/685)): | ||
* `Orderbook` (the existing structure) | ||
- `counter_offer_id` and `base_offer_id` only show up in these records | ||
- the redundant `offer_id` field was removed; it matches `base_offer_id` | ||
* `LiquidityPool` (new) | ||
- `base_account` xor `counter_account` will appear in these records | ||
* `price` fields changed from `number`s to `string`s | ||
* The links to `base` and `counter` can now point to *either* an account or a liquidity pool | ||
- An account's `balances` array can now include a new type ([#688](https://github.com/stellar/js-stellar-sdk/pull/688)): | ||
* `asset_type` can now be `liquidity_pool_shares` | ||
* The following fields are *not* included in pool share balances: | ||
- `buying_liabilities` | ||
- `selling_liabilities` | ||
- `asset_code` | ||
- `asset_issue` | ||
- The `ChangeTrustOperationResponse` has changed ([#688](https://github.com/stellar/js-stellar-sdk/pull/688), [#692](https://github.com/stellar/js-stellar-sdk/pull/692)): | ||
* `asset_type` can now be `liquidity_pool_shares` | ||
* `asset_code`, `asset_issuer`, and `trustee` are now optional | ||
* `liquidity_pool_id` is a new optional field | ||
- The trustline effects (`TrustlineCreated`, `TrustlineUpdated`, `TrustlineRevoked`) have changed ([#690](https://github.com/stellar/js-stellar-sdk/pull/690)): | ||
* the asset type can now be `liquidity_pool_shares` | ||
* they can optionally include a `liquidity_pool_id` | ||
- Trustline sponsorship effects (`TrustlineSponsorshipCreated`, `TrustlineSponsorshipUpdated`, `TrustlineSponsorshipRemoved`) have been updated ([#690](https://github.com/stellar/js-stellar-sdk/pull/690)): | ||
* the `asset` field is now optional, and is replaced by | ||
* the `liquidity_pool_id` field for liquidity pools | ||
## [v8.2.5](https://github.com/stellar/js-stellar-sdk/compare/v8.2.4...v8.2.5) | ||
@@ -14,2 +94,3 @@ | ||
## [v8.2.4](https://github.com/stellar/js-stellar-sdk/compare/v8.2.3...v8.2.4) | ||
@@ -16,0 +97,0 @@ |
@@ -11,2 +11,3 @@ /// <reference types="urijs" /> | ||
sponsor(id: string): this; | ||
forLiquidityPool(id: string): this; | ||
} |
@@ -30,2 +30,6 @@ "use strict"; | ||
}; | ||
AccountCallBuilder.prototype.forLiquidityPool = function (id) { | ||
this.url.setQuery("liquidity_pool", id); | ||
return this; | ||
}; | ||
return AccountCallBuilder; | ||
@@ -32,0 +36,0 @@ }(call_builder_1.CallBuilder)); |
@@ -14,3 +14,4 @@ /// <reference types="eventsource" /> | ||
protected originalSegments: string[]; | ||
constructor(serverUrl: URI); | ||
protected neighborRoot: string; | ||
constructor(serverUrl: URI, neighborRoot?: string); | ||
call(): Promise<T>; | ||
@@ -22,2 +23,3 @@ stream(options?: EventSourceOptions<T>): () => void; | ||
join(include: "transactions"): this; | ||
protected forEndpoint(endpoint: string, param: string): this; | ||
private checkFilter; | ||
@@ -24,0 +26,0 @@ private _requestFnForLink; |
@@ -24,6 +24,8 @@ "use strict"; | ||
var CallBuilder = (function () { | ||
function CallBuilder(serverUrl) { | ||
function CallBuilder(serverUrl, neighborRoot) { | ||
if (neighborRoot === void 0) { neighborRoot = ""; } | ||
this.url = serverUrl.clone(); | ||
this.filter = []; | ||
this.originalSegments = this.url.segment() || []; | ||
this.neighborRoot = neighborRoot; | ||
} | ||
@@ -132,2 +134,9 @@ CallBuilder.prototype.call = function () { | ||
}; | ||
CallBuilder.prototype.forEndpoint = function (endpoint, param) { | ||
if (this.neighborRoot === "") { | ||
throw new Error("Invalid usage: neighborRoot not set in constructor"); | ||
} | ||
this.filter.push([endpoint, param, this.neighborRoot]); | ||
return this; | ||
}; | ||
CallBuilder.prototype.checkFilter = function () { | ||
@@ -134,0 +143,0 @@ if (this.filter.length >= 2) { |
@@ -10,2 +10,3 @@ /// <reference types="urijs" /> | ||
forOperation(operationId: string): this; | ||
forLiquidityPool(poolId: string): this; | ||
} |
@@ -9,3 +9,3 @@ "use strict"; | ||
function EffectCallBuilder(serverUrl) { | ||
var _this = _super.call(this, serverUrl) || this; | ||
var _this = _super.call(this, serverUrl, "effects") || this; | ||
_this.url.segment("effects"); | ||
@@ -15,21 +15,16 @@ return _this; | ||
EffectCallBuilder.prototype.forAccount = function (accountId) { | ||
this.filter.push(["accounts", accountId, "effects"]); | ||
return this; | ||
return this.forEndpoint("accounts", accountId); | ||
}; | ||
EffectCallBuilder.prototype.forLedger = function (sequence) { | ||
this.filter.push([ | ||
"ledgers", | ||
typeof sequence === "number" ? sequence.toString() : sequence, | ||
"effects", | ||
]); | ||
return this; | ||
return this.forEndpoint("ledgers", sequence.toString()); | ||
}; | ||
EffectCallBuilder.prototype.forTransaction = function (transactionId) { | ||
this.filter.push(["transactions", transactionId, "effects"]); | ||
return this; | ||
return this.forEndpoint("transactions", transactionId); | ||
}; | ||
EffectCallBuilder.prototype.forOperation = function (operationId) { | ||
this.filter.push(["operations", operationId, "effects"]); | ||
return this; | ||
return this.forEndpoint("operations", operationId); | ||
}; | ||
EffectCallBuilder.prototype.forLiquidityPool = function (poolId) { | ||
return this.forEndpoint("liquidity_pools", poolId); | ||
}; | ||
return EffectCallBuilder; | ||
@@ -36,0 +31,0 @@ }(call_builder_1.CallBuilder)); |
@@ -53,2 +53,13 @@ /// <reference types="node" /> | ||
} | ||
interface BalanceLineLiquidityPool { | ||
liquidity_pool_id: string; | ||
asset_type: AssetType.liquidityPoolShares; | ||
balance: string; | ||
limit: string; | ||
last_modified_ledger: number; | ||
is_authorized: boolean; | ||
is_authorized_to_maintain_liabilities: boolean; | ||
is_clawback_enabled: boolean; | ||
sponsor?: string; | ||
} | ||
interface BalanceLineAsset<T extends AssetType.credit4 | AssetType.credit12 = AssetType.credit4 | AssetType.credit12> { | ||
@@ -65,5 +76,6 @@ balance: string; | ||
is_authorized_to_maintain_liabilities: boolean; | ||
is_clawback_enabled: boolean; | ||
sponsor?: string; | ||
} | ||
type BalanceLine<T extends AssetType = AssetType> = T extends AssetType.native ? BalanceLineNative : T extends AssetType.credit4 | AssetType.credit12 ? BalanceLineAsset<T> : BalanceLineNative | BalanceLineAsset; | ||
type BalanceLine<T extends AssetType = AssetType> = T extends AssetType.native ? BalanceLineNative : T extends AssetType.credit4 | AssetType.credit12 ? BalanceLineAsset<T> : T extends AssetType.liquidityPoolShares ? BalanceLineLiquidityPool : BalanceLineNative | BalanceLineAsset | BalanceLineLiquidityPool; | ||
interface AssetAccounts { | ||
@@ -121,2 +133,5 @@ authorized: number; | ||
} | ||
enum LiquidityPoolType { | ||
constantProduct = "constant_product" | ||
} | ||
enum OperationResponseType { | ||
@@ -144,3 +159,5 @@ createAccount = "create_account", | ||
clawbackClaimableBalance = "clawback_claimable_balance", | ||
setTrustLineFlags = "set_trust_line_flags" | ||
setTrustLineFlags = "set_trust_line_flags", | ||
liquidityPoolDeposit = "liquidity_pool_deposit", | ||
liquidityPoolWithdraw = "liquidity_pool_withdraw" | ||
} | ||
@@ -169,3 +186,5 @@ enum OperationResponseTypeI { | ||
clawbackClaimableBalance = 20, | ||
setTrustLineFlags = 21 | ||
setTrustLineFlags = 21, | ||
liquidityPoolDeposit = 22, | ||
liquidityPoolWithdraw = 23 | ||
} | ||
@@ -268,6 +287,7 @@ interface BaseOperationResponse<T extends OperationResponseType = OperationResponseType, TI extends OperationResponseTypeI = OperationResponseTypeI> extends BaseResponse<"succeeds" | "precedes" | "effects" | "transaction"> { | ||
interface ChangeTrustOperationResponse extends BaseOperationResponse<OperationResponseType.changeTrust, OperationResponseTypeI.changeTrust> { | ||
asset_type: AssetType.credit4 | AssetType.credit12; | ||
asset_code: string; | ||
asset_issuer: string; | ||
trustee: string; | ||
asset_type: AssetType.credit4 | AssetType.credit12 | AssetType.liquidityPoolShares; | ||
asset_code?: string; | ||
asset_issuer?: string; | ||
liquidity_pool_id?: string; | ||
trustee?: string; | ||
trustor: string; | ||
@@ -332,2 +352,3 @@ limit: string; | ||
trustline_asset?: string; | ||
trustline_liquidity_pool_id?: string; | ||
signer_account_id?: string; | ||
@@ -354,2 +375,22 @@ signer_key?: string; | ||
} | ||
interface Reserve { | ||
asset: string; | ||
amount: string; | ||
} | ||
interface DepositLiquidityOperationResponse extends BaseOperationResponse<OperationResponseType.liquidityPoolDeposit, OperationResponseTypeI.liquidityPoolDeposit> { | ||
liquidity_pool_id: string; | ||
reserves_max: Reserve[]; | ||
min_price: string; | ||
min_price_r: PriceRShorthand; | ||
max_price: string; | ||
max_price_r: PriceRShorthand; | ||
reserves_deposited: Reserve[]; | ||
shares_received: string; | ||
} | ||
interface WithdrawLiquidityOperationResponse extends BaseOperationResponse<OperationResponseType.liquidityPoolWithdraw, OperationResponseTypeI.liquidityPoolWithdraw> { | ||
liquidity_pool_id: string; | ||
reserves_min: Reserve[]; | ||
shares: string; | ||
reserves_received: Reserve[]; | ||
} | ||
interface ResponseCollection<T extends BaseResponse = BaseResponse> { | ||
@@ -356,0 +397,0 @@ _links: { |
@@ -6,2 +6,6 @@ "use strict"; | ||
(function (Horizon) { | ||
var LiquidityPoolType; | ||
(function (LiquidityPoolType) { | ||
LiquidityPoolType["constantProduct"] = "constant_product"; | ||
})(LiquidityPoolType = Horizon.LiquidityPoolType || (Horizon.LiquidityPoolType = {})); | ||
var OperationResponseType; | ||
@@ -31,2 +35,4 @@ (function (OperationResponseType) { | ||
OperationResponseType["setTrustLineFlags"] = "set_trust_line_flags"; | ||
OperationResponseType["liquidityPoolDeposit"] = "liquidity_pool_deposit"; | ||
OperationResponseType["liquidityPoolWithdraw"] = "liquidity_pool_withdraw"; | ||
})(OperationResponseType = Horizon.OperationResponseType || (Horizon.OperationResponseType = {})); | ||
@@ -57,2 +63,4 @@ var OperationResponseTypeI; | ||
OperationResponseTypeI[OperationResponseTypeI["setTrustLineFlags"] = 21] = "setTrustLineFlags"; | ||
OperationResponseTypeI[OperationResponseTypeI["liquidityPoolDeposit"] = 22] = "liquidityPoolDeposit"; | ||
OperationResponseTypeI[OperationResponseTypeI["liquidityPoolWithdraw"] = 23] = "liquidityPoolWithdraw"; | ||
})(OperationResponseTypeI = Horizon.OperationResponseTypeI || (Horizon.OperationResponseTypeI = {})); | ||
@@ -59,0 +67,0 @@ var TransactionFailedResultCodes; |
@@ -9,3 +9,3 @@ "use strict"; | ||
function OfferCallBuilder(serverUrl) { | ||
var _this = _super.call(this, serverUrl) || this; | ||
var _this = _super.call(this, serverUrl, "offers") || this; | ||
_this.url.segment("offers"); | ||
@@ -20,4 +20,3 @@ return _this; | ||
OfferCallBuilder.prototype.forAccount = function (id) { | ||
this.filter.push(["accounts", id, "offers"]); | ||
return this; | ||
return this.forEndpoint("accounts", id); | ||
}; | ||
@@ -24,0 +23,0 @@ OfferCallBuilder.prototype.buying = function (asset) { |
@@ -11,3 +11,4 @@ /// <reference types="urijs" /> | ||
forTransaction(transactionId: string): this; | ||
forLiquidityPool(poolId: string): this; | ||
includeFailed(value: boolean): this; | ||
} |
@@ -9,3 +9,3 @@ "use strict"; | ||
function OperationCallBuilder(serverUrl) { | ||
var _this = _super.call(this, serverUrl) || this; | ||
var _this = _super.call(this, serverUrl, "operations") || this; | ||
_this.url.segment("operations"); | ||
@@ -20,21 +20,16 @@ return _this; | ||
OperationCallBuilder.prototype.forAccount = function (accountId) { | ||
this.filter.push(["accounts", accountId, "operations"]); | ||
return this; | ||
return this.forEndpoint("accounts", accountId); | ||
}; | ||
OperationCallBuilder.prototype.forClaimableBalance = function (claimableBalanceId) { | ||
this.filter.push(["claimable_balances", claimableBalanceId, "operations"]); | ||
return this; | ||
return this.forEndpoint("claimable_balances", claimableBalanceId); | ||
}; | ||
OperationCallBuilder.prototype.forLedger = function (sequence) { | ||
this.filter.push([ | ||
"ledgers", | ||
typeof sequence === "number" ? sequence.toString() : sequence, | ||
"operations", | ||
]); | ||
return this; | ||
return this.forEndpoint("ledgers", sequence.toString()); | ||
}; | ||
OperationCallBuilder.prototype.forTransaction = function (transactionId) { | ||
this.filter.push(["transactions", transactionId, "operations"]); | ||
return this; | ||
return this.forEndpoint("transactions", transactionId); | ||
}; | ||
OperationCallBuilder.prototype.forLiquidityPool = function (poolId) { | ||
return this.forEndpoint("liquidity_pools", poolId); | ||
}; | ||
OperationCallBuilder.prototype.includeFailed = function (value) { | ||
@@ -41,0 +36,0 @@ this.url.setQuery("include_failed", value.toString()); |
@@ -9,3 +9,3 @@ "use strict"; | ||
function PaymentCallBuilder(serverUrl) { | ||
var _this = _super.call(this, serverUrl) || this; | ||
var _this = _super.call(this, serverUrl, "payments") || this; | ||
_this.url.segment("payments"); | ||
@@ -15,16 +15,9 @@ return _this; | ||
PaymentCallBuilder.prototype.forAccount = function (accountId) { | ||
this.filter.push(["accounts", accountId, "payments"]); | ||
return this; | ||
return this.forEndpoint("accounts", accountId); | ||
}; | ||
PaymentCallBuilder.prototype.forLedger = function (sequence) { | ||
this.filter.push([ | ||
"ledgers", | ||
typeof sequence === "number" ? sequence.toString() : sequence, | ||
"payments", | ||
]); | ||
return this; | ||
return this.forEndpoint("ledgers", sequence.toString()); | ||
}; | ||
PaymentCallBuilder.prototype.forTransaction = function (transactionId) { | ||
this.filter.push(["transactions", transactionId, "payments"]); | ||
return this; | ||
return this.forEndpoint("transactions", transactionId); | ||
}; | ||
@@ -31,0 +24,0 @@ return PaymentCallBuilder; |
@@ -66,2 +66,19 @@ import { Asset } from "stellar-base"; | ||
} | ||
export interface LiquidityPoolRecord extends Horizon.BaseResponse { | ||
id: string; | ||
paging_token: string; | ||
fee_bp: number; | ||
type: Horizon.LiquidityPoolType; | ||
total_trustlines: string; | ||
total_shares: string; | ||
reserves: { | ||
amount: string; | ||
asset: string; | ||
}; | ||
} | ||
export enum TradeType { | ||
all = "all", | ||
liquidityPools = "liquidity_pools", | ||
orderbook = "orderbook" | ||
} | ||
interface EffectRecordMethods { | ||
@@ -144,24 +161,45 @@ operation?: CallFunction<OperationRecord>; | ||
export type OperationRecord = CreateAccountOperationRecord | PaymentOperationRecord | PathPaymentOperationRecord | ManageOfferOperationRecord | PassiveOfferOperationRecord | SetOptionsOperationRecord | ChangeTrustOperationRecord | AllowTrustOperationRecord | AccountMergeOperationRecord | InflationOperationRecord | ManageDataOperationRecord | BumpSequenceOperationRecord | PathPaymentStrictSendOperationRecord | CreateClaimableBalanceOperationRecord | ClaimClaimableBalanceOperationRecord | BeginSponsoringFutureReservesOperationRecord | EndSponsoringFutureReservesOperationRecord | RevokeSponsorshipOperationRecord; | ||
export interface TradeRecord extends Horizon.BaseResponse { | ||
id: string; | ||
paging_token: string; | ||
ledger_close_time: string; | ||
offer_id: string; | ||
base_offer_id: string; | ||
base_account: string; | ||
base_amount: string; | ||
base_asset_type: string; | ||
base_asset_code?: string; | ||
base_asset_issuer?: string; | ||
counter_offer_id: string; | ||
counter_account: string; | ||
counter_amount: string; | ||
counter_asset_type: string; | ||
counter_asset_code?: string; | ||
counter_asset_issuer?: string; | ||
base_is_seller: boolean; | ||
base: CallFunction<AccountRecord>; | ||
counter: CallFunction<AccountRecord>; | ||
operation: CallFunction<OperationRecord>; | ||
export namespace TradeRecord { | ||
interface Base extends Horizon.BaseResponse { | ||
id: string; | ||
paging_token: string; | ||
ledger_close_time: string; | ||
trade_type: TradeType; | ||
base_account?: string; | ||
base_amount: string; | ||
base_asset_type: string; | ||
base_asset_code?: string; | ||
base_asset_issuer?: string; | ||
counter_account?: string; | ||
counter_amount: string; | ||
counter_asset_type: string; | ||
counter_asset_code?: string; | ||
counter_asset_issuer?: string; | ||
base_is_seller: boolean; | ||
price?: { | ||
n: string; | ||
d: string; | ||
}; | ||
operation: CallFunction<OperationRecord>; | ||
} | ||
export interface Orderbook extends Base { | ||
trade_type: TradeType.orderbook; | ||
base_offer_id: string; | ||
base_account: string; | ||
counter_offer_id: string; | ||
counter_account: string; | ||
base: CallFunction<AccountRecord>; | ||
counter: CallFunction<AccountRecord>; | ||
} | ||
export interface LiquidityPool extends Base { | ||
trade_type: TradeType.liquidityPools; | ||
base_liquidity_pool_id?: string; | ||
counter_liquidity_pool_id?: string; | ||
liquidity_pool_fee_bp: number; | ||
base: CallFunction<AccountRecord | LiquidityPoolRecord>; | ||
counter: CallFunction<AccountRecord | LiquidityPoolRecord>; | ||
} | ||
export {}; | ||
} | ||
export type TradeRecord = TradeRecord.Orderbook | TradeRecord.LiquidityPool; | ||
export interface TransactionRecord extends Omit<Horizon.TransactionResponse, "ledger"> { | ||
@@ -168,0 +206,0 @@ ledger_attr: Horizon.TransactionResponse["ledger"]; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ServerApi = void 0; | ||
var ServerApi; | ||
(function (ServerApi) { | ||
var TradeType; | ||
(function (TradeType) { | ||
TradeType["all"] = "all"; | ||
TradeType["liquidityPools"] = "liquidity_pools"; | ||
TradeType["orderbook"] = "orderbook"; | ||
})(TradeType = ServerApi.TradeType || (ServerApi.TradeType = {})); | ||
})(ServerApi = exports.ServerApi || (exports.ServerApi = {})); | ||
//# sourceMappingURL=server_api.js.map |
@@ -11,2 +11,3 @@ import { Asset, FeeBumpTransaction, Transaction } from "stellar-base"; | ||
import { LedgerCallBuilder } from "./ledger_call_builder"; | ||
import { LiquidityPoolCallBuilder } from "./liquidity_pool_call_builder"; | ||
import { OfferCallBuilder } from "./offer_call_builder"; | ||
@@ -36,2 +37,3 @@ import { OperationCallBuilder } from "./operation_call_builder"; | ||
operations(): OperationCallBuilder; | ||
liquidityPools(): LiquidityPoolCallBuilder; | ||
strictReceivePaths(source: string | Asset[], destinationAsset: Asset, destinationAmount: string): PathCallBuilder; | ||
@@ -38,0 +40,0 @@ strictSendPaths(sourceAsset: Asset, sourceAmount: string, destination: string | Asset[]): PathCallBuilder; |
@@ -20,2 +20,3 @@ "use strict"; | ||
var ledger_call_builder_1 = require("./ledger_call_builder"); | ||
var liquidity_pool_call_builder_1 = require("./liquidity_pool_call_builder"); | ||
var offer_call_builder_1 = require("./offer_call_builder"); | ||
@@ -158,3 +159,16 @@ var operation_call_builder_1 = require("./operation_call_builder"); | ||
.offersClaimed() | ||
.map(function (offerClaimed) { | ||
.map(function (offerClaimedAtom) { | ||
var offerClaimed = offerClaimedAtom.value(); | ||
var sellerId = ""; | ||
switch (offerClaimedAtom.switch()) { | ||
case stellar_base_1.xdr.ClaimAtomType.claimAtomTypeV0(): | ||
sellerId = stellar_base_1.StrKey.encodeEd25519PublicKey(offerClaimed.sellerEd25519()); | ||
break; | ||
case stellar_base_1.xdr.ClaimAtomType.claimAtomTypeOrderBook(): | ||
sellerId = stellar_base_1.StrKey.encodeEd25519PublicKey(offerClaimed.sellerId().ed25519()); | ||
break; | ||
default: | ||
throw new Error("Invalid offer result type: " + | ||
offerClaimedAtom.switch()); | ||
} | ||
var claimedOfferAmountBought = new bignumber_js_1.default(offerClaimed.amountBought().toString()); | ||
@@ -177,3 +191,3 @@ var claimedOfferAmountSold = new bignumber_js_1.default(offerClaimed.amountSold().toString()); | ||
return { | ||
sellerId: stellar_base_1.StrKey.encodeEd25519PublicKey(offerClaimed.sellerId().ed25519()), | ||
sellerId: sellerId, | ||
offerId: offerClaimed.offerId().toString(), | ||
@@ -267,2 +281,5 @@ assetSold: assetSold, | ||
}; | ||
Server.prototype.liquidityPools = function () { | ||
return new liquidity_pool_call_builder_1.LiquidityPoolCallBuilder(urijs_1.default(this.serverURL)); | ||
}; | ||
Server.prototype.strictReceivePaths = function (source, destinationAsset, destinationAmount) { | ||
@@ -269,0 +286,0 @@ return new strict_receive_path_call_builder_1.StrictReceivePathCallBuilder(urijs_1.default(this.serverURL), source, destinationAsset, destinationAmount); |
@@ -9,3 +9,4 @@ /// <reference types="urijs" /> | ||
forOffer(offerId: string): this; | ||
forType(tradeType: ServerApi.TradeType): this; | ||
forAccount(accountId: string): this; | ||
} |
@@ -9,3 +9,3 @@ "use strict"; | ||
function TradesCallBuilder(serverUrl) { | ||
var _this = _super.call(this, serverUrl) || this; | ||
var _this = _super.call(this, serverUrl, "trades") || this; | ||
_this.url.segment("trades"); | ||
@@ -37,6 +37,9 @@ return _this; | ||
}; | ||
TradesCallBuilder.prototype.forAccount = function (accountId) { | ||
this.filter.push(["accounts", accountId, "trades"]); | ||
TradesCallBuilder.prototype.forType = function (tradeType) { | ||
this.url.setQuery("trade_type", tradeType); | ||
return this; | ||
}; | ||
TradesCallBuilder.prototype.forAccount = function (accountId) { | ||
return this.forEndpoint("accounts", accountId); | ||
}; | ||
return TradesCallBuilder; | ||
@@ -43,0 +46,0 @@ }(call_builder_1.CallBuilder)); |
@@ -10,3 +10,4 @@ /// <reference types="urijs" /> | ||
forLedger(sequence: number | string): this; | ||
forLiquidityPool(poolId: string): this; | ||
includeFailed(value: boolean): this; | ||
} |
@@ -9,3 +9,3 @@ "use strict"; | ||
function TransactionCallBuilder(serverUrl) { | ||
var _this = _super.call(this, serverUrl) || this; | ||
var _this = _super.call(this, serverUrl, "transactions") || this; | ||
_this.url.segment("transactions"); | ||
@@ -20,14 +20,13 @@ return _this; | ||
TransactionCallBuilder.prototype.forAccount = function (accountId) { | ||
this.filter.push(["accounts", accountId, "transactions"]); | ||
return this; | ||
return this.forEndpoint("accounts", accountId); | ||
}; | ||
TransactionCallBuilder.prototype.forClaimableBalance = function (claimableBalanceId) { | ||
this.filter.push(["claimable_balances", claimableBalanceId, "transactions"]); | ||
return this; | ||
return this.forEndpoint("claimable_balances", claimableBalanceId); | ||
}; | ||
TransactionCallBuilder.prototype.forLedger = function (sequence) { | ||
var ledgerSequence = typeof sequence === "number" ? sequence.toString() : sequence; | ||
this.filter.push(["ledgers", ledgerSequence, "transactions"]); | ||
return this; | ||
return this.forEndpoint("ledgers", sequence.toString()); | ||
}; | ||
TransactionCallBuilder.prototype.forLiquidityPool = function (poolId) { | ||
return this.forEndpoint("liquidity_pools", poolId); | ||
}; | ||
TransactionCallBuilder.prototype.includeFailed = function (value) { | ||
@@ -34,0 +33,0 @@ this.url.setQuery("include_failed", value.toString()); |
@@ -48,3 +48,9 @@ import { Horizon } from "./../horizon_api"; | ||
signer_sponsorship_removed = 74, | ||
claimable_balance_clawed_back = 80 | ||
claimable_balance_clawed_back = 80, | ||
liquidity_pool_deposited = 81, | ||
liquidity_pool_withdrew = 82, | ||
liquidity_pool_trade = 83, | ||
liquidity_pool_created = 84, | ||
liquidity_pool_removed = 85, | ||
liquidity_pool_revoked = 86 | ||
} | ||
@@ -119,2 +125,3 @@ export interface BaseEffectRecord extends Horizon.BaseResponse { | ||
limit: string; | ||
liquidity_pool_id?: string; | ||
} | ||
@@ -171,3 +178,4 @@ export interface TrustlineCreated extends TrustlineEvents { | ||
interface TrustlineSponsorshipEvents extends BaseEffectRecord, SponsershipFields { | ||
asset: string; | ||
asset?: string; | ||
liquidity_pool_id?: string; | ||
} | ||
@@ -219,2 +227,46 @@ export declare type TrustlineSponsorshipCreated = Omit<TrustlineSponsorshipEvents, "new_sponsor" | "former_sponsor"> & { | ||
}; | ||
export interface LiquidityPoolEffectRecord extends Horizon.BaseResponse { | ||
id: string; | ||
fee_bp: number; | ||
type: Horizon.LiquidityPoolType; | ||
total_trustlines: string; | ||
total_shares: string; | ||
reserves: Horizon.Reserve[]; | ||
} | ||
export interface DepositLiquidityEffect extends BaseEffectRecord { | ||
type_i: EffectType.liquidity_pool_deposited; | ||
liquidity_pool: LiquidityPoolEffectRecord; | ||
reserves_deposited: Horizon.Reserve[]; | ||
shares_received: string; | ||
} | ||
export interface WithdrawLiquidityEffect extends BaseEffectRecord { | ||
type_i: EffectType.liquidity_pool_withdrew; | ||
liquidity_pool: LiquidityPoolEffectRecord; | ||
reserves_received: Horizon.Reserve[]; | ||
shares_redeemed: string; | ||
} | ||
export interface LiquidityPoolTradeEffect extends BaseEffectRecord { | ||
type_i: EffectType.liquidity_pool_trade; | ||
liquidity_pool: LiquidityPoolEffectRecord; | ||
sold: Horizon.Reserve; | ||
bought: Horizon.Reserve; | ||
} | ||
export interface LiquidityPoolCreatedEffect extends BaseEffectRecord { | ||
type_i: EffectType.liquidity_pool_created; | ||
liquidity_pool: LiquidityPoolEffectRecord; | ||
} | ||
export interface LiquidityPoolRemovedEffect extends BaseEffectRecord { | ||
type_i: EffectType.liquidity_pool_removed; | ||
liquidity_pool_id: string; | ||
} | ||
export interface LiquidityPoolRevokedEffect extends BaseEffectRecord { | ||
type_i: EffectType.liquidity_pool_revoked; | ||
liquidity_pool: LiquidityPoolEffectRecord; | ||
reserves_revoked: [{ | ||
asset: string; | ||
amount: string; | ||
claimable_balance_id: string; | ||
}]; | ||
shares_revoked: string; | ||
} | ||
export {}; |
@@ -51,3 +51,9 @@ "use strict"; | ||
EffectType[EffectType["claimable_balance_clawed_back"] = 80] = "claimable_balance_clawed_back"; | ||
EffectType[EffectType["liquidity_pool_deposited"] = 81] = "liquidity_pool_deposited"; | ||
EffectType[EffectType["liquidity_pool_withdrew"] = 82] = "liquidity_pool_withdrew"; | ||
EffectType[EffectType["liquidity_pool_trade"] = 83] = "liquidity_pool_trade"; | ||
EffectType[EffectType["liquidity_pool_created"] = 84] = "liquidity_pool_created"; | ||
EffectType[EffectType["liquidity_pool_removed"] = 85] = "liquidity_pool_removed"; | ||
EffectType[EffectType["liquidity_pool_revoked"] = 86] = "liquidity_pool_revoked"; | ||
})(EffectType = exports.EffectType || (exports.EffectType = {})); | ||
//# sourceMappingURL=effects.js.map |
{ | ||
"name": "stellar-sdk", | ||
"version": "8.2.5", | ||
"version": "9.0.0", | ||
"description": "stellar-sdk is a library for working with the Stellar Horizon server.", | ||
@@ -135,8 +135,9 @@ "main": "./lib/index.js", | ||
"bignumber.js": "^4.0.0", | ||
"chai-http": "^4.3.0", | ||
"detect-node": "^2.0.4", | ||
"es6-promise": "^4.2.4", | ||
"eventsource": "^1.0.7", | ||
"lodash": "^4.17.11", | ||
"lodash": "^4.17.21", | ||
"randombytes": "^2.1.0", | ||
"stellar-base": "^5.3.2", | ||
"stellar-base": "^6.0.1", | ||
"toml": "^2.3.0", | ||
@@ -143,0 +144,0 @@ "tslib": "^1.10.0", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
112
2526279
17
51827
1
+ Addedchai-http@^4.3.0
+ Added@types/chai@4.3.20(transitive)
+ Added@types/cookiejar@2.1.5(transitive)
+ Added@types/superagent@4.1.13(transitive)
+ Addedasap@2.0.6(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedcall-bind-apply-helpers@1.0.2(transitive)
+ Addedcall-bound@1.0.3(transitive)
+ Addedchai-http@4.4.0(transitive)
+ Addedcharset@1.0.1(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedcomponent-emitter@1.3.1(transitive)
+ Addedcookiejar@2.1.4(transitive)
+ Addeddebug@4.4.0(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addeddezalgo@1.0.4(transitive)
+ Addeddunder-proto@1.0.1(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.1.1(transitive)
+ Addedes-set-tostringtag@2.1.0(transitive)
+ Addedfast-safe-stringify@2.1.1(transitive)
+ Addedform-data@4.0.2(transitive)
+ Addedformidable@2.1.2(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.7(transitive)
+ Addedget-proto@1.0.1(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhexoid@1.0.0(transitive)
+ Addedip-regex@2.1.0(transitive)
+ Addedis-ip@2.0.0(transitive)
+ Addedmath-intrinsics@1.1.0(transitive)
+ Addedmethods@1.1.2(transitive)
+ Addedmime@2.6.0(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedms@2.1.3(transitive)
+ Addedobject-inspect@1.13.4(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedqs@6.14.0(transitive)
+ Addedsemver@7.7.1(transitive)
+ Addedside-channel@1.1.0(transitive)
+ Addedside-channel-list@1.0.0(transitive)
+ Addedside-channel-map@1.0.1(transitive)
+ Addedside-channel-weakmap@1.0.2(transitive)
+ Addedstellar-base@6.0.6(transitive)
+ Addedsuperagent@8.1.2(transitive)
+ Addedwrappy@1.0.2(transitive)
- Removedstellar-base@5.3.2(transitive)
Updatedlodash@^4.17.21
Updatedstellar-base@^6.0.1