v12.0.0-rc.3: Protocol 21 Release Candidate 3
This update supports Protocol 21. It is an additive change to the protocol so there are no true backwards incompatibilities, but your software may break if you encounter new unexpected fields from this Protocol (#949).
Breaking Changes
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.
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.
Full Changelog: v11.3.0...v12.0.0-rc.3