@aptos-labs/wallet-adapter-react 3.4.2 → 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.js CHANGED
@@ -22,8 +22,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
22
22
  var src_exports = {};
23
23
  __export(src_exports, {
24
24
  APTOS_PRIVACY_POLICY_URL: () => APTOS_PRIVACY_POLICY_URL,
25
+ AboutAptosConnect: () => AboutAptosConnect,
25
26
  AptosPrivacyPolicy: () => AptosPrivacyPolicy,
26
27
  AptosWalletAdapterProvider: () => AptosWalletAdapterProvider,
28
+ EXPLORE_ECOSYSTEM_URL: () => EXPLORE_ECOSYSTEM_URL,
27
29
  WalletContext: () => WalletContext,
28
30
  WalletItem: () => WalletItem,
29
31
  useWallet: () => useWallet
@@ -69,15 +71,24 @@ var AptosWalletAdapterProvider = ({
69
71
  }) => {
70
72
  const [{ connected, account, network, wallet }, setState] = (0, import_react2.useState)(initialState);
71
73
  const [isLoading, setIsLoading] = (0, import_react2.useState)(true);
72
- const walletCore = (0, import_react2.useMemo)(
73
- () => new import_wallet_adapter_core.WalletCore(plugins != null ? plugins : [], optInWallets != null ? optInWallets : [], dappConfig),
74
- []
75
- );
76
- const [wallets, setWallets] = (0, import_react2.useState)(walletCore.wallets);
74
+ const [walletCore, setWalletCore] = (0, import_react2.useState)();
75
+ const [wallets, setWallets] = (0, import_react2.useState)(plugins != null ? plugins : []);
76
+ (0, import_react2.useEffect)(() => {
77
+ const walletCore2 = new import_wallet_adapter_core.WalletCore(
78
+ plugins != null ? plugins : [],
79
+ optInWallets != null ? optInWallets : [],
80
+ dappConfig
81
+ );
82
+ setWalletCore(walletCore2);
83
+ }, []);
84
+ (0, import_react2.useEffect)(() => {
85
+ var _a;
86
+ setWallets((_a = walletCore == null ? void 0 : walletCore.wallets) != null ? _a : []);
87
+ }, [walletCore]);
77
88
  const connect = async (walletName) => {
78
89
  try {
79
90
  setIsLoading(true);
80
- await walletCore.connect(walletName);
91
+ await (walletCore == null ? void 0 : walletCore.connect(walletName));
81
92
  } catch (error) {
82
93
  if (onError)
83
94
  onError(error);
@@ -88,7 +99,7 @@ var AptosWalletAdapterProvider = ({
88
99
  };
89
100
  const disconnect = async () => {
90
101
  try {
91
- await walletCore.disconnect();
102
+ await (walletCore == null ? void 0 : walletCore.disconnect());
92
103
  } catch (error) {
93
104
  if (onError)
94
105
  onError(error);
@@ -96,8 +107,15 @@ var AptosWalletAdapterProvider = ({
96
107
  }
97
108
  };
98
109
  const signTransaction = async (transaction, asFeePayer, options) => {
110
+ if (!walletCore) {
111
+ throw new Error("WalletCore is not initialized");
112
+ }
99
113
  try {
100
- return await walletCore.signTransaction(transaction, asFeePayer, options);
114
+ return await (walletCore == null ? void 0 : walletCore.signTransaction(
115
+ transaction,
116
+ asFeePayer,
117
+ options
118
+ ));
101
119
  } catch (error) {
102
120
  if (onError)
103
121
  onError(error);
@@ -105,8 +123,11 @@ var AptosWalletAdapterProvider = ({
105
123
  }
106
124
  };
107
125
  const signMessage = async (message) => {
126
+ if (!walletCore) {
127
+ throw new Error("WalletCore is not initialized");
128
+ }
108
129
  try {
109
- return await walletCore.signMessage(message);
130
+ return await (walletCore == null ? void 0 : walletCore.signMessage(message));
110
131
  } catch (error) {
111
132
  if (onError)
112
133
  onError(error);
@@ -114,8 +135,11 @@ var AptosWalletAdapterProvider = ({
114
135
  }
115
136
  };
116
137
  const signMessageAndVerify = async (message) => {
138
+ if (!walletCore) {
139
+ throw new Error("WalletCore is not initialized");
140
+ }
117
141
  try {
118
- return await walletCore.signMessageAndVerify(message);
142
+ return await (walletCore == null ? void 0 : walletCore.signMessageAndVerify(message));
119
143
  } catch (error) {
120
144
  if (onError)
121
145
  onError(error);
@@ -123,8 +147,11 @@ var AptosWalletAdapterProvider = ({
123
147
  }
124
148
  };
125
149
  const submitTransaction = async (transaction) => {
150
+ if (!walletCore) {
151
+ throw new Error("WalletCore is not initialized");
152
+ }
126
153
  try {
127
- return await walletCore.submitTransaction(transaction);
154
+ return await (walletCore == null ? void 0 : walletCore.submitTransaction(transaction));
128
155
  } catch (error) {
129
156
  if (onError)
130
157
  onError(error);
@@ -133,7 +160,7 @@ var AptosWalletAdapterProvider = ({
133
160
  };
134
161
  const signAndSubmitTransaction = async (transaction) => {
135
162
  try {
136
- return await walletCore.signAndSubmitTransaction(transaction);
163
+ return await (walletCore == null ? void 0 : walletCore.signAndSubmitTransaction(transaction));
137
164
  } catch (error) {
138
165
  if (onError)
139
166
  onError(error);
@@ -141,8 +168,11 @@ var AptosWalletAdapterProvider = ({
141
168
  }
142
169
  };
143
170
  const changeNetwork = async (network2) => {
171
+ if (!walletCore) {
172
+ throw new Error("WalletCore is not initialized");
173
+ }
144
174
  try {
145
- return await walletCore.changeNetwork(network2);
175
+ return await (walletCore == null ? void 0 : walletCore.changeNetwork(network2));
146
176
  } catch (error) {
147
177
  if (onError)
148
178
  onError(error);
@@ -160,8 +190,8 @@ var AptosWalletAdapterProvider = ({
160
190
  }, [autoConnect, wallets]);
161
191
  (0, import_react2.useEffect)(() => {
162
192
  if (connected) {
163
- walletCore.onAccountChange();
164
- walletCore.onNetworkChange();
193
+ walletCore == null ? void 0 : walletCore.onAccountChange();
194
+ walletCore == null ? void 0 : walletCore.onNetworkChange();
165
195
  }
166
196
  }, [connected]);
167
197
  const handleConnect = () => {
@@ -169,9 +199,9 @@ var AptosWalletAdapterProvider = ({
169
199
  return {
170
200
  ...state,
171
201
  connected: true,
172
- account: walletCore.account,
173
- network: walletCore.network,
174
- wallet: walletCore.wallet
202
+ account: (walletCore == null ? void 0 : walletCore.account) || null,
203
+ network: (walletCore == null ? void 0 : walletCore.network) || null,
204
+ wallet: (walletCore == null ? void 0 : walletCore.wallet) || null
175
205
  };
176
206
  });
177
207
  };
@@ -182,8 +212,8 @@ var AptosWalletAdapterProvider = ({
182
212
  return {
183
213
  ...state,
184
214
  connected: false,
185
- account: walletCore.account,
186
- network: walletCore.network,
215
+ account: (walletCore == null ? void 0 : walletCore.account) || null,
216
+ network: (walletCore == null ? void 0 : walletCore.network) || null,
187
217
  wallet: null
188
218
  };
189
219
  });
@@ -191,24 +221,24 @@ var AptosWalletAdapterProvider = ({
191
221
  const handleAccountChange = (0, import_react2.useCallback)(() => {
192
222
  if (!connected)
193
223
  return;
194
- if (!walletCore.wallet)
224
+ if (!(walletCore == null ? void 0 : walletCore.wallet))
195
225
  return;
196
226
  setState((state) => {
197
227
  return {
198
228
  ...state,
199
- account: walletCore.account
229
+ account: (walletCore == null ? void 0 : walletCore.account) || null
200
230
  };
201
231
  });
202
232
  }, [connected]);
203
233
  const handleNetworkChange = (0, import_react2.useCallback)(() => {
204
234
  if (!connected)
205
235
  return;
206
- if (!walletCore.wallet)
236
+ if (!(walletCore == null ? void 0 : walletCore.wallet))
207
237
  return;
208
238
  setState((state) => {
209
239
  return {
210
240
  ...state,
211
- network: walletCore.network
241
+ network: (walletCore == null ? void 0 : walletCore.network) || null
212
242
  };
213
243
  });
214
244
  }, [connected]);
@@ -236,21 +266,21 @@ var AptosWalletAdapterProvider = ({
236
266
  }
237
267
  };
238
268
  (0, import_react2.useEffect)(() => {
239
- walletCore.on("connect", handleConnect);
240
- walletCore.on("disconnect", handleDisconnect);
241
- walletCore.on("accountChange", handleAccountChange);
242
- walletCore.on("networkChange", handleNetworkChange);
243
- walletCore.on("readyStateChange", handleReadyStateChange);
244
- walletCore.on("standardWalletsAdded", handleStandardWalletsAdded);
269
+ walletCore == null ? void 0 : walletCore.on("connect", handleConnect);
270
+ walletCore == null ? void 0 : walletCore.on("disconnect", handleDisconnect);
271
+ walletCore == null ? void 0 : walletCore.on("accountChange", handleAccountChange);
272
+ walletCore == null ? void 0 : walletCore.on("networkChange", handleNetworkChange);
273
+ walletCore == null ? void 0 : walletCore.on("readyStateChange", handleReadyStateChange);
274
+ walletCore == null ? void 0 : walletCore.on("standardWalletsAdded", handleStandardWalletsAdded);
245
275
  return () => {
246
- walletCore.off("connect", handleConnect);
247
- walletCore.off("disconnect", handleDisconnect);
248
- walletCore.off("accountChange", handleAccountChange);
249
- walletCore.off("networkChange", handleNetworkChange);
250
- walletCore.off("readyStateChange", handleReadyStateChange);
251
- walletCore.off("standardWalletsAdded", handleStandardWalletsAdded);
276
+ walletCore == null ? void 0 : walletCore.off("connect", handleConnect);
277
+ walletCore == null ? void 0 : walletCore.off("disconnect", handleDisconnect);
278
+ walletCore == null ? void 0 : walletCore.off("accountChange", handleAccountChange);
279
+ walletCore == null ? void 0 : walletCore.off("networkChange", handleNetworkChange);
280
+ walletCore == null ? void 0 : walletCore.off("readyStateChange", handleReadyStateChange);
281
+ walletCore == null ? void 0 : walletCore.off("standardWalletsAdded", handleStandardWalletsAdded);
252
282
  };
253
- }, [wallets, connected]);
283
+ }, [wallets, account]);
254
284
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(WalletContext.Provider, {
255
285
  value: {
256
286
  connect,
@@ -272,14 +302,293 @@ var AptosWalletAdapterProvider = ({
272
302
  });
273
303
  };
274
304
 
275
- // src/components/AptosPrivacyPolicy.tsx
276
- var import_react_slot = require("@radix-ui/react-slot");
305
+ // src/components/AboutAptosConnect.tsx
306
+ var import_react7 = require("react");
307
+
308
+ // src/graphics/LinkGraphic.tsx
277
309
  var import_react3 = require("react");
310
+ var import_jsx_runtime = require("react/jsx-runtime");
311
+ var LinkGraphic = (0, import_react3.forwardRef)(
312
+ (props, ref) => {
313
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", {
314
+ ref,
315
+ width: "102",
316
+ height: "132",
317
+ viewBox: "0 0 102 132",
318
+ fill: "none",
319
+ ...props,
320
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", {
321
+ stroke: "currentColor",
322
+ strokeMiterlimit: "10",
323
+ children: [
324
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
325
+ 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"
326
+ }),
327
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
328
+ 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"
329
+ }),
330
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
331
+ 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"
332
+ }),
333
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
334
+ 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"
335
+ }),
336
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
337
+ 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"
338
+ }),
339
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
340
+ 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"
341
+ })
342
+ ]
343
+ })
344
+ });
345
+ }
346
+ );
347
+ LinkGraphic.displayName = "LinkGraphic";
348
+
349
+ // src/graphics/WalletGraphic.tsx
350
+ var import_react4 = require("react");
351
+ var import_jsx_runtime = require("react/jsx-runtime");
352
+ var WalletGraphic = (0, import_react4.forwardRef)(
353
+ (props, ref) => {
354
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", {
355
+ ref,
356
+ width: "128",
357
+ height: "102",
358
+ viewBox: "0 0 128 102",
359
+ fill: "none",
360
+ ...props,
361
+ children: [
362
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
363
+ fill: "currentColor",
364
+ 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"
365
+ }),
366
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
367
+ stroke: "currentColor",
368
+ strokeMiterlimit: "10",
369
+ 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"
370
+ }),
371
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
372
+ stroke: "currentColor",
373
+ strokeMiterlimit: "10",
374
+ 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"
375
+ }),
376
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
377
+ stroke: "currentColor",
378
+ strokeMiterlimit: "10",
379
+ d: "M9.86 23.69V5.72h107.97v18.04H84.65"
380
+ }),
381
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
382
+ stroke: "currentColor",
383
+ strokeMiterlimit: "10",
384
+ d: "M117.83 20.46h3.39V1H13.25v4.72M9.36 23.69h31.78"
385
+ })
386
+ ]
387
+ });
388
+ }
389
+ );
390
+ WalletGraphic.displayName = "WalletGraphic";
391
+
392
+ // src/graphics/Web3Graphic.tsx
393
+ var import_react5 = require("react");
394
+ var import_jsx_runtime = require("react/jsx-runtime");
395
+ var Web3Graphic = (0, import_react5.forwardRef)(
396
+ (props, ref) => {
397
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", {
398
+ ref,
399
+ width: "142",
400
+ height: "108",
401
+ viewBox: "0 0 142 108",
402
+ fill: "none",
403
+ ...props,
404
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", {
405
+ stroke: "currentColor",
406
+ strokeLinejoin: "round",
407
+ children: [
408
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
409
+ 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"
410
+ }),
411
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
412
+ 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"
413
+ }),
414
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
415
+ d: "M36.55 30.8s-.08 5.92-.1 9l.1-9ZM71 59.51v-9.07L36.55 30.8l-.1 9L63.5 55"
416
+ }),
417
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
418
+ d: "M71 59.51v-9.07L36.44 70.78l-.1 9.14L55.5 68.5"
419
+ }),
420
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
421
+ 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"
422
+ }),
423
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
424
+ d: "m105.44 30.8.11 9-.1-9Z"
425
+ }),
426
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
427
+ d: "M71 59.51v-9.07l34.44-19.64.11 9L78.5 55"
428
+ }),
429
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
430
+ d: "M71 59.51v-9.07l34.56 20.34.1 9.14L87 69"
431
+ }),
432
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
433
+ 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"
434
+ }),
435
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
436
+ 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"
437
+ }),
438
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
439
+ d: "m71.3 97.6 19.96-23.83.06 9.33L71.3 107v-9.4Z"
440
+ })
441
+ ]
442
+ })
443
+ });
444
+ }
445
+ );
446
+ Web3Graphic.displayName = "Web3Graphic";
447
+
448
+ // src/components/utils.tsx
449
+ var import_react_slot = require("@radix-ui/react-slot");
450
+ var import_react6 = require("react");
451
+ var import_jsx_runtime = require("react/jsx-runtime");
452
+ function createHeadlessComponent(displayName, elementType, props) {
453
+ const component = (0, import_react6.forwardRef)(({ className, asChild, children }, ref) => {
454
+ const Component = asChild ? import_react_slot.Slot : elementType;
455
+ const { children: defaultChildren, ...resolvedProps } = typeof props === "function" ? props(displayName) : props != null ? props : {};
456
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {
457
+ ref,
458
+ className,
459
+ children: children != null ? children : defaultChildren,
460
+ ...resolvedProps
461
+ });
462
+ });
463
+ component.displayName = displayName;
464
+ return component;
465
+ }
466
+
467
+ // src/components/AboutAptosConnect.tsx
468
+ var import_jsx_runtime = require("react/jsx-runtime");
469
+ var EXPLORE_ECOSYSTEM_URL = "https://aptosfoundation.org/ecosystem/projects/all";
470
+ var AboutAptosConnectContext = (0, import_react7.createContext)(null);
471
+ function useAboutAptosConnectContext(displayName) {
472
+ const context = (0, import_react7.useContext)(AboutAptosConnectContext);
473
+ if (!context) {
474
+ throw new Error(
475
+ `\`${displayName}\` must be used within \`AboutAptosConnect\``
476
+ );
477
+ }
478
+ return context;
479
+ }
480
+ var educationScreens = [
481
+ {
482
+ Graphic: LinkGraphic,
483
+ Title: createHeadlessComponent("EducationScreen.Title", "h3", {
484
+ children: "A better way to login."
485
+ }),
486
+ Description: createHeadlessComponent("EducationScreen.Description", "p", {
487
+ children: "Aptos Connect is a web3 wallet that uses a Social Login to create accounts on the Aptos blockchain."
488
+ })
489
+ },
490
+ {
491
+ Graphic: WalletGraphic,
492
+ Title: createHeadlessComponent("EducationScreen.Title", "h2", {
493
+ children: "What is a wallet?"
494
+ }),
495
+ Description: createHeadlessComponent("EducationScreen.Description", "p", {
496
+ children: "Wallets are a secure way to send, receive, and interact with digital assets like cryptocurrencies & NFTs."
497
+ })
498
+ },
499
+ {
500
+ Graphic: Web3Graphic,
501
+ Title: createHeadlessComponent("EducationScreen.Title", "h2", {
502
+ children: "Explore more of web3."
503
+ }),
504
+ Description: createHeadlessComponent("EducationScreen.Description", "p", {
505
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
506
+ children: [
507
+ "Aptos Connect lets you to take one account across any application built on Aptos.",
508
+ " ",
509
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
510
+ href: EXPLORE_ECOSYSTEM_URL,
511
+ target: "_blank",
512
+ rel: "noopener noreferrer",
513
+ children: "Explore the ecosystem"
514
+ }),
515
+ "."
516
+ ]
517
+ })
518
+ })
519
+ }
520
+ ];
521
+ var educationScreenIndicators = Array(educationScreens.length).fill(null).map(
522
+ (_, index) => createHeadlessComponent(
523
+ "AboutAptosConnect.ScreenIndicator",
524
+ "button",
525
+ (displayName) => {
526
+ const context = useAboutAptosConnectContext(displayName);
527
+ const isActive = context.screenIndex - 1 === index;
528
+ return {
529
+ "aria-label": `Go to screen ${index + 1}`,
530
+ "aria-current": isActive ? "step" : void 0,
531
+ "data-active": isActive || void 0,
532
+ onClick: () => {
533
+ context.setScreenIndex(index + 1);
534
+ }
535
+ };
536
+ }
537
+ )
538
+ );
539
+ var Root = ({ renderEducationScreen, children }) => {
540
+ const [screenIndex, setScreenIndex] = (0, import_react7.useState)(0);
541
+ const currentEducationScreen = (0, import_react7.useMemo)(
542
+ () => educationScreens.map((screen, i) => ({
543
+ ...screen,
544
+ screenIndex: i,
545
+ totalScreens: educationScreens.length,
546
+ screenIndicators: educationScreenIndicators,
547
+ back: () => {
548
+ setScreenIndex(screenIndex - 1);
549
+ },
550
+ next: () => {
551
+ setScreenIndex(
552
+ screenIndex === educationScreens.length ? 0 : screenIndex + 1
553
+ );
554
+ },
555
+ cancel: () => {
556
+ setScreenIndex(0);
557
+ }
558
+ }))[screenIndex - 1],
559
+ [screenIndex]
560
+ );
561
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AboutAptosConnectContext.Provider, {
562
+ value: { screenIndex, setScreenIndex },
563
+ children: screenIndex === 0 ? children : renderEducationScreen(currentEducationScreen)
564
+ });
565
+ };
566
+ Root.displayName = "AboutAptosConnect";
567
+ var Trigger = createHeadlessComponent(
568
+ "AboutAptosConnect.Trigger",
569
+ "button",
570
+ (displayName) => {
571
+ const context = useAboutAptosConnectContext(displayName);
572
+ return {
573
+ onClick: () => {
574
+ context.setScreenIndex(1);
575
+ }
576
+ };
577
+ }
578
+ );
579
+ var AboutAptosConnect = Object.assign(Root, {
580
+ Trigger
581
+ });
582
+
583
+ // src/components/AptosPrivacyPolicy.tsx
584
+ var import_react9 = require("react");
278
585
 
