Releases: stellar/js-stellar-sdk
v13.2.0
v13.2.0
Added
- Support passing in an optional
options.addressto thecontract.Client.deploymethod (#1158).
Fixed
- Extend support for parsing contract specifications in environments that don't have WebAssembly compilers (#1157).
- Add missing
to_muxedandto_muxed_idto Horizon’sPaymentOperationResponse(#1149). - Upgrade
@stellar/stellar-basedependency to latest version (#1159).
Contributors
@chadoh @kknownymouss @jeesunikim @kalepail @Shaptic
Full Changelog: v13.1.0...v13.2.0
v13.1.0
v13.1.0
Added
- Added
Horizon.Server.rootto obtain information from the Horizon root endpoint (#1122).
Fixed
- When using a friendbot that points to a Horizon instance that has ledger metadata disabled, you can no longer extract the account sequence from the response. Instead, we hit RPC directly (#1107).
rpc.Server.getEvents()now correctly returns thecursorfield at the top-level response (#1124).
Contributors
Full Changelog: v13.0.0...v13.1.0
v13.0.0
v13.0.0: Protocol 22
This is a direct re-tag of rc.2 with the only change being an upgrade to the stellar-base library to incorporate a patch release. Nonetheless, the entire changelog from the prior major version here is replicated for a comprehensive view on what's broken, added, and fixed.
Breaking Changes
- We stopped supporting Node 18 explicitly a while ago, but now the Babelification of the codebase will transform to Node 18 instead of 16.
TypeScript Bindings: the contract module.
contract.AssembledTransaction#signAuthEntriesnow takes anaddressinstead of apublicKey. This brings the API more inline with its actual functionality: It can be used to sign all the auth entries for a particular address, whether that is the address of an account (public key) or a contract. (#1044).- The
ClientOptions.signTransactiontype has been updated to reflect the latest SEP-43 protocol, which matches the latest major version of Freighter and other wallets. It now acceptsaddress,submit, andsubmitUrloptions, and it returns a promise containing thesignedTxXdrand thesignerAddress. It now also returns anErrortype if an error occurs during signing.basicNodeSignerhas been updated to reflect this new type.
ClientOptions.signAuthEntrytype has been updated to reflect the SEP-43 protocol, which returns a promise containing thesignerAddressin addition to thesignAuthEntrythat was returned previously. It also can return anErrortype.SentTransaction.initandnew SentTransactionnow take one (1) argument instead of two (2). The first argument had previously been deprecated and ignored. To update:
-SentTransaction(nonsense, realStuff)
+SentTransaction(realStuff)
-new SentTransaction(nonsense, realStuff)
+new SentTransaction(realStuff)Server APIs: the rpc and Horizon modules.
- Deprecated RPC APIs have been removed (#1084):
simulateTransaction'scostfield is removedrpc.Server.getEvents'spagingTokenfield is deprecated, usecursorinstead
- Deprecated Horizon APIs have been removed (deprecated since v10.0.1, ):
- removed fields
transaction_count,base_fee, andbase_reserve - removed fields
num_accountsandamountfrom assets
- removed fields
- The
SorobanRpcimport, previously deprecated, has been removed. You can importrpcinstead:
-import { SorobanRpc } from '@stellar/stellar-sdk'
+import { rpc } from '@stellar/stellar-sdk'
// alternatively, you can also import from the `rpc` entrypoint:
import { Server } from '@stellar/stellar-sdk/rpc'Added
TypeScript Bindings: the contract module.
contract.Clientnow has a staticdeploymethod that can be used to deploy a contract instance from an existing uploaded/"installed" Wasm hash. The first arguments to this method are the arguments for the contract's__constructormethod in accordance with CAP-42 (#1086). For example, using theincrementtest contract as modified in https://github.com/stellar/soroban-test-examples/pull/2/files#diff-8734809100be3803c3ce38064730b4578074d7c2dc5fb7c05ca802b2248b18afR10-R45:
const tx = await contract.Client.deploy(
{ counter: 42 },
{
networkPassphrase,
rpcUrl,
wasmHash: uploadedWasmHash,
publicKey: someKeypair.publicKey(),
...basicNodeSigner(someKeypair, networkPassphrase),
},
);
const { result: client } = await tx.signAndSend();
const t = await client.get();
expect(t.result, 42);contract.AssembledTransaction#signAuthEntriesnow allows you to overrideauthorizeEntry. This can be used to streamline novel workflows using cross-contract auth. (#1044).
Server modules: the rpc, Horizon, and stellartoml modules.
Horizon.ServerApinow has anEffectTypeexported so that you can compare and infer effect types directly (#1099).Horizon.ServerApi.Tradetype now has atype_ifield for type inference (#1099).- All effects now expose their type as an exact string (#947).
stellartoml.Resolver.resolvenow has aallowedRedirectsoption to configure the number of allowed redirects to follow when resolving a stellar toml file.rpc.Server.getEventsnow returns acursorfield that matchespagingTokenandidrpc.Server.getTransactionsnow returns atxHashfieldrpc.Serverhas two new methods:
export interface BalanceResponse {
latestLedger: number;
/** present only on success, otherwise request malformed or no balance */
balanceEntry?: {
/** a 64-bit integer */
amount: string;
authorized: boolean;
clawback: boolean;
lastModifiedLedgerSeq?: number;
liveUntilLedgerSeq?: number;
};
}New bundles without dependencies
- You can now build the browser bundle without various dependencies:
- Set
USE_AXIOS=falseto build without theaxiosdependency: this will buildstellar-sdk-no-axios.jsandstellar-sdk-no-axios.min.jsin thedist/directory, or just runyarn build:browser:no-axiosto generate these files. - You can import Node packages without the
axiosdependency via@stellar/stellar-sdk/no-axios. For Node environments that don't support modern imports, use@stellar/stellar-sdk/lib/no-axios/index. - Set
USE_EVENTSOURCE=falseto build without theeventsourcedependency: this will buildstellar-sdk-no-eventsource.jsandstellar-sdk-no-eventsource.min.jsin thedist/directory, or just runyarn build:browser:no-eventsourceto generate these files. - You can import Node packages without the
eventsourcedependency via@stellar/stellar-sdk/no-eventsource. For Node.js environments that don't support modern imports, use@stellar/stellar-sdk/lib/no-eventsource/index. - To use a minimal build without both Axios and EventSource, use
stellar-sdk-minimal.jsfor the browser build and import from@stellar/stellar-sdk/minimalfor the Node package.
- Set
Fixed
contract.AssembledTransaction#nonInvokerSigningBynow correctly returns contract addresses, in instances of cross-contract auth, rather than throwing an error.signwill ignore these contract addresses, since auth happens via cross-contract call (#1044).buildInvocationTreenow correctly handles V2 contract creation and displays constructor args (js-stellar-base#785).
v13.0.0-rc.2
v13.0.0-rc.2
Breaking Changes
- The
ClientOptions.signTransactiontype has been updated to reflect the latest SEP-43 protocol, which matches the latest major version of Freighter and other wallets. It now acceptsaddress,submit, andsubmitUrloptions, and it returns a promise containing thesignedTxXdrand thesignerAddress. It now also returns anErrortype if an error occurs during signing.basicNodeSignerhas been updated to reflect the new type.
ClientOptions.signAuthEntrytype has also been updated to reflect the SEP-43 protocol, which also returns a promise containing thesignerAddressin addition to thesignAuthEntrythat was returned previously. It also can return anErrortype.
Added
contract.Clientnow has a staticdeploymethod that can be used to deploy a contract instance from an existing uploaded/"installed" Wasm hash. The first arguments to this method are the arguments for the contract's__constructormethod in accordance with CAP-42 (#1086).
For example, using the increment test contract as modified in https://github.com/stellar/soroban-test-examples/pull/2/files#diff-8734809100be3803c3ce38064730b4578074d7c2dc5fb7c05ca802b2248b18afR10-R45:
const tx = await contract.Client.deploy(
{ counter: 42 },
{
networkPassphrase,
rpcUrl,
wasmHash: uploadedWasmHash,
publicKey: someKeypair.publicKey(),
...basicNodeSigner(someKeypair, networkPassphrase),
},
);
const { result: client } = await tx.signAndSend();
const t = await client.get();
expect(t.result, 42);Horizon.ServerApinow has anEffectTypeexported so that you can compare and infer effect types directly (#1099).Horizon.ServerApi.Tradetype now has atype_ifield for type inference.- All effects now expose their type as an exact string (#947).
stellartoml-Resolver.resolvenow has aallowedRedirectsoption to configure the number of allowed redirects to follow when resolving a stellar toml file.
v13.0.0-rc.1
v13.0.0-rc.1: Protocol 22
Breaking Changes
-
Deprecated RPC APIs have been removed (#1084):
simulateTransaction'scostfield is removedgetEventsreturns acursorfield that matchespagingTokenandidgetTransactionsreturns atxHashfield
-
Horizon Server API types: removed fields
transaction_count,base_fee, andbase_reserve(deprecated since v10.0.1) -
SentTransaction.initandnew SentTransactionnow take one (1) argument instead of two (2). The first argument had previously been deprecated and ignored. To update:-SentTransaction(nonsense, realStuff) +SentTransaction(realStuff) -new SentTransaction(nonsense, realStuff) +new SentTransaction(realStuff)
-
SorobanRpcimport, previously deprecated, has been removed. You can importrpcinstead:-import { SorobanRpc } from '@stellar/stellar-sdk' +import { rpc } from '@stellar/stellar-sdk'
As an alternative, you can also import from the
rpcentrypoint:import { Server } from '@stellar/stellar-sdk/rpc'
Added
rpc.Servernow has apollTransactionmethod to retry transaction retrieval (#1092).
Full Changelog: v13.0.0-beta.1...v13.0.0-rc.1
v13.0.0-beta.1: Protocol 22
v13.0.0-beta.1
This is the first release that supports Protocol 22. While the network has not upgraded yet, you can start integrating the new features into your codebase if you want a head start. Keep in mind that while the binary XDR is backwards-compatible, the naming and layout of structures is not. In other words, this build will continue to work on Protocol 21, but you may have to update code that references XDR directly.
Breaking Changes
contract.AssembledTransaction#signAuthEntriesnow takes anaddressinstead of apublicKey. This brings the API more inline with its actual functionality: It can be used to sign all the auth entries for a particular address, whether that is the address of an account (public key) or a contract. (#1044).- The Node.js code will now Babelify to Node 18 instead of Node 16, but we stopped supporting Node 16 long ago so this shouldn't be a breaking change.
Added
- You can now build the browser bundle without various dependencies:
- Set
USE_AXIOS=falseto build without theaxiosdependency: this will buildstellar-sdk-no-axios.jsandstellar-sdk-no-axios.min.jsin thedist/directory, or just runyarn build:browser:no-axiosto generate these files. - You can import Node packages without the
axiosdependency via@stellar/stellar-sdk/no-axios. For Node environments that don't support modern imports, use@stellar/stellar-sdk/lib/no-axios/index. - Set
USE_EVENTSOURCE=falseto build without theeventsourcedependency: this will buildstellar-sdk-no-eventsource.jsandstellar-sdk-no-eventsource.min.jsin thedist/directory, or just runyarn build:browser:no-eventsourceto generate these files. - You can import Node packages without the
eventsourcedependency via@stellar/stellar-sdk/no-eventsource. For Node.js environments that don't support modern imports, use@stellar/stellar-sdk/lib/no-eventsource/index. - To use a minimal build without both Axios and EventSource, use
stellar-sdk-minimal.jsfor the browser build and import from@stellar/stellar-sdk/minimalfor the Node package.
- Set
contract.AssembledTransaction#signAuthEntriesnow allows you to overrideauthorizeEntry. This can be used to streamline novel workflows using cross-contract auth. (#1044)rpc.Servernow has agetSACBalancehelper which lets you fetch the balance of a built-in Stellar Asset Contract token held by a contract (#1046):
export interface BalanceResponse {
latestLedger: number;
/** present only on success, otherwise request malformed or no balance */
balanceEntry?: {
/** a 64-bit integer */
amount: string;
authorized: boolean;
clawback: boolean;
lastModifiedLedgerSeq?: number;
liveUntilLedgerSeq?: number;
};
}Fixed
contract.AssembledTransaction#nonInvokerSigningBynow correctly returns contract addresses, in instances of cross-contract auth, rather than throwing an error.signwill ignore these contract addresses, since auth happens via cross-contract call (#1044).
Contributors
@Shaptic @psheth9 @BlaineHeffron @chadoh
New Contributors
- @ElliotFriend made their first contribution in #965
- @omahs made their first contribution in #1069
Full Changelog: v12.3.0...v13.0.0-beta.1
v12.3.0
Added
rpc.Servernow has agetTransactions, which has the same response schema asgetTransactionsexcept with bundles of transactions (#1037).rpc.Servernow has agetVersionInfomethod which reports version information of the RPC instance it is connected to (#1028):
export interface GetVersionInfoResponse {
version: string;
commit_hash: string;
build_time_stamp: string;
captive_core_version: string;
protocol_version: number;
}Fixed
- Lower authorization entry's default signature expiration to ~8min for security reasons (#1023).
- Remove
statusTexterror check to broaden compatibility (#1001). - Upgraded
stellar-basewhich includes various fixes (release notes, #1045).
Contributors
@Shaptic @chadoh @aditya1702 @psheth9
New Contributors
- @jeesunikim made their first contribution in #1025
- @cah4a made their first contribution in #1001
Full Changelog: v12.2.0...v12.3.0
v12.2.0
Fixed
@stellar/stellar-baseand its underlying dependency@stellar/js-xdrhave been upgraded to their latest versions; reference their release notes (v12.1.0 and v3.1.2, respectively) for details (#1013).
Added
- You can now pass custom headers to both
rpc.ServerandHorizon.Server(#1013):
import { Server } from "@stellar/stellar-sdk/rpc";
const s = new Server("<some URL>", { headers: { "X-Custom-Header": "hello" }})Horizon.Servernow supports the newPOST /transactions_asyncendpoint via thesubmitAsyncTransactionmethod (#989). Its purpose is to provide an immediate response to the submission rather than waiting for Horizon to determine its status. The response schema is as follows:
interface SubmitAsyncTransactionResponse {
// the submitted transaction hash
hash: string;
// one of "PENDING", "DUPLICATE", "TRY_AGAIN_LATER", or "ERROR"
tx_status: string;
// a base64-encoded xdr.TransactionResult iff `tx_status` is "ERROR"
error_result_xdr: string;
}rpc.Servernow has agetFeeStatsmethod which retrieves fee statistics for a previous chunk of ledgers to provide users with a way to provide informed decisions about getting their transactions included in the following ledgers (#998):
export interface GetFeeStatsResponse {
sorobanInclusionFee: FeeDistribution;
inclusionFee: FeeDistribution;
latestLedger: number; // uint32
}
interface FeeDistribution {
max: string; // uint64
min: string; // uint64
mode: string; // uint64
p10: string; // uint64
p20: string; // uint64
p30: string; // uint64
p40: string; // uint64
p50: string; // uint64
p60: string; // uint64
p70: string; // uint64
p80: string; // uint64
p90: string; // uint64
p95: string; // uint64
p99: string; // uint64
transactionCount: string; // uint32
ledgerCount: number; // uint32
}New Contributors
- @celestialkylin made their first contribution in #988
- @aditya1702 made their first contribution in #989
- @kanwalpreetd made their first contribution in #1008
Full Changelog: v12.1.0...v12.2.0
v12.1.0
v12.1.0
Added
contractnow exports theDEFAULT_TIMEOUT(#984).contract.AssembledTransactionnow has:toXDRandfromXDRmethods for serializing the transaction to and from XDR. These methods should be used in place ofAssembledTransaction.toJSONandAssembledTransaction.fromJSONfor multi-auth signing. The JSON methods are now deprecated. Note: you must now callsimulateon the transaction before the finalsignAndSendcall after all required signatures are gathered when using the XDR methods (#977).- a
restoreFootprintmethod which accepts therestorePreamblereturned when a simulation call fails due to some contract state that has expired. When invoking a contract function, one can now setrestoretotruein theMethodOptions. When enabled, arestoreFootprinttransaction will be created and await signing when required (#991). - separate
signandsendmethods so that you can sign a transaction without sending it (signAndSendstill works as before; #922).
contract.Clientnow has atxFromXDRmethod which should be used in place oftxFromJSONfor multi-auth signing (#977).
Deprecated
- In
contract.AssembledTransaction,toJSONandfromJSONshould be replaced withtoXDRandfromXDR. - In
contract.Client,txFromJSONshould be replaced withtxFromXDR.
Fixed
- If you edit an
AssembledTransactionwithtx.raw = cloneFrom(tx.build), thetx.simulationDatawill now be updated correctly (#985).
v12.0.1
v12.0.1: Protocol 21 Stable Release
This update supports Protocol 21. It is an additive change to the protocol so there are no binary (i.e. XDR-level) incompatibilities, but your software may break if you encounter new unexpected or renamed fields from this Protocol (#949).
The following changelog is a concatenation of all of the RCs since the previous stable release and includes one additional added feature.
Breaking Changes
- The default timeout for transaction calls is now set to 300 seconds (5 minutes) when using
ContractClientfrom the previous default of 10 seconds. 10 seconds is often not enough time to review transactions before signing, especially in Freighter or using a hardware wallet like a Ledger, which would cause atxTooLateerror response from the server. Five minutes is also the value used by the CLI, so this brings the two into alignment (#956). ContractClientfunctionality previously added in v11.3.0 was exported in a non-standard way. You can now import it as any otherstellar-sdkmodule (#962):
-import { ContractClient } from '@stellar/stellar-sdk/lib/contract_client'
+import { contract } from '@stellar/stellar-sdk'
+const { Client } = contractNote that this top-level contract export is a container for ContractClient and related functionality. The ContractClient class is now available at contract.Client, as shown. Further note that there is a capitalized Contract export as well, which comes from stellar-base. You can remember which is which because capital-C Contract is a class, whereas lowercase-c contract is a container/module with a bunch of classes, functions, and types.
Additionally, this is available from the /contract entrypoint, if your version of Node and TypeScript support the exports declaration. Finally, some of its exports have been renamed:
import {
AssembledTransaction,
SentTransaction,
- ContractClient,
- ContractClientOptions,
-} from '@stellar/stellar-sdk/lib/contract_client'
+ Client,
+ ClientOptions,
+} from '@stellar/stellar-sdk/contract'- The
ContractSpecclass is now nested under thecontractmodule, and has been renamed toSpec(#962). Alternatively, you can import this from thecontractentrypoint, if your version of Node and TypeScript support theexportsdeclaration:
-import { ContractSpec } from '@stellar/stellar-sdk'
+import { contract } from '@stellar/stellar-sdk'
+const { Spec } = contract
// OR
+import { Spec } from '@stellar/stellar-sdk/contract'- Previously,
AssembledTransaction.signAndSend()would return aSentTransactioneven if the transaction never finalized. That is, if it successfully sent the transaction to the network, but the transaction was stillstatus: 'PENDING', then it wouldconsole.erroran error message, but return the indeterminate transaction anyhow. It now throws aSentTransaction.Errors.TransactionStillPendingerror with that error message instead (#962).
Deprecated
SorobanRpcmodule is now also exported asrpc(#962). You can import it with either name for now, butSorobanRpcwill be removed in a future release:
-import { SorobanRpc } from '@stellar/stellar-sdk'
+import { rpc } from '@stellar/stellar-sdk'You can also now import it at the /rpc entrypoint, if your version of Node and TypeScript support the exports declaration.
-import { SorobanRpc } from '@stellar/stellar-sdk'
-const { Api } = SorobanRpc
+import { Api } from '@stellar/stellar-sdk/rpc'Added
- New methods on
contract.Client(#960):from(opts: ContractClientOptions)instantiatescontract.Clientby fetching thecontractId's WASM from the network to fill out the client'sContractSpec.fromWasmandfromWasmHashmethods to instantiate acontract.Clientwhen you already have the WASM bytes or hash alongside thecontract.ClientOptions.
- New methods on
rpc.Server(#960):getContractWasmByContractIdandgetContractWasmByHashto retrieve a contract's WASM bytecode via itscontractIdorwasmHash, respectively.
rpc.server.simulateTransactionnow supports an optionalstateChanges?: LedgerEntryChange[]field (#963):- If
Beforeis omitted, it constitutes a creation, ifAfteris omitted, it constitutes a deletions, note thatBeforeandAftercannot be be omitted at the same time. Each item follows this schema:
- If
interface LedgerEntryChange {
type: number;
key: xdr.LedgerKey;
before: xdr.LedgerEntry | null;
after: xdr.LedgerEntry | null;
}Fixed
- The breaking changes above (strictly speaking, they are not breaking changes because importing from the inner guts of the SDK is not supported) enable the
contractmodule to be used in non-Node environments. - Dependencies have been properly updated to pull in Protocol 21 XDR, where RC1 was not pulling properly for existing installs (#959).
- Each item in the
GetEventsResponse.eventslist will now have atxHashitem corresponding to the transaction hash that triggered a particular event (#939). ContractClientnow properly handles methods that take no arguments by makingMethodOptionsthe only parameter, bringing it inline with the types generated by Soroban CLI'ssoroban contract bindings typescript(#940).ContractClientnow allowspublicKeyto be undefined (#941).SentTransactionwill only passallowHttpif (and only if) its correspondingAssembledTransaction#optionsconfig allowed it (#952).
New Contributors
- @silence48 made their first contribution in #934
- @BlaineHeffron made their first contribution in #951
- @psheth9 made their first contribution in #963
Full Changelog: v11.3.0...v12.0.1