@use-glyph/sdk-react 0.0.1

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 (117) hide show
  1. package/LICENSE +17 -0
  2. package/README.md +152 -0
  3. package/dist/EIP1193Strategy.js +116 -0
  4. package/dist/PrivyStrategy.js +92 -0
  5. package/dist/assets/sdk-react.css +1 -0
  6. package/dist/index.js +17858 -0
  7. package/dist/sdk-react.es.js +28 -0
  8. package/dist/sdk-react.umd.js +151 -0
  9. package/dist/types/assets/svg/APEIcon.d.ts +2 -0
  10. package/dist/types/assets/svg/APE_ETH.d.ts +1 -0
  11. package/dist/types/assets/svg/APE_USD.d.ts +1 -0
  12. package/dist/types/assets/svg/APE_WAPE.d.ts +1 -0
  13. package/dist/types/assets/svg/ActivityIcon.d.ts +5 -0
  14. package/dist/types/assets/svg/ApechainIcon.d.ts +1 -0
  15. package/dist/types/assets/svg/ApecoinIcon.d.ts +2 -0
  16. package/dist/types/assets/svg/BackIcon.d.ts +2 -0
  17. package/dist/types/assets/svg/CaretDownIcon.d.ts +1 -0
  18. package/dist/types/assets/svg/CopyIcon.d.ts +5 -0
  19. package/dist/types/assets/svg/EditIcon.d.ts +2 -0
  20. package/dist/types/assets/svg/FailureIcon.d.ts +1 -0
  21. package/dist/types/assets/svg/GlyphIcon.d.ts +2 -0
  22. package/dist/types/assets/svg/HelpIcon.d.ts +1 -0
  23. package/dist/types/assets/svg/HomeIcon.d.ts +2 -0
  24. package/dist/types/assets/svg/InfoIcon.d.ts +1 -0
  25. package/dist/types/assets/svg/LinkIcon.d.ts +1 -0
  26. package/dist/types/assets/svg/LoadingCircleIcon..d.ts +2 -0
  27. package/dist/types/assets/svg/NetworkIcon.d.ts +1 -0
  28. package/dist/types/assets/svg/NoTokenIcon.d.ts +1 -0
  29. package/dist/types/assets/svg/PlusSign.d.ts +1 -0
  30. package/dist/types/assets/svg/ProfileViewPattern.d.ts +2 -0
  31. package/dist/types/assets/svg/QRIcon.d.ts +1 -0
  32. package/dist/types/assets/svg/SuccessIcon.d.ts +1 -0
  33. package/dist/types/assets/svg/SuccessViewPattern.d.ts +2 -0
  34. package/dist/types/assets/svg/TokensIcon.d.ts +2 -0
  35. package/dist/types/assets/svg/TxReceiveIcon.d.ts +1 -0
  36. package/dist/types/assets/svg/TxSendIcon.d.ts +1 -0
  37. package/dist/types/assets/svg/WalletIcon.d.ts +1 -0
  38. package/dist/types/assets/svg/WalletsTabFilledIcon.d.ts +2 -0
  39. package/dist/types/assets/svg/WalletsTabOutlinedIcon.d.ts +2 -0
  40. package/dist/types/components/GlyphWidget.d.ts +3 -0
  41. package/dist/types/components/GlyphWidgetButton.d.ts +3 -0
  42. package/dist/types/components/LoginButton.d.ts +2 -0
  43. package/dist/types/components/LogoutButton.d.ts +2 -0
  44. package/dist/types/components/SignUpButton.d.ts +2 -0
  45. package/dist/types/components/shared/ActivityRow.d.ts +10 -0
  46. package/dist/types/components/shared/CopyButton.d.ts +10 -0
  47. package/dist/types/components/shared/LinkWithIcon.d.ts +4 -0
  48. package/dist/types/components/shared/UserAvatar.d.ts +8 -0
  49. package/dist/types/components/shared/WalletViewFooterNav.d.ts +8 -0
  50. package/dist/types/components/shared/WalletViewHeader.d.ts +11 -0
  51. package/dist/types/components/shared/WalletViewTemplate.d.ts +10 -0
  52. package/dist/types/components/shared/skeletons/ActivityRowSkeleton.d.ts +1 -0
  53. package/dist/types/components/ui/accordion.d.ts +7 -0
  54. package/dist/types/components/ui/button.d.ts +15 -0
  55. package/dist/types/components/ui/drawer.d.ts +27 -0
  56. package/dist/types/components/ui/input-helper.d.ts +8 -0
  57. package/dist/types/components/ui/input.d.ts +26 -0
  58. package/dist/types/components/ui/popover.d.ts +6 -0
  59. package/dist/types/components/ui/select.d.ts +13 -0
  60. package/dist/types/components/ui/skeleton.d.ts +2 -0
  61. package/dist/types/components/ui/sonner.d.ts +4 -0
  62. package/dist/types/components/ui/tooltip-element.d.ts +14 -0
  63. package/dist/types/components/ui/tooltip.d.ts +8 -0
  64. package/dist/types/components/widget/UnsupportedChainOverlay.d.ts +5 -0
  65. package/dist/types/components/widget/Wallet.d.ts +4 -0
  66. package/dist/types/components/widget/WalletActivityTab.d.ts +4 -0
  67. package/dist/types/components/widget/WalletFundFailedView.d.ts +8 -0
  68. package/dist/types/components/widget/WalletFundPendingView.d.ts +8 -0
  69. package/dist/types/components/widget/WalletFundSuccessView.d.ts +8 -0
  70. package/dist/types/components/widget/WalletFundView.d.ts +8 -0
  71. package/dist/types/components/widget/WalletHomeTab.d.ts +6 -0
  72. package/dist/types/components/widget/WalletLinkedAccountsTab.d.ts +1 -0
  73. package/dist/types/components/widget/WalletMainView.d.ts +12 -0
  74. package/dist/types/components/widget/WalletProfileView.d.ts +4 -0
  75. package/dist/types/components/widget/WalletReceiveView.d.ts +4 -0
  76. package/dist/types/components/widget/WalletSendFundEnterAddressView.d.ts +12 -0
  77. package/dist/types/components/widget/WalletSendFundFailedView.d.ts +10 -0
  78. package/dist/types/components/widget/WalletSendFundPendingView.d.ts +13 -0
  79. package/dist/types/components/widget/WalletSendFundSuccessView.d.ts +10 -0
  80. package/dist/types/components/widget/WalletSendFundView.d.ts +23 -0
  81. package/dist/types/components/widget/WalletTokensTab.d.ts +1 -0
  82. package/dist/types/components/widget/WidgetGradient.d.ts +4 -0
  83. package/dist/types/context/GlyphContext.d.ts +18 -0
  84. package/dist/types/context/GlyphProvider.d.ts +3 -0
  85. package/dist/types/context/GlyphUserDataContext.d.ts +9 -0
  86. package/dist/types/context/GlyphUserDataProvider.d.ts +5 -0
  87. package/dist/types/context/GlyphViewContext.d.ts +12 -0
  88. package/dist/types/context/GlyphViewProvider.d.ts +4 -0
  89. package/dist/types/context/strategies/EIP1193Strategy.d.ts +4 -0
  90. package/dist/types/context/strategies/LoadingStrategy.d.ts +5 -0
  91. package/dist/types/context/strategies/PrivyStrategy.d.ts +3 -0
  92. package/dist/types/hooks/useActivity.d.ts +30 -0
  93. package/dist/types/hooks/useBalances.d.ts +4 -0
  94. package/dist/types/hooks/useGlyph.d.ts +49 -0
  95. package/dist/types/hooks/useGlyphApi.d.ts +3 -0
  96. package/dist/types/hooks/useGlyphFunding.d.ts +17 -0
  97. package/dist/types/hooks/useGlyphFundingApi.d.ts +45 -0
  98. package/dist/types/hooks/useGlyphView.d.ts +3 -0
  99. package/dist/types/hooks/useMediaQuery.d.ts +2 -0
  100. package/dist/types/hooks/useNativeGlyphConnection.d.ts +11 -0
  101. package/dist/types/index.d.ts +20 -0
  102. package/dist/types/lib/constants.d.ts +45 -0
  103. package/dist/types/lib/eip1193/GlyphWalletProvider.d.ts +40 -0
  104. package/dist/types/lib/eip1193/glyphWalletConnector.d.ts +35 -0
  105. package/dist/types/lib/eip1193/glyphWalletRK.d.ts +18 -0
  106. package/dist/types/lib/intl.d.ts +2 -0
  107. package/dist/types/lib/numericInputs.d.ts +2 -0
  108. package/dist/types/lib/popup.d.ts +11 -0
  109. package/dist/types/lib/privy/GlyphPrivyProvider.d.ts +25 -0
  110. package/dist/types/lib/privy/InjectWagmiConnector.d.ts +5 -0
  111. package/dist/types/lib/privy/usePrivyCrossAppProvider.d.ts +15 -0
  112. package/dist/types/lib/providers.d.ts +6889 -0
  113. package/dist/types/lib/svg.d.ts +4 -0
  114. package/dist/types/lib/utils.d.ts +128 -0
  115. package/dist/types/types/GlyphWidgetTypes.d.ts +90 -0
  116. package/dist/types/types/index.d.ts +1 -0
  117. package/package.json +98 -0
