@mysten/dapp-kit 0.4.0 → 0.6.0
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 +28 -0
- package/README.md +6 -6
- package/dist/cjs/components/AccountDropdownMenu.d.ts +4 -0
- package/dist/cjs/components/AccountDropdownMenu.js +61 -18
- package/dist/cjs/components/AccountDropdownMenu.js.map +2 -2
- package/dist/cjs/components/ConnectButton.js +74 -25
- package/dist/cjs/components/ConnectButton.js.map +3 -3
- package/dist/cjs/components/SuiClientProvider.d.ts +4 -4
- package/dist/cjs/components/SuiClientProvider.js +1 -0
- package/dist/cjs/components/SuiClientProvider.js.map +2 -2
- package/dist/cjs/components/WalletProvider.js +91 -28
- package/dist/cjs/components/WalletProvider.js.map +3 -3
- package/dist/cjs/components/connect-modal/ConnectModal.js +15 -8
- package/dist/cjs/components/connect-modal/ConnectModal.js.map +2 -2
- package/dist/cjs/hooks/networkConfig.d.ts +10 -0
- package/dist/cjs/hooks/networkConfig.js +74 -0
- package/dist/cjs/hooks/networkConfig.js.map +7 -0
- package/dist/cjs/hooks/useResolveSuiNSNames.d.ts +3 -105
- package/dist/cjs/hooks/useResolveSuiNSNames.js +6 -5
- package/dist/cjs/hooks/useResolveSuiNSNames.js.map +2 -2
- package/dist/cjs/hooks/useSuiClient.js.map +2 -2
- package/dist/cjs/hooks/useSuiClientInfiniteQuery.d.ts +7 -8
- package/dist/cjs/hooks/useSuiClientInfiniteQuery.js +11 -7
- package/dist/cjs/hooks/useSuiClientInfiniteQuery.js.map +2 -2
- package/dist/cjs/hooks/useSuiClientMutation.d.ts +1 -1
- package/dist/cjs/hooks/useSuiClientMutation.js.map +2 -2
- package/dist/cjs/hooks/useSuiClientQuery.d.ts +3 -2
- package/dist/cjs/hooks/useSuiClientQuery.js.map +2 -2
- package/dist/cjs/hooks/wallet/useAutoConnectWallet.js +65 -15
- package/dist/cjs/hooks/wallet/useAutoConnectWallet.js.map +3 -3
- package/dist/cjs/hooks/wallet/useAutoConnectionStatus.d.ts +4 -0
- package/dist/cjs/hooks/wallet/useAutoConnectionStatus.js +50 -0
- package/dist/cjs/hooks/wallet/useAutoConnectionStatus.js.map +7 -0
- package/dist/cjs/hooks/wallet/useConnectWallet.d.ts +1 -1
- package/dist/cjs/hooks/wallet/useConnectWallet.js +15 -8
- package/dist/cjs/hooks/wallet/useConnectWallet.js.map +2 -2
- package/dist/cjs/hooks/wallet/useCurrentWallet.d.ts +19 -1
- package/dist/cjs/hooks/wallet/useCurrentWallet.js +29 -1
- package/dist/cjs/hooks/wallet/useCurrentWallet.js.map +2 -2
- package/dist/cjs/hooks/wallet/useDisconnectWallet.d.ts +1 -1
- package/dist/cjs/hooks/wallet/useDisconnectWallet.js +30 -2
- package/dist/cjs/hooks/wallet/useDisconnectWallet.js.map +2 -2
- package/dist/cjs/hooks/wallet/useSignAndExecuteTransactionBlock.d.ts +1 -1
- package/dist/cjs/hooks/wallet/useSignAndExecuteTransactionBlock.js +30 -2
- package/dist/cjs/hooks/wallet/useSignAndExecuteTransactionBlock.js.map +2 -2
- package/dist/cjs/hooks/wallet/useSignPersonalMessage.d.ts +1 -1
- package/dist/cjs/hooks/wallet/useSignPersonalMessage.js +30 -2
- package/dist/cjs/hooks/wallet/useSignPersonalMessage.js.map +2 -2
- package/dist/cjs/hooks/wallet/useSignTransactionBlock.d.ts +1 -1
- package/dist/cjs/hooks/wallet/useSignTransactionBlock.js +30 -2
- package/dist/cjs/hooks/wallet/useSignTransactionBlock.js.map +2 -2
- package/dist/cjs/hooks/wallet/useSwitchAccount.d.ts +1 -1
- package/dist/cjs/hooks/wallet/useSwitchAccount.js +30 -2
- package/dist/cjs/hooks/wallet/useSwitchAccount.js.map +2 -2
- package/dist/cjs/hooks/wallet/useUnsafeBurnerWallet.js.map +2 -2
- package/dist/cjs/hooks/wallet/useWalletPropertiesChanged.js +30 -2
- package/dist/cjs/hooks/wallet/useWalletPropertiesChanged.js.map +2 -2
- package/dist/cjs/index.css +127 -127
- package/dist/cjs/index.css.map +3 -3
- package/dist/cjs/index.d.ts +14 -10
- package/dist/cjs/index.js +698 -577
- package/dist/cjs/index.js.map +4 -4
- package/dist/cjs/walletStore.d.ts +10 -2
- package/dist/cjs/walletStore.js +23 -4
- package/dist/cjs/walletStore.js.map +2 -2
- package/dist/esm/components/AccountDropdownMenu.d.ts +4 -0
- package/dist/esm/components/AccountDropdownMenu.js +61 -18
- package/dist/esm/components/AccountDropdownMenu.js.map +2 -2
- package/dist/esm/components/ConnectButton.js +74 -25
- package/dist/esm/components/ConnectButton.js.map +3 -3
- package/dist/esm/components/SuiClientProvider.d.ts +4 -4
- package/dist/esm/components/SuiClientProvider.js +1 -0
- package/dist/esm/components/SuiClientProvider.js.map +2 -2
- package/dist/esm/components/WalletProvider.js +91 -28
- package/dist/esm/components/WalletProvider.js.map +3 -3
- package/dist/esm/components/connect-modal/ConnectModal.js +15 -8
- package/dist/esm/components/connect-modal/ConnectModal.js.map +2 -2
- package/dist/esm/hooks/networkConfig.d.ts +10 -0
- package/dist/esm/hooks/networkConfig.js +51 -0
- package/dist/esm/hooks/networkConfig.js.map +7 -0
- package/dist/esm/hooks/useResolveSuiNSNames.d.ts +3 -105
- package/dist/esm/hooks/useResolveSuiNSNames.js +6 -5
- package/dist/esm/hooks/useResolveSuiNSNames.js.map +2 -2
- package/dist/esm/hooks/useSuiClient.js.map +2 -2
- package/dist/esm/hooks/useSuiClientInfiniteQuery.d.ts +7 -8
- package/dist/esm/hooks/useSuiClientInfiniteQuery.js +11 -7
- package/dist/esm/hooks/useSuiClientInfiniteQuery.js.map +2 -2
- package/dist/esm/hooks/useSuiClientMutation.d.ts +1 -1
- package/dist/esm/hooks/useSuiClientMutation.js.map +2 -2
- package/dist/esm/hooks/useSuiClientQuery.d.ts +3 -2
- package/dist/esm/hooks/useSuiClientQuery.js.map +2 -2
- package/dist/esm/hooks/wallet/useAutoConnectWallet.js +65 -15
- package/dist/esm/hooks/wallet/useAutoConnectWallet.js.map +3 -3
- package/dist/esm/hooks/wallet/useAutoConnectionStatus.d.ts +4 -0
- package/dist/esm/hooks/wallet/useAutoConnectionStatus.js +27 -0
- package/dist/esm/hooks/wallet/useAutoConnectionStatus.js.map +7 -0
- package/dist/esm/hooks/wallet/useConnectWallet.d.ts +1 -1
- package/dist/esm/hooks/wallet/useConnectWallet.js +15 -8
- package/dist/esm/hooks/wallet/useConnectWallet.js.map +2 -2
- package/dist/esm/hooks/wallet/useCurrentWallet.d.ts +19 -1
- package/dist/esm/hooks/wallet/useCurrentWallet.js +29 -1
- package/dist/esm/hooks/wallet/useCurrentWallet.js.map +2 -2
- package/dist/esm/hooks/wallet/useDisconnectWallet.d.ts +1 -1
- package/dist/esm/hooks/wallet/useDisconnectWallet.js +30 -2
- package/dist/esm/hooks/wallet/useDisconnectWallet.js.map +2 -2
- package/dist/esm/hooks/wallet/useSignAndExecuteTransactionBlock.d.ts +1 -1
- package/dist/esm/hooks/wallet/useSignAndExecuteTransactionBlock.js +30 -2
- package/dist/esm/hooks/wallet/useSignAndExecuteTransactionBlock.js.map +2 -2
- package/dist/esm/hooks/wallet/useSignPersonalMessage.d.ts +1 -1
- package/dist/esm/hooks/wallet/useSignPersonalMessage.js +30 -2
- package/dist/esm/hooks/wallet/useSignPersonalMessage.js.map +2 -2
- package/dist/esm/hooks/wallet/useSignTransactionBlock.d.ts +1 -1
- package/dist/esm/hooks/wallet/useSignTransactionBlock.js +30 -2
- package/dist/esm/hooks/wallet/useSignTransactionBlock.js.map +2 -2
- package/dist/esm/hooks/wallet/useSwitchAccount.d.ts +1 -1
- package/dist/esm/hooks/wallet/useSwitchAccount.js +30 -2
- package/dist/esm/hooks/wallet/useSwitchAccount.js.map +2 -2
- package/dist/esm/hooks/wallet/useUnsafeBurnerWallet.js.map +2 -2
- package/dist/esm/hooks/wallet/useWalletPropertiesChanged.js +30 -2
- package/dist/esm/hooks/wallet/useWalletPropertiesChanged.js.map +2 -2
- package/dist/esm/index.css +127 -127
- package/dist/esm/index.css.map +3 -3
- package/dist/esm/index.d.ts +14 -10
- package/dist/esm/index.js +692 -571
- package/dist/esm/index.js.map +4 -4
- package/dist/esm/walletStore.d.ts +10 -2
- package/dist/esm/walletStore.js +23 -4
- package/dist/esm/walletStore.js.map +2 -2
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/components/AccountDropdownMenu.tsx +26 -8
- package/src/components/SuiClientProvider.tsx +11 -2
- package/src/components/WalletProvider.tsx +1 -0
- package/src/hooks/networkConfig.ts +45 -0
- package/src/hooks/useResolveSuiNSNames.ts +14 -5
- package/src/hooks/useSuiClientInfiniteQuery.ts +38 -24
- package/src/hooks/useSuiClientQuery.ts +11 -7
- package/src/hooks/wallet/useAutoConnectWallet.ts +24 -7
- package/src/hooks/wallet/useAutoConnectionStatus.ts +12 -0
- package/src/hooks/wallet/useConnectWallet.ts +17 -8
- package/src/hooks/wallet/useCurrentWallet.ts +30 -1
- package/src/hooks/wallet/useDisconnectWallet.ts +1 -1
- package/src/hooks/wallet/useSignAndExecuteTransactionBlock.ts +1 -1
- package/src/hooks/wallet/useSignPersonalMessage.ts +1 -1
- package/src/hooks/wallet/useSignTransactionBlock.ts +1 -1
- package/src/hooks/wallet/useSwitchAccount.ts +1 -1
- package/src/hooks/wallet/useWalletPropertiesChanged.ts +1 -1
- package/src/index.ts +14 -10
- package/src/walletStore.ts +30 -2
package/dist/esm/index.js
CHANGED
|
@@ -54,133 +54,12 @@ var require_StyleMarker_css = __commonJS({
|
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
// src/
|
|
58
|
-
import
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
import { getFullnodeUrl, isSuiClient, SuiClient } from "@mysten/sui.js/client";
|
|
62
|
-
import { createContext, useMemo, useState } from "react";
|
|
63
|
-
import { jsx } from "react/jsx-runtime";
|
|
64
|
-
var SuiClientContext = createContext(null);
|
|
65
|
-
var DEFAULT_NETWORKS = {
|
|
66
|
-
localnet: { url: getFullnodeUrl("localnet") }
|
|
67
|
-
};
|
|
68
|
-
var DEFAULT_CREATE_CLIENT = function createClient(_name, config) {
|
|
69
|
-
if (isSuiClient(config)) {
|
|
70
|
-
return config;
|
|
71
|
-
}
|
|
72
|
-
return new SuiClient(config);
|
|
73
|
-
};
|
|
74
|
-
function SuiClientProvider(props) {
|
|
75
|
-
const { onNetworkChange, network, children } = props;
|
|
76
|
-
const networks = props.networks ?? DEFAULT_NETWORKS;
|
|
77
|
-
const createClient2 = props.createClient ?? DEFAULT_CREATE_CLIENT;
|
|
78
|
-
const [selectedNetwork, setSelectedNetwork] = useState(
|
|
79
|
-
props.network ?? props.defaultNetwork ?? Object.keys(networks)[0]
|
|
80
|
-
);
|
|
81
|
-
const currentNetwork = props.network ?? selectedNetwork;
|
|
82
|
-
const client = useMemo(() => {
|
|
83
|
-
return createClient2(currentNetwork, networks[currentNetwork]);
|
|
84
|
-
}, [createClient2, currentNetwork, networks]);
|
|
85
|
-
const ctx = useMemo(() => {
|
|
86
|
-
return {
|
|
87
|
-
client,
|
|
88
|
-
networks,
|
|
89
|
-
network: currentNetwork,
|
|
90
|
-
selectNetwork: (newNetwork) => {
|
|
91
|
-
if (currentNetwork === newNetwork) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
if (!network && newNetwork !== selectedNetwork) {
|
|
95
|
-
setSelectedNetwork(newNetwork);
|
|
96
|
-
}
|
|
97
|
-
onNetworkChange?.(newNetwork);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
}, [client, networks, selectedNetwork, currentNetwork, network, onNetworkChange]);
|
|
101
|
-
return /* @__PURE__ */ jsx(SuiClientContext.Provider, { value: ctx, children });
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// src/hooks/useSuiClient.ts
|
|
105
|
-
function useSuiClientContext() {
|
|
106
|
-
const suiClient = useContext(SuiClientContext);
|
|
107
|
-
if (!suiClient) {
|
|
108
|
-
throw new Error(
|
|
109
|
-
"Could not find SuiClientContext. Ensure that you have set up the SuiClientProvider"
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
return suiClient;
|
|
113
|
-
}
|
|
114
|
-
function useSuiClient() {
|
|
115
|
-
return useSuiClientContext().client;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// src/hooks/wallet/useWalletStore.ts
|
|
119
|
-
import { useContext as useContext2 } from "react";
|
|
120
|
-
import { useStore } from "zustand";
|
|
121
|
-
|
|
122
|
-
// src/contexts/walletContext.ts
|
|
123
|
-
import { createContext as createContext2 } from "react";
|
|
124
|
-
var WalletContext = createContext2(null);
|
|
125
|
-
|
|
126
|
-
// src/hooks/wallet/useWalletStore.ts
|
|
127
|
-
function useWalletStore(selector) {
|
|
128
|
-
const store = useContext2(WalletContext);
|
|
129
|
-
if (!store) {
|
|
130
|
-
throw new Error(
|
|
131
|
-
"Could not find WalletContext. Ensure that you have set up the WalletProvider."
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
return useStore(store, selector);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// src/hooks/wallet/useCurrentAccount.ts
|
|
138
|
-
function useCurrentAccount() {
|
|
139
|
-
return useWalletStore((state) => state.currentAccount);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// src/components/AccountDropdownMenu.tsx
|
|
143
|
-
import { formatAddress } from "@mysten/sui.js/utils";
|
|
144
|
-
import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
|
|
145
|
-
import clsx3 from "clsx";
|
|
146
|
-
|
|
147
|
-
// src/hooks/useSuiClientQuery.ts
|
|
148
|
-
import { useQuery } from "@tanstack/react-query";
|
|
149
|
-
function useSuiClientQuery(...args) {
|
|
150
|
-
const [method, params, { queryKey = [], ...options } = {}] = args;
|
|
151
|
-
const suiContext = useSuiClientContext();
|
|
152
|
-
return useQuery({
|
|
153
|
-
...options,
|
|
154
|
-
queryKey: [suiContext.network, method, params, ...queryKey],
|
|
155
|
-
queryFn: async () => {
|
|
156
|
-
return await suiContext.client[method](params);
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// src/hooks/useResolveSuiNSNames.ts
|
|
162
|
-
function useResolveSuiNSName(address) {
|
|
163
|
-
const { data, ...rest } = useSuiClientQuery(
|
|
164
|
-
"resolveNameServiceNames",
|
|
165
|
-
{
|
|
166
|
-
address,
|
|
167
|
-
limit: 1
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
enabled: !!address,
|
|
171
|
-
refetchOnWindowFocus: false,
|
|
172
|
-
retry: false
|
|
173
|
-
}
|
|
174
|
-
);
|
|
175
|
-
return { data: data?.data?.[0] ?? null, ...rest };
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// src/hooks/wallet/useAccounts.ts
|
|
179
|
-
function useAccounts() {
|
|
180
|
-
return useWalletStore((state) => state.accounts);
|
|
181
|
-
}
|
|
57
|
+
// src/components/connect-modal/ConnectModal.tsx
|
|
58
|
+
import * as Dialog from "@radix-ui/react-dialog";
|
|
59
|
+
import clsx6 from "clsx";
|
|
60
|
+
import { useState } from "react";
|
|
182
61
|
|
|
183
|
-
// src/hooks/wallet/
|
|
62
|
+
// src/hooks/wallet/useConnectWallet.ts
|
|
184
63
|
import { useMutation } from "@tanstack/react-query";
|
|
185
64
|
|
|
186
65
|
// src/constants/walletMutationKeys.ts
|
|
@@ -199,246 +78,48 @@ function formMutationKeyFn(baseEntity) {
|
|
|
199
78
|
};
|
|
200
79
|
}
|
|
201
80
|
|
|
202
|
-
// src/
|
|
203
|
-
|
|
204
|
-
};
|
|
205
|
-
var WalletNoAccountSelectedError = class extends Error {
|
|
206
|
-
};
|
|
207
|
-
var WalletFeatureNotSupportedError = class extends Error {
|
|
208
|
-
};
|
|
209
|
-
var WalletAccountNotFoundError = class extends Error {
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
// src/hooks/wallet/useCurrentWallet.ts
|
|
213
|
-
function useCurrentWallet() {
|
|
214
|
-
return useWalletStore((state) => state.currentWallet);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// src/hooks/wallet/useDisconnectWallet.ts
|
|
218
|
-
function useDisconnectWallet({
|
|
219
|
-
mutationKey,
|
|
220
|
-
...mutationOptions
|
|
221
|
-
} = {}) {
|
|
222
|
-
const currentWallet = useCurrentWallet();
|
|
223
|
-
const setWalletDisconnected = useWalletStore((state) => state.setWalletDisconnected);
|
|
224
|
-
return useMutation({
|
|
225
|
-
mutationKey: walletMutationKeys.disconnectWallet(mutationKey),
|
|
226
|
-
mutationFn: async () => {
|
|
227
|
-
if (!currentWallet) {
|
|
228
|
-
throw new WalletNotConnectedError("No wallet is connected.");
|
|
229
|
-
}
|
|
230
|
-
try {
|
|
231
|
-
await currentWallet.features["standard:disconnect"]?.disconnect();
|
|
232
|
-
} catch (error) {
|
|
233
|
-
console.error("Failed to disconnect the application from the current wallet.", error);
|
|
234
|
-
}
|
|
235
|
-
setWalletDisconnected();
|
|
236
|
-
},
|
|
237
|
-
...mutationOptions
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
// src/hooks/wallet/useSwitchAccount.ts
|
|
242
|
-
import { useMutation as useMutation2 } from "@tanstack/react-query";
|
|
243
|
-
function useSwitchAccount({
|
|
244
|
-
mutationKey,
|
|
245
|
-
...mutationOptions
|
|
246
|
-
} = {}) {
|
|
247
|
-
const currentWallet = useCurrentWallet();
|
|
248
|
-
const setAccountSwitched = useWalletStore((state) => state.setAccountSwitched);
|
|
249
|
-
return useMutation2({
|
|
250
|
-
mutationKey: walletMutationKeys.switchAccount(mutationKey),
|
|
251
|
-
mutationFn: async ({ account }) => {
|
|
252
|
-
if (!currentWallet) {
|
|
253
|
-
throw new WalletNotConnectedError("No wallet is connected.");
|
|
254
|
-
}
|
|
255
|
-
const accountToSelect = currentWallet.accounts.find(
|
|
256
|
-
(walletAccount) => walletAccount.address === account.address
|
|
257
|
-
);
|
|
258
|
-
if (!accountToSelect) {
|
|
259
|
-
throw new WalletAccountNotFoundError(
|
|
260
|
-
`No account with address ${account.address} is connected to ${currentWallet.name}.`
|
|
261
|
-
);
|
|
262
|
-
}
|
|
263
|
-
setAccountSwitched(accountToSelect);
|
|
264
|
-
},
|
|
265
|
-
...mutationOptions
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
// src/components/AccountDropdownMenu.css.ts
|
|
270
|
-
var connectedAccount = "AccountDropdownMenu_connectedAccount__div2ql0";
|
|
271
|
-
var menuContent = "AccountDropdownMenu_menuContent__div2ql1";
|
|
272
|
-
var menuItem = "AccountDropdownMenu_menuItem__div2ql2";
|
|
273
|
-
var separator = "AccountDropdownMenu_separator__div2ql4";
|
|
274
|
-
var switchAccountMenuItem = "AccountDropdownMenu_switchAccountMenuItem__div2ql3";
|
|
275
|
-
|
|
276
|
-
// src/components/icons/CheckIcon.tsx
|
|
277
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
278
|
-
function CheckIcon(props) {
|
|
279
|
-
return /* @__PURE__ */ jsx2("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "none", ...props, children: /* @__PURE__ */ jsx2(
|
|
280
|
-
"path",
|
|
281
|
-
{
|
|
282
|
-
fill: "currentColor",
|
|
283
|
-
d: "m11.726 5.048-4.73 5.156-1.722-1.879a.72.72 0 0 0-.529-.23.722.722 0 0 0-.525.24.858.858 0 0 0-.22.573.86.86 0 0 0 .211.576l2.255 2.458c.14.153.332.24.53.24.2 0 .391-.087.532-.24l5.261-5.735A.86.86 0 0 0 13 5.63a.858.858 0 0 0-.22-.572.722.722 0 0 0-.525-.24.72.72 0 0 0-.529.23Z"
|
|
284
|
-
}
|
|
285
|
-
) });
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
// src/components/icons/ChevronIcon.tsx
|
|
289
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
290
|
-
function ChevronIcon(props) {
|
|
291
|
-
return /* @__PURE__ */ jsx3("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "none", ...props, children: /* @__PURE__ */ jsx3(
|
|
292
|
-
"path",
|
|
293
|
-
{
|
|
294
|
-
stroke: "#A0B6C3",
|
|
295
|
-
strokeLinecap: "round",
|
|
296
|
-
strokeLinejoin: "round",
|
|
297
|
-
strokeWidth: 1.5,
|
|
298
|
-
d: "m4 6 4 4 4-4"
|
|
299
|
-
}
|
|
300
|
-
) });
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
// src/components/styling/StyleMarker.tsx
|
|
304
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
305
|
-
import { forwardRef } from "react";
|
|
306
|
-
|
|
307
|
-
// src/constants/styleDataAttribute.ts
|
|
308
|
-
var styleDataAttributeName = "data-dapp-kit";
|
|
309
|
-
var styleDataAttributeSelector = `[${styleDataAttributeName}]`;
|
|
310
|
-
var styleDataAttribute = { [styleDataAttributeName]: "" };
|
|
311
|
-
|
|
312
|
-
// src/components/styling/StyleMarker.tsx
|
|
313
|
-
var import_StyleMarker_css = __toESM(require_StyleMarker_css());
|
|
314
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
315
|
-
var StyleMarker = forwardRef(({ children }, forwardedRef) => /* @__PURE__ */ jsx4(Slot, { ref: forwardedRef, ...styleDataAttribute, children }));
|
|
316
|
-
StyleMarker.displayName = "StyleMarker";
|
|
317
|
-
|
|
318
|
-
// src/components/ui/Button.tsx
|
|
319
|
-
import { Slot as Slot2 } from "@radix-ui/react-slot";
|
|
320
|
-
import clsx from "clsx";
|
|
321
|
-
import { forwardRef as forwardRef2 } from "react";
|
|
322
|
-
|
|
323
|
-
// src/components/ui/Button.css.ts
|
|
324
|
-
import { createRuntimeFn as _7a468 } from "@vanilla-extract/recipes/createRuntimeFn";
|
|
325
|
-
var buttonVariants = _7a468({ defaultClassName: "Button_buttonVariants__x1s81q0", variantClassNames: { variant: { primary: "Button_buttonVariants_variant_primary__x1s81q1", outline: "Button_buttonVariants_variant_outline__x1s81q2" }, size: { md: "Button_buttonVariants_size_md__x1s81q3", lg: "Button_buttonVariants_size_lg__x1s81q4" } }, defaultVariants: { variant: "primary", size: "md" }, compoundVariants: [] });
|
|
326
|
-
|
|
327
|
-
// src/components/ui/Button.tsx
|
|
328
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
329
|
-
var Button = forwardRef2(
|
|
330
|
-
({ className, variant, size, asChild = false, ...props }, forwardedRef) => {
|
|
331
|
-
const Comp = asChild ? Slot2 : "button";
|
|
332
|
-
return /* @__PURE__ */ jsx5(
|
|
333
|
-
Comp,
|
|
334
|
-
{
|
|
335
|
-
...props,
|
|
336
|
-
className: clsx(buttonVariants({ variant, size }), className),
|
|
337
|
-
ref: forwardedRef
|
|
338
|
-
}
|
|
339
|
-
);
|
|
340
|
-
}
|
|
341
|
-
);
|
|
342
|
-
Button.displayName = "Button";
|
|
343
|
-
|
|
344
|
-
// src/components/ui/Text.tsx
|
|
345
|
-
import { Slot as Slot3 } from "@radix-ui/react-slot";
|
|
346
|
-
import clsx2 from "clsx";
|
|
347
|
-
import { forwardRef as forwardRef3 } from "react";
|
|
81
|
+
// src/hooks/wallet/useWalletStore.ts
|
|
82
|
+
import { useContext } from "react";
|
|
83
|
+
import { useStore } from "zustand";
|
|
348
84
|
|
|
349
|
-
// src/
|
|
350
|
-
import {
|
|
351
|
-
var
|
|
85
|
+
// src/contexts/walletContext.ts
|
|
86
|
+
import { createContext } from "react";
|
|
87
|
+
var WalletContext = createContext(null);
|
|
352
88
|
|
|
353
|
-
// src/
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
({
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
asChild = false,
|
|
360
|
-
as: Tag = "div",
|
|
361
|
-
size,
|
|
362
|
-
weight,
|
|
363
|
-
color,
|
|
364
|
-
mono,
|
|
365
|
-
...textProps
|
|
366
|
-
}, forwardedRef) => {
|
|
367
|
-
return /* @__PURE__ */ jsx6(
|
|
368
|
-
Slot3,
|
|
369
|
-
{
|
|
370
|
-
...textProps,
|
|
371
|
-
ref: forwardedRef,
|
|
372
|
-
className: clsx2(textVariants({ size, weight, color, mono }), className),
|
|
373
|
-
children: asChild ? children : /* @__PURE__ */ jsx6(Tag, { children })
|
|
374
|
-
}
|
|
89
|
+
// src/hooks/wallet/useWalletStore.ts
|
|
90
|
+
function useWalletStore(selector) {
|
|
91
|
+
const store = useContext(WalletContext);
|
|
92
|
+
if (!store) {
|
|
93
|
+
throw new Error(
|
|
94
|
+
"Could not find WalletContext. Ensure that you have set up the WalletProvider."
|
|
375
95
|
);
|
|
376
96
|
}
|
|
377
|
-
);
|
|
378
|
-
Text.displayName = "Text";
|
|
379
|
-
|
|
380
|
-
// src/components/AccountDropdownMenu.tsx
|
|
381
|
-
import { jsx as jsx7, jsxs } from "react/jsx-runtime";
|
|
382
|
-
function AccountDropdownMenu({ currentAccount }) {
|
|
383
|
-
const { mutate: disconnectWallet } = useDisconnectWallet();
|
|
384
|
-
const { mutate: switchAccount } = useSwitchAccount();
|
|
385
|
-
const { data: domain } = useResolveSuiNSName(
|
|
386
|
-
currentAccount.label ? null : currentAccount.address
|
|
387
|
-
);
|
|
388
|
-
const accounts = useAccounts();
|
|
389
|
-
return /* @__PURE__ */ jsxs(DropdownMenu.Root, { modal: false, children: [
|
|
390
|
-
/* @__PURE__ */ jsx7(StyleMarker, { children: /* @__PURE__ */ jsx7(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { size: "lg", className: connectedAccount, children: [
|
|
391
|
-
/* @__PURE__ */ jsx7(Text, { mono: true, weight: "bold", children: currentAccount.label ?? domain ?? formatAddress(currentAccount.address) }),
|
|
392
|
-
/* @__PURE__ */ jsx7(ChevronIcon, {})
|
|
393
|
-
] }) }) }),
|
|
394
|
-
/* @__PURE__ */ jsx7(DropdownMenu.Portal, { children: /* @__PURE__ */ jsx7(StyleMarker, { children: /* @__PURE__ */ jsxs(DropdownMenu.Content, { className: menuContent, children: [
|
|
395
|
-
accounts.map((account) => /* @__PURE__ */ jsxs(
|
|
396
|
-
DropdownMenu.Item,
|
|
397
|
-
{
|
|
398
|
-
className: clsx3(menuItem, switchAccountMenuItem),
|
|
399
|
-
onSelect: () => switchAccount({ account }),
|
|
400
|
-
children: [
|
|
401
|
-
/* @__PURE__ */ jsx7(Text, { mono: true, children: account.label ?? formatAddress(account.address) }),
|
|
402
|
-
currentAccount.address === account.address ? /* @__PURE__ */ jsx7(CheckIcon, {}) : null
|
|
403
|
-
]
|
|
404
|
-
},
|
|
405
|
-
account.address
|
|
406
|
-
)),
|
|
407
|
-
/* @__PURE__ */ jsx7(DropdownMenu.Separator, { className: separator }),
|
|
408
|
-
/* @__PURE__ */ jsx7(
|
|
409
|
-
DropdownMenu.Item,
|
|
410
|
-
{
|
|
411
|
-
className: clsx3(menuItem),
|
|
412
|
-
onSelect: () => disconnectWallet(),
|
|
413
|
-
children: "Disconnect"
|
|
414
|
-
}
|
|
415
|
-
)
|
|
416
|
-
] }) }) })
|
|
417
|
-
] });
|
|
97
|
+
return useStore(store, selector);
|
|
418
98
|
}
|
|
419
99
|
|
|
420
|
-
// src/components/connect-modal/ConnectModal.tsx
|
|
421
|
-
import * as Dialog from "@radix-ui/react-dialog";
|
|
422
|
-
import clsx7 from "clsx";
|
|
423
|
-
import { useState as useState2 } from "react";
|
|
424
|
-
|
|
425
100
|
// src/hooks/wallet/useConnectWallet.ts
|
|
426
|
-
import { useMutation as useMutation3 } from "@tanstack/react-query";
|
|
427
101
|
function useConnectWallet({
|
|
428
102
|
mutationKey,
|
|
429
103
|
...mutationOptions
|
|
430
104
|
} = {}) {
|
|
431
105
|
const setWalletConnected = useWalletStore((state) => state.setWalletConnected);
|
|
432
|
-
|
|
106
|
+
const setConnectionStatus = useWalletStore((state) => state.setConnectionStatus);
|
|
107
|
+
return useMutation({
|
|
433
108
|
mutationKey: walletMutationKeys.connectWallet(mutationKey),
|
|
434
|
-
mutationFn: async ({ wallet, accountAddress, ...
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
109
|
+
mutationFn: async ({ wallet, accountAddress, ...connectArgs }) => {
|
|
110
|
+
try {
|
|
111
|
+
setConnectionStatus("connecting");
|
|
112
|
+
const connectResult = await wallet.features["standard:connect"].connect(connectArgs);
|
|
113
|
+
const connectedSuiAccounts = connectResult.accounts.filter(
|
|
114
|
+
(account) => account.chains.some((chain) => chain.split(":")[0] === "sui")
|
|
115
|
+
);
|
|
116
|
+
const selectedAccount = getSelectedAccount(connectedSuiAccounts, accountAddress);
|
|
117
|
+
setWalletConnected(wallet, connectedSuiAccounts, selectedAccount);
|
|
118
|
+
return { accounts: connectedSuiAccounts };
|
|
119
|
+
} catch (error) {
|
|
120
|
+
setConnectionStatus("disconnected");
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
442
123
|
},
|
|
443
124
|
...mutationOptions
|
|
444
125
|
});
|
|
@@ -455,9 +136,9 @@ function getSelectedAccount(connectedAccounts, accountAddress) {
|
|
|
455
136
|
}
|
|
456
137
|
|
|
457
138
|
// src/components/icons/BackIcon.tsx
|
|
458
|
-
import { jsx
|
|
139
|
+
import { jsx } from "react/jsx-runtime";
|
|
459
140
|
function BackIcon(props) {
|
|
460
|
-
return /* @__PURE__ */
|
|
141
|
+
return /* @__PURE__ */ jsx("svg", { width: 24, height: 24, fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ jsx(
|
|
461
142
|
"path",
|
|
462
143
|
{
|
|
463
144
|
d: "M7.57 12.262c0 .341.13.629.403.895l5.175 5.059c.204.205.45.307.751.307.609 0 1.101-.485 1.101-1.087 0-.293-.123-.574-.349-.8L10.14 12.27l4.511-4.375A1.13 1.13 0 0 0 15 7.087C15 6.485 14.508 6 13.9 6c-.295 0-.54.103-.752.308l-5.175 5.058c-.28.28-.404.56-.404.896Z",
|
|
@@ -467,9 +148,9 @@ function BackIcon(props) {
|
|
|
467
148
|
}
|
|
468
149
|
|
|
469
150
|
// src/components/icons/CloseIcon.tsx
|
|
470
|
-
import { jsx as
|
|
151
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
471
152
|
function CloseIcon(props) {
|
|
472
|
-
return /* @__PURE__ */
|
|
153
|
+
return /* @__PURE__ */ jsx2("svg", { width: 10, height: 10, fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ jsx2(
|
|
473
154
|
"path",
|
|
474
155
|
{
|
|
475
156
|
d: "M9.708.292a.999.999 0 0 0-1.413 0l-3.289 3.29L1.717.291A.999.999 0 0 0 .305 1.705l3.289 3.289-3.29 3.289a.999.999 0 1 0 1.413 1.412l3.29-3.289 3.288 3.29a.999.999 0 0 0 1.413-1.413l-3.29-3.29 3.29-3.288a.999.999 0 0 0 0-1.413Z",
|
|
@@ -478,18 +159,33 @@ function CloseIcon(props) {
|
|
|
478
159
|
) });
|
|
479
160
|
}
|
|
480
161
|
|
|
162
|
+
// src/components/styling/StyleMarker.tsx
|
|
163
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
164
|
+
import { forwardRef } from "react";
|
|
165
|
+
|
|
166
|
+
// src/constants/styleDataAttribute.ts
|
|
167
|
+
var styleDataAttributeName = "data-dapp-kit";
|
|
168
|
+
var styleDataAttributeSelector = `[${styleDataAttributeName}]`;
|
|
169
|
+
var styleDataAttribute = { [styleDataAttributeName]: "" };
|
|
170
|
+
|
|
171
|
+
// src/components/styling/StyleMarker.tsx
|
|
172
|
+
var import_StyleMarker_css = __toESM(require_StyleMarker_css());
|
|
173
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
174
|
+
var StyleMarker = forwardRef(({ children }, forwardedRef) => /* @__PURE__ */ jsx3(Slot, { ref: forwardedRef, ...styleDataAttribute, children }));
|
|
175
|
+
StyleMarker.displayName = "StyleMarker";
|
|
176
|
+
|
|
481
177
|
// src/components/ui/Heading.tsx
|
|
482
|
-
import { Slot as
|
|
483
|
-
import
|
|
484
|
-
import { forwardRef as
|
|
178
|
+
import { Slot as Slot2 } from "@radix-ui/react-slot";
|
|
179
|
+
import clsx from "clsx";
|
|
180
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
485
181
|
|
|
486
182
|
// src/components/ui/Heading.css.ts
|
|
487
|
-
import { createRuntimeFn as
|
|
488
|
-
var headingVariants =
|
|
183
|
+
import { createRuntimeFn as _7a468 } from "@vanilla-extract/recipes/createRuntimeFn";
|
|
184
|
+
var headingVariants = _7a468({ defaultClassName: "Heading__1aa835k0", variantClassNames: { size: { sm: "Heading_headingVariants_size_sm__1aa835k1", md: "Heading_headingVariants_size_md__1aa835k2", lg: "Heading_headingVariants_size_lg__1aa835k3", xl: "Heading_headingVariants_size_xl__1aa835k4" }, weight: { normal: "Heading_headingVariants_weight_normal__1aa835k5", bold: "Heading_headingVariants_weight_bold__1aa835k6" }, truncate: { true: "Heading_headingVariants_truncate_true__1aa835k7" } }, defaultVariants: { size: "lg", weight: "bold" }, compoundVariants: [] });
|
|
489
185
|
|
|
490
186
|
// src/components/ui/Heading.tsx
|
|
491
|
-
import { jsx as
|
|
492
|
-
var Heading =
|
|
187
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
188
|
+
var Heading = forwardRef2(
|
|
493
189
|
({
|
|
494
190
|
children,
|
|
495
191
|
className,
|
|
@@ -500,13 +196,13 @@ var Heading = forwardRef4(
|
|
|
500
196
|
truncate,
|
|
501
197
|
...headingProps
|
|
502
198
|
}, forwardedRef) => {
|
|
503
|
-
return /* @__PURE__ */
|
|
504
|
-
|
|
199
|
+
return /* @__PURE__ */ jsx4(
|
|
200
|
+
Slot2,
|
|
505
201
|
{
|
|
506
202
|
...headingProps,
|
|
507
203
|
ref: forwardedRef,
|
|
508
|
-
className:
|
|
509
|
-
children: asChild ? children : /* @__PURE__ */
|
|
204
|
+
className: clsx(headingVariants({ size, weight, truncate }), className),
|
|
205
|
+
children: asChild ? children : /* @__PURE__ */ jsx4(Tag, { children })
|
|
510
206
|
}
|
|
511
207
|
);
|
|
512
208
|
}
|
|
@@ -514,19 +210,19 @@ var Heading = forwardRef4(
|
|
|
514
210
|
Heading.displayName = "Heading";
|
|
515
211
|
|
|
516
212
|
// src/components/ui/IconButton.tsx
|
|
517
|
-
import { Slot as
|
|
518
|
-
import
|
|
519
|
-
import { forwardRef as
|
|
213
|
+
import { Slot as Slot3 } from "@radix-ui/react-slot";
|
|
214
|
+
import clsx2 from "clsx";
|
|
215
|
+
import { forwardRef as forwardRef3 } from "react";
|
|
520
216
|
|
|
521
217
|
// src/components/ui/IconButton.css.ts
|
|
522
218
|
var container = "IconButton_container__s6n7bq0";
|
|
523
219
|
|
|
524
220
|
// src/components/ui/IconButton.tsx
|
|
525
|
-
import { jsx as
|
|
526
|
-
var IconButton =
|
|
221
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
222
|
+
var IconButton = forwardRef3(
|
|
527
223
|
({ className, asChild = false, ...props }, forwardedRef) => {
|
|
528
|
-
const Comp = asChild ?
|
|
529
|
-
return /* @__PURE__ */
|
|
224
|
+
const Comp = asChild ? Slot3 : "button";
|
|
225
|
+
return /* @__PURE__ */ jsx5(Comp, { ...props, className: clsx2(container, className), ref: forwardedRef });
|
|
530
226
|
}
|
|
531
227
|
);
|
|
532
228
|
IconButton.displayName = "Button";
|
|
@@ -544,6 +240,68 @@ var walletListContainerWithViewSelected = "ConnectModal_walletListContainerWithV
|
|
|
544
240
|
var walletListContent = "ConnectModal_walletListContent__gz8z98";
|
|
545
241
|
var whatIsAWalletButton = "ConnectModal_whatIsAWalletButton__gz8z93";
|
|
546
242
|
|
|
243
|
+
// src/components/ui/Button.tsx
|
|
244
|
+
import { Slot as Slot4 } from "@radix-ui/react-slot";
|
|
245
|
+
import clsx3 from "clsx";
|
|
246
|
+
import { forwardRef as forwardRef4 } from "react";
|
|
247
|
+
|
|
248
|
+
// src/components/ui/Button.css.ts
|
|
249
|
+
import { createRuntimeFn as _7a4682 } from "@vanilla-extract/recipes/createRuntimeFn";
|
|
250
|
+
var buttonVariants = _7a4682({ defaultClassName: "Button_buttonVariants__x1s81q0", variantClassNames: { variant: { primary: "Button_buttonVariants_variant_primary__x1s81q1", outline: "Button_buttonVariants_variant_outline__x1s81q2" }, size: { md: "Button_buttonVariants_size_md__x1s81q3", lg: "Button_buttonVariants_size_lg__x1s81q4" } }, defaultVariants: { variant: "primary", size: "md" }, compoundVariants: [] });
|
|
251
|
+
|
|
252
|
+
// src/components/ui/Button.tsx
|
|
253
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
254
|
+
var Button = forwardRef4(
|
|
255
|
+
({ className, variant, size, asChild = false, ...props }, forwardedRef) => {
|
|
256
|
+
const Comp = asChild ? Slot4 : "button";
|
|
257
|
+
return /* @__PURE__ */ jsx6(
|
|
258
|
+
Comp,
|
|
259
|
+
{
|
|
260
|
+
...props,
|
|
261
|
+
className: clsx3(buttonVariants({ variant, size }), className),
|
|
262
|
+
ref: forwardedRef
|
|
263
|
+
}
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
);
|
|
267
|
+
Button.displayName = "Button";
|
|
268
|
+
|
|
269
|
+
// src/components/ui/Text.tsx
|
|
270
|
+
import { Slot as Slot5 } from "@radix-ui/react-slot";
|
|
271
|
+
import clsx4 from "clsx";
|
|
272
|
+
import { forwardRef as forwardRef5 } from "react";
|
|
273
|
+
|
|
274
|
+
// src/components/ui/Text.css.ts
|
|
275
|
+
import { createRuntimeFn as _7a4683 } from "@vanilla-extract/recipes/createRuntimeFn";
|
|
276
|
+
var textVariants = _7a4683({ defaultClassName: "Text__2bv1ur0", variantClassNames: { size: { sm: "Text_textVariants_size_sm__2bv1ur1" }, weight: { normal: "Text_textVariants_weight_normal__2bv1ur2", medium: "Text_textVariants_weight_medium__2bv1ur3", bold: "Text_textVariants_weight_bold__2bv1ur4" }, color: { muted: "Text_textVariants_color_muted__2bv1ur5", danger: "Text_textVariants_color_danger__2bv1ur6" }, mono: { true: "Text_textVariants_mono_true__2bv1ur7" } }, defaultVariants: { size: "sm", weight: "normal" }, compoundVariants: [] });
|
|
277
|
+
|
|
278
|
+
// src/components/ui/Text.tsx
|
|
279
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
280
|
+
var Text = forwardRef5(
|
|
281
|
+
({
|
|
282
|
+
children,
|
|
283
|
+
className,
|
|
284
|
+
asChild = false,
|
|
285
|
+
as: Tag = "div",
|
|
286
|
+
size,
|
|
287
|
+
weight,
|
|
288
|
+
color,
|
|
289
|
+
mono,
|
|
290
|
+
...textProps
|
|
291
|
+
}, forwardedRef) => {
|
|
292
|
+
return /* @__PURE__ */ jsx7(
|
|
293
|
+
Slot5,
|
|
294
|
+
{
|
|
295
|
+
...textProps,
|
|
296
|
+
ref: forwardedRef,
|
|
297
|
+
className: clsx4(textVariants({ size, weight, color, mono }), className),
|
|
298
|
+
children: asChild ? children : /* @__PURE__ */ jsx7(Tag, { children })
|
|
299
|
+
}
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
);
|
|
303
|
+
Text.displayName = "Text";
|
|
304
|
+
|
|
547
305
|
// src/components/connect-modal/views/ConnectionStatus.css.ts
|
|
548
306
|
var connectionStatus = "ConnectionStatus_connectionStatus__nckm2d3";
|
|
549
307
|
var container2 = "ConnectionStatus_container__nckm2d0";
|
|
@@ -552,14 +310,14 @@ var title2 = "ConnectionStatus_title__nckm2d2";
|
|
|
552
310
|
var walletIcon = "ConnectionStatus_walletIcon__nckm2d1";
|
|
553
311
|
|
|
554
312
|
// src/components/connect-modal/views/ConnectionStatus.tsx
|
|
555
|
-
import { jsx as
|
|
313
|
+
import { jsx as jsx8, jsxs } from "react/jsx-runtime";
|
|
556
314
|
function ConnectionStatus({
|
|
557
315
|
selectedWallet,
|
|
558
316
|
hadConnectionError,
|
|
559
317
|
onRetryConnection
|
|
560
318
|
}) {
|
|
561
|
-
return /* @__PURE__ */
|
|
562
|
-
/* @__PURE__ */
|
|
319
|
+
return /* @__PURE__ */ jsxs("div", { className: container2, children: [
|
|
320
|
+
/* @__PURE__ */ jsx8(
|
|
563
321
|
"img",
|
|
564
322
|
{
|
|
565
323
|
className: walletIcon,
|
|
@@ -567,12 +325,12 @@ function ConnectionStatus({
|
|
|
567
325
|
alt: `${selectedWallet.name} logo`
|
|
568
326
|
}
|
|
569
327
|
),
|
|
570
|
-
/* @__PURE__ */
|
|
328
|
+
/* @__PURE__ */ jsx8("div", { className: title2, children: /* @__PURE__ */ jsxs(Heading, { as: "h2", size: "xl", children: [
|
|
571
329
|
"Opening ",
|
|
572
330
|
selectedWallet.name
|
|
573
331
|
] }) }),
|
|
574
|
-
/* @__PURE__ */
|
|
575
|
-
hadConnectionError ? /* @__PURE__ */
|
|
332
|
+
/* @__PURE__ */ jsx8("div", { className: connectionStatus, children: hadConnectionError ? /* @__PURE__ */ jsx8(Text, { color: "danger", children: "Connection failed" }) : /* @__PURE__ */ jsx8(Text, { color: "muted", children: "Confirm connection in the wallet..." }) }),
|
|
333
|
+
hadConnectionError ? /* @__PURE__ */ jsx8("div", { className: retryButtonContainer, children: /* @__PURE__ */ jsx8(Button, { type: "button", variant: "outline", onClick: () => onRetryConnection(selectedWallet), children: "Retry Connection" }) }) : null
|
|
576
334
|
] });
|
|
577
335
|
}
|
|
578
336
|
|
|
@@ -580,11 +338,11 @@ function ConnectionStatus({
|
|
|
580
338
|
var container3 = "InfoSection_container__1wtioi70";
|
|
581
339
|
|
|
582
340
|
// src/components/connect-modal/InfoSection.tsx
|
|
583
|
-
import { jsx as
|
|
341
|
+
import { jsx as jsx9, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
584
342
|
function InfoSection({ title: title3, children }) {
|
|
585
|
-
return /* @__PURE__ */
|
|
586
|
-
/* @__PURE__ */
|
|
587
|
-
/* @__PURE__ */
|
|
343
|
+
return /* @__PURE__ */ jsxs2("section", { className: container3, children: [
|
|
344
|
+
/* @__PURE__ */ jsx9(Heading, { as: "h3", size: "sm", weight: "normal", children: title3 }),
|
|
345
|
+
/* @__PURE__ */ jsx9(Text, { weight: "medium", color: "muted", children })
|
|
588
346
|
] });
|
|
589
347
|
}
|
|
590
348
|
|
|
@@ -594,15 +352,15 @@ var content2 = "GettingStarted_content__1fp07e11";
|
|
|
594
352
|
var installButtonContainer = "GettingStarted_installButtonContainer__1fp07e12";
|
|
595
353
|
|
|
596
354
|
// src/components/connect-modal/views/GettingStarted.tsx
|
|
597
|
-
import { jsx as
|
|
355
|
+
import { jsx as jsx10, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
598
356
|
function GettingStarted() {
|
|
599
|
-
return /* @__PURE__ */
|
|
600
|
-
/* @__PURE__ */
|
|
601
|
-
/* @__PURE__ */
|
|
602
|
-
/* @__PURE__ */
|
|
603
|
-
/* @__PURE__ */
|
|
604
|
-
/* @__PURE__ */
|
|
605
|
-
/* @__PURE__ */
|
|
357
|
+
return /* @__PURE__ */ jsxs3("div", { className: container4, children: [
|
|
358
|
+
/* @__PURE__ */ jsx10(Heading, { as: "h2", children: "Get Started with Sui" }),
|
|
359
|
+
/* @__PURE__ */ jsxs3("div", { className: content2, children: [
|
|
360
|
+
/* @__PURE__ */ jsx10(InfoSection, { title: "Install the Sui Wallet Extension", children: "We recommend pinning Sui Wallet to your taskbar for quicker access." }),
|
|
361
|
+
/* @__PURE__ */ jsx10(InfoSection, { title: "Create or Import a Wallet", children: "Be sure to back up your wallet using a secure method. Never share your secret phrase with anyone." }),
|
|
362
|
+
/* @__PURE__ */ jsx10(InfoSection, { title: "Refresh Your Browser", children: "Once you set up your wallet, refresh this window browser to load up the extension." }),
|
|
363
|
+
/* @__PURE__ */ jsx10("div", { className: installButtonContainer, children: /* @__PURE__ */ jsx10(Button, { variant: "outline", asChild: true, children: /* @__PURE__ */ jsx10(
|
|
606
364
|
"a",
|
|
607
365
|
{
|
|
608
366
|
href: "https://chrome.google.com/webstore/detail/sui-wallet/opcgpfmipidbgpenhmajoajpbobppdil",
|
|
@@ -620,13 +378,13 @@ var container5 = "WhatIsAWallet_container__1ktpkq90";
|
|
|
620
378
|
var content3 = "WhatIsAWallet_content__1ktpkq91";
|
|
621
379
|
|
|
622
380
|
// src/components/connect-modal/views/WhatIsAWallet.tsx
|
|
623
|
-
import { jsx as
|
|
381
|
+
import { jsx as jsx11, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
624
382
|
function WhatIsAWallet() {
|
|
625
|
-
return /* @__PURE__ */
|
|
626
|
-
/* @__PURE__ */
|
|
627
|
-
/* @__PURE__ */
|
|
628
|
-
/* @__PURE__ */
|
|
629
|
-
/* @__PURE__ */
|
|
383
|
+
return /* @__PURE__ */ jsxs4("div", { className: container5, children: [
|
|
384
|
+
/* @__PURE__ */ jsx11(Heading, { as: "h2", children: "What is a Wallet" }),
|
|
385
|
+
/* @__PURE__ */ jsxs4("div", { className: content3, children: [
|
|
386
|
+
/* @__PURE__ */ jsx11(InfoSection, { title: "Easy Login", children: "No need to create new accounts and passwords for every website. Just connect your wallet and get going." }),
|
|
387
|
+
/* @__PURE__ */ jsx11(InfoSection, { title: "Store your Digital Assets", children: "Send, receive, store, and display your digital assets like NFTs & coins." })
|
|
630
388
|
] })
|
|
631
389
|
] });
|
|
632
390
|
}
|
|
@@ -637,11 +395,11 @@ function useWallets() {
|
|
|
637
395
|
}
|
|
638
396
|
|
|
639
397
|
// src/components/icons/SuiIcon.tsx
|
|
640
|
-
import { jsx as
|
|
398
|
+
import { jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
641
399
|
function SuiIcon(props) {
|
|
642
|
-
return /* @__PURE__ */
|
|
643
|
-
/* @__PURE__ */
|
|
644
|
-
/* @__PURE__ */
|
|
400
|
+
return /* @__PURE__ */ jsxs5("svg", { width: 28, height: 28, fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [
|
|
401
|
+
/* @__PURE__ */ jsx12("rect", { width: 28, height: 28, rx: 6, fill: "#6FBCF0" }),
|
|
402
|
+
/* @__PURE__ */ jsx12(
|
|
645
403
|
"path",
|
|
646
404
|
{
|
|
647
405
|
fillRule: "evenodd",
|
|
@@ -657,7 +415,7 @@ function SuiIcon(props) {
|
|
|
657
415
|
var container6 = "WalletList_container__1v2s6cz0";
|
|
658
416
|
|
|
659
417
|
// src/components/connect-modal/wallet-list/WalletListItem.tsx
|
|
660
|
-
import { clsx as
|
|
418
|
+
import { clsx as clsx5 } from "clsx";
|
|
661
419
|
|
|
662
420
|
// src/components/connect-modal/wallet-list/WalletListItem.css.ts
|
|
663
421
|
var container7 = "WalletListItem_container__1dqqtqs0";
|
|
@@ -666,27 +424,27 @@ var walletIcon2 = "WalletListItem_walletIcon__1dqqtqs3";
|
|
|
666
424
|
var walletItem = "WalletListItem_walletItem__1dqqtqs1";
|
|
667
425
|
|
|
668
426
|
// src/components/connect-modal/wallet-list/WalletListItem.tsx
|
|
669
|
-
import { jsx as
|
|
427
|
+
import { jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
670
428
|
function WalletListItem({ name, icon, onClick, isSelected = false }) {
|
|
671
|
-
return /* @__PURE__ */
|
|
429
|
+
return /* @__PURE__ */ jsx13("li", { className: container7, children: /* @__PURE__ */ jsxs6(
|
|
672
430
|
"button",
|
|
673
431
|
{
|
|
674
|
-
className:
|
|
432
|
+
className: clsx5(walletItem, { [selectedWalletItem]: isSelected }),
|
|
675
433
|
type: "button",
|
|
676
434
|
onClick,
|
|
677
435
|
children: [
|
|
678
|
-
typeof icon === "string" ? /* @__PURE__ */
|
|
679
|
-
/* @__PURE__ */
|
|
436
|
+
typeof icon === "string" ? /* @__PURE__ */ jsx13("img", { className: walletIcon2, src: icon, alt: `${name} logo` }) : icon,
|
|
437
|
+
/* @__PURE__ */ jsx13(Heading, { size: "md", truncate: true, asChild: true, children: /* @__PURE__ */ jsx13("div", { children: name }) })
|
|
680
438
|
]
|
|
681
439
|
}
|
|
682
440
|
) });
|
|
683
441
|
}
|
|
684
442
|
|
|
685
443
|
// src/components/connect-modal/wallet-list/WalletList.tsx
|
|
686
|
-
import { jsx as
|
|
444
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
687
445
|
function WalletList({ selectedWalletName, onPlaceholderClick, onSelect }) {
|
|
688
446
|
const wallets = useWallets();
|
|
689
|
-
return /* @__PURE__ */
|
|
447
|
+
return /* @__PURE__ */ jsx14("ul", { className: container6, children: wallets.length > 0 ? wallets.map((wallet) => /* @__PURE__ */ jsx14(
|
|
690
448
|
WalletListItem,
|
|
691
449
|
{
|
|
692
450
|
name: wallet.name,
|
|
@@ -695,11 +453,11 @@ function WalletList({ selectedWalletName, onPlaceholderClick, onSelect }) {
|
|
|
695
453
|
onClick: () => onSelect(wallet)
|
|
696
454
|
},
|
|
697
455
|
wallet.name
|
|
698
|
-
)) : /* @__PURE__ */
|
|
456
|
+
)) : /* @__PURE__ */ jsx14(
|
|
699
457
|
WalletListItem,
|
|
700
458
|
{
|
|
701
459
|
name: "Sui Wallet",
|
|
702
|
-
icon: /* @__PURE__ */
|
|
460
|
+
icon: /* @__PURE__ */ jsx14(SuiIcon, {}),
|
|
703
461
|
onClick: onPlaceholderClick,
|
|
704
462
|
isSelected: true
|
|
705
463
|
}
|
|
@@ -707,11 +465,11 @@ function WalletList({ selectedWalletName, onPlaceholderClick, onSelect }) {
|
|
|
707
465
|
}
|
|
708
466
|
|
|
709
467
|
// src/components/connect-modal/ConnectModal.tsx
|
|
710
|
-
import { jsx as
|
|
468
|
+
import { jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
711
469
|
function ConnectModal({ trigger, open, defaultOpen, onOpenChange }) {
|
|
712
|
-
const [isModalOpen, setModalOpen] =
|
|
713
|
-
const [currentView, setCurrentView] =
|
|
714
|
-
const [selectedWallet, setSelectedWallet] =
|
|
470
|
+
const [isModalOpen, setModalOpen] = useState(open ?? defaultOpen);
|
|
471
|
+
const [currentView, setCurrentView] = useState();
|
|
472
|
+
const [selectedWallet, setSelectedWallet] = useState();
|
|
715
473
|
const { mutate, isError } = useConnectWallet();
|
|
716
474
|
const resetSelection = () => {
|
|
717
475
|
setSelectedWallet(void 0);
|
|
@@ -736,13 +494,13 @@ function ConnectModal({ trigger, open, defaultOpen, onOpenChange }) {
|
|
|
736
494
|
let modalContent;
|
|
737
495
|
switch (currentView) {
|
|
738
496
|
case "what-is-a-wallet":
|
|
739
|
-
modalContent = /* @__PURE__ */
|
|
497
|
+
modalContent = /* @__PURE__ */ jsx15(WhatIsAWallet, {});
|
|
740
498
|
break;
|
|
741
499
|
case "getting-started":
|
|
742
|
-
modalContent = /* @__PURE__ */
|
|
500
|
+
modalContent = /* @__PURE__ */ jsx15(GettingStarted, {});
|
|
743
501
|
break;
|
|
744
502
|
case "connection-status":
|
|
745
|
-
modalContent = /* @__PURE__ */
|
|
503
|
+
modalContent = /* @__PURE__ */ jsx15(
|
|
746
504
|
ConnectionStatus,
|
|
747
505
|
{
|
|
748
506
|
selectedWallet,
|
|
@@ -752,62 +510,358 @@ function ConnectModal({ trigger, open, defaultOpen, onOpenChange }) {
|
|
|
752
510
|
);
|
|
753
511
|
break;
|
|
754
512
|
default:
|
|
755
|
-
modalContent = /* @__PURE__ */
|
|
513
|
+
modalContent = /* @__PURE__ */ jsx15(WhatIsAWallet, {});
|
|
756
514
|
}
|
|
757
|
-
return /* @__PURE__ */
|
|
758
|
-
/* @__PURE__ */
|
|
759
|
-
/* @__PURE__ */
|
|
760
|
-
/* @__PURE__ */
|
|
515
|
+
return /* @__PURE__ */ jsxs7(Dialog.Root, { open: open ?? isModalOpen, onOpenChange: handleOpenChange, children: [
|
|
516
|
+
/* @__PURE__ */ jsx15(StyleMarker, { children: /* @__PURE__ */ jsx15(Dialog.Trigger, { asChild: true, children: trigger }) }),
|
|
517
|
+
/* @__PURE__ */ jsx15(Dialog.Portal, { children: /* @__PURE__ */ jsx15(StyleMarker, { children: /* @__PURE__ */ jsx15(Dialog.Overlay, { className: overlay, children: /* @__PURE__ */ jsxs7(Dialog.Content, { className: content, "aria-describedby": void 0, children: [
|
|
518
|
+
/* @__PURE__ */ jsxs7(
|
|
519
|
+
"div",
|
|
520
|
+
{
|
|
521
|
+
className: clsx6(walletListContainer, {
|
|
522
|
+
[walletListContainerWithViewSelected]: !!currentView
|
|
523
|
+
}),
|
|
524
|
+
children: [
|
|
525
|
+
/* @__PURE__ */ jsxs7("div", { className: walletListContent, children: [
|
|
526
|
+
/* @__PURE__ */ jsx15(Dialog.Title, { className: title, asChild: true, children: /* @__PURE__ */ jsx15(Heading, { as: "h2", children: "Connect a Wallet" }) }),
|
|
527
|
+
/* @__PURE__ */ jsx15(
|
|
528
|
+
WalletList,
|
|
529
|
+
{
|
|
530
|
+
selectedWalletName: selectedWallet?.name,
|
|
531
|
+
onPlaceholderClick: () => setCurrentView("getting-started"),
|
|
532
|
+
onSelect: (wallet) => {
|
|
533
|
+
if (selectedWallet?.name !== wallet.name) {
|
|
534
|
+
setSelectedWallet(wallet);
|
|
535
|
+
connectWallet(wallet);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
)
|
|
540
|
+
] }),
|
|
541
|
+
/* @__PURE__ */ jsx15(
|
|
542
|
+
"button",
|
|
543
|
+
{
|
|
544
|
+
className: whatIsAWalletButton,
|
|
545
|
+
onClick: () => setCurrentView("what-is-a-wallet"),
|
|
546
|
+
type: "button",
|
|
547
|
+
children: "What is a Wallet?"
|
|
548
|
+
}
|
|
549
|
+
)
|
|
550
|
+
]
|
|
551
|
+
}
|
|
552
|
+
),
|
|
553
|
+
/* @__PURE__ */ jsxs7(
|
|
761
554
|
"div",
|
|
762
555
|
{
|
|
763
|
-
className:
|
|
764
|
-
[
|
|
765
|
-
}),
|
|
766
|
-
children: [
|
|
767
|
-
/* @__PURE__ */
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
556
|
+
className: clsx6(viewContainer, {
|
|
557
|
+
[selectedViewContainer]: !!currentView
|
|
558
|
+
}),
|
|
559
|
+
children: [
|
|
560
|
+
/* @__PURE__ */ jsx15("div", { className: backButtonContainer, children: /* @__PURE__ */ jsx15(IconButton, { type: "button", "aria-label": "Back", onClick: () => resetSelection(), children: /* @__PURE__ */ jsx15(BackIcon, {}) }) }),
|
|
561
|
+
modalContent
|
|
562
|
+
]
|
|
563
|
+
}
|
|
564
|
+
),
|
|
565
|
+
/* @__PURE__ */ jsx15(Dialog.Close, { className: closeButtonContainer, asChild: true, children: /* @__PURE__ */ jsx15(IconButton, { type: "button", "aria-label": "Close", children: /* @__PURE__ */ jsx15(CloseIcon, {}) }) })
|
|
566
|
+
] }) }) }) })
|
|
567
|
+
] });
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
// src/hooks/wallet/useCurrentAccount.ts
|
|
571
|
+
function useCurrentAccount() {
|
|
572
|
+
return useWalletStore((state) => state.currentAccount);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// src/components/AccountDropdownMenu.tsx
|
|
576
|
+
import { formatAddress } from "@mysten/sui.js/utils";
|
|
577
|
+
import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
|
|
578
|
+
import clsx7 from "clsx";
|
|
579
|
+
|
|
580
|
+
// src/hooks/useSuiClientQuery.ts
|
|
581
|
+
import { useQuery } from "@tanstack/react-query";
|
|
582
|
+
|
|
583
|
+
// src/hooks/useSuiClient.ts
|
|
584
|
+
import { useContext as useContext2 } from "react";
|
|
585
|
+
|
|
586
|
+
// src/components/SuiClientProvider.tsx
|
|
587
|
+
import { getFullnodeUrl, isSuiClient, SuiClient } from "@mysten/sui.js/client";
|
|
588
|
+
import { createContext as createContext2, useMemo, useState as useState2 } from "react";
|
|
589
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
590
|
+
var SuiClientContext = createContext2(null);
|
|
591
|
+
var DEFAULT_NETWORKS = {
|
|
592
|
+
localnet: { url: getFullnodeUrl("localnet") }
|
|
593
|
+
};
|
|
594
|
+
var DEFAULT_CREATE_CLIENT = function createClient(_name, config) {
|
|
595
|
+
if (isSuiClient(config)) {
|
|
596
|
+
return config;
|
|
597
|
+
}
|
|
598
|
+
return new SuiClient(config);
|
|
599
|
+
};
|
|
600
|
+
function SuiClientProvider(props) {
|
|
601
|
+
const { onNetworkChange, network, children } = props;
|
|
602
|
+
const networks = props.networks ?? DEFAULT_NETWORKS;
|
|
603
|
+
const createClient2 = props.createClient ?? DEFAULT_CREATE_CLIENT;
|
|
604
|
+
const [selectedNetwork, setSelectedNetwork] = useState2(
|
|
605
|
+
props.network ?? props.defaultNetwork ?? Object.keys(networks)[0]
|
|
606
|
+
);
|
|
607
|
+
const currentNetwork = props.network ?? selectedNetwork;
|
|
608
|
+
const client = useMemo(() => {
|
|
609
|
+
return createClient2(currentNetwork, networks[currentNetwork]);
|
|
610
|
+
}, [createClient2, currentNetwork, networks]);
|
|
611
|
+
const ctx = useMemo(() => {
|
|
612
|
+
return {
|
|
613
|
+
client,
|
|
614
|
+
networks,
|
|
615
|
+
network: currentNetwork,
|
|
616
|
+
config: networks[currentNetwork] instanceof SuiClient ? null : networks[currentNetwork],
|
|
617
|
+
selectNetwork: (newNetwork) => {
|
|
618
|
+
if (currentNetwork === newNetwork) {
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
if (!network && newNetwork !== selectedNetwork) {
|
|
622
|
+
setSelectedNetwork(newNetwork);
|
|
623
|
+
}
|
|
624
|
+
onNetworkChange?.(newNetwork);
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
}, [client, networks, selectedNetwork, currentNetwork, network, onNetworkChange]);
|
|
628
|
+
return /* @__PURE__ */ jsx16(SuiClientContext.Provider, { value: ctx, children });
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
// src/hooks/useSuiClient.ts
|
|
632
|
+
function useSuiClientContext() {
|
|
633
|
+
const suiClient = useContext2(SuiClientContext);
|
|
634
|
+
if (!suiClient) {
|
|
635
|
+
throw new Error(
|
|
636
|
+
"Could not find SuiClientContext. Ensure that you have set up the SuiClientProvider"
|
|
637
|
+
);
|
|
638
|
+
}
|
|
639
|
+
return suiClient;
|
|
640
|
+
}
|
|
641
|
+
function useSuiClient() {
|
|
642
|
+
return useSuiClientContext().client;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
// src/hooks/useSuiClientQuery.ts
|
|
646
|
+
function useSuiClientQuery(...args) {
|
|
647
|
+
const [method, params, { queryKey = [], ...options } = {}] = args;
|
|
648
|
+
const suiContext = useSuiClientContext();
|
|
649
|
+
return useQuery({
|
|
650
|
+
...options,
|
|
651
|
+
queryKey: [suiContext.network, method, params, ...queryKey],
|
|
652
|
+
queryFn: async () => {
|
|
653
|
+
return await suiContext.client[method](params);
|
|
654
|
+
}
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
// src/hooks/useResolveSuiNSNames.ts
|
|
659
|
+
function useResolveSuiNSName(address, options) {
|
|
660
|
+
return useSuiClientQuery(
|
|
661
|
+
"resolveNameServiceNames",
|
|
662
|
+
{
|
|
663
|
+
address,
|
|
664
|
+
limit: 1
|
|
665
|
+
},
|
|
666
|
+
{
|
|
667
|
+
...options,
|
|
668
|
+
refetchOnWindowFocus: false,
|
|
669
|
+
retry: false,
|
|
670
|
+
select: (data) => data.data.length > 0 ? data.data[0] : null,
|
|
671
|
+
enabled: !!address && options?.enabled !== false
|
|
672
|
+
}
|
|
673
|
+
);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
// src/hooks/wallet/useAccounts.ts
|
|
677
|
+
function useAccounts() {
|
|
678
|
+
return useWalletStore((state) => state.accounts);
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
// src/hooks/wallet/useDisconnectWallet.ts
|
|
682
|
+
import { useMutation as useMutation2 } from "@tanstack/react-query";
|
|
683
|
+
|
|
684
|
+
// src/errors/walletErrors.ts
|
|
685
|
+
var WalletNotConnectedError = class extends Error {
|
|
686
|
+
};
|
|
687
|
+
var WalletNoAccountSelectedError = class extends Error {
|
|
688
|
+
};
|
|
689
|
+
var WalletFeatureNotSupportedError = class extends Error {
|
|
690
|
+
};
|
|
691
|
+
var WalletAccountNotFoundError = class extends Error {
|
|
692
|
+
};
|
|
693
|
+
|
|
694
|
+
// src/hooks/wallet/useCurrentWallet.ts
|
|
695
|
+
function useCurrentWallet() {
|
|
696
|
+
const currentWallet = useWalletStore((state) => state.currentWallet);
|
|
697
|
+
const connectionStatus2 = useWalletStore((state) => state.connectionStatus);
|
|
698
|
+
switch (connectionStatus2) {
|
|
699
|
+
case "connecting":
|
|
700
|
+
return {
|
|
701
|
+
connectionStatus: connectionStatus2,
|
|
702
|
+
currentWallet: null,
|
|
703
|
+
isDisconnected: false,
|
|
704
|
+
isConnecting: true,
|
|
705
|
+
isConnected: false
|
|
706
|
+
};
|
|
707
|
+
case "disconnected":
|
|
708
|
+
return {
|
|
709
|
+
connectionStatus: connectionStatus2,
|
|
710
|
+
currentWallet: null,
|
|
711
|
+
isDisconnected: true,
|
|
712
|
+
isConnecting: false,
|
|
713
|
+
isConnected: false
|
|
714
|
+
};
|
|
715
|
+
case "connected": {
|
|
716
|
+
return {
|
|
717
|
+
connectionStatus: connectionStatus2,
|
|
718
|
+
currentWallet,
|
|
719
|
+
isDisconnected: false,
|
|
720
|
+
isConnecting: false,
|
|
721
|
+
isConnected: true
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
// src/hooks/wallet/useDisconnectWallet.ts
|
|
728
|
+
function useDisconnectWallet({
|
|
729
|
+
mutationKey,
|
|
730
|
+
...mutationOptions
|
|
731
|
+
} = {}) {
|
|
732
|
+
const { currentWallet } = useCurrentWallet();
|
|
733
|
+
const setWalletDisconnected = useWalletStore((state) => state.setWalletDisconnected);
|
|
734
|
+
return useMutation2({
|
|
735
|
+
mutationKey: walletMutationKeys.disconnectWallet(mutationKey),
|
|
736
|
+
mutationFn: async () => {
|
|
737
|
+
if (!currentWallet) {
|
|
738
|
+
throw new WalletNotConnectedError("No wallet is connected.");
|
|
739
|
+
}
|
|
740
|
+
try {
|
|
741
|
+
await currentWallet.features["standard:disconnect"]?.disconnect();
|
|
742
|
+
} catch (error) {
|
|
743
|
+
console.error("Failed to disconnect the application from the current wallet.", error);
|
|
744
|
+
}
|
|
745
|
+
setWalletDisconnected();
|
|
746
|
+
},
|
|
747
|
+
...mutationOptions
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
// src/hooks/wallet/useSwitchAccount.ts
|
|
752
|
+
import { useMutation as useMutation3 } from "@tanstack/react-query";
|
|
753
|
+
function useSwitchAccount({
|
|
754
|
+
mutationKey,
|
|
755
|
+
...mutationOptions
|
|
756
|
+
} = {}) {
|
|
757
|
+
const { currentWallet } = useCurrentWallet();
|
|
758
|
+
const setAccountSwitched = useWalletStore((state) => state.setAccountSwitched);
|
|
759
|
+
return useMutation3({
|
|
760
|
+
mutationKey: walletMutationKeys.switchAccount(mutationKey),
|
|
761
|
+
mutationFn: async ({ account }) => {
|
|
762
|
+
if (!currentWallet) {
|
|
763
|
+
throw new WalletNotConnectedError("No wallet is connected.");
|
|
764
|
+
}
|
|
765
|
+
const accountToSelect = currentWallet.accounts.find(
|
|
766
|
+
(walletAccount) => walletAccount.address === account.address
|
|
767
|
+
);
|
|
768
|
+
if (!accountToSelect) {
|
|
769
|
+
throw new WalletAccountNotFoundError(
|
|
770
|
+
`No account with address ${account.address} is connected to ${currentWallet.name}.`
|
|
771
|
+
);
|
|
772
|
+
}
|
|
773
|
+
setAccountSwitched(accountToSelect);
|
|
774
|
+
},
|
|
775
|
+
...mutationOptions
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
// src/components/AccountDropdownMenu.css.ts
|
|
780
|
+
var connectedAccount = "AccountDropdownMenu_connectedAccount__div2ql0";
|
|
781
|
+
var menuContent = "AccountDropdownMenu_menuContent__div2ql1";
|
|
782
|
+
var menuItem = "AccountDropdownMenu_menuItem__div2ql2";
|
|
783
|
+
var separator = "AccountDropdownMenu_separator__div2ql4";
|
|
784
|
+
var switchAccountMenuItem = "AccountDropdownMenu_switchAccountMenuItem__div2ql3";
|
|
785
|
+
|
|
786
|
+
// src/components/icons/CheckIcon.tsx
|
|
787
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
788
|
+
function CheckIcon(props) {
|
|
789
|
+
return /* @__PURE__ */ jsx17("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "none", ...props, children: /* @__PURE__ */ jsx17(
|
|
790
|
+
"path",
|
|
791
|
+
{
|
|
792
|
+
fill: "currentColor",
|
|
793
|
+
d: "m11.726 5.048-4.73 5.156-1.722-1.879a.72.72 0 0 0-.529-.23.722.722 0 0 0-.525.24.858.858 0 0 0-.22.573.86.86 0 0 0 .211.576l2.255 2.458c.14.153.332.24.53.24.2 0 .391-.087.532-.24l5.261-5.735A.86.86 0 0 0 13 5.63a.858.858 0 0 0-.22-.572.722.722 0 0 0-.525-.24.72.72 0 0 0-.529.23Z"
|
|
794
|
+
}
|
|
795
|
+
) });
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
// src/components/icons/ChevronIcon.tsx
|
|
799
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
800
|
+
function ChevronIcon(props) {
|
|
801
|
+
return /* @__PURE__ */ jsx18("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "none", ...props, children: /* @__PURE__ */ jsx18(
|
|
802
|
+
"path",
|
|
803
|
+
{
|
|
804
|
+
stroke: "#A0B6C3",
|
|
805
|
+
strokeLinecap: "round",
|
|
806
|
+
strokeLinejoin: "round",
|
|
807
|
+
strokeWidth: 1.5,
|
|
808
|
+
d: "m4 6 4 4 4-4"
|
|
809
|
+
}
|
|
810
|
+
) });
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
// src/components/AccountDropdownMenu.tsx
|
|
814
|
+
import { jsx as jsx19, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
815
|
+
function AccountDropdownMenu({ currentAccount }) {
|
|
816
|
+
const { mutate: disconnectWallet } = useDisconnectWallet();
|
|
817
|
+
const { data: domain } = useResolveSuiNSName(
|
|
818
|
+
currentAccount.label ? null : currentAccount.address
|
|
819
|
+
);
|
|
820
|
+
const accounts = useAccounts();
|
|
821
|
+
return /* @__PURE__ */ jsxs8(DropdownMenu.Root, { modal: false, children: [
|
|
822
|
+
/* @__PURE__ */ jsx19(StyleMarker, { children: /* @__PURE__ */ jsx19(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs8(Button, { size: "lg", className: connectedAccount, children: [
|
|
823
|
+
/* @__PURE__ */ jsx19(Text, { mono: true, weight: "bold", children: currentAccount.label ?? domain ?? formatAddress(currentAccount.address) }),
|
|
824
|
+
/* @__PURE__ */ jsx19(ChevronIcon, {})
|
|
825
|
+
] }) }) }),
|
|
826
|
+
/* @__PURE__ */ jsx19(DropdownMenu.Portal, { children: /* @__PURE__ */ jsx19(StyleMarker, { children: /* @__PURE__ */ jsxs8(DropdownMenu.Content, { className: menuContent, children: [
|
|
827
|
+
accounts.map((account) => /* @__PURE__ */ jsx19(
|
|
828
|
+
AccountDropdownMenuItem,
|
|
829
|
+
{
|
|
830
|
+
account,
|
|
831
|
+
active: currentAccount.address === account.address
|
|
832
|
+
},
|
|
833
|
+
account.address
|
|
834
|
+
)),
|
|
835
|
+
/* @__PURE__ */ jsx19(DropdownMenu.Separator, { className: separator }),
|
|
836
|
+
/* @__PURE__ */ jsx19(
|
|
837
|
+
DropdownMenu.Item,
|
|
797
838
|
{
|
|
798
|
-
className: clsx7(
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
children: [
|
|
802
|
-
/* @__PURE__ */ jsx19("div", { className: backButtonContainer, children: /* @__PURE__ */ jsx19(IconButton, { type: "button", "aria-label": "Back", onClick: () => resetSelection(), children: /* @__PURE__ */ jsx19(BackIcon, {}) }) }),
|
|
803
|
-
modalContent
|
|
804
|
-
]
|
|
839
|
+
className: clsx7(menuItem),
|
|
840
|
+
onSelect: () => disconnectWallet(),
|
|
841
|
+
children: "Disconnect"
|
|
805
842
|
}
|
|
806
|
-
)
|
|
807
|
-
|
|
808
|
-
] }) }) }) })
|
|
843
|
+
)
|
|
844
|
+
] }) }) })
|
|
809
845
|
] });
|
|
810
846
|
}
|
|
847
|
+
function AccountDropdownMenuItem({
|
|
848
|
+
account,
|
|
849
|
+
active
|
|
850
|
+
}) {
|
|
851
|
+
const { mutate: switchAccount } = useSwitchAccount();
|
|
852
|
+
const { data: domain } = useResolveSuiNSName(account.label ? null : account.address);
|
|
853
|
+
return /* @__PURE__ */ jsxs8(
|
|
854
|
+
DropdownMenu.Item,
|
|
855
|
+
{
|
|
856
|
+
className: clsx7(menuItem, switchAccountMenuItem),
|
|
857
|
+
onSelect: () => switchAccount({ account }),
|
|
858
|
+
children: [
|
|
859
|
+
/* @__PURE__ */ jsx19(Text, { mono: true, children: account.label ?? domain ?? formatAddress(account.address) }),
|
|
860
|
+
active ? /* @__PURE__ */ jsx19(CheckIcon, {}) : null
|
|
861
|
+
]
|
|
862
|
+
}
|
|
863
|
+
);
|
|
864
|
+
}
|
|
811
865
|
|
|
812
866
|
// src/components/ConnectButton.tsx
|
|
813
867
|
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
@@ -826,25 +880,35 @@ import { useRef } from "react";
|
|
|
826
880
|
import { useEffect } from "react";
|
|
827
881
|
function useAutoConnectWallet(autoConnectEnabled) {
|
|
828
882
|
const { mutate: connectWallet } = useConnectWallet();
|
|
829
|
-
const
|
|
883
|
+
const setAutoConnectionStatus = useWalletStore((state) => state.setAutoConnectionStatus);
|
|
830
884
|
const lastConnectedWalletName = useWalletStore((state) => state.lastConnectedWalletName);
|
|
831
885
|
const lastConnectedAccountAddress = useWalletStore((state) => state.lastConnectedAccountAddress);
|
|
886
|
+
const wallets = useWallets();
|
|
887
|
+
const { isDisconnected } = useCurrentWallet();
|
|
832
888
|
useEffect(() => {
|
|
833
|
-
if (!autoConnectEnabled || !lastConnectedWalletName)
|
|
889
|
+
if (!autoConnectEnabled || !lastConnectedWalletName || !lastConnectedAccountAddress || !isDisconnected) {
|
|
834
890
|
return;
|
|
891
|
+
}
|
|
835
892
|
const wallet = wallets.find((wallet2) => wallet2.name === lastConnectedWalletName);
|
|
836
893
|
if (wallet) {
|
|
837
|
-
connectWallet(
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
894
|
+
connectWallet(
|
|
895
|
+
{
|
|
896
|
+
wallet,
|
|
897
|
+
accountAddress: lastConnectedAccountAddress,
|
|
898
|
+
silent: true
|
|
899
|
+
},
|
|
900
|
+
{
|
|
901
|
+
onSettled: () => setAutoConnectionStatus("settled")
|
|
902
|
+
}
|
|
903
|
+
);
|
|
842
904
|
}
|
|
843
905
|
}, [
|
|
844
906
|
autoConnectEnabled,
|
|
845
907
|
connectWallet,
|
|
908
|
+
isDisconnected,
|
|
846
909
|
lastConnectedAccountAddress,
|
|
847
910
|
lastConnectedWalletName,
|
|
911
|
+
setAutoConnectionStatus,
|
|
848
912
|
wallets
|
|
849
913
|
]);
|
|
850
914
|
}
|
|
@@ -968,7 +1032,7 @@ function registerUnsafeBurnerWallet(suiClient) {
|
|
|
968
1032
|
// src/hooks/wallet/useWalletPropertiesChanged.ts
|
|
969
1033
|
import { useEffect as useEffect3 } from "react";
|
|
970
1034
|
function useWalletPropertiesChanged() {
|
|
971
|
-
const currentWallet = useCurrentWallet();
|
|
1035
|
+
const { currentWallet } = useCurrentWallet();
|
|
972
1036
|
const updateWalletAccounts = useWalletStore((state) => state.updateWalletAccounts);
|
|
973
1037
|
useEffect3(() => {
|
|
974
1038
|
const unsubscribeFromEvents = currentWallet?.features["standard:events"].on(
|
|
@@ -1087,7 +1151,12 @@ var lightTheme = {
|
|
|
1087
1151
|
// src/walletStore.ts
|
|
1088
1152
|
import { createStore } from "zustand";
|
|
1089
1153
|
import { createJSONStorage, persist } from "zustand/middleware";
|
|
1090
|
-
function createWalletStore({
|
|
1154
|
+
function createWalletStore({
|
|
1155
|
+
wallets,
|
|
1156
|
+
storage,
|
|
1157
|
+
storageKey,
|
|
1158
|
+
autoConnect
|
|
1159
|
+
}) {
|
|
1091
1160
|
return createStore()(
|
|
1092
1161
|
persist(
|
|
1093
1162
|
(set, get) => ({
|
|
@@ -1098,13 +1167,25 @@ function createWalletStore({ wallets, storage, storageKey }) {
|
|
|
1098
1167
|
lastConnectedAccountAddress: null,
|
|
1099
1168
|
lastConnectedWalletName: null,
|
|
1100
1169
|
connectionStatus: "disconnected",
|
|
1170
|
+
autoConnectionStatus: autoConnect ? "idle" : "disabled",
|
|
1171
|
+
setConnectionStatus(connectionStatus2) {
|
|
1172
|
+
set(() => ({
|
|
1173
|
+
connectionStatus: connectionStatus2
|
|
1174
|
+
}));
|
|
1175
|
+
},
|
|
1176
|
+
setAutoConnectionStatus(autoConnectionStatus) {
|
|
1177
|
+
set(() => ({
|
|
1178
|
+
autoConnectionStatus
|
|
1179
|
+
}));
|
|
1180
|
+
},
|
|
1101
1181
|
setWalletConnected(wallet, connectedAccounts, selectedAccount) {
|
|
1102
1182
|
set(() => ({
|
|
1103
1183
|
accounts: connectedAccounts,
|
|
1104
1184
|
currentWallet: wallet,
|
|
1105
1185
|
currentAccount: selectedAccount,
|
|
1106
1186
|
lastConnectedWalletName: wallet.name,
|
|
1107
|
-
lastConnectedAccountAddress: selectedAccount?.address
|
|
1187
|
+
lastConnectedAccountAddress: selectedAccount?.address,
|
|
1188
|
+
connectionStatus: "connected"
|
|
1108
1189
|
}));
|
|
1109
1190
|
},
|
|
1110
1191
|
setWalletDisconnected() {
|
|
@@ -1113,7 +1194,8 @@ function createWalletStore({ wallets, storage, storageKey }) {
|
|
|
1113
1194
|
currentWallet: null,
|
|
1114
1195
|
currentAccount: null,
|
|
1115
1196
|
lastConnectedWalletName: null,
|
|
1116
|
-
lastConnectedAccountAddress: null
|
|
1197
|
+
lastConnectedAccountAddress: null,
|
|
1198
|
+
connectionStatus: "disconnected"
|
|
1117
1199
|
}));
|
|
1118
1200
|
},
|
|
1119
1201
|
setAccountSwitched(selectedAccount) {
|
|
@@ -1133,7 +1215,8 @@ function createWalletStore({ wallets, storage, storageKey }) {
|
|
|
1133
1215
|
currentWallet: null,
|
|
1134
1216
|
currentAccount: null,
|
|
1135
1217
|
lastConnectedWalletName: null,
|
|
1136
|
-
lastConnectedAccountAddress: null
|
|
1218
|
+
lastConnectedAccountAddress: null,
|
|
1219
|
+
connectionStatus: "disconnected"
|
|
1137
1220
|
}));
|
|
1138
1221
|
} else {
|
|
1139
1222
|
set(() => ({ wallets: updatedWallets }));
|
|
@@ -1274,7 +1357,8 @@ function WalletProvider({
|
|
|
1274
1357
|
createWalletStore({
|
|
1275
1358
|
wallets: getRegisteredWallets(preferredWallets, requiredFeatures),
|
|
1276
1359
|
storageKey,
|
|
1277
|
-
storage
|
|
1360
|
+
storage,
|
|
1361
|
+
autoConnect
|
|
1278
1362
|
})
|
|
1279
1363
|
);
|
|
1280
1364
|
return /* @__PURE__ */ jsx22(WalletContext.Provider, { value: storeRef.current, children: /* @__PURE__ */ jsxs9(
|
|
@@ -1305,88 +1389,80 @@ function WalletConnectionManager({
|
|
|
1305
1389
|
return children;
|
|
1306
1390
|
}
|
|
1307
1391
|
|
|
1308
|
-
// src/hooks/
|
|
1309
|
-
|
|
1310
|
-
function
|
|
1311
|
-
|
|
1312
|
-
|
|
1392
|
+
// src/hooks/networkConfig.ts
|
|
1393
|
+
function createNetworkConfig(networkConfig) {
|
|
1394
|
+
function useNetworkConfig() {
|
|
1395
|
+
const { config } = useSuiClientContext();
|
|
1396
|
+
if (!config) {
|
|
1397
|
+
throw new Error("No network config found");
|
|
1398
|
+
}
|
|
1399
|
+
return config;
|
|
1400
|
+
}
|
|
1401
|
+
function useNetworkVariables() {
|
|
1402
|
+
const { variables } = useNetworkConfig();
|
|
1403
|
+
return variables ?? {};
|
|
1404
|
+
}
|
|
1405
|
+
function useNetworkVariable(name) {
|
|
1406
|
+
const variables = useNetworkVariables();
|
|
1407
|
+
return variables[name];
|
|
1408
|
+
}
|
|
1409
|
+
return {
|
|
1410
|
+
networkConfig,
|
|
1411
|
+
useNetworkConfig,
|
|
1412
|
+
useNetworkVariables,
|
|
1413
|
+
useNetworkVariable
|
|
1414
|
+
};
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
// src/hooks/useSuiClientInfiniteQuery.ts
|
|
1418
|
+
import { useInfiniteQuery } from "@tanstack/react-query";
|
|
1419
|
+
function useSuiClientInfiniteQuery(method, params, {
|
|
1420
|
+
queryKey = [],
|
|
1421
|
+
enabled = !!params,
|
|
1422
|
+
...options
|
|
1313
1423
|
} = {}) {
|
|
1314
|
-
const
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
"No wallet account is selected to sign the personal message with."
|
|
1326
|
-
);
|
|
1327
|
-
}
|
|
1328
|
-
const walletFeature = currentWallet.features["sui:signPersonalMessage"];
|
|
1329
|
-
if (!walletFeature) {
|
|
1330
|
-
throw new WalletFeatureNotSupportedError(
|
|
1331
|
-
"This wallet doesn't support the `signPersonalMessage` feature."
|
|
1332
|
-
);
|
|
1333
|
-
}
|
|
1334
|
-
return await walletFeature.signPersonalMessage({
|
|
1335
|
-
...signPersonalMessageArgs,
|
|
1336
|
-
account: signerAccount
|
|
1337
|
-
});
|
|
1338
|
-
},
|
|
1339
|
-
...mutationOptions
|
|
1424
|
+
const suiContext = useSuiClientContext();
|
|
1425
|
+
return useInfiniteQuery({
|
|
1426
|
+
...options,
|
|
1427
|
+
initialPageParam: null,
|
|
1428
|
+
queryKey: [suiContext.network, method, params, ...queryKey],
|
|
1429
|
+
enabled,
|
|
1430
|
+
queryFn: ({ pageParam }) => suiContext.client[method]({
|
|
1431
|
+
...params ?? {},
|
|
1432
|
+
cursor: pageParam
|
|
1433
|
+
}),
|
|
1434
|
+
getNextPageParam: ({ nextCursor }) => nextCursor ?? null
|
|
1340
1435
|
});
|
|
1341
1436
|
}
|
|
1342
1437
|
|
|
1343
|
-
// src/hooks/
|
|
1344
|
-
import { useMutation as
|
|
1345
|
-
function
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
mutationKey: walletMutationKeys.signTransactionBlock(mutationKey),
|
|
1353
|
-
mutationFn: async (signTransactionBlockArgs) => {
|
|
1354
|
-
if (!currentWallet) {
|
|
1355
|
-
throw new WalletNotConnectedError("No wallet is connected.");
|
|
1356
|
-
}
|
|
1357
|
-
const signerAccount = signTransactionBlockArgs.account ?? currentAccount;
|
|
1358
|
-
if (!signerAccount) {
|
|
1359
|
-
throw new WalletNoAccountSelectedError(
|
|
1360
|
-
"No wallet account is selected to sign the transaction block with."
|
|
1361
|
-
);
|
|
1362
|
-
}
|
|
1363
|
-
const walletFeature = currentWallet.features["sui:signTransactionBlock"];
|
|
1364
|
-
if (!walletFeature) {
|
|
1365
|
-
throw new WalletFeatureNotSupportedError(
|
|
1366
|
-
"This wallet doesn't support the `SignTransactionBlock` feature."
|
|
1367
|
-
);
|
|
1368
|
-
}
|
|
1369
|
-
return await walletFeature.signTransactionBlock({
|
|
1370
|
-
...signTransactionBlockArgs,
|
|
1371
|
-
account: signerAccount,
|
|
1372
|
-
chain: signTransactionBlockArgs.chain ?? signerAccount.chains[0]
|
|
1373
|
-
});
|
|
1374
|
-
},
|
|
1375
|
-
...mutationOptions
|
|
1438
|
+
// src/hooks/useSuiClientMutation.ts
|
|
1439
|
+
import { useMutation as useMutation4 } from "@tanstack/react-query";
|
|
1440
|
+
function useSuiClientMutation(method, options = {}) {
|
|
1441
|
+
const suiContext = useSuiClientContext();
|
|
1442
|
+
return useMutation4({
|
|
1443
|
+
...options,
|
|
1444
|
+
mutationFn: async (params) => {
|
|
1445
|
+
return await suiContext.client[method](params);
|
|
1446
|
+
}
|
|
1376
1447
|
});
|
|
1377
1448
|
}
|
|
1378
1449
|
|
|
1450
|
+
// src/hooks/wallet/useAutoConnectionStatus.ts
|
|
1451
|
+
function useAutoConnectionStatus() {
|
|
1452
|
+
return useWalletStore((state) => state.autoConnectionStatus);
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1379
1455
|
// src/hooks/wallet/useSignAndExecuteTransactionBlock.ts
|
|
1380
|
-
import { useMutation as
|
|
1456
|
+
import { useMutation as useMutation5 } from "@tanstack/react-query";
|
|
1381
1457
|
function useSignAndExecuteTransactionBlock({
|
|
1382
1458
|
mutationKey,
|
|
1383
1459
|
executeFromWallet,
|
|
1384
1460
|
...mutationOptions
|
|
1385
1461
|
} = {}) {
|
|
1386
|
-
const currentWallet = useCurrentWallet();
|
|
1462
|
+
const { currentWallet } = useCurrentWallet();
|
|
1387
1463
|
const currentAccount = useCurrentAccount();
|
|
1388
1464
|
const client = useSuiClient();
|
|
1389
|
-
return
|
|
1465
|
+
return useMutation5({
|
|
1390
1466
|
mutationKey: walletMutationKeys.signAndExecuteTransactionBlock(mutationKey),
|
|
1391
1467
|
mutationFn: async ({ requestType, options, ...signTransactionBlockArgs }) => {
|
|
1392
1468
|
if (!currentWallet) {
|
|
@@ -1435,32 +1511,74 @@ function useSignAndExecuteTransactionBlock({
|
|
|
1435
1511
|
});
|
|
1436
1512
|
}
|
|
1437
1513
|
|
|
1438
|
-
// src/hooks/
|
|
1439
|
-
import { useMutation as
|
|
1440
|
-
function
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1514
|
+
// src/hooks/wallet/useSignPersonalMessage.ts
|
|
1515
|
+
import { useMutation as useMutation6 } from "@tanstack/react-query";
|
|
1516
|
+
function useSignPersonalMessage({
|
|
1517
|
+
mutationKey,
|
|
1518
|
+
...mutationOptions
|
|
1519
|
+
} = {}) {
|
|
1520
|
+
const { currentWallet } = useCurrentWallet();
|
|
1521
|
+
const currentAccount = useCurrentAccount();
|
|
1522
|
+
return useMutation6({
|
|
1523
|
+
mutationKey: walletMutationKeys.signPersonalMessage(mutationKey),
|
|
1524
|
+
mutationFn: async (signPersonalMessageArgs) => {
|
|
1525
|
+
if (!currentWallet) {
|
|
1526
|
+
throw new WalletNotConnectedError("No wallet is connected.");
|
|
1527
|
+
}
|
|
1528
|
+
const signerAccount = signPersonalMessageArgs.account ?? currentAccount;
|
|
1529
|
+
if (!signerAccount) {
|
|
1530
|
+
throw new WalletNoAccountSelectedError(
|
|
1531
|
+
"No wallet account is selected to sign the personal message with."
|
|
1532
|
+
);
|
|
1533
|
+
}
|
|
1534
|
+
const walletFeature = currentWallet.features["sui:signPersonalMessage"];
|
|
1535
|
+
if (!walletFeature) {
|
|
1536
|
+
throw new WalletFeatureNotSupportedError(
|
|
1537
|
+
"This wallet doesn't support the `signPersonalMessage` feature."
|
|
1538
|
+
);
|
|
1539
|
+
}
|
|
1540
|
+
return await walletFeature.signPersonalMessage({
|
|
1541
|
+
...signPersonalMessageArgs,
|
|
1542
|
+
account: signerAccount
|
|
1543
|
+
});
|
|
1544
|
+
},
|
|
1545
|
+
...mutationOptions
|
|
1447
1546
|
});
|
|
1448
1547
|
}
|
|
1449
1548
|
|
|
1450
|
-
// src/hooks/
|
|
1451
|
-
import {
|
|
1452
|
-
function
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1549
|
+
// src/hooks/wallet/useSignTransactionBlock.ts
|
|
1550
|
+
import { useMutation as useMutation7 } from "@tanstack/react-query";
|
|
1551
|
+
function useSignTransactionBlock({
|
|
1552
|
+
mutationKey,
|
|
1553
|
+
...mutationOptions
|
|
1554
|
+
} = {}) {
|
|
1555
|
+
const { currentWallet } = useCurrentWallet();
|
|
1556
|
+
const currentAccount = useCurrentAccount();
|
|
1557
|
+
return useMutation7({
|
|
1558
|
+
mutationKey: walletMutationKeys.signTransactionBlock(mutationKey),
|
|
1559
|
+
mutationFn: async (signTransactionBlockArgs) => {
|
|
1560
|
+
if (!currentWallet) {
|
|
1561
|
+
throw new WalletNotConnectedError("No wallet is connected.");
|
|
1562
|
+
}
|
|
1563
|
+
const signerAccount = signTransactionBlockArgs.account ?? currentAccount;
|
|
1564
|
+
if (!signerAccount) {
|
|
1565
|
+
throw new WalletNoAccountSelectedError(
|
|
1566
|
+
"No wallet account is selected to sign the transaction block with."
|
|
1567
|
+
);
|
|
1568
|
+
}
|
|
1569
|
+
const walletFeature = currentWallet.features["sui:signTransactionBlock"];
|
|
1570
|
+
if (!walletFeature) {
|
|
1571
|
+
throw new WalletFeatureNotSupportedError(
|
|
1572
|
+
"This wallet doesn't support the `SignTransactionBlock` feature."
|
|
1573
|
+
);
|
|
1574
|
+
}
|
|
1575
|
+
return await walletFeature.signTransactionBlock({
|
|
1576
|
+
...signTransactionBlockArgs,
|
|
1577
|
+
account: signerAccount,
|
|
1578
|
+
chain: signTransactionBlockArgs.chain ?? signerAccount.chains[0]
|
|
1579
|
+
});
|
|
1460
1580
|
},
|
|
1461
|
-
|
|
1462
|
-
return lastPage.nextCursor ?? null;
|
|
1463
|
-
}
|
|
1581
|
+
...mutationOptions
|
|
1464
1582
|
});
|
|
1465
1583
|
}
|
|
1466
1584
|
export {
|
|
@@ -1469,12 +1587,15 @@ export {
|
|
|
1469
1587
|
SuiClientContext,
|
|
1470
1588
|
SuiClientProvider,
|
|
1471
1589
|
WalletProvider,
|
|
1590
|
+
createNetworkConfig,
|
|
1472
1591
|
lightTheme,
|
|
1473
1592
|
useAccounts,
|
|
1593
|
+
useAutoConnectionStatus,
|
|
1474
1594
|
useConnectWallet,
|
|
1475
1595
|
useCurrentAccount,
|
|
1476
1596
|
useCurrentWallet,
|
|
1477
1597
|
useDisconnectWallet,
|
|
1598
|
+
useResolveSuiNSName,
|
|
1478
1599
|
useSignAndExecuteTransactionBlock,
|
|
1479
1600
|
useSignPersonalMessage,
|
|
1480
1601
|
useSignTransactionBlock,
|