@huma-finance/soroban-tranche-vault 0.0.8-beta.2

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.
package/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # tb-trancheVault JS
2
+
3
+ JS library for interacting with [Soroban](https://soroban.stellar.org/) smart contract `tb-trancheVault` via Soroban RPC.
4
+
5
+ This library was automatically generated by Soroban CLI using a command similar to:
6
+
7
+ ```bash
8
+ soroban contract bindings ts \
9
+ --rpc-url https://soroban-testnet.stellar.org:443 \
10
+ --network-passphrase "Test SDF Network ; September 2015" \
11
+ --contract-id CDXI5L5EFHBW3KYY3D6JGXJTGDOG5EZAQUDAK5LWZQVH4TEUDAO7PBGU \
12
+ --output-dir ./path/to/tb-trancheVault
13
+ ```
14
+
15
+ The network passphrase and contract ID are exported from [index.ts](./src/index.ts) in the `networks` constant. If you are the one who generated this library and you know that this contract is also deployed to other networks, feel free to update `networks` with other valid options. This will help your contract consumers use this library more easily.
16
+
17
+ # To publish or not to publish
18
+
19
+ This library is suitable for publishing to NPM. You can publish it to NPM using the `npm publish` command.
20
+
21
+ But you don't need to publish this library to NPM to use it. You can add it to your project's `package.json` using a file path:
22
+
23
+ ```json
24
+ "dependencies": {
25
+ "tb-trancheVault": "./path/to/this/folder"
26
+ }
27
+ ```
28
+
29
+ However, we've actually encountered [frustration](https://github.com/stellar/soroban-example-dapp/pull/117#discussion_r1232873560) using local libraries with NPM in this way. Though it seems a bit messy, we suggest generating the library directly to your `node_modules` folder automatically after each install by using a `postinstall` script. We've had the least trouble with this approach. NPM will automatically remove what it sees as erroneous directories during the `install` step, and then regenerate them when it gets to your `postinstall` step, which will keep the library up-to-date with your contract.
30
+
31
+ ```json
32
+ "scripts": {
33
+ "postinstall": "soroban contract bindings ts --rpc-url https://soroban-testnet.stellar.org:443 --network-passphrase \"Test SDF Network ; September 2015\" --id CDXI5L5EFHBW3KYY3D6JGXJTGDOG5EZAQUDAK5LWZQVH4TEUDAO7PBGU --name tb-trancheVault"
34
+ }
35
+ ```
36
+
37
+ Obviously you need to adjust the above command based on the actual command you used to generate the library.
38
+
39
+ # Use it
40
+
41
+ Now that you have your library up-to-date and added to your project, you can import it in a file and see inline documentation for all of its exported methods:
42
+
43
+ ```js
44
+ import { Contract, networks } from "tb-trancheVault"
45
+
46
+ const contract = new Contract({
47
+ ...networks.futurenet, // for example; check which networks this library exports
48
+ rpcUrl: '...', // use your own, or find one for testing at https://soroban.stellar.org/docs/reference/rpc#public-rpc-providers
49
+ })
50
+
51
+ contract.|
52
+ ```
53
+
54
+ As long as your editor is configured to show JavaScript/TypeScript documentation, you can pause your typing at that `|` to get a list of all exports and inline-documentation for each. It exports a separate [async](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function) function for each method in the smart contract, with documentation for each generated from the comments the contract's author included in the original source code.