package/LICENSE ADDED
@@ -0,0 +1,17 @@
1
+ GLYPH SOFTWARE LICENSE v1.0
2
+
3
+ This Glyph Software License (this “License”) is granted by Yuga Labs, Inc. (“Yuga Labs” “we,” or “us”) to the person, entity or organization (“Licensee” or “you” or “your”) downloading or otherwise obtaining a copy of the Glyph software code published and maintained by Yuga Labs at https://github.com/yuga-labs/glyph-sdk (such software code, “Glyph Code”).
4
+
5
+ Yuga Labs grants to Licensee a worldwide, non-exclusive, royalty-free, non-assignable, non-transferrable, non-sublicensable limited copyright license to publicly display, publicly perform, reproduce, and distribute the Glyph Code solely for the purpose of integrating the Glyph Code into your products and services (such products and services, the “Developer Products and Services”). Reproduction and distribution of the Glyph Code by you must include a copy of this License. Except for the express license rights granted above, all right, title and interest in the Glyph Code shall remain with Yuga Labs. Use of the Glyph Code is subject to the terms and conditions set forth at https://useglyph.io/terms (the “Terms and Conditions”). This License shall automatically terminate in the event you violate any provision of this License or of the Terms and Conditions.
6
+
7
+ This License does not include the right to (i) create derivative works or (ii) use any trade names, trademarks, or service marks of the Ape Foundation, a Cayman Foundation (e.g., Apechain or ApeCoin), or Yuga Labs or any of their respective affiliates or development partners except as expressly required in the notice statement below. This License is not an express or implied warranty, endorsement or approval of Developer Products and Services. Licensee shall use the Glyph Code in compliance with all applicable laws.
8
+
9
+ All copies of the Glyph Code shall include the following notice statement: “This Glyph Code is licensed by Yuga Labs, Inc. and may only be used in accordance with the Glyph Software License v1.0 published at https://useglyph.io/license ” This License applies to any copies of the Glyph Code, regardless of where the copies were obtained.
10
+
11
+ THE GLYPH CODE IS PROVIDED “AS IS,” “WHERE IS,” AND “AS AVAILABLE,” WITH ALL FAULTS AND WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND TITLE. WITHOUT LIMITING THE GENERALITY OF THE FOREGOING, (I) CERTAIN FUNCTIONALITY OR ENTIRE RELEASES OF THE GLYPH CODE MAY BE RELEASED AS BETA OR TEST VERSIONS, MAY CONTAIN ERRORS, BUGS AND OTHER DEFICIENCIES, AND ARE USED BY YOU AT YOUR OWN RISK; AND (II) THE GLYPH CODE IS SUBJECT TO CHANGES AND REDESIGNS, WHETHER BY YUGA LABS OR THIRD PARTIES, IN FUTURE RELEASES WITHOUT NOTICE WHICH MAY RENDER CERTAIN FUNCTIONALITY OR ENTIRE VERSIONS OF EARLIER RELEASES OF THE GLYPH CODE UNSUPPORTED AND OBSOLETE.
12
+
13
+ IN NO EVENT SHALL YUGA LABS, ITS AFFILIATES, ITS LICENSORS OR LICENSEES, AND EACH OF THEIR RESPECTIVE OFFICERS, DIRECTORS, SHAREHOLDERS, MEMBERS, SUPERVISORS, MANAGERS, EMPLOYEES, ADVISORS, CONTRACTORS, DEVELOPMENT PARTNERS, AGENTS, AND SUCCESSORS AND ASSIGNS (“RELEASEES”) BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, INCIDENTAL, EXEMPLARY, PUNITIVE, OR SPECIAL DAMAGES OF ANY NATURE ARISING FROM, OUT OF OR IN CONNECTION WITH, THE GLYPH CODE OR USE THEREOF, INCLUDING WITHOUT LIMITATION, THE PROVISION OF DEVELOPER PRODUCTS AND SERVICES. THIS LICENSE SHALL NOT BE CONSTRUED, INTERPRETED, CLASSIFIED OR TREATED AS ENABLING, OR OFFERING ANY OPPORTUNITY TO, THE LICENSEE TO PARTICIPATE IN OR RECEIVE ANY PROFITS, INCOME, OR OTHER PAYMENTS OR RETURNS ARISING FROM OR IN CONNECTION WITH THIS LICENSE, THE GLYPH CODE, OR THE DEVELOPER PRODUCTS AND SERVICES (OTHER THAN YOUR DEVELOPER PRODUCTS AND SERVICES). IN USING THE GLYPH CODE, YOU ARE SOLELY RESPONSIBLE FOR YOUR ACTIONS AND YOU WILL INDEMNIFY, DEFEND, AND HOLD EACH RELEASEE HARMLESS FOR ANY LIABILITY ARISING FROM YOUR USE OF THE GLYPH CODE AND ANY DEVELOPER PRODUCTS AND SERVICES.
14
+
15
+ This License shall be interpreted under the laws of the United States.
16
+
17
+ END OF LICENSE
package/README.md ADDED
@@ -0,0 +1,152 @@
1
+ Using the Widget
2
+ Setup
3
+ To use the widget, you need to set up access to Glyph users through Privy's cross-app ecosystem and configure wagmi for EIP1193 wallets.
4
+
5
+ Accessing Glyph Users through Privy
6
+
7
+ 1. Install the Privy SDK:
8
+
9
+ ```sh
10
+ npm install @privy-io/privy-sdk
11
+ ```
12
+
13
+ 2. Initialize the Privy client in your application:
14
+
15
+ ```js
16
+ import { PrivyClient } from "@privy-io/privy-sdk";
17
+
18
+ const privy = new PrivyClient({
19
+ apiKey: "YOUR_PRIVY_API_KEY",
20
+ appId: "YOUR_APP_ID"
21
+ });
22
+ ```
23
+
24
+ Use the Priv client to access Glyph users:
25
+
26
+ ```js
27
+ const user = await privy.getUser("USER_ID");
28
+ console.log(user);
29
+ ```
30
+
31
+ 1. Setting up wagmi for EIP1193 Wallets
32
+
33
+ Install wagmi and ethers:
34
+
35
+ ```sh
36
+ npm install wagmi ethers
37
+ ```
38
+
39
+ 2. Configure wagmi in your application:
40
+
41
+ ```js
42
+ import { createClient, configureChains, defaultChains } from "wagmi";
43
+ import { publicProvider } from "wagmi/providers/public";
44
+
45
+ const { chains, provider } = configureChains(defaultChains, [publicProvider()]);
46
+
47
+ const client = createClient({
48
+ autoConnect: true,
49
+ provider
50
+ });
51
+ ```
52
+
53
+ 3. Use wagmi hooks to interact with wallets:
54
+
55
+ ```js
56
+ import { useAccount, useConnect, useDisconnect } from "wagmi";
57
+
58
+ function Wallet() {
59
+ const { address, isConnected } = useAccount();
60
+ const { connect, connectors } = useConnect();
61
+ const { disconnect } = useDisconnect();
62
+
63
+ if (isConnected) {
64
+ return (
65
+ <div>
66
+ <div>Connected to {address}</div>
67
+ <button onClick={() => disconnect()}>Disconnect</button>
68
+ </div>
69
+ );
70
+ }
71
+
72
+ return (
73
+ <div>
74
+ {connectors.map((connector) => (
75
+ <button key={connector.id} onClick={() => connect(connector)}>
76
+ Connect with {connector.name}
77
+ </button>
78
+ ))}
79
+ </div>
80
+ );
81
+ }
82
+ ```
83
+
84
+ ## Using with Next.js
85
+
86
+ When using this widget in a Next.js application, you may encounter the following error in the console:
87
+
88
+ ```
89
+ URL scheme "webpack-internal" is not supported.
90
+ ```
91
+
92
+ This happens because Next.js uses webpack for bundling, while this widget is built with Vite, and they handle asset URLs differently.
93
+
94
+ ### Solution
95
+
96
+ 1. Make sure you're using the latest version of the widget which includes fixes for Next.js compatibility.
97
+
98
+ 2. If you're still experiencing the issue, create a `next.config.js` file in your project root (or modify your existing one) to properly handle the widget's assets:
99
+
100
+ ```js
101
+ /** @type {import('next').NextConfig} */
102
+ const nextConfig = {
103
+ webpack: (config) => {
104
+ // This helps resolve the "URL scheme webpack-internal is not supported" error
105
+ config.module.rules.push({
106
+ test: /\.(woff2|jpg|jpeg|png|svg|webp)$/,
107
+ type: "asset/resource"
108
+ });
109
+
110
+ return config;
111
+ }
112
+ };
113
+
114
+ module.exports = nextConfig;
115
+ ```
116
+
117
+ 3. Import the CSS file explicitly in your Next.js application:
118
+
119
+ ```jsx
120
+ // In your _app.js or layout.js
121
+ import "@yuga-labs/glyph-sdk-react/style.css";
122
+ ```
123
+
124
+ 4. If you're using Next.js App Router, you may need to add the following to your `app/layout.js` file:
125
+
126
+ ```jsx
127
+ export const metadata = {
128
+ // your existing metadata
129
+ };
130
+
131
+ export default function RootLayout({ children }) {
132
+ return (
133
+ <html lang="en">
134
+ <head>
135
+ {/* Add this line to ensure fonts are loaded correctly */}
136
+ <link
137
+ href="/assets/Gramatika-Regular.woff2"
138
+ rel="preload"
139
+ as="font"
140
+ type="font/woff2"
141
+ crossOrigin="anonymous"
142
+ />
143
+ </head>
144
+ <body>{children}</body>
145
+ </html>
146
+ );
147
+ }
148
+ ```
149
+
150
+ 5. Copy the font files from `node_modules/@yuga-labs/glyph-sdk-react/dist/assets/` to your `public/assets/` directory to ensure they're available at runtime.
151
+
152
+ By following these steps, you can set up the widget to access Glyph users through Privy's cross-app ecosystem and configure wagmi for EIP1193 wallets.
@@ -0,0 +1,116 @@
1
+ import { c as $, W as S, d as b, j as M, a as O, b as D } from "./index.js";
2
+ import { useState as f, useCallback as g, useEffect as x } from "react";
3
+ import { useAccount as K, useDisconnect as G, useSignMessage as R, useSendTransaction as Y, useAccountEffect as B } from "wagmi";
4
+ const p = "__glyph-widget-token__", I = "__glyph-widget-nonce__", n = $("EIP1193Strategy"), J = ({ children: C, glyphUrl: a, onLogin: y, onLogout: h }) => {
5
+ const [N, l] = f(!1), [P, u] = f(null), { address: t, isConnected: s, chainId: j } = K(), { disconnectAsync: _ } = G(), { signMessageAsync: w } = R(), { sendTransactionAsync: F } = Y();
6
+ B({
7
+ onDisconnect: () => {
8
+ T();
9
+ }
10
+ }), n.log({ address: t, isConnected: s });
11
+ const [o, m] = f(() => {
12
+ if (typeof window > "u")
13
+ return null;
14
+ try {
15
+ return localStorage.getItem(p);
16
+ } catch (e) {
17
+ return n.warn("Error reading session token", e), null;
18
+ }
19
+ }), [i, A] = f(() => {
20
+ if (typeof window > "u")
21
+ return null;
22
+ try {
23
+ return localStorage.getItem(I);
24
+ } catch (e) {
25
+ return n.warn("Error reading session nonce", e), null;
26
+ }
27
+ });
28
+ x(() => {
29
+ try {
30
+ o ? (localStorage.setItem(p, o), localStorage.setItem(I, i)) : (localStorage.removeItem(p), localStorage.removeItem(I));
31
+ } catch (e) {
32
+ n.error("Error saving session token", e);
33
+ }
34
+ }, [i, o]);
35
+ const v = g(async (e) => {
36
+ try {
37
+ return await fetch(`${a || S}/api/widget/auth/message/${e}`).then(
38
+ (c) => c.json()
39
+ );
40
+ } catch (r) {
41
+ throw n.error("Can't fetch message to sign", r), new Error("Failed to fetch the message to sign.");
42
+ }
43
+ }, [a]), k = g(async (e, r, c) => {
44
+ try {
45
+ return await fetch(`${a || S}/api/widget/auth/verify/${e}`, {
46
+ method: "POST",
47
+ body: JSON.stringify({ signature: r, nonce: c })
48
+ }).then((E) => E.json());
49
+ } catch (d) {
50
+ throw n.error("Can't verify signature", d), new Error("Signature verification failed.");
51
+ }
52
+ }, [a]);
53
+ x(() => {
54
+ if (!o || !i) return;
55
+ const e = b(a || S, async () => o, {
56
+ "x-evm-address": t,
57
+ "x-glyph-nonce": i
58
+ });
59
+ u(() => e);
60
+ }, [o, t, a, i]);
61
+ const W = g(async () => {
62
+ var e;
63
+ if (n.log("authenticate"), !t) {
64
+ n.error("no wallet connected.");
65
+ return;
66
+ }
67
+ try {
68
+ if (!t || !s) {
69
+ u(null), l(!1);
70
+ return;
71
+ }
72
+ l(!0);
73
+ const { message: r, nonce: c } = await v(t), d = await w({ account: t, message: r }), E = (e = await k(t, d, c)) == null ? void 0 : e.token;
74
+ m(E), A(c);
75
+ } catch (r) {
76
+ n.error("Authentication failed", r), u(null), m(null), A(null);
77
+ } finally {
78
+ l(!1);
79
+ }
80
+ }, [t, s, v, w, k]), T = g(async (e = !1) => {
81
+ n.log(`logout: disconnect=${e}`), m(null), l(!1), u(null), e && await _();
82
+ }, [_]);
83
+ return /* @__PURE__ */ M.jsx(
84
+ O.Provider,
85
+ {
86
+ value: {
87
+ ready: !N,
88
+ authenticated: s && !!t && o !== null,
89
+ symbol: "APE",
90
+ glyphUrl: a,
91
+ hideWidget: !s || !t,
92
+ login: async () => {
93
+ await W(), y == null || y();
94
+ },
95
+ logout: async () => {
96
+ await T(!0), h == null || h();
97
+ },
98
+ signMessage: async ({ message: e }) => {
99
+ if (!t || !s)
100
+ throw new Error("Wallet not connected");
101
+ return w({ account: t, message: e });
102
+ },
103
+ sendTransaction: async ({ transaction: e }) => {
104
+ if (!t || !s) throw new Error("Wallet not connected");
105
+ return F({ ...e, chainId: j || D.id });
106
+ },
107
+ apiFetch: P
108
+ },
109
+ children: C
110
+ }
111
+ );
112
+ };
113
+ J.displayName = "EIP1193Strategy";
114
+ export {
115
+ J as default
116
+ };
@@ -0,0 +1,92 @@
1
+ import { c as B, i as $, S as M, G as T, j as q, a as z, b as J, d as K, W as O } from "./index.js";
2
+ import { usePrivy as Q, useCrossAppAccounts as X, useWallets as Z } from "@privy-io/react-auth";
3
+ import { memo as L, useState as l, useEffect as ss } from "react";
4
+ const e = B("PrivyStrategy"), W = ({ children: k, glyphUrl: p, onLogin: u, onLogout: y, useStagingTenant: g }) => {
5
+ const [C, f] = l(!0), [D, h] = l(null), [r, R] = l(null), [A, F] = l(!1), {
6
+ ready: n,
7
+ authenticated: d,
8
+ user: a,
9
+ getAccessToken: P,
10
+ login: N,
11
+ logout: w,
12
+ signMessage: V,
13
+ sendTransaction: Y
14
+ } = Q(), { signMessage: j, sendTransaction: U } = X();
15
+ e.debug(n, d, !!a);
16
+ const { wallets: H } = Z();
17
+ return ss(() => {
18
+ var G, S, i, I, x;
19
+ if (!n) {
20
+ h(null), f(!0);
21
+ return;
22
+ }
23
+ if (!d || !a) {
24
+ h(null), f(!1);
25
+ return;
26
+ }
27
+ let s;
28
+ const c = $((G = a.wallet) == null ? void 0 : G.address);
29
+ c && e.debug("Privy (main) EVM embedded wallet", (S = a.wallet) == null ? void 0 : S.address), e.debug("finding cross-app accounts...");
30
+ const _ = ((I = (i = a.linkedAccounts) == null ? void 0 : i.filter) == null ? void 0 : I.call(i, (t) => t.type === "cross_app")) || [], b = _.filter(
31
+ (t) => {
32
+ var o;
33
+ return ((o = t.providerApp) == null ? void 0 : o.id) !== (g ? M : T);
34
+ }
35
+ );
36
+ e.debug("linked accounts - non-Glyph", { accounts: b });
37
+ const m = b.map((t) => t.embeddedWallets[0].address);
38
+ m.length > 0 && (s = m[0], e.log("using cross_app (non-Glyph) account"), m.length > 1 && e.warn("too many cross_app accounts"));
39
+ const E = _.filter(
40
+ (t) => {
41
+ var o;
42
+ return ((o = t.providerApp) == null ? void 0 : o.id) === (g ? M : T);
43
+ }
44
+ );
45
+ e.debug("linked accounts - Glyph", { accounts: E });
46
+ const v = E.map((t) => t.embeddedWallets[0].address);
47
+ v.length > 0 && (s = v[0], e.log("using cross_app (Glyph) account"), v.length > 1 && e.warn("too many cross_app accounts")), s ? (F(!0), e.log("using cross_app account", s)) : c && (s = (x = a.wallet) == null ? void 0 : x.address, e.log("using Privy (main) EVM embedded wallet", s)), R(s ?? null), (async () => {
48
+ if (!s) {
49
+ e.error("user has no wallet");
50
+ return;
51
+ }
52
+ const t = K(
53
+ p || O,
54
+ async () => await P(),
55
+ { "x-evm-address": s }
56
+ );
57
+ h(() => t), f(!1);
58
+ })();
59
+ }, [p, d, n, a, g, A, H, r, P, w]), /* @__PURE__ */ q.jsx(
60
+ z.Provider,
61
+ {
62
+ value: {
63
+ ready: n && !C,
64
+ authenticated: n && d,
65
+ symbol: "APE",
66
+ glyphUrl: p,
67
+ login: () => {
68
+ N(), u == null || u();
69
+ },
70
+ logout: () => {
71
+ w(), y == null || y();
72
+ },
73
+ signMessage: async ({ message: s }) => {
74
+ if (!r) throw new Error("No wallet address found");
75
+ return A ? j(s, { address: r }) : V({ message: s });
76
+ },
77
+ sendTransaction: async ({ transaction: s }) => {
78
+ if (!r) throw new Error("No wallet address found");
79
+ const c = { ...s, chainId: J.id };
80
+ return A ? U(c, { address: r }) : Y(c, { address: r });
81
+ },
82
+ apiFetch: D
83
+ },
84
+ children: k
85
+ }
86
+ );
87
+ };
88
+ W.displayName = "PrivyStrategy";
89
+ const ns = L(W);
90
+ export {
91
+ ns as default
92
+ };