v15.0.0: Protocol 26
Migration Guide — step-by-step upgrade instructions with code examples and severity ratings.
TransactionBase.networkPassphrasesetter now throws an error to enforce immutability (#891).- React Native apps using the Hermes engine must polyfill broken typed array methods such as
subarray; this compatibility is no longer provided by@stellar/js-xdr. One option is@exodus/patch-broken-hermes-typed-arrays. If needed, please review and consider manually adding it to your project. - Construction and encoding of sized XDR integer values now throw on overflow and underflow instead of silently clamping, via
@stellar/js-xdr(#133). This may affect code that previously relied on permissive bigint coercion.
- XDR definitions have been updated to align with Protocol 26 (#944).
Keypair.verifynow returnsfalseinstead of throwing when the signature is invalid (#892).Memo.idnow correctly rejects negative values, decimal values, and values exceeding the uint64 maximum (2^64 - 1); the error message now correctly saysuint64(#892).Operation._toXDRPricenow accepts price objects withn: 0(a zero numerator was previously treated as falsy and fell through to float approximation) (#892).SignerKey.decodeSignerKeynow reads the exact payload length from the 4-byte length prefix when decodingsignedPayloadsigner keys, preventing data truncation or over-read (#892).TransactionBuilder.cloneFromnow correctly re-encodesextraSignersas StrKey strings (they were previously passed as raw XDR objects) (#892).TransactionBuilder.cloneFromnow usesMath.floorwhen computingunscaledFeeto prevent fractional fee values (#892).TransactionBuildernow floorsDatetimebounds to integer UNIX timestamps (#892).Auth.bytesToInt64now correctly handles bytes with upper-32-bit values set by processing each 32-bit half independently (#891).ScIntconstructor now correctly handles string input (#891).Soroban.parseTokenAmountnow throws when the input value has more decimal places than the specifieddecimalsargument (#891).- XDR
ArrayandVarArraydecoding now fails fast when the declared array length exceeds the remaining bytes, via@stellar/js-xdr(#132).
- Implemented
TransactionBuilder.addSacTransferOperationto remove the need for simulation for SAC (Stellar Asset Contract) transfers by creating the appropriate auth entries and footprint (#861).
TransactionBuilder.buildnow addsthis.sorobanData.resourceFee()tobaseFeewhen provided (#861).- The generated XDR type declarations for unions with integer discriminants now use constructors instead of named static methods (stellar/dts-xdr#9) (#874).
- Fixes a bug in
Addresswhich prevented it from decoding claimable balances (#825). - Fixes a bug in
Soroban.formatTokenAmountthat would cause a lack of leading or trailing zeroes at the decimal point in some cases (#821, #823).
- Add conversions for timepoint and duration scval types (#819)
- Lowered the maximum bid for fee-bumped Soroban transactions by not doubling the resource fee (#817).
- Added missing
Asset.toString()TypeScript definition (#1218).
v14.0.0: Protocol 23
- This package now requires >= Node 20.
- XDR definitions have been updated to align with Protocol 23 (#800).
- The
sodium-nativeandtweetnacldependencies have been replaced with@noble/curves(#802). - Support for claimable balances and liquidity pools in
StrKey(#799). - Support for claimable balances, liquidity pools, and muxed accounts in
Address(#801). - Added the ability for
nativeToScValto convert arrays with differing types to smart contract values, e.g.,nativeToScVal([1, "x", "y"], { type: [ "i128", "symbol" ]})will give you aVec<i128, symbol, string>(#803).
- Removed the custom
Buffer.subarraypolyfill introduced in #733 in v11.0.1 as a workaround for React Native's Hermes engine. Please use@exodus/patch-broken-hermes-typed-arraysas an alternative, if needed (#795). - Fix browser compatibility with proper module resolution and UMD configuration (#798).
- Remove
MuxedAccount.parseBaseAddressfrom TypeScript definitions (#797).
- Fixes a bug in
Address.toScAddress()that would prevent claimable balances and muxed accounts from being encoded correctly.
v14.0.0-rc.1: Protocol 23
- This package now requires >= Node 20.
- XDR definitions have been updated to align with Protocol 23 (#800).
- The
sodium-nativeandtweetnacldependencies have been replaced with@noble/curves(#802). - Support for claimable balances and liquidity pools in
StrKey(#799). - Support for claimable balances, liquidity pools, and muxed accounts in
Address(#801). - Added the ability for
nativeToScValto convert arrays with differing types to smart contract values, e.g.,nativeToScVal([1, "x", "y"], { type: [ "i128", "symbol" ]})will give you aVec<i128, symbol, string>(#803).
- Removed the custom
Buffer.subarraypolyfill introduced in #733 in v11.0.1 as a workaround for React Native's Hermes engine. Please use@exodus/patch-broken-hermes-typed-arraysas an alternative, if needed (#795). - Fix browser compatibility with proper module resolution and UMD configuration (#798).
- Remove
MuxedAccount.parseBaseAddressfrom TypeScript definitions (#797).
nativeToScValnow supports encodingKeypairs as addresses (#794).- Within
authorizeEntry, theSigningCallbackcallback function should now return an object containing both the signature and the identity of the signer. In multi-signature situations, it isn't necessarily the case that the address within the authorization entry is the one that actually signs that entry. Thus, the callback now takes the following form, where the originalPromise<BufferLike>option is preserved for backwards compatibility and should be considered deprecated (#783):
export type SigningCallback = (
preimage: xdr.HashIdPreimage
) => Promise<BufferLike | { signature: BufferLike; publicKey: string }>;scValToNativewill decode addresses more efficiently and reliably (#794).
buildInvocationTreewill now successfully walk creation invocations with constructor arguments (#784).
This release 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.
This version is unchanged from 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.
- XDR definitions have been upgraded to Protocol 22 (#777).
- You can create contracts with constructors a new, optional parameter of
Operation.createCustomContract,constructorArgs: xdr.ScVal[](#770).
- Add missing methods to TypeScript definitions (#766).
- Fix the TypeScript definition of
walkInvocationTreeto allow void returns on the callback function as intended rather than forcing areturn null(#765). - Fix
authorizeEntryto use the correct public key when passingKeypairs (#772). - Upgrade misc. dependencies (#771, #773).
TransactionBuildernow hasaddOperationAtandclearOperationAtmethods to allow manipulation of individual operations (#757).
- Improve the efficiency and portability of asset type retrieval (#758).
nativeToScValnow correctly sorts maps lexicographically based on the keys to match what the Soroban environment expects (#759).nativeToScValnow allows all integer types to come from strings (#763).humanizeEventsnow handles events without acontractIdset more reliably (#764).
- Export TypeScript definition for
StrKey.isValidContract(#751). scValToNativewould fail when the values contained error codes because the parsing routine hadn't been updated to the new error schemas. Errors are now converted to the following format (#753):
interface Error {
type: "contract" | "system";
code: number;
value?: string; // only present for type === 'system'
}You can refer to the XDR documentation for additional explanations for each error code.
This is a re-tag of v12.0.0-rc.1 with only developer dependency updates in-between.
- The generated XDR has been upgraded to match the upcoming Protocol 21, namely stellar/stellar-xdr@
1a04392(#738).
- To facilitate serialization and deserialization for downstream systems, this package now exports
cereal.XdrWriterandcereal.XdrReaderwhich come directly from@stellar/js-xdr(#744).
- Updated various dependencies (#737, #739).
BufferandUint8Arraycompatibility has improved inStrKey(#746).
- Add compatibility with pre-ES2016 environments (like some React Native JS compilers) by adding a custom
Buffer.subarraypolyfill (#733). - Upgrade underlying dependencies, including
@stellar/js-xdrwhich should broaden compatibility to pre-ES2016 environments (#734, #735).
Note: This version is (still) compatible with Protocol 20. Most people should be unaffected by the technically-breaking changes below and can treat this more like a v10.0.3 patch release.
- Starting from v10.0.0-beta.0, we set
BigNumber.DEBUGinbignumber.jstotrueinternally, which affects all code usingBigNumber. This behavior has been fixed and only affects this library: globally,BigNumber.DEBUGnow remains at its default setting (i.e. disabled). This is technically a breaking behavior change and is released as such (#729).
- The
contractIdfield is correctly omitted from humanized events when it wasn't present in the structure (#721). - Misc. outdated or incorrect documentation has been updated (#723, #720).
- Dependencies have been updated (#724).
- The TypeScript definition for
Asset.contractId()now includes a missing parameter (thenetworkPassphrasechanges the ID for a contract; #718).
v10.0.0: Protocol 20 Stable Release
- The new minimum supported Node version is Node 18.
- XDR has been upgraded to the latest stable version (stellar-xdr@
6a620d1). This is mostly renames, but it includes the following relevant breaking changes (#704):Operation.bumpFootprintExpirationis nowextendFootprintTtland itsledgersToExpirefield is now namedextendTo, but it serves the same purpose.- In TypeScript, the
Operation.BumpFootprintExpirationis nowOperation.ExtendFootprintTTL xdr.ContractExecutable.contractExecutableTokenis nowcontractExecutableStellarAssetxdr.SorobanTransactionData.refundableFeeis nowresourceFee- In turn,
SorobanDataBuilder.setRefundableFeeis nowsetResourceFee - This new fee encompasses the entirety of the Soroban-related resource fees. Note that this is distinct from the "network-inclusion" fee that you would set on your transaction (i.e.
TransactionBuilder(..., { fee: ... })).
Contract.getFootprint()now only returns a single result: the ledger key of the deployed instance for the given ID, because the key for the code entry was incorrect (it should not be the ID but rather the WASM hash, which is not calculatable w/o network access) (#709).
- You can now correctly clone transactions (
TransactionBuilder.cloneFrom) with large sequence numbers (#711).
- Fixes a bug where
authorizeEntrymight perform a no-op when it shouldn't (#701). - Fixes a TypeScript bug where
Memo.hashdid not accept aBuffer(#698). - Upgrades a transient dependency for security (#296).
- The wrappers around multi-party authorization have changed (#678):
authorizeEntryhas been added to help sign auth entries in-place- the signature for
authorizeInvocationhas changed: it now offers a callback approach by default and requires slightly different parameters buildAuthEntry,buildAuthEnvelope, andauthorizeInvocationCallbackhave been removed
- The TypeScript definitions for XDR schemas now point to the current protocol rather than vNext (#694).
- Misc. dependencies have been updated to their latest versions (#694).
nativeToScValnow allows anything to be passed to theopts.typespecifier. Previously, it was only integer types (#691).Contract.call()now produces validOperationXDR (#692).
v10.0.0-beta.0: Protocol 20
- Node 16 is the new minimum version to use the SDKs.
- The XDR has been massively overhauled to support Soroban in Protocol 20, which means new operations, data structures, and a transaction format as well as new overlay features (#538).
The core data structure of Soroban is a generic type called an ScVal (smart contract value, which is a union of types that can basically represent anything [numbers, strings, arrays, maps, contract bytecode, etc.]). You can refer to the XDR for details, and you can utilize new APIs to make dealing with these complex values easier:
nativeToScValhelps convert native types to their closest Soroban equivalentscValToNativehelps find the closest native JavaScript type(s) corresponding to a smart contract valuescValToBigInthelps convert numericScVals into nativebigintsScIntandXdrLargeInthelp convert to and frombigints to other types and form sized integer types for smart contract usage
The following are new APIs to deal with new Soroban constructs:
Address, which helps manage "smart" addresses in the Soroban context. Addresses there (used for auth and identity purposes) can either be contracts (strkeyC...) or accounts (strkeyG...). This abstraction helps manage them and distinguish between them easily.Contract, which helps manage contract identifiers. The primary purpose is to build invocations of its methods via the genericcall(...), but it also provides utilities for converting to anAddressor calculating its minimum footprint for state expiration.- Three new operations have been added related to Soroban transactions:
invokeHostFunctionfor calling contract codebumpFootprintExpirationfor extending the state lifetime of Soroban datarestoreFootprintfor restoring expired, off-chain state back onto the ledger
- The
TransactionBuildernow takes asorobanDataparameter (and has a corresponding.setSorobanData()builder method) which primarily describes the storage footprint of a Soroban (that is, which parts of the ledger state [in the form ofxdr.LedgerKeys] it plans to read and write as part of the transaction).- To facilitate building this out, there's a new
SorobanDataBuilderfactory to set fields individually
- To facilitate building this out, there's a new
- The
TransactionBuildernow has acloneFrom(tx, opts)constructor method to create an instance from an existing transaction, also allowing parameter overrides viaopts. - The following are convenience methods for building out certain types of smart contract-related structures:
buildInvocationTreeandwalkInvocationTreeare both ways to visualize invocation calling trees betterauthorizeInvocationhelps multiple parties sign invocation calling treeshumanizeEventshelps make diagnostic events more readable
- We've added a GHA to track bundle size changes as PRs are made. This protocol upgrade adds +18% to the final, minified bundle size which is significant but acceptable given the size of the upgrade.
- Improves the error messages when passing invalid amounts to deposit and withdraw operations (#679).
This is a large update and the following changelog incorporates ALL changes across the beta.N versions of this upgrade.
This version is marked by a major version bump because of the significant upgrades to underlying dependencies. While there should be no noticeable API changes from a downstream perspective, there may be breaking changes in the way that this library is bundled.
The browser bundle size has decreased significantly:
stellar-base.min.jsis 340 KiB, down from 1.2 MiB previously.- the new, unminified
stellar-base.jsis 895 KiB.
Though we have tried to maintain compatibility with older JavaScript implementations, this still means you may need to update your build pipeline to transpile to certain targets.
- Fixes a bug when sorting mixed-case assets for liquidity pools (#606).
- Documentation is fixed and should generate correctly on https://stellar.github.io/js-stellar-base/ (#609).
- XDR has been updated to its latest version (both
currandnextversions, #587). - Drop the
lodashdependency entirely (#624). - Drop the
crcdependency and inline it to lower bundle size (#621). - Upgrade all dependencies to their latest versions (#608).
- Fixes a bug when sorting mixed-case assets for liquidity pools (#606).
- Upgrade all dependencies to their latest versions (#608).
- Drop the
crcdependency and inline it to lower bundle size (#621).
- Upgrades the
js-xdrdependency (major performance improvements, seejs-xdr@v2.0.0) and other dependencies to their latest versions (#592).
- Correct XDR type definition for raw
xdr.Operations (#591).
This version is marked by a major version bump because of the significant upgrades to underlying dependencies. While there should be no noticeable API changes from a downstream perspective, there may be breaking changes in the way that this library is bundled.
-
Build system has been overhauled to support Webpack 5 (#585).
-
Current and vNext XDR updated to latest versions (#587).
- Enable signing in service workers using FastSigning (#567).
- Turn all XLM-like (i.e. casing agnostic) asset codes into the native asset with code
XLM(#546).
Operation.setOptionsnow supports the new CAP-40 signed payload signer (ed25519SignedPayload) thanks to @orbitlens (#542).
-
TransactionBase.addDecoratedSignatureis a clearer way to add signatures directly to a built transaction without fiddling with the underlyingsignaturesarray (#535). -
Update the XDR definitions (and the way in which they're generated) to contain both the latest current XDR (which introduces CAP-42) and the "v-next" XDR (which contains XDR related to Soroban and should be considered unstable) (#537).
- Correctly set
minAccountSequenceinTransactionBuilderfor large values (#539, thank you @overcat!).
- Correctly predict claimable balance IDs with large sequence numbers (#530, thank you @overcat!).
This is a promotion from the beta version without changes, now that the CAP-21 and CAP-40 implementations have made it into stellar/stellar-core#master.
This release adds support for Protocol 19, which includes CAP-21 (new transaction preconditions) and CAP-40 (signed payload signers).
This is considered a beta release until the XDR for the Stellar protocol stabilizes and is officially released.
As of this release, the minimum supported version of NodeJS is 14.x.
- Two XDR types have been renamed:
xdr.OperationIdis nowxdr.HashIdPreimagexdr.OperationIdIdis nowxdr.HashIdPreimageOperationId
-
Support for converting signed payloads (CAP-40) to and from their StrKey (
P...) representation (#511):Keypair.signPayloadDecorated(data)StrKey.encodeSignedPayload(buf)StrKey.decodeSignedPayload(str)StrKey.isValidSignedPayload(str)
-
Support for creating transactions with the new preconditions (CAP-21) via
TransactionBuilder(#513). -
A way to convert between addresses (like
G...andP..., i.e. theStrKeyclass) and their respective signer keys (i.e.xdr.SignerKeys), particularly for use in the new transaction preconditions (#520):SignerKey.decodeAddress(address)SignerKey.encodeSignerKey(address)TransactionBuilder.setTimebounds(min, max)TransactionBuilder.setLedgerbounds(min, max)TransactionBuilder.setMinAccountSequence(seq)TransactionBuilder.setMinAccountSequenceAge(age)TransactionBuilder.setMinAccountSequenceLedgerGap(gap)TransactionBuilder.setExtraSigners([signers])
-
Correct a TypeScript definition on the
RevokeLiquidityPoolSponsorshipoperation (#522). -
Resolves a bug that incorrectly sorted
Assets with mixed-case asset codes (it preferred lowercase codes incorrectly) (#516). -
Update developer dependencies:
This release introduces unconditional support for muxed accounts (#485).
In v5.2.0, we introduced opt-in support for muxed accounts, where you would need to explicitly pass a true flag if you wanted to interpret muxed account objects as muxed addresses (in the form M..., see SEP-23). We stated that this would become the default in the future. That is now the case.
The following fields will now always support muxed properties:
FeeBumpTransaction.feeSourceTransaction.sourceAccountOperation.sourceAccountPayment.destinationPathPaymentStrictReceive.destinationPathPaymentStrictSend.destinationAccountMerge.destinationClawback.from
The following functions had a withMuxing parameter removed:
Operation.fromXDRObjectTransaction.constructorFeeBumpTransaction.constructorTransactionBuilder.fromXDRTransactionBuilder.buildFeeBumpTransaction
The following functions will no longer check the opts object for a withMuxing field:
TransactionBuilder.constructorOperation.setSourceAccount
There are several other breaking changes:
TransactionBuilder.enableMuxedAccounts()is removeddecodeAddressToMuxedAccount()andencodeMuxedAccountToAddress()no longer accept a second boolean parameterAccount.createSubaccount()andMuxedAccount.createSubaccount()are removed (#487). You should prefer to create them manually:
let mux1 = new MuxedAccount(someAccount, "1");
// before:
let mux2 = mux1.createSubaccount("2");
// now:
let mux2 = new MuxedAccount(mux1.baseAccount(), "2");- Introduced a new helper method to help convert from muxed account addresses to their underlying Stellar addresses (#485):
function extractBaseAddess(address: string): string;- The following muxed account validation functions are now available from Typescript (#483):
namespace StrKey {
function encodeMed25519PublicKey(data: Buffer): string;
function decodeMed25519PublicKey(data: string): Buffer;
function isValidMed25519PublicKey(publicKey: string): boolean;
}
function decodeAddressToMuxedAccount(
address: string,
supportMuxing: boolean
): xdr.MuxedAccount;
function encodeMuxedAccountToAddress(
account: xdr.MuxedAccount,
supportMuxing: boolean
): string;
function encodeMuxedAccount(gAddress: string, id: string): xdr.MuxedAccount;- Added a helper function
Transaction.getClaimableBalanceId(int)which lets you pre-determine the hex claimable balance ID of acreateClaimableBalanceoperation prior to submission to the network (#482).
- Add
Bufferas a parameter type option for theKeypairconstructor in Typescript (#484).
This version bump fixes a security vulnerability in a developer dependency; please upgrade as soon as possible! You may be affected if you are working on this package in a developer capacity (i.e. you've cloned this repository) and have run yarn or yarn install any time on Oct 22nd, 2021.
Please refer to the security advisory for details.
- Pin
ua-parser-jsto a known safe version (#477).
- Allow muxed accounts when decoding transactions via
TransactionBuilder.fromXDR()(#470).
- When creating a
Transaction, forward the optionalwithMuxingflag along to its operations so that their properties are also decoded with the appropriate muxing state (#469).
- Fix Typescript signatures for operations to universally allow setting the
withMuxingflag (#466).
- Introduced new CAP-38 operations
LiquidityPoolDepositOpandLiquidityPoolWithdrawOp. - Introduced two new types of assets,
LiquidityPoolIdandLiquidityPoolAsset.
- The XDR definitions have been updated to support CAP-38.
- Extended
Operationclass with theOperation.revokeLiquidityPoolSponsorshiphelper that allows revoking a liquidity pool sponsorship. - Asset types now include
AssetType.liquidityPoolShares. Operation.changeTrustandChangeTrustOpcan now useLiquidityPoolAssetin addition toAsset.Operation.revokeTrustlineSponsorshipcan now useLiquidityPoolIdin addition toAsset.
- Update various dependencies to secure versions. Most are developer dependencies which means no or minimal downstream effects (#446, #447, #392, #428); the only non-developer dependency upgrade is a patch version bump to
lodash(#449).
- Creating operations with both muxed and unmuxed properties resulted in unintuitive XDR. Specifically, the unmuxed property would be transformed into the equivalent property with an ID of 0 (#441).
- Opt-in support for muxed accounts. In addition to the support introduced in v5.2.0, this completes support for muxed accounts by enabling them for fee-bump transactions. Pass a muxed account address (in the
M...form) as the first parameter (and explicitly opt-in to muxing by passingtrueas the last parameter) toTransactionBuilder.buildFeeBumpTransactionto make thefeeSourcea fully-muxed account instance (#434).
-
Opt-in support for muxed accounts. This introduces
M...addresses from SEP-23, which multiplex a StellarG...address across IDs to eliminate the need for ad-hoc multiplexing via the Transaction.memo field (see the relevant SEP-29 and blog post on the topic). The following operations now support muxed accounts (#416):Payment.destinationPathPaymentStrictReceive.destinationPathPaymentStrictSend.destinationOperation.sourceAccountAccountMerge.destinationTransaction.sourceAccount
-
The above changeset also introduces a new high-level object,
MuxedAccount(not to be confused withxdr.MuxedAccount, which is the underlying raw representation) to make working with muxed accounts easier. You can use it to easily create and manage muxed accounts and their underlying sharedAccount, passing them along to the supported operations andTransactionBuilder(#416):
const PUBKEY = "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ";
const ACC = new StellarBase.Account(PUBKEY, "1");
const mux1 = new StellarBase.MuxedAccount(ACC, "1000");
console.log(mux1.accountId(), mux1.id());
// MA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJUAAAAAAAAAAD5DTGC 1000
const mux2 = ACC.createSubaccount("2000");
console.log(
"Parent relationship preserved:",
mux2.baseAccount().accountId() === mux1.baseAccount().accountId()
);
console.log(mux2.accountId(), mux2.id());
// MA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJUAAAAAAAAAAH2B4RU 2000
mux1.setID("3000");
console.log(
"Underlying account unchanged:",
ACC.accountId() === mux1.baseAccount().accountId()
);
console.log(mux1.accountId(), mux1.id());
// MA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJUAAAAAAAAAALXC5LE 3000- You can refer to the documentation or the test suite for more uses of the API.
- Modernize the minimum-supported browser versions for the library (#419).
- Update Typescript test for
SetOptionsto use authorization flags (e.g.AuthRequiredFlag) correctly (#418).
- The Typescript definitions have been updated to support CAP-35 (#407).
- Introduced new CAP-35 operations,
ClawbackOp,ClawbackClaimableBalanceOp, andSetTrustLineFlagsOp(#397).
-
Add an additional parameter check to
claimClaimableBalanceto fail faster (#390). -
The XDR definitions have been updated to support CAP-35 (#394).
AllowTrustOpAssethas been renamed toAssetCode(#394)
AllowTrustOpis now a deprecated operation.
- Fix deployment script.
- Update
createAccountoperation to accept0as the starting balance (#375).
- Add the
Claimantclass which helps the creation of claimable balances. (#367). The default behavior of this class it to create claimants with an unconditional predicate if none is passed:
const claimant = new StellarBase.Claimant(
'GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ'
);
However, you can use any of the following helpers to create a predicate:
StellarBase.Claimant.predicateUnconditional();
StellarBase.Claimant.predicateAnd(left, right);
StellarBase.Claimant.predicateOr(left, right);
StellarBase.Claimant.predicateNot(predicate);
StellarBase.Claimant.predicateBeforeAbsoluteTime(unixEpoch);
StellarBase.Claimant.predicateBeforeRelativeTime(seconds);
And then pass the predicate in the constructor:
const left = StellarBase.Claimant.predicateBeforeRelativeTime('800');
const right = StellarBase.Claimant.predicateBeforeRelativeTime(
'1200'
);
const predicate = StellarBase.Claimant.predicateOr(left, right);
const claimant = new StellarBase.Claimant(
'GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ',
predicate
);
- Add
Operation.createClaimableBalance(#368) Extend the operation class with a new helper to create claimable balance operations.
const asset = new Asset(
"USD",
"GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7"
);
const amount = "100.0000000";
const claimants = [
new Claimant(
"GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ",
Claimant.predicateBeforeAbsoluteTime("4102444800000")
),
];
const op = Operation.createClaimableBalance({
asset,
amount,
claimants,
});- Add
Operation.claimClaimableBalance(#368) Extend the operation class with a new helper to create claim claimable balance operations. It receives thebalanceIdas exposed by Horizon in the/claimable_balancesend-point.
const op = Operation.createClaimableBalance({
balanceId:
"00000000da0d57da7d4850e7fc10d2a9d0ebc731f7afb40574c03395b17d49149b91f5be",
});- Add support for Sponsored Reserves (CAP33)(#369)
Extend the operation class with helpers that allow sponsoring reserves and also revoke sponsorships.
To start sponsoring reserves for an account use:
Operation.beginSponsoringFutureReservesOperation.endSponsoringFutureReserves
To revoke a sponsorship after it has been created use any of the following helpers:
Operation.revokeAccountSponsorshipOperation.revokeTrustlineSponsorshipOperation.revokeOfferSponsorshipOperation.revokeDataSponsorshipOperation.revokeClaimableBalanceSponsorshipOperation.revokeSignerSponsorship
The following example contains a transaction which sponsors operations for an account and then revoke some sponsorships.
const transaction = new StellarSdk.TransactionBuilder(account, {
fee: "100",
networkPassphrase: StellarSdk.Networks.TESTNET
})
.addOperation(
StellarSdk.Operation.beginSponsoringFutureReserves({
sponsoredId: account.accountId(),
source: masterKey.publicKey()
})
)
.addOperation(
StellarSdk.Operation.accountMerge({ destination: destKey.publicKey() }),
).addOperation(
StellarSdk.Operation.createClaimableBalance({
amount: "10",
asset: StellarSdk.Asset.native(),
claimants: [
new StellarSdk.Claimant(account.accountId())
]
}),
).addOperation(
StellarSdk.Operation.claimClaimableBalance({
balanceId: "00000000da0d57da7d4850e7fc10d2a9d0ebc731f7afb40574c03395b17d49149b91f5be",
}),
).addOperation(
StellarSdk.Operation.endSponsoringFutureReserves({
})
).addOperation(
StellarSdk.Operation.revokeAccountSponsorship({
account: account.accountId(),
})
).addOperation(
StellarSdk.Operation.revokeTrustlineSponsorship({
account: account.accountId(),
asset: usd,
})
).addOperation(
StellarSdk.Operation.revokeOfferSponsorship({
seller: account.accountId(),
offerId: '12345'
})
).addOperation(
StellarSdk.Operation.revokeDataSponsorship({
account: account.accountId(),
name: 'foo'
})
).addOperation(
StellarSdk.Operation.revokeClaimableBalanceSponsorship({
balanceId: "00000000da0d57da7d4850e7fc10d2a9d0ebc731f7afb40574c03395b17d49149b91f5be",
})
).addOperation(
StellarSdk.Operation.revokeSignerSponsorship({
account: account.accountId(),
signer: {
ed25519PublicKey: sourceKey.publicKey()
}
})
).addOperation(
StellarSdk.Operation.revokeSignerSponsorship({
account: account.accountId(),
signer: {
sha256Hash: "da0d57da7d4850e7fc10d2a9d0ebc731f7afb40574c03395b17d49149b91f5be"
}
})
).addOperation(
StellarSdk.Operation.revokeSignerSponsorship({
account: account.accountId(),
signer: {
preAuthTx: "da0d57da7d4850e7fc10d2a9d0ebc731f7afb40574c03395b17d49149b91f5be"
}
})
).build();
- The XDR generated in this code includes breaking changes on the internal XDR library since a bug was fixed which was causing incorrect code to be generated (see stellar/xdrgen#52).
The following functions were renamed:
xdr.OperationBody.setOption()->xdr.OperationBody.setOptions()xdr.OperationBody.manageDatum()->xdr.OperationBody.manageData()xdr.OperationType.setOption()->xdr.OperationType.setOptions()xdr.OperationType.manageDatum()->xdr.OperationType.manageData()
The following enum values were rename in OperationType:
setOption->setOptionsmanageDatum->manageData
- Generate V1 transactions by default and allow V0 transactions to be fee bumped (#355).
- Rollback support for SEP23 (Muxed Account StrKey) (#349).
- Extend
filesin npm package to include XDR type definitions (#345).
- Add TypeScript definitions for auto-generated XDR code (#342).
This version brings protocol 13 support with backwards compatibility support for protocol 12.
- Add
TransactionBuilder.buildFeeBumpTransactionwhich makes it easy to createFeeBumpTransaction(#321). - Adds a feature flag which allow consumers of this library to create V1 (protocol 13) transactions using the
TransactionBuilder(#321). - Add support for CAP0027: First-class multiplexed accounts (#325).
AddKeypair.xdrMuxedAccountwhich creates a newxdr.MuxedAccount(#325).- Add
FeeBumpTransactionwhich makes it easy to work with fee bump transactions (#328). - Add
TransactionBuilder.fromXDRwhich receives an xdr envelope and return aTransactionorFeeBumpTransaction(#328).
-
Update XDR definitions with protocol 13 (#317).
-
Extend
Transactionto work withTransactionV1EnvelopeandTransactionV0Envelope(#317). -
Add backward compatibility support for CAP0018 (#317). CAP0018 provides issuers with a new level of authorization between unauthorized and fully authorized, called "authorized to maintain liabilities". The changes in this release allow you to use the new authorization level and provides backward compatible support for Protocol 12.
Before Protocol 13, the argument
authorizein theAllowTrustoperation was of typebooleanwheretruewas authorize andfalsedeauthorize. Starting in Protocol 13, this value is now anumberwhere0is deauthorize,1is authorize, and2is authorize to maintain liabilities.The syntax for authorizing a trustline is still the same, but the authorize parameter is now a
number.Operation.allowTrust({ trustor: trustor.publicKey(), assetCode: "COP", authorize: 1, });
You can use still use a
boolean; however, we recommend you update your code to pass anumberinstead. Finally, using the value2for authorize to maintain liabilities will only be valid if Stellar Core is running on Protocol 13; otherwise, you'll get an error. -
Update operations builder to support multiplexed accounts (#337).
-
Transaction.toEnvelope()returns a protocol 13xdr.TransactionEnvelopewhich is anxdr.Union(#317). If you have code that looks like this -transaction.toEnvelope().tx- you have two options:- You can grab the value wrapped by the union, calling
value()liketransaction.toEnvelope().value().tx. - You can check which is the discriminant by using
switch()and then callv0(),v1(), orfeeBump().
- You can grab the value wrapped by the union, calling
-
The return value from
Transaction.feechanged fromnumbertostring. This brings support forInt64values (#321). -
The const
BASE_FEEchanged fromnumbertostring(#321). -
The option
feepassed tonew TransactionBuilder({fee: ..})changed fromnumbertostring(#321). -
The following fields, which were previously an
xdr.AccountIDare now axdr.MuxedAccount(#325):PaymentOp.destinationPathPaymentStrictReceiveOp.destinationPathPaymentStrictSendOp.destinationOperation.sourceAccountOperation.destination(forACCOUNT_MERGE)Transaction.sourceAccountFeeBumpTransaction.feeSource
You can get the string representation by calling
StrKey.encodeMuxedAccountwhich will return aG..orM..account. -
Remove the following deprecated functions (#331):
Operation.manageOfferOperation.createPassiveOfferOperation.pathPaymentKeypair.fromBase58Seed
-
Remove the
Networkclass (#331). -
Remove
vendor/base58.js(#331).
-
Update operations builder to support multiplexed accounts (#337).
This allows you to specify an
Maccount as the destination or source:var destination = 'MAAAAAAAAAAAAAB7BQ2L7E5NBWMXDUCMZSIPOBKRDSBYVLMXGSSKF6YNPIB7Y77ITLVL6'; var amount = '1000.0000000'; var asset = new StellarBase.Asset( 'USDUSD', 'GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7' ); var source = 'MAAAAAAAAAAAAAB7BQ2L7E5NBWMXDUCMZSIPOBKRDSBYVLMXGSSKF6YNPIB7Y77ITLVL6'; StellarBase.Operation.payment({ destination, asset, amount, source });To use multiplexed accounts you need an instance of Stellar running on Protocol 13 or higher
This version brings protocol 13 support with backwards compatibility support for protocol 12.
- Add
TransactionBuilder.buildFeeBumpTransactionwhich makes it easy to createFeeBumpTransaction(#321). - Adds a feature flag which allow consumers of this library to create V1 (protocol 13) transactions using the
TransactionBuilder(#321). - Add support for CAP0027: First-class multiplexed accounts (#325).
- Add
Keypair.xdrMuxedAccountwhich creates a newxdr.MuxedAccount(#325). - Add
FeeBumpTransactionwhich makes it easy to work with fee bump transactions (#328). - Add
TransactionBuilder.fromXDRwhich receives an xdr envelope and return aTransactionorFeeBumpTransaction(#328).
- Update XDR definitions with protocol 13 (#317).
- Extend
Transactionto work withTransactionV1EnvelopeandTransactionV0Envelope(#317). - Add backward compatibility support for CAP0018 (#317).
-
Transaction.toEnvelope()returns a protocol 13xdr.TransactionEnvelopewhich is anxdr.Union(#317). If you have code that looks like thistransaction.toEnvelope().txyou have two options:- You can grab the value wrapped by the union, calling
value()liketransaction.toEnvelope().value().tx. - You can check which is the discriminant by using
switch()and then callv0(),v1(), orfeeBump().
- You can grab the value wrapped by the union, calling
-
The return value from
Transaction.feechanged fromnumbertostring. This brings support forInt64values (#321). -
The const
BASE_FEEchanged fromnumbertostring(#321). -
The option
feepassed tonew TransactionBuilder({fee: ..})changed fromnumbertostring(#321). -
The following fields, which were previously an
xdr.AccountIDare now axdr.MuxedAccount(#325):PaymentOp.destinationPathPaymentStrictReceiveOp.destinationPathPaymentStrictSendOp.destinationOperation.sourceAccountOperation.destination(forACCOUNT_MERGE)Transaction.sourceAccountFeeBumpTransaction.feeSource
You can get the string representation by calling
StrKey.encodeMuxedAccountwhich will return aG..orM..account. -
Remove the following deprecated functions (#331):
Operation.manageOfferOperation.createPassiveOfferOperation.pathPaymentKeypair.fromBase58Seed
-
Remove the
Networkclass (#331). -
Remove
vendor/base58.js(#331).
- Update dependencies which depend on minimist. (#332)
- Fix
setTimeout(0)and partially defined timebounds (#315).
- Fix TypeScript options for
ManageDataoperation to allow setting value tonull(#310) - Fix crash on partially defined time bounds (#303)
- Fix npm deployment.
- Add
toXDRtype to Transaction class (#296)
- Fix doc link (#298)
- Remove node engine restriction (#294)
- Regenerate the XDR definitions to include MetaV2 (#288)
- Throw errors when obviously invalid network passphrases are used in
new Transaction(). (284)
- Update documentation for
Operationto showpathPaymentStrictSendandpathPaymentStrictReceive. (279)
-
Update
asset.toString()to return canonical representation for asset. (277).Calling
asset.toString()will returnnativeforXLMorAssetCode:AssetIssuerfor issued assets. See this PR for more information.
This release adds support for stellar-core protocol 12 release and CAP 24 ("Make PathPayment Symmetrical").
-
Operation.pathPaymentStrictSend: Sends a path payments, debiting from the source account exactly a specified amount of one asset, crediting at least a given amount of another asset. (#274).The following operation will debit exactly 10 USD from the source account, crediting at least 9.2 EUR in the destination account 💸:
var sendAsset = new StellarBase.Asset( "USD", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7" ); var sendAmount = "10"; var destination = "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ"; var destAsset = new StellarBase.Asset( "USD", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7" ); var destMin = "9.2"; var path = [ new StellarBase.Asset( "USD", "GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB" ), new StellarBase.Asset( "EUR", "GDTNXRLOJD2YEBPKK7KCMR7J33AAG5VZXHAJTHIG736D6LVEFLLLKPDL" ), ]; let op = StellarBase.Operation.pathPaymentStrictSend({ sendAsset, sendAmount, destination, destAsset, destMin, path, });
-
Operation.pathPaymentStrictReceive: This behaves the same as the formerpathPaymentsoperation. (#274).The following operation will debit maximum 10 USD from the source account, crediting exactly 9.2 EUR in the destination account 💸:
var sendAsset = new StellarBase.Asset( "USD", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7" ); var sendMax = "10"; var destination = "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ"; var destAsset = new StellarBase.Asset( "USD", "GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7" ); var destAmount = "9.2"; var path = [ new StellarBase.Asset( "USD", "GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB" ), new StellarBase.Asset( "EUR", "GDTNXRLOJD2YEBPKK7KCMR7J33AAG5VZXHAJTHIG736D6LVEFLLLKPDL" ), ]; let op = StellarBase.Operation.pathPaymentStrictReceive({ sendAsset, sendMax, destination, destAsset, destAmount, path, });
Operation.pathPaymentis being deprecated in favor ofOperation.pathPaymentStrictReceive. Both functions take the same arguments and behave the same. (#274).
No changes. Fixes deploy script and includes changes from v2.0.0.
- Drop Support for Node 6 since it has been end-of-lifed and no longer in LTS. We now require Node 10 which is the current LTS until April 1st, 2021. (#255)
- Fix no-network warnings (#248)
Deprecate global singleton for Network. The following classes and
methods take an optional network passphrase, and issue a warning if it
is not passed:
Keypair.master(Networks.TESTNET);const xenv = new xdr.TransactionEnvelope({ tx: xtx });
new Transaction(xenv, Networks.TESTNET);const transaction = new StellarSdk.TransactionBuilder(account, {
fee: StellarSdk.BASE_FEE,
networkPassphrase: Networks.TESTNET,
});See #207 and #112 for more information.
The Network class will be removed on the 2.0 release.
- Add docs for BASE_FEE const. (#211)
- Fix typo. (#213)
- Add
toString()to Asset (#172) - Add types for missing Network functions (#208)
- Add BASE_FEE to TS types (#209)
- Fix typo in types (#194)
- Fix types: Fee is no longer optional (#195)
- Fix typings for Account Sequence Number (#203)
- Fix typings for Transaction Sequence Number (#205)
- Fix a bug where
sodium-nativewas making it into the browser bundle, which is supposed to usetweetnacl.
- Restore
Operation.manageOfferandOperation.createPassiveOffer, and issue a warning if they're called. - Add type definitions for the timeBounds property of transactions.
- Breaking change Stellar Protocol 11 compatibility
- Rename
Operation.manageOffertoOperation.manageSellOffer. - Rename
Operation.createPassiveOffertoOperation.createPassiveSellOffer. - Add
Operation.manageBuyOffer.
- Rename
- Breaking change The
feeparameter toTransactionBuilderis now required. Failing to provide a fee will throw an error.
- Bring DefinitelyTyped definitions into the repo for faster updating.
- Add missing Typescript type definitions.
- Add code to verify signatures when added to transactions.
- Replace ed25519 with sodium-native.
- Fix the xdr for SCP_MESSAGE.
- Update the README for the latest info.
- Travis: Deploy NPM with an environment variable instead of an encrypted API key.
- Instruct Travis to cache node_modules
- Remove the
cryptolibrary. This reduces the number of Node built-ins we have to shim into the production bundle, and incidentally fixes a bug with Angular 6.
- Warning Calling TransactionBuilder without a
feeparam is now deprecated and will issue a warning. In a later release, it will throw an error. Please update your transaction builders as soon as you can! - Add a
toXDRfunction for transactions that lets you get the transaction as a base64-encoded string (so you may enter it into the Stellar Laboratory XDR viewer, for one) - Fix TransactionBuilder example syntax errors
- Use more thorough "create account" documentation
- Add
Datesupport forTransactionBuildertimebounds - Add two functions to
Transactionthat support pre-generated transactions:getKeypairSignaturehelps users sign pre-generated transaction XDRsaddSignaturelets you add pre-generated signatures to a built transaction
- Added ESLint and Prettier to enforce code style
- Upgraded dependencies, including Babel to 6
- Bump local node version to 6.14.0
- Change Operations._fromXDRAmount to not use scientific notation (1e-7) for small amounts like 0.0000001.
- Breaking change Added
TransactionBuilder.setTimeoutmethod that setstimebounds.max_timeon a transaction. Because of the distributed nature of the Stellar network it is possible that the status of your transaction will be determined after a long time if the network is highly congested. If you want to be sure to receive the status of the transaction within a given period you should set the TimeBounds withmaxTimeon the transaction (this is whatsetTimeoutdoes internally; if there'sminTimeset but nomaxTimeit will be added). Call toTransactionBuilder.setTimeoutis required if Transaction does not havemax_timeset. If you don't want to set timeout, useTimeoutInfinite. In general you should setTimeoutInfiniteonly in smart contracts. Please checkTransactionBuilder.setTimeoutdocs for more information. - Fixed decoding empty
homeDomain.
- Update
js-xdrto support unmarshaling non-utf8 strings. - String fields returned by
Operation.fromXDRObject()are of typeBuffernow (exceptSetOptions.home_domainandManageData.name- both required to be ASCII by stellar-core).
- Update
xdrfiles to V10.
- Upgrade
js-xdr.
- Removed
srcfrom.npmignore.
- Added support for
bump_sequenceoperation. - Fixed many code style issues.
- Updated docs.
- Updated dependencies.
- Updated docs.
- Updated docs.
Keypair.constructornow requirestypefield to define public-key signature system used in this instance (soKeypaircan support other systems in a future). It also checks if public key and secret key match if both are passed (to prevent nasty bugs).Keypair.fromRawSeedhas been renamed toKeypair.fromRawEd25519Seedto make it clear that the seed must be Ed25519 seed.- It's now possible to instantiate
Memoclass so it's easier to check it's type and value (without dealing with low levelxdr.Memoobjects). - Changed
Asset.toXdrObjecttoAsset.toXDRObjectandOperation.operationToObjecttoOperation.toXDRObjectfor consistency. - Time bounds support for numeric input values.
- Added
browserprop to package.json.
- Update dependencies.
- Remove unused methods.
- Allow hex string in setOptions signers
- Updated XDR files
- Checking hash preimage length
- Support for new signer types:
sha256Hash,preAuthTx. StrKeyhelper class withstrkeyencoding related methods.- Removed deprecated methods:
Keypair.isValidPublicKey(useStrKey),Keypair.isValidSecretKey(useStrKey),Keypair.fromSeed,Keypair.seed,Keypair.rawSeed. - Breaking changes:
Networkmust be explicitly selected. Previously testnet was a default network.Operation.setOptions()methodsignerparam changed.Keypair.fromAccountId()renamed toKeypair.fromPublicKey().Keypair.accountId()renamed toKeypair.publicKey().- Dropping support for
End-of-Lifenode versions.
- Breaking change
ed25519package is now optional dependency. - Export account flags constants.
- Fixes XDR decoding issue when using firefox
- UTF-8 support in
Memo.text().
- Make 0 a valid number for transaction fee,
- Fix signer in Operation.operationToObject() - close #82
- Fixed Lodash registering itself to global scope.
- Add support for ManageData operation.
- Moved
Account.isValidAccountIdtoKeypair.isValidPublicKey. It's still possible to useAccount.isValidAccountIdbut it will be removed in the next minor release (breaking change). (af10f2a) signer.addressoption inOperation.setOptionswas changed tosigner.pubKey. It's still possible to usesigner.addressbut it will be removed in the next minor release (breaking change). (07f43fb)Operation.setOptionsnow accepts strings forclearFlags,setFlags,masterWeight,lowThreshold,medThreshold,highThreshold,signer.weightoptions. (665e018)- Fixed TransactionBuilder timebounds option. (854f275)
- Added
CHANGELOG.mdfile.
- Now it's possible to pass
priceparams as{n: numerator, d: denominator}object. Thanks @FredericHeem. (#73)
- Breaking change
sequenceinAccountconstructor must be a string. (4da5dfc) - Breaking change Removed deprecated methods (180a5b8):
Account.isValidAddress(replaced byAccount.isValidAccountId)Account.getSequenceNumber(replaced byAccount.sequenceNumber)Keypair.address(replaced byKeypair.accountId)Network.usePublicNet(replaced byNetwork.usePublicNetwork)Network.useTestNet(replaced byNetwork.useTestNetwork)TransactionBuilder.addSigner(callTransaction.signon buildTransactionobject)