@ant-design/web3-sui 0.0.0-alpha-20260209094036

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/CHANGELOG.md ADDED
@@ -0,0 +1,158 @@
1
+ # @ant-design/web3-sui
2
+
3
+ ## 0.0.0-alpha-20260209094036
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [01dc595]
8
+ - @ant-design/web3-common@0.0.0-alpha-20260209094036
9
+ - @ant-design/web3-assets@0.0.0-alpha-20260209094036
10
+
11
+ ## 1.2.0
12
+
13
+ ### Minor Changes
14
+
15
+ - 2ae483c: feat: support ignoreConfig for support multiple chain better
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [dfa67c5]
20
+ - Updated dependencies [2ae483c]
21
+ - @ant-design/web3-common@1.22.0
22
+ - @ant-design/web3-assets@1.14.3
23
+
24
+ ## 1.1.2
25
+
26
+ ### Patch Changes
27
+
28
+ - @ant-design/web3-assets@1.14.2
29
+
30
+ ## 1.1.1
31
+
32
+ ### Patch Changes
33
+
34
+ - @ant-design/web3-assets@1.14.1
35
+
36
+ ## 1.1.0
37
+
38
+ ### Minor Changes
39
+
40
+ - 3d6d7c6: feat(sui):rename SuiWallet to Slush
41
+
42
+ ### Patch Changes
43
+
44
+ - Updated dependencies [640bce9]
45
+ - Updated dependencies [3d6d7c6]
46
+ - @ant-design/web3-assets@1.14.0
47
+ - @ant-design/web3-common@1.21.0
48
+
49
+ ## 1.0.12
50
+
51
+ ### Patch Changes
52
+
53
+ - Updated dependencies [98dc8ef]
54
+ - Updated dependencies [b309635]
55
+ - Updated dependencies [d9629ed]
56
+ - @ant-design/web3-assets@1.13.0
57
+ - @ant-design/web3-common@1.20.0
58
+
59
+ ## 1.0.11
60
+
61
+ ### Patch Changes
62
+
63
+ - Updated dependencies [0f83657]
64
+ - @ant-design/web3-common@1.19.0
65
+ - @ant-design/web3-assets@1.12.1
66
+
67
+ ## 1.0.10
68
+
69
+ ### Patch Changes
70
+
71
+ - Updated dependencies [b6f1f1d]
72
+ - @ant-design/web3-assets@1.12.0
73
+ - @ant-design/web3-common@1.18.0
74
+
75
+ ## 1.0.9
76
+
77
+ ### Patch Changes
78
+
79
+ - Updated dependencies [f896044]
80
+ - @ant-design/web3-common@1.17.0
81
+ - @ant-design/web3-assets@1.11.8
82
+
83
+ ## 1.0.8
84
+
85
+ ### Patch Changes
86
+
87
+ - 8b857d3: chore: update wagmi version
88
+ - Updated dependencies [ad278cd]
89
+ - Updated dependencies [8b857d3]
90
+ - @ant-design/web3-common@1.16.0
91
+ - @ant-design/web3-assets@1.11.7
92
+
93
+ ## 1.0.7
94
+
95
+ ### Patch Changes
96
+
97
+ - @ant-design/web3-assets@1.11.6
98
+
99
+ ## 1.0.6
100
+
101
+ ### Patch Changes
102
+
103
+ - e0db15a: chore: upgrade pnpm version from 8.9.0 to 9.14.4
104
+ - Updated dependencies [14fae53]
105
+ - Updated dependencies [e0db15a]
106
+ - @ant-design/web3-assets@1.11.5
107
+ - @ant-design/web3-common@1.15.1
108
+
109
+ ## 1.0.5
110
+
111
+ ### Patch Changes
112
+
113
+ - 06aae9b: feat(sui): Returns addresses on connected
114
+ - Updated dependencies [0b2a19d]
115
+ - @ant-design/web3-common@1.15.0
116
+ - @ant-design/web3-assets@1.11.4
117
+
118
+ ## 1.0.4
119
+
120
+ ### Patch Changes
121
+
122
+ - @ant-design/web3-assets@1.11.3
123
+
124
+ ## 1.0.3
125
+
126
+ ### Patch Changes
127
+
128
+ - @ant-design/web3-assets@1.11.2
129
+
130
+ ## 1.0.2
131
+
132
+ ### Patch Changes
133
+
134
+ - Updated dependencies [c32f8e2]
135
+ - Updated dependencies [613b265]
136
+ - @ant-design/web3-common@1.14.0
137
+ - @ant-design/web3-assets@1.11.1
138
+
139
+ ## 1.0.1
140
+
141
+ ### Patch Changes
142
+
143
+ - 1091cfd: fix(sui,solana): Should return address after connect
144
+ - 804cf3e: docs: Update Sui doc
145
+ - Updated dependencies [c22eb4d]
146
+ - @ant-design/web3-assets@1.11.0
147
+
148
+ ## 1.0.0
149
+
150
+ ### Major Changes
151
+
152
+ - 9bb1ea1: feat: Add Sui adapter
153
+
154
+ ### Patch Changes
155
+
156
+ - Updated dependencies [9bb1ea1]
157
+ - @ant-design/web3-common@1.13.0
158
+ - @ant-design/web3-assets@1.10.2
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Ant Design Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # @ant-design/web3-sui
2
+
3
+ This package provides a [Sui](https://sui.io) adapter for [@ant-design/web3](https://www.npmjs.com/package/@ant-design/web3).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @ant-design/web3 @ant-design/web3-sui --save
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```tsx
14
+ import { ConnectButton, Connector } from '@ant-design/web3';
15
+ import { Slush, SuiWeb3ConfigProvider } from '@ant-design/web3-sui';
16
+
17
+ const App: React.FC = () => {
18
+ return (
19
+ <SuiWeb3ConfigProvider>
20
+ <Connector>
21
+ <ConnectButton />
22
+ </Connector>
23
+ </SuiWeb3ConfigProvider>
24
+ );
25
+ };
26
+
27
+ export default App;
28
+ ```
29
+
30
+ For more examples, refer to [Sui - Ant Design Web3](https://web3.ant.design/components/sui).
31
+
32
+ ## Documentation
33
+
34
+ - For more information, visit [Ant Design Web3](https://web3.ant.design).
35
+ - For an introduction to Sui, visit [Sui](https://sui.io).
@@ -0,0 +1,10 @@
1
+ import type { Chain } from '@ant-design/web3-common';
2
+ import { SuiChainIds } from '@ant-design/web3-common';
3
+ export interface SuiChain extends Chain {
4
+ id: SuiChainIds;
5
+ network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';
6
+ }
7
+ export declare const suiMainnet: SuiChain;
8
+ export declare const suiTestnet: SuiChain;
9
+ export declare const suiDevnet: SuiChain;
10
+ export declare const suiLocalnet: SuiChain;
@@ -0,0 +1,64 @@
1
+ import React from 'react';
2
+ import { createGetBrowserLink, SuiChainIds } from '@ant-design/web3-common';
3
+ import { SuiColorful } from '@ant-design/web3-icons';
4
+ import { SUI_DECIMALS } from '@mysten/sui/utils';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ export const suiMainnet = {
7
+ id: SuiChainIds.Mainnet,
8
+ name: 'Sui',
9
+ network: 'mainnet',
10
+ icon: /*#__PURE__*/_jsx(SuiColorful, {}),
11
+ browser: {
12
+ icon: /*#__PURE__*/_jsx(SuiColorful, {}),
13
+ getBrowserLink: createGetBrowserLink('https://suiscan.xyz/mainnet')
14
+ },
15
+ nativeCurrency: {
16
+ name: 'Sui',
17
+ symbol: 'SUI',
18
+ decimals: SUI_DECIMALS
19
+ }
20
+ };
21
+ export const suiTestnet = {
22
+ id: SuiChainIds.Testnet,
23
+ name: 'Sui Testnet',
24
+ network: 'testnet',
25
+ icon: /*#__PURE__*/_jsx(SuiColorful, {}),
26
+ browser: {
27
+ icon: /*#__PURE__*/_jsx(SuiColorful, {}),
28
+ getBrowserLink: createGetBrowserLink('https://suiscan.xyz/testnet')
29
+ },
30
+ nativeCurrency: {
31
+ name: 'Sui',
32
+ symbol: 'SUI',
33
+ decimals: SUI_DECIMALS
34
+ }
35
+ };
36
+ export const suiDevnet = {
37
+ id: SuiChainIds.Devnet,
38
+ name: 'Sui Devnet',
39
+ network: 'devnet',
40
+ icon: /*#__PURE__*/_jsx(SuiColorful, {}),
41
+ browser: {
42
+ icon: /*#__PURE__*/_jsx(SuiColorful, {}),
43
+ getBrowserLink: createGetBrowserLink('https://suiscan.xyz/devnet')
44
+ },
45
+ nativeCurrency: {
46
+ name: 'Sui',
47
+ symbol: 'SUI',
48
+ decimals: SUI_DECIMALS
49
+ }
50
+ };
51
+ export const suiLocalnet = {
52
+ id: SuiChainIds.Localnet,
53
+ name: 'Sui Localnet',
54
+ network: 'localnet',
55
+ icon: /*#__PURE__*/_jsx(SuiColorful, {}),
56
+ browser: {
57
+ icon: /*#__PURE__*/_jsx(SuiColorful, {})
58
+ },
59
+ nativeCurrency: {
60
+ name: 'Sui',
61
+ symbol: 'SUI',
62
+ decimals: SUI_DECIMALS
63
+ }
64
+ };
@@ -0,0 +1,4 @@
1
+ export * from './chain';
2
+ export * from './sui-provider';
3
+ export * from './wallets/built-in';
4
+ export * from './wallets/factory';
@@ -0,0 +1,4 @@
1
+ export * from "./chain";
2
+ export * from "./sui-provider";
3
+ export * from "./wallets/built-in";
4
+ export * from "./wallets/factory";
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import type { Locale } from '@ant-design/web3-common';
3
+ import type { SuiChain } from '../chain';
4
+ import type { WalletFactory } from '../wallets/types';
5
+ export interface AntDesignWeb3ConfigProviderProps {
6
+ balance?: boolean;
7
+ locale?: Locale;
8
+ availableChains?: SuiChain[];
9
+ availableWallets?: WalletFactory[];
10
+ currentChain?: SuiChain;
11
+ sns?: boolean;
12
+ onCurrentChainChange: (network: string) => void;
13
+ /**
14
+ * If true, this provider's configuration will be ignored when merging with parent context.
15
+ * This is useful when you have multiple chain providers and want to switch between them
16
+ * without causing page flickering. Only the active provider should not have this flag set.
17
+ */
18
+ ignoreConfig?: boolean;
19
+ }
20
+ export declare const AntDesignWeb3ConfigProvider: React.FC<React.PropsWithChildren<AntDesignWeb3ConfigProviderProps>>;
@@ -0,0 +1,126 @@
1
+ import React, { useCallback, useMemo } from 'react';
2
+ import { SUI } from '@ant-design/web3-assets/tokens';
3
+ import { Web3ConfigProvider } from '@ant-design/web3-common';
4
+ import { SuiColorful } from '@ant-design/web3-icons';
5
+ import { useConnectWallet, useCurrentAccount, useDisconnectWallet, useResolveSuiNSName, useSuiClient, useSuiClientQuery, useWallets } from '@mysten/dapp-kit';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ export const AntDesignWeb3ConfigProvider = ({
8
+ balance: showBalance,
9
+ locale,
10
+ availableChains,
11
+ availableWallets,
12
+ currentChain,
13
+ sns,
14
+ onCurrentChainChange,
15
+ ignoreConfig,
16
+ children
17
+ }) => {
18
+ const account = useCurrentAccount();
19
+ const standardWallets = useWallets();
20
+ const {
21
+ mutateAsync: connectAsync
22
+ } = useConnectWallet();
23
+ const {
24
+ mutateAsync: disconnectAsync
25
+ } = useDisconnectWallet();
26
+ const {
27
+ data: snsData
28
+ } = useResolveSuiNSName(sns ? account?.address : undefined);
29
+ const client = useSuiClient();
30
+ const {
31
+ data: balanceData
32
+ } = useSuiClientQuery('getBalance', {
33
+ owner: account?.address ?? ''
34
+ }, {
35
+ select(data) {
36
+ return BigInt(data.totalBalance);
37
+ }
38
+ });
39
+ const accountData = account ? {
40
+ address: account.address,
41
+ name: sns && snsData ? snsData : undefined
42
+ } : undefined;
43
+ const allWallets = useMemo(() => {
44
+ const standardWalletNames = standardWallets.map(w => w.name);
45
+ const fixedWallets = availableWallets?.map(factory => factory.create())?.filter(w => !standardWalletNames.includes(w.name));
46
+ const injectedWalletAssets = standardWallets.map(w => {
47
+ return {
48
+ name: w.name,
49
+ icon: w.icon,
50
+ remark: w.name,
51
+ _standardWallet: w,
52
+ async hasExtensionInstalled() {
53
+ return true;
54
+ },
55
+ async hasWalletReady() {
56
+ return true;
57
+ }
58
+ };
59
+ });
60
+ return fixedWallets ? fixedWallets.concat(injectedWalletAssets) : injectedWalletAssets;
61
+ }, [availableWallets, standardWallets]);
62
+ const getNFTMetadataFunc = useCallback(async ({
63
+ address
64
+ }) => {
65
+ const {
66
+ data: nftData
67
+ } = await client.getObject({
68
+ id: address,
69
+ options: {
70
+ showContent: true,
71
+ showDisplay: true
72
+ }
73
+ });
74
+ const displayData = nftData?.display?.data;
75
+ const objectFields = nftData?.content?.dataType === 'moveObject' ? nftData.content.fields : undefined;
76
+ return {
77
+ image: displayData?.image_url,
78
+ date: objectFields?.birthdate,
79
+ attributes: objectFields?.attributes,
80
+ description: displayData?.description,
81
+ edition: nftData?.version
82
+ };
83
+ }, [client]);
84
+ return /*#__PURE__*/_jsx(Web3ConfigProvider, {
85
+ availableChains: availableChains,
86
+ availableWallets: allWallets,
87
+ locale: locale,
88
+ account: accountData,
89
+ chain: currentChain,
90
+ balance: showBalance ? {
91
+ symbol: SUI.symbol,
92
+ decimals: SUI.decimal,
93
+ value: balanceData,
94
+ icon: /*#__PURE__*/_jsx(SuiColorful, {})
95
+ } : undefined,
96
+ connect: async wallet => {
97
+ const foundWallet = wallet?._standardWallet;
98
+ if (!foundWallet) {
99
+ throw new Error(`Can not find wallet ${wallet?.name}`);
100
+ }
101
+ const {
102
+ accounts
103
+ } = await connectAsync({
104
+ wallet: foundWallet
105
+ });
106
+ const defaultAccount = accounts[0];
107
+ const addresses = accounts.map(item => item.address);
108
+ return {
109
+ address: defaultAccount.address,
110
+ addresses: addresses
111
+ };
112
+ },
113
+ disconnect: async () => {
114
+ await disconnectAsync();
115
+ },
116
+ switchChain: async chain => {
117
+ const network = availableChains?.find(item => item.id === chain.id)?.network;
118
+ if (network) {
119
+ onCurrentChainChange(network);
120
+ }
121
+ },
122
+ getNFTMetadata: getNFTMetadataFunc,
123
+ ignoreConfig: ignoreConfig,
124
+ children: children
125
+ });
126
+ };
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import type { Locale } from '@ant-design/web3-common';
3
+ import { createNetworkConfig } from '@mysten/dapp-kit';
4
+ import { QueryClient } from '@tanstack/react-query';
5
+ import type { WalletFactory } from '../wallets/types';
6
+ export interface SuiWeb3ConfigProviderProps {
7
+ balance?: boolean;
8
+ locale?: Locale;
9
+ autoConnect?: boolean;
10
+ networkConfig?: ReturnType<typeof createNetworkConfig>['networkConfig'];
11
+ sns?: boolean;
12
+ defaultNetwork?: string;
13
+ wallets?: WalletFactory[];
14
+ queryClient?: QueryClient;
15
+ /**
16
+ * If true, this provider's configuration will be ignored when merging with parent context.
17
+ * This is useful when you have multiple chain providers and want to switch between them
18
+ * without causing page flickering. Only the active provider should not have this flag set.
19
+ */
20
+ ignoreConfig?: boolean;
21
+ }
22
+ export declare const SuiWeb3ConfigProvider: React.FC<React.PropsWithChildren<SuiWeb3ConfigProviderProps>>;
@@ -0,0 +1,61 @@
1
+ import React, { useContext } from 'react';
2
+ import { createNetworkConfig, SuiClientProvider, WalletProvider } from '@mysten/dapp-kit';
3
+ import { getFullnodeUrl } from '@mysten/sui/client';
4
+ import { QueryClient, QueryClientContext, QueryClientProvider } from '@tanstack/react-query';
5
+ import { suiDevnet, suiLocalnet, suiMainnet, suiTestnet } from "../chain";
6
+ import { AntDesignWeb3ConfigProvider } from "./config-provider";
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ export const SuiWeb3ConfigProvider = ({
9
+ autoConnect,
10
+ balance,
11
+ locale,
12
+ networkConfig,
13
+ defaultNetwork = 'mainnet',
14
+ queryClient,
15
+ sns,
16
+ wallets,
17
+ ignoreConfig,
18
+ children
19
+ }) => {
20
+ const [network, setNetwork] = React.useState(defaultNetwork);
21
+ const injectedQueryClient = useContext(QueryClientContext);
22
+ const mergedQueryClient = React.useMemo(() => {
23
+ return queryClient ?? injectedQueryClient ?? new QueryClient();
24
+ }, [injectedQueryClient, queryClient]);
25
+ const mergedNetworkConfig = React.useMemo(() => {
26
+ return networkConfig ?? createNetworkConfig({
27
+ mainnet: {
28
+ url: getFullnodeUrl('mainnet')
29
+ }
30
+ }).networkConfig;
31
+ }, [networkConfig]);
32
+ const networks = React.useMemo(() => {
33
+ const networkConfigKeys = Object.keys(mergedNetworkConfig);
34
+ const networkConfigs = [suiMainnet, suiTestnet, suiDevnet, suiLocalnet];
35
+ return networkConfigKeys.map(networkKey => networkConfigs.find(item => item.network === networkKey)).filter(item => !!item);
36
+ }, [mergedNetworkConfig]);
37
+ const currentNetwork = React.useMemo(() => {
38
+ return networks?.find(item => item.network === network);
39
+ }, [network, networks]);
40
+ return /*#__PURE__*/_jsx(QueryClientProvider, {
41
+ client: mergedQueryClient,
42
+ children: /*#__PURE__*/_jsx(SuiClientProvider, {
43
+ networks: mergedNetworkConfig,
44
+ network: network,
45
+ children: /*#__PURE__*/_jsx(WalletProvider, {
46
+ autoConnect: autoConnect,
47
+ children: /*#__PURE__*/_jsx(AntDesignWeb3ConfigProvider, {
48
+ locale: locale,
49
+ availableChains: networks,
50
+ availableWallets: wallets,
51
+ currentChain: currentNetwork,
52
+ balance: balance,
53
+ sns: sns,
54
+ onCurrentChainChange: setNetwork,
55
+ ignoreConfig: ignoreConfig,
56
+ children: children
57
+ })
58
+ })
59
+ })
60
+ });
61
+ };
@@ -0,0 +1,4 @@
1
+ export declare const Suiet: () => import("packages/sui/src/wallets/types").WalletFactory;
2
+ export declare const Slush: () => import("packages/sui/src/wallets/types").WalletFactory;
3
+ /** @deprecated Please use `Slush()` instead */
4
+ export declare const SuiWallet: () => import("packages/sui/src/wallets/types").WalletFactory;
@@ -0,0 +1,8 @@
1
+ /* v8 ignore start */
2
+ import { metadata_Slush, metadata_Suiet } from '@ant-design/web3-assets';
3
+ import { WalletFactory } from "./factory";
4
+ export const Suiet = () => WalletFactory(metadata_Suiet);
5
+ export const Slush = () => WalletFactory(metadata_Slush);
6
+
7
+ /** @deprecated Please use `Slush()` instead */
8
+ export const SuiWallet = () => WalletFactory(metadata_Slush);
@@ -0,0 +1,2 @@
1
+ import type { WalletFactoryBuilder } from './types';
2
+ export declare const WalletFactory: WalletFactoryBuilder;
@@ -0,0 +1,15 @@
1
+ /* v8 ignore start */
2
+
3
+ export const WalletFactory = metadata => {
4
+ return {
5
+ create: () => {
6
+ return {
7
+ ...metadata,
8
+ // We simply assume that all wallets implement the `Standard Wallet`,
9
+ // so the wallets provided by `wallets` are not available.
10
+ hasWalletReady: () => Promise.resolve(false),
11
+ hasExtensionInstalled: () => Promise.resolve(false)
12
+ };
13
+ }
14
+ };
15
+ };
@@ -0,0 +1,5 @@
1
+ import type { Wallet, WalletMetadata } from '@ant-design/web3-common';
2
+ export interface WalletFactory {
3
+ create: () => Wallet;
4
+ }
5
+ export type WalletFactoryBuilder = (metadata: WalletMetadata) => WalletFactory;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { Chain } from '@ant-design/web3-common';
2
+ import { SuiChainIds } from '@ant-design/web3-common';
3
+ export interface SuiChain extends Chain {
4
+ id: SuiChainIds;
5
+ network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';
6
+ }
7
+ export declare const suiMainnet: SuiChain;
8
+ export declare const suiTestnet: SuiChain;
9
+ export declare const suiDevnet: SuiChain;
10
+ export declare const suiLocalnet: SuiChain;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.suiTestnet = exports.suiMainnet = exports.suiLocalnet = exports.suiDevnet = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _web3Common = require("@ant-design/web3-common");
9
+ var _web3Icons = require("@ant-design/web3-icons");
10
+ var _utils = require("@mysten/sui/utils");
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ const suiMainnet = exports.suiMainnet = {
14
+ id: _web3Common.SuiChainIds.Mainnet,
15
+ name: 'Sui',
16
+ network: 'mainnet',
17
+ icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_web3Icons.SuiColorful, {}),
18
+ browser: {
19
+ icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_web3Icons.SuiColorful, {}),
20
+ getBrowserLink: (0, _web3Common.createGetBrowserLink)('https://suiscan.xyz/mainnet')
21
+ },
22
+ nativeCurrency: {
23
+ name: 'Sui',
24
+ symbol: 'SUI',
25
+ decimals: _utils.SUI_DECIMALS
26
+ }
27
+ };
28
+ const suiTestnet = exports.suiTestnet = {
29
+ id: _web3Common.SuiChainIds.Testnet,
30
+ name: 'Sui Testnet',
31
+ network: 'testnet',
32
+ icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_web3Icons.SuiColorful, {}),
33
+ browser: {
34
+ icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_web3Icons.SuiColorful, {}),
35
+ getBrowserLink: (0, _web3Common.createGetBrowserLink)('https://suiscan.xyz/testnet')
36
+ },
37
+ nativeCurrency: {
38
+ name: 'Sui',
39
+ symbol: 'SUI',
40
+ decimals: _utils.SUI_DECIMALS
41
+ }
42
+ };
43
+ const suiDevnet = exports.suiDevnet = {
44
+ id: _web3Common.SuiChainIds.Devnet,
45
+ name: 'Sui Devnet',
46
+ network: 'devnet',
47
+ icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_web3Icons.SuiColorful, {}),
48
+ browser: {
49
+ icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_web3Icons.SuiColorful, {}),
50
+ getBrowserLink: (0, _web3Common.createGetBrowserLink)('https://suiscan.xyz/devnet')
51
+ },
52
+ nativeCurrency: {
53
+ name: 'Sui',
54
+ symbol: 'SUI',
55
+ decimals: _utils.SUI_DECIMALS
56
+ }
57
+ };
58
+ const suiLocalnet = exports.suiLocalnet = {
59
+ id: _web3Common.SuiChainIds.Localnet,
60
+ name: 'Sui Localnet',
61
+ network: 'localnet',
62
+ icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_web3Icons.SuiColorful, {}),
63
+ browser: {
64
+ icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_web3Icons.SuiColorful, {})
65
+ },
66
+ nativeCurrency: {
67
+ name: 'Sui',
68
+ symbol: 'SUI',
69
+ decimals: _utils.SUI_DECIMALS
70
+ }
71
+ };
@@ -0,0 +1,4 @@
1
+ export * from './chain';
2
+ export * from './sui-provider';
3
+ export * from './wallets/built-in';
4
+ export * from './wallets/factory';
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _chain = require("./chain");
7
+ Object.keys(_chain).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _chain[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _chain[key];
14
+ }
15
+ });
16
+ });
17
+ var _suiProvider = require("./sui-provider");
18
+ Object.keys(_suiProvider).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _suiProvider[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _suiProvider[key];
25
+ }
26
+ });
27
+ });
28
+ var _builtIn = require("./wallets/built-in");
29
+ Object.keys(_builtIn).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _builtIn[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _builtIn[key];
36
+ }
37
+ });
38
+ });
39
+ var _factory = require("./wallets/factory");
40
+ Object.keys(_factory).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _factory[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _factory[key];
47
+ }
48
+ });
49
+ });
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import type { Locale } from '@ant-design/web3-common';
3
+ import type { SuiChain } from '../chain';
4
+ import type { WalletFactory } from '../wallets/types';
5
+ export interface AntDesignWeb3ConfigProviderProps {
6
+ balance?: boolean;
7
+ locale?: Locale;
8
+ availableChains?: SuiChain[];
9
+ availableWallets?: WalletFactory[];
10
+ currentChain?: SuiChain;
11
+ sns?: boolean;
12
+ onCurrentChainChange: (network: string) => void;
13
+ /**
14
+ * If true, this provider's configuration will be ignored when merging with parent context.
15
+ * This is useful when you have multiple chain providers and want to switch between them
16
+ * without causing page flickering. Only the active provider should not have this flag set.
17
+ */
18
+ ignoreConfig?: boolean;
19
+ }
20
+ export declare const AntDesignWeb3ConfigProvider: React.FC<React.PropsWithChildren<AntDesignWeb3ConfigProviderProps>>;
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.AntDesignWeb3ConfigProvider = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _tokens = require("@ant-design/web3-assets/tokens");
9
+ var _web3Common = require("@ant-design/web3-common");
10
+ var _web3Icons = require("@ant-design/web3-icons");
11
+ var _dappKit = require("@mysten/dapp-kit");
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
+ const AntDesignWeb3ConfigProvider = ({
16
+ balance: showBalance,
17
+ locale,
18
+ availableChains,
19
+ availableWallets,
20
+ currentChain,
21
+ sns,
22
+ onCurrentChainChange,
23
+ ignoreConfig,
24
+ children
25
+ }) => {
26
+ const account = (0, _dappKit.useCurrentAccount)();
27
+ const standardWallets = (0, _dappKit.useWallets)();
28
+ const {
29
+ mutateAsync: connectAsync
30
+ } = (0, _dappKit.useConnectWallet)();
31
+ const {
32
+ mutateAsync: disconnectAsync
33
+ } = (0, _dappKit.useDisconnectWallet)();
34
+ const {
35
+ data: snsData
36
+ } = (0, _dappKit.useResolveSuiNSName)(sns ? account?.address : undefined);
37
+ const client = (0, _dappKit.useSuiClient)();
38
+ const {
39
+ data: balanceData
40
+ } = (0, _dappKit.useSuiClientQuery)('getBalance', {
41
+ owner: account?.address ?? ''
42
+ }, {
43
+ select(data) {
44
+ return BigInt(data.totalBalance);
45
+ }
46
+ });
47
+ const accountData = account ? {
48
+ address: account.address,
49
+ name: sns && snsData ? snsData : undefined
50
+ } : undefined;
51
+ const allWallets = (0, _react.useMemo)(() => {
52
+ const standardWalletNames = standardWallets.map(w => w.name);
53
+ const fixedWallets = availableWallets?.map(factory => factory.create())?.filter(w => !standardWalletNames.includes(w.name));
54
+ const injectedWalletAssets = standardWallets.map(w => {
55
+ return {
56
+ name: w.name,
57
+ icon: w.icon,
58
+ remark: w.name,
59
+ _standardWallet: w,
60
+ async hasExtensionInstalled() {
61
+ return true;
62
+ },
63
+ async hasWalletReady() {
64
+ return true;
65
+ }
66
+ };
67
+ });
68
+ return fixedWallets ? fixedWallets.concat(injectedWalletAssets) : injectedWalletAssets;
69
+ }, [availableWallets, standardWallets]);
70
+ const getNFTMetadataFunc = (0, _react.useCallback)(async ({
71
+ address
72
+ }) => {
73
+ const {
74
+ data: nftData
75
+ } = await client.getObject({
76
+ id: address,
77
+ options: {
78
+ showContent: true,
79
+ showDisplay: true
80
+ }
81
+ });
82
+ const displayData = nftData?.display?.data;
83
+ const objectFields = nftData?.content?.dataType === 'moveObject' ? nftData.content.fields : undefined;
84
+ return {
85
+ image: displayData?.image_url,
86
+ date: objectFields?.birthdate,
87
+ attributes: objectFields?.attributes,
88
+ description: displayData?.description,
89
+ edition: nftData?.version
90
+ };
91
+ }, [client]);
92
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_web3Common.Web3ConfigProvider, {
93
+ availableChains: availableChains,
94
+ availableWallets: allWallets,
95
+ locale: locale,
96
+ account: accountData,
97
+ chain: currentChain,
98
+ balance: showBalance ? {
99
+ symbol: _tokens.SUI.symbol,
100
+ decimals: _tokens.SUI.decimal,
101
+ value: balanceData,
102
+ icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_web3Icons.SuiColorful, {})
103
+ } : undefined,
104
+ connect: async wallet => {
105
+ const foundWallet = wallet?._standardWallet;
106
+ if (!foundWallet) {
107
+ throw new Error(`Can not find wallet ${wallet?.name}`);
108
+ }
109
+ const {
110
+ accounts
111
+ } = await connectAsync({
112
+ wallet: foundWallet
113
+ });
114
+ const defaultAccount = accounts[0];
115
+ const addresses = accounts.map(item => item.address);
116
+ return {
117
+ address: defaultAccount.address,
118
+ addresses: addresses
119
+ };
120
+ },
121
+ disconnect: async () => {
122
+ await disconnectAsync();
123
+ },
124
+ switchChain: async chain => {
125
+ const network = availableChains?.find(item => item.id === chain.id)?.network;
126
+ if (network) {
127
+ onCurrentChainChange(network);
128
+ }
129
+ },
130
+ getNFTMetadata: getNFTMetadataFunc,
131
+ ignoreConfig: ignoreConfig,
132
+ children: children
133
+ });
134
+ };
135
+ exports.AntDesignWeb3ConfigProvider = AntDesignWeb3ConfigProvider;
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import type { Locale } from '@ant-design/web3-common';
3
+ import { createNetworkConfig } from '@mysten/dapp-kit';
4
+ import { QueryClient } from '@tanstack/react-query';
5
+ import type { WalletFactory } from '../wallets/types';
6
+ export interface SuiWeb3ConfigProviderProps {
7
+ balance?: boolean;
8
+ locale?: Locale;
9
+ autoConnect?: boolean;
10
+ networkConfig?: ReturnType<typeof createNetworkConfig>['networkConfig'];
11
+ sns?: boolean;
12
+ defaultNetwork?: string;
13
+ wallets?: WalletFactory[];
14
+ queryClient?: QueryClient;
15
+ /**
16
+ * If true, this provider's configuration will be ignored when merging with parent context.
17
+ * This is useful when you have multiple chain providers and want to switch between them
18
+ * without causing page flickering. Only the active provider should not have this flag set.
19
+ */
20
+ ignoreConfig?: boolean;
21
+ }
22
+ export declare const SuiWeb3ConfigProvider: React.FC<React.PropsWithChildren<SuiWeb3ConfigProviderProps>>;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SuiWeb3ConfigProvider = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _dappKit = require("@mysten/dapp-kit");
9
+ var _client = require("@mysten/sui/client");
10
+ var _reactQuery = require("@tanstack/react-query");
11
+ var _chain = require("../chain");
12
+ var _configProvider = require("./config-provider");
13
+ var _jsxRuntime = require("react/jsx-runtime");
14
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
+ const SuiWeb3ConfigProvider = ({
17
+ autoConnect,
18
+ balance,
19
+ locale,
20
+ networkConfig,
21
+ defaultNetwork = 'mainnet',
22
+ queryClient,
23
+ sns,
24
+ wallets,
25
+ ignoreConfig,
26
+ children
27
+ }) => {
28
+ const [network, setNetwork] = _react.default.useState(defaultNetwork);
29
+ const injectedQueryClient = (0, _react.useContext)(_reactQuery.QueryClientContext);
30
+ const mergedQueryClient = _react.default.useMemo(() => {
31
+ return queryClient ?? injectedQueryClient ?? new _reactQuery.QueryClient();
32
+ }, [injectedQueryClient, queryClient]);
33
+ const mergedNetworkConfig = _react.default.useMemo(() => {
34
+ return networkConfig ?? (0, _dappKit.createNetworkConfig)({
35
+ mainnet: {
36
+ url: (0, _client.getFullnodeUrl)('mainnet')
37
+ }
38
+ }).networkConfig;
39
+ }, [networkConfig]);
40
+ const networks = _react.default.useMemo(() => {
41
+ const networkConfigKeys = Object.keys(mergedNetworkConfig);
42
+ const networkConfigs = [_chain.suiMainnet, _chain.suiTestnet, _chain.suiDevnet, _chain.suiLocalnet];
43
+ return networkConfigKeys.map(networkKey => networkConfigs.find(item => item.network === networkKey)).filter(item => !!item);
44
+ }, [mergedNetworkConfig]);
45
+ const currentNetwork = _react.default.useMemo(() => {
46
+ return networks?.find(item => item.network === network);
47
+ }, [network, networks]);
48
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactQuery.QueryClientProvider, {
49
+ client: mergedQueryClient,
50
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_dappKit.SuiClientProvider, {
51
+ networks: mergedNetworkConfig,
52
+ network: network,
53
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_dappKit.WalletProvider, {
54
+ autoConnect: autoConnect,
55
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_configProvider.AntDesignWeb3ConfigProvider, {
56
+ locale: locale,
57
+ availableChains: networks,
58
+ availableWallets: wallets,
59
+ currentChain: currentNetwork,
60
+ balance: balance,
61
+ sns: sns,
62
+ onCurrentChainChange: setNetwork,
63
+ ignoreConfig: ignoreConfig,
64
+ children: children
65
+ })
66
+ })
67
+ })
68
+ });
69
+ };
70
+ exports.SuiWeb3ConfigProvider = SuiWeb3ConfigProvider;
@@ -0,0 +1,4 @@
1
+ export declare const Suiet: () => import("packages/sui/src/wallets/types").WalletFactory;
2
+ export declare const Slush: () => import("packages/sui/src/wallets/types").WalletFactory;
3
+ /** @deprecated Please use `Slush()` instead */
4
+ export declare const SuiWallet: () => import("packages/sui/src/wallets/types").WalletFactory;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Suiet = exports.SuiWallet = exports.Slush = void 0;
7
+ var _web3Assets = require("@ant-design/web3-assets");
8
+ var _factory = require("./factory");
9
+ /* v8 ignore start */
10
+
11
+ const Suiet = () => (0, _factory.WalletFactory)(_web3Assets.metadata_Suiet);
12
+ exports.Suiet = Suiet;
13
+ const Slush = () => (0, _factory.WalletFactory)(_web3Assets.metadata_Slush);
14
+
15
+ /** @deprecated Please use `Slush()` instead */
16
+ exports.Slush = Slush;
17
+ const SuiWallet = () => (0, _factory.WalletFactory)(_web3Assets.metadata_Slush);
18
+ exports.SuiWallet = SuiWallet;
@@ -0,0 +1,2 @@
1
+ import type { WalletFactoryBuilder } from './types';
2
+ export declare const WalletFactory: WalletFactoryBuilder;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.WalletFactory = void 0;
7
+ /* v8 ignore start */
8
+
9
+ const WalletFactory = metadata => {
10
+ return {
11
+ create: () => {
12
+ return {
13
+ ...metadata,
14
+ // We simply assume that all wallets implement the `Standard Wallet`,
15
+ // so the wallets provided by `wallets` are not available.
16
+ hasWalletReady: () => Promise.resolve(false),
17
+ hasExtensionInstalled: () => Promise.resolve(false)
18
+ };
19
+ }
20
+ };
21
+ };
22
+ exports.WalletFactory = WalletFactory;
@@ -0,0 +1,5 @@
1
+ import type { Wallet, WalletMetadata } from '@ant-design/web3-common';
2
+ export interface WalletFactory {
3
+ create: () => Wallet;
4
+ }
5
+ export type WalletFactoryBuilder = (metadata: WalletMetadata) => WalletFactory;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@ant-design/web3-sui",
3
+ "version": "0.0.0-alpha-20260209094036",
4
+ "main": "dist/lib/index.js",
5
+ "module": "dist/esm/index.js",
6
+ "typings": "dist/esm/index.d.ts",
7
+ "exports": {
8
+ "import": "./dist/esm/index.js",
9
+ "require": "./dist/lib/index.js",
10
+ "types": "./dist/esm/index.d.ts"
11
+ },
12
+ "sideEffects": false,
13
+ "files": [
14
+ "dist",
15
+ "CHANGELOG.md",
16
+ "README.md"
17
+ ],
18
+ "keywords": [
19
+ "ant",
20
+ "design",
21
+ "web3",
22
+ "antd",
23
+ "component",
24
+ "components",
25
+ "framework",
26
+ "frontend",
27
+ "react",
28
+ "react-component",
29
+ "ui",
30
+ "sui"
31
+ ],
32
+ "homepage": "https://web3.ant.design",
33
+ "bugs": {
34
+ "url": "https://github.com/ant-design/ant-design-web3/issues"
35
+ },
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "https://github.com/ant-design/ant-design-web3"
39
+ },
40
+ "dependencies": {
41
+ "debug": "^4.4.0",
42
+ "@ant-design/web3-common": "0.0.0-alpha-20260209094036",
43
+ "@ant-design/web3-assets": "0.0.0-alpha-20260209094036"
44
+ },
45
+ "devDependencies": {
46
+ "@mysten/dapp-kit": "^0.14.50",
47
+ "@mysten/sui": "^1.37.1",
48
+ "@tanstack/react-query": "^5.40.1",
49
+ "@types/debug": "^4.1.12",
50
+ "father": "^4.6.2",
51
+ "typescript": "^5.6.2"
52
+ },
53
+ "peerDependencies": {
54
+ "@mysten/dapp-kit": "^0.14.50",
55
+ "@mysten/sui": "^1.37.1",
56
+ "@tanstack/react-query": "^5.40.1"
57
+ },
58
+ "publishConfig": {
59
+ "registry": "https://registry.npmjs.org",
60
+ "access": "public"
61
+ },
62
+ "browserslist": [
63
+ "last 2 versions",
64
+ "Firefox ESR",
65
+ "> 1%",
66
+ "ie >= 11"
67
+ ],
68
+ "scripts": {
69
+ "dev": "father dev",
70
+ "build": "father build"
71
+ }
72
+ }