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