@aptos-labs/wallet-adapter-react 3.4.3 → 3.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.
Files changed (35) hide show
  1. package/README.md +3 -1
  2. package/dist/WalletProvider.d.ts.map +1 -1
  3. package/dist/components/AboutAptosConnect.d.ts +60 -0
  4. package/dist/components/AboutAptosConnect.d.ts.map +1 -0
  5. package/dist/components/AptosPrivacyPolicy.d.ts +6 -15
  6. package/dist/components/AptosPrivacyPolicy.d.ts.map +1 -1
  7. package/dist/components/WalletItem.d.ts +7 -24
  8. package/dist/components/WalletItem.d.ts.map +1 -1
  9. package/dist/components/utils.d.ts +20 -0
  10. package/dist/components/utils.d.ts.map +1 -0
  11. package/dist/graphics/LinkGraphic.d.ts +3 -0
  12. package/dist/graphics/LinkGraphic.d.ts.map +1 -0
  13. package/dist/graphics/SmallAptosLogo.d.ts +1 -1
  14. package/dist/graphics/SmallAptosLogo.d.ts.map +1 -1
  15. package/dist/graphics/WalletGraphic.d.ts +3 -0
  16. package/dist/graphics/WalletGraphic.d.ts.map +1 -0
  17. package/dist/graphics/Web3Graphic.d.ts +3 -0
  18. package/dist/graphics/Web3Graphic.d.ts.map +1 -0
  19. package/dist/index.d.ts +1 -0
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +421 -147
  22. package/dist/index.js.map +1 -1
  23. package/dist/index.mjs +435 -168
  24. package/dist/index.mjs.map +1 -1
  25. package/package.json +2 -2
  26. package/src/WalletProvider.tsx +70 -45
  27. package/src/components/AboutAptosConnect.tsx +214 -0
  28. package/src/components/AptosPrivacyPolicy.tsx +14 -55
  29. package/src/components/WalletItem.tsx +60 -114
  30. package/src/components/utils.tsx +66 -0
  31. package/src/graphics/LinkGraphic.tsx +26 -0
  32. package/src/graphics/SmallAptosLogo.tsx +15 -4
  33. package/src/graphics/WalletGraphic.tsx +42 -0
  34. package/src/graphics/Web3Graphic.tsx +31 -0
  35. package/src/index.tsx +1 -0
package/dist/index.mjs CHANGED
@@ -2,12 +2,7 @@
2
2
  export * from "@aptos-labs/wallet-adapter-core";
3
3
 
4
4
  // src/WalletProvider.tsx
5
- import {
6
- useCallback,
7
- useEffect,
8
- useMemo,
9
- useState
10
- } from "react";
5
+ import { useCallback, useEffect, useState } from "react";
11
6
 
12
7
  // src/useWallet.tsx
13
8
  import { createContext, useContext } from "react";
