stellar-sdk
Advanced tools
Comparing version 9.0.0-beta.0 to 9.0.0-beta.1
@@ -6,5 +6,20 @@ # Changelog | ||
## Unreleased | ||
## [v9.0.0-beta.1](https://github.com/stellar/js-stellar-sdk/compare/v9.0.0-beta.0...v9.0.0-beta.1) | ||
### Add | ||
- Add `/liquidity_pools/:id/trades` endpoint ([#710](https://github.com/stellar/js-stellar-sdk/pull/710)) | ||
### Updates | ||
- Updates the following SEP-10 utility functions to be compilant with the protocols ([#709](https://github.com/stellar/js-stellar-sdk/pull/709/), [stellar-protocol/#1036](https://github.com/stellar/stellar-protocol/pull/1036)) | ||
- Updated `utils.buildChallengeTx()` to accept muxed accounts (`M...`) for client account IDs | ||
- Updated `utils.buildChallengeTx()` to accept a `memo` parameter to attach to the challenge transaction | ||
- Updated `utils.readChallengeTx()` to provide a `memo` property in the returned object | ||
- Updated `utils.readChallengeTx()` to validate challenge transactions with muxed accounts (`M...`) as the client account ID | ||
### Fix | ||
- Drops the `chai-http` dependency to be only for developers ([#707](https://github.com/stellar/js-stellar-sdk/pull/707)). | ||
## [v9.0.0-beta.0](https://github.com/stellar/js-stellar-sdk/compare/v8.2.5...v9.0.0-beta.0) | ||
@@ -26,3 +41,3 @@ | ||
- 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}` | ||
* `/trades?trade_type={orderbook,liquidity_pools,all}`. By default, the filter is `all`, including both liquidity pool and orderbook records. | ||
* A liquidity pool trade contains the following fields: | ||
@@ -29,0 +44,0 @@ - `liquidity_pool_fee_bp`: LP fee expressed in basis points, and *either* |
@@ -11,2 +11,3 @@ /// <reference types="urijs" /> | ||
forAccount(accountId: string): this; | ||
forLiquidityPool(liquidityPoolId: string): this; | ||
} |
@@ -43,2 +43,5 @@ "use strict"; | ||
}; | ||
TradesCallBuilder.prototype.forLiquidityPool = function (liquidityPoolId) { | ||
return this.forEndpoint("liquidity_pools", liquidityPoolId); | ||
}; | ||
return TradesCallBuilder; | ||
@@ -45,0 +48,0 @@ }(call_builder_1.CallBuilder)); |
import { FeeBumpTransaction, Keypair, Transaction } from "stellar-base"; | ||
import { ServerApi } from "./server_api"; | ||
export declare namespace Utils { | ||
function buildChallengeTx(serverKeypair: Keypair, clientAccountID: string, homeDomain: string, timeout: number | undefined, networkPassphrase: string, webAuthDomain: string): string; | ||
function buildChallengeTx(serverKeypair: Keypair, clientAccountID: string, homeDomain: string, timeout: number | undefined, networkPassphrase: string, webAuthDomain: string, memo?: string | null): string; | ||
function readChallengeTx(challengeTx: string, serverAccountID: string, networkPassphrase: string, homeDomains: string | string[], webAuthDomain: string): { | ||
@@ -9,2 +9,3 @@ tx: Transaction; | ||
matchedHomeDomain: string; | ||
memo: string | null; | ||
}; | ||
@@ -11,0 +12,0 @@ function verifyChallengeTxThreshold(challengeTx: string, serverAccountID: string, networkPassphrase: string, threshold: number, signerSummary: ServerApi.AccountRecordSigners[], homeDomains: string | string[], webAuthDomain: string): string[]; |
@@ -11,6 +11,7 @@ "use strict"; | ||
(function (Utils) { | ||
function buildChallengeTx(serverKeypair, clientAccountID, homeDomain, timeout, networkPassphrase, webAuthDomain) { | ||
function buildChallengeTx(serverKeypair, clientAccountID, homeDomain, timeout, networkPassphrase, webAuthDomain, memo) { | ||
if (timeout === void 0) { timeout = 300; } | ||
if (clientAccountID.startsWith("M")) { | ||
throw Error("Invalid clientAccountID: multiplexed accounts are not supported."); | ||
if (memo === void 0) { memo = null; } | ||
if (clientAccountID.startsWith("M") && memo) { | ||
throw Error("memo cannot be used if clientAccountID is a muxed account"); | ||
} | ||
@@ -20,3 +21,3 @@ var account = new stellar_base_1.Account(serverKeypair.publicKey(), "-1"); | ||
var value = randombytes_1.default(48).toString("base64"); | ||
var transaction = new stellar_base_1.TransactionBuilder(account, { | ||
var builder = new stellar_base_1.TransactionBuilder(account, { | ||
fee: stellar_base_1.BASE_FEE, | ||
@@ -33,2 +34,3 @@ networkPassphrase: networkPassphrase, | ||
source: clientAccountID, | ||
withMuxing: true, | ||
})) | ||
@@ -39,4 +41,7 @@ .addOperation(stellar_base_1.Operation.manageData({ | ||
source: account.accountId(), | ||
})) | ||
.build(); | ||
})); | ||
if (memo) { | ||
builder.addMemo(stellar_base_1.Memo.id(memo)); | ||
} | ||
var transaction = builder.build(); | ||
transaction.sign(serverKeypair); | ||
@@ -54,4 +59,13 @@ return transaction | ||
} | ||
var transaction = stellar_base_1.TransactionBuilder.fromXDR(challengeTx, networkPassphrase); | ||
if (!(transaction instanceof stellar_base_1.Transaction)) { | ||
var transaction; | ||
try { | ||
transaction = new stellar_base_1.Transaction(challengeTx, networkPassphrase, true); | ||
} | ||
catch (_b) { | ||
try { | ||
transaction = new stellar_base_1.FeeBumpTransaction(challengeTx, networkPassphrase, true); | ||
} | ||
catch (_c) { | ||
throw new errors_1.InvalidSep10ChallengeError("Invalid challenge: unable to deserialize challengeTx transaction string"); | ||
} | ||
throw new errors_1.InvalidSep10ChallengeError("Invalid challenge: expected a Transaction but received a FeeBumpTransaction"); | ||
@@ -69,3 +83,3 @@ } | ||
} | ||
var _b = transaction.operations, operation = _b[0], subsequentOperations = _b.slice(1); | ||
var _d = transaction.operations, operation = _d[0], subsequentOperations = _d.slice(1); | ||
if (!operation.source) { | ||
@@ -75,2 +89,12 @@ throw new errors_1.InvalidSep10ChallengeError("The transaction's operation should contain a source account"); | ||
var clientAccountID = operation.source; | ||
var memo = null; | ||
if (transaction.memo.type !== stellar_base_1.MemoNone) { | ||
if (clientAccountID.startsWith("M")) { | ||
throw new errors_1.InvalidSep10ChallengeError("The transaction has a memo but the client account ID is a muxed account"); | ||
} | ||
if (transaction.memo.type !== stellar_base_1.MemoID) { | ||
throw new errors_1.InvalidSep10ChallengeError("The transaction's memo must be of type `id`"); | ||
} | ||
memo = transaction.memo.value; | ||
} | ||
if (operation.type !== "manageData") { | ||
@@ -133,3 +157,3 @@ throw new errors_1.InvalidSep10ChallengeError("The transaction's operation type should be 'manageData'"); | ||
} | ||
return { tx: transaction, clientAccountID: clientAccountID, matchedHomeDomain: matchedHomeDomain }; | ||
return { tx: transaction, clientAccountID: clientAccountID, matchedHomeDomain: matchedHomeDomain, memo: memo }; | ||
} | ||
@@ -136,0 +160,0 @@ Utils.readChallengeTx = readChallengeTx; |
{ | ||
"name": "stellar-sdk", | ||
"version": "9.0.0-beta.0", | ||
"version": "9.0.0-beta.1", | ||
"description": "stellar-sdk is a library for working with the Stellar Horizon server.", | ||
@@ -76,2 +76,3 @@ "main": "./lib/index.js", | ||
"chai-as-promised": "^5.2.0", | ||
"chai-http": "^4.3.0", | ||
"clear": "^0.1.0", | ||
@@ -136,3 +137,2 @@ "coveralls": "3.0.2", | ||
"bignumber.js": "^4.0.0", | ||
"chai-http": "^4.3.0", | ||
"detect-node": "^2.0.4", | ||
@@ -143,3 +143,3 @@ "es6-promise": "^4.2.4", | ||
"randombytes": "^2.1.0", | ||
"stellar-base": "^6.0.1", | ||
"stellar-base": "^6.0.3", | ||
"toml": "^2.3.0", | ||
@@ -146,0 +146,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
2531309
16
51883
70
- Removedchai-http@^4.3.0
- Removed@types/chai@4.3.20(transitive)
- Removed@types/cookiejar@2.1.5(transitive)
- Removed@types/superagent@4.1.13(transitive)
- Removedasap@2.0.6(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedcall-bind-apply-helpers@1.0.2(transitive)
- Removedcall-bound@1.0.3(transitive)
- Removedchai-http@4.4.0(transitive)
- Removedcharset@1.0.1(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcomponent-emitter@1.3.1(transitive)
- Removedcookiejar@2.1.4(transitive)
- Removeddebug@4.4.0(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removeddezalgo@1.0.4(transitive)
- Removeddunder-proto@1.0.1(transitive)
- Removedes-define-property@1.0.1(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-object-atoms@1.1.1(transitive)
- Removedes-set-tostringtag@2.1.0(transitive)
- Removedfast-safe-stringify@2.1.1(transitive)
- Removedform-data@4.0.2(transitive)
- Removedformidable@2.1.2(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.2.7(transitive)
- Removedget-proto@1.0.1(transitive)
- Removedgopd@1.2.0(transitive)
- Removedhas-symbols@1.1.0(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhexoid@1.0.0(transitive)
- Removedip-regex@2.1.0(transitive)
- Removedis-ip@2.0.0(transitive)
- Removedmath-intrinsics@1.1.0(transitive)
- Removedmethods@1.1.2(transitive)
- Removedmime@2.6.0(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedms@2.1.3(transitive)
- Removedobject-inspect@1.13.4(transitive)
- Removedonce@1.4.0(transitive)
- Removedqs@6.14.0(transitive)
- Removedsemver@7.7.1(transitive)
- Removedside-channel@1.1.0(transitive)
- Removedside-channel-list@1.0.0(transitive)
- Removedside-channel-map@1.0.1(transitive)
- Removedside-channel-weakmap@1.0.2(transitive)
- Removedsuperagent@8.1.2(transitive)
- Removedwrappy@1.0.2(transitive)
Updatedstellar-base@^6.0.3