279
586
  // src/graphics/SmallAptosLogo.tsx
587
+ var import_react8 = require("react");
280
588
  var import_jsx_runtime = require("react/jsx-runtime");
281
- function SmallAptosLogo(props) {
589
+ var SmallAptosLogo = (0, import_react8.forwardRef)((props, ref) => {
282
590
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", {
591
+ ref,
283
592
  width: "12",
284
593
  height: "12",
285
594
  viewBox: "0 0 12 12",
@@ -292,48 +601,25 @@ function SmallAptosLogo(props) {
292
601
  fill: "currentColor"
293
602
  })
294
603
  });
295
- }
604
+ });
605
+ SmallAptosLogo.displayName = "SmallAptosLogo";
296
606
 
297
607
  // src/components/AptosPrivacyPolicy.tsx
298
608
  var import_jsx_runtime = require("react/jsx-runtime");
299
609
  var APTOS_PRIVACY_POLICY_URL = "https://aptoslabs.com/privacy";
300
- var Root = (0, import_react3.forwardRef)(
301
- ({ className, asChild, children }, ref) => {
302
- const Component = asChild ? import_react_slot.Slot : "div";
303
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {
304
- ref,
305
- className,
306
- children
307
- });
308
- }
610
+ var Root2 = createHeadlessComponent("AptosPrivacyPolicy.Root", "div");
611
+ var Disclaimer = createHeadlessComponent(
612
+ "AptosPrivacyPolicy.Disclaimer",
613
+ "span",
614
+ { children: "By continuing, you agree to Aptos Labs'" }
309
615
  );
