@stellar/stellar-sdk 12.0.0 → 12.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/CHANGELOG.md +116 -1
  2. package/README.md +1 -1
  3. package/dist/stellar-sdk.js +3089 -1219
  4. package/dist/stellar-sdk.min.js +1 -1
  5. package/lib/browser.js +1 -1
  6. package/lib/config.js +3 -3
  7. package/lib/{contract_client → contract}/assembled_transaction.d.ts +154 -59
  8. package/lib/{contract_client → contract}/assembled_transaction.js +403 -187
  9. package/lib/{contract_client → contract}/basic_node_signer.d.ts +2 -2
  10. package/lib/{contract_client → contract}/basic_node_signer.js +5 -5
  11. package/lib/contract/client.d.ts +53 -0
  12. package/lib/contract/client.js +180 -0
  13. package/lib/contract/index.d.ts +8 -0
  14. package/lib/{contract_client → contract}/index.js +37 -9
  15. package/lib/{rust_types/result.js → contract/rust_result.js} +3 -3
  16. package/lib/{contract_client → contract}/sent_transaction.d.ts +27 -18
  17. package/lib/{contract_client → contract}/sent_transaction.js +49 -47
  18. package/lib/{contract_spec.d.ts → contract/spec.d.ts} +3 -3
  19. package/lib/{contract_spec.js → contract/spec.js} +169 -169
  20. package/lib/{contract_client → contract}/types.d.ts +15 -8
  21. package/lib/contract/utils.d.ts +44 -0
  22. package/lib/{contract_client → contract}/utils.js +47 -5
  23. package/lib/errors.js +10 -10
  24. package/lib/federation/server.js +10 -10
  25. package/lib/horizon/account_call_builder.d.ts +1 -0
  26. package/lib/horizon/account_call_builder.js +8 -8
  27. package/lib/horizon/account_response.js +7 -7
  28. package/lib/horizon/assets_call_builder.d.ts +1 -0
  29. package/lib/horizon/assets_call_builder.js +8 -8
  30. package/lib/horizon/call_builder.js +6 -6
  31. package/lib/horizon/claimable_balances_call_builder.d.ts +1 -0
  32. package/lib/horizon/claimable_balances_call_builder.js +8 -8
  33. package/lib/horizon/effect_call_builder.d.ts +1 -0
  34. package/lib/horizon/effect_call_builder.js +8 -8
  35. package/lib/horizon/friendbot_builder.d.ts +1 -0
  36. package/lib/horizon/friendbot_builder.js +8 -8
  37. package/lib/horizon/horizon_api.d.ts +1 -0
  38. package/lib/horizon/horizon_axios_client.js +1 -1
  39. package/lib/horizon/ledger_call_builder.d.ts +1 -0
  40. package/lib/horizon/ledger_call_builder.js +8 -8
  41. package/lib/horizon/liquidity_pool_call_builder.d.ts +1 -0
  42. package/lib/horizon/liquidity_pool_call_builder.js +8 -8
  43. package/lib/horizon/offer_call_builder.d.ts +1 -0
  44. package/lib/horizon/offer_call_builder.js +8 -8
  45. package/lib/horizon/operation_call_builder.d.ts +1 -0
  46. package/lib/horizon/operation_call_builder.js +8 -8
  47. package/lib/horizon/orderbook_call_builder.d.ts +1 -0
  48. package/lib/horizon/orderbook_call_builder.js +8 -8
  49. package/lib/horizon/path_call_builder.d.ts +1 -0
  50. package/lib/horizon/path_call_builder.js +8 -8
  51. package/lib/horizon/payment_call_builder.d.ts +1 -0
  52. package/lib/horizon/payment_call_builder.js +8 -8
  53. package/lib/horizon/server.js +6 -6
  54. package/lib/horizon/strict_receive_path_call_builder.d.ts +1 -0
  55. package/lib/horizon/strict_receive_path_call_builder.js +8 -8
  56. package/lib/horizon/strict_send_path_call_builder.d.ts +1 -0
  57. package/lib/horizon/strict_send_path_call_builder.js +8 -8
  58. package/lib/horizon/trade_aggregation_call_builder.d.ts +1 -0
  59. package/lib/horizon/trade_aggregation_call_builder.js +8 -8
  60. package/lib/horizon/trades_call_builder.d.ts +1 -0
  61. package/lib/horizon/trades_call_builder.js +8 -8
  62. package/lib/horizon/transaction_call_builder.d.ts +1 -0
  63. package/lib/horizon/transaction_call_builder.js +8 -8
  64. package/lib/index.d.ts +27 -2
  65. package/lib/index.js +10 -16
  66. package/lib/{soroban → rpc}/api.d.ts +25 -10
  67. package/lib/{soroban → rpc}/axios.js +1 -1
  68. package/lib/{soroban → rpc}/browser.js +1 -1
  69. package/lib/rpc/index.d.ts +8 -0
  70. package/lib/{soroban → rpc}/index.js +1 -1
  71. package/lib/{soroban → rpc}/jsonrpc.js +3 -3
  72. package/lib/{soroban → rpc}/parsers.js +12 -3
  73. package/lib/{soroban → rpc}/server.d.ts +50 -0
  74. package/lib/{soroban → rpc}/server.js +209 -128
  75. package/lib/stellartoml/index.js +6 -6
  76. package/lib/utils.js +3 -3
  77. package/lib/webauth/errors.js +10 -10
  78. package/lib/webauth/utils.js +9 -9
  79. package/package.json +38 -30
  80. package/lib/contract_client/client.d.ts +0 -17
  81. package/lib/contract_client/client.js +0 -57
  82. package/lib/contract_client/index.d.ts +0 -6
  83. package/lib/contract_client/utils.d.ts +0 -23
  84. package/lib/rust_types/index.d.ts +0 -1
  85. package/lib/rust_types/index.js +0 -16
  86. package/lib/soroban/index.d.ts +0 -7
  87. /package/lib/{rust_types/result.d.ts → contract/rust_result.d.ts} +0 -0
  88. /package/lib/{contract_client → contract}/types.js +0 -0
  89. /package/lib/{soroban → rpc}/api.js +0 -0
  90. /package/lib/{soroban → rpc}/axios.d.ts +0 -0
  91. /package/lib/{soroban → rpc}/browser.d.ts +0 -0
  92. /package/lib/{soroban → rpc}/jsonrpc.d.ts +0 -0
  93. /package/lib/{soroban → rpc}/parsers.d.ts +0 -0
  94. /package/lib/{soroban → rpc}/transaction.d.ts +0 -0
  95. /package/lib/{soroban → rpc}/transaction.js +0 -0
  96. /package/lib/{soroban → rpc}/utils.d.ts +0 -0
  97. /package/lib/{soroban → rpc}/utils.js +0 -0
