@aptos-labs/wallet-adapter-react 3.3.0 → 3.4.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/README.md CHANGED
@@ -66,14 +66,16 @@ Import the `AptosWalletAdapterProvider`.
66
66
  import { AptosWalletAdapterProvider } from "@aptos-labs/wallet-adapter-react";
67
67
  ```
68
68
 
69
- Wrap your app with the Provider, pass it the `plugins (wallets)` you want to have on your app as an array and a `autoConnect` option (set to false by default)
69
+ Wrap your app with the Provider, pass it the relevant props.
70
70
 
71
71
  ```js
72
- const wallets = [new AptosWallet()];
72
+ const wallets = [new AptosLegacyStandardWallet()];
73
73
 
74
74
  <AptosWalletAdapterProvider
75
75
  plugins={wallets}
76
76
  autoConnect={true}
77
+ optInWallets={["Petra"]}
78
+ dappConfig={{ netwrok: Network.MAINNET }}
77
79
  onError={(error) => {
78
80
  console.log("error", error);
79
81
  }}
@@ -82,6 +84,14 @@ const wallets = [new AptosWallet()];
82
84
  </AptosWalletAdapterProvider>;
83
85
  ```
84
86
 
87
+ #### Available Provider Props
88
+
89
+ - `plugins` - any legacy standard wallet, i.e a wallet that is not AIP-62 standard compatible, should be installed and passed in this array. [Check here](../../README.md#supported-wallet-packages) for a list of AIP-62 and legacy standard wallets.
90
+ - `autoConnect` - a prop indicates whether the dapp should auto connect with a previous connected wallet.
91
+ - `optInWallets` - the adapter detects and adds AIP-62 standard wallets by default, sometimes you might want to opt-in with specific wallets. This props lets you define the AIP-62 standard wallets you want to support in your dapp.
92
+ - `dappConfig` - the adapter comes built-in with AIP-62 standard SDK wallets and it needs to know what configuration your dapp is in to render the current instance.
93
+ - `onError` - a callback function to fire when the adapter throws an error
94
+
85
95
  #### Use Wallet
86
96
 
87
97
  On any page you want to use the wallet props, import `useWallet` from `@aptos-labs/wallet-adapter-react`
@@ -112,14 +122,19 @@ const {
112
122
  ### Use a UI package (recommended)
113
123
 
114
124
  As part of the wallet adapter repo we provide a wallet connect UI package that provides a wallet connect button and a wallet select modal.
115
- You can find it [here](../wallet-adapter-ant-design/) with instructions on how to use it.
125
+
126
+ The available UI Packages are
127
+
128
+ - [shadcn/ui](../wallet-adapter-react/src/WalletItem.tsx)
129
+ - [Ant Design](<(../wallet-adapter-ant-design/)>)
130
+ - [MUI](../wallet-adapter-mui-design/)
116
131
 
117
132
  #### Examples
118
133
 
119
134
  ##### Initialize Aptos
120
135
 
121
136
  ```js
122
- const aptosConfig = new AptosConfig({ network: Network.TESTNET });
137
+ const aptosConfig = new AptosConfig({ network: Network.MAINNET });
123
138
  const aptos = new Aptos(aptosConfig);
