Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix documentation rendering #965

Merged
merged 67 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
9ee3090
update README badges
ElliotFriend May 10, 2024
8317c6c
remove conflicting class tags from call builder classes
ElliotFriend May 10, 2024
96b0796
Merge branch 'master' into 920-documentation-rendering
ElliotFriend May 11, 2024
a5e188d
removing old soroban links in README.md
ElliotFriend May 13, 2024
82335be
changing old soroban link in another readme file
ElliotFriend May 13, 2024
cdfe297
changing old soroban links to new home in dev docs
ElliotFriend May 13, 2024
e7d721c
make WebAuth show up as a namespace
ElliotFriend May 13, 2024
8bc0f5a
collect methods and classes into a SorobanRpc namespace for JSDoc
ElliotFriend May 14, 2024
887f35c
create a Horizon JSDoc namespace and add the server class to it
ElliotFriend May 14, 2024
0b5b3e8
fix broken links to API dev docs
ElliotFriend May 14, 2024
1c7c9b0
add the Durability enum to the SorobanRPC JSDoc namespace
ElliotFriend May 14, 2024
f1eb36a
fix links to the SorobanRPC server methods
ElliotFriend May 14, 2024
22db24a
link call builders to the horizon.server methods
ElliotFriend May 14, 2024
9d663a1
create a util namespace and add validateTimebounds to it
ElliotFriend May 14, 2024
c1d6a11
remove unnecessary code blocks from ContractSpec examples
ElliotFriend May 14, 2024
aee50b1
group some const declarations into more relevant namespaces/classes
ElliotFriend May 14, 2024
94bd492
make a stellartoml JSDoc namespace
ElliotFriend May 14, 2024
ce3d74c
flesh out the jsdoc info for the jsonrpc postObject function
ElliotFriend May 14, 2024
d908609
some minor jsdoc fixups
ElliotFriend May 14, 2024
9f4555b
make federation a module, include the typedefs
ElliotFriend May 16, 2024
260b9c2
add throws tags to federation methods
ElliotFriend May 16, 2024
879b9b5
mark most of the "call builder" classes as private in JSDoc
ElliotFriend May 17, 2024
3da0c0b
fine-tune the JSDoc syntaxes and types in config.ts
ElliotFriend May 17, 2024
a19df6e
JSDoc fixes for the Utils class
ElliotFriend May 17, 2024
8253b25
mark the Ok and Err rust type classes as private in JSDoc
ElliotFriend May 17, 2024
db23f84
change StellarToml from a JSDoc namespace to a module
ElliotFriend May 17, 2024
bdf6dbb
change webauth from a JSDoc namespace to a module
ElliotFriend May 17, 2024
8269c16
make SorobanRpc a JSDoc module instead of a namespace
ElliotFriend May 17, 2024
d04527a
mark the AccountResponse class as private in JSDoc
ElliotFriend May 17, 2024
ae18fa4
add soroban tx timeout const to the SorobanRpc.Server module
ElliotFriend May 17, 2024
51f8016
try out a new JSDoc theme
ElliotFriend May 17, 2024
3ae5a6f
Merge branch 'master' into 920-documentation-rendering
ElliotFriend May 17, 2024
334731a
rename SorobanRpc to rpc in JSDoc comments
ElliotFriend May 17, 2024
d95209f
make contract a JSDoc module
ElliotFriend May 17, 2024
937b7b1
mark contract export as private in JSDoc
ElliotFriend May 17, 2024
a0e21ff
mark postObject as private in JSDoc
ElliotFriend May 17, 2024
b684b80
mark contract/utils functions as private in JSDoc
ElliotFriend May 17, 2024
0195708
remove unused import to fix tests (i think?)
ElliotFriend May 17, 2024
422c3a2
add some default values to JSDoc constants
ElliotFriend May 17, 2024
b0b93bb
fix error message type
ElliotFriend May 17, 2024
403d165
break the errors classes into multiple files for JSDoc rendering
ElliotFriend May 17, 2024
4efede5
add JSDoc type definition to friendbot api
ElliotFriend May 17, 2024
afd392b
add default value to max toml file size in JSDoc
ElliotFriend May 17, 2024
462e5f6
try to clarify when timebounds are attached to tx in JSDoc
ElliotFriend May 17, 2024
5b12f6b
clarify note about when the timebounds are added to client txs
ElliotFriend May 21, 2024
6f74f95
Merge remote-tracking branch 'origin/master' into 920-documentation-r…
ElliotFriend Jun 4, 2024
a42c08e
update some federation links
ElliotFriend Jun 4, 2024
e2707c4
fixes to rpc server links, types, etc.
ElliotFriend Jun 4, 2024
0ac4f7d
some fixes to links, params, etc. in WebAuth module
ElliotFriend Jun 5, 2024
afaf06e
improving docs rendering for errors
ElliotFriend Jun 18, 2024
643a330
Merge remote-tracking branch 'origin/master' into 920-documentation-r…
ElliotFriend Jun 18, 2024
4c164c4
remove unused jsdoc theme package
ElliotFriend Jun 18, 2024
ceaf127
move better-docs to dev deps, remove old jsdoc theme minami
ElliotFriend Sep 17, 2024
59ba38e
Merge branch 'master' of github.com:stellar/js-stellar-sdk into 920-d…
ElliotFriend Sep 17, 2024
38ef48a
formatting and linting
ElliotFriend Sep 18, 2024
f5665b0
ignore test output file from prettier
ElliotFriend Sep 18, 2024
dd3cee8
use correct github link in docs site header
ElliotFriend Sep 18, 2024
c5a125c
correct old rpc and horizon docs urls
ElliotFriend Sep 18, 2024
d4db2c5
tweak docs for config class and interface
ElliotFriend Sep 19, 2024
fa9f6c8
fix all Server.* modules being lumped together
ElliotFriend Sep 19, 2024
a18da01
add exceptions for unknown jsdoc tags from base repo
ElliotFriend Sep 19, 2024
f5652ed
some fine-tuning and tweaks
ElliotFriend Sep 20, 2024
0980205
fold rust result interfaces into the contract module
ElliotFriend Sep 20, 2024
139a1da
Merge branch 'master' of github.com:stellar/js-stellar-sdk into 920-d…
ElliotFriend Sep 20, 2024
841f7c9
use prettier in src directory
ElliotFriend Sep 20, 2024
972f3bd
Revert "use prettier in src directory"
ElliotFriend Sep 24, 2024
719c90f
Merge branch 'master' of github.com:stellar/js-stellar-sdk into 920-d…
ElliotFriend Sep 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
</div>

