Skip to content

Commit

Permalink
fix(devx): rebase, fix conflicts, fix tags, fix imports
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-tortora committed Aug 13, 2024
1 parent f963a90 commit 2766885
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 302 deletions.
2 changes: 1 addition & 1 deletion docs/content/developer/getting-started/build-test.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Learn how to build and test Move packages in IOTA with detailed instructions and examples.
tags: [Move, IOTA, Package Building, Package Testing, Unit Testing, Debugging]
tags: [move, testing, how-to, cli]
---

import TestingCheatSheet from "../../_snippets/testing-cheat-sheet.mdx";
Expand Down
143 changes: 76 additions & 67 deletions docs/content/developer/getting-started/client-tssdk.mdx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
description: Learn how to build a client application using the IOTA TypeScript SDK and dApp Kit in a React environment.
tags: [ TypeScript SDK, React, dApp Kit, Wallet Integration ]
tags: [ typescript, sdk, getting-started, install]
---

import InfoPnpmRequired from "../../_snippets/info-pnpm-required.mdx";
import AlphaNet from "../../_snippets/alphanet.mdx";

# Client App with IOTA TypeScript SDK

Expand Down Expand Up @@ -32,7 +33,7 @@ yarn create @iota/dapp --template react-client-dapp

## What is the IOTA TypeScript SDK?

The [IOTA TypeScript SDK](../../references/ts-sdk/typescript/index.mdx) (`@iota/iota.js`) provides the essential
The [IOTA TypeScript SDK](../../references/ts-sdk/typescript/index.mdx) (`@iota/iota-sdk`) provides the essential
functionality needed to interact with the IOTA
ecosystem from TypeScript. It's versatile enough to be used in any TypeScript or JavaScript project, including web apps,
Node.js applications, or mobile apps developed with tools like React Native that support TypeScript.
Expand All @@ -55,12 +56,19 @@ templates:
```bash npm2yarn
npm init vite
```

Now that you have a React app, you can install the necessary dependencies to use dApp Kit:

```bash npm2yarn
npm install @iota/iota.js @iota/dapp-kit @tanstack/react-query
npm install @iota/iota-sdk @iota/dapp-kit @tanstack/react-query
```

:::info Local version of the SDK

If you'd like to use a locally compiled version of the SDK you can follow the instructions in the [Local Development](local-network.mdx#test-with-the-iota-typescript-sdk) section.

:::

## Setting Up Provider Components

To use all the features of dApp Kit, wrap your app with several `Provider` components.
Expand All @@ -87,6 +95,7 @@ ReactDOM.createRoot(document.getElementById('root')!).render(
</React.StrictMode>,
);
```
<AlphaNet />

### `IOTAClientProvider`

Expand All @@ -96,7 +105,7 @@ networks. In this exercise, you'll connect to `devnet`.

```ts
import { IOTAClientProvider } from '@iota/dapp-kit';
import { getFullnodeUrl } from '@iota/iota.js/client';
import { getFullnodeUrl } from '@iota/iota-sdk/client';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';

const queryClient = new QueryClient();
Expand Down Expand Up @@ -125,25 +134,25 @@ Finally, set up the `WalletProvider` from `@iota/dapp-kit`, and import styles fo
import '@iota/dapp-kit/dist/index.css';

import { IOTAClientProvider, WalletProvider } from '@iota/dapp-kit';
import { getFullnodeUrl } from '@iota/iota.js/client';
import { getFullnodeUrl } from '@iota/iota-sdk/client';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';

const queryClient = new QueryClient();
const networks = {
devnet: { url: getFullnodeUrl('devnet') },
mainnet: { url: getFullnodeUrl('mainnet') },
devnet: { url: getFullnodeUrl('devnet') },
mainnet: { url: getFullnodeUrl('mainnet') },
};

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<QueryClientProvider client={queryClient}>
<IOTAClientProvider networks={networks} defaultNetwork="devnet">
<WalletProvider>
<App />
</WalletProvider>
</IOTAClientProvider>
</QueryClientProvider>
</React.StrictMode>,
<React.StrictMode>
<QueryClientProvider client={queryClient}>
<IOTAClientProvider networks={networks} defaultNetwork="devnet">
<WalletProvider>
<App />
</WalletProvider>
</IOTAClientProvider>
</QueryClientProvider>
</React.StrictMode>,
);
```

Expand All @@ -156,13 +165,13 @@ allow users to connect their wallets to your dApp, add a `ConnectButton`.
import { ConnectButton } from '@iota/dapp-kit';

function App() {
return (
<div className="App">
<header className="App-header">
<ConnectButton />
</header>
</div>
);
return (
<div className="App">
<header className="App-header">
<ConnectButton />
</header>
</div>
);
}
```

Expand All @@ -178,25 +187,25 @@ details about the connected wallet account.
import { ConnectButton, useCurrentAccount } from '@iota/dapp-kit';

function App() {
return (
<div className="App">
<header className="App-header">
<ConnectButton />
</header>

<ConnectedAccount />
</div>
);
return (
<div className="App">
<header className="App-header">
<ConnectButton />
</header>

<ConnectedAccount />
</div>
);
}

function ConnectedAccount() {
const account = useCurrentAccount();
const account = useCurrentAccount();

if (!account) {
return null;
}
if (!account) {
return null;
}

return <div>Connected to {account.address}</div>;
return <div>Connected to {account.address}</div>;
}
```

Expand All @@ -208,39 +217,39 @@ Now that you have the account connected, you can query for objects that the conn
import { useCurrentAccount, useIOTAClientQuery } from '@iota/dapp-kit';

function ConnectedAccount() {
const account = useCurrentAccount();

if (!account) {
return null;
}

return (
<div>
<div>Connected to {account.address}</div>;
<OwnedObjects address={account.address} />
</div>
);
const account = useCurrentAccount();

if (!account) {
return null;
}

return (
<div>
<div>Connected to {account.address}</div>;
<OwnedObjects address={account.address} />
</div>
);
}

function OwnedObjects({ address }: { address: string }) {
const { data } = useIOTAClientQuery('getOwnedObjects', {
owner: address,
});
if (!data) {
return null;
}

return (
<ul>
{data.data.map((object) => (
<li key={object.data?.objectId}>
<a href={`https://example-explorer.com/object/${object.data?.objectId}`}>
{object.data?.objectId}
</a>
</li>
))}
</ul>
);
const { data } = useIOTAClientQuery('getOwnedObjects', {
owner: address,
});
if (!data) {
return null;
}

return (
<ul>
{data.data.map((object) => (
<li key={object.data?.objectId}>
<a href={`https://explorer.iota.cafe/object/${object.data?.objectId}`}>
{object.data?.objectId}
</a>
</li>
))}
</ul>
);
}
```

Expand Down
2 changes: 1 addition & 1 deletion docs/content/developer/getting-started/create-a-module.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Guide to creating and understanding a Move module in an IOTA package.
tags: [IOTA, Move, module, smart contract, development]
tags: [move, getting-started]
---

# Create a Move Module
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: How to create a Move package in IOTA
tags: [ Move, Package Creation, .toml, manifest ]
tags: [ move, getting-started ]
---

# Create a Move Package
Expand Down
2 changes: 1 addition & 1 deletion docs/content/developer/getting-started/debug.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description: Learn how to use the std::debug module in Move for debugging and printing values.
tags: [Move, debugging, std::debug, smart contracts]
tags: [move, getting-started, testing]
---
# Debugging

Expand Down
Loading

0 comments on commit 2766885

Please sign in to comment.