@stellar/stellar-sdk 11.0.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 (112) hide show
  1. package/CHANGELOG.md +1275 -0
  2. package/LICENSE +228 -0
  3. package/README.md +274 -0
  4. package/dist/stellar-sdk.js +56470 -0
  5. package/dist/stellar-sdk.min.js +2 -0
  6. package/dist/stellar-sdk.min.js.LICENSE.txt +71 -0
  7. package/lib/browser.d.ts +6 -0
  8. package/lib/browser.js +37 -0
  9. package/lib/config.d.ts +52 -0
  10. package/lib/config.js +49 -0
  11. package/lib/contract_spec.d.ts +130 -0
  12. package/lib/contract_spec.js +549 -0
  13. package/lib/errors.d.ts +59 -0
  14. package/lib/errors.js +105 -0
  15. package/lib/federation/api.d.ts +11 -0
  16. package/lib/federation/api.js +7 -0
  17. package/lib/federation/index.d.ts +2 -0
  18. package/lib/federation/index.js +24 -0
  19. package/lib/federation/server.d.ts +118 -0
  20. package/lib/federation/server.js +253 -0
  21. package/lib/friendbot/index.d.ts +5 -0
  22. package/lib/friendbot/index.js +7 -0
  23. package/lib/horizon/account_call_builder.d.ts +55 -0
  24. package/lib/horizon/account_call_builder.js +64 -0
  25. package/lib/horizon/account_response.d.ts +58 -0
  26. package/lib/horizon/account_response.js +50 -0
  27. package/lib/horizon/assets_call_builder.d.ts +27 -0
  28. package/lib/horizon/assets_call_builder.js +45 -0
  29. package/lib/horizon/call_builder.d.ts +128 -0
  30. package/lib/horizon/call_builder.js +360 -0
  31. package/lib/horizon/claimable_balances_call_builder.d.ts +49 -0
  32. package/lib/horizon/claimable_balances_call_builder.js +58 -0
  33. package/lib/horizon/effect_call_builder.d.ts +53 -0
  34. package/lib/horizon/effect_call_builder.js +58 -0
  35. package/lib/horizon/friendbot_builder.d.ts +5 -0
  36. package/lib/horizon/friendbot_builder.js +33 -0
  37. package/lib/horizon/horizon_api.d.ts +523 -0
  38. package/lib/horizon/horizon_api.js +96 -0
  39. package/lib/horizon/horizon_axios_client.d.ts +30 -0
  40. package/lib/horizon/horizon_axios_client.js +48 -0
  41. package/lib/horizon/index.d.ts +7 -0
  42. package/lib/horizon/index.js +78 -0
  43. package/lib/horizon/ledger_call_builder.d.ts +22 -0
  44. package/lib/horizon/ledger_call_builder.js +39 -0
  45. package/lib/horizon/liquidity_pool_call_builder.d.ts +38 -0
  46. package/lib/horizon/liquidity_pool_call_builder.js +61 -0
  47. package/lib/horizon/offer_call_builder.d.ts +64 -0
  48. package/lib/horizon/offer_call_builder.js +81 -0
  49. package/lib/horizon/operation_call_builder.d.ts +68 -0
  50. package/lib/horizon/operation_call_builder.js +71 -0
  51. package/lib/horizon/orderbook_call_builder.d.ts +16 -0
  52. package/lib/horizon/orderbook_call_builder.js +46 -0
  53. package/lib/horizon/path_call_builder.d.ts +31 -0
  54. package/lib/horizon/path_call_builder.js +42 -0
  55. package/lib/horizon/payment_call_builder.d.ts +36 -0
  56. package/lib/horizon/payment_call_builder.js +48 -0
  57. package/lib/horizon/server.d.ts +361 -0
  58. package/lib/horizon/server.js +507 -0
  59. package/lib/horizon/server_api.d.ts +279 -0
  60. package/lib/horizon/server_api.js +19 -0
  61. package/lib/horizon/strict_receive_path_call_builder.d.ts +34 -0
  62. package/lib/horizon/strict_receive_path_call_builder.js +51 -0
  63. package/lib/horizon/strict_send_path_call_builder.d.ts +34 -0
  64. package/lib/horizon/strict_send_path_call_builder.js +51 -0
  65. package/lib/horizon/trade_aggregation_call_builder.d.ts +48 -0
  66. package/lib/horizon/trade_aggregation_call_builder.js +82 -0
  67. package/lib/horizon/trades_call_builder.d.ts +50 -0
  68. package/lib/horizon/trades_call_builder.js +74 -0
  69. package/lib/horizon/transaction_call_builder.d.ts +58 -0
  70. package/lib/horizon/transaction_call_builder.js +66 -0
  71. package/lib/horizon/types/account.d.ts +5 -0
  72. package/lib/horizon/types/account.js +5 -0
  73. package/lib/horizon/types/assets.d.ts +19 -0
  74. package/lib/horizon/types/assets.js +5 -0
  75. package/lib/horizon/types/effects.d.ts +285 -0
  76. package/lib/horizon/types/effects.js +62 -0
  77. package/lib/horizon/types/offer.d.ts +20 -0
  78. package/lib/horizon/types/offer.js +5 -0
  79. package/lib/horizon/types/trade.d.ts +13 -0
  80. package/lib/horizon/types/trade.js +5 -0
  81. package/lib/index.d.ts +14 -0
  82. package/lib/index.js +79 -0
  83. package/lib/soroban/api.d.ts +247 -0
  84. package/lib/soroban/api.js +32 -0
  85. package/lib/soroban/axios.d.ts +3 -0
  86. package/lib/soroban/axios.js +16 -0
  87. package/lib/soroban/browser.d.ts +6 -0
  88. package/lib/soroban/browser.js +37 -0
  89. package/lib/soroban/index.d.ts +8 -0
  90. package/lib/soroban/index.js +72 -0
  91. package/lib/soroban/jsonrpc.d.ts +33 -0
  92. package/lib/soroban/jsonrpc.js +93 -0
  93. package/lib/soroban/parsers.d.ts +17 -0
  94. package/lib/soroban/parsers.js +111 -0
  95. package/lib/soroban/server.d.ts +427 -0
  96. package/lib/soroban/server.js +598 -0
  97. package/lib/soroban/transaction.d.ts +20 -0
  98. package/lib/soroban/transaction.js +55 -0
  99. package/lib/soroban/utils.d.ts +1 -0
  100. package/lib/soroban/utils.js +9 -0
  101. package/lib/stellartoml/index.d.ts +121 -0
  102. package/lib/stellartoml/index.js +78 -0
  103. package/lib/utils.d.ts +12 -0
  104. package/lib/utils.js +32 -0
  105. package/lib/webauth/errors.d.ts +4 -0
  106. package/lib/webauth/errors.js +37 -0
  107. package/lib/webauth/index.d.ts +2 -0
  108. package/lib/webauth/index.js +27 -0
  109. package/lib/webauth/utils.d.ts +294 -0
  110. package/lib/webauth/utils.js +332 -0
  111. package/package.json +153 -0
  112. package/types/dom-monkeypatch.d.ts +126 -0