310
- Root.displayName = "AptosPrivacyPolicy.Root";
311
- var Disclaimer = (0, import_react3.forwardRef)(
312
- ({ className, asChild, children }, ref) => {
313
- const Component = asChild ? import_react_slot.Slot : "span";
314
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {
315
- ref,
316
- className,
317
- children: children != null ? children : "By continuing, you agree to Aptos Labs'"
318
- });
319
- }
320
- );
321
- Disclaimer.displayName = "AptosPrivacyPolicy.Disclaimer";
322
- var Link = (0, import_react3.forwardRef)(
323
- ({ className, asChild, children }, ref) => {
324
- const Component = asChild ? import_react_slot.Slot : "a";
325
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {
326
- ref,
327
- className,
328
- href: APTOS_PRIVACY_POLICY_URL,
329
- target: "_blank",
330
- rel: "noopener noreferrer",
331
- children: children != null ? children : "Privacy Policy"
332
- });
333
- }
334
- );
335
- Link.displayName = "AptosPrivacyPolicy.Link";
336
- var PoweredBy = (0, import_react3.forwardRef)(({ className }, ref) => {
616
+ var Link = createHeadlessComponent("AptosPrivacyPolicy.Disclaimer", "a", {
617
+ href: APTOS_PRIVACY_POLICY_URL,
618
+ target: "_blank",
619
+ rel: "noopener noreferrer",
620
+ children: "Privacy Policy"
621
+ });
622
+ var PoweredBy = (0, import_react9.forwardRef)(({ className }, ref) => {
337
623
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
338
624
  ref,
339
625
  className,
@@ -349,7 +635,7 @@ var PoweredBy = (0, import_react3.forwardRef)(({ className }, ref) => {
349
635
  });
350
636
  });
351
637
  PoweredBy.displayName = "AptosPrivacyPolicy.PoweredBy";
352
- var AptosPrivacyPolicy = Object.assign(Root, {
638
+ var AptosPrivacyPolicy = Object.assign(Root2, {
353
639
  Disclaimer,
354
640
  Link,
355
641
  PoweredBy
@@ -358,13 +644,20 @@ var AptosPrivacyPolicy = Object.assign(Root, {
358
644
  // src/components/WalletItem.tsx
359
645
  var import_wallet_adapter_core2 = require("@aptos-labs/wallet-adapter-core");
360
646
  var import_react_slot2 = require("@radix-ui/react-slot");
361
- var import_react4 = require("react");
647
+ var import_react10 = require("react");
362
648
  var import_jsx_runtime = require("react/jsx-runtime");
363
- var WalletItemContext = (0, import_react4.createContext)(null);
364
- var WalletItemRoot = (0, import_react4.forwardRef)(
649
+ function useWalletItemContext(displayName) {
650
+ const context = (0, import_react10.useContext)(WalletItemContext);
651
+ if (!context) {
652
+ throw new Error(`\`${displayName}\` must be used within \`WalletItem\``);
653
+ }
654
+ return context;
655
+ }
656
+ var WalletItemContext = (0, import_react10.createContext)(null);
657
+ var Root3 = (0, import_react10.forwardRef)(
365
658
  ({ wallet, onConnect, className, asChild, children }, ref) => {
366
659
  const { connect } = useWallet();
367
- const connectWallet = (0, import_react4.useCallback)(() => {
660
+ const connectWallet = (0, import_react10.useCallback)(() => {
368
661
  connect(wallet.name);
369
662
  onConnect == null ? void 0 : onConnect();
370
663
  }, [connect, wallet.name, onConnect]);
@@ -383,84 +676,65 @@ var WalletItemRoot = (0, import_react4.forwardRef)(
383
676
  });
384
677
  }
385
678
  );
386
- WalletItemRoot.displayName = "WalletItem";
387
- var WalletItemIcon = (0, import_react4.forwardRef)(
388
- ({ className, asChild, children }, ref) => {
389
- const context = (0, import_react4.useContext)(WalletItemContext);
390
- if (!context) {
391
- throw new Error("`WalletItem.Icon` must be used within `WalletItem`");
392
- }
393
- const Component = asChild ? import_react_slot2.Slot : "img";
394
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {
395
- ref,
679
+ Root3.displayName = "WalletItem";
680
+ var Icon = createHeadlessComponent(
681
+ "WalletItem.Icon",
682
+ "img",
683
+ (displayName) => {
684
+ const context = useWalletItemContext(displayName);
685
+ return {
396
686
  src: context.wallet.icon,
397
- alt: `${context.wallet.name} icon`,
398
- className,
399
- children
400
- });
687
+ alt: `${context.wallet.name} icon`
688
+ };
401
689
  }
402
690
  );
403
- WalletItemIcon.displayName = "WalletItem.Icon";
404
- var WalletItemName = (0, import_react4.forwardRef)(
405
- ({ className, asChild, children }, ref) => {
406
- const context = (0, import_react4.useContext)(WalletItemContext);
407
- if (!context) {
408
- throw new Error("`WalletItem.Name` must be used within `WalletItem`");
409
- }
410
- const Component = asChild ? import_react_slot2.Slot : "div";
411
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {
412
- ref,
413
- className,
414
- children: children != null ? children : context.wallet.name
415
- });
691
+ var Name = createHeadlessComponent(
692
+ "WalletItem.Name",
693
+ "div",
694
+ (displayName) => {
695
+ const context = useWalletItemContext(displayName);
696
+ return {
697
+ children: context.wallet.name
698
+ };
416
699
  }
417
700
  );
418
- WalletItemName.displayName = "WalletItem.Name";
419
- var WalletItemConnectButton = (0, import_react4.forwardRef)(({ className, asChild, children }, ref) => {
420
- const context = (0, import_react4.useContext)(WalletItemContext);
421
- if (!context) {
422
- throw new Error(
423
- "`WalletItem.ConnectButton` must be used within `WalletItem`"
424
- );
701
+ var ConnectButton = createHeadlessComponent(
702
+ "WalletItem.ConnectButton",
703
+ "button",
704
+ (displayName) => {
705
+ const context = useWalletItemContext(displayName);
706
+ return {
707
+ onClick: context.connectWallet,
708
+ children: "Connect"
709
+ };
425
710
  }
426
- const Component = asChild ? import_react_slot2.Slot : "button";
427
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {
428
- ref,
429
- className,
430
- onClick: context.connectWallet,
431
- children: children != null ? children : "Connect"
432
- });
433
- });
434
- WalletItemConnectButton.displayName = "WalletItem.ConnectButton";
435
- var WalletItemInstallLink = (0, import_react4.forwardRef)(({ className, asChild, children }, ref) => {
436
- const context = (0, import_react4.useContext)(WalletItemContext);
437
- if (!context) {
438
- throw new Error(
439
- "`WalletItem.InstallLink` must be used within `WalletItem`"
440
- );
711
+ );
712
+ var InstallLink = createHeadlessComponent(
713
+ "WalletItem.InstallLink",
714
+ "a",
715
+ (displayName) => {
716
+ const context = useWalletItemContext(displayName);
717
+ return {
718
+ href: context.wallet.url,
719
+ target: "_blank",
720
+ rel: "noopener noreferrer",
721
+ children: "Install"
722
+ };
441
723
  }
442
- const Component = asChild ? import_react_slot2.Slot : "a";
443
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {
444
- ref,
445
- className,
446
- href: context.wallet.url,
447
- target: "_blank",
448
- rel: "noopener noreferrer",
449
- children: children != null ? children : "Install"
450
- });
451
- });
452
- WalletItemInstallLink.displayName = "WalletItem.InstallLink";
453
- var WalletItem = Object.assign(WalletItemRoot, {
454
- Icon: WalletItemIcon,
455
- Name: WalletItemName,
456
- ConnectButton: WalletItemConnectButton,
457
- InstallLink: WalletItemInstallLink
724
+ );
725
+ var WalletItem = Object.assign(Root3, {
726
+ Icon,
727
+ Name,
728
+ ConnectButton,
729
+ InstallLink
458
730
  });
459
731
  // Annotate the CommonJS export names for ESM import in node:
460
732
  0 && (module.exports = {
461
733
  APTOS_PRIVACY_POLICY_URL,
734
+ AboutAptosConnect,
462
735
  AptosPrivacyPolicy,
463
736
  AptosWalletAdapterProvider,
737
+ EXPLORE_ECOSYSTEM_URL,
464
738
  WalletContext,
465
739
  WalletItem,
466
740
  useWallet