@use-glyph/sdk-react 1.1.3 → 1.1.5
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/dist/glyph-widget.es.js +19218 -30
- package/dist/glyph-widget.es.js.map +1 -0
- package/dist/glyph-widget.umd.js +44 -43
- package/dist/glyph-widget.umd.js.map +1 -0
- package/dist/types/components/GlyphWidget.d.ts +1 -2
- package/dist/types/components/GlyphWidgetButton.d.ts +1 -2
- package/dist/types/components/LoginButton.d.ts +1 -2
- package/dist/types/components/LogoutButton.d.ts +1 -2
- package/dist/types/components/NativeGlyphConnectButton.d.ts +1 -2
- package/dist/types/components/SignUpButton.d.ts +1 -2
- package/dist/types/components/shared/CopyButton.d.ts +1 -2
- package/dist/types/components/shared/UserAvatar.d.ts +1 -2
- package/dist/types/components/shared/WalletViewFooterNav.d.ts +1 -2
- package/dist/types/components/shared/WalletViewHeader.d.ts +1 -2
- package/dist/types/components/ui/accordion.d.ts +4 -5
- package/dist/types/components/ui/button.d.ts +3 -3
- package/dist/types/components/ui/drawer.d.ts +17 -24
- package/dist/types/components/ui/input.d.ts +5 -5
- package/dist/types/components/ui/popover.d.ts +3 -4
- package/dist/types/components/ui/tooltip-element.d.ts +2 -2
- package/dist/types/components/ui/tooltip.d.ts +6 -7
- package/dist/types/components/widget/WalletFundFailedView.d.ts +1 -2
- package/dist/types/components/widget/WalletFundPendingView.d.ts +1 -2
- package/dist/types/components/widget/WalletFundSuccessView.d.ts +1 -2
- package/dist/types/components/widget/WalletSendFundEnterAddressView.d.ts +1 -2
- package/dist/types/components/widget/WalletSendFundFailedView.d.ts +1 -2
- package/dist/types/components/widget/WalletSendFundPendingView.d.ts +1 -2
- package/dist/types/components/widget/WalletSendFundSuccessView.d.ts +1 -2
- package/dist/types/context/GlyphProvider.d.ts +1 -2
- package/dist/types/context/strategies/LoadingStrategy.d.ts +2 -3
- package/dist/types/index.d.ts +4 -4
- package/dist/types/lib/eip1193/GlyphWalletProvider.d.ts +0 -1
- package/dist/types/lib/privy/GlyphPrivyProvider.d.ts +3 -3
- package/dist/types/lib/privy/InjectWagmiConnector.d.ts +0 -1
- package/package.json +3 -3
- package/dist/EIP1193Strategy.js +0 -148
- package/dist/PrivyStrategy.js +0 -108
- package/dist/index.js +0 -19490
package/dist/PrivyStrategy.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { c as B, i as $, S as x, G as C, j as q, a as z, b as J, W as K } from "./index.js";
|
|
2
|
-
import { usePrivy as O, useCrossAppAccounts as Q, useWallets as X } from "@privy-io/react-auth";
|
|
3
|
-
import { memo as Z, useState as d, useEffect as ss, useCallback as l } from "react";
|
|
4
|
-
import { useChainId as es } from "wagmi";
|
|
5
|
-
const t = B("PrivyStrategy"), M = ({ children: D, glyphUrl: p, onLogin: m, onLogout: v, useStagingTenant: u }) => {
|
|
6
|
-
const [L, y] = d(!0), [R, g] = d(null), [a, F] = d(null), [n, N] = d(!1), P = es(), {
|
|
7
|
-
ready: o,
|
|
8
|
-
authenticated: i,
|
|
9
|
-
user: c,
|
|
10
|
-
getAccessToken: _,
|
|
11
|
-
login: w,
|
|
12
|
-
logout: f,
|
|
13
|
-
signMessage: b,
|
|
14
|
-
sendTransaction: E
|
|
15
|
-
} = O(), { signMessage: G, sendTransaction: S } = Q();
|
|
16
|
-
t.debug(o, i, !!c);
|
|
17
|
-
const { wallets: V } = X();
|
|
18
|
-
ss(() => {
|
|
19
|
-
if (!o) {
|
|
20
|
-
g(null), y(!0);
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
if (!i || !c) {
|
|
24
|
-
g(null), y(!1);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
let e;
|
|
28
|
-
const r = c.linkedAccounts?.find(
|
|
29
|
-
(s) => s.type === "wallet" && s.chainType === "ethereum" && s.walletClientType === "privy"
|
|
30
|
-
), I = r && $(r.address);
|
|
31
|
-
I && t.debug("Privy (main) EVM embedded wallet", r.address), t.debug("finding cross-app accounts...");
|
|
32
|
-
const T = c.linkedAccounts?.filter?.((s) => s.type === "cross_app") || [], W = T.filter(
|
|
33
|
-
(s) => s.providerApp?.id !== (u ? x : C)
|
|
34
|
-
);
|
|
35
|
-
t.debug("linked accounts - non-Glyph", { accounts: W });
|
|
36
|
-
const h = W.map((s) => s.embeddedWallets[0].address);
|
|
37
|
-
h.length > 0 && (e = h[0], t.log("using cross_app (non-Glyph) account"), h.length > 1 && t.warn("too many cross_app accounts"));
|
|
38
|
-
const k = T.filter(
|
|
39
|
-
(s) => s.providerApp?.id === (u ? x : C)
|
|
40
|
-
);
|
|
41
|
-
t.debug("linked accounts - Glyph", { accounts: k });
|
|
42
|
-
const A = k.map((s) => s.embeddedWallets[0].address);
|
|
43
|
-
A.length > 0 && (e = A[0], t.log("using cross_app (Glyph) account"), A.length > 1 && t.warn("too many cross_app accounts")), e ? (N(!0), t.log("using cross_app account", e)) : I && (e = r.address, t.log("using Privy (main) EVM embedded wallet", e)), F(e ?? null), (async () => {
|
|
44
|
-
if (!e) {
|
|
45
|
-
t.error("user has no wallet");
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const s = J(
|
|
49
|
-
p || K,
|
|
50
|
-
async () => await _(),
|
|
51
|
-
{ "x-evm-address": e }
|
|
52
|
-
);
|
|
53
|
-
g(() => s), y(!1);
|
|
54
|
-
})();
|
|
55
|
-
}, [
|
|
56
|
-
p,
|
|
57
|
-
i,
|
|
58
|
-
o,
|
|
59
|
-
c,
|
|
60
|
-
u,
|
|
61
|
-
n,
|
|
62
|
-
V,
|
|
63
|
-
a,
|
|
64
|
-
_,
|
|
65
|
-
f
|
|
66
|
-
]);
|
|
67
|
-
const Y = l(async () => {
|
|
68
|
-
await w(), m?.();
|
|
69
|
-
}, [m, w]), j = l(async () => {
|
|
70
|
-
f(), v?.();
|
|
71
|
-
}, [v, f]), U = l(
|
|
72
|
-
async ({ message: e }) => {
|
|
73
|
-
if (!a) throw new Error("No wallet address found");
|
|
74
|
-
return n ? G(e, { address: a }) : b({ message: e });
|
|
75
|
-
},
|
|
76
|
-
[a, n, G, b]
|
|
77
|
-
), H = l(
|
|
78
|
-
async ({ transaction: e }) => {
|
|
79
|
-
if (!a) throw new Error("No wallet address found");
|
|
80
|
-
const r = { ...e, chainId: P };
|
|
81
|
-
return n ? S(r, { address: a }) : E(r, { address: a });
|
|
82
|
-
},
|
|
83
|
-
[P, n, a, S, E]
|
|
84
|
-
);
|
|
85
|
-
return /* @__PURE__ */ q.jsx(
|
|
86
|
-
z.Provider,
|
|
87
|
-
{
|
|
88
|
-
value: {
|
|
89
|
-
ready: o && !L,
|
|
90
|
-
authenticated: o && i,
|
|
91
|
-
symbol: "APE",
|
|
92
|
-
glyphUrl: p,
|
|
93
|
-
// Pass as string to avoid type error (we are passing fallback value in useGlyph hook at a common place)
|
|
94
|
-
login: Y,
|
|
95
|
-
logout: j,
|
|
96
|
-
signMessage: U,
|
|
97
|
-
sendTransaction: H,
|
|
98
|
-
apiFetch: R
|
|
99
|
-
},
|
|
100
|
-
children: D
|
|
101
|
-
}
|
|
102
|
-
);
|
|
103
|
-
};
|
|
104
|
-
M.displayName = "PrivyStrategy";
|
|
105
|
-
const cs = Z(M);
|
|
106
|
-
export {
|
|
107
|
-
cs as default
|
|
108
|
-
};
|