Skip to content

Commit

Permalink
docs: update demos
Browse files Browse the repository at this point in the history
  • Loading branch information
gin-lsl committed Jul 9, 2024
1 parent e93579a commit 80e9b38
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 23 deletions.
12 changes: 2 additions & 10 deletions packages/web3/src/sui/demos/more-components.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
import React from 'react';
import { NFTCard, NFTImage } from '@ant-design/web3';
import { SuiWeb3ConfigProvider } from '@ant-design/web3-sui';
import { createNetworkConfig } from '@mysten/dapp-kit';
import { getFullnodeUrl } from '@mysten/sui.js/client';
import { QueryClient } from '@tanstack/react-query';
import { Space } from 'antd';

const queryClient = new QueryClient();
const networkConfig = createNetworkConfig({
localnet: { url: getFullnodeUrl('localnet') },
devnet: { url: getFullnodeUrl('devnet') },
// testnet: { url: getFullnodeUrl('testnet') },
testnet: { url: `https://api.zan.top/node/v1/sui/testnet/${YOUR_ZAN_API_KEY}` },
mainnet: { url: getFullnodeUrl('mainnet') },
});

const App: React.FC = () => {
return (
<SuiWeb3ConfigProvider networkConfig={networkConfig} queryClient={queryClient}>
<SuiWeb3ConfigProvider queryClient={queryClient}>
<Space>
<NFTCard address="0x110e5f6b7113ac27cad69b561d0cc595f6b875d07d2d8714e439bb73059aa6f8" />
<NFTImage address="0x110e5f6b7113ac27cad69b561d0cc595f6b875d07d2d8714e439bb73059aa6f8" />
Expand Down
24 changes: 24 additions & 0 deletions packages/web3/src/sui/demos/networks-unofficial.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import { ConnectButton, Connector } from '@ant-design/web3';
import { SuiWeb3ConfigProvider } from '@ant-design/web3-sui';
import { createNetworkConfig } from '@mysten/dapp-kit';
import { QueryClient } from '@tanstack/react-query';

const queryClient = new QueryClient();

const { networkConfig } = createNetworkConfig({
testnet: { url: `https://api.zan.top/node/v1/sui/testnet/${YOUR_ZAN_API_KEY}` },
mainnet: { url: `https://api.zan.top/node/v1/sui/mainnet/${YOUR_ZAN_API_KEY}` },
});

const App: React.FC = () => {
return (
<SuiWeb3ConfigProvider balance networkConfig={networkConfig} queryClient={queryClient}>
<Connector>
<ConnectButton />
</Connector>
</SuiWeb3ConfigProvider>
);
};

export default App;
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,17 @@ import { getFullnodeUrl } from '@mysten/sui.js/client';
import { QueryClient } from '@tanstack/react-query';

const queryClient = new QueryClient();
const networkConfig = createNetworkConfig({

const { networkConfig } = createNetworkConfig({
localnet: { url: getFullnodeUrl('localnet') },
devnet: { url: getFullnodeUrl('devnet') },
// testnet: { url: getFullnodeUrl('testnet') },
testnet: { url: `https://api.zan.top/node/v1/sui/testnet/${YOUR_ZAN_API_KEY}` },
testnet: { url: getFullnodeUrl('testnet') },
mainnet: { url: getFullnodeUrl('mainnet') },
});

const App: React.FC = () => {
return (
<SuiWeb3ConfigProvider
balance
autoConnect
networkConfig={networkConfig}
defaultNetwork="mainnet"
queryClient={queryClient}
>
<SuiWeb3ConfigProvider balance networkConfig={networkConfig} queryClient={queryClient}>
<Connector>
<ConnectButton />
</Connector>
Expand Down
18 changes: 18 additions & 0 deletions packages/web3/src/sui/demos/recommend.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import { ConnectButton, Connector } from '@ant-design/web3';
import { SuiWeb3ConfigProvider } from '@ant-design/web3-sui';
import { QueryClient } from '@tanstack/react-query';

const queryClient = new QueryClient();

const App: React.FC = () => {
return (
<SuiWeb3ConfigProvider balance autoConnect queryClient={queryClient}>
<Connector>
<ConnectButton />
</Connector>
</SuiWeb3ConfigProvider>
);
};

export default App;
14 changes: 11 additions & 3 deletions packages/web3/src/sui/index.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
---
nav: Components
order: 5
order: 6
group:
title: Connect Blockchains
order: 2
---

# Sui

## Basic
## Recommended configuration

<code src="./demos/basic.tsx"></code>
<code src="./demos/recommend.tsx"></code>

## Networks

<code src="./demos/networks.tsx"></code>

## Unoffical networks

<code src="./demos/networks-unofficial.tsx"></code>

## More Components

Expand Down
25 changes: 25 additions & 0 deletions packages/web3/src/sui/index.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
nav: 组件
order: 6
group:
title: 连接链
order: 2
---

# Sui

## 推荐配置

<code src="./demos/recommend.tsx"></code>

## 网络

<code src="./demos/networks.tsx"></code>

## 非官方网络

<code src="./demos/networks-unofficial.tsx"></code>

## 更多组件

<code src="./demos/more-components.tsx"></code>

0 comments on commit 80e9b38

Please sign in to comment.