package/CHANGELOG.md CHANGED
@@ -7,6 +7,121 @@ A breaking change will get clearly marked in this log.
7
7
  ## Unreleased
8
8
 
9
9
 
10
+ ## [v12.1.0](https://github.com/stellar/js-stellar-sdk/compare/v12.0.1...v12.1.0)
11
+
12
+ ### Added
13
+ - `contract` now exports the `DEFAULT_TIMEOUT` ([#984](https://github.com/stellar/js-stellar-sdk/pull/984)).
14
+ - `contract.AssembledTransaction` now has:
15
+ - `toXDR` and `fromXDR` methods for serializing the transaction to and from XDR. These methods should be used in place of `AssembledTransaction.toJSON` and `AssembledTransaction.fromJSON`for multi-auth signing. The JSON methods are now deprecated. **Note:** you must now call `simulate` on the transaction before the final `signAndSend` call after all required signatures are gathered when using the XDR methods ([#977](https://github.com/stellar/js-stellar-sdk/pull/977)).
16
+ - a `restoreFootprint` method which accepts the `restorePreamble` returned when a simulation call fails due to some contract state that has expired. When invoking a contract function, one can now set `restore` to `true` in the `MethodOptions`. When enabled, a `restoreFootprint` transaction will be created and await signing when required ([#991](https://github.com/stellar/js-stellar-sdk/pull/991)).
17
+ - separate `sign` and `send` methods so that you can sign a transaction without sending it (`signAndSend` still works as before; [#922](https://github.com/stellar/js-stellar-sdk/pull/992)).
18
+ - `contract.Client` now has a `txFromXDR` method which should be used in place of `txFromJSON` for multi-auth signing ([#977](https://github.com/stellar/js-stellar-sdk/pull/977)).
19
+
20
+ ### Deprecated
21
+ - In `contract.AssembledTransaction`, `toJSON` and `fromJSON` should be replaced with `toXDR` and `fromXDR`.
22
+ - In `contract.Client`, `txFromJSON` should be replaced with `txFromXDR`.
23
+
24
+ ### Fixed
25
+ - If you edit an `AssembledTransaction` with `tx.raw = cloneFrom(tx.build)`, the `tx.simulationData` will now be updated correctly ([#985](https://github.com/stellar/js-stellar-sdk/pull/985)).
26
+
27
+
28
+ ## [v12.0.1](https://github.com/stellar/js-stellar-sdk/compare/v11.3.0...v12.0.1)
29
+
30
+ - This is a re-tag of `v12.0.0-rc.3` with dependency updates and a single new feature.
31
+
32
+ ### Added
33
+ - `rpc.server.simulateTransaction` now supports an optional `stateChanges?: LedgerEntryChange[]` field ([#963](https://github.com/stellar/js-stellar-sdk/pull/963)):
34
+ * If `Before` is omitted, it constitutes a creation, if `After` is omitted, it constitutes a deletions, note that `Before` and `After` cannot be be omitted at the same time. Each item follows this schema:
35
+
36
+ ```typescript
37
+ interface LedgerEntryChange {
38
+ type: number;
39
+ key: xdr.LedgerKey;
40
+ before: xdr.LedgerEntry | null;
41
+ after: xdr.LedgerEntry | null;
42
+ }
43
+ ```
44
+
45
+
46
+ ## [v12.0.0-rc.3](https://github.com/stellar/js-stellar-sdk/compare/v11.3.0...v12.0.0-rc.3)
47
+
48
+ ### Breaking Changes
49
+
50
+ - `ContractClient` functionality previously added in [v11.3.0](https://github.com/stellar/js-stellar-sdk/releases/tag/v11.3.0) was exported in a non-standard way. You can now import it as any other `stellar-sdk` module ([#962](https://github.com/stellar/js-stellar-sdk/pull/962)):
51
+
52
+ ```diff
53
+ -import { ContractClient } from '@stellar/stellar-sdk/lib/contract_client'
54
+ +import { contract } from '@stellar/stellar-sdk'
55
+ +const { Client } = contract
56
+ ```
57
+
58
+ Note 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](https://github.com/stellar/js-stellar-base/blob/b96281b9b3f94af23a913f93bdb62477f5434ccc/src/contract.js#L6-L19). 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.
59
+
60
+ Additionally, this is available from the `/contract` entrypoint, if your version of Node [and TypeScript](https://stackoverflow.com/a/70020984/249801) support [the `exports` declaration](https://nodejs.org/api/packages.html#exports). Finally, some of its exports have been renamed:
61
+
62
+ ```diff
63
+ import {
64
+ - ContractClient,
65
+ + Client,
66
+ AssembledTransaction,
67
+ - ContractClientOptions,
68
+ + ClientOptions,
69
+ SentTransaction,
70
+ -} from '@stellar/stellar-sdk/lib/contract_client'
71
+ +} from '@stellar/stellar-sdk/contract'
72
+ ```
73
+
74
+ - The `ContractSpec` class is now nested under the `contract` module, and has been **renamed** to `Spec` ([#962](https://github.com/stellar/js-stellar-sdk/pull/962)). Alternatively, you can import this from the `contract` entrypoint, if your version of Node [and TypeScript](https://stackoverflow.com/a/70020984/249801) support [the `exports` declaration](https://nodejs.org/api/packages.html#exports):
75
+
76
+ ```diff
77
+ -import { ContractSpec } from '@stellar/stellar-sdk'
78
+ +import { contract } from '@stellar/stellar-sdk'
79
+ +const { Spec } = contract
80
+ // OR
81
+ +import { Spec } from '@stellar/stellar-sdk/contract'
82
+ ```
83
+
84
+ - Previously, `AssembledTransaction.signAndSend()` would return a `SentTransaction` even if the transaction never finalized. That is, if it successfully sent the transaction to the network, but the transaction was still `status: 'PENDING'`, then it would `console.error` an error message, but return the indeterminate transaction anyhow. **It now throws** a `SentTransaction.Errors.TransactionStillPending` error with that error message instead ([#962](https://github.com/stellar/js-stellar-sdk/pull/962)).
85
+
86
+ ### Deprecated
87
+
88
+ - `SorobanRpc` module is now also exported as `rpc` ([#962](https://github.com/stellar/js-stellar-sdk/pull/962)). You can import it with either name for now, but `SorobanRpc` will be removed in a future release:
89
+
90
+ ```diff
91
+ -import { SorobanRpc } from '@stellar/stellar-sdk'
92
+ +import { rpc } from '@stellar/stellar-sdk'
93
+ ```
94
+
95
+ You can also now import it at the `/rpc` entrypoint, if your version of Node [and TypeScript](https://stackoverflow.com/a/70020984/249801) support [the `exports` declaration](https://nodejs.org/api/packages.html#exports).
96
+
97
+ ```diff
98
+ -import { SorobanRpc } from '@stellar/stellar-sdk'
99
+ -const { Api } = SorobanRpc
100
+ +import { Api } from '@stellar/stellar-sdk/rpc'
101
+ ```
102
+
103
+ ### Added
104
+ * New methods on `contract.Client` ([#960](https://github.com/stellar/js-stellar-sdk/pull/960)):
105
+ - `from(opts: ContractClientOptions)` instantiates `contract.Client` by fetching the `contractId`'s WASM from the network to fill out the client's `ContractSpec`.
106
+ - `fromWasm` and `fromWasmHash` methods to instantiate a `contract.Client` when you already have the WASM bytes or hash alongside the `contract.ClientOptions`.
107
+ * New methods on `rpc.Server` ([#960](https://github.com/stellar/js-stellar-sdk/pull/960)):
108
+ - `getContractWasmByContractId` and `getContractWasmByHash` to retrieve a contract's WASM bytecode via its `contractId` or `wasmHash`, respectively.
109
+
110
+ ### Fixed
111
+ * 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 `contract` module to be used in non-Node environments.
112
+
113
+
114
+ ## [v12.0.0-rc.2](https://github.com/stellar/js-stellar-sdk/compare/v11.3.0...v12.0.0-rc.2)
115
+
116
+ **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](https://github.com/stellar/js-stellar-sdk/pull/949)).
117
+
118
+ ### Breaking Changes
119
+ * The **default timeout for transaction calls is now set to 300 seconds (5 minutes)** from the previous default of 10 seconds. 10 seconds is often not enough time to review transactions before signing, especially in Freighter or using a hardware wallet like a Ledger, which would cause a `txTooLate` error response from the server. Five minutes is also the value used by the CLI, so this brings the two into alignment ([#956](https://github.com/stellar/js-stellar-sdk/pull/956)).
120
+
121
+ ### Fixed
122
+ * Dependencies have been properly updated to pull in Protocol 21 XDR ([#959](https://github.com/stellar/js-stellar-sdk/pull/959)).
123
+
124
+
10
125
  ## [v12.0.0-rc.1](https://github.com/stellar/js-stellar-sdk/compare/v11.3.0...v12.0.0-rc.1)
11
126
 
12
127
  ### Breaking Changes
@@ -17,7 +132,7 @@ A breaking change will get clearly marked in this log.
17
132
  * `ContractClient` now properly handles methods that take no arguments by making `MethodOptions` the only parameter, bringing it inline with the types generated by Soroban CLI's `soroban contract bindings typescript` ([#940](https://github.com/stellar/js-stellar-sdk/pull/940)).
18
133
  * `ContractClient` now allows `publicKey` to be undefined ([#941](https://github.com/stellar/js-stellar-sdk/pull/941)).
19
134
  * `SentTransaction` will only pass `allowHttp` if (and only if) its corresponding `AssembledTransaction#options` config allowed it ([#952](https://github.com/stellar/js-stellar-sdk/pull/952)).
20
-
135
+ * `SentTransaction` will now modify the time bounds of the transaction to be `timeoutInSeconds` seconds after the transaction has been simulated. Previously this was set when the transaction is built, before the simulation. This makes the time bounds line up with the timeout retry logic in `SentTransaction`.
21
136
 
22
137
  ## [v11.3.0](https://github.com/stellar/js-stellar-sdk/compare/v11.2.2...v11.3.0)
23
138
 
package/README.md CHANGED
@@ -96,7 +96,7 @@ The usage documentation for this library lives in a handful of places:
96
96
  You can also refer to:
97
97
 
98
98
  * the [documentation](https://developers.stellar.org/network/horizon) for the Horizon REST API (if using the `Horizon` module) and
99
- * the [documentation](https://soroban.stellar.org/docs/reference/rpc) for Soroban RPC's API (if using the `SorobanRpc` module)
99
+ * the [documentation](https://soroban.stellar.org/docs/reference/rpc) for Soroban RPC's API (if using the `rpc` module)
100
100
 
101
101
  ### Usage with React-Native
102
102