Skip to content

Releases: stellar/js-stellar-base

v5.2.0

05 May 17:58
307396b
Compare
Choose a tag to compare

Add

  • Opt-in support for muxed accounts. This introduces M... addresses from SEP-23, which multiplex a Stellar G... 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.destination
    • PathPaymentStrictReceive.destination
    • PathPaymentStrictSend.destination
    • Operation.sourceAccount
    • AccountMerge.destination
    • Transaction.sourceAccount

The above changeset also introduces a new high-level object, MuxedAccount (not to be confused with xdr.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 shared Account, passing them along to the supported operations and TransactionBuilder:

  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 test suite (at test/unit/muxed_account_test.js) for more uses of the API.

Update

  • Modernize the minimum-supported browser versions for the library (#419).

Fix

  • Update Typescript test for SetOptions to use authorization flags (e.g. AuthRequiredFlag) correctly (#418).

v5.1.0

07 Apr 21:16
cf3e56f
Compare
Choose a tag to compare

Update

  • The Typescript definitions have been updated to support CAP-35 (#407).

v5.0.0

25 Mar 19:26
c687cf9
Compare
Choose a tag to compare

Add

  • Introduced new CAP-35 operations: ClawbackOp, ClawbackClaimableBalanceOp, and SetTrustLineFlagsOp (#397).

Update

  • Add an additional parameter check to claimClaimableBalance to fail faster (#390).
  • The XDR definitions have been updated to support CAP-35 (#394).

Breaking

  • AllowTrustOpAsset has been renamed to AssetCode (#394).

Deprecated

  • AllowTrustOp is now a deprecated operation (#397).

v4.0.3

13 Nov 20:08
e486ed6
Compare
Choose a tag to compare
v4.0.3 (#382)

v4.0.2

22 Oct 23:33
3a13ffd
Compare
Choose a tag to compare
v4.0.2 (#377)

v4.0.1

22 Oct 23:07
9d79fe6
Compare
Choose a tag to compare

Update

  • Update createAccount operation to accept 0 as the starting balance (#375).

v4.0.0

25 Sep 20:37
293ff99
Compare
Choose a tag to compare

Add

  • Add the Claimant class 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 the balanceId as exposed by Horizon in the /claimable_balances end-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.beginSponsoringFutureReserves
  • Operation.endSponsoringFutureReserves

To revoke a sponsorship after it has been created use any of the following helpers:

  • Operation.revokeAccountSponsorship
  • Operation.revokeTrustlineSponsorship
  • Operation.revokeOfferSponsorship
  • Operation.revokeDataSponsorship
  • Operation.revokeClaimableBalanceSponsorship
  • Operation.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();

Breaking

  • 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 -> setOptions
  • manageDatum -> manageData

v3.0.4

18 Jun 16:01
d5056d7
Compare
Choose a tag to compare

Update

  • Generate V1 transactions by default and allow V0 transactions to be fee bumped (#355).

v3.0.3

22 May 18:43
7fb62f6
Compare
Choose a tag to compare

Remove

  • Rollback support for SEP23 (Muxed Account StrKey) (#349).

v3.0.2 (#345)

04 May 14:53
c24a362
Compare
Choose a tag to compare

Fix

  • Extend files in npm package to include XDR type definitions (#345).