From bbd258fa56e7f0b51fc21020be5f3b01ed4230b6 Mon Sep 17 00:00:00 2001 From: George Date: Thu, 14 Nov 2024 11:34:44 -0800 Subject: [PATCH] Protocol 22 stable release, v13.0.0 (#1103) * Upgrade stellar-base --- CHANGELOG.md | 101 +++++++++++++++++++++++++++++++++++++++++++++++++-- package.json | 4 +- yarn.lock | 32 ++++++++-------- 3 files changed, 116 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 455ccfafe..8f1df5ef5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,12 +6,107 @@ A breaking change will get clearly marked in this log. ## Unreleased -## [v13.0.0-rc.2](https://github.com/stellar/js-stellar-sdk/compare/v12.3.0...v13.0.0-rc.2) + +## [v13.0.0](https://github.com/stellar/js-stellar-sdk/compare/v12.3.0...v13.0.0) +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#signAuthEntries` now takes an `address` instead of a `publicKey`. 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](https://github.com/stellar/js-stellar-sdk/pull/1044)). +- The `ClientOptions.signTransaction` type has been updated to reflect the latest [SEP-43](https://stellar.org/protocol/sep-43#wallet-interface-format) protocol, which matches the latest major version of Freighter and other wallets. It now accepts `address`, `submit`, and `submitUrl` options, and it returns a promise containing the `signedTxXdr` and the `signerAddress`. It now also returns an `Error` type if an error occurs during signing. + * `basicNodeSigner` has been updated to reflect this new type. +- `ClientOptions.signAuthEntry` type has been updated to reflect the [SEP-43](https://stellar.org/protocol/sep-43#wallet-interface-format) protocol, which returns a promise containing the `signerAddress` in addition to the `signAuthEntry` that was returned previously. It also can return an `Error` type. +- `SentTransaction.init` and `new SentTransaction` now take _one_ (1) argument instead of _two_ (2). The first argument had previously been deprecated and ignored. To update: +```diff +-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](https://github.com/stellar/js-stellar-sdk/pull/1084)): + * `simulateTransaction`'s `cost` field is removed + * `rpc.Server.getEvents`'s `pagingToken` field is deprecated, use `cursor` instead +- Deprecated Horizon APIs have been removed (deprecated since [v10.0.1](https://github.com/stellar/js-stellar-sdk/releases/tag/v10.0.1), []()): + * removed fields `transaction_count`, `base_fee`, and `base_reserve` + * removed fields `num_accounts` and `amount` from assets +- The `SorobanRpc` import, previously deprecated, has been removed. You can import `rpc` instead: +```diff +-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.Client` now has a static `deploy` method 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 `__constructor` method in accordance with [CAP-42](https://stellar.org/protocol/cap-42) ([#1086](https://github.com/stellar/js-stellar-sdk/pull/1086/)). For example, using the `increment` test contract as modified in https://github.com/stellar/soroban-test-examples/pull/2/files#diff-8734809100be3803c3ce38064730b4578074d7c2dc5fb7c05ca802b2248b18afR10-R45: +```typescript +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#signAuthEntries` now allows you to override `authorizeEntry`. This can be used to streamline novel workflows using cross-contract auth. ([#1044](https://github.com/stellar/js-stellar-sdk/pull/1044)). + +#### Server modules: the `rpc`, `Horizon`, and `stellartoml` modules. +* `Horizon.ServerApi` now has an `EffectType` exported so that you can compare and infer effect types directly ([#1099](https://github.com/stellar/js-stellar-sdk/pull/1099)). +* `Horizon.ServerApi.Trade` type now has a `type_i` field for type inference ([#1099](https://github.com/stellar/js-stellar-sdk/pull/1099)). +* All effects now expose their type as an exact string ([#947](https://github.com/stellar/js-stellar-sdk/pull/947)). +* `stellartoml.Resolver.resolve` now has a `allowedRedirects` option to configure the number of allowed redirects to follow when resolving a stellar toml file. +* `rpc.Server.getEvents` now returns a `cursor` field that matches `pagingToken` and `id` +* `rpc.Server.getTransactions` now returns a `txHash` field +* `rpc.Server` has two new methods: + - `pollTransaction` to retry transaction retrieval ([#1092]https://github.com/stellar/js-stellar-sdk/pull/1092), and + - `getSACBalance` to fetch the balance of a built-in Stellar Asset Contract token held by a contract ([#1046](https://github.com/stellar/js-stellar-sdk/pull/1046)), returning this schema: +```typescript +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=false` to build without the `axios` dependency: this will build `stellar-sdk-no-axios.js` and `stellar-sdk-no-axios.min.js` in the `dist/` directory, or just run `yarn build:browser:no-axios` to generate these files. + * You can import Node packages without the `axios` dependency 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=false` to build without the `eventsource` dependency: this will build `stellar-sdk-no-eventsource.js` and `stellar-sdk-no-eventsource.min.js` in the `dist/` directory, or just run `yarn build:browser:no-eventsource` to generate these files. + * You can import Node packages without the `eventsource` dependency 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.js` for the browser build and import from `@stellar/stellar-sdk/minimal` for the Node package. + +### Fixed +- `contract.AssembledTransaction#nonInvokerSigningBy` now correctly returns contract addresses, in instances of cross-contract auth, rather than throwing an error. `sign` will ignore these contract addresses, since auth happens via cross-contract call ([#1044](https://github.com/stellar/js-stellar-sdk/pull/1044)). +- `buildInvocationTree` now correctly handles V2 contract creation and displays constructor args ([js-stellar-base#785](https://github.com/stellar/js-stellar-base/pull/785)). + + +## [v13.0.0-rc.2](https://github.com/stellar/js-stellar-sdk/compare/v13.0.0-rc.1...v13.0.0-rc.2) ### Breaking Changes - The `ClientOptions.signTransaction` type has been updated to reflect the latest [SEP-43](https://stellar.org/protocol/sep-43#wallet-interface-format) protocol, which matches the latest major version of Freighter and other wallets. It now accepts `address`, `submit`, and `submitUrl` options, and it returns a promise containing the `signedTxXdr` and the `signerAddress`. It now also returns an `Error` type if an error occurs during signing. * `basicNodeSigner` has been updated to reflect the new type. -- `ClientOptions.signAuthEntry` type has also been updated to reflect the [SEP-43](https://stellar.org/protocol/sep-43#wallet-interface-format) protocol, which also returns a promise containing the `signerAddress` in addition to the `signAuthEntry` that was returned previously. It also can return an `Error` type. +- `ClientOptions.signAuthEntry` type has also been updated to reflect the [SEP-43](https://stellar.org/protocol/sep-43#wallet-interface-format) protocol, which also returns a promise containing the `signerAddress` in addition to the `signAuthEntry` that was returned previously. It also can return an `Error` type. ### Added * `contract.Client` now has a static `deploy` method 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 `__constructor` method in accordance with CAP-42 ([#1086](https://github.com/stellar/js-stellar-sdk/pull/1086/)). @@ -38,7 +133,7 @@ For example, using the `increment` test contract as modified in https://github.c * `stellartoml-Resolver.resolve` now has a `allowedRedirects` option to configure the number of allowed redirects to follow when resolving a stellar toml file. -## [v13.0.0-rc.1](https://github.com/stellar/js-stellar-sdk/compare/v12.3.0...v13.0.0-rc.1) +## [v13.0.0-rc.1](https://github.com/stellar/js-stellar-sdk/compare/v13.0.0-beta.1...v13.0.0-rc.1) ### Breaking Changes - Deprecated RPC APIs have been removed ([#1084](https://github.com/stellar/js-stellar-sdk/pull/1084)): diff --git a/package.json b/package.json index 59d7ea503..15b3d3f90 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@stellar/stellar-sdk", - "version": "13.0.0-rc.2", + "version": "13.0.0", "description": "A library for working with the Stellar network, including communication with the Horizon and Soroban RPC servers.", "keywords": [ "stellar" @@ -213,7 +213,7 @@ "webpack-cli": "^5.0.1" }, "dependencies": { - "@stellar/stellar-base": "^13.0.0", + "@stellar/stellar-base": "^13.0.1", "axios": "^1.7.7", "bignumber.js": "^9.1.2", "eventsource": "^2.0.2", diff --git a/yarn.lock b/yarn.lock index b73f76bd9..5c30c61f0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1257,10 +1257,10 @@ resolved "https://registry.yarnpkg.com/@stellar/js-xdr/-/js-xdr-3.1.2.tgz#db7611135cf21e989602fd72f513c3bed621bc74" integrity sha512-VVolPL5goVEIsvuGqDc5uiKxV03lzfWdvYg1KikvwheDmTBO68CKDji3bAZ/kppZrx5iTA8z3Ld5yuytcvhvOQ== -"@stellar/stellar-base@^13.0.0": - version "13.0.0" - resolved "https://registry.yarnpkg.com/@stellar/stellar-base/-/stellar-base-13.0.0.tgz#cbe5877600ec1aff9822ab671230a60fd026ad8d" - integrity sha512-zS/F1P2MfvgoIlUxOM3PMAEm76qoP5N7HYiww6y6EMP+j3brVFTnTIlJuYdnRdVaPXC/Z4BpojG3bVyhs32Tiw== +"@stellar/stellar-base@^13.0.1": + version "13.0.1" + resolved "https://registry.yarnpkg.com/@stellar/stellar-base/-/stellar-base-13.0.1.tgz#0897f77349ded61e838c0d55519f36f720efe3c9" + integrity sha512-Xbd12mc9Oj/130Tv0URmm3wXG77XMshZtZ2yNCjqX5ZbMD5IYpbBs3DVCteLU/4SLj/Fnmhh1dzhrQXnk4r+pQ== dependencies: "@stellar/js-xdr" "^3.1.2" base32.js "^0.1.0" @@ -1785,9 +1785,9 @@ accepts@~1.3.4: negotiator "0.6.3" ace-builds@^1.4.13: - version "1.36.4" - resolved "https://registry.yarnpkg.com/ace-builds/-/ace-builds-1.36.4.tgz#c859de4a7701aa86a1e708d38cebe66807d0d84c" - integrity sha512-eE+iAsLRfNsq30yd34cezKSob6/N9mQatWs44Bp5LUDgKZ3rJtQds/YtcbnwbEWMTe7yCIxG/Cfezd4BsKIiFg== + version "1.36.5" + resolved "https://registry.yarnpkg.com/ace-builds/-/ace-builds-1.36.5.tgz#ae9cc7a32eccc2f484926131c00545cd6b78a6a6" + integrity sha512-mZ5KVanRT6nLRDLqtG/1YQQLX/gZVC/v526cm1Ru/MTSlrbweSmqv2ZT0d2GaHpJq035MwCMIrj+LgDAUnDXrg== acorn-globals@^3.0.0: version "3.1.0" @@ -3265,9 +3265,9 @@ ee-first@1.1.1: integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow== electron-to-chromium@^1.5.41: - version "1.5.57" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.57.tgz#cb43af8784166bca24565b3418bf5f775a6b1c86" - integrity sha512-xS65H/tqgOwUBa5UmOuNSLuslDo7zho0y/lgQw35pnrqiZh7UOWHCeL/Bt6noJATbA6tpQJGCifsFsIRZj1Fqg== + version "1.5.58" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.58.tgz#d90bd7a04d9223dce4e72316e14492140ec9af40" + integrity sha512-al2l4r+24ZFL7WzyPTlyD0fC33LLzvxqLCwurtBibVPghRGO9hSTl+tis8t1kD7biPiH/en4U0I7o/nQbYeoVA== elliptic@^6.5.3, elliptic@^6.5.5: version "6.6.1" @@ -7253,9 +7253,9 @@ streamroller@^3.1.5: fs-extra "^8.1.0" streamx@^2.15.0: - version "2.20.1" - resolved "https://registry.yarnpkg.com/streamx/-/streamx-2.20.1.tgz#471c4f8b860f7b696feb83d5b125caab2fdbb93c" - integrity sha512-uTa0mU6WUC65iUvzKH4X9hEdvSW7rbPxPtwfWiLMSj3qTdQbAiUboZTxauKfpFuGIGa1C2BYijZ7wgdUXICJhA== + version "2.20.2" + resolved "https://registry.yarnpkg.com/streamx/-/streamx-2.20.2.tgz#6a8911959d6f307c19781a1d19ecd94b5f042d78" + integrity sha512-aDGDLU+j9tJcUdPGOaHmVF1u/hhI+CsGkT02V3OKlHDV7IukOI+nTWAGkiZEKCO35rWN1wIr4tS7YFr1f4qSvA== dependencies: fast-fifo "^1.3.2" queue-tick "^1.0.1" @@ -7786,9 +7786,9 @@ typedarray@^0.0.6: integrity sha512-vA2PUOj2bV0HJSD6/y+Zs6cJvGpvrAtgfHB4UtK6ABFA5s3rCcs2d+zK5WZfzt0hxgI15RI8UzUFj6A4FE/0YQ== "typescript-5.8@npm:typescript@~5.8.0-0": - version "5.8.0-dev.20241113" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.8.0-dev.20241113.tgz#d940ddc2edf73029e7888439bc1b6b1efa31419b" - integrity sha512-UHZg5oh4kRf5PSlyJapVs80pWwb3qxK4MP07PxOz7KDYRf0vWBBepHbZI6Xmx1syYb9M+plmem9PUT2kM2YlzQ== + version "5.8.0-dev.20241114" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.8.0-dev.20241114.tgz#3765ad130591c423dec3a1c3b70705732738d839" + integrity sha512-FCT0wJBcmIXGSTij0CscfHzyI8aOtjnknnrKcSQZ8mzvQ9fQgvpqeIFToCyXkfaHmObw0Lom+J45w7NDh5WIAg== typescript@5.3.3: version "5.3.3"