@@ -44,15 +39,24 @@ var AptosWalletAdapterProvider = ({
44
39
  }) => {
45
40
  const [{ connected, account, network, wallet }, setState] = useState(initialState);
46
41
  const [isLoading, setIsLoading] = useState(true);
47
- const walletCore = useMemo(
48
- () => new WalletCore(plugins != null ? plugins : [], optInWallets != null ? optInWallets : [], dappConfig),
49
- []
50
- );
51
- const [wallets, setWallets] = useState(walletCore.wallets);
42
+ const [walletCore, setWalletCore] = useState();
43
+ const [wallets, setWallets] = useState(plugins != null ? plugins : []);
44
+ useEffect(() => {
45
+ const walletCore2 = new WalletCore(
46
+ plugins != null ? plugins : [],
47
+ optInWallets != null ? optInWallets : [],
48
+ dappConfig
49
+ );
50
+ setWalletCore(walletCore2);
51
+ }, []);
52
+ useEffect(() => {
53
+ var _a;
54
+ setWallets((_a = walletCore == null ? void 0 : walletCore.wallets) != null ? _a : []);
55
+ }, [walletCore]);
52
56
  const connect = async (walletName) => {
53
57
  try {
54
58
  setIsLoading(true);
55
- await walletCore.connect(walletName);
59
+ await (walletCore == null ? void 0 : walletCore.connect(walletName));
56
60
  } catch (error) {
57
61
  if (onError)
58
62
  onError(error);
@@ -63,7 +67,7 @@ var AptosWalletAdapterProvider = ({
63
67
  };
64
68
  const disconnect = async () => {
65
69
  try {
66
- await walletCore.disconnect();
70
+ await (walletCore == null ? void 0 : walletCore.disconnect());
67
71
  } catch (error) {
68
72
  if (onError)
69
73
  onError(error);
@@ -71,8 +75,15 @@ var AptosWalletAdapterProvider = ({
71
75
  }
72
76
  };
73
77
  const signTransaction = async (transaction, asFeePayer, options) => {
78
+ if (!walletCore) {
79
+ throw new Error("WalletCore is not initialized");
80
+ }
74
81
  try {
75
- return await walletCore.signTransaction(transaction, asFeePayer, options);
82
+ return await (walletCore == null ? void 0 : walletCore.signTransaction(
83
+ transaction,
84
+ asFeePayer,
85
+ options
86
+ ));
76
87
  } catch (error) {
77
88
  if (onError)
78
89
  onError(error);
@@ -80,8 +91,11 @@ var AptosWalletAdapterProvider = ({
80
91
  }
81
92
  };
82
93
  const signMessage = async (message) => {
94
+ if (!walletCore) {
95
+ throw new Error("WalletCore is not initialized");
96
+ }
83
97
  try {
84
- return await walletCore.signMessage(message);
98
+ return await (walletCore == null ? void 0 : walletCore.signMessage(message));
85
99
  } catch (error) {
86
100
  if (onError)
87
101
  onError(error);
@@ -89,8 +103,11 @@ var AptosWalletAdapterProvider = ({
89
103
  }
90
104
  };
91
105
  const signMessageAndVerify = async (message) => {
106
+ if (!walletCore) {
107
+ throw new Error("WalletCore is not initialized");
108
+ }
92
109
  try {
93
- return await walletCore.signMessageAndVerify(message);
110
+ return await (walletCore == null ? void 0 : walletCore.signMessageAndVerify(message));
94
111
  } catch (error) {
95
112
  if (onError)
96
113
  onError(error);
@@ -98,8 +115,11 @@ var AptosWalletAdapterProvider = ({
98
115
  }
99
116
  };
100
117
  const submitTransaction = async (transaction) => {
118
+ if (!walletCore) {
119
+ throw new Error("WalletCore is not initialized");
120
+ }
101
121
  try {
102
- return await walletCore.submitTransaction(transaction);
122
+ return await (walletCore == null ? void 0 : walletCore.submitTransaction(transaction));
103
123
  } catch (error) {
104
124
  if (onError)
105
125
  onError(error);
@@ -108,7 +128,7 @@ var AptosWalletAdapterProvider = ({
108
128
  };
109
129
  const signAndSubmitTransaction = async (transaction) => {
110
130
  try {
111
- return await walletCore.signAndSubmitTransaction(transaction);
131
+ return await (walletCore == null ? void 0 : walletCore.signAndSubmitTransaction(transaction));
112
132
  } catch (error) {
113
133
  if (onError)
114
134
  onError(error);
@@ -116,8 +136,11 @@ var AptosWalletAdapterProvider = ({
116
136
  }
117
137
  };
118
138
  const changeNetwork = async (network2) => {
139
+ if (!walletCore) {
140
+ throw new Error("WalletCore is not initialized");
141
+ }
119
142
  try {
120
- return await walletCore.changeNetwork(network2);
143
+ return await (walletCore == null ? void 0 : walletCore.changeNetwork(network2));
121
144
  } catch (error) {
122
145
  if (onError)
123
146
  onError(error);
@@ -135,8 +158,8 @@ var AptosWalletAdapterProvider = ({
135
158
  }, [autoConnect, wallets]);
136
159
  useEffect(() => {
137
160
  if (connected) {
138
- walletCore.onAccountChange();
139
- walletCore.onNetworkChange();
161
+ walletCore == null ? void 0 : walletCore.onAccountChange();
162
+ walletCore == null ? void 0 : walletCore.onNetworkChange();
140
163
  }
141
164
  }, [connected]);
142
165
  const handleConnect = () => {
@@ -144,9 +167,9 @@ var AptosWalletAdapterProvider = ({
144
167
  return {
145
168
  ...state,
146
169
  connected: true,
147
- account: walletCore.account,
148
- network: walletCore.network,
149
- wallet: walletCore.wallet
170
+ account: (walletCore == null ? void 0 : walletCore.account) || null,
171
+ network: (walletCore == null ? void 0 : walletCore.network) || null,
172
+ wallet: (walletCore == null ? void 0 : walletCore.wallet) || null
150
173
  };
151
174
  });
152
175
  };
@@ -157,8 +180,8 @@ var AptosWalletAdapterProvider = ({
157
180
  return {
158
181
  ...state,
159
182
  connected: false,
160
- account: walletCore.account,
161
- network: walletCore.network,
183
+ account: (walletCore == null ? void 0 : walletCore.account) || null,
184
+ network: (walletCore == null ? void 0 : walletCore.network) || null,
162
185
  wallet: null
163
186
  };
164
187
  });
@@ -166,24 +189,24 @@ var AptosWalletAdapterProvider = ({
166
189
  const handleAccountChange = useCallback(() => {
167
190
  if (!connected)
168
191
  return;
169
- if (!walletCore.wallet)
192
+ if (!(walletCore == null ? void 0 : walletCore.wallet))
170
193
  return;
171
194
  setState((state) => {
172
195
  return {
173
196
  ...state,
174
- account: walletCore.account
197
+ account: (walletCore == null ? void 0 : walletCore.account) || null
175
198
  };
176
199
  });
177
200
  }, [connected]);
178
201
  const handleNetworkChange = useCallback(() => {
179
202
  if (!connected)
180
203
  return;
181
- if (!walletCore.wallet)
204
+ if (!(walletCore == null ? void 0 : walletCore.wallet))
182
205
  return;
183
206
  setState((state) => {
184
207
  return {
185
208
  ...state,
186
- network: walletCore.network
209
+ network: (walletCore == null ? void 0 : walletCore.network) || null
187
210
  };
188
211
  });
189
212
  }, [connected]);
@@ -211,21 +234,21 @@ var AptosWalletAdapterProvider = ({
211
234
  }
212
235
  };
213
236
  useEffect(() => {
214
- walletCore.on("connect", handleConnect);
215
- walletCore.on("disconnect", handleDisconnect);
216
- walletCore.on("accountChange", handleAccountChange);
217
- walletCore.on("networkChange", handleNetworkChange);
218
- walletCore.on("readyStateChange", handleReadyStateChange);
219
- walletCore.on("standardWalletsAdded", handleStandardWalletsAdded);
237
+ walletCore == null ? void 0 : walletCore.on("connect", handleConnect);
238
+ walletCore == null ? void 0 : walletCore.on("disconnect", handleDisconnect);
239
+ walletCore == null ? void 0 : walletCore.on("accountChange", handleAccountChange);
240
+ walletCore == null ? void 0 : walletCore.on("networkChange", handleNetworkChange);
241
+ walletCore == null ? void 0 : walletCore.on("readyStateChange", handleReadyStateChange);
242
+ walletCore == null ? void 0 : walletCore.on("standardWalletsAdded", handleStandardWalletsAdded);
220
243
  return () => {
221
- walletCore.off("connect", handleConnect);
222
- walletCore.off("disconnect", handleDisconnect);
223
- walletCore.off("accountChange", handleAccountChange);
224
- walletCore.off("networkChange", handleNetworkChange);
225
- walletCore.off("readyStateChange", handleReadyStateChange);
226
- walletCore.off("standardWalletsAdded", handleStandardWalletsAdded);
244
+ walletCore == null ? void 0 : walletCore.off("connect", handleConnect);
245
+ walletCore == null ? void 0 : walletCore.off("disconnect", handleDisconnect);
246
+ walletCore == null ? void 0 : walletCore.off("accountChange", handleAccountChange);
247
+ walletCore == null ? void 0 : walletCore.off("networkChange", handleNetworkChange);
248
+ walletCore == null ? void 0 : walletCore.off("readyStateChange", handleReadyStateChange);
249
+ walletCore == null ? void 0 : walletCore.off("standardWalletsAdded", handleStandardWalletsAdded);
227
250
  };
228
- }, [wallets, connected]);
251
+ }, [wallets, account]);
229
252
  return /* @__PURE__ */ jsx(WalletContext.Provider, {
230
253
  value: {
231
254
  connect,
@@ -247,84 +270,345 @@ var AptosWalletAdapterProvider = ({
247
270
  });
248
271
  };
249
272
 
250
- // src/components/AptosPrivacyPolicy.tsx
251
- import { Slot } from "@radix-ui/react-slot";
273
+ // src/components/AboutAptosConnect.tsx
274
+ import {
275
+ createContext as createContext2,
276
+ useContext as useContext2,
277
+ useMemo,
278
+ useState as useState2
279
+ } from "react";
280
+
281
+ // src/graphics/LinkGraphic.tsx
252
282
  import { forwardRef } from "react";
283
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
284
+ var LinkGraphic = forwardRef(
285
+ (props, ref) => {
286
+ return /* @__PURE__ */ jsx2("svg", {
287
+ ref,
288
+ width: "102",
289
+ height: "132",
290
+ viewBox: "0 0 102 132",
291
+ fill: "none",
292
+ ...props,
293
+ children: /* @__PURE__ */ jsxs("g", {
294
+ stroke: "currentColor",
295
+ strokeMiterlimit: "10",
296
+ children: [
297
+ /* @__PURE__ */ jsx2("path", {
298
+ d: "M59.633 80.66c11.742-2.814 17.48-7.018 20.925-13.254l17.518-31.69c6.257-11.317 2.142-25.55-9.189-31.798C82.737.53 75.723.188 69.593 2.398M60.7 69.565a14.09 14.09 0 0 1-6.907-1.767l-.228-.108"
299
+ }),
300
+ /* @__PURE__ */ jsx2("path", {
301
+ d: "m52.365 41.075 12.507-22.627a14.146 14.146 0 0 1 4.727-5.062M32.407 118.619a14.139 14.139 0 0 1-7.034-1.768c-6.857-3.78-9.353-12.402-5.561-19.25l16.634-30.1a14.097 14.097 0 0 1 4.518-4.923"
302
+ }),
303
+ /* @__PURE__ */ jsx2("path", {
304
+ d: "M41.211 78.85c11.332 6.248 25.583 2.14 31.84-9.177l17.518-31.691c6.256-11.317 2.142-25.55-9.19-31.798-6.085-3.357-13.018-3.724-19.104-1.59A23.31 23.31 0 0 0 49.541 15.36L36.863 38.298l7.989 5.036 12.506-22.627c3.786-6.848 12.419-9.34 19.276-5.554 6.856 3.78 9.353 12.402 5.561 19.25l-16.634 30.1c-3.785 6.848-12.418 9.341-19.275 5.555l-5.075 8.791ZM29.5 130.447c12.361-1.37 19.2-6.994 22.966-13.804l12.678-22.936-8.305-5.239"
305
+ }),
306
+ /* @__PURE__ */ jsx2("path", {
307
+ d: "m55.72 61.947-.442.764 5.511-9.55c-6.901-3.806-18.65-3.124-27.105.814M44.85 43.523l7.635-2.486m-4.221 23.264 7.217-1.723m-9.316 7.517 7.59-2.405m-.562-12.156 7.508-2.221m10.136-51.32L62.761 4.43M49.642 90.778l7.514-2.26m.474 7.448 7.514-2.26m-50.306-60.13c7.135 0 12.918-5.776 12.918-12.9 0-7.126-5.783-12.902-12.918-12.902-7.134 0-12.917 5.776-12.917 12.901s5.783 12.901 12.918 12.901Z"
308
+ }),
309
+ /* @__PURE__ */ jsx2("path", {
310
+ d: "M15.724 7.774h3.197c7.135 0 12.918 5.776 12.918 12.901 0 7.126-5.783 12.901-12.918 12.901h-3.425m65.112 66.935h3.198c7.135 0 12.918 5.775 12.918 12.901 0 7.125-5.783 12.9-12.918 12.9h-3.425"
311
+ }),
312
+ /* @__PURE__ */ jsx2("path", {
313
+ d: "M79.717 126.312c7.135 0 12.918-5.775 12.918-12.9s-5.783-12.901-12.918-12.901c-7.134 0-12.917 5.776-12.917 12.901s5.783 12.9 12.917 12.9ZM53.281 55.414c-11.33-6.248-25.582-2.14-31.839 9.177L3.924 96.281c-6.257 11.318-2.142 25.55 9.189 31.799 11.331 6.248 25.582 2.139 31.839-9.177l12.677-22.937-7.988-5.036-12.507 22.627c-3.785 6.848-12.418 9.341-19.275 5.554-6.857-3.781-9.353-12.402-5.561-19.25l16.633-30.1c3.786-6.848 12.419-9.341 19.276-5.555l5.074-8.792Z"
314
+ })
315
+ ]
316
+ })
317
+ });
318
+ }
319
+ );
320
+ LinkGraphic.displayName = "LinkGraphic";
321
+
322
+ // src/graphics/WalletGraphic.tsx
323
+ import { forwardRef as forwardRef2 } from "react";
324
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
325
+ var WalletGraphic = forwardRef2(
326
+ (props, ref) => {
327
+ return /* @__PURE__ */ jsxs2("svg", {
328
+ ref,
329
+ width: "128",
330
+ height: "102",
331
+ viewBox: "0 0 128 102",
332
+ fill: "none",
333
+ ...props,
334
+ children: [
335
+ /* @__PURE__ */ jsx3("path", {
336
+ fill: "currentColor",
337
+ d: "m.96 25.93-.36-.35.36.85v-.5Zm7.79-7.81v-.5h-.21l-.15.15.36.35ZM1.3 26.28l7.79-7.8-.7-.71-7.8 7.8.7.71Zm7.44-7.66H10v-1H8.75v1Zm29.22 6.8h-37v1h37.01v-1Z"
338
+ }),
339
+ /* @__PURE__ */ jsx3("path", {
340
+ stroke: "currentColor",
341
+ strokeMiterlimit: "10",
342
+ d: "M82.25 26.08c0 12.25-9.92 22.2-22.14 22.2a22.17 22.17 0 0 1-22.14-22.2H1.1v74.82h118.02V26.08H82.25Zm44.33 67.02h.33V18.27h-5.7"
343
+ }),
344
+ /* @__PURE__ */ jsx3("path", {
345
+ stroke: "currentColor",
346
+ strokeMiterlimit: "10",
347
+ d: "M74.52 42.92a22.4 22.4 0 0 1-11.43 3.3 22.5 22.5 0 0 1-22.46-22.53H9.52M119.22 101l7.78-7.82m-7.88-67.1 7.79-7.81m-44.78 7.72 2.73-2.3m-46.89 2.39 2.39-2.4"
348
+ }),
349
+ /* @__PURE__ */ jsx3("path", {
350
+ stroke: "currentColor",
351
+ strokeMiterlimit: "10",
352
+ d: "M9.86 23.69V5.72h107.97v18.04H84.65"
353
+ }),
354
+ /* @__PURE__ */ jsx3("path", {
355
+ stroke: "currentColor",
356
+ strokeMiterlimit: "10",
357
+ d: "M117.83 20.46h3.39V1H13.25v4.72M9.36 23.69h31.78"
358
+ })
359
+ ]
360
+ });
361
+ }
362
+ );
363
+ WalletGraphic.displayName = "WalletGraphic";
364
+
365
+ // src/graphics/Web3Graphic.tsx
366
+ import { forwardRef as forwardRef3 } from "react";
367
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
368
+ var Web3Graphic = forwardRef3(
369
+ (props, ref) => {
370
+ return /* @__PURE__ */ jsx4("svg", {
371
+ ref,
372
+ width: "142",
373
+ height: "108",
374
+ viewBox: "0 0 142 108",
375
+ fill: "none",
376
+ ...props,
377
+ children: /* @__PURE__ */ jsxs3("g", {
378
+ stroke: "currentColor",
379
+ strokeLinejoin: "round",
380
+ children: [
381
+ /* @__PURE__ */ jsx4("path", {
382
+ d: "m91.26 35.8.06-10.46L71.3 1v10.53L87 30.5m-36.11 5.24-.06-10.45L71.3 1v10.53L55 30.5"
383
+ }),
384
+ /* @__PURE__ */ jsx4("path", {
385
+ d: "M71 59.55V49.17L50.83 25.3l.06 10.45L57 42.5m14 17.05V49.18l20.33-23.84-.07 10.45L86 42M1 59.68l.22-9.07 35.33-19.8-.1 9L9 55"
386
+ }),
387
+ /* @__PURE__ */ jsx4("path", {
388
+ d: "M36.55 30.8s-.08 5.92-.1 9l.1-9ZM71 59.51v-9.07L36.55 30.8l-.1 9L63.5 55"
389
+ }),
390
+ /* @__PURE__ */ jsx4("path", {
391
+ d: "M71 59.51v-9.07L36.44 70.78l-.1 9.14L55.5 68.5"
392
+ }),
393
+ /* @__PURE__ */ jsx4("path", {
394
+ d: "M1.22 50.6a77387.2 77387.2 0 0 0 35.22 20.18l-.1 9.14L1 59.68l.23-9.07h-.01ZM141 59.68l-.23-9.07-35.33-19.8.11 9L133 55"
395
+ }),
396
+ /* @__PURE__ */ jsx4("path", {
397
+ d: "m105.44 30.8.11 9-.1-9Z"
398
+ }),
399
+ /* @__PURE__ */ jsx4("path", {
400
+ d: "M71 59.51v-9.07l34.44-19.64.11 9L78.5 55"
401
+ }),
402
+ /* @__PURE__ */ jsx4("path", {
403
+ d: "M71 59.51v-9.07l34.56 20.34.1 9.14L87 69"
404
+ }),
405
+ /* @__PURE__ */ jsx4("path", {
406
+ d: "M140.78 50.6a78487.3 78487.3 0 0 1-35.23 20.18l.11 9.14L141 59.68l-.23-9.07ZM50.83 80.15l.06-6.33 20.1-23.38H71v9.26L55 79"
407
+ }),
408
+ /* @__PURE__ */ jsx4("path", {
409
+ d: "M71.3 97.6 50.89 73.81l-.06 9.33L71.3 107v-9.4Zm20.03-14.5-.07-9.33L71 50.44v9.26l16 18.8"
410
+ }),
411
+ /* @__PURE__ */ jsx4("path", {
412
+ d: "m71.3 97.6 19.96-23.83.06 9.33L71.3 107v-9.4Z"
413
+ })
414
+ ]
415
+ })
416
+ });
417
+ }
418
+ );
419
+ Web3Graphic.displayName = "Web3Graphic";
420
+
421
+ // src/components/utils.tsx
422
+ import { Slot } from "@radix-ui/react-slot";
423
+ import { forwardRef as forwardRef4 } from "react";
424
+ import { jsx as jsx5 } from "react/jsx-runtime";
425
+ function createHeadlessComponent(displayName, elementType, props) {
426
+ const component = forwardRef4(({ className, asChild, children }, ref) => {
427
+ const Component = asChild ? Slot : elementType;
428
+ const { children: defaultChildren, ...resolvedProps } = typeof props === "function" ? props(displayName) : props != null ? props : {};
429
+ return /* @__PURE__ */ jsx5(Component, {
430
+ ref,
431
+ className,
432
+ children: children != null ? children : defaultChildren,
433
+ ...resolvedProps
434
+ });
435
+ });
436
+ component.displayName = displayName;
437
+ return component;
438
+ }
439
+
440
+ // src/components/AboutAptosConnect.tsx
441
+ import { Fragment, jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
442
+ var EXPLORE_ECOSYSTEM_URL = "https://aptosfoundation.org/ecosystem/projects/all";
443
+ var AboutAptosConnectContext = createContext2(null);
444
+ function useAboutAptosConnectContext(displayName) {
445
+ const context = useContext2(AboutAptosConnectContext);
446
+ if (!context) {
447
+ throw new Error(
448
+ `\`${displayName}\` must be used within \`AboutAptosConnect\``
449
+ );
450
+ }
451
+ return context;
452
+ }
453
+ var educationScreens = [
454
+ {
455
+ Graphic: LinkGraphic,
456
+ Title: createHeadlessComponent("EducationScreen.Title", "h3", {
457
+ children: "A better way to login."
458
+ }),
459
+ Description: createHeadlessComponent("EducationScreen.Description", "p", {
460
+ children: "Aptos Connect is a web3 wallet that uses a Social Login to create accounts on the Aptos blockchain."
461
+ })
462
+ },
463
+ {
464
+ Graphic: WalletGraphic,
465
+ Title: createHeadlessComponent("EducationScreen.Title", "h2", {
466
+ children: "What is a wallet?"
467
+ }),
468
+ Description: createHeadlessComponent("EducationScreen.Description", "p", {
469
+ children: "Wallets are a secure way to send, receive, and interact with digital assets like cryptocurrencies & NFTs."
470
+ })
471
+ },
472
+ {
473
+ Graphic: Web3Graphic,
474
+ Title: createHeadlessComponent("EducationScreen.Title", "h2", {
475
+ children: "Explore more of web3."
476
+ }),
477
+ Description: createHeadlessComponent("EducationScreen.Description", "p", {
478
+ children: /* @__PURE__ */ jsxs4(Fragment, {
479
+ children: [
480
+ "Aptos Connect lets you to take one account across any application built on Aptos.",
481
+ " ",
482
+ /* @__PURE__ */ jsx6("a", {
483
+ href: EXPLORE_ECOSYSTEM_URL,
484
+ target: "_blank",
485
+ rel: "noopener noreferrer",
486
+ children: "Explore the ecosystem"
487
+ }),
488
+ "."
489
+ ]
490
+ })
491
+ })
492
+ }
493
+ ];
494
+ var educationScreenIndicators = Array(educationScreens.length).fill(null).map(
495
+ (_, index) => createHeadlessComponent(
496
+ "AboutAptosConnect.ScreenIndicator",
497
+ "button",
498
+ (displayName) => {
499
+ const context = useAboutAptosConnectContext(displayName);
500
+ const isActive = context.screenIndex - 1 === index;
501
+ return {
502
+ "aria-label": `Go to screen ${index + 1}`,
503
+ "aria-current": isActive ? "step" : void 0,
504
+ "data-active": isActive || void 0,
505
+ onClick: () => {
506
+ context.setScreenIndex(index + 1);
507
+ }
508
+ };
509
+ }
510
+ )
511
+ );
512
+ var Root = ({ renderEducationScreen, children }) => {
513
+ const [screenIndex, setScreenIndex] = useState2(0);
514
+ const currentEducationScreen = useMemo(
515
+ () => educationScreens.map((screen, i) => ({
516
+ ...screen,
517
+ screenIndex: i,
518
+ totalScreens: educationScreens.length,
519
+ screenIndicators: educationScreenIndicators,
520
+ back: () => {
521
+ setScreenIndex(screenIndex - 1);
522
+ },
523
+ next: () => {
524
+ setScreenIndex(
525
+ screenIndex === educationScreens.length ? 0 : screenIndex + 1
526
+ );
527
+ },
528
+ cancel: () => {
529
+ setScreenIndex(0);
530
+ }
531
+ }))[screenIndex - 1],
532
+ [screenIndex]
533
+ );
534
+ return /* @__PURE__ */ jsx6(AboutAptosConnectContext.Provider, {
535
+ value: { screenIndex, setScreenIndex },
536
+ children: screenIndex === 0 ? children : renderEducationScreen(currentEducationScreen)
537
+ });
538
+ };
539
+ Root.displayName = "AboutAptosConnect";
540
+ var Trigger = createHeadlessComponent(
541
+ "AboutAptosConnect.Trigger",
542
+ "button",
543
+ (displayName) => {
544
+ const context = useAboutAptosConnectContext(displayName);
545
+ return {
546
+ onClick: () => {
547
+ context.setScreenIndex(1);
548
+ }
549
+ };
550
+ }
551
+ );
552
+ var AboutAptosConnect = Object.assign(Root, {
553
+ Trigger
554
+ });
555
+
556
+ // src/components/AptosPrivacyPolicy.tsx
557
+ import { forwardRef as forwardRef6 } from "react";
253
558
 
254
559
  // src/graphics/SmallAptosLogo.tsx
255
- import { jsx as jsx2 } from "react/jsx-runtime";
256
- function SmallAptosLogo(props) {
257
- return /* @__PURE__ */ jsx2("svg", {
560
+ import { forwardRef as forwardRef5 } from "react";
561
+ import { jsx as jsx7 } from "react/jsx-runtime";
562
+ var SmallAptosLogo = forwardRef5((props, ref) => {
563
+ return /* @__PURE__ */ jsx7("svg", {
564
+ ref,
258
565
  width: "12",
259
566
  height: "12",
260
567
  viewBox: "0 0 12 12",
261
568
  fill: "none",
262
569
  ...props,
263
- children: /* @__PURE__ */ jsx2("path", {
570
+ children: /* @__PURE__ */ jsx7("path", {
264
571
  fillRule: "evenodd",
265
572
  clipRule: "evenodd",
266
573
  d: "M6 12C9.31371 12 12 9.31371 12 6C12 2.68629 9.31371 0 6 0C2.68629 0 0 2.68629 0 6C0 9.31371 2.68629 12 6 12ZM7.17547 3.67976C7.13401 3.72309 7.07649 3.74757 7.01648 3.74757H3.00775C3.69185 2.83824 4.77995 2.25 6.00569 2.25C7.23142 2.25 8.31953 2.83824 9.00362 3.74757H8.28524C8.20824 3.74757 8.13498 3.71468 8.08401 3.65701L7.81608 3.35416C7.77618 3.30896 7.71882 3.28308 7.6585 3.28308H7.6454C7.58805 3.28308 7.53318 3.30646 7.49343 3.34792L7.17547 3.67976ZM8.05656 4.75897H7.39569C7.31869 4.75897 7.24543 4.72593 7.19447 4.66842L6.92638 4.36557C6.88647 4.32036 6.82896 4.29465 6.7688 4.29465C6.70863 4.29465 6.65112 4.32052 6.61121 4.36557L6.38131 4.6254C6.30603 4.71034 6.19801 4.75913 6.08454 4.75913H2.46703C2.36401 5.05278 2.29683 5.36296 2.27002 5.68467H5.68505C5.74506 5.68467 5.80258 5.66019 5.84404 5.61686L6.16201 5.28502C6.20175 5.24356 6.25662 5.22018 6.31398 5.22018H6.32707C6.38739 5.22018 6.44475 5.24606 6.48465 5.29126L6.75258 5.59411C6.80355 5.65178 6.87681 5.68467 6.95381 5.68467H9.74133C9.71452 5.3628 9.64734 5.05263 9.54431 4.75913H8.05641L8.05656 4.75897ZM4.33651 7.63095C4.39652 7.63095 4.45404 7.60648 4.4955 7.56315L4.81347 7.23131C4.85321 7.18985 4.90808 7.16647 4.96544 7.16647H4.97853C5.03885 7.16647 5.09621 7.19234 5.13611 7.23739L5.40404 7.54024C5.45501 7.59791 5.52827 7.6308 5.60527 7.6308H9.38285C9.52438 7.33839 9.62803 7.02463 9.68975 6.69591H6.06383C5.98683 6.69591 5.91357 6.66287 5.8626 6.60535L5.59467 6.3025C5.55477 6.2573 5.49725 6.23158 5.43709 6.23158C5.37692 6.23158 5.31941 6.25746 5.27951 6.3025L5.0496 6.56233C4.97432 6.64728 4.86631 6.69606 4.75268 6.69606H2.32147C2.3832 7.02479 2.487 7.33855 2.62837 7.63095H4.33651ZM5.57359 8.55745H4.59116C4.51417 8.55745 4.44091 8.52441 4.38994 8.46689L4.12201 8.16404C4.0821 8.11884 4.02459 8.09312 3.96442 8.09312C3.90426 8.09312 3.84675 8.119 3.80684 8.16404L3.57694 8.42387C3.50166 8.50882 3.39364 8.55761 3.28001 8.55761H3.26474C3.94915 9.29096 4.92378 9.74998 6.00596 9.74998C7.08815 9.74998 8.06262 9.29096 8.74719 8.55761H5.57359V8.55745Z",
267
574
  fill: "currentColor"
268
575
  })
269
576
  });
270
- }
577
+ });
578
+ SmallAptosLogo.displayName = "SmallAptosLogo";
271
579
 
272
580
  // src/components/AptosPrivacyPolicy.tsx
273
- import { jsx as jsx3, jsxs } from "react/jsx-runtime";
581
+ import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
274
582
  var APTOS_PRIVACY_POLICY_URL = "https://aptoslabs.com/privacy";
275
- var Root = forwardRef(
276
- ({ className, asChild, children }, ref) => {
277
- const Component = asChild ? Slot : "div";
278
- return /* @__PURE__ */ jsx3(Component, {
279
- ref,
280
- className,
281
- children
282
- });
283
- }
284
- );
285
- Root.displayName = "AptosPrivacyPolicy.Root";
286
- var Disclaimer = forwardRef(
287
- ({ className, asChild, children }, ref) => {
288
- const Component = asChild ? Slot : "span";
289
- return /* @__PURE__ */ jsx3(Component, {
290
- ref,
291
- className,
292
- children: children != null ? children : "By continuing, you agree to Aptos Labs'"
293
- });
294
- }
295
- );
296
- Disclaimer.displayName = "AptosPrivacyPolicy.Disclaimer";
297
- var Link = forwardRef(
298
- ({ className, asChild, children }, ref) => {
299
- const Component = asChild ? Slot : "a";
300
- return /* @__PURE__ */ jsx3(Component, {
301
- ref,
302
- className,
303
- href: APTOS_PRIVACY_POLICY_URL,
304
- target: "_blank",
305
- rel: "noopener noreferrer",
306
- children: children != null ? children : "Privacy Policy"
307
- });
308
- }
583
+ var Root2 = createHeadlessComponent("AptosPrivacyPolicy.Root", "div");
584
+ var Disclaimer = createHeadlessComponent(
585
+ "AptosPrivacyPolicy.Disclaimer",
586
+ "span",
587
+ { children: "By continuing, you agree to Aptos Labs'" }
309
588
  );
310
- Link.displayName = "AptosPrivacyPolicy.Link";
311
- var PoweredBy = forwardRef(({ className }, ref) => {
312
- return /* @__PURE__ */ jsxs("div", {
589
+ var Link = createHeadlessComponent("AptosPrivacyPolicy.Disclaimer", "a", {
590
+ href: APTOS_PRIVACY_POLICY_URL,
591
+ target: "_blank",
592
+ rel: "noopener noreferrer",
593
+ children: "Privacy Policy"
594
+ });
595
+ var PoweredBy = forwardRef6(({ className }, ref) => {
596
+ return /* @__PURE__ */ jsxs5("div", {
313
597
  ref,
314
598
  className,
315
599
  children: [
316
- /* @__PURE__ */ jsx3("span", {
600
+ /* @__PURE__ */ jsx8("span", {
317
601
  children: "Powered by"
318
602
  }),
319
- /* @__PURE__ */ jsx3(SmallAptosLogo, {}),
320
- /* @__PURE__ */ jsx3("span", {
603
+ /* @__PURE__ */ jsx8(SmallAptosLogo, {}),
604
+ /* @__PURE__ */ jsx8("span", {
321
605
  children: "Aptos Labs"
322
606
  })
323
607
  ]
324
608
  });
325
609
  });
326
610
  PoweredBy.displayName = "AptosPrivacyPolicy.PoweredBy";
327
- var AptosPrivacyPolicy = Object.assign(Root, {
611
+ var AptosPrivacyPolicy = Object.assign(Root2, {
328
612
  Disclaimer,
329
613
  Link,
330
614
  PoweredBy
@@ -336,15 +620,17 @@ import {
336
620
  isRedirectable
337
621
  } from "@aptos-labs/wallet-adapter-core";
338
622
  import { Slot as Slot2 } from "@radix-ui/react-slot";
339
- import {
340
- createContext as createContext2,
341
- forwardRef as forwardRef2,
342
- useCallback as useCallback2,
343
- useContext as useContext2
344
- } from "react";
345
- import { jsx as jsx4 } from "react/jsx-runtime";
346
- var WalletItemContext = createContext2(null);
347
- var WalletItemRoot = forwardRef2(
623
+ import { createContext as createContext3, forwardRef as forwardRef7, useCallback as useCallback2, useContext as useContext3 } from "react";
624
+ import { jsx as jsx9 } from "react/jsx-runtime";
625
+ function useWalletItemContext(displayName) {
626
+ const context = useContext3(WalletItemContext);
627
+ if (!context) {
628
+ throw new Error(`\`${displayName}\` must be used within \`WalletItem\``);
629
+ }
630
+ return context;
631
+ }
632
+ var WalletItemContext = createContext3(null);
633
+ var Root3 = forwardRef7(
348
634
  ({ wallet, onConnect, className, asChild, children }, ref) => {
349
635
  const { connect } = useWallet();
350
636
  const connectWallet = useCallback2(() => {
@@ -356,9 +642,9 @@ var WalletItemRoot = forwardRef2(
356
642
  if (!isWalletReady && isRedirectable() && !mobileSupport)
357
643
  return null;
358
644
  const Component = asChild ? Slot2 : "div";
359
- return /* @__PURE__ */ jsx4(WalletItemContext.Provider, {
645
+ return /* @__PURE__ */ jsx9(WalletItemContext.Provider, {
360
646
  value: { wallet, connectWallet },
361
- children: /* @__PURE__ */ jsx4(Component, {
647
+ children: /* @__PURE__ */ jsx9(Component, {
362
648
  ref,
363
649
  className,
364
650
  children
@@ -366,83 +652,64 @@ var WalletItemRoot = forwardRef2(
366
652
  });
367
653
  }
368
654
  );
369
- WalletItemRoot.displayName = "WalletItem";
370
- var WalletItemIcon = forwardRef2(
371
- ({ className, asChild, children }, ref) => {
372
- const context = useContext2(WalletItemContext);
373
- if (!context) {
374
- throw new Error("`WalletItem.Icon` must be used within `WalletItem`");
375
- }
376
- const Component = asChild ? Slot2 : "img";
377
- return /* @__PURE__ */ jsx4(Component, {
378
- ref,
655
+ Root3.displayName = "WalletItem";
656
+ var Icon = createHeadlessComponent(
657
+ "WalletItem.Icon",
658
+ "img",
659
+ (displayName) => {
660
+ const context = useWalletItemContext(displayName);
661
+ return {
379
662
  src: context.wallet.icon,
380
- alt: `${context.wallet.name} icon`,
381
- className,
382
- children
383
- });
663
+ alt: `${context.wallet.name} icon`
664
+ };
384
665
  }
385
666
  );
386
- WalletItemIcon.displayName = "WalletItem.Icon";
387
- var WalletItemName = forwardRef2(
388
- ({ className, asChild, children }, ref) => {
389
- const context = useContext2(WalletItemContext);
390
- if (!context) {
391
- throw new Error("`WalletItem.Name` must be used within `WalletItem`");
392
- }
393
- const Component = asChild ? Slot2 : "div";
394
- return /* @__PURE__ */ jsx4(Component, {
395
- ref,
396
- className,
397
- children: children != null ? children : context.wallet.name
398
- });
667
+ var Name = createHeadlessComponent(
668
+ "WalletItem.Name",
669
+ "div",
670
+ (displayName) => {
671
+ const context = useWalletItemContext(displayName);
672
+ return {
673
+ children: context.wallet.name
674
+ };
399
675
  }
400
676
  );
401
- WalletItemName.displayName = "WalletItem.Name";
402
- var WalletItemConnectButton = forwardRef2(({ className, asChild, children }, ref) => {
403
- const context = useContext2(WalletItemContext);
404
- if (!context) {
405
- throw new Error(
406
- "`WalletItem.ConnectButton` must be used within `WalletItem`"
407
- );
677
+ var ConnectButton = createHeadlessComponent(
678
+ "WalletItem.ConnectButton",
679
+ "button",
680
+ (displayName) => {
681
+ const context = useWalletItemContext(displayName);
682
+ return {
683
+ onClick: context.connectWallet,
684
+ children: "Connect"
685
+ };
408
686
  }
409
- const Component = asChild ? Slot2 : "button";
410
- return /* @__PURE__ */ jsx4(Component, {
411
- ref,
412
- className,
413
- onClick: context.connectWallet,
414
- children: children != null ? children : "Connect"
415
- });
416
- });
417
- WalletItemConnectButton.displayName = "WalletItem.ConnectButton";
418
- var WalletItemInstallLink = forwardRef2(({ className, asChild, children }, ref) => {
419
- const context = useContext2(WalletItemContext);
420
- if (!context) {
421
- throw new Error(
422
- "`WalletItem.InstallLink` must be used within `WalletItem`"
423
- );
687
+ );
688
+ var InstallLink = createHeadlessComponent(
689
+ "WalletItem.InstallLink",
690
+ "a",
691
+ (displayName) => {
692
+ const context = useWalletItemContext(displayName);
693
+ return {
694
+ href: context.wallet.url,
695
+ target: "_blank",
696
+ rel: "noopener noreferrer",
697
+ children: "Install"
698
+ };
424
699
  }
425
- const Component = asChild ? Slot2 : "a";
426
- return /* @__PURE__ */ jsx4(Component, {
427
- ref,
428
- className,
429
- href: context.wallet.url,
430
- target: "_blank",
431
- rel: "noopener noreferrer",
432
- children: children != null ? children : "Install"
433
- });
434
- });
435
- WalletItemInstallLink.displayName = "WalletItem.InstallLink";
436
- var WalletItem = Object.assign(WalletItemRoot, {
437
- Icon: WalletItemIcon,
438
- Name: WalletItemName,
439
- ConnectButton: WalletItemConnectButton,
440
- InstallLink: WalletItemInstallLink
700
+ );
701
+ var WalletItem = Object.assign(Root3, {
702
+ Icon,
703
+ Name,
704
+ ConnectButton,
705
+ InstallLink
441
706
  });
442
707
  export {
443
708
  APTOS_PRIVACY_POLICY_URL,
709
+ AboutAptosConnect,
444
710
  AptosPrivacyPolicy,
445
711
  AptosWalletAdapterProvider,
712
+ EXPLORE_ECOSYSTEM_URL,
446
713
  WalletContext,
447
714
  WalletItem,
448
715
  useWallet