Releases: stellar/js-stellar-base
v5.3.0
Add
- 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 passingtrue
as the last parameter,withMuxing
) toTransactionBuilder.buildFeeBumpTransaction
to make thefeeSource
a fully-muxed account instance (#434).
v5.2.1
v5.2.0
Add
- 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 theTransaction.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
v5.0.0
Add
- Introduced new CAP-35 operations:
ClawbackOp
,ClawbackClaimableBalanceOp
, andSetTrustLineFlagsOp
(#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 toAssetCode
(#394).
Deprecated
AllowTrustOp
is now a deprecated operation (#397).
v4.0.3
v4.0.2
v4.0.1
v4.0.0
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 thebalanceId
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