@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/cjs/index.js
CHANGED
|
@@ -68,12 +68,15 @@ __export(src_exports, {
|
|
|
68
68
|
SuiClientContext: () => SuiClientContext,
|
|
69
69
|
SuiClientProvider: () => SuiClientProvider,
|
|
70
70
|
WalletProvider: () => WalletProvider,
|
|
71
|
+
createNetworkConfig: () => createNetworkConfig,
|
|
71
72
|
lightTheme: () => lightTheme,
|
|
72
73
|
useAccounts: () => useAccounts,
|
|
74
|
+
useAutoConnectionStatus: () => useAutoConnectionStatus,
|
|
73
75
|
useConnectWallet: () => useConnectWallet,
|
|
74
76
|
useCurrentAccount: () => useCurrentAccount,
|
|
75
77
|
useCurrentWallet: () => useCurrentWallet,
|
|
76
78
|
useDisconnectWallet: () => useDisconnectWallet,
|
|
79
|
+
useResolveSuiNSName: () => useResolveSuiNSName,
|
|
77
80
|
useSignAndExecuteTransactionBlock: () => useSignAndExecuteTransactionBlock,
|
|
78
81
|
useSignPersonalMessage: () => useSignPersonalMessage,
|
|
79
82
|
useSignTransactionBlock: () => useSignTransactionBlock,
|
|
@@ -87,134 +90,13 @@ __export(src_exports, {
|
|
|
87
90
|
});
|
|
88
91
|
module.exports = __toCommonJS(src_exports);
|
|
89
92
|
|
|
90
|
-
// src/
|
|
91
|
-
var
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
var import_client = require("@mysten/sui.js/client");
|
|
95
|
-
var import_react = require("react");
|
|
96
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
97
|
-
var SuiClientContext = (0, import_react.createContext)(null);
|
|
98
|
-
var DEFAULT_NETWORKS = {
|
|
99
|
-
localnet: { url: (0, import_client.getFullnodeUrl)("localnet") }
|
|
100
|
-
};
|
|
101
|
-
var DEFAULT_CREATE_CLIENT = function createClient(_name, config) {
|
|
102
|
-
if ((0, import_client.isSuiClient)(config)) {
|
|
103
|
-
return config;
|
|
104
|
-
}
|
|
105
|
-
return new import_client.SuiClient(config);
|
|
106
|
-
};
|
|
107
|
-
function SuiClientProvider(props) {
|
|
108
|
-
const { onNetworkChange, network, children } = props;
|
|
109
|
-
const networks = props.networks ?? DEFAULT_NETWORKS;
|
|
110
|
-
const createClient2 = props.createClient ?? DEFAULT_CREATE_CLIENT;
|
|
111
|
-
const [selectedNetwork, setSelectedNetwork] = (0, import_react.useState)(
|
|
112
|
-
props.network ?? props.defaultNetwork ?? Object.keys(networks)[0]
|
|
113
|
-
);
|
|
114
|
-
const currentNetwork = props.network ?? selectedNetwork;
|
|
115
|
-
const client = (0, import_react.useMemo)(() => {
|
|
116
|
-
return createClient2(currentNetwork, networks[currentNetwork]);
|
|
117
|
-
}, [createClient2, currentNetwork, networks]);
|
|
118
|
-
const ctx = (0, import_react.useMemo)(() => {
|
|
119
|
-
return {
|
|
120
|
-
client,
|
|
121
|
-
networks,
|
|
122
|
-
network: currentNetwork,
|
|
123
|
-
selectNetwork: (newNetwork) => {
|
|
124
|
-
if (currentNetwork === newNetwork) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
if (!network && newNetwork !== selectedNetwork) {
|
|
128
|
-
setSelectedNetwork(newNetwork);
|
|
129
|
-
}
|
|
130
|
-
onNetworkChange?.(newNetwork);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
}, [client, networks, selectedNetwork, currentNetwork, network, onNetworkChange]);
|
|
134
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SuiClientContext.Provider, { value: ctx, children });
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// src/hooks/useSuiClient.ts
|
|
138
|
-
function useSuiClientContext() {
|
|
139
|
-
const suiClient = (0, import_react2.useContext)(SuiClientContext);
|
|
140
|
-
if (!suiClient) {
|
|
141
|
-
throw new Error(
|
|
142
|
-
"Could not find SuiClientContext. Ensure that you have set up the SuiClientProvider"
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
return suiClient;
|
|
146
|
-
}
|
|
147
|
-
function useSuiClient() {
|
|
148
|
-
return useSuiClientContext().client;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// src/hooks/wallet/useWalletStore.ts
|
|
152
|
-
var import_react4 = require("react");
|
|
153
|
-
var import_zustand = require("zustand");
|
|
154
|
-
|
|
155
|
-
// src/contexts/walletContext.ts
|
|
156
|
-
var import_react3 = require("react");
|
|
157
|
-
var WalletContext = (0, import_react3.createContext)(null);
|
|
158
|
-
|
|
159
|
-
// src/hooks/wallet/useWalletStore.ts
|
|
160
|
-
function useWalletStore(selector) {
|
|
161
|
-
const store = (0, import_react4.useContext)(WalletContext);
|
|
162
|
-
if (!store) {
|
|
163
|
-
throw new Error(
|
|
164
|
-
"Could not find WalletContext. Ensure that you have set up the WalletProvider."
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
return (0, import_zustand.useStore)(store, selector);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// src/hooks/wallet/useCurrentAccount.ts
|
|
171
|
-
function useCurrentAccount() {
|
|
172
|
-
return useWalletStore((state) => state.currentAccount);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// src/components/AccountDropdownMenu.tsx
|
|
176
|
-
var import_utils = require("@mysten/sui.js/utils");
|
|
177
|
-
var DropdownMenu = __toESM(require("@radix-ui/react-dropdown-menu"));
|
|
178
|
-
var import_clsx3 = __toESM(require("clsx"));
|
|
93
|
+
// src/components/connect-modal/ConnectModal.tsx
|
|
94
|
+
var Dialog = __toESM(require("@radix-ui/react-dialog"));
|
|
95
|
+
var import_clsx6 = __toESM(require("clsx"));
|
|
96
|
+
var import_react8 = require("react");
|
|
179
97
|
|
|
180
|
-
// src/hooks/
|
|
98
|
+
// src/hooks/wallet/useConnectWallet.ts
|
|
181
99
|
var import_react_query = require("@tanstack/react-query");
|
|
182
|
-
function useSuiClientQuery(...args) {
|
|
183
|
-
const [method, params, { queryKey = [], ...options } = {}] = args;
|
|
184
|
-
const suiContext = useSuiClientContext();
|
|
185
|
-
return (0, import_react_query.useQuery)({
|
|
186
|
-
...options,
|
|
187
|
-
queryKey: [suiContext.network, method, params, ...queryKey],
|
|
188
|
-
queryFn: async () => {
|
|
189
|
-
return await suiContext.client[method](params);
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// src/hooks/useResolveSuiNSNames.ts
|
|
195
|
-
function useResolveSuiNSName(address) {
|
|
196
|
-
const { data, ...rest } = useSuiClientQuery(
|
|
197
|
-
"resolveNameServiceNames",
|
|
198
|
-
{
|
|
199
|
-
address,
|
|
200
|
-
limit: 1
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
enabled: !!address,
|
|
204
|
-
refetchOnWindowFocus: false,
|
|
205
|
-
retry: false
|
|
206
|
-
}
|
|
207
|
-
);
|
|
208
|
-
return { data: data?.data?.[0] ?? null, ...rest };
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
// src/hooks/wallet/useAccounts.ts
|
|
212
|
-
function useAccounts() {
|
|
213
|
-
return useWalletStore((state) => state.accounts);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// src/hooks/wallet/useDisconnectWallet.ts
|
|
217
|
-
var import_react_query2 = require("@tanstack/react-query");
|
|
218
100
|
|
|
219
101
|
// src/constants/walletMutationKeys.ts
|
|
220
102
|
var walletMutationKeys = {
|
|
@@ -232,246 +114,48 @@ function formMutationKeyFn(baseEntity) {
|
|
|
232
114
|
};
|
|
233
115
|
}
|
|
234
116
|
|
|
235
|
-
// src/
|
|
236
|
-
var
|
|
237
|
-
|
|
238
|
-
var WalletNoAccountSelectedError = class extends Error {
|
|
239
|
-
};
|
|
240
|
-
var WalletFeatureNotSupportedError = class extends Error {
|
|
241
|
-
};
|
|
242
|
-
var WalletAccountNotFoundError = class extends Error {
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
// src/hooks/wallet/useCurrentWallet.ts
|
|
246
|
-
function useCurrentWallet() {
|
|
247
|
-
return useWalletStore((state) => state.currentWallet);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// src/hooks/wallet/useDisconnectWallet.ts
|
|
251
|
-
function useDisconnectWallet({
|
|
252
|
-
mutationKey,
|
|
253
|
-
...mutationOptions
|
|
254
|
-
} = {}) {
|
|
255
|
-
const currentWallet = useCurrentWallet();
|
|
256
|
-
const setWalletDisconnected = useWalletStore((state) => state.setWalletDisconnected);
|
|
257
|
-
return (0, import_react_query2.useMutation)({
|
|
258
|
-
mutationKey: walletMutationKeys.disconnectWallet(mutationKey),
|
|
259
|
-
mutationFn: async () => {
|
|
260
|
-
if (!currentWallet) {
|
|
261
|
-
throw new WalletNotConnectedError("No wallet is connected.");
|
|
262
|
-
}
|
|
263
|
-
try {
|
|
264
|
-
await currentWallet.features["standard:disconnect"]?.disconnect();
|
|
265
|
-
} catch (error) {
|
|
266
|
-
console.error("Failed to disconnect the application from the current wallet.", error);
|
|
267
|
-
}
|
|
268
|
-
setWalletDisconnected();
|
|
269
|
-
},
|
|
270
|
-
...mutationOptions
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
// src/hooks/wallet/useSwitchAccount.ts
|
|
275
|
-
var import_react_query3 = require("@tanstack/react-query");
|
|
276
|
-
function useSwitchAccount({
|
|
277
|
-
mutationKey,
|
|
278
|
-
...mutationOptions
|
|
279
|
-
} = {}) {
|
|
280
|
-
const currentWallet = useCurrentWallet();
|
|
281
|
-
const setAccountSwitched = useWalletStore((state) => state.setAccountSwitched);
|
|
282
|
-
return (0, import_react_query3.useMutation)({
|
|
283
|
-
mutationKey: walletMutationKeys.switchAccount(mutationKey),
|
|
284
|
-
mutationFn: async ({ account }) => {
|
|
285
|
-
if (!currentWallet) {
|
|
286
|
-
throw new WalletNotConnectedError("No wallet is connected.");
|
|
287
|
-
}
|
|
288
|
-
const accountToSelect = currentWallet.accounts.find(
|
|
289
|
-
(walletAccount) => walletAccount.address === account.address
|
|
290
|
-
);
|
|
291
|
-
if (!accountToSelect) {
|
|
292
|
-
throw new WalletAccountNotFoundError(
|
|
293
|
-
`No account with address ${account.address} is connected to ${currentWallet.name}.`
|
|
294
|
-
);
|
|
295
|
-
}
|
|
296
|
-
setAccountSwitched(accountToSelect);
|
|
297
|
-
},
|
|
298
|
-
...mutationOptions
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
// src/components/AccountDropdownMenu.css.ts
|
|
303
|
-
var connectedAccount = "AccountDropdownMenu_connectedAccount__div2ql0";
|
|
304
|
-
var menuContent = "AccountDropdownMenu_menuContent__div2ql1";
|
|
305
|
-
var menuItem = "AccountDropdownMenu_menuItem__div2ql2";
|
|
306
|
-
var separator = "AccountDropdownMenu_separator__div2ql4";
|
|
307
|
-
var switchAccountMenuItem = "AccountDropdownMenu_switchAccountMenuItem__div2ql3";
|
|
308
|
-
|
|
309
|
-
// src/components/icons/CheckIcon.tsx
|
|
310
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
311
|
-
function CheckIcon(props) {
|
|
312
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "none", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
313
|
-
"path",
|
|
314
|
-
{
|
|
315
|
-
fill: "currentColor",
|
|
316
|
-
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"
|
|
317
|
-
}
|
|
318
|
-
) });
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
// src/components/icons/ChevronIcon.tsx
|
|
322
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
323
|
-
function ChevronIcon(props) {
|
|
324
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "none", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
325
|
-
"path",
|
|
326
|
-
{
|
|
327
|
-
stroke: "#A0B6C3",
|
|
328
|
-
strokeLinecap: "round",
|
|
329
|
-
strokeLinejoin: "round",
|
|
330
|
-
strokeWidth: 1.5,
|
|
331
|
-
d: "m4 6 4 4 4-4"
|
|
332
|
-
}
|
|
333
|
-
) });
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
// src/components/styling/StyleMarker.tsx
|
|
337
|
-
var import_react_slot = require("@radix-ui/react-slot");
|
|
338
|
-
var import_react5 = require("react");
|
|
339
|
-
|
|
340
|
-
// src/constants/styleDataAttribute.ts
|
|
341
|
-
var styleDataAttributeName = "data-dapp-kit";
|
|
342
|
-
var styleDataAttributeSelector = `[${styleDataAttributeName}]`;
|
|
343
|
-
var styleDataAttribute = { [styleDataAttributeName]: "" };
|
|
344
|
-
|
|
345
|
-
// src/components/styling/StyleMarker.tsx
|
|
346
|
-
var import_StyleMarker_css = __toESM(require_StyleMarker_css());
|
|
347
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
348
|
-
var StyleMarker = (0, import_react5.forwardRef)(({ children }, forwardedRef) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_slot.Slot, { ref: forwardedRef, ...styleDataAttribute, children }));
|
|
349
|
-
StyleMarker.displayName = "StyleMarker";
|
|
350
|
-
|
|
351
|
-
// src/components/ui/Button.tsx
|
|
352
|
-
var import_react_slot2 = require("@radix-ui/react-slot");
|
|
353
|
-
var import_clsx = __toESM(require("clsx"));
|
|
354
|
-
var import_react6 = require("react");
|
|
355
|
-
|
|
356
|
-
// src/components/ui/Button.css.ts
|
|
357
|
-
var import_createRuntimeFn = require("@vanilla-extract/recipes/createRuntimeFn");
|
|
358
|
-
var buttonVariants = (0, import_createRuntimeFn.createRuntimeFn)({ 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: [] });
|
|
359
|
-
|
|
360
|
-
// src/components/ui/Button.tsx
|
|
361
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
362
|
-
var Button = (0, import_react6.forwardRef)(
|
|
363
|
-
({ className, variant, size, asChild = false, ...props }, forwardedRef) => {
|
|
364
|
-
const Comp = asChild ? import_react_slot2.Slot : "button";
|
|
365
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
366
|
-
Comp,
|
|
367
|
-
{
|
|
368
|
-
...props,
|
|
369
|
-
className: (0, import_clsx.default)(buttonVariants({ variant, size }), className),
|
|
370
|
-
ref: forwardedRef
|
|
371
|
-
}
|
|
372
|
-
);
|
|
373
|
-
}
|
|
374
|
-
);
|
|
375
|
-
Button.displayName = "Button";
|
|
376
|
-
|
|
377
|
-
// src/components/ui/Text.tsx
|
|
378
|
-
var import_react_slot3 = require("@radix-ui/react-slot");
|
|
379
|
-
var import_clsx2 = __toESM(require("clsx"));
|
|
380
|
-
var import_react7 = require("react");
|
|
117
|
+
// src/hooks/wallet/useWalletStore.ts
|
|
118
|
+
var import_react2 = require("react");
|
|
119
|
+
var import_zustand = require("zustand");
|
|
381
120
|
|
|
382
|
-
// src/
|
|
383
|
-
var
|
|
384
|
-
var
|
|
121
|
+
// src/contexts/walletContext.ts
|
|
122
|
+
var import_react = require("react");
|
|
123
|
+
var WalletContext = (0, import_react.createContext)(null);
|
|
385
124
|
|
|
386
|
-
// src/
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
({
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
asChild = false,
|
|
393
|
-
as: Tag = "div",
|
|
394
|
-
size,
|
|
395
|
-
weight,
|
|
396
|
-
color,
|
|
397
|
-
mono,
|
|
398
|
-
...textProps
|
|
399
|
-
}, forwardedRef) => {
|
|
400
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
401
|
-
import_react_slot3.Slot,
|
|
402
|
-
{
|
|
403
|
-
...textProps,
|
|
404
|
-
ref: forwardedRef,
|
|
405
|
-
className: (0, import_clsx2.default)(textVariants({ size, weight, color, mono }), className),
|
|
406
|
-
children: asChild ? children : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Tag, { children })
|
|
407
|
-
}
|
|
125
|
+
// src/hooks/wallet/useWalletStore.ts
|
|
126
|
+
function useWalletStore(selector) {
|
|
127
|
+
const store = (0, import_react2.useContext)(WalletContext);
|
|
128
|
+
if (!store) {
|
|
129
|
+
throw new Error(
|
|
130
|
+
"Could not find WalletContext. Ensure that you have set up the WalletProvider."
|
|
408
131
|
);
|
|
409
132
|
}
|
|
410
|
-
);
|
|
411
|
-
Text.displayName = "Text";
|
|
412
|
-
|
|
413
|
-
// src/components/AccountDropdownMenu.tsx
|
|
414
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
415
|
-
function AccountDropdownMenu({ currentAccount }) {
|
|
416
|
-
const { mutate: disconnectWallet } = useDisconnectWallet();
|
|
417
|
-
const { mutate: switchAccount } = useSwitchAccount();
|
|
418
|
-
const { data: domain } = useResolveSuiNSName(
|
|
419
|
-
currentAccount.label ? null : currentAccount.address
|
|
420
|
-
);
|
|
421
|
-
const accounts = useAccounts();
|
|
422
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(DropdownMenu.Root, { modal: false, children: [
|
|
423
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StyleMarker, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Button, { size: "lg", className: connectedAccount, children: [
|
|
424
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { mono: true, weight: "bold", children: currentAccount.label ?? domain ?? (0, import_utils.formatAddress)(currentAccount.address) }),
|
|
425
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ChevronIcon, {})
|
|
426
|
-
] }) }) }),
|
|
427
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DropdownMenu.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StyleMarker, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(DropdownMenu.Content, { className: menuContent, children: [
|
|
428
|
-
accounts.map((account) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
429
|
-
DropdownMenu.Item,
|
|
430
|
-
{
|
|
431
|
-
className: (0, import_clsx3.default)(menuItem, switchAccountMenuItem),
|
|
432
|
-
onSelect: () => switchAccount({ account }),
|
|
433
|
-
children: [
|
|
434
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { mono: true, children: account.label ?? (0, import_utils.formatAddress)(account.address) }),
|
|
435
|
-
currentAccount.address === account.address ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CheckIcon, {}) : null
|
|
436
|
-
]
|
|
437
|
-
},
|
|
438
|
-
account.address
|
|
439
|
-
)),
|
|
440
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DropdownMenu.Separator, { className: separator }),
|
|
441
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
442
|
-
DropdownMenu.Item,
|
|
443
|
-
{
|
|
444
|
-
className: (0, import_clsx3.default)(menuItem),
|
|
445
|
-
onSelect: () => disconnectWallet(),
|
|
446
|
-
children: "Disconnect"
|
|
447
|
-
}
|
|
448
|
-
)
|
|
449
|
-
] }) }) })
|
|
450
|
-
] });
|
|
133
|
+
return (0, import_zustand.useStore)(store, selector);
|
|
451
134
|
}
|
|
452
135
|
|
|
453
|
-
// src/components/connect-modal/ConnectModal.tsx
|
|
454
|
-
var Dialog = __toESM(require("@radix-ui/react-dialog"));
|
|
455
|
-
var import_clsx7 = __toESM(require("clsx"));
|
|
456
|
-
var import_react10 = require("react");
|
|
457
|
-
|
|
458
136
|
// src/hooks/wallet/useConnectWallet.ts
|
|
459
|
-
var import_react_query4 = require("@tanstack/react-query");
|
|
460
137
|
function useConnectWallet({
|
|
461
138
|
mutationKey,
|
|
462
139
|
...mutationOptions
|
|
463
140
|
} = {}) {
|
|
464
141
|
const setWalletConnected = useWalletStore((state) => state.setWalletConnected);
|
|
465
|
-
|
|
142
|
+
const setConnectionStatus = useWalletStore((state) => state.setConnectionStatus);
|
|
143
|
+
return (0, import_react_query.useMutation)({
|
|
466
144
|
mutationKey: walletMutationKeys.connectWallet(mutationKey),
|
|
467
|
-
mutationFn: async ({ wallet, accountAddress, ...
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
145
|
+
mutationFn: async ({ wallet, accountAddress, ...connectArgs }) => {
|
|
146
|
+
try {
|
|
147
|
+
setConnectionStatus("connecting");
|
|
148
|
+
const connectResult = await wallet.features["standard:connect"].connect(connectArgs);
|
|
149
|
+
const connectedSuiAccounts = connectResult.accounts.filter(
|
|
150
|
+
(account) => account.chains.some((chain) => chain.split(":")[0] === "sui")
|
|
151
|
+
);
|
|
152
|
+
const selectedAccount = getSelectedAccount(connectedSuiAccounts, accountAddress);
|
|
153
|
+
setWalletConnected(wallet, connectedSuiAccounts, selectedAccount);
|
|
154
|
+
return { accounts: connectedSuiAccounts };
|
|
155
|
+
} catch (error) {
|
|
156
|
+
setConnectionStatus("disconnected");
|
|
157
|
+
throw error;
|
|
158
|
+
}
|
|
475
159
|
},
|
|
476
160
|
...mutationOptions
|
|
477
161
|
});
|
|
@@ -488,9 +172,9 @@ function getSelectedAccount(connectedAccounts, accountAddress) {
|
|
|
488
172
|
}
|
|
489
173
|
|
|
490
174
|
// src/components/icons/BackIcon.tsx
|
|
491
|
-
var
|
|
175
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
492
176
|
function BackIcon(props) {
|
|
493
|
-
return /* @__PURE__ */ (0,
|
|
177
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { width: 24, height: 24, fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
494
178
|
"path",
|
|
495
179
|
{
|
|
496
180
|
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",
|
|
@@ -500,9 +184,9 @@ function BackIcon(props) {
|
|
|
500
184
|
}
|
|
501
185
|
|
|
502
186
|
// src/components/icons/CloseIcon.tsx
|
|
503
|
-
var
|
|
187
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
504
188
|
function CloseIcon(props) {
|
|
505
|
-
return /* @__PURE__ */ (0,
|
|
189
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { width: 10, height: 10, fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
506
190
|
"path",
|
|
507
191
|
{
|
|
508
192
|
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",
|
|
@@ -511,18 +195,33 @@ function CloseIcon(props) {
|
|
|
511
195
|
) });
|
|
512
196
|
}
|
|
513
197
|
|
|
198
|
+
// src/components/styling/StyleMarker.tsx
|
|
199
|
+
var import_react_slot = require("@radix-ui/react-slot");
|
|
200
|
+
var import_react3 = require("react");
|
|
201
|
+
|
|
202
|
+
// src/constants/styleDataAttribute.ts
|
|
203
|
+
var styleDataAttributeName = "data-dapp-kit";
|
|
204
|
+
var styleDataAttributeSelector = `[${styleDataAttributeName}]`;
|
|
205
|
+
var styleDataAttribute = { [styleDataAttributeName]: "" };
|
|
206
|
+
|
|
207
|
+
// src/components/styling/StyleMarker.tsx
|
|
208
|
+
var import_StyleMarker_css = __toESM(require_StyleMarker_css());
|
|
209
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
210
|
+
var StyleMarker = (0, import_react3.forwardRef)(({ children }, forwardedRef) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_slot.Slot, { ref: forwardedRef, ...styleDataAttribute, children }));
|
|
211
|
+
StyleMarker.displayName = "StyleMarker";
|
|
212
|
+
|
|
514
213
|
// src/components/ui/Heading.tsx
|
|
515
|
-
var
|
|
516
|
-
var
|
|
517
|
-
var
|
|
214
|
+
var import_react_slot2 = require("@radix-ui/react-slot");
|
|
215
|
+
var import_clsx = __toESM(require("clsx"));
|
|
216
|
+
var import_react4 = require("react");
|
|
518
217
|
|
|
519
218
|
// src/components/ui/Heading.css.ts
|
|
520
|
-
var
|
|
521
|
-
var headingVariants = (0,
|
|
219
|
+
var import_createRuntimeFn = require("@vanilla-extract/recipes/createRuntimeFn");
|
|
220
|
+
var headingVariants = (0, import_createRuntimeFn.createRuntimeFn)({ 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: [] });
|
|
522
221
|
|
|
523
222
|
// src/components/ui/Heading.tsx
|
|
524
|
-
var
|
|
525
|
-
var Heading = (0,
|
|
223
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
224
|
+
var Heading = (0, import_react4.forwardRef)(
|
|
526
225
|
({
|
|
527
226
|
children,
|
|
528
227
|
className,
|
|
@@ -533,13 +232,13 @@ var Heading = (0, import_react8.forwardRef)(
|
|
|
533
232
|
truncate,
|
|
534
233
|
...headingProps
|
|
535
234
|
}, forwardedRef) => {
|
|
536
|
-
return /* @__PURE__ */ (0,
|
|
537
|
-
|
|
235
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
236
|
+
import_react_slot2.Slot,
|
|
538
237
|
{
|
|
539
238
|
...headingProps,
|
|
540
239
|
ref: forwardedRef,
|
|
541
|
-
className: (0,
|
|
542
|
-
children: asChild ? children : /* @__PURE__ */ (0,
|
|
240
|
+
className: (0, import_clsx.default)(headingVariants({ size, weight, truncate }), className),
|
|
241
|
+
children: asChild ? children : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Tag, { children })
|
|
543
242
|
}
|
|
544
243
|
);
|
|
545
244
|
}
|
|
@@ -547,35 +246,97 @@ var Heading = (0, import_react8.forwardRef)(
|
|
|
547
246
|
Heading.displayName = "Heading";
|
|
548
247
|
|
|
549
248
|
// src/components/ui/IconButton.tsx
|
|
550
|
-
var
|
|
551
|
-
var
|
|
552
|
-
var
|
|
249
|
+
var import_react_slot3 = require("@radix-ui/react-slot");
|
|
250
|
+
var import_clsx2 = __toESM(require("clsx"));
|
|
251
|
+
var import_react5 = require("react");
|
|
553
252
|
|
|
554
253
|
// src/components/ui/IconButton.css.ts
|
|
555
254
|
var container = "IconButton_container__s6n7bq0";
|
|
556
255
|
|
|
557
256
|
// src/components/ui/IconButton.tsx
|
|
558
|
-
var
|
|
559
|
-
var IconButton = (0,
|
|
257
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
258
|
+
var IconButton = (0, import_react5.forwardRef)(
|
|
560
259
|
({ className, asChild = false, ...props }, forwardedRef) => {
|
|
561
|
-
const Comp = asChild ?
|
|
562
|
-
return /* @__PURE__ */ (0,
|
|
260
|
+
const Comp = asChild ? import_react_slot3.Slot : "button";
|
|
261
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Comp, { ...props, className: (0, import_clsx2.default)(container, className), ref: forwardedRef });
|
|
262
|
+
}
|
|
263
|
+
);
|
|
264
|
+
IconButton.displayName = "Button";
|
|
265
|
+
|
|
266
|
+
// src/components/connect-modal/ConnectModal.css.ts
|
|
267
|
+
var backButtonContainer = "ConnectModal_backButtonContainer__gz8z96";
|
|
268
|
+
var closeButtonContainer = "ConnectModal_closeButtonContainer__gz8z97";
|
|
269
|
+
var content = "ConnectModal_content__gz8z92";
|
|
270
|
+
var overlay = "ConnectModal_overlay__gz8z90";
|
|
271
|
+
var selectedViewContainer = "ConnectModal_selectedViewContainer__gz8z95";
|
|
272
|
+
var title = "ConnectModal_title__gz8z91";
|
|
273
|
+
var viewContainer = "ConnectModal_viewContainer__gz8z94";
|
|
274
|
+
var walletListContainer = "ConnectModal_walletListContainer__gz8z99";
|
|
275
|
+
var walletListContainerWithViewSelected = "ConnectModal_walletListContainerWithViewSelected__gz8z9a";
|
|
276
|
+
var walletListContent = "ConnectModal_walletListContent__gz8z98";
|
|
277
|
+
var whatIsAWalletButton = "ConnectModal_whatIsAWalletButton__gz8z93";
|
|
278
|
+
|
|
279
|
+
// src/components/ui/Button.tsx
|
|
280
|
+
var import_react_slot4 = require("@radix-ui/react-slot");
|
|
281
|
+
var import_clsx3 = __toESM(require("clsx"));
|
|
282
|
+
var import_react6 = require("react");
|
|
283
|
+
|
|
284
|
+
// src/components/ui/Button.css.ts
|
|
285
|
+
var import_createRuntimeFn2 = require("@vanilla-extract/recipes/createRuntimeFn");
|
|
286
|
+
var buttonVariants = (0, import_createRuntimeFn2.createRuntimeFn)({ 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: [] });
|
|
287
|
+
|
|
288
|
+
// src/components/ui/Button.tsx
|
|
289
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
290
|
+
var Button = (0, import_react6.forwardRef)(
|
|
291
|
+
({ className, variant, size, asChild = false, ...props }, forwardedRef) => {
|
|
292
|
+
const Comp = asChild ? import_react_slot4.Slot : "button";
|
|
293
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
294
|
+
Comp,
|
|
295
|
+
{
|
|
296
|
+
...props,
|
|
297
|
+
className: (0, import_clsx3.default)(buttonVariants({ variant, size }), className),
|
|
298
|
+
ref: forwardedRef
|
|
299
|
+
}
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
);
|
|
303
|
+
Button.displayName = "Button";
|
|
304
|
+
|
|
305
|
+
// src/components/ui/Text.tsx
|
|
306
|
+
var import_react_slot5 = require("@radix-ui/react-slot");
|
|
307
|
+
var import_clsx4 = __toESM(require("clsx"));
|
|
308
|
+
var import_react7 = require("react");
|
|
309
|
+
|
|
310
|
+
// src/components/ui/Text.css.ts
|
|
311
|
+
var import_createRuntimeFn3 = require("@vanilla-extract/recipes/createRuntimeFn");
|
|
312
|
+
var textVariants = (0, import_createRuntimeFn3.createRuntimeFn)({ 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: [] });
|
|
313
|
+
|
|
314
|
+
// src/components/ui/Text.tsx
|
|
315
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
316
|
+
var Text = (0, import_react7.forwardRef)(
|
|
317
|
+
({
|
|
318
|
+
children,
|
|
319
|
+
className,
|
|
320
|
+
asChild = false,
|
|
321
|
+
as: Tag = "div",
|
|
322
|
+
size,
|
|
323
|
+
weight,
|
|
324
|
+
color,
|
|
325
|
+
mono,
|
|
326
|
+
...textProps
|
|
327
|
+
}, forwardedRef) => {
|
|
328
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
329
|
+
import_react_slot5.Slot,
|
|
330
|
+
{
|
|
331
|
+
...textProps,
|
|
332
|
+
ref: forwardedRef,
|
|
333
|
+
className: (0, import_clsx4.default)(textVariants({ size, weight, color, mono }), className),
|
|
334
|
+
children: asChild ? children : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Tag, { children })
|
|
335
|
+
}
|
|
336
|
+
);
|
|
563
337
|
}
|
|
564
338
|
);
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
// src/components/connect-modal/ConnectModal.css.ts
|
|
568
|
-
var backButtonContainer = "ConnectModal_backButtonContainer__gz8z96";
|
|
569
|
-
var closeButtonContainer = "ConnectModal_closeButtonContainer__gz8z97";
|
|
570
|
-
var content = "ConnectModal_content__gz8z92";
|
|
571
|
-
var overlay = "ConnectModal_overlay__gz8z90";
|
|
572
|
-
var selectedViewContainer = "ConnectModal_selectedViewContainer__gz8z95";
|
|
573
|
-
var title = "ConnectModal_title__gz8z91";
|
|
574
|
-
var viewContainer = "ConnectModal_viewContainer__gz8z94";
|
|
575
|
-
var walletListContainer = "ConnectModal_walletListContainer__gz8z99";
|
|
576
|
-
var walletListContainerWithViewSelected = "ConnectModal_walletListContainerWithViewSelected__gz8z9a";
|
|
577
|
-
var walletListContent = "ConnectModal_walletListContent__gz8z98";
|
|
578
|
-
var whatIsAWalletButton = "ConnectModal_whatIsAWalletButton__gz8z93";
|
|
339
|
+
Text.displayName = "Text";
|
|
579
340
|
|
|
580
341
|
// src/components/connect-modal/views/ConnectionStatus.css.ts
|
|
581
342
|
var connectionStatus = "ConnectionStatus_connectionStatus__nckm2d3";
|
|
@@ -585,14 +346,14 @@ var title2 = "ConnectionStatus_title__nckm2d2";
|
|
|
585
346
|
var walletIcon = "ConnectionStatus_walletIcon__nckm2d1";
|
|
586
347
|
|
|
587
348
|
// src/components/connect-modal/views/ConnectionStatus.tsx
|
|
588
|
-
var
|
|
349
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
589
350
|
function ConnectionStatus({
|
|
590
351
|
selectedWallet,
|
|
591
352
|
hadConnectionError,
|
|
592
353
|
onRetryConnection
|
|
593
354
|
}) {
|
|
594
|
-
return /* @__PURE__ */ (0,
|
|
595
|
-
/* @__PURE__ */ (0,
|
|
355
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: container2, children: [
|
|
356
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
596
357
|
"img",
|
|
597
358
|
{
|
|
598
359
|
className: walletIcon,
|
|
@@ -600,12 +361,12 @@ function ConnectionStatus({
|
|
|
600
361
|
alt: `${selectedWallet.name} logo`
|
|
601
362
|
}
|
|
602
363
|
),
|
|
603
|
-
/* @__PURE__ */ (0,
|
|
364
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: title2, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Heading, { as: "h2", size: "xl", children: [
|
|
604
365
|
"Opening ",
|
|
605
366
|
selectedWallet.name
|
|
606
367
|
] }) }),
|
|
607
|
-
/* @__PURE__ */ (0,
|
|
608
|
-
hadConnectionError ? /* @__PURE__ */ (0,
|
|
368
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: connectionStatus, children: hadConnectionError ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { color: "danger", children: "Connection failed" }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Text, { color: "muted", children: "Confirm connection in the wallet..." }) }),
|
|
369
|
+
hadConnectionError ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: retryButtonContainer, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Button, { type: "button", variant: "outline", onClick: () => onRetryConnection(selectedWallet), children: "Retry Connection" }) }) : null
|
|
609
370
|
] });
|
|
610
371
|
}
|
|
611
372
|
|
|
@@ -613,11 +374,11 @@ function ConnectionStatus({
|
|
|
613
374
|
var container3 = "InfoSection_container__1wtioi70";
|
|
614
375
|
|
|
615
376
|
// src/components/connect-modal/InfoSection.tsx
|
|
616
|
-
var
|
|
377
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
617
378
|
function InfoSection({ title: title3, children }) {
|
|
618
|
-
return /* @__PURE__ */ (0,
|
|
619
|
-
/* @__PURE__ */ (0,
|
|
620
|
-
/* @__PURE__ */ (0,
|
|
379
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("section", { className: container3, children: [
|
|
380
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Heading, { as: "h3", size: "sm", weight: "normal", children: title3 }),
|
|
381
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Text, { weight: "medium", color: "muted", children })
|
|
621
382
|
] });
|
|
622
383
|
}
|
|
623
384
|
|
|
@@ -627,15 +388,15 @@ var content2 = "GettingStarted_content__1fp07e11";
|
|
|
627
388
|
var installButtonContainer = "GettingStarted_installButtonContainer__1fp07e12";
|
|
628
389
|
|
|
629
390
|
// src/components/connect-modal/views/GettingStarted.tsx
|
|
630
|
-
var
|
|
391
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
631
392
|
function GettingStarted() {
|
|
632
|
-
return /* @__PURE__ */ (0,
|
|
633
|
-
/* @__PURE__ */ (0,
|
|
634
|
-
/* @__PURE__ */ (0,
|
|
635
|
-
/* @__PURE__ */ (0,
|
|
636
|
-
/* @__PURE__ */ (0,
|
|
637
|
-
/* @__PURE__ */ (0,
|
|
638
|
-
/* @__PURE__ */ (0,
|
|
393
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: container4, children: [
|
|
394
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Heading, { as: "h2", children: "Get Started with Sui" }),
|
|
395
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: content2, children: [
|
|
396
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(InfoSection, { title: "Install the Sui Wallet Extension", children: "We recommend pinning Sui Wallet to your taskbar for quicker access." }),
|
|
397
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(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." }),
|
|
398
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(InfoSection, { title: "Refresh Your Browser", children: "Once you set up your wallet, refresh this window browser to load up the extension." }),
|
|
399
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: installButtonContainer, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Button, { variant: "outline", asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
639
400
|
"a",
|
|
640
401
|
{
|
|
641
402
|
href: "https://chrome.google.com/webstore/detail/sui-wallet/opcgpfmipidbgpenhmajoajpbobppdil",
|
|
@@ -653,13 +414,13 @@ var container5 = "WhatIsAWallet_container__1ktpkq90";
|
|
|
653
414
|
var content3 = "WhatIsAWallet_content__1ktpkq91";
|
|
654
415
|
|
|
655
416
|
// src/components/connect-modal/views/WhatIsAWallet.tsx
|
|
656
|
-
var
|
|
417
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
657
418
|
function WhatIsAWallet() {
|
|
658
|
-
return /* @__PURE__ */ (0,
|
|
659
|
-
/* @__PURE__ */ (0,
|
|
660
|
-
/* @__PURE__ */ (0,
|
|
661
|
-
/* @__PURE__ */ (0,
|
|
662
|
-
/* @__PURE__ */ (0,
|
|
419
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: container5, children: [
|
|
420
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Heading, { as: "h2", children: "What is a Wallet" }),
|
|
421
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: content3, children: [
|
|
422
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(InfoSection, { title: "Easy Login", children: "No need to create new accounts and passwords for every website. Just connect your wallet and get going." }),
|
|
423
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(InfoSection, { title: "Store your Digital Assets", children: "Send, receive, store, and display your digital assets like NFTs & coins." })
|
|
663
424
|
] })
|
|
664
425
|
] });
|
|
665
426
|
}
|
|
@@ -670,11 +431,11 @@ function useWallets() {
|
|
|
670
431
|
}
|
|
671
432
|
|
|
672
433
|
// src/components/icons/SuiIcon.tsx
|
|
673
|
-
var
|
|
434
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
674
435
|
function SuiIcon(props) {
|
|
675
|
-
return /* @__PURE__ */ (0,
|
|
676
|
-
/* @__PURE__ */ (0,
|
|
677
|
-
/* @__PURE__ */ (0,
|
|
436
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("svg", { width: 28, height: 28, fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [
|
|
437
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("rect", { width: 28, height: 28, rx: 6, fill: "#6FBCF0" }),
|
|
438
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
678
439
|
"path",
|
|
679
440
|
{
|
|
680
441
|
fillRule: "evenodd",
|
|
@@ -690,7 +451,7 @@ function SuiIcon(props) {
|
|
|
690
451
|
var container6 = "WalletList_container__1v2s6cz0";
|
|
691
452
|
|
|
692
453
|
// src/components/connect-modal/wallet-list/WalletListItem.tsx
|
|
693
|
-
var
|
|
454
|
+
var import_clsx5 = require("clsx");
|
|
694
455
|
|
|
695
456
|
// src/components/connect-modal/wallet-list/WalletListItem.css.ts
|
|
696
457
|
var container7 = "WalletListItem_container__1dqqtqs0";
|
|
@@ -699,27 +460,27 @@ var walletIcon2 = "WalletListItem_walletIcon__1dqqtqs3";
|
|
|
699
460
|
var walletItem = "WalletListItem_walletItem__1dqqtqs1";
|
|
700
461
|
|
|
701
462
|
// src/components/connect-modal/wallet-list/WalletListItem.tsx
|
|
702
|
-
var
|
|
463
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
703
464
|
function WalletListItem({ name, icon, onClick, isSelected = false }) {
|
|
704
|
-
return /* @__PURE__ */ (0,
|
|
465
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("li", { className: container7, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
705
466
|
"button",
|
|
706
467
|
{
|
|
707
|
-
className: (0,
|
|
468
|
+
className: (0, import_clsx5.clsx)(walletItem, { [selectedWalletItem]: isSelected }),
|
|
708
469
|
type: "button",
|
|
709
470
|
onClick,
|
|
710
471
|
children: [
|
|
711
|
-
typeof icon === "string" ? /* @__PURE__ */ (0,
|
|
712
|
-
/* @__PURE__ */ (0,
|
|
472
|
+
typeof icon === "string" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("img", { className: walletIcon2, src: icon, alt: `${name} logo` }) : icon,
|
|
473
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Heading, { size: "md", truncate: true, asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { children: name }) })
|
|
713
474
|
]
|
|
714
475
|
}
|
|
715
476
|
) });
|
|
716
477
|
}
|
|
717
478
|
|
|
718
479
|
// src/components/connect-modal/wallet-list/WalletList.tsx
|
|
719
|
-
var
|
|
480
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
720
481
|
function WalletList({ selectedWalletName, onPlaceholderClick, onSelect }) {
|
|
721
482
|
const wallets = useWallets();
|
|
722
|
-
return /* @__PURE__ */ (0,
|
|
483
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("ul", { className: container6, children: wallets.length > 0 ? wallets.map((wallet) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
723
484
|
WalletListItem,
|
|
724
485
|
{
|
|
725
486
|
name: wallet.name,
|
|
@@ -728,11 +489,11 @@ function WalletList({ selectedWalletName, onPlaceholderClick, onSelect }) {
|
|
|
728
489
|
onClick: () => onSelect(wallet)
|
|
729
490
|
},
|
|
730
491
|
wallet.name
|
|
731
|
-
)) : /* @__PURE__ */ (0,
|
|
492
|
+
)) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
732
493
|
WalletListItem,
|
|
733
494
|
{
|
|
734
495
|
name: "Sui Wallet",
|
|
735
|
-
icon: /* @__PURE__ */ (0,
|
|
496
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SuiIcon, {}),
|
|
736
497
|
onClick: onPlaceholderClick,
|
|
737
498
|
isSelected: true
|
|
738
499
|
}
|
|
@@ -740,11 +501,11 @@ function WalletList({ selectedWalletName, onPlaceholderClick, onSelect }) {
|
|
|
740
501
|
}
|
|
741
502
|
|
|
742
503
|
// src/components/connect-modal/ConnectModal.tsx
|
|
743
|
-
var
|
|
504
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
744
505
|
function ConnectModal({ trigger, open, defaultOpen, onOpenChange }) {
|
|
745
|
-
const [isModalOpen, setModalOpen] = (0,
|
|
746
|
-
const [currentView, setCurrentView] = (0,
|
|
747
|
-
const [selectedWallet, setSelectedWallet] = (0,
|
|
506
|
+
const [isModalOpen, setModalOpen] = (0, import_react8.useState)(open ?? defaultOpen);
|
|
507
|
+
const [currentView, setCurrentView] = (0, import_react8.useState)();
|
|
508
|
+
const [selectedWallet, setSelectedWallet] = (0, import_react8.useState)();
|
|
748
509
|
const { mutate, isError } = useConnectWallet();
|
|
749
510
|
const resetSelection = () => {
|
|
750
511
|
setSelectedWallet(void 0);
|
|
@@ -769,13 +530,13 @@ function ConnectModal({ trigger, open, defaultOpen, onOpenChange }) {
|
|
|
769
530
|
let modalContent;
|
|
770
531
|
switch (currentView) {
|
|
771
532
|
case "what-is-a-wallet":
|
|
772
|
-
modalContent = /* @__PURE__ */ (0,
|
|
533
|
+
modalContent = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(WhatIsAWallet, {});
|
|
773
534
|
break;
|
|
774
535
|
case "getting-started":
|
|
775
|
-
modalContent = /* @__PURE__ */ (0,
|
|
536
|
+
modalContent = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(GettingStarted, {});
|
|
776
537
|
break;
|
|
777
538
|
case "connection-status":
|
|
778
|
-
modalContent = /* @__PURE__ */ (0,
|
|
539
|
+
modalContent = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
779
540
|
ConnectionStatus,
|
|
780
541
|
{
|
|
781
542
|
selectedWallet,
|
|
@@ -785,62 +546,358 @@ function ConnectModal({ trigger, open, defaultOpen, onOpenChange }) {
|
|
|
785
546
|
);
|
|
786
547
|
break;
|
|
787
548
|
default:
|
|
788
|
-
modalContent = /* @__PURE__ */ (0,
|
|
549
|
+
modalContent = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(WhatIsAWallet, {});
|
|
789
550
|
}
|
|
790
|
-
return /* @__PURE__ */ (0,
|
|
791
|
-
/* @__PURE__ */ (0,
|
|
792
|
-
/* @__PURE__ */ (0,
|
|
793
|
-
/* @__PURE__ */ (0,
|
|
551
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Dialog.Root, { open: open ?? isModalOpen, onOpenChange: handleOpenChange, children: [
|
|
552
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(StyleMarker, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Dialog.Trigger, { asChild: true, children: trigger }) }),
|
|
553
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Dialog.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(StyleMarker, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Dialog.Overlay, { className: overlay, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Dialog.Content, { className: content, "aria-describedby": void 0, children: [
|
|
554
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
555
|
+
"div",
|
|
556
|
+
{
|
|
557
|
+
className: (0, import_clsx6.default)(walletListContainer, {
|
|
558
|
+
[walletListContainerWithViewSelected]: !!currentView
|
|
559
|
+
}),
|
|
560
|
+
children: [
|
|
561
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: walletListContent, children: [
|
|
562
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Dialog.Title, { className: title, asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Heading, { as: "h2", children: "Connect a Wallet" }) }),
|
|
563
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
564
|
+
WalletList,
|
|
565
|
+
{
|
|
566
|
+
selectedWalletName: selectedWallet?.name,
|
|
567
|
+
onPlaceholderClick: () => setCurrentView("getting-started"),
|
|
568
|
+
onSelect: (wallet) => {
|
|
569
|
+
if (selectedWallet?.name !== wallet.name) {
|
|
570
|
+
setSelectedWallet(wallet);
|
|
571
|
+
connectWallet(wallet);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
)
|
|
576
|
+
] }),
|
|
577
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
578
|
+
"button",
|
|
579
|
+
{
|
|
580
|
+
className: whatIsAWalletButton,
|
|
581
|
+
onClick: () => setCurrentView("what-is-a-wallet"),
|
|
582
|
+
type: "button",
|
|
583
|
+
children: "What is a Wallet?"
|
|
584
|
+
}
|
|
585
|
+
)
|
|
586
|
+
]
|
|
587
|
+
}
|
|
588
|
+
),
|
|
589
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
794
590
|
"div",
|
|
795
591
|
{
|
|
796
|
-
className: (0,
|
|
797
|
-
[
|
|
798
|
-
}),
|
|
799
|
-
children: [
|
|
800
|
-
/* @__PURE__ */ (0,
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
592
|
+
className: (0, import_clsx6.default)(viewContainer, {
|
|
593
|
+
[selectedViewContainer]: !!currentView
|
|
594
|
+
}),
|
|
595
|
+
children: [
|
|
596
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: backButtonContainer, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(IconButton, { type: "button", "aria-label": "Back", onClick: () => resetSelection(), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(BackIcon, {}) }) }),
|
|
597
|
+
modalContent
|
|
598
|
+
]
|
|
599
|
+
}
|
|
600
|
+
),
|
|
601
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Dialog.Close, { className: closeButtonContainer, asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(IconButton, { type: "button", "aria-label": "Close", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CloseIcon, {}) }) })
|
|
602
|
+
] }) }) }) })
|
|
603
|
+
] });
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
// src/hooks/wallet/useCurrentAccount.ts
|
|
607
|
+
function useCurrentAccount() {
|
|
608
|
+
return useWalletStore((state) => state.currentAccount);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// src/components/AccountDropdownMenu.tsx
|
|
612
|
+
var import_utils = require("@mysten/sui.js/utils");
|
|
613
|
+
var DropdownMenu = __toESM(require("@radix-ui/react-dropdown-menu"));
|
|
614
|
+
var import_clsx7 = __toESM(require("clsx"));
|
|
615
|
+
|
|
616
|
+
// src/hooks/useSuiClientQuery.ts
|
|
617
|
+
var import_react_query2 = require("@tanstack/react-query");
|
|
618
|
+
|
|
619
|
+
// src/hooks/useSuiClient.ts
|
|
620
|
+
var import_react10 = require("react");
|
|
621
|
+
|
|
622
|
+
// src/components/SuiClientProvider.tsx
|
|
623
|
+
var import_client = require("@mysten/sui.js/client");
|
|
624
|
+
var import_react9 = require("react");
|
|
625
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
626
|
+
var SuiClientContext = (0, import_react9.createContext)(null);
|
|
627
|
+
var DEFAULT_NETWORKS = {
|
|
628
|
+
localnet: { url: (0, import_client.getFullnodeUrl)("localnet") }
|
|
629
|
+
};
|
|
630
|
+
var DEFAULT_CREATE_CLIENT = function createClient(_name, config) {
|
|
631
|
+
if ((0, import_client.isSuiClient)(config)) {
|
|
632
|
+
return config;
|
|
633
|
+
}
|
|
634
|
+
return new import_client.SuiClient(config);
|
|
635
|
+
};
|
|
636
|
+
function SuiClientProvider(props) {
|
|
637
|
+
const { onNetworkChange, network, children } = props;
|
|
638
|
+
const networks = props.networks ?? DEFAULT_NETWORKS;
|
|
639
|
+
const createClient2 = props.createClient ?? DEFAULT_CREATE_CLIENT;
|
|
640
|
+
const [selectedNetwork, setSelectedNetwork] = (0, import_react9.useState)(
|
|
641
|
+
props.network ?? props.defaultNetwork ?? Object.keys(networks)[0]
|
|
642
|
+
);
|
|
643
|
+
const currentNetwork = props.network ?? selectedNetwork;
|
|
644
|
+
const client = (0, import_react9.useMemo)(() => {
|
|
645
|
+
return createClient2(currentNetwork, networks[currentNetwork]);
|
|
646
|
+
}, [createClient2, currentNetwork, networks]);
|
|
647
|
+
const ctx = (0, import_react9.useMemo)(() => {
|
|
648
|
+
return {
|
|
649
|
+
client,
|
|
650
|
+
networks,
|
|
651
|
+
network: currentNetwork,
|
|
652
|
+
config: networks[currentNetwork] instanceof import_client.SuiClient ? null : networks[currentNetwork],
|
|
653
|
+
selectNetwork: (newNetwork) => {
|
|
654
|
+
if (currentNetwork === newNetwork) {
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
if (!network && newNetwork !== selectedNetwork) {
|
|
658
|
+
setSelectedNetwork(newNetwork);
|
|
659
|
+
}
|
|
660
|
+
onNetworkChange?.(newNetwork);
|
|
661
|
+
}
|
|
662
|
+
};
|
|
663
|
+
}, [client, networks, selectedNetwork, currentNetwork, network, onNetworkChange]);
|
|
664
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SuiClientContext.Provider, { value: ctx, children });
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
// src/hooks/useSuiClient.ts
|
|
668
|
+
function useSuiClientContext() {
|
|
669
|
+
const suiClient = (0, import_react10.useContext)(SuiClientContext);
|
|
670
|
+
if (!suiClient) {
|
|
671
|
+
throw new Error(
|
|
672
|
+
"Could not find SuiClientContext. Ensure that you have set up the SuiClientProvider"
|
|
673
|
+
);
|
|
674
|
+
}
|
|
675
|
+
return suiClient;
|
|
676
|
+
}
|
|
677
|
+
function useSuiClient() {
|
|
678
|
+
return useSuiClientContext().client;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
// src/hooks/useSuiClientQuery.ts
|
|
682
|
+
function useSuiClientQuery(...args) {
|
|
683
|
+
const [method, params, { queryKey = [], ...options } = {}] = args;
|
|
684
|
+
const suiContext = useSuiClientContext();
|
|
685
|
+
return (0, import_react_query2.useQuery)({
|
|
686
|
+
...options,
|
|
687
|
+
queryKey: [suiContext.network, method, params, ...queryKey],
|
|
688
|
+
queryFn: async () => {
|
|
689
|
+
return await suiContext.client[method](params);
|
|
690
|
+
}
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
// src/hooks/useResolveSuiNSNames.ts
|
|
695
|
+
function useResolveSuiNSName(address, options) {
|
|
696
|
+
return useSuiClientQuery(
|
|
697
|
+
"resolveNameServiceNames",
|
|
698
|
+
{
|
|
699
|
+
address,
|
|
700
|
+
limit: 1
|
|
701
|
+
},
|
|
702
|
+
{
|
|
703
|
+
...options,
|
|
704
|
+
refetchOnWindowFocus: false,
|
|
705
|
+
retry: false,
|
|
706
|
+
select: (data) => data.data.length > 0 ? data.data[0] : null,
|
|
707
|
+
enabled: !!address && options?.enabled !== false
|
|
708
|
+
}
|
|
709
|
+
);
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
// src/hooks/wallet/useAccounts.ts
|
|
713
|
+
function useAccounts() {
|
|
714
|
+
return useWalletStore((state) => state.accounts);
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
// src/hooks/wallet/useDisconnectWallet.ts
|
|
718
|
+
var import_react_query3 = require("@tanstack/react-query");
|
|
719
|
+
|
|
720
|
+
// src/errors/walletErrors.ts
|
|
721
|
+
var WalletNotConnectedError = class extends Error {
|
|
722
|
+
};
|
|
723
|
+
var WalletNoAccountSelectedError = class extends Error {
|
|
724
|
+
};
|
|
725
|
+
var WalletFeatureNotSupportedError = class extends Error {
|
|
726
|
+
};
|
|
727
|
+
var WalletAccountNotFoundError = class extends Error {
|
|
728
|
+
};
|
|
729
|
+
|
|
730
|
+
// src/hooks/wallet/useCurrentWallet.ts
|
|
731
|
+
function useCurrentWallet() {
|
|
732
|
+
const currentWallet = useWalletStore((state) => state.currentWallet);
|
|
733
|
+
const connectionStatus2 = useWalletStore((state) => state.connectionStatus);
|
|
734
|
+
switch (connectionStatus2) {
|
|
735
|
+
case "connecting":
|
|
736
|
+
return {
|
|
737
|
+
connectionStatus: connectionStatus2,
|
|
738
|
+
currentWallet: null,
|
|
739
|
+
isDisconnected: false,
|
|
740
|
+
isConnecting: true,
|
|
741
|
+
isConnected: false
|
|
742
|
+
};
|
|
743
|
+
case "disconnected":
|
|
744
|
+
return {
|
|
745
|
+
connectionStatus: connectionStatus2,
|
|
746
|
+
currentWallet: null,
|
|
747
|
+
isDisconnected: true,
|
|
748
|
+
isConnecting: false,
|
|
749
|
+
isConnected: false
|
|
750
|
+
};
|
|
751
|
+
case "connected": {
|
|
752
|
+
return {
|
|
753
|
+
connectionStatus: connectionStatus2,
|
|
754
|
+
currentWallet,
|
|
755
|
+
isDisconnected: false,
|
|
756
|
+
isConnecting: false,
|
|
757
|
+
isConnected: true
|
|
758
|
+
};
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
// src/hooks/wallet/useDisconnectWallet.ts
|
|
764
|
+
function useDisconnectWallet({
|
|
765
|
+
mutationKey,
|
|
766
|
+
...mutationOptions
|
|
767
|
+
} = {}) {
|
|
768
|
+
const { currentWallet } = useCurrentWallet();
|
|
769
|
+
const setWalletDisconnected = useWalletStore((state) => state.setWalletDisconnected);
|
|
770
|
+
return (0, import_react_query3.useMutation)({
|
|
771
|
+
mutationKey: walletMutationKeys.disconnectWallet(mutationKey),
|
|
772
|
+
mutationFn: async () => {
|
|
773
|
+
if (!currentWallet) {
|
|
774
|
+
throw new WalletNotConnectedError("No wallet is connected.");
|
|
775
|
+
}
|
|
776
|
+
try {
|
|
777
|
+
await currentWallet.features["standard:disconnect"]?.disconnect();
|
|
778
|
+
} catch (error) {
|
|
779
|
+
console.error("Failed to disconnect the application from the current wallet.", error);
|
|
780
|
+
}
|
|
781
|
+
setWalletDisconnected();
|
|
782
|
+
},
|
|
783
|
+
...mutationOptions
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
// src/hooks/wallet/useSwitchAccount.ts
|
|
788
|
+
var import_react_query4 = require("@tanstack/react-query");
|
|
789
|
+
function useSwitchAccount({
|
|
790
|
+
mutationKey,
|
|
791
|
+
...mutationOptions
|
|
792
|
+
} = {}) {
|
|
793
|
+
const { currentWallet } = useCurrentWallet();
|
|
794
|
+
const setAccountSwitched = useWalletStore((state) => state.setAccountSwitched);
|
|
795
|
+
return (0, import_react_query4.useMutation)({
|
|
796
|
+
mutationKey: walletMutationKeys.switchAccount(mutationKey),
|
|
797
|
+
mutationFn: async ({ account }) => {
|
|
798
|
+
if (!currentWallet) {
|
|
799
|
+
throw new WalletNotConnectedError("No wallet is connected.");
|
|
800
|
+
}
|
|
801
|
+
const accountToSelect = currentWallet.accounts.find(
|
|
802
|
+
(walletAccount) => walletAccount.address === account.address
|
|
803
|
+
);
|
|
804
|
+
if (!accountToSelect) {
|
|
805
|
+
throw new WalletAccountNotFoundError(
|
|
806
|
+
`No account with address ${account.address} is connected to ${currentWallet.name}.`
|
|
807
|
+
);
|
|
808
|
+
}
|
|
809
|
+
setAccountSwitched(accountToSelect);
|
|
810
|
+
},
|
|
811
|
+
...mutationOptions
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
// src/components/AccountDropdownMenu.css.ts
|
|
816
|
+
var connectedAccount = "AccountDropdownMenu_connectedAccount__div2ql0";
|
|
817
|
+
var menuContent = "AccountDropdownMenu_menuContent__div2ql1";
|
|
818
|
+
var menuItem = "AccountDropdownMenu_menuItem__div2ql2";
|
|
819
|
+
var separator = "AccountDropdownMenu_separator__div2ql4";
|
|
820
|
+
var switchAccountMenuItem = "AccountDropdownMenu_switchAccountMenuItem__div2ql3";
|
|
821
|
+
|
|
822
|
+
// src/components/icons/CheckIcon.tsx
|
|
823
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
824
|
+
function CheckIcon(props) {
|
|
825
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "none", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
826
|
+
"path",
|
|
827
|
+
{
|
|
828
|
+
fill: "currentColor",
|
|
829
|
+
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"
|
|
830
|
+
}
|
|
831
|
+
) });
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
// src/components/icons/ChevronIcon.tsx
|
|
835
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
836
|
+
function ChevronIcon(props) {
|
|
837
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "none", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
838
|
+
"path",
|
|
839
|
+
{
|
|
840
|
+
stroke: "#A0B6C3",
|
|
841
|
+
strokeLinecap: "round",
|
|
842
|
+
strokeLinejoin: "round",
|
|
843
|
+
strokeWidth: 1.5,
|
|
844
|
+
d: "m4 6 4 4 4-4"
|
|
845
|
+
}
|
|
846
|
+
) });
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
// src/components/AccountDropdownMenu.tsx
|
|
850
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
851
|
+
function AccountDropdownMenu({ currentAccount }) {
|
|
852
|
+
const { mutate: disconnectWallet } = useDisconnectWallet();
|
|
853
|
+
const { data: domain } = useResolveSuiNSName(
|
|
854
|
+
currentAccount.label ? null : currentAccount.address
|
|
855
|
+
);
|
|
856
|
+
const accounts = useAccounts();
|
|
857
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(DropdownMenu.Root, { modal: false, children: [
|
|
858
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(StyleMarker, { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(Button, { size: "lg", className: connectedAccount, children: [
|
|
859
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Text, { mono: true, weight: "bold", children: currentAccount.label ?? domain ?? (0, import_utils.formatAddress)(currentAccount.address) }),
|
|
860
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ChevronIcon, {})
|
|
861
|
+
] }) }) }),
|
|
862
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(DropdownMenu.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(StyleMarker, { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(DropdownMenu.Content, { className: menuContent, children: [
|
|
863
|
+
accounts.map((account) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
864
|
+
AccountDropdownMenuItem,
|
|
865
|
+
{
|
|
866
|
+
account,
|
|
867
|
+
active: currentAccount.address === account.address
|
|
868
|
+
},
|
|
869
|
+
account.address
|
|
870
|
+
)),
|
|
871
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(DropdownMenu.Separator, { className: separator }),
|
|
872
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
873
|
+
DropdownMenu.Item,
|
|
830
874
|
{
|
|
831
|
-
className: (0, import_clsx7.default)(
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
children: [
|
|
835
|
-
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: backButtonContainer, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(IconButton, { type: "button", "aria-label": "Back", onClick: () => resetSelection(), children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(BackIcon, {}) }) }),
|
|
836
|
-
modalContent
|
|
837
|
-
]
|
|
875
|
+
className: (0, import_clsx7.default)(menuItem),
|
|
876
|
+
onSelect: () => disconnectWallet(),
|
|
877
|
+
children: "Disconnect"
|
|
838
878
|
}
|
|
839
|
-
)
|
|
840
|
-
|
|
841
|
-
] }) }) }) })
|
|
879
|
+
)
|
|
880
|
+
] }) }) })
|
|
842
881
|
] });
|
|
843
882
|
}
|
|
883
|
+
function AccountDropdownMenuItem({
|
|
884
|
+
account,
|
|
885
|
+
active
|
|
886
|
+
}) {
|
|
887
|
+
const { mutate: switchAccount } = useSwitchAccount();
|
|
888
|
+
const { data: domain } = useResolveSuiNSName(account.label ? null : account.address);
|
|
889
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
890
|
+
DropdownMenu.Item,
|
|
891
|
+
{
|
|
892
|
+
className: (0, import_clsx7.default)(menuItem, switchAccountMenuItem),
|
|
893
|
+
onSelect: () => switchAccount({ account }),
|
|
894
|
+
children: [
|
|
895
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Text, { mono: true, children: account.label ?? domain ?? (0, import_utils.formatAddress)(account.address) }),
|
|
896
|
+
active ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(CheckIcon, {}) : null
|
|
897
|
+
]
|
|
898
|
+
}
|
|
899
|
+
);
|
|
900
|
+
}
|
|
844
901
|
|
|
845
902
|
// src/components/ConnectButton.tsx
|
|
846
903
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
@@ -859,25 +916,35 @@ var import_react15 = require("react");
|
|
|
859
916
|
var import_react11 = require("react");
|
|
860
917
|
function useAutoConnectWallet(autoConnectEnabled) {
|
|
861
918
|
const { mutate: connectWallet } = useConnectWallet();
|
|
862
|
-
const
|
|
919
|
+
const setAutoConnectionStatus = useWalletStore((state) => state.setAutoConnectionStatus);
|
|
863
920
|
const lastConnectedWalletName = useWalletStore((state) => state.lastConnectedWalletName);
|
|
864
921
|
const lastConnectedAccountAddress = useWalletStore((state) => state.lastConnectedAccountAddress);
|
|
922
|
+
const wallets = useWallets();
|
|
923
|
+
const { isDisconnected } = useCurrentWallet();
|
|
865
924
|
(0, import_react11.useEffect)(() => {
|
|
866
|
-
if (!autoConnectEnabled || !lastConnectedWalletName)
|
|
925
|
+
if (!autoConnectEnabled || !lastConnectedWalletName || !lastConnectedAccountAddress || !isDisconnected) {
|
|
867
926
|
return;
|
|
927
|
+
}
|
|
868
928
|
const wallet = wallets.find((wallet2) => wallet2.name === lastConnectedWalletName);
|
|
869
929
|
if (wallet) {
|
|
870
|
-
connectWallet(
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
930
|
+
connectWallet(
|
|
931
|
+
{
|
|
932
|
+
wallet,
|
|
933
|
+
accountAddress: lastConnectedAccountAddress,
|
|
934
|
+
silent: true
|
|
935
|
+
},
|
|
936
|
+
{
|
|
937
|
+
onSettled: () => setAutoConnectionStatus("settled")
|
|
938
|
+
}
|
|
939
|
+
);
|
|
875
940
|
}
|
|
876
941
|
}, [
|
|
877
942
|
autoConnectEnabled,
|
|
878
943
|
connectWallet,
|
|
944
|
+
isDisconnected,
|
|
879
945
|
lastConnectedAccountAddress,
|
|
880
946
|
lastConnectedWalletName,
|
|
947
|
+
setAutoConnectionStatus,
|
|
881
948
|
wallets
|
|
882
949
|
]);
|
|
883
950
|
}
|
|
@@ -1001,7 +1068,7 @@ function registerUnsafeBurnerWallet(suiClient) {
|
|
|
1001
1068
|
// src/hooks/wallet/useWalletPropertiesChanged.ts
|
|
1002
1069
|
var import_react13 = require("react");
|
|
1003
1070
|
function useWalletPropertiesChanged() {
|
|
1004
|
-
const currentWallet = useCurrentWallet();
|
|
1071
|
+
const { currentWallet } = useCurrentWallet();
|
|
1005
1072
|
const updateWalletAccounts = useWalletStore((state) => state.updateWalletAccounts);
|
|
1006
1073
|
(0, import_react13.useEffect)(() => {
|
|
1007
1074
|
const unsubscribeFromEvents = currentWallet?.features["standard:events"].on(
|
|
@@ -1120,7 +1187,12 @@ var lightTheme = {
|
|
|
1120
1187
|
// src/walletStore.ts
|
|
1121
1188
|
var import_zustand2 = require("zustand");
|
|
1122
1189
|
var import_middleware = require("zustand/middleware");
|
|
1123
|
-
function createWalletStore({
|
|
1190
|
+
function createWalletStore({
|
|
1191
|
+
wallets,
|
|
1192
|
+
storage,
|
|
1193
|
+
storageKey,
|
|
1194
|
+
autoConnect
|
|
1195
|
+
}) {
|
|
1124
1196
|
return (0, import_zustand2.createStore)()(
|
|
1125
1197
|
(0, import_middleware.persist)(
|
|
1126
1198
|
(set, get) => ({
|
|
@@ -1131,13 +1203,25 @@ function createWalletStore({ wallets, storage, storageKey }) {
|
|
|
1131
1203
|
lastConnectedAccountAddress: null,
|
|
1132
1204
|
lastConnectedWalletName: null,
|
|
1133
1205
|
connectionStatus: "disconnected",
|
|
1206
|
+
autoConnectionStatus: autoConnect ? "idle" : "disabled",
|
|
1207
|
+
setConnectionStatus(connectionStatus2) {
|
|
1208
|
+
set(() => ({
|
|
1209
|
+
connectionStatus: connectionStatus2
|
|
1210
|
+
}));
|
|
1211
|
+
},
|
|
1212
|
+
setAutoConnectionStatus(autoConnectionStatus) {
|
|
1213
|
+
set(() => ({
|
|
1214
|
+
autoConnectionStatus
|
|
1215
|
+
}));
|
|
1216
|
+
},
|
|
1134
1217
|
setWalletConnected(wallet, connectedAccounts, selectedAccount) {
|
|
1135
1218
|
set(() => ({
|
|
1136
1219
|
accounts: connectedAccounts,
|
|
1137
1220
|
currentWallet: wallet,
|
|
1138
1221
|
currentAccount: selectedAccount,
|
|
1139
1222
|
lastConnectedWalletName: wallet.name,
|
|
1140
|
-
lastConnectedAccountAddress: selectedAccount?.address
|
|
1223
|
+
lastConnectedAccountAddress: selectedAccount?.address,
|
|
1224
|
+
connectionStatus: "connected"
|
|
1141
1225
|
}));
|
|
1142
1226
|
},
|
|
1143
1227
|
setWalletDisconnected() {
|
|
@@ -1146,7 +1230,8 @@ function createWalletStore({ wallets, storage, storageKey }) {
|
|
|
1146
1230
|
currentWallet: null,
|
|
1147
1231
|
currentAccount: null,
|
|
1148
1232
|
lastConnectedWalletName: null,
|
|
1149
|
-
lastConnectedAccountAddress: null
|
|
1233
|
+
lastConnectedAccountAddress: null,
|
|
1234
|
+
connectionStatus: "disconnected"
|
|
1150
1235
|
}));
|
|
1151
1236
|
},
|
|
1152
1237
|
setAccountSwitched(selectedAccount) {
|
|
@@ -1166,7 +1251,8 @@ function createWalletStore({ wallets, storage, storageKey }) {
|
|
|
1166
1251
|
currentWallet: null,
|
|
1167
1252
|
currentAccount: null,
|
|
1168
1253
|
lastConnectedWalletName: null,
|
|
1169
|
-
lastConnectedAccountAddress: null
|
|
1254
|
+
lastConnectedAccountAddress: null,
|
|
1255
|
+
connectionStatus: "disconnected"
|
|
1170
1256
|
}));
|
|
1171
1257
|
} else {
|
|
1172
1258
|
set(() => ({ wallets: updatedWallets }));
|
|
@@ -1307,7 +1393,8 @@ function WalletProvider({
|
|
|
1307
1393
|
createWalletStore({
|
|
1308
1394
|
wallets: getRegisteredWallets(preferredWallets, requiredFeatures),
|
|
1309
1395
|
storageKey,
|
|
1310
|
-
storage
|
|
1396
|
+
storage,
|
|
1397
|
+
autoConnect
|
|
1311
1398
|
})
|
|
1312
1399
|
);
|
|
1313
1400
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(WalletContext.Provider, { value: storeRef.current, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
@@ -1338,77 +1425,69 @@ function WalletConnectionManager({
|
|
|
1338
1425
|
return children;
|
|
1339
1426
|
}
|
|
1340
1427
|
|
|
1341
|
-
// src/hooks/
|
|
1428
|
+
// src/hooks/networkConfig.ts
|
|
1429
|
+
function createNetworkConfig(networkConfig) {
|
|
1430
|
+
function useNetworkConfig() {
|
|
1431
|
+
const { config } = useSuiClientContext();
|
|
1432
|
+
if (!config) {
|
|
1433
|
+
throw new Error("No network config found");
|
|
1434
|
+
}
|
|
1435
|
+
return config;
|
|
1436
|
+
}
|
|
1437
|
+
function useNetworkVariables() {
|
|
1438
|
+
const { variables } = useNetworkConfig();
|
|
1439
|
+
return variables ?? {};
|
|
1440
|
+
}
|
|
1441
|
+
function useNetworkVariable(name) {
|
|
1442
|
+
const variables = useNetworkVariables();
|
|
1443
|
+
return variables[name];
|
|
1444
|
+
}
|
|
1445
|
+
return {
|
|
1446
|
+
networkConfig,
|
|
1447
|
+
useNetworkConfig,
|
|
1448
|
+
useNetworkVariables,
|
|
1449
|
+
useNetworkVariable
|
|
1450
|
+
};
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
// src/hooks/useSuiClientInfiniteQuery.ts
|
|
1342
1454
|
var import_react_query5 = require("@tanstack/react-query");
|
|
1343
|
-
function
|
|
1344
|
-
|
|
1345
|
-
|
|
1455
|
+
function useSuiClientInfiniteQuery(method, params, {
|
|
1456
|
+
queryKey = [],
|
|
1457
|
+
enabled = !!params,
|
|
1458
|
+
...options
|
|
1346
1459
|
} = {}) {
|
|
1347
|
-
const
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
}
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
"No wallet account is selected to sign the personal message with."
|
|
1359
|
-
);
|
|
1360
|
-
}
|
|
1361
|
-
const walletFeature = currentWallet.features["sui:signPersonalMessage"];
|
|
1362
|
-
if (!walletFeature) {
|
|
1363
|
-
throw new WalletFeatureNotSupportedError(
|
|
1364
|
-
"This wallet doesn't support the `signPersonalMessage` feature."
|
|
1365
|
-
);
|
|
1366
|
-
}
|
|
1367
|
-
return await walletFeature.signPersonalMessage({
|
|
1368
|
-
...signPersonalMessageArgs,
|
|
1369
|
-
account: signerAccount
|
|
1370
|
-
});
|
|
1371
|
-
},
|
|
1372
|
-
...mutationOptions
|
|
1460
|
+
const suiContext = useSuiClientContext();
|
|
1461
|
+
return (0, import_react_query5.useInfiniteQuery)({
|
|
1462
|
+
...options,
|
|
1463
|
+
initialPageParam: null,
|
|
1464
|
+
queryKey: [suiContext.network, method, params, ...queryKey],
|
|
1465
|
+
enabled,
|
|
1466
|
+
queryFn: ({ pageParam }) => suiContext.client[method]({
|
|
1467
|
+
...params ?? {},
|
|
1468
|
+
cursor: pageParam
|
|
1469
|
+
}),
|
|
1470
|
+
getNextPageParam: ({ nextCursor }) => nextCursor ?? null
|
|
1373
1471
|
});
|
|
1374
1472
|
}
|
|
1375
1473
|
|
|
1376
|
-
// src/hooks/
|
|
1474
|
+
// src/hooks/useSuiClientMutation.ts
|
|
1377
1475
|
var import_react_query6 = require("@tanstack/react-query");
|
|
1378
|
-
function
|
|
1379
|
-
|
|
1380
|
-
...mutationOptions
|
|
1381
|
-
} = {}) {
|
|
1382
|
-
const currentWallet = useCurrentWallet();
|
|
1383
|
-
const currentAccount = useCurrentAccount();
|
|
1476
|
+
function useSuiClientMutation(method, options = {}) {
|
|
1477
|
+
const suiContext = useSuiClientContext();
|
|
1384
1478
|
return (0, import_react_query6.useMutation)({
|
|
1385
|
-
|
|
1386
|
-
mutationFn: async (
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
}
|
|
1390
|
-
const signerAccount = signTransactionBlockArgs.account ?? currentAccount;
|
|
1391
|
-
if (!signerAccount) {
|
|
1392
|
-
throw new WalletNoAccountSelectedError(
|
|
1393
|
-
"No wallet account is selected to sign the transaction block with."
|
|
1394
|
-
);
|
|
1395
|
-
}
|
|
1396
|
-
const walletFeature = currentWallet.features["sui:signTransactionBlock"];
|
|
1397
|
-
if (!walletFeature) {
|
|
1398
|
-
throw new WalletFeatureNotSupportedError(
|
|
1399
|
-
"This wallet doesn't support the `SignTransactionBlock` feature."
|
|
1400
|
-
);
|
|
1401
|
-
}
|
|
1402
|
-
return await walletFeature.signTransactionBlock({
|
|
1403
|
-
...signTransactionBlockArgs,
|
|
1404
|
-
account: signerAccount,
|
|
1405
|
-
chain: signTransactionBlockArgs.chain ?? signerAccount.chains[0]
|
|
1406
|
-
});
|
|
1407
|
-
},
|
|
1408
|
-
...mutationOptions
|
|
1479
|
+
...options,
|
|
1480
|
+
mutationFn: async (params) => {
|
|
1481
|
+
return await suiContext.client[method](params);
|
|
1482
|
+
}
|
|
1409
1483
|
});
|
|
1410
1484
|
}
|
|
1411
1485
|
|
|
1486
|
+
// src/hooks/wallet/useAutoConnectionStatus.ts
|
|
1487
|
+
function useAutoConnectionStatus() {
|
|
1488
|
+
return useWalletStore((state) => state.autoConnectionStatus);
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1412
1491
|
// src/hooks/wallet/useSignAndExecuteTransactionBlock.ts
|
|
1413
1492
|
var import_react_query7 = require("@tanstack/react-query");
|
|
1414
1493
|
function useSignAndExecuteTransactionBlock({
|
|
@@ -1416,7 +1495,7 @@ function useSignAndExecuteTransactionBlock({
|
|
|
1416
1495
|
executeFromWallet,
|
|
1417
1496
|
...mutationOptions
|
|
1418
1497
|
} = {}) {
|
|
1419
|
-
const currentWallet = useCurrentWallet();
|
|
1498
|
+
const { currentWallet } = useCurrentWallet();
|
|
1420
1499
|
const currentAccount = useCurrentAccount();
|
|
1421
1500
|
const client = useSuiClient();
|
|
1422
1501
|
return (0, import_react_query7.useMutation)({
|
|
@@ -1468,32 +1547,74 @@ function useSignAndExecuteTransactionBlock({
|
|
|
1468
1547
|
});
|
|
1469
1548
|
}
|
|
1470
1549
|
|
|
1471
|
-
// src/hooks/
|
|
1550
|
+
// src/hooks/wallet/useSignPersonalMessage.ts
|
|
1472
1551
|
var import_react_query8 = require("@tanstack/react-query");
|
|
1473
|
-
function
|
|
1474
|
-
|
|
1552
|
+
function useSignPersonalMessage({
|
|
1553
|
+
mutationKey,
|
|
1554
|
+
...mutationOptions
|
|
1555
|
+
} = {}) {
|
|
1556
|
+
const { currentWallet } = useCurrentWallet();
|
|
1557
|
+
const currentAccount = useCurrentAccount();
|
|
1475
1558
|
return (0, import_react_query8.useMutation)({
|
|
1476
|
-
|
|
1477
|
-
mutationFn: async (
|
|
1478
|
-
|
|
1479
|
-
|
|
1559
|
+
mutationKey: walletMutationKeys.signPersonalMessage(mutationKey),
|
|
1560
|
+
mutationFn: async (signPersonalMessageArgs) => {
|
|
1561
|
+
if (!currentWallet) {
|
|
1562
|
+
throw new WalletNotConnectedError("No wallet is connected.");
|
|
1563
|
+
}
|
|
1564
|
+
const signerAccount = signPersonalMessageArgs.account ?? currentAccount;
|
|
1565
|
+
if (!signerAccount) {
|
|
1566
|
+
throw new WalletNoAccountSelectedError(
|
|
1567
|
+
"No wallet account is selected to sign the personal message with."
|
|
1568
|
+
);
|
|
1569
|
+
}
|
|
1570
|
+
const walletFeature = currentWallet.features["sui:signPersonalMessage"];
|
|
1571
|
+
if (!walletFeature) {
|
|
1572
|
+
throw new WalletFeatureNotSupportedError(
|
|
1573
|
+
"This wallet doesn't support the `signPersonalMessage` feature."
|
|
1574
|
+
);
|
|
1575
|
+
}
|
|
1576
|
+
return await walletFeature.signPersonalMessage({
|
|
1577
|
+
...signPersonalMessageArgs,
|
|
1578
|
+
account: signerAccount
|
|
1579
|
+
});
|
|
1580
|
+
},
|
|
1581
|
+
...mutationOptions
|
|
1480
1582
|
});
|
|
1481
1583
|
}
|
|
1482
1584
|
|
|
1483
|
-
// src/hooks/
|
|
1585
|
+
// src/hooks/wallet/useSignTransactionBlock.ts
|
|
1484
1586
|
var import_react_query9 = require("@tanstack/react-query");
|
|
1485
|
-
function
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1587
|
+
function useSignTransactionBlock({
|
|
1588
|
+
mutationKey,
|
|
1589
|
+
...mutationOptions
|
|
1590
|
+
} = {}) {
|
|
1591
|
+
const { currentWallet } = useCurrentWallet();
|
|
1592
|
+
const currentAccount = useCurrentAccount();
|
|
1593
|
+
return (0, import_react_query9.useMutation)({
|
|
1594
|
+
mutationKey: walletMutationKeys.signTransactionBlock(mutationKey),
|
|
1595
|
+
mutationFn: async (signTransactionBlockArgs) => {
|
|
1596
|
+
if (!currentWallet) {
|
|
1597
|
+
throw new WalletNotConnectedError("No wallet is connected.");
|
|
1598
|
+
}
|
|
1599
|
+
const signerAccount = signTransactionBlockArgs.account ?? currentAccount;
|
|
1600
|
+
if (!signerAccount) {
|
|
1601
|
+
throw new WalletNoAccountSelectedError(
|
|
1602
|
+
"No wallet account is selected to sign the transaction block with."
|
|
1603
|
+
);
|
|
1604
|
+
}
|
|
1605
|
+
const walletFeature = currentWallet.features["sui:signTransactionBlock"];
|
|
1606
|
+
if (!walletFeature) {
|
|
1607
|
+
throw new WalletFeatureNotSupportedError(
|
|
1608
|
+
"This wallet doesn't support the `SignTransactionBlock` feature."
|
|
1609
|
+
);
|
|
1610
|
+
}
|
|
1611
|
+
return await walletFeature.signTransactionBlock({
|
|
1612
|
+
...signTransactionBlockArgs,
|
|
1613
|
+
account: signerAccount,
|
|
1614
|
+
chain: signTransactionBlockArgs.chain ?? signerAccount.chains[0]
|
|
1615
|
+
});
|
|
1493
1616
|
},
|
|
1494
|
-
|
|
1495
|
-
return lastPage.nextCursor ?? null;
|
|
1496
|
-
}
|
|
1617
|
+
...mutationOptions
|
|
1497
1618
|
});
|
|
1498
1619
|
}
|
|
1499
1620
|
//# sourceMappingURL=index.js.map
|