@mysten/dapp-kit 0.4.0 → 0.5.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 +6 -0
- package/README.md +4 -4
- package/dist/cjs/components/AccountDropdownMenu.d.ts +4 -0
- package/dist/cjs/components/AccountDropdownMenu.js +28 -13
- package/dist/cjs/components/AccountDropdownMenu.js.map +2 -2
- package/dist/cjs/components/ConnectButton.js +26 -12
- package/dist/cjs/components/ConnectButton.js.map +2 -2
- 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.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 +7 -5
- package/dist/cjs/hooks/useResolveSuiNSNames.js +4 -3
- package/dist/cjs/hooks/useResolveSuiNSNames.js.map +2 -2
- package/dist/cjs/hooks/useSuiClient.js.map +2 -2
- package/dist/cjs/hooks/useSuiClientInfiniteQuery.js.map +2 -2
- package/dist/cjs/hooks/useSuiClientMutation.js.map +2 -2
- package/dist/cjs/hooks/useSuiClientQuery.js.map +2 -2
- package/dist/cjs/hooks/wallet/useSignAndExecuteTransactionBlock.js.map +2 -2
- package/dist/cjs/hooks/wallet/useUnsafeBurnerWallet.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 +13 -10
- package/dist/cjs/index.js +601 -555
- package/dist/cjs/index.js.map +4 -4
- package/dist/esm/components/AccountDropdownMenu.d.ts +4 -0
- package/dist/esm/components/AccountDropdownMenu.js +28 -13
- package/dist/esm/components/AccountDropdownMenu.js.map +2 -2
- package/dist/esm/components/ConnectButton.js +26 -12
- package/dist/esm/components/ConnectButton.js.map +2 -2
- 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.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 +7 -5
- package/dist/esm/hooks/useResolveSuiNSNames.js +4 -3
- package/dist/esm/hooks/useResolveSuiNSNames.js.map +2 -2
- package/dist/esm/hooks/useSuiClient.js.map +2 -2
- package/dist/esm/hooks/useSuiClientInfiniteQuery.js.map +2 -2
- package/dist/esm/hooks/useSuiClientMutation.js.map +2 -2
- package/dist/esm/hooks/useSuiClientQuery.js.map +2 -2
- package/dist/esm/hooks/wallet/useSignAndExecuteTransactionBlock.js.map +2 -2
- package/dist/esm/hooks/wallet/useUnsafeBurnerWallet.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 +13 -10
- package/dist/esm/index.js +608 -562
- package/dist/esm/index.js.map +4 -4
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/AccountDropdownMenu.tsx +26 -8
- package/src/components/SuiClientProvider.tsx +11 -2
- package/src/hooks/networkConfig.ts +45 -0
- package/src/hooks/useResolveSuiNSNames.ts +12 -2
- package/src/index.ts +13 -10
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,237 +78,32 @@ 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
|
-
return
|
|
106
|
+
return useMutation({
|
|
433
107
|
mutationKey: walletMutationKeys.connectWallet(mutationKey),
|
|
434
108
|
mutationFn: async ({ wallet, accountAddress, ...standardConnectInput }) => {
|
|
435
109
|
const connectResult = await wallet.features["standard:connect"].connect(standardConnectInput);
|
|
@@ -455,9 +129,9 @@ function getSelectedAccount(connectedAccounts, accountAddress) {
|
|
|
455
129
|
}
|
|
456
130
|
|
|
457
131
|
// src/components/icons/BackIcon.tsx
|
|
458
|
-
import { jsx
|
|
132
|
+
import { jsx } from "react/jsx-runtime";
|
|
459
133
|
function BackIcon(props) {
|
|
460
|
-
return /* @__PURE__ */
|
|
134
|
+
return /* @__PURE__ */ jsx("svg", { width: 24, height: 24, fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ jsx(
|
|
461
135
|
"path",
|
|
462
136
|
{
|
|
463
137
|
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 +141,9 @@ function BackIcon(props) {
|
|
|
467
141
|
}
|
|
468
142
|
|
|
469
143
|
// src/components/icons/CloseIcon.tsx
|
|
470
|
-
import { jsx as
|
|
144
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
471
145
|
function CloseIcon(props) {
|
|
472
|
-
return /* @__PURE__ */
|
|
146
|
+
return /* @__PURE__ */ jsx2("svg", { width: 10, height: 10, fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ jsx2(
|
|
473
147
|
"path",
|
|
474
148
|
{
|
|
475
149
|
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 +152,33 @@ function CloseIcon(props) {
|
|
|
478
152
|
) });
|
|
479
153
|
}
|
|
480
154
|
|
|
155
|
+
// src/components/styling/StyleMarker.tsx
|
|
156
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
157
|
+
import { forwardRef } from "react";
|
|
158
|
+
|
|
159
|
+
// src/constants/styleDataAttribute.ts
|
|
160
|
+
var styleDataAttributeName = "data-dapp-kit";
|
|
161
|
+
var styleDataAttributeSelector = `[${styleDataAttributeName}]`;
|
|
162
|
+
var styleDataAttribute = { [styleDataAttributeName]: "" };
|
|
163
|
+
|
|
164
|
+
// src/components/styling/StyleMarker.tsx
|
|
165
|
+
var import_StyleMarker_css = __toESM(require_StyleMarker_css());
|
|
166
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
167
|
+
var StyleMarker = forwardRef(({ children }, forwardedRef) => /* @__PURE__ */ jsx3(Slot, { ref: forwardedRef, ...styleDataAttribute, children }));
|
|
168
|
+
StyleMarker.displayName = "StyleMarker";
|
|
169
|
+
|
|
481
170
|
// src/components/ui/Heading.tsx
|
|
482
|
-
import { Slot as
|
|
483
|
-
import
|
|
484
|
-
import { forwardRef as
|
|
171
|
+
import { Slot as Slot2 } from "@radix-ui/react-slot";
|
|
172
|
+
import clsx from "clsx";
|
|
173
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
485
174
|
|
|
486
175
|
// src/components/ui/Heading.css.ts
|
|
487
|
-
import { createRuntimeFn as
|
|
488
|
-
var headingVariants =
|
|
176
|
+
import { createRuntimeFn as _7a468 } from "@vanilla-extract/recipes/createRuntimeFn";
|
|
177
|
+
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
178
|
|
|
490
179
|
// src/components/ui/Heading.tsx
|
|
491
|
-
import { jsx as
|
|
492
|
-
var Heading =
|
|
180
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
181
|
+
var Heading = forwardRef2(
|
|
493
182
|
({
|
|
494
183
|
children,
|
|
495
184
|
className,
|
|
@@ -500,13 +189,13 @@ var Heading = forwardRef4(
|
|
|
500
189
|
truncate,
|
|
501
190
|
...headingProps
|
|
502
191
|
}, forwardedRef) => {
|
|
503
|
-
return /* @__PURE__ */
|
|
504
|
-
|
|
192
|
+
return /* @__PURE__ */ jsx4(
|
|
193
|
+
Slot2,
|
|
505
194
|
{
|
|
506
195
|
...headingProps,
|
|
507
196
|
ref: forwardedRef,
|
|
508
|
-
className:
|
|
509
|
-
children: asChild ? children : /* @__PURE__ */
|
|
197
|
+
className: clsx(headingVariants({ size, weight, truncate }), className),
|
|
198
|
+
children: asChild ? children : /* @__PURE__ */ jsx4(Tag, { children })
|
|
510
199
|
}
|
|
511
200
|
);
|
|
512
201
|
}
|
|
@@ -514,35 +203,97 @@ var Heading = forwardRef4(
|
|
|
514
203
|
Heading.displayName = "Heading";
|
|
515
204
|
|
|
516
205
|
// src/components/ui/IconButton.tsx
|
|
517
|
-
import { Slot as
|
|
518
|
-
import
|
|
519
|
-
import { forwardRef as
|
|
206
|
+
import { Slot as Slot3 } from "@radix-ui/react-slot";
|
|
207
|
+
import clsx2 from "clsx";
|
|
208
|
+
import { forwardRef as forwardRef3 } from "react";
|
|
520
209
|
|
|
521
210
|
// src/components/ui/IconButton.css.ts
|
|
522
211
|
var container = "IconButton_container__s6n7bq0";
|
|
523
212
|
|
|
524
213
|
// src/components/ui/IconButton.tsx
|
|
525
|
-
import { jsx as
|
|
526
|
-
var IconButton =
|
|
214
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
215
|
+
var IconButton = forwardRef3(
|
|
527
216
|
({ className, asChild = false, ...props }, forwardedRef) => {
|
|
528
|
-
const Comp = asChild ?
|
|
529
|
-
return /* @__PURE__ */
|
|
217
|
+
const Comp = asChild ? Slot3 : "button";
|
|
218
|
+
return /* @__PURE__ */ jsx5(Comp, { ...props, className: clsx2(container, className), ref: forwardedRef });
|
|
219
|
+
}
|
|
220
|
+
);
|
|
221
|
+
IconButton.displayName = "Button";
|
|
222
|
+
|
|
223
|
+
// src/components/connect-modal/ConnectModal.css.ts
|
|
224
|
+
var backButtonContainer = "ConnectModal_backButtonContainer__gz8z96";
|
|
225
|
+
var closeButtonContainer = "ConnectModal_closeButtonContainer__gz8z97";
|
|
226
|
+
var content = "ConnectModal_content__gz8z92";
|
|
227
|
+
var overlay = "ConnectModal_overlay__gz8z90";
|
|
228
|
+
var selectedViewContainer = "ConnectModal_selectedViewContainer__gz8z95";
|
|
229
|
+
var title = "ConnectModal_title__gz8z91";
|
|
230
|
+
var viewContainer = "ConnectModal_viewContainer__gz8z94";
|
|
231
|
+
var walletListContainer = "ConnectModal_walletListContainer__gz8z99";
|
|
232
|
+
var walletListContainerWithViewSelected = "ConnectModal_walletListContainerWithViewSelected__gz8z9a";
|
|
233
|
+
var walletListContent = "ConnectModal_walletListContent__gz8z98";
|
|
234
|
+
var whatIsAWalletButton = "ConnectModal_whatIsAWalletButton__gz8z93";
|
|
235
|
+
|
|
236
|
+
// src/components/ui/Button.tsx
|
|
237
|
+
import { Slot as Slot4 } from "@radix-ui/react-slot";
|
|
238
|
+
import clsx3 from "clsx";
|
|
239
|
+
import { forwardRef as forwardRef4 } from "react";
|
|
240
|
+
|
|
241
|
+
// src/components/ui/Button.css.ts
|
|
242
|
+
import { createRuntimeFn as _7a4682 } from "@vanilla-extract/recipes/createRuntimeFn";
|
|
243
|
+
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: [] });
|
|
244
|
+
|
|
245
|
+
// src/components/ui/Button.tsx
|
|
246
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
247
|
+
var Button = forwardRef4(
|
|
248
|
+
({ className, variant, size, asChild = false, ...props }, forwardedRef) => {
|
|
249
|
+
const Comp = asChild ? Slot4 : "button";
|
|
250
|
+
return /* @__PURE__ */ jsx6(
|
|
251
|
+
Comp,
|
|
252
|
+
{
|
|
253
|
+
...props,
|
|
254
|
+
className: clsx3(buttonVariants({ variant, size }), className),
|
|
255
|
+
ref: forwardedRef
|
|
256
|
+
}
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
);
|
|
260
|
+
Button.displayName = "Button";
|
|
261
|
+
|
|
262
|
+
// src/components/ui/Text.tsx
|
|
263
|
+
import { Slot as Slot5 } from "@radix-ui/react-slot";
|
|
264
|
+
import clsx4 from "clsx";
|
|
265
|
+
import { forwardRef as forwardRef5 } from "react";
|
|
266
|
+
|
|
267
|
+
// src/components/ui/Text.css.ts
|
|
268
|
+
import { createRuntimeFn as _7a4683 } from "@vanilla-extract/recipes/createRuntimeFn";
|
|
269
|
+
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: [] });
|
|
270
|
+
|
|
271
|
+
// src/components/ui/Text.tsx
|
|
272
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
273
|
+
var Text = forwardRef5(
|
|
274
|
+
({
|
|
275
|
+
children,
|
|
276
|
+
className,
|
|
277
|
+
asChild = false,
|
|
278
|
+
as: Tag = "div",
|
|
279
|
+
size,
|
|
280
|
+
weight,
|
|
281
|
+
color,
|
|
282
|
+
mono,
|
|
283
|
+
...textProps
|
|
284
|
+
}, forwardedRef) => {
|
|
285
|
+
return /* @__PURE__ */ jsx7(
|
|
286
|
+
Slot5,
|
|
287
|
+
{
|
|
288
|
+
...textProps,
|
|
289
|
+
ref: forwardedRef,
|
|
290
|
+
className: clsx4(textVariants({ size, weight, color, mono }), className),
|
|
291
|
+
children: asChild ? children : /* @__PURE__ */ jsx7(Tag, { children })
|
|
292
|
+
}
|
|
293
|
+
);
|
|
530
294
|
}
|
|
531
295
|
);
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
// src/components/connect-modal/ConnectModal.css.ts
|
|
535
|
-
var backButtonContainer = "ConnectModal_backButtonContainer__gz8z96";
|
|
536
|
-
var closeButtonContainer = "ConnectModal_closeButtonContainer__gz8z97";
|
|
537
|
-
var content = "ConnectModal_content__gz8z92";
|
|
538
|
-
var overlay = "ConnectModal_overlay__gz8z90";
|
|
539
|
-
var selectedViewContainer = "ConnectModal_selectedViewContainer__gz8z95";
|
|
540
|
-
var title = "ConnectModal_title__gz8z91";
|
|
541
|
-
var viewContainer = "ConnectModal_viewContainer__gz8z94";
|
|
542
|
-
var walletListContainer = "ConnectModal_walletListContainer__gz8z99";
|
|
543
|
-
var walletListContainerWithViewSelected = "ConnectModal_walletListContainerWithViewSelected__gz8z9a";
|
|
544
|
-
var walletListContent = "ConnectModal_walletListContent__gz8z98";
|
|
545
|
-
var whatIsAWalletButton = "ConnectModal_whatIsAWalletButton__gz8z93";
|
|
296
|
+
Text.displayName = "Text";
|
|
546
297
|
|
|
547
298
|
// src/components/connect-modal/views/ConnectionStatus.css.ts
|
|
548
299
|
var connectionStatus = "ConnectionStatus_connectionStatus__nckm2d3";
|
|
@@ -552,14 +303,14 @@ var title2 = "ConnectionStatus_title__nckm2d2";
|
|
|
552
303
|
var walletIcon = "ConnectionStatus_walletIcon__nckm2d1";
|
|
553
304
|
|
|
554
305
|
// src/components/connect-modal/views/ConnectionStatus.tsx
|
|
555
|
-
import { jsx as
|
|
306
|
+
import { jsx as jsx8, jsxs } from "react/jsx-runtime";
|
|
556
307
|
function ConnectionStatus({
|
|
557
308
|
selectedWallet,
|
|
558
309
|
hadConnectionError,
|
|
559
310
|
onRetryConnection
|
|
560
311
|
}) {
|
|
561
|
-
return /* @__PURE__ */
|
|
562
|
-
/* @__PURE__ */
|
|
312
|
+
return /* @__PURE__ */ jsxs("div", { className: container2, children: [
|
|
313
|
+
/* @__PURE__ */ jsx8(
|
|
563
314
|
"img",
|
|
564
315
|
{
|
|
565
316
|
className: walletIcon,
|
|
@@ -567,12 +318,12 @@ function ConnectionStatus({
|
|
|
567
318
|
alt: `${selectedWallet.name} logo`
|
|
568
319
|
}
|
|
569
320
|
),
|
|
570
|
-
/* @__PURE__ */
|
|
321
|
+
/* @__PURE__ */ jsx8("div", { className: title2, children: /* @__PURE__ */ jsxs(Heading, { as: "h2", size: "xl", children: [
|
|
571
322
|
"Opening ",
|
|
572
323
|
selectedWallet.name
|
|
573
324
|
] }) }),
|
|
574
|
-
/* @__PURE__ */
|
|
575
|
-
hadConnectionError ? /* @__PURE__ */
|
|
325
|
+
/* @__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..." }) }),
|
|
326
|
+
hadConnectionError ? /* @__PURE__ */ jsx8("div", { className: retryButtonContainer, children: /* @__PURE__ */ jsx8(Button, { type: "button", variant: "outline", onClick: () => onRetryConnection(selectedWallet), children: "Retry Connection" }) }) : null
|
|
576
327
|
] });
|
|
577
328
|
}
|
|
578
329
|
|
|
@@ -580,11 +331,11 @@ function ConnectionStatus({
|
|
|
580
331
|
var container3 = "InfoSection_container__1wtioi70";
|
|
581
332
|
|
|
582
333
|
// src/components/connect-modal/InfoSection.tsx
|
|
583
|
-
import { jsx as
|
|
334
|
+
import { jsx as jsx9, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
584
335
|
function InfoSection({ title: title3, children }) {
|
|
585
|
-
return /* @__PURE__ */
|
|
586
|
-
/* @__PURE__ */
|
|
587
|
-
/* @__PURE__ */
|
|
336
|
+
return /* @__PURE__ */ jsxs2("section", { className: container3, children: [
|
|
337
|
+
/* @__PURE__ */ jsx9(Heading, { as: "h3", size: "sm", weight: "normal", children: title3 }),
|
|
338
|
+
/* @__PURE__ */ jsx9(Text, { weight: "medium", color: "muted", children })
|
|
588
339
|
] });
|
|
589
340
|
}
|
|
590
341
|
|
|
@@ -594,15 +345,15 @@ var content2 = "GettingStarted_content__1fp07e11";
|
|
|
594
345
|
var installButtonContainer = "GettingStarted_installButtonContainer__1fp07e12";
|
|
595
346
|
|
|
596
347
|
// src/components/connect-modal/views/GettingStarted.tsx
|
|
597
|
-
import { jsx as
|
|
348
|
+
import { jsx as jsx10, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
598
349
|
function GettingStarted() {
|
|
599
|
-
return /* @__PURE__ */
|
|
600
|
-
/* @__PURE__ */
|
|
601
|
-
/* @__PURE__ */
|
|
602
|
-
/* @__PURE__ */
|
|
603
|
-
/* @__PURE__ */
|
|
604
|
-
/* @__PURE__ */
|
|
605
|
-
/* @__PURE__ */
|
|
350
|
+
return /* @__PURE__ */ jsxs3("div", { className: container4, children: [
|
|
351
|
+
/* @__PURE__ */ jsx10(Heading, { as: "h2", children: "Get Started with Sui" }),
|
|
352
|
+
/* @__PURE__ */ jsxs3("div", { className: content2, children: [
|
|
353
|
+
/* @__PURE__ */ jsx10(InfoSection, { title: "Install the Sui Wallet Extension", children: "We recommend pinning Sui Wallet to your taskbar for quicker access." }),
|
|
354
|
+
/* @__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." }),
|
|
355
|
+
/* @__PURE__ */ jsx10(InfoSection, { title: "Refresh Your Browser", children: "Once you set up your wallet, refresh this window browser to load up the extension." }),
|
|
356
|
+
/* @__PURE__ */ jsx10("div", { className: installButtonContainer, children: /* @__PURE__ */ jsx10(Button, { variant: "outline", asChild: true, children: /* @__PURE__ */ jsx10(
|
|
606
357
|
"a",
|
|
607
358
|
{
|
|
608
359
|
href: "https://chrome.google.com/webstore/detail/sui-wallet/opcgpfmipidbgpenhmajoajpbobppdil",
|
|
@@ -620,13 +371,13 @@ var container5 = "WhatIsAWallet_container__1ktpkq90";
|
|
|
620
371
|
var content3 = "WhatIsAWallet_content__1ktpkq91";
|
|
621
372
|
|
|
622
373
|
// src/components/connect-modal/views/WhatIsAWallet.tsx
|
|
623
|
-
import { jsx as
|
|
374
|
+
import { jsx as jsx11, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
624
375
|
function WhatIsAWallet() {
|
|
625
|
-
return /* @__PURE__ */
|
|
626
|
-
/* @__PURE__ */
|
|
627
|
-
/* @__PURE__ */
|
|
628
|
-
/* @__PURE__ */
|
|
629
|
-
/* @__PURE__ */
|
|
376
|
+
return /* @__PURE__ */ jsxs4("div", { className: container5, children: [
|
|
377
|
+
/* @__PURE__ */ jsx11(Heading, { as: "h2", children: "What is a Wallet" }),
|
|
378
|
+
/* @__PURE__ */ jsxs4("div", { className: content3, children: [
|
|
379
|
+
/* @__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." }),
|
|
380
|
+
/* @__PURE__ */ jsx11(InfoSection, { title: "Store your Digital Assets", children: "Send, receive, store, and display your digital assets like NFTs & coins." })
|
|
630
381
|
] })
|
|
631
382
|
] });
|
|
632
383
|
}
|
|
@@ -637,11 +388,11 @@ function useWallets() {
|
|
|
637
388
|
}
|
|
638
389
|
|
|
639
390
|
// src/components/icons/SuiIcon.tsx
|
|
640
|
-
import { jsx as
|
|
391
|
+
import { jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
641
392
|
function SuiIcon(props) {
|
|
642
|
-
return /* @__PURE__ */
|
|
643
|
-
/* @__PURE__ */
|
|
644
|
-
/* @__PURE__ */
|
|
393
|
+
return /* @__PURE__ */ jsxs5("svg", { width: 28, height: 28, fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [
|
|
394
|
+
/* @__PURE__ */ jsx12("rect", { width: 28, height: 28, rx: 6, fill: "#6FBCF0" }),
|
|
395
|
+
/* @__PURE__ */ jsx12(
|
|
645
396
|
"path",
|
|
646
397
|
{
|
|
647
398
|
fillRule: "evenodd",
|
|
@@ -657,7 +408,7 @@ function SuiIcon(props) {
|
|
|
657
408
|
var container6 = "WalletList_container__1v2s6cz0";
|
|
658
409
|
|
|
659
410
|
// src/components/connect-modal/wallet-list/WalletListItem.tsx
|
|
660
|
-
import { clsx as
|
|
411
|
+
import { clsx as clsx5 } from "clsx";
|
|
661
412
|
|
|
662
413
|
// src/components/connect-modal/wallet-list/WalletListItem.css.ts
|
|
663
414
|
var container7 = "WalletListItem_container__1dqqtqs0";
|
|
@@ -666,27 +417,27 @@ var walletIcon2 = "WalletListItem_walletIcon__1dqqtqs3";
|
|
|
666
417
|
var walletItem = "WalletListItem_walletItem__1dqqtqs1";
|
|
667
418
|
|
|
668
419
|
// src/components/connect-modal/wallet-list/WalletListItem.tsx
|
|
669
|
-
import { jsx as
|
|
420
|
+
import { jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
670
421
|
function WalletListItem({ name, icon, onClick, isSelected = false }) {
|
|
671
|
-
return /* @__PURE__ */
|
|
422
|
+
return /* @__PURE__ */ jsx13("li", { className: container7, children: /* @__PURE__ */ jsxs6(
|
|
672
423
|
"button",
|
|
673
424
|
{
|
|
674
|
-
className:
|
|
425
|
+
className: clsx5(walletItem, { [selectedWalletItem]: isSelected }),
|
|
675
426
|
type: "button",
|
|
676
427
|
onClick,
|
|
677
428
|
children: [
|
|
678
|
-
typeof icon === "string" ? /* @__PURE__ */
|
|
679
|
-
/* @__PURE__ */
|
|
429
|
+
typeof icon === "string" ? /* @__PURE__ */ jsx13("img", { className: walletIcon2, src: icon, alt: `${name} logo` }) : icon,
|
|
430
|
+
/* @__PURE__ */ jsx13(Heading, { size: "md", truncate: true, asChild: true, children: /* @__PURE__ */ jsx13("div", { children: name }) })
|
|
680
431
|
]
|
|
681
432
|
}
|
|
682
433
|
) });
|
|
683
434
|
}
|
|
684
435
|
|
|
685
436
|
// src/components/connect-modal/wallet-list/WalletList.tsx
|
|
686
|
-
import { jsx as
|
|
437
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
687
438
|
function WalletList({ selectedWalletName, onPlaceholderClick, onSelect }) {
|
|
688
439
|
const wallets = useWallets();
|
|
689
|
-
return /* @__PURE__ */
|
|
440
|
+
return /* @__PURE__ */ jsx14("ul", { className: container6, children: wallets.length > 0 ? wallets.map((wallet) => /* @__PURE__ */ jsx14(
|
|
690
441
|
WalletListItem,
|
|
691
442
|
{
|
|
692
443
|
name: wallet.name,
|
|
@@ -695,11 +446,11 @@ function WalletList({ selectedWalletName, onPlaceholderClick, onSelect }) {
|
|
|
695
446
|
onClick: () => onSelect(wallet)
|
|
696
447
|
},
|
|
697
448
|
wallet.name
|
|
698
|
-
)) : /* @__PURE__ */
|
|
449
|
+
)) : /* @__PURE__ */ jsx14(
|
|
699
450
|
WalletListItem,
|
|
700
451
|
{
|
|
701
452
|
name: "Sui Wallet",
|
|
702
|
-
icon: /* @__PURE__ */
|
|
453
|
+
icon: /* @__PURE__ */ jsx14(SuiIcon, {}),
|
|
703
454
|
onClick: onPlaceholderClick,
|
|
704
455
|
isSelected: true
|
|
705
456
|
}
|
|
@@ -707,11 +458,11 @@ function WalletList({ selectedWalletName, onPlaceholderClick, onSelect }) {
|
|
|
707
458
|
}
|
|
708
459
|
|
|
709
460
|
// src/components/connect-modal/ConnectModal.tsx
|
|
710
|
-
import { jsx as
|
|
461
|
+
import { jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
711
462
|
function ConnectModal({ trigger, open, defaultOpen, onOpenChange }) {
|
|
712
|
-
const [isModalOpen, setModalOpen] =
|
|
713
|
-
const [currentView, setCurrentView] =
|
|
714
|
-
const [selectedWallet, setSelectedWallet] =
|
|
463
|
+
const [isModalOpen, setModalOpen] = useState(open ?? defaultOpen);
|
|
464
|
+
const [currentView, setCurrentView] = useState();
|
|
465
|
+
const [selectedWallet, setSelectedWallet] = useState();
|
|
715
466
|
const { mutate, isError } = useConnectWallet();
|
|
716
467
|
const resetSelection = () => {
|
|
717
468
|
setSelectedWallet(void 0);
|
|
@@ -736,13 +487,13 @@ function ConnectModal({ trigger, open, defaultOpen, onOpenChange }) {
|
|
|
736
487
|
let modalContent;
|
|
737
488
|
switch (currentView) {
|
|
738
489
|
case "what-is-a-wallet":
|
|
739
|
-
modalContent = /* @__PURE__ */
|
|
490
|
+
modalContent = /* @__PURE__ */ jsx15(WhatIsAWallet, {});
|
|
740
491
|
break;
|
|
741
492
|
case "getting-started":
|
|
742
|
-
modalContent = /* @__PURE__ */
|
|
493
|
+
modalContent = /* @__PURE__ */ jsx15(GettingStarted, {});
|
|
743
494
|
break;
|
|
744
495
|
case "connection-status":
|
|
745
|
-
modalContent = /* @__PURE__ */
|
|
496
|
+
modalContent = /* @__PURE__ */ jsx15(
|
|
746
497
|
ConnectionStatus,
|
|
747
498
|
{
|
|
748
499
|
selectedWallet,
|
|
@@ -752,62 +503,330 @@ function ConnectModal({ trigger, open, defaultOpen, onOpenChange }) {
|
|
|
752
503
|
);
|
|
753
504
|
break;
|
|
754
505
|
default:
|
|
755
|
-
modalContent = /* @__PURE__ */
|
|
506
|
+
modalContent = /* @__PURE__ */ jsx15(WhatIsAWallet, {});
|
|
756
507
|
}
|
|
757
|
-
return /* @__PURE__ */
|
|
758
|
-
/* @__PURE__ */
|
|
759
|
-
/* @__PURE__ */
|
|
760
|
-
/* @__PURE__ */
|
|
508
|
+
return /* @__PURE__ */ jsxs7(Dialog.Root, { open: open ?? isModalOpen, onOpenChange: handleOpenChange, children: [
|
|
509
|
+
/* @__PURE__ */ jsx15(StyleMarker, { children: /* @__PURE__ */ jsx15(Dialog.Trigger, { asChild: true, children: trigger }) }),
|
|
510
|
+
/* @__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: [
|
|
511
|
+
/* @__PURE__ */ jsxs7(
|
|
512
|
+
"div",
|
|
513
|
+
{
|
|
514
|
+
className: clsx6(walletListContainer, {
|
|
515
|
+
[walletListContainerWithViewSelected]: !!currentView
|
|
516
|
+
}),
|
|
517
|
+
children: [
|
|
518
|
+
/* @__PURE__ */ jsxs7("div", { className: walletListContent, children: [
|
|
519
|
+
/* @__PURE__ */ jsx15(Dialog.Title, { className: title, asChild: true, children: /* @__PURE__ */ jsx15(Heading, { as: "h2", children: "Connect a Wallet" }) }),
|
|
520
|
+
/* @__PURE__ */ jsx15(
|
|
521
|
+
WalletList,
|
|
522
|
+
{
|
|
523
|
+
selectedWalletName: selectedWallet?.name,
|
|
524
|
+
onPlaceholderClick: () => setCurrentView("getting-started"),
|
|
525
|
+
onSelect: (wallet) => {
|
|
526
|
+
if (selectedWallet?.name !== wallet.name) {
|
|
527
|
+
setSelectedWallet(wallet);
|
|
528
|
+
connectWallet(wallet);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
)
|
|
533
|
+
] }),
|
|
534
|
+
/* @__PURE__ */ jsx15(
|
|
535
|
+
"button",
|
|
536
|
+
{
|
|
537
|
+
className: whatIsAWalletButton,
|
|
538
|
+
onClick: () => setCurrentView("what-is-a-wallet"),
|
|
539
|
+
type: "button",
|
|
540
|
+
children: "What is a Wallet?"
|
|
541
|
+
}
|
|
542
|
+
)
|
|
543
|
+
]
|
|
544
|
+
}
|
|
545
|
+
),
|
|
546
|
+
/* @__PURE__ */ jsxs7(
|
|
761
547
|
"div",
|
|
762
548
|
{
|
|
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
|
-
|
|
549
|
+
className: clsx6(viewContainer, {
|
|
550
|
+
[selectedViewContainer]: !!currentView
|
|
551
|
+
}),
|
|
552
|
+
children: [
|
|
553
|
+
/* @__PURE__ */ jsx15("div", { className: backButtonContainer, children: /* @__PURE__ */ jsx15(IconButton, { type: "button", "aria-label": "Back", onClick: () => resetSelection(), children: /* @__PURE__ */ jsx15(BackIcon, {}) }) }),
|
|
554
|
+
modalContent
|
|
555
|
+
]
|
|
556
|
+
}
|
|
557
|
+
),
|
|
558
|
+
/* @__PURE__ */ jsx15(Dialog.Close, { className: closeButtonContainer, asChild: true, children: /* @__PURE__ */ jsx15(IconButton, { type: "button", "aria-label": "Close", children: /* @__PURE__ */ jsx15(CloseIcon, {}) }) })
|
|
559
|
+
] }) }) }) })
|
|
560
|
+
] });
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
// src/hooks/wallet/useCurrentAccount.ts
|
|
564
|
+
function useCurrentAccount() {
|
|
565
|
+
return useWalletStore((state) => state.currentAccount);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
// src/components/AccountDropdownMenu.tsx
|
|
569
|
+
import { formatAddress } from "@mysten/sui.js/utils";
|
|
570
|
+
import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
|
|
571
|
+
import clsx7 from "clsx";
|
|
572
|
+
|
|
573
|
+
// src/hooks/useSuiClientQuery.ts
|
|
574
|
+
import { useQuery } from "@tanstack/react-query";
|
|
575
|
+
|
|
576
|
+
// src/hooks/useSuiClient.ts
|
|
577
|
+
import { useContext as useContext2 } from "react";
|
|
578
|
+
|
|
579
|
+
// src/components/SuiClientProvider.tsx
|
|
580
|
+
import { getFullnodeUrl, isSuiClient, SuiClient } from "@mysten/sui.js/client";
|
|
581
|
+
import { createContext as createContext2, useMemo, useState as useState2 } from "react";
|
|
582
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
583
|
+
var SuiClientContext = createContext2(null);
|
|
584
|
+
var DEFAULT_NETWORKS = {
|
|
585
|
+
localnet: { url: getFullnodeUrl("localnet") }
|
|
586
|
+
};
|
|
587
|
+
var DEFAULT_CREATE_CLIENT = function createClient(_name, config) {
|
|
588
|
+
if (isSuiClient(config)) {
|
|
589
|
+
return config;
|
|
590
|
+
}
|
|
591
|
+
return new SuiClient(config);
|
|
592
|
+
};
|
|
593
|
+
function SuiClientProvider(props) {
|
|
594
|
+
const { onNetworkChange, network, children } = props;
|
|
595
|
+
const networks = props.networks ?? DEFAULT_NETWORKS;
|
|
596
|
+
const createClient2 = props.createClient ?? DEFAULT_CREATE_CLIENT;
|
|
597
|
+
const [selectedNetwork, setSelectedNetwork] = useState2(
|
|
598
|
+
props.network ?? props.defaultNetwork ?? Object.keys(networks)[0]
|
|
599
|
+
);
|
|
600
|
+
const currentNetwork = props.network ?? selectedNetwork;
|
|
601
|
+
const client = useMemo(() => {
|
|
602
|
+
return createClient2(currentNetwork, networks[currentNetwork]);
|
|
603
|
+
}, [createClient2, currentNetwork, networks]);
|
|
604
|
+
const ctx = useMemo(() => {
|
|
605
|
+
return {
|
|
606
|
+
client,
|
|
607
|
+
networks,
|
|
608
|
+
network: currentNetwork,
|
|
609
|
+
config: networks[currentNetwork] instanceof SuiClient ? null : networks[currentNetwork],
|
|
610
|
+
selectNetwork: (newNetwork) => {
|
|
611
|
+
if (currentNetwork === newNetwork) {
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
if (!network && newNetwork !== selectedNetwork) {
|
|
615
|
+
setSelectedNetwork(newNetwork);
|
|
616
|
+
}
|
|
617
|
+
onNetworkChange?.(newNetwork);
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
}, [client, networks, selectedNetwork, currentNetwork, network, onNetworkChange]);
|
|
621
|
+
return /* @__PURE__ */ jsx16(SuiClientContext.Provider, { value: ctx, children });
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
// src/hooks/useSuiClient.ts
|
|
625
|
+
function useSuiClientContext() {
|
|
626
|
+
const suiClient = useContext2(SuiClientContext);
|
|
627
|
+
if (!suiClient) {
|
|
628
|
+
throw new Error(
|
|
629
|
+
"Could not find SuiClientContext. Ensure that you have set up the SuiClientProvider"
|
|
630
|
+
);
|
|
631
|
+
}
|
|
632
|
+
return suiClient;
|
|
633
|
+
}
|
|
634
|
+
function useSuiClient() {
|
|
635
|
+
return useSuiClientContext().client;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
// src/hooks/useSuiClientQuery.ts
|
|
639
|
+
function useSuiClientQuery(...args) {
|
|
640
|
+
const [method, params, { queryKey = [], ...options } = {}] = args;
|
|
641
|
+
const suiContext = useSuiClientContext();
|
|
642
|
+
return useQuery({
|
|
643
|
+
...options,
|
|
644
|
+
queryKey: [suiContext.network, method, params, ...queryKey],
|
|
645
|
+
queryFn: async () => {
|
|
646
|
+
return await suiContext.client[method](params);
|
|
647
|
+
}
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
// src/hooks/useResolveSuiNSNames.ts
|
|
652
|
+
function useResolveSuiNSName(address, options) {
|
|
653
|
+
const { data, ...rest } = useSuiClientQuery(
|
|
654
|
+
"resolveNameServiceNames",
|
|
655
|
+
{
|
|
656
|
+
address,
|
|
657
|
+
limit: 1
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
refetchOnWindowFocus: false,
|
|
661
|
+
retry: false,
|
|
662
|
+
...options,
|
|
663
|
+
enabled: !!address && options?.enabled !== false
|
|
664
|
+
}
|
|
665
|
+
);
|
|
666
|
+
return { data: data?.data?.[0] ?? null, ...rest };
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
// src/hooks/wallet/useAccounts.ts
|
|
670
|
+
function useAccounts() {
|
|
671
|
+
return useWalletStore((state) => state.accounts);
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
// src/hooks/wallet/useDisconnectWallet.ts
|
|
675
|
+
import { useMutation as useMutation2 } from "@tanstack/react-query";
|
|
676
|
+
|
|
677
|
+
// src/errors/walletErrors.ts
|
|
678
|
+
var WalletNotConnectedError = class extends Error {
|
|
679
|
+
};
|
|
680
|
+
var WalletNoAccountSelectedError = class extends Error {
|
|
681
|
+
};
|
|
682
|
+
var WalletFeatureNotSupportedError = class extends Error {
|
|
683
|
+
};
|
|
684
|
+
var WalletAccountNotFoundError = class extends Error {
|
|
685
|
+
};
|
|
686
|
+
|
|
687
|
+
// src/hooks/wallet/useCurrentWallet.ts
|
|
688
|
+
function useCurrentWallet() {
|
|
689
|
+
return useWalletStore((state) => state.currentWallet);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
// src/hooks/wallet/useDisconnectWallet.ts
|
|
693
|
+
function useDisconnectWallet({
|
|
694
|
+
mutationKey,
|
|
695
|
+
...mutationOptions
|
|
696
|
+
} = {}) {
|
|
697
|
+
const currentWallet = useCurrentWallet();
|
|
698
|
+
const setWalletDisconnected = useWalletStore((state) => state.setWalletDisconnected);
|
|
699
|
+
return useMutation2({
|
|
700
|
+
mutationKey: walletMutationKeys.disconnectWallet(mutationKey),
|
|
701
|
+
mutationFn: async () => {
|
|
702
|
+
if (!currentWallet) {
|
|
703
|
+
throw new WalletNotConnectedError("No wallet is connected.");
|
|
704
|
+
}
|
|
705
|
+
try {
|
|
706
|
+
await currentWallet.features["standard:disconnect"]?.disconnect();
|
|
707
|
+
} catch (error) {
|
|
708
|
+
console.error("Failed to disconnect the application from the current wallet.", error);
|
|
709
|
+
}
|
|
710
|
+
setWalletDisconnected();
|
|
711
|
+
},
|
|
712
|
+
...mutationOptions
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
// src/hooks/wallet/useSwitchAccount.ts
|
|
717
|
+
import { useMutation as useMutation3 } from "@tanstack/react-query";
|
|
718
|
+
function useSwitchAccount({
|
|
719
|
+
mutationKey,
|
|
720
|
+
...mutationOptions
|
|
721
|
+
} = {}) {
|
|
722
|
+
const currentWallet = useCurrentWallet();
|
|
723
|
+
const setAccountSwitched = useWalletStore((state) => state.setAccountSwitched);
|
|
724
|
+
return useMutation3({
|
|
725
|
+
mutationKey: walletMutationKeys.switchAccount(mutationKey),
|
|
726
|
+
mutationFn: async ({ account }) => {
|
|
727
|
+
if (!currentWallet) {
|
|
728
|
+
throw new WalletNotConnectedError("No wallet is connected.");
|
|
729
|
+
}
|
|
730
|
+
const accountToSelect = currentWallet.accounts.find(
|
|
731
|
+
(walletAccount) => walletAccount.address === account.address
|
|
732
|
+
);
|
|
733
|
+
if (!accountToSelect) {
|
|
734
|
+
throw new WalletAccountNotFoundError(
|
|
735
|
+
`No account with address ${account.address} is connected to ${currentWallet.name}.`
|
|
736
|
+
);
|
|
737
|
+
}
|
|
738
|
+
setAccountSwitched(accountToSelect);
|
|
739
|
+
},
|
|
740
|
+
...mutationOptions
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
// src/components/AccountDropdownMenu.css.ts
|
|
745
|
+
var connectedAccount = "AccountDropdownMenu_connectedAccount__div2ql0";
|
|
746
|
+
var menuContent = "AccountDropdownMenu_menuContent__div2ql1";
|
|
747
|
+
var menuItem = "AccountDropdownMenu_menuItem__div2ql2";
|
|
748
|
+
var separator = "AccountDropdownMenu_separator__div2ql4";
|
|
749
|
+
var switchAccountMenuItem = "AccountDropdownMenu_switchAccountMenuItem__div2ql3";
|
|
750
|
+
|
|
751
|
+
// src/components/icons/CheckIcon.tsx
|
|
752
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
753
|
+
function CheckIcon(props) {
|
|
754
|
+
return /* @__PURE__ */ jsx17("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "none", ...props, children: /* @__PURE__ */ jsx17(
|
|
755
|
+
"path",
|
|
756
|
+
{
|
|
757
|
+
fill: "currentColor",
|
|
758
|
+
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"
|
|
759
|
+
}
|
|
760
|
+
) });
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
// src/components/icons/ChevronIcon.tsx
|
|
764
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
765
|
+
function ChevronIcon(props) {
|
|
766
|
+
return /* @__PURE__ */ jsx18("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "none", ...props, children: /* @__PURE__ */ jsx18(
|
|
767
|
+
"path",
|
|
768
|
+
{
|
|
769
|
+
stroke: "#A0B6C3",
|
|
770
|
+
strokeLinecap: "round",
|
|
771
|
+
strokeLinejoin: "round",
|
|
772
|
+
strokeWidth: 1.5,
|
|
773
|
+
d: "m4 6 4 4 4-4"
|
|
774
|
+
}
|
|
775
|
+
) });
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
// src/components/AccountDropdownMenu.tsx
|
|
779
|
+
import { jsx as jsx19, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
780
|
+
function AccountDropdownMenu({ currentAccount }) {
|
|
781
|
+
const { mutate: disconnectWallet } = useDisconnectWallet();
|
|
782
|
+
const { data: domain } = useResolveSuiNSName(
|
|
783
|
+
currentAccount.label ? null : currentAccount.address
|
|
784
|
+
);
|
|
785
|
+
const accounts = useAccounts();
|
|
786
|
+
return /* @__PURE__ */ jsxs8(DropdownMenu.Root, { modal: false, children: [
|
|
787
|
+
/* @__PURE__ */ jsx19(StyleMarker, { children: /* @__PURE__ */ jsx19(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs8(Button, { size: "lg", className: connectedAccount, children: [
|
|
788
|
+
/* @__PURE__ */ jsx19(Text, { mono: true, weight: "bold", children: currentAccount.label ?? domain ?? formatAddress(currentAccount.address) }),
|
|
789
|
+
/* @__PURE__ */ jsx19(ChevronIcon, {})
|
|
790
|
+
] }) }) }),
|
|
791
|
+
/* @__PURE__ */ jsx19(DropdownMenu.Portal, { children: /* @__PURE__ */ jsx19(StyleMarker, { children: /* @__PURE__ */ jsxs8(DropdownMenu.Content, { className: menuContent, children: [
|
|
792
|
+
accounts.map((account) => /* @__PURE__ */ jsx19(
|
|
793
|
+
AccountDropdownMenuItem,
|
|
794
|
+
{
|
|
795
|
+
account,
|
|
796
|
+
active: currentAccount.address === account.address
|
|
797
|
+
},
|
|
798
|
+
account.address
|
|
799
|
+
)),
|
|
800
|
+
/* @__PURE__ */ jsx19(DropdownMenu.Separator, { className: separator }),
|
|
801
|
+
/* @__PURE__ */ jsx19(
|
|
802
|
+
DropdownMenu.Item,
|
|
797
803
|
{
|
|
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
|
-
]
|
|
804
|
+
className: clsx7(menuItem),
|
|
805
|
+
onSelect: () => disconnectWallet(),
|
|
806
|
+
children: "Disconnect"
|
|
805
807
|
}
|
|
806
|
-
)
|
|
807
|
-
|
|
808
|
-
] }) }) }) })
|
|
808
|
+
)
|
|
809
|
+
] }) }) })
|
|
809
810
|
] });
|
|
810
811
|
}
|
|
812
|
+
function AccountDropdownMenuItem({
|
|
813
|
+
account,
|
|
814
|
+
active
|
|
815
|
+
}) {
|
|
816
|
+
const { mutate: switchAccount } = useSwitchAccount();
|
|
817
|
+
const { data: domain } = useResolveSuiNSName(account.label ? null : account.address);
|
|
818
|
+
return /* @__PURE__ */ jsxs8(
|
|
819
|
+
DropdownMenu.Item,
|
|
820
|
+
{
|
|
821
|
+
className: clsx7(menuItem, switchAccountMenuItem),
|
|
822
|
+
onSelect: () => switchAccount({ account }),
|
|
823
|
+
children: [
|
|
824
|
+
/* @__PURE__ */ jsx19(Text, { mono: true, children: account.label ?? domain ?? formatAddress(account.address) }),
|
|
825
|
+
active ? /* @__PURE__ */ jsx19(CheckIcon, {}) : null
|
|
826
|
+
]
|
|
827
|
+
}
|
|
828
|
+
);
|
|
829
|
+
}
|
|
811
830
|
|
|
812
831
|
// src/components/ConnectButton.tsx
|
|
813
832
|
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
@@ -1305,176 +1324,203 @@ function WalletConnectionManager({
|
|
|
1305
1324
|
return children;
|
|
1306
1325
|
}
|
|
1307
1326
|
|
|
1308
|
-
// src/hooks/
|
|
1327
|
+
// src/hooks/networkConfig.ts
|
|
1328
|
+
function createNetworkConfig(networkConfig) {
|
|
1329
|
+
function useNetworkConfig() {
|
|
1330
|
+
const { config } = useSuiClientContext();
|
|
1331
|
+
if (!config) {
|
|
1332
|
+
throw new Error("No network config found");
|
|
1333
|
+
}
|
|
1334
|
+
return config;
|
|
1335
|
+
}
|
|
1336
|
+
function useNetworkVariables() {
|
|
1337
|
+
const { variables } = useNetworkConfig();
|
|
1338
|
+
return variables ?? {};
|
|
1339
|
+
}
|
|
1340
|
+
function useNetworkVariable(name) {
|
|
1341
|
+
const variables = useNetworkVariables();
|
|
1342
|
+
return variables[name];
|
|
1343
|
+
}
|
|
1344
|
+
return {
|
|
1345
|
+
networkConfig,
|
|
1346
|
+
useNetworkConfig,
|
|
1347
|
+
useNetworkVariables,
|
|
1348
|
+
useNetworkVariable
|
|
1349
|
+
};
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
// src/hooks/useSuiClientInfiniteQuery.ts
|
|
1353
|
+
import { useInfiniteQuery } from "@tanstack/react-query";
|
|
1354
|
+
function useSuiClientInfiniteQuery(method, params, { queryKey = [], enabled = !!params, ...options } = {}) {
|
|
1355
|
+
const suiContext = useSuiClientContext();
|
|
1356
|
+
return useInfiniteQuery({
|
|
1357
|
+
...options,
|
|
1358
|
+
queryKey: [suiContext.network, method, params, ...queryKey],
|
|
1359
|
+
enabled,
|
|
1360
|
+
queryFn: async () => {
|
|
1361
|
+
return await suiContext.client[method](params);
|
|
1362
|
+
},
|
|
1363
|
+
getNextPageParam: (lastPage) => {
|
|
1364
|
+
return lastPage.nextCursor ?? null;
|
|
1365
|
+
}
|
|
1366
|
+
});
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
// src/hooks/useSuiClientMutation.ts
|
|
1309
1370
|
import { useMutation as useMutation4 } from "@tanstack/react-query";
|
|
1310
|
-
function
|
|
1371
|
+
function useSuiClientMutation(method, options = {}) {
|
|
1372
|
+
const suiContext = useSuiClientContext();
|
|
1373
|
+
return useMutation4({
|
|
1374
|
+
...options,
|
|
1375
|
+
mutationFn: async (params) => {
|
|
1376
|
+
return await suiContext.client[method](params);
|
|
1377
|
+
}
|
|
1378
|
+
});
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
// src/hooks/wallet/useSignAndExecuteTransactionBlock.ts
|
|
1382
|
+
import { useMutation as useMutation5 } from "@tanstack/react-query";
|
|
1383
|
+
function useSignAndExecuteTransactionBlock({
|
|
1311
1384
|
mutationKey,
|
|
1385
|
+
executeFromWallet,
|
|
1312
1386
|
...mutationOptions
|
|
1313
1387
|
} = {}) {
|
|
1314
1388
|
const currentWallet = useCurrentWallet();
|
|
1315
1389
|
const currentAccount = useCurrentAccount();
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1390
|
+
const client = useSuiClient();
|
|
1391
|
+
return useMutation5({
|
|
1392
|
+
mutationKey: walletMutationKeys.signAndExecuteTransactionBlock(mutationKey),
|
|
1393
|
+
mutationFn: async ({ requestType, options, ...signTransactionBlockArgs }) => {
|
|
1319
1394
|
if (!currentWallet) {
|
|
1320
1395
|
throw new WalletNotConnectedError("No wallet is connected.");
|
|
1321
1396
|
}
|
|
1322
|
-
const signerAccount =
|
|
1397
|
+
const signerAccount = signTransactionBlockArgs.account ?? currentAccount;
|
|
1323
1398
|
if (!signerAccount) {
|
|
1324
1399
|
throw new WalletNoAccountSelectedError(
|
|
1325
|
-
"No wallet account is selected to sign the
|
|
1400
|
+
"No wallet account is selected to sign and execute the transaction block with."
|
|
1326
1401
|
);
|
|
1327
1402
|
}
|
|
1328
|
-
|
|
1403
|
+
if (executeFromWallet) {
|
|
1404
|
+
const walletFeature2 = currentWallet.features["sui:signAndExecuteTransactionBlock"];
|
|
1405
|
+
if (!walletFeature2) {
|
|
1406
|
+
throw new WalletFeatureNotSupportedError(
|
|
1407
|
+
"This wallet doesn't support the `signAndExecuteTransactionBlock` feature."
|
|
1408
|
+
);
|
|
1409
|
+
}
|
|
1410
|
+
return walletFeature2.signAndExecuteTransactionBlock({
|
|
1411
|
+
...signTransactionBlockArgs,
|
|
1412
|
+
account: signerAccount,
|
|
1413
|
+
chain: signTransactionBlockArgs.chain ?? signerAccount.chains[0],
|
|
1414
|
+
requestType,
|
|
1415
|
+
options
|
|
1416
|
+
});
|
|
1417
|
+
}
|
|
1418
|
+
const walletFeature = currentWallet.features["sui:signTransactionBlock"];
|
|
1329
1419
|
if (!walletFeature) {
|
|
1330
1420
|
throw new WalletFeatureNotSupportedError(
|
|
1331
|
-
"This wallet doesn't support the `
|
|
1421
|
+
"This wallet doesn't support the `signTransactionBlock` feature."
|
|
1332
1422
|
);
|
|
1333
1423
|
}
|
|
1334
|
-
|
|
1335
|
-
...
|
|
1336
|
-
account: signerAccount
|
|
1424
|
+
const { signature, transactionBlockBytes } = await walletFeature.signTransactionBlock({
|
|
1425
|
+
...signTransactionBlockArgs,
|
|
1426
|
+
account: signerAccount,
|
|
1427
|
+
chain: signTransactionBlockArgs.chain ?? signerAccount.chains[0]
|
|
1428
|
+
});
|
|
1429
|
+
return client.executeTransactionBlock({
|
|
1430
|
+
transactionBlock: transactionBlockBytes,
|
|
1431
|
+
signature,
|
|
1432
|
+
requestType,
|
|
1433
|
+
options
|
|
1337
1434
|
});
|
|
1338
1435
|
},
|
|
1339
1436
|
...mutationOptions
|
|
1340
1437
|
});
|
|
1341
1438
|
}
|
|
1342
1439
|
|
|
1343
|
-
// src/hooks/wallet/
|
|
1344
|
-
import { useMutation as
|
|
1345
|
-
function
|
|
1440
|
+
// src/hooks/wallet/useSignPersonalMessage.ts
|
|
1441
|
+
import { useMutation as useMutation6 } from "@tanstack/react-query";
|
|
1442
|
+
function useSignPersonalMessage({
|
|
1346
1443
|
mutationKey,
|
|
1347
1444
|
...mutationOptions
|
|
1348
1445
|
} = {}) {
|
|
1349
1446
|
const currentWallet = useCurrentWallet();
|
|
1350
1447
|
const currentAccount = useCurrentAccount();
|
|
1351
|
-
return
|
|
1352
|
-
mutationKey: walletMutationKeys.
|
|
1353
|
-
mutationFn: async (
|
|
1448
|
+
return useMutation6({
|
|
1449
|
+
mutationKey: walletMutationKeys.signPersonalMessage(mutationKey),
|
|
1450
|
+
mutationFn: async (signPersonalMessageArgs) => {
|
|
1354
1451
|
if (!currentWallet) {
|
|
1355
1452
|
throw new WalletNotConnectedError("No wallet is connected.");
|
|
1356
1453
|
}
|
|
1357
|
-
const signerAccount =
|
|
1454
|
+
const signerAccount = signPersonalMessageArgs.account ?? currentAccount;
|
|
1358
1455
|
if (!signerAccount) {
|
|
1359
1456
|
throw new WalletNoAccountSelectedError(
|
|
1360
|
-
"No wallet account is selected to sign the
|
|
1457
|
+
"No wallet account is selected to sign the personal message with."
|
|
1361
1458
|
);
|
|
1362
1459
|
}
|
|
1363
|
-
const walletFeature = currentWallet.features["sui:
|
|
1460
|
+
const walletFeature = currentWallet.features["sui:signPersonalMessage"];
|
|
1364
1461
|
if (!walletFeature) {
|
|
1365
1462
|
throw new WalletFeatureNotSupportedError(
|
|
1366
|
-
"This wallet doesn't support the `
|
|
1463
|
+
"This wallet doesn't support the `signPersonalMessage` feature."
|
|
1367
1464
|
);
|
|
1368
1465
|
}
|
|
1369
|
-
return await walletFeature.
|
|
1370
|
-
...
|
|
1371
|
-
account: signerAccount
|
|
1372
|
-
chain: signTransactionBlockArgs.chain ?? signerAccount.chains[0]
|
|
1466
|
+
return await walletFeature.signPersonalMessage({
|
|
1467
|
+
...signPersonalMessageArgs,
|
|
1468
|
+
account: signerAccount
|
|
1373
1469
|
});
|
|
1374
1470
|
},
|
|
1375
1471
|
...mutationOptions
|
|
1376
1472
|
});
|
|
1377
1473
|
}
|
|
1378
1474
|
|
|
1379
|
-
// src/hooks/wallet/
|
|
1380
|
-
import { useMutation as
|
|
1381
|
-
function
|
|
1475
|
+
// src/hooks/wallet/useSignTransactionBlock.ts
|
|
1476
|
+
import { useMutation as useMutation7 } from "@tanstack/react-query";
|
|
1477
|
+
function useSignTransactionBlock({
|
|
1382
1478
|
mutationKey,
|
|
1383
|
-
executeFromWallet,
|
|
1384
1479
|
...mutationOptions
|
|
1385
1480
|
} = {}) {
|
|
1386
1481
|
const currentWallet = useCurrentWallet();
|
|
1387
1482
|
const currentAccount = useCurrentAccount();
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
mutationFn: async ({ requestType, options, ...signTransactionBlockArgs }) => {
|
|
1483
|
+
return useMutation7({
|
|
1484
|
+
mutationKey: walletMutationKeys.signTransactionBlock(mutationKey),
|
|
1485
|
+
mutationFn: async (signTransactionBlockArgs) => {
|
|
1392
1486
|
if (!currentWallet) {
|
|
1393
1487
|
throw new WalletNotConnectedError("No wallet is connected.");
|
|
1394
1488
|
}
|
|
1395
1489
|
const signerAccount = signTransactionBlockArgs.account ?? currentAccount;
|
|
1396
1490
|
if (!signerAccount) {
|
|
1397
1491
|
throw new WalletNoAccountSelectedError(
|
|
1398
|
-
"No wallet account is selected to sign
|
|
1492
|
+
"No wallet account is selected to sign the transaction block with."
|
|
1399
1493
|
);
|
|
1400
1494
|
}
|
|
1401
|
-
if (executeFromWallet) {
|
|
1402
|
-
const walletFeature2 = currentWallet.features["sui:signAndExecuteTransactionBlock"];
|
|
1403
|
-
if (!walletFeature2) {
|
|
1404
|
-
throw new WalletFeatureNotSupportedError(
|
|
1405
|
-
"This wallet doesn't support the `signAndExecuteTransactionBlock` feature."
|
|
1406
|
-
);
|
|
1407
|
-
}
|
|
1408
|
-
return walletFeature2.signAndExecuteTransactionBlock({
|
|
1409
|
-
...signTransactionBlockArgs,
|
|
1410
|
-
account: signerAccount,
|
|
1411
|
-
chain: signTransactionBlockArgs.chain ?? signerAccount.chains[0],
|
|
1412
|
-
requestType,
|
|
1413
|
-
options
|
|
1414
|
-
});
|
|
1415
|
-
}
|
|
1416
1495
|
const walletFeature = currentWallet.features["sui:signTransactionBlock"];
|
|
1417
1496
|
if (!walletFeature) {
|
|
1418
1497
|
throw new WalletFeatureNotSupportedError(
|
|
1419
|
-
"This wallet doesn't support the `
|
|
1498
|
+
"This wallet doesn't support the `SignTransactionBlock` feature."
|
|
1420
1499
|
);
|
|
1421
1500
|
}
|
|
1422
|
-
|
|
1501
|
+
return await walletFeature.signTransactionBlock({
|
|
1423
1502
|
...signTransactionBlockArgs,
|
|
1424
1503
|
account: signerAccount,
|
|
1425
1504
|
chain: signTransactionBlockArgs.chain ?? signerAccount.chains[0]
|
|
1426
1505
|
});
|
|
1427
|
-
return client.executeTransactionBlock({
|
|
1428
|
-
transactionBlock: transactionBlockBytes,
|
|
1429
|
-
signature,
|
|
1430
|
-
requestType,
|
|
1431
|
-
options
|
|
1432
|
-
});
|
|
1433
1506
|
},
|
|
1434
1507
|
...mutationOptions
|
|
1435
1508
|
});
|
|
1436
1509
|
}
|
|
1437
|
-
|
|
1438
|
-
// src/hooks/useSuiClientMutation.ts
|
|
1439
|
-
import { useMutation as useMutation7 } from "@tanstack/react-query";
|
|
1440
|
-
function useSuiClientMutation(method, options = {}) {
|
|
1441
|
-
const suiContext = useSuiClientContext();
|
|
1442
|
-
return useMutation7({
|
|
1443
|
-
...options,
|
|
1444
|
-
mutationFn: async (params) => {
|
|
1445
|
-
return await suiContext.client[method](params);
|
|
1446
|
-
}
|
|
1447
|
-
});
|
|
1448
|
-
}
|
|
1449
|
-
|
|
1450
|
-
// src/hooks/useSuiClientInfiniteQuery.ts
|
|
1451
|
-
import { useInfiniteQuery } from "@tanstack/react-query";
|
|
1452
|
-
function useSuiClientInfiniteQuery(method, params, { queryKey = [], enabled = !!params, ...options } = {}) {
|
|
1453
|
-
const suiContext = useSuiClientContext();
|
|
1454
|
-
return useInfiniteQuery({
|
|
1455
|
-
...options,
|
|
1456
|
-
queryKey: [suiContext.network, method, params, ...queryKey],
|
|
1457
|
-
enabled,
|
|
1458
|
-
queryFn: async () => {
|
|
1459
|
-
return await suiContext.client[method](params);
|
|
1460
|
-
},
|
|
1461
|
-
getNextPageParam: (lastPage) => {
|
|
1462
|
-
return lastPage.nextCursor ?? null;
|
|
1463
|
-
}
|
|
1464
|
-
});
|
|
1465
|
-
}
|
|
1466
1510
|
export {
|
|
1467
1511
|
ConnectButton,
|
|
1468
1512
|
ConnectModal,
|
|
1469
1513
|
SuiClientContext,
|
|
1470
1514
|
SuiClientProvider,
|
|
1471
1515
|
WalletProvider,
|
|
1516
|
+
createNetworkConfig,
|
|
1472
1517
|
lightTheme,
|
|
1473
1518
|
useAccounts,
|
|
1474
1519
|
useConnectWallet,
|
|
1475
1520
|
useCurrentAccount,
|
|
1476
1521
|
useCurrentWallet,
|
|
1477
1522
|
useDisconnectWallet,
|
|
1523
|
+
useResolveSuiNSName,
|
|
1478
1524
|
useSignAndExecuteTransactionBlock,
|
|
1479
1525
|
useSignPersonalMessage,
|
|
1480
1526
|
useSignTransactionBlock,
|