<p align="center">
<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>
<a href="https://badge.fury.io/js/@stellar%2Fstellar-sdk"><img src="https://badge.fury.io/js/@stellar%2Fstellar-sdk.svg" alt="npm version" height="18"></a>
<a href="https://www.npmjs.com/package/@stellar/stellar-sdk">
<img alt="Weekly Downloads" src="https://img.shields.io/npm/dw/stellar-sdk" />
<img alt="Weekly Downloads" src="https://img.shields.io/npm/dw/@stellar/stellar-sdk" />
</a>
<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>
</p>

js-stellar-sdk is a JavaScript library for communicating with a
[Stellar Horizon server](https://github.com/stellar/go/tree/master/services/horizon) and [Soroban RPC](https://soroban.stellar.org/docs/reference/rpc).
[Stellar Horizon server](https://github.com/stellar/go/tree/master/services/horizon) and [Soroban RPC](https://developers.stellar.org/docs/data/rpc).
It is used for building Stellar apps either on Node.js or in the browser, though it can be used in other environments with some tinkering.

It provides:
Expand Down Expand Up @@ -89,14 +89,14 @@ If you don't want to use or install Bower, you can copy the packaged JS files fr

The usage documentation for this library lives in a handful of places:

* across the [Stellar Developer Docs](), which includes tutorials and examples,
* across the [Stellar Developer Docs](https://developers.stellar.org), which includes tutorials and examples,
* within [this repository itself](https://github.com/stellar/js-stellar-sdk/blob/master/docs/reference/readme.md), and
* on the generated [API doc site](https://stellar.github.io/js-stellar-sdk/).

You can also refer to:

* the [documentation](https://developers.stellar.org/network/horizon) for the Horizon REST API (if using the `Horizon` module) and
* the [documentation](https://soroban.stellar.org/docs/reference/rpc) for Soroban RPC's API (if using the `rpc` module)
* the [documentation](https://developers.stellar.org/docs/data/horizon) for the Horizon REST API (if using the `Horizon` module) and
* the [documentation](https://developers.stellar.org/docs/data/rpc) for Soroban RPC's API (if using the `rpc` module)

### Usage with React-Native

Expand Down
44 changes: 41 additions & 3 deletions config/.jsdoc.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,51 @@
{
"tags": {
"allowUnknownTags": ["optional", "category", "warning", "note", "link"]
},
"plugins": [
"plugins/markdown",
"node_modules/better-docs/typescript",
"node_modules/better-docs/category"
],
"source": {
"include": ["lib/", "js-stellar-base/src"],
"includePattern": "\\.(js|ts)$",
"exclude": "js-stellar-base/src/generated"
},
"opts": {
"encoding": "utf8",
"readme": "README.md",
"destination": "jsdoc/",
"recurse": true,
"template": "node_modules/minami",
"readme": "README.md"
"verbose": true,
"template": "node_modules/better-docs",
"private": true
},
"templates": {
"cleverLinks": false,
"monospaceLinks": false,
"search": true,
"default": {
"useLongnameInNav": true
},
"better-docs": {
"name": "@stellar/stellar-sdk",
"title": "@stellar/stellar-sdk Documentation",
"hideGenerator": false,
"navLinks": [
{
"label": "GitHub",
"href": "https://github.com/stellar/js-stellar-sdk"
},
{
"label": "npm",
"href": "https://www.npmjs.com/package/@stellar/stellar-sdk"
}
]
}
},
"plugins": ["plugins/markdown"]
"markdown": {
"hardwrap": false,
"idInHeadings": true
}
}
3 changes: 2 additions & 1 deletion config/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
../node_modules
../lib
../dist
../docs
../docs
../test/unit/out/contract_spec.js
2 changes: 1 addition & 1 deletion docs/reference/readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Overview
---
The JavaScript Stellar SDK facilitates integration with the Stellar [Horizon API server](https://developers.stellar.org/api/), the Stellar [Soroban RPC server](https://soroban.stellar.org/docs/reference/rpc) and submission of Stellar transactions, either on Node.js or in the browser. It has three main uses: [querying Horizon](#querying-horizon), [interacting with Soroban RPC](), and [building, signing, and submitting transactions to the Stellar network](#building-transactions).
The JavaScript Stellar SDK facilitates integration with the Stellar [Horizon API server](https://developers.stellar.org/api/), the Stellar [Soroban RPC server](https://developers.stellar.org/network/soroban-rpc) and submission of Stellar transactions, either on Node.js or in the browser. It has three main uses: [querying Horizon](#querying-horizon), [interacting with Soroban RPC](), and [building, signing, and submitting transactions to the Stellar network](#building-transactions).

* [Building and installing the SDK](https://github.com/stellar/js-stellar-sdk)
* [Examples of using the SDK](./examples.md)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"build:browser": "webpack -c config/webpack.config.browser.js",
"build:docs": "cross-env NODE_ENV=docs yarn _babel",
"clean": "rm -rf lib/ dist/ coverage/ .nyc_output/ jsdoc/ test/e2e/.soroban",
"docs": "yarn build:docs && jsdoc -c ./config/.jsdoc.json --verbose",
"docs": "yarn build:docs && jsdoc -c ./config/.jsdoc.json",
"test": "yarn build:test && yarn test:node && yarn test:integration && yarn test:browser",
"test:e2e": "./test/e2e/initialize.sh && yarn _nyc mocha --recursive 'test/e2e/src/test-*.js'",
"test:node": "yarn _nyc mocha --recursive 'test/unit/**/*.js'",
Expand Down Expand Up @@ -116,6 +116,7 @@
"axios-mock-adapter": "^1.22.0",
"babel-loader": "^9.1.3",
"babel-plugin-istanbul": "^7.0.0",
"better-docs": "^2.7.3",
"buffer": "^6.0.3",
"chai": "^4.3.10",
"chai-as-promised": "^7.1.1",
Expand Down Expand Up @@ -146,7 +147,6 @@
"karma-webpack": "^5.0.1",
"lint-staged": "^15.2.10",
"lodash": "^4.17.21",
"minami": "^1.1.1",
"mocha": "^10.6.0",
"node-polyfill-webpack-plugin": "^3.0.0",
"nyc": "^17.0.0",
Expand Down
50 changes: 24 additions & 26 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
interface Configuration {
/**
* Global config parameters.
*/
export interface Configuration {
/**
* Allow connecting to http servers, default: `false`. This must be set to false in production deployments!
*
* @type {boolean}
* Allow connecting to http servers. This must be set to false in production deployments!
* @default false
*/
allowHttp: boolean;
/**
* Allow a timeout, default: 0. Allows user to avoid nasty lag due to TOML resolve issue. You can also use {@link Config} class to set this globally.
*
* @type {number}
* Allow a timeout. Allows user to avoid nasty lag due network issues.
* @default 0
*/
timeout: number;
}
Expand All @@ -23,54 +24,52 @@ let config = { ...defaultConfig};
/**
* Global config class.
*
* Usage node:
* ```
* import {Config} from 'stellar-sdk';
* @hideconstructor
*
* @example <caption>Usage in node</caption>
* import { Config } from '@stellar/stellar-sdk';
* Config.setAllowHttp(true);
* Config.setTimeout(5000);
* ```
*
* Usage browser:
* ```
* @example <caption>Usage in the browser</caption>
* StellarSdk.Config.setAllowHttp(true);
* StellarSdk.Config.setTimeout(5000);
* ```
* @static
*/
class Config {
/**
* Sets `allowHttp` flag globally. When set to `true`, connections to insecure http protocol servers will be allowed.
* Must be set to `false` in production. Default: `false`.
* @param {boolean} value new allowHttp value
* @returns {void}
* Sets `allowHttp` flag globally. When set to `true`, connections to insecure
* http protocol servers will be allowed. Must be set to `false` in
* production.
* @default false
* @static
*/
public static setAllowHttp(value: boolean): void {
config.allowHttp = value;
}

/**
* Sets `timeout` flag globally. When set to anything besides 0, the request will timeout after specified time (ms).
* Default: 0.
* @param {number} value new timeout value
* @returns {void}
* Sets `timeout` flag globally. When set to anything besides 0, the request
* will timeout after specified time (ms).
* @default 0
* @static
*/
public static setTimeout(value: number): void {
config.timeout = value;
}

/**
* Returns the configured `allowHttp` flag.
* @static
* @returns {boolean} allowHttp flag
* @returns {boolean}
*/
public static isAllowHttp(): boolean {
return config.allowHttp;
}

/**
* Returns the configured `timeout` flag.
* @static
* @returns {number} timeout flag
* @returns {number}
*/
public static getTimeout(): number {
return config.timeout;
Expand All @@ -79,7 +78,6 @@ class Config {
/**
* Sets all global config flags to default values.
* @static
* @returns {void}
*/
public static setDefault(): void {
config = { ...defaultConfig};
Expand Down
51 changes: 28 additions & 23 deletions src/contract/assembled_transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type {
Tx,
XDR_BASE64,
} from "./types";
import { Server } from "../rpc/server";
import { Server } from "../rpc";
import { Api } from "../rpc/api";
import { assembleTransaction } from "../rpc/transaction";
import type { Client } from "./client";
Expand All @@ -32,6 +32,8 @@ import { DEFAULT_TIMEOUT } from "./types";
import { SentTransaction } from "./sent_transaction";
import { Spec } from "./spec";

/** @module contract */

/**
* The main workhorse of {@link Client}. This class is used to wrap a
* transaction-under-construction and provide high-level interfaces to the most
Expand All @@ -47,7 +49,7 @@ import { Spec } from "./spec";
* Let's look at examples of how to use `AssembledTransaction` for a variety of
* use-cases:
*
* # 1. Simple read call
* #### 1. Simple read call
*
* Since these only require simulation, you can get the `result` of the call
* right after constructing your `AssembledTransaction`:
Expand Down Expand Up @@ -80,7 +82,7 @@ import { Spec } from "./spec";
* })
* ```
*
* # 2. Simple write call
* #### 2. Simple write call
*
* For write calls that will be simulated and then sent to the network without
* further manipulation, only one more step is needed:
Expand Down Expand Up @@ -114,7 +116,7 @@ import { Spec } from "./spec";
* const { result } = await tx.signAndSend()
* ```
*
* # 3. More fine-grained control over transaction construction
* #### 3. More fine-grained control over transaction construction
*
* If you need more control over the transaction before simulating it, you can
* set various {@link MethodOptions} when constructing your
Expand Down Expand Up @@ -147,7 +149,7 @@ import { Spec } from "./spec";
* If you need to inspect the simulation later, you can access it with
* `tx.simulation`.
*
* # 4. Multi-auth workflows
* #### 4. Multi-auth workflows
*
* Soroban, and Stellar in general, allows multiple parties to sign a
* transaction.
Expand Down Expand Up @@ -234,6 +236,8 @@ import { Spec } from "./spec";
* To see an even more complicated example, where Alice swaps with Bob but the
* transaction is invoked by yet another party, check out
* [test-swap.js](../../test/e2e/src/test-swap.js).
*
* @memberof module:contract
*/
export class AssembledTransaction<T> {
/**
Expand Down Expand Up @@ -401,7 +405,7 @@ export class AssembledTransaction<T> {
}
const method = invokeContractArgs.functionName().toString('utf-8');
const txn = new AssembledTransaction(
{ ...options,
{ ...options,
method,
parseResultXdr: (result: xdr.ScVal) =>
spec.funcResToNative(method, result),
Expand Down Expand Up @@ -431,10 +435,11 @@ export class AssembledTransaction<T> {
* If you don't want to simulate the transaction, you can set `simulate` to
* `false` in the options.
*
* const tx = await AssembledTransaction.build({
* ...,
* simulate: false,
* })
* @example
* const tx = await AssembledTransaction.build({
* ...,
* simulate: false,
* })
*/
static async build<T>(
options: AssembledTransactionOptions<T>,
Expand Down Expand Up @@ -557,7 +562,7 @@ export class AssembledTransaction<T> {
if (Api.isSimulationRestore(simulation)) {
throw new AssembledTransaction.Errors.ExpiredState(
`You need to restore some contract state before you can invoke this method.\n` +
'You can set `restore` to true in the method options in order to ' +
'You can set `restore` to true in the method options in order to ' +
'automatically restore the contract state when needed.'
);
}
Expand Down Expand Up @@ -597,7 +602,7 @@ export class AssembledTransaction<T> {
}

/**
* Sign the transaction with the signTransaction function included previously.
* Sign the transaction with the signTransaction function included previously.
* If you did not previously include one, you need to include one now.
*/
sign = async ({
Expand Down Expand Up @@ -674,9 +679,9 @@ export class AssembledTransaction<T> {
}

/**
* Sign the transaction with the `signTransaction` function included previously.
* If you did not previously include one, you need to include one now.
* After signing, this method will send the transaction to the network and
* Sign the transaction with the `signTransaction` function included previously.
* If you did not previously include one, you need to include one now.
* After signing, this method will send the transaction to the network and
* return a `SentTransaction` that keeps track * of all the attempts to fetch the transaction.
*/
signAndSend = async ({
Expand Down Expand Up @@ -875,28 +880,28 @@ export class AssembledTransaction<T> {
}

/**
* Restores the footprint (resource ledger entries that can be read or written)
* of an expired transaction.
*
* Restores the footprint (resource ledger entries that can be read or written)
* of an expired transaction.
*
* The method will:
* 1. Build a new transaction aimed at restoring the necessary resources.
* 2. Sign this new transaction if a `signTransaction` handler is provided.
* 3. Send the signed transaction to the network.
* 4. Await and return the response from the network.
*
*
* Preconditions:
* - A `signTransaction` function must be provided during the Client initialization.
* - The provided `restorePreamble` should include a minimum resource fee and valid
* transaction data.
*
* @throws {Error} - Throws an error if no `signTransaction` function is provided during
*
* @throws {Error} - Throws an error if no `signTransaction` function is provided during
* Client initialization.
* @throws {AssembledTransaction.Errors.RestoreFailure} - Throws a custom error if the
* @throws {AssembledTransaction.Errors.RestoreFailure} - Throws a custom error if the
* restore transaction fails, providing the details of the failure.
*/
async restoreFootprint(
/**
* The preamble object containing data required to
* The preamble object containing data required to
* build the restore transaction.
*/
restorePreamble: {
Expand Down
Loading
Loading