package/LICENSE ADDED
@@ -0,0 +1,228 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2015 Stellar Development Foundation
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
203
+
204
+ ----
205
+
206
+ Included code for base58 encoding is licensed under the MIT license:
207
+
208
+ Copyright (c) 2011 Google Inc
209
+ Copyright (c) 2013 BitPay Inc
210
+
211
+ Permission is hereby granted, free of charge, to any person obtaining a copy
212
+ of this software and associated documentation files (the "Software"), to deal
213
+ in the Software without restriction, including without limitation the rights
214
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
215
+ copies of the Software, and to permit persons to whom the Software is
216
+ furnished to do so, subject to the following conditions:
217
+
218
+ The above copyright notice and this permission notice shall be included in
219
+ all copies or substantial portions of the Software.
220
+
221
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
222
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
223
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
224
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
225
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
226
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
227
+ THE SOFTWARE.
228
+
package/README.md ADDED
@@ -0,0 +1,274 @@
1
+ <div align="center">
2
+ <img alt="Stellar" src="https://github.com/stellar/.github/raw/master/stellar-logo.png" width="558" />
3
+ <br/>
4
+ <strong>Creating equitable access to the global financial system</strong>
5
+ <h1>js-stellar-sdk</h1>
6
+ </div>
7
+
8
+ <p align="center">
9
+ <a href="https://badge.fury.io/js/stellar-sdk"><img src="https://badge.fury.io/js/stellar-sdk.svg" alt="npm version" height="18"></a>
10
+ <a href="https://www.npmjs.com/package/stellar-sdk">
11
+ <img alt="Weekly Downloads" src="https://img.shields.io/npm/dw/stellar-sdk" />
12
+ </a>
13
+ <a href="https://github.com/stellar/js-stellar-sdk/actions/workflows/tests.yml"><img alt="Test Status" src="https://github.com/stellar/js-stellar-sdk/actions/workflows/tests.yml/badge.svg" /></a>
14
+ </p>
15
+
16
+ js-stellar-sdk is a Javascript library for communicating with a
17
+ [Stellar Horizon server](https://github.com/stellar/go/tree/master/services/horizon).
18
+ It is used for building Stellar apps either on Node.js or in the browser.
19
+
20
+ It provides:
21
+
22
+ - a networking layer API for Horizon endpoints.
23
+ - facilities for building and signing transactions, for communicating with a
24
+ Stellar Horizon instance, and for submitting transactions or querying network
25
+ history.
26
+
27
+ ### stellar-sdk vs stellar-base
28
+
29
+ stellar-sdk is a high-level library that serves as client-side API for Horizon.
30
+ [stellar-base](https://github.com/stellar/js-stellar-base) is lower-level
31
+ library for creating Stellar primitive constructs via XDR helpers and wrappers.
32
+
33
+ **Most people will want stellar-sdk instead of stellar-base.** You should only
34
+ use stellar-base if you know what you're doing!
35
+
36
+ If you add `stellar-sdk` to a project, **do not add `stellar-base`!** Mis-matching
37
+ versions could cause weird, hard-to-find bugs. `stellar-sdk` automatically
38
+ installs `stellar-base` and exposes all of its exports in case you need them.
39
+
40
+ > **Important!** The Node.js version of the `stellar-base` (`stellar-sdk` dependency) package
41
+ > uses the [`sodium-native`](https://www.npmjs.com/package/sodium-native) package as
42
+ > an [optional dependency](https://docs.npmjs.com/files/package.json#optionaldependencies). `sodium-native` is
43
+ > a low level binding to [libsodium](https://github.com/jedisct1/libsodium),
44
+ > (an implementation of [Ed25519](https://ed25519.cr.yp.to/) signatures).
45
+ > If installation of `sodium-native` fails, or it is unavailable, `stellar-base` (and `stellar-sdk`) will
46
+ > fallback to using the [`tweetnacl`](https://www.npmjs.com/package/tweetnacl) package implementation.
47
+ >
48
+ > If you are using `stellar-sdk`/`stellar-base` in a browser you can ignore
49
+ > this. However, for production backend deployments you should be
50
+ > using `sodium-native`. If `sodium-native` is successfully installed and working the
51
+ > `StellarSdk.FastSigning` variable will return `true`.
52
+
53
+ ## Quick start
54
+
55
+ Using npm to include js-stellar-sdk in your own project:
56
+
57
+ ```shell
58
+ npm install --save stellar-sdk
59
+ ```
60
+
61
+ Alternatively, you can use cdnjs in a browser:
62
+
63
+ ```html
64
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/stellar-sdk/{version}/stellar-sdk.js"></script>
65
+ ````
66
+
67
+ ## Install
68
+
69
+ ### To use as a module in a Node.js project
70
+
71
+ 1. Install it using npm:
72
+
73
+ ```shell
74
+ npm install --save stellar-sdk
75
+ ```
76
+
77
+ 2. require/import it in your JavaScript:
78
+
79
+ ```js
80
+ var StellarSdk = require('stellar-sdk');
81
+ ```
82
+
83
+ ### To self host for use in the browser
84
+
85
+ 1. Install it using [bower](http://bower.io):
86
+
87
+ ```shell
88
+ bower install stellar-sdk
89
+ ```
90
+
91
+ 2. Include it in the browser:
92
+
93
+ ```html
94
+ <script src="./bower_components/stellar-sdk/stellar-sdk.js"></script>
95
+ <script>
96
+ console.log(StellarSdk);
97
+ </script>
98
+ ```
99
+
100
+ If you don't want to use or install Bower, you can copy built JS files from the
101
+ [bower-js-stellar-sdk repo](https://github.com/stellar/bower-js-stellar-sdk).
102
+
103
+ ### To use the [cdnjs](https://cdnjs.com/libraries/stellar-sdk) hosted script in the browser
104
+
105
+ 1. Instruct the browser to fetch the library from
106
+ [cdnjs](https://cdnjs.com/libraries/stellar-sdk), a 3rd party service that
107
+ hosts js libraries:
108
+
109
+ ```html
110
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/stellar-sdk/{version}/stellar-sdk.js"></script>
111
+ <script>
112
+ console.log(StellarSdk);
113
+ </script>
114
+ ```
115
+
116
+ Note that this method relies using a third party to host the JS library. This
117
+ may not be entirely secure.
118
+
119
+ Make sure that you are using the latest version number. They can be found on the
120
+ [releases page in Github](https://github.com/stellar/js-stellar-sdk/releases).
121
+
122
+ ### To develop and test js-stellar-sdk itself
123
+
124
+ 1. Clone the repo:
125
+
126
+ ```shell
127
+ git clone https://github.com/stellar/js-stellar-sdk.git
128
+ ```
129
+
130
+ 2. Install dependencies inside js-stellar-sdk folder:
131
+
132
+ ```shell
133
+ cd js-stellar-sdk
134
+ npm install
135
+ ```
136
+
137
+ 3. Install Node 16
138
+
139
+ Because we support the oldest maintenance version of Node, please install and develop on Node 16 so you don't get surprised when your code works locally but breaks in CI.
140
+
141
+ Here's how to install `nvm` if you haven't: https://github.com/creationix/nvm
142
+
143
+ ```shell
144
+ nvm install
145
+
146
+ # if you've never installed 16 before you'll want to re-install yarn
147
+ npm install -g yarn
148
+ ```
149
+
150
+ If you work on several projects that use different Node versions, you might it
151
+ helpful to install this automatic version manager:
152
+ https://github.com/wbyoung/avn
153
+
154
+ 4. Observe the project's code style
155
+
156
+ While you're making changes, make sure to run the linter-watcher to catch any
157
+ linting errors (in addition to making sure your text editor supports ESLint)
158
+
159
+ ```shell
160
+ node_modules/.bin/gulp watch
161
+ ```
162
+
163
+
164
+ ## Usage
165
+
166
+ For information on how to use js-stellar-sdk, take a look at [the
167
+ documentation](https://stellar.github.io/js-stellar-sdk/), or [the
168
+ examples](https://github.com/stellar/js-stellar-sdk/tree/master/docs/reference).
169
+
170
+ There is also Horizon REST API Documentation
171
+ [here](https://developers.stellar.org/api/introduction/).
172
+
173
+ ### Usage with React-Native
174
+
175
+ 1. Install `yarn add --dev rn-nodeify`
176
+ 2. Add the following postinstall script:
177
+ ```
178
+ yarn rn-nodeify --install url,events,https,http,util,stream,crypto,vm,buffer --hack --yarn
179
+ ```
180
+ 3. Uncomment `require('crypto')` on shim.js
181
+ 4. `react-native link react-native-randombytes`
182
+ 5. Create file `rn-cli.config.js`
183
+ ```
184
+ module.exports = {
185
+ resolver: {
186
+ extraNodeModules: require("node-libs-react-native"),
187
+ },
188
+ };
189
+ ```
190
+ 6. Add `import "./shim";` to the top of `index.js`
191
+ 7. `yarn add stellar-sdk`
192
+
193
+ There is also a [sample](https://github.com/fnando/rn-stellar-sdk-sample) that you can follow.
194
+
195
+ #### Using in an Expo managed workflow
196
+
197
+ 1. Install `yarn add --dev rn-nodeify`
198
+ 2. Add the following postinstall script:
199
+ ```
200
+ yarn rn-nodeify --install process,url,events,https,http,util,stream,crypto,vm,buffer --hack --yarn
201
+ ```
202
+ 3. Add `import "./shim";` to the your app's entry point (by default `./App.js`)
203
+ 4. `yarn add stellar-sdk`
204
+ 5. `expo install expo-random`
205
+
206
+ At this point, the Stellar SDK will work, except that `StellarSdk.Keypair.random()` will throw an error. To work around this, you can create your own method to generate a random keypair like this:
207
+
208
+ ```javascript
209
+ import * as Random from 'expo-random';
210
+ import StellarSdk from 'stellar-sdk';
211
+
212
+ const generateRandomKeypair = () => {
213
+ const randomBytes = Random.getRandomBytes(32);
214
+
215
+ return StellarSdk.Keypair.fromRawEd25519Seed(Buffer.from(randomBytes));
216
+ };
217
+ ```
218
+
219
+ ## Testing
220
+
221
+ To run all tests:
222
+
223
+ ```shell
224
+ yarn test
225
+ ```
226
+
227
+ To run a specific set of tests:
228
+
229
+ ```shell
230
+ yarn test:node
231
+ yarn test:browser
232
+ ```
233
+
234
+ To generate and check the documentation site:
235
+
236
+ ```shell
237
+ # install the `serve` command if you don't have it already
238
+ npm install -g serve
239
+
240
+ # generate the docs files
241
+ yarn docs
242
+
243
+ # get these files working in a browser
244
+ cd jsdoc && serve .
245
+
246
+ # you'll be able to browse the docs at http://localhost:5000
247
+ ```
248
+
249
+ ## Documentation
250
+
251
+ Documentation for this repo lives in
252
+ [Developers site](https://github.com/stellar/js-stellar-sdk/blob/master/docs/reference/readme.md).
253
+
254
+ ## Contributing
255
+
256
+ For information on how to contribute, please refer to our
257
+ [contribution guide](https://github.com/stellar/js-stellar-sdk/blob/master/CONTRIBUTING.md).
258
+
259
+ ## Publishing to npm
260
+
261
+ ```
262
+ npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease]
263
+ ```
264
+
265
+ A new version will be published to npm **and** Bower by GitHub actions.
266
+
267
+ npm >= 2.13.0 required. Read more about
268
+ [npm version](https://docs.npmjs.com/cli/version).
269
+
270
+ ## License
271
+
272
+ js-stellar-sdk is licensed under an Apache-2.0 license. See the
273
+ [LICENSE](https://github.com/stellar/js-stellar-sdk/blob/master/LICENSE) file
274
+ for details.