From 856dbfeb65b6780aacc532a504aa1a9278e43951 Mon Sep 17 00:00:00 2001 From: Thoralf-M <46689931+Thoralf-M@users.noreply.github.com> Date: Mon, 11 Dec 2023 14:59:24 +0100 Subject: [PATCH 1/4] Update wasm.mdx --- .../1.0/docs/getting-started/wasm.mdx | 40 +------------------ 1 file changed, 2 insertions(+), 38 deletions(-) diff --git a/docs/build/iota-sdk/1.0/docs/getting-started/wasm.mdx b/docs/build/iota-sdk/1.0/docs/getting-started/wasm.mdx index f76c4ee356e..e964c69acf0 100644 --- a/docs/build/iota-sdk/1.0/docs/getting-started/wasm.mdx +++ b/docs/build/iota-sdk/1.0/docs/getting-started/wasm.mdx @@ -147,49 +147,13 @@ A bundler such as [webpack](https://webpack.js.org/) or [rollup](https://rollupj After you [installed the library](#install-the-iota-sdk), you can create a `Client` instance and interface with it. -```typescript reference -https://github.com/iotaledger/iota-sdk/blob/develop/bindings/nodejs/examples/client/getting-started.ts#L4-L23 -``` +https://github.com/iotaledger/iota-sdk/tree/develop/bindings/wasm#client-usage ### Wallet After you [installed the library](#installing-the-iota-sdk), you can create a `Wallet` instance and interact with it. -```typescript reference -https://github.com/iotaledger/iota-sdk/blob/develop/bindings/nodejs/examples/wallet/getting-started.ts#L4-L60 -``` - -### Web Usage - -```javascript -import init, {Wallet, CoinType} from "@iota/sdk-wasm/web"; - -init().then(() => { - const wallet = new Wallet({ - storagePath: './my-database', - coinType: CoinType.Shimmer, - clientOptions: { - nodes: ['https://api.testnet.shimmer.network'], - }, - secretManager: { - mnemonic: "my development mnemonic", - }, - }); - - const account = await wallet.createAccount({ - alias: 'Alice', - }); - - account.addresses().then((addresses) => { - console.log(addresses); - }); -}).catch(console.error); - -// Default path to load is "iota_sdk_wasm_bg.wasm", -// but you can override it by passing a path explicitly. -// -// init("./static/iota_sdk_wasm_bg.wasm").then(...) -``` +https://github.com/iotaledger/iota-sdk/tree/develop/bindings/wasm#wallet-usage ## What's next? From 6265826987947de653369fa22b7c6f3769cbea2f Mon Sep 17 00:00:00 2001 From: Lucas Tortora Date: Tue, 12 Dec 2023 13:10:22 -0300 Subject: [PATCH 2/4] * added requirements * added example explanations * import examples from https://github.com/iotaledger/iota-sdk/blob/develop/bindings/wasm/README.md * updated API Ref link --- .../1.0/docs/getting-started/wasm.mdx | 69 +++++++++++++++++-- 1 file changed, 65 insertions(+), 4 deletions(-) diff --git a/docs/build/iota-sdk/1.0/docs/getting-started/wasm.mdx b/docs/build/iota-sdk/1.0/docs/getting-started/wasm.mdx index e964c69acf0..ccd585baef5 100644 --- a/docs/build/iota-sdk/1.0/docs/getting-started/wasm.mdx +++ b/docs/build/iota-sdk/1.0/docs/getting-started/wasm.mdx @@ -43,6 +43,15 @@ Use the Node.js bindings if you can. The Wasm bindings are just more portable an ::: +### Requirements + +- One of the following [Node.js](https://nodejs.org/) versions: '16.x', '18.x'; +- [`wasm-bindgen`](https://github.com/rustwasm/wasm-bindgen). You can install it by running: + +```bash +cargo install wasm-bindgen-cli +``` + ### Install Using a Package Manager To start using the IOTA SDK in your Wasm project, you can install the IOTA SDK from your package manager of choice: @@ -145,17 +154,68 @@ A bundler such as [webpack](https://webpack.js.org/) or [rollup](https://rollupj ### Client +#### Node.js + After you [installed the library](#install-the-iota-sdk), you can create a `Client` instance and interface with it. -https://github.com/iotaledger/iota-sdk/tree/develop/bindings/wasm#client-usage +The following example creates a [`Client`](https://wiki.iota.org/shimmer/iota-sdk/references/nodejs/classes/Client/) +instance connected to +the [Shimmer Testnet](https://api.testnet.shimmer.network), and retrieves the node's information by +calling [`Client.getInfo()`](https://wiki.iota.org/shimmer/iota-sdk/references/nodejs/classes/Client/#getinfo), +and then print the node's information. + +
+ +```typescript reference +https://github.com/iotaledger/iota-sdk/blob/develop/bindings/wasm/README.md#L127-L145 +``` + +
+ +#### Web + +
+ +```typescript reference +https://github.com/iotaledger/iota-sdk/blob/develop/bindings/wasm/README.md#L151-L168 +``` + +
### Wallet After you [installed the library](#installing-the-iota-sdk), you can create a `Wallet` instance and interact with it. -https://github.com/iotaledger/iota-sdk/tree/develop/bindings/wasm#wallet-usage +The following example will create a +new [`Wallet`](https://wiki.iota.org/iota-sdk/references/nodejs/classes/Wallet/) [`Account`](https://wiki.iota.org/iota-sdk/references/nodejs/classes/Account/) +that connects to the [Shimmer Testnet](https://api.testnet.shimmer.network) using the +[`MnemonicSecretManager`](https://wiki.iota.org/iota-sdk/references/nodejs/interfaces/MnemonicSecretManager/) +by calling +the [`Wallet.createAccount(data)`](https://wiki.iota.org/iota-sdk/references/nodejs/classes/Wallet/#createaccount) +function. + +#### Node.js + + +
+ +```typescript reference +https://github.com/iotaledger/iota-sdk/blob/develop/bindings/wasm/README.md#L184-L208 +``` + +
+ +#### Web + +
+ +```typescript reference +https://github.com/iotaledger/iota-sdk/blob/develop/bindings/wasm/README.md#L214-L239 +``` + +
-## What's next? +## What's Next? ### How-To Guides @@ -182,4 +242,5 @@ yarn run-example examples/client/00_get_info.ts ## API Reference -The IOTA SDK Rust API Reference is in the [crate documentation](https://docs.rs/iota-sdk/latest/iota_sdk/). +If you are using the Wasm binding, you use the Node.js API reference in the +[IOTA Wiki](https://wiki.iota.org/shimmer/iota-sdk/references/nodejs/api_ref/). \ No newline at end of file From aa2534691afebb1d10c971d4a1ba50ab07296494 Mon Sep 17 00:00:00 2001 From: Lucas Tortora Date: Tue, 12 Dec 2023 14:12:44 -0300 Subject: [PATCH 3/4] use tabs for Node.js and Web --- .../1.0/docs/getting-started/wasm.mdx | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/docs/build/iota-sdk/1.0/docs/getting-started/wasm.mdx b/docs/build/iota-sdk/1.0/docs/getting-started/wasm.mdx index ccd585baef5..4e39819170b 100644 --- a/docs/build/iota-sdk/1.0/docs/getting-started/wasm.mdx +++ b/docs/build/iota-sdk/1.0/docs/getting-started/wasm.mdx @@ -154,8 +154,6 @@ A bundler such as [webpack](https://webpack.js.org/) or [rollup](https://rollupj ### Client -#### Node.js - After you [installed the library](#install-the-iota-sdk), you can create a `Client` instance and interface with it. The following example creates a [`Client`](https://wiki.iota.org/shimmer/iota-sdk/references/nodejs/classes/Client/) @@ -164,6 +162,8 @@ the [Shimmer Testnet](https://api.testnet.shimmer.network), and retrieves the no calling [`Client.getInfo()`](https://wiki.iota.org/shimmer/iota-sdk/references/nodejs/classes/Client/#getinfo), and then print the node's information. + +
```typescript reference @@ -171,9 +171,8 @@ https://github.com/iotaledger/iota-sdk/blob/develop/bindings/wasm/README.md#L127 ```
- -#### Web - +
+
```typescript reference @@ -181,6 +180,8 @@ https://github.com/iotaledger/iota-sdk/blob/develop/bindings/wasm/README.md#L151 ```
+
+
### Wallet @@ -194,19 +195,19 @@ by calling the [`Wallet.createAccount(data)`](https://wiki.iota.org/iota-sdk/references/nodejs/classes/Wallet/#createaccount) function. -#### Node.js - + +
```typescript reference https://github.com/iotaledger/iota-sdk/blob/develop/bindings/wasm/README.md#L184-L208 ``` -
- -#### Web + +
+
```typescript reference @@ -214,6 +215,8 @@ https://github.com/iotaledger/iota-sdk/blob/develop/bindings/wasm/README.md#L214 ```
+
+
## What's Next? From 2c53835a7e84bd1ce18ee086a02031262320c2d2 Mon Sep 17 00:00:00 2001 From: Lucas Tortora Date: Tue, 12 Dec 2023 17:55:09 -0300 Subject: [PATCH 4/4] changed tab order --- .../iota-sdk/1.0/docs/getting-started/wasm.mdx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/build/iota-sdk/1.0/docs/getting-started/wasm.mdx b/docs/build/iota-sdk/1.0/docs/getting-started/wasm.mdx index 4e39819170b..6d65222f30f 100644 --- a/docs/build/iota-sdk/1.0/docs/getting-started/wasm.mdx +++ b/docs/build/iota-sdk/1.0/docs/getting-started/wasm.mdx @@ -163,20 +163,20 @@ calling [`Client.getInfo()`](https://wiki.iota.org/shimmer/iota-sdk/references/n and then print the node's information. - +
```typescript reference -https://github.com/iotaledger/iota-sdk/blob/develop/bindings/wasm/README.md#L127-L145 +https://github.com/iotaledger/iota-sdk/blob/develop/bindings/wasm/README.md#L151-L168 ```
- +
```typescript reference -https://github.com/iotaledger/iota-sdk/blob/develop/bindings/wasm/README.md#L151-L168 +https://github.com/iotaledger/iota-sdk/blob/develop/bindings/wasm/README.md#L127-L145 ```
@@ -197,23 +197,23 @@ function. - +
```typescript reference -https://github.com/iotaledger/iota-sdk/blob/develop/bindings/wasm/README.md#L184-L208 +https://github.com/iotaledger/iota-sdk/blob/develop/bindings/wasm/README.md#L214-L239 ``` -
- +
```typescript reference -https://github.com/iotaledger/iota-sdk/blob/develop/bindings/wasm/README.md#L214-L239 +https://github.com/iotaledger/iota-sdk/blob/develop/bindings/wasm/README.md#L184-L208 ``` +