124
139
  ```
125
140
 
@@ -0,0 +1,22 @@
1
+ import { ReactNode } from "react";
2
+ export declare const APTOS_PRIVACY_POLICY_URL = "https://aptoslabs.com/privacy";
3
+ export interface AptosPrivacyPolicyProps {
4
+ /** A class name for styling the element. */
5
+ className?: string;
6
+ /**
7
+ * Whether to render as the child element instead of the default element provided.
8
+ * All props will be merged into the child element.
9
+ */
10
+ asChild?: boolean;
11
+ children?: ReactNode;
12
+ }
13
+ /**
14
+ * A headless component for rendering the Aptos Labs privacy policy disclaimer
15
+ * that should be placed under the Aptos Connect login options.
16
+ */
17
+ export declare const AptosPrivacyPolicy: import("react").ForwardRefExoticComponent<AptosPrivacyPolicyProps & import("react").RefAttributes<HTMLDivElement>> & {
18
+ Disclaimer: import("react").ForwardRefExoticComponent<AptosPrivacyPolicyProps & import("react").RefAttributes<HTMLSpanElement>>;
19
+ Link: import("react").ForwardRefExoticComponent<AptosPrivacyPolicyProps & import("react").RefAttributes<HTMLAnchorElement>>;
20
+ PoweredBy: import("react").ForwardRefExoticComponent<Pick<AptosPrivacyPolicyProps, "className"> & import("react").RefAttributes<HTMLDivElement>>;
21
+ };
22
+ //# sourceMappingURL=AptosPrivacyPolicy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AptosPrivacyPolicy.d.ts","sourceRoot":"","sources":["../../src/components/AptosPrivacyPolicy.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAc,MAAM,OAAO,CAAC;AAG9C,eAAO,MAAM,wBAAwB,kCAAkC,CAAC;AAExE,MAAM,WAAW,uBAAuB;IACtC,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AA6DD;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;CAI7B,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WalletItem.d.ts","sourceRoot":"","sources":["../../src/components/WalletItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAGf,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,SAAS,EAKV,MAAM,OAAO,CAAC;AAGf,MAAM,WAAW,eAAe;IAC9B,yCAAyC;IACzC,MAAM,EAAE,cAAc,CAAC;IACvB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,MAAM,WAAW,sBAAsB;IACrC,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAmID,kHAAkH;AAClH,eAAO,MAAM,UAAU;;;;;CAKrB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { SVGProps } from "react";
2
+ export declare function SmallAptosLogo(props: SVGProps<SVGSVGElement>): import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=SmallAptosLogo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SmallAptosLogo.d.ts","sourceRoot":"","sources":["../../src/graphics/SmallAptosLogo.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,wBAAgB,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,aAAa,CAAC,2CAW5D"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export * from "@aptos-labs/wallet-adapter-core";
2
- export * from "./WalletItem";
3
2
  export * from "./WalletProvider";
3
+ export * from "./components/AptosPrivacyPolicy";
4
+ export * from "./components/WalletItem";
4
5
  export * from "./useWallet";
5
- export * from "./utils";
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,kBAAkB,CAAC;AACjC,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -21,22 +21,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  // src/index.tsx
22
22
  var src_exports = {};
23
23
  __export(src_exports, {
24
+ APTOS_PRIVACY_POLICY_URL: () => APTOS_PRIVACY_POLICY_URL,
25
+ AptosPrivacyPolicy: () => AptosPrivacyPolicy,
24
26
  AptosWalletAdapterProvider: () => AptosWalletAdapterProvider,
25
27
  WalletContext: () => WalletContext,
26
28
  WalletItem: () => WalletItem,
27
- getAptosConnectWallets: () => getAptosConnectWallets,
28
- isInstallRequired: () => isInstallRequired,
29
- isInstalledOrLoadable: () => isInstalledOrLoadable,
30
- partitionWallets: () => partitionWallets,
31
- truncateAddress: () => truncateAddress,
32
29
  useWallet: () => useWallet
33
30
  });
34
31
  module.exports = __toCommonJS(src_exports);
35
32
  __reExport(src_exports, require("@aptos-labs/wallet-adapter-core"), module.exports);
36
33
 
37
- // src/WalletItem.tsx
38
- var import_wallet_adapter_core = require("@aptos-labs/wallet-adapter-core");
39
- var import_react_slot = require("@radix-ui/react-slot");
34
+ // src/WalletProvider.tsx
40
35
  var import_react2 = require("react");
41
36
 
42
37
  // src/useWallet.tsx
@@ -55,108 +50,8 @@ function useWallet() {
55
50
  return context;
56
51
  }
57
52
 
58
- // src/WalletItem.tsx
59
- var import_jsx_runtime = require("react/jsx-runtime");
60
- var WalletItemContext = (0, import_react2.createContext)(null);
61
- var WalletItemRoot = (0, import_react2.forwardRef)(
62
- ({ wallet, onConnect, className, asChild, children }, ref) => {
63
- const { connect } = useWallet();
64
- const connectWallet = (0, import_react2.useCallback)(() => {
65
- connect(wallet.name);
66
- onConnect == null ? void 0 : onConnect();
67
- }, [connect, wallet.name, onConnect]);
68
- const isWalletReady = wallet.readyState === import_wallet_adapter_core.WalletReadyState.Installed || wallet.readyState === import_wallet_adapter_core.WalletReadyState.Loadable;
69
- const mobileSupport = "deeplinkProvider" in wallet && wallet.deeplinkProvider;
70
- if (!isWalletReady && (0, import_wallet_adapter_core.isRedirectable)() && !mobileSupport)
71
- return null;
72
- const Component = asChild ? import_react_slot.Slot : "div";
73
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(WalletItemContext.Provider, {
74
- value: { wallet, connectWallet },
75
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {
76
- ref,
77
- className,
78
- children
79
- })
80
- });
81
- }
82
- );
83
- WalletItemRoot.displayName = "WalletItem";
84
- var WalletItemIcon = (0, import_react2.forwardRef)(
85
- ({ className, asChild, children }, ref) => {
86
- const context = (0, import_react2.useContext)(WalletItemContext);
87
- if (!context) {
88
- throw new Error("`WalletItem.Icon` must be used within `WalletItem`");
89
- }
90
- const Component = asChild ? import_react_slot.Slot : "img";
91
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {
92
- ref,
93
- src: context.wallet.icon,
94
- alt: `${context.wallet.name} icon`,
95
- className,
96
- children
97
- });
98
- }
99
- );
100
- WalletItemIcon.displayName = "WalletItem.Icon";
101
- var WalletItemName = (0, import_react2.forwardRef)(
102
- ({ className, asChild, children }, ref) => {
103
- const context = (0, import_react2.useContext)(WalletItemContext);
104
- if (!context) {
105
- throw new Error("`WalletItem.Name` must be used within `WalletItem`");
106
- }
107
- const Component = asChild ? import_react_slot.Slot : "div";
108
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {
109
- ref,
110
- className,
111
- children: children != null ? children : context.wallet.name
112
- });
113
- }
114
- );
115
- WalletItemName.displayName = "WalletItem.Name";
116
- var WalletItemConnectButton = (0, import_react2.forwardRef)(({ className, asChild, children }, ref) => {
117
- const context = (0, import_react2.useContext)(WalletItemContext);
118
- if (!context) {
119
- throw new Error(
120
- "`WalletItem.ConnectButton` must be used within `WalletItem`"
121
- );
122
- }
123
- const Component = asChild ? import_react_slot.Slot : "button";
124
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {
125
- ref,
126
- className,
127
- onClick: context.connectWallet,
128
- children: children != null ? children : "Connect"
129
- });
130
- });
131
- WalletItemConnectButton.displayName = "WalletItem.ConnectButton";
132
- var WalletItemInstallLink = (0, import_react2.forwardRef)(({ className, asChild, children }, ref) => {
133
- const context = (0, import_react2.useContext)(WalletItemContext);
134
- if (!context) {
135
- throw new Error(
136
- "`WalletItem.InstallLink` must be used within `WalletItem`"
137
- );
138
- }
139
- const Component = asChild ? import_react_slot.Slot : "a";
140
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {
141
- ref,
142
- className,
143
- href: context.wallet.url,
144
- target: "_blank",
145
- rel: "noopener noreferrer",
146
- children: children != null ? children : "Install"
147
- });
148
- });
149
- WalletItemInstallLink.displayName = "WalletItem.InstallLink";
150
- var WalletItem = Object.assign(WalletItemRoot, {
151
- Icon: WalletItemIcon,
152
- Name: WalletItemName,
153
- ConnectButton: WalletItemConnectButton,
154
- InstallLink: WalletItemInstallLink
155
- });
156
-
157
53
  // src/WalletProvider.tsx
158
- var import_react3 = require("react");
159
- var import_wallet_adapter_core2 = require("@aptos-labs/wallet-adapter-core");
54
+ var import_wallet_adapter_core = require("@aptos-labs/wallet-adapter-core");
160
55
  var import_jsx_runtime = require("react/jsx-runtime");
161
56
  var initialState = {
162
57
  connected: false,
@@ -172,13 +67,13 @@ var AptosWalletAdapterProvider = ({
172
67
  dappConfig,
173
68
  onError
174
69
  }) => {
175
- const [{ connected, account, network, wallet }, setState] = (0, import_react3.useState)(initialState);
176
- const [isLoading, setIsLoading] = (0, import_react3.useState)(true);
177
- const walletCore = (0, import_react3.useMemo)(
178
- () => new import_wallet_adapter_core2.WalletCore(plugins != null ? plugins : [], optInWallets != null ? optInWallets : [], dappConfig),
70
+ const [{ connected, account, network, wallet }, setState] = (0, import_react2.useState)(initialState);
71
+ 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),
179
74
  []
180
75
  );
181
- const [wallets, setWallets] = (0, import_react3.useState)(walletCore.wallets);
76
+ const [wallets, setWallets] = (0, import_react2.useState)(walletCore.wallets);
182
77
  const connect = async (walletName) => {
183
78
  try {
184
79
  setIsLoading(true);
@@ -254,7 +149,7 @@ var AptosWalletAdapterProvider = ({
254
149
  return Promise.reject(error);
255
150
  }
256
151
  };
257
- (0, import_react3.useEffect)(() => {
152
+ (0, import_react2.useEffect)(() => {
258
153
  if (autoConnect) {
259
154
  if (localStorage.getItem("AptosWalletName") && !connected) {
260
155
  connect(localStorage.getItem("AptosWalletName"));
@@ -263,7 +158,7 @@ var AptosWalletAdapterProvider = ({
263
158
  }
264
159
  }
265
160
  }, [autoConnect, wallets]);
266
- (0, import_react3.useEffect)(() => {
161
+ (0, import_react2.useEffect)(() => {
267
162
  if (connected) {
268
163
  walletCore.onAccountChange();
269
164
  walletCore.onNetworkChange();
@@ -293,7 +188,7 @@ var AptosWalletAdapterProvider = ({
293
188
  };
294
189
  });
295
190
  };
296
- const handleAccountChange = (0, import_react3.useCallback)(() => {
191
+ const handleAccountChange = (0, import_react2.useCallback)(() => {
297
192
  if (!connected)
298
193
  return;
299
194
  if (!walletCore.wallet)
@@ -305,7 +200,7 @@ var AptosWalletAdapterProvider = ({
305
200
  };
306
201
  });
307
202
  }, [connected]);
308
- const handleNetworkChange = (0, import_react3.useCallback)(() => {
203
+ const handleNetworkChange = (0, import_react2.useCallback)(() => {
309
204
  if (!connected)
310
205
  return;
311
206
  if (!walletCore.wallet)
@@ -340,7 +235,7 @@ var AptosWalletAdapterProvider = ({
340
235
  setWallets((wallets2) => [...wallets2, standardWallet]);
341
236
  }
342
237
  };
343
- (0, import_react3.useEffect)(() => {
238
+ (0, import_react2.useEffect)(() => {
344
239
  walletCore.on("connect", handleConnect);
345
240
  walletCore.on("disconnect", handleDisconnect);
346
241
  walletCore.on("accountChange", handleAccountChange);
@@ -377,49 +272,197 @@ var AptosWalletAdapterProvider = ({
377
272
  });
378
273
  };
379
274
 
380
- // src/utils.tsx
381
- var import_wallet_adapter_core3 = require("@aptos-labs/wallet-adapter-core");
382
- function partitionWallets(wallets, partitionFunction = isInstalledOrLoadable) {
383
- const defaultWallets = [];
384
- const moreWallets = [];
385
- for (const wallet of wallets) {
386
- if (partitionFunction(wallet))
387
- defaultWallets.push(wallet);
388
- else
389
- moreWallets.push(wallet);
390
- }
391
- return { defaultWallets, moreWallets };
392
- }
393
- function isInstalledOrLoadable(wallet) {
394
- return wallet.readyState === import_wallet_adapter_core3.WalletReadyState.Installed || wallet.readyState === import_wallet_adapter_core3.WalletReadyState.Loadable;
395
- }
396
- function getAptosConnectWallets(wallets) {
397
- const { defaultWallets, moreWallets } = partitionWallets(
398
- wallets,
399
- (wallet) => wallet.url.includes("aptosconnect.app")
400
- );
401
- return { aptosConnectWallets: defaultWallets, otherWallets: moreWallets };
402
- }
403
- function isInstallRequired(wallet) {
404
- const isWalletReady = isInstalledOrLoadable(wallet);
405
- const isMobile = !isWalletReady && (0, import_wallet_adapter_core3.isRedirectable)();
406
- return !isMobile && !isWalletReady;
407
- }
408
- function truncateAddress(address) {
409
- if (!address)
410
- return;
411
- return `${address.slice(0, 6)}...${address.slice(-5)}`;
275
+ // src/components/AptosPrivacyPolicy.tsx
276
+ var import_react_slot = require("@radix-ui/react-slot");
277
+ var import_react3 = require("react");
278
+
279
+ // src/graphics/SmallAptosLogo.tsx
280
+ var import_jsx_runtime = require("react/jsx-runtime");
281
+ function SmallAptosLogo(props) {
282
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", {
283
+ width: "12",
284
+ height: "12",
285
+ viewBox: "0 0 12 12",
286
+ fill: "none",
287
+ ...props,
288
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
289
+ "fill-rule": "evenodd",
290
+ "clip-rule": "evenodd",
291
+ 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",
292
+ fill: "currentColor"
293
+ })
294
+ });
412
295
  }
296
+
297
+ // src/components/AptosPrivacyPolicy.tsx
298
+ var import_jsx_runtime = require("react/jsx-runtime");
299
+ 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
+ }
309
+ );
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) => {
337
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
338
+ ref,
339
+ className,
340
+ children: [
341
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
342
+ children: "Powered by"
343
+ }),
344
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SmallAptosLogo, {}),
345
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
346
+ children: "Aptos Labs"
347
+ })
348
+ ]
349
+ });
350
+ });
351
+ PoweredBy.displayName = "AptosPrivacyPolicy.PoweredBy";
352
+ var AptosPrivacyPolicy = Object.assign(Root, {
353
+ Disclaimer,
354
+ Link,
355
+ PoweredBy
356
+ });
357
+
358
+ // src/components/WalletItem.tsx
359
+ var import_wallet_adapter_core2 = require("@aptos-labs/wallet-adapter-core");
360
+ var import_react_slot2 = require("@radix-ui/react-slot");
361
+ var import_react4 = require("react");
362
+ var import_jsx_runtime = require("react/jsx-runtime");
363
+ var WalletItemContext = (0, import_react4.createContext)(null);
364
+ var WalletItemRoot = (0, import_react4.forwardRef)(
365
+ ({ wallet, onConnect, className, asChild, children }, ref) => {
366
+ const { connect } = useWallet();
367
+ const connectWallet = (0, import_react4.useCallback)(() => {
368
+ connect(wallet.name);
369
+ onConnect == null ? void 0 : onConnect();
370
+ }, [connect, wallet.name, onConnect]);
371
+ const isWalletReady = wallet.readyState === import_wallet_adapter_core2.WalletReadyState.Installed || wallet.readyState === import_wallet_adapter_core2.WalletReadyState.Loadable;
372
+ const mobileSupport = "deeplinkProvider" in wallet && wallet.deeplinkProvider;
373
+ if (!isWalletReady && (0, import_wallet_adapter_core2.isRedirectable)() && !mobileSupport)
374
+ return null;
375
+ const Component = asChild ? import_react_slot2.Slot : "div";
376
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(WalletItemContext.Provider, {
377
+ value: { wallet, connectWallet },
378
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {
379
+ ref,
380
+ className,
381
+ children
382
+ })
383
+ });
384
+ }
385
+ );
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,
396
+ src: context.wallet.icon,
397
+ alt: `${context.wallet.name} icon`,
398
+ className,
399
+ children
400
+ });
401
+ }
402
+ );
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
+ });
416
+ }
417
+ );
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
+ );
425
+ }
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
+ );
441
+ }
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
458
+ });
413
459
  // Annotate the CommonJS export names for ESM import in node:
414
460
  0 && (module.exports = {
461
+ APTOS_PRIVACY_POLICY_URL,
462
+ AptosPrivacyPolicy,
415
463
  AptosWalletAdapterProvider,
416
464
  WalletContext,
417
465
  WalletItem,
418
- getAptosConnectWallets,
419
- isInstallRequired,
420
- isInstalledOrLoadable,
421
- partitionWallets,
422
- truncateAddress,
423
466
  useWallet
424
467
  });
425
468
  //# sourceMappingURL=index.js.map