@aptos-labs/wallet-adapter-react 8.3.0 → 8.3.2
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/WalletProvider.d.ts +2 -2
- package/dist/WalletProvider.d.ts.map +1 -1
- package/dist/components/AboutAptosConnect.d.ts +2 -2
- package/dist/components/AboutAptosConnect.d.ts.map +1 -1
- package/dist/components/AboutPetraWeb.d.ts +2 -2
- package/dist/components/AboutPetraWeb.d.ts.map +1 -1
- package/dist/components/AptosPrivacyPolicy.d.ts +1 -1
- package/dist/components/AptosPrivacyPolicy.d.ts.map +1 -1
- package/dist/components/WalletItem.d.ts +2 -2
- package/dist/components/WalletItem.d.ts.map +1 -1
- package/dist/components/utils.d.ts +3 -3
- package/dist/components/utils.d.ts.map +1 -1
- package/dist/graphics/LinkGraphic.d.ts +1 -1
- package/dist/graphics/LinkGraphic.d.ts.map +1 -1
- package/dist/graphics/SmallAptosLogo.d.ts +1 -1
- package/dist/graphics/SmallAptosLogo.d.ts.map +1 -1
- package/dist/graphics/WalletGraphic.d.ts +1 -1
- package/dist/graphics/WalletGraphic.d.ts.map +1 -1
- package/dist/graphics/Web3Graphic.d.ts +1 -1
- package/dist/graphics/Web3Graphic.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +666 -703
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +674 -709
- package/dist/index.mjs.map +1 -1
- package/dist/useWallet.d.ts +2 -2
- package/dist/useWallet.d.ts.map +1 -1
- package/package.json +3 -4
- package/src/WalletProvider.tsx +29 -22
- package/src/components/AboutAptosConnect.tsx +7 -7
- package/src/components/AboutPetraWeb.tsx +7 -7
- package/src/components/AptosPrivacyPolicy.tsx +1 -1
- package/src/components/WalletItem.tsx +12 -5
- package/src/components/utils.tsx +7 -6
- package/src/graphics/LinkGraphic.tsx +1 -1
- package/src/graphics/SmallAptosLogo.tsx +1 -1
- package/src/graphics/WalletGraphic.tsx +1 -1
- package/src/graphics/Web3Graphic.tsx +1 -1
- package/src/index.tsx +1 -1
- package/src/useWallet.tsx +10 -10
package/dist/index.mjs
CHANGED
|
@@ -1,710 +1,295 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __objRest = (source, exclude) => {
|
|
21
|
-
var target = {};
|
|
22
|
-
for (var prop in source)
|
|
23
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
-
target[prop] = source[prop];
|
|
25
|
-
if (source != null && __getOwnPropSymbols)
|
|
26
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
}
|
|
30
|
-
return target;
|
|
31
|
-
};
|
|
32
|
-
var __async = (__this, __arguments, generator) => {
|
|
33
|
-
return new Promise((resolve, reject) => {
|
|
34
|
-
var fulfilled = (value) => {
|
|
35
|
-
try {
|
|
36
|
-
step(generator.next(value));
|
|
37
|
-
} catch (e) {
|
|
38
|
-
reject(e);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
var rejected = (value) => {
|
|
42
|
-
try {
|
|
43
|
-
step(generator.throw(value));
|
|
44
|
-
} catch (e) {
|
|
45
|
-
reject(e);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
49
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
|
|
53
1
|
// src/index.tsx
|
|
54
2
|
export * from "@aptos-labs/wallet-adapter-core";
|
|
55
3
|
|
|
56
|
-
// src/
|
|
4
|
+
// src/components/AboutAptosConnect.tsx
|
|
57
5
|
import {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
6
|
+
createContext,
|
|
7
|
+
useContext,
|
|
8
|
+
useMemo,
|
|
9
|
+
useState
|
|
10
|
+
} from "react";
|
|
62
11
|
|
|
63
|
-
// src/
|
|
64
|
-
import {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
12
|
+
// src/graphics/LinkGraphic.tsx
|
|
13
|
+
import { forwardRef } from "react";
|
|
14
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
+
var LinkGraphic = forwardRef(
|
|
16
|
+
(props, ref) => {
|
|
17
|
+
return /* @__PURE__ */ jsx(
|
|
18
|
+
"svg",
|
|
19
|
+
{
|
|
20
|
+
ref,
|
|
21
|
+
width: "102",
|
|
22
|
+
height: "132",
|
|
23
|
+
viewBox: "0 0 102 132",
|
|
24
|
+
fill: "none",
|
|
25
|
+
...props,
|
|
26
|
+
children: /* @__PURE__ */ jsxs("g", { stroke: "currentColor", strokeMiterlimit: "10", children: [
|
|
27
|
+
/* @__PURE__ */ jsx("path", { 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" }),
|
|
28
|
+
/* @__PURE__ */ jsx("path", { 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" }),
|
|
29
|
+
/* @__PURE__ */ jsx("path", { 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" }),
|
|
30
|
+
/* @__PURE__ */ jsx("path", { 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" }),
|
|
31
|
+
/* @__PURE__ */ jsx("path", { 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" }),
|
|
32
|
+
/* @__PURE__ */ jsx("path", { 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" })
|
|
33
|
+
] })
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
}
|
|
70
37
|
);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
38
|
+
LinkGraphic.displayName = "LinkGraphic";
|
|
39
|
+
|
|
40
|
+
// src/graphics/WalletGraphic.tsx
|
|
41
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
42
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
43
|
+
var WalletGraphic = forwardRef2(
|
|
44
|
+
(props, ref) => {
|
|
45
|
+
return /* @__PURE__ */ jsxs2(
|
|
46
|
+
"svg",
|
|
47
|
+
{
|
|
48
|
+
ref,
|
|
49
|
+
width: "128",
|
|
50
|
+
height: "102",
|
|
51
|
+
viewBox: "0 0 128 102",
|
|
52
|
+
fill: "none",
|
|
53
|
+
...props,
|
|
54
|
+
children: [
|
|
55
|
+
/* @__PURE__ */ jsx2(
|
|
56
|
+
"path",
|
|
57
|
+
{
|
|
58
|
+
fill: "currentColor",
|
|
59
|
+
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"
|
|
60
|
+
}
|
|
61
|
+
),
|
|
62
|
+
/* @__PURE__ */ jsx2(
|
|
63
|
+
"path",
|
|
64
|
+
{
|
|
65
|
+
stroke: "currentColor",
|
|
66
|
+
strokeMiterlimit: "10",
|
|
67
|
+
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"
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
/* @__PURE__ */ jsx2(
|
|
71
|
+
"path",
|
|
72
|
+
{
|
|
73
|
+
stroke: "currentColor",
|
|
74
|
+
strokeMiterlimit: "10",
|
|
75
|
+
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"
|
|
76
|
+
}
|
|
77
|
+
),
|
|
78
|
+
/* @__PURE__ */ jsx2(
|
|
79
|
+
"path",
|
|
80
|
+
{
|
|
81
|
+
stroke: "currentColor",
|
|
82
|
+
strokeMiterlimit: "10",
|
|
83
|
+
d: "M9.86 23.69V5.72h107.97v18.04H84.65"
|
|
84
|
+
}
|
|
85
|
+
),
|
|
86
|
+
/* @__PURE__ */ jsx2(
|
|
87
|
+
"path",
|
|
88
|
+
{
|
|
89
|
+
stroke: "currentColor",
|
|
90
|
+
strokeMiterlimit: "10",
|
|
91
|
+
d: "M117.83 20.46h3.39V1H13.25v4.72M9.36 23.69h31.78"
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
);
|
|
75
97
|
}
|
|
76
|
-
|
|
98
|
+
);
|
|
99
|
+
WalletGraphic.displayName = "WalletGraphic";
|
|
100
|
+
|
|
101
|
+
// src/graphics/Web3Graphic.tsx
|
|
102
|
+
import { forwardRef as forwardRef3 } from "react";
|
|
103
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
104
|
+
var Web3Graphic = forwardRef3(
|
|
105
|
+
(props, ref) => {
|
|
106
|
+
return /* @__PURE__ */ jsx3(
|
|
107
|
+
"svg",
|
|
108
|
+
{
|
|
109
|
+
ref,
|
|
110
|
+
width: "142",
|
|
111
|
+
height: "108",
|
|
112
|
+
viewBox: "0 0 142 108",
|
|
113
|
+
fill: "none",
|
|
114
|
+
...props,
|
|
115
|
+
children: /* @__PURE__ */ jsxs3("g", { stroke: "currentColor", strokeLinejoin: "round", children: [
|
|
116
|
+
/* @__PURE__ */ jsx3("path", { 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" }),
|
|
117
|
+
/* @__PURE__ */ jsx3("path", { 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" }),
|
|
118
|
+
/* @__PURE__ */ jsx3("path", { d: "M36.55 30.8s-.08 5.92-.1 9l.1-9ZM71 59.51v-9.07L36.55 30.8l-.1 9L63.5 55" }),
|
|
119
|
+
/* @__PURE__ */ jsx3("path", { d: "M71 59.51v-9.07L36.44 70.78l-.1 9.14L55.5 68.5" }),
|
|
120
|
+
/* @__PURE__ */ jsx3("path", { 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" }),
|
|
121
|
+
/* @__PURE__ */ jsx3("path", { d: "m105.44 30.8.11 9-.1-9Z" }),
|
|
122
|
+
/* @__PURE__ */ jsx3("path", { d: "M71 59.51v-9.07l34.44-19.64.11 9L78.5 55" }),
|
|
123
|
+
/* @__PURE__ */ jsx3("path", { d: "M71 59.51v-9.07l34.56 20.34.1 9.14L87 69" }),
|
|
124
|
+
/* @__PURE__ */ jsx3("path", { 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" }),
|
|
125
|
+
/* @__PURE__ */ jsx3("path", { 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" }),
|
|
126
|
+
/* @__PURE__ */ jsx3("path", { d: "m71.3 97.6 19.96-23.83.06 9.33L71.3 107v-9.4Z" })
|
|
127
|
+
] })
|
|
128
|
+
}
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
Web3Graphic.displayName = "Web3Graphic";
|
|
133
|
+
|
|
134
|
+
// src/components/utils.tsx
|
|
135
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
136
|
+
import { cloneElement, forwardRef as forwardRef4, isValidElement } from "react";
|
|
137
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
138
|
+
function createHeadlessComponent(displayName, elementType, props) {
|
|
139
|
+
const component = forwardRef4(({ className, asChild, children }, ref) => {
|
|
140
|
+
const Component = asChild ? Slot : elementType;
|
|
141
|
+
const { children: defaultChildren, ...resolvedProps } = typeof props === "function" ? props(displayName) : props ?? {};
|
|
142
|
+
const resolvedChildren = (
|
|
143
|
+
/**
|
|
144
|
+
* Use props' default children if no children are set in the component element's children and when asChild is true.
|
|
145
|
+
*/
|
|
146
|
+
asChild && isValidElement(children) && !children.props.children ? cloneElement(children, {}, defaultChildren) : children ?? defaultChildren
|
|
147
|
+
);
|
|
148
|
+
return (
|
|
149
|
+
/**
|
|
150
|
+
* Due to the complexity of the types at play, TypeScript reports the
|
|
151
|
+
* following error for our JSX below:
|
|
152
|
+
*
|
|
153
|
+
* `Expression produces a union type that is too complex to represent.`
|
|
154
|
+
*
|
|
155
|
+
* We can safely ignore this error and retain accurate return types for
|
|
156
|
+
* consumers of this function. The only drawback is that type-checking is
|
|
157
|
+
* ignored for the JSX block below.
|
|
158
|
+
*/
|
|
159
|
+
// @ts-expect-error
|
|
160
|
+
/* @__PURE__ */ jsx4(Component, { ref, className, ...resolvedProps, children: resolvedChildren })
|
|
161
|
+
);
|
|
162
|
+
});
|
|
163
|
+
component.displayName = displayName;
|
|
164
|
+
return component;
|
|
77
165
|
}
|
|
78
166
|
|
|
79
|
-
// src/
|
|
80
|
-
import { jsx } from "react/jsx-runtime";
|
|
81
|
-
var
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
children,
|
|
89
|
-
optInWallets,
|
|
90
|
-
hideWallets,
|
|
91
|
-
autoConnect = false,
|
|
92
|
-
dappConfig,
|
|
93
|
-
disableTelemetry = false,
|
|
94
|
-
onError
|
|
95
|
-
}) => {
|
|
96
|
-
const didAttemptAutoConnectRef = useRef(false);
|
|
97
|
-
const initialLoadCompletedRef = useRef(false);
|
|
98
|
-
const [{ account, network, connected, wallet }, setState] = useState(initialState);
|
|
99
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
100
|
-
const [walletCore, setWalletCore] = useState();
|
|
101
|
-
const [wallets, setWallets] = useState([]);
|
|
102
|
-
const [hiddenWallets, setHiddenWallets] = useState([]);
|
|
103
|
-
const [notDetectedWallets, setNotDetectedWallets] = useState([]);
|
|
104
|
-
useEffect(() => {
|
|
105
|
-
const walletCore2 = new WalletCore(
|
|
106
|
-
optInWallets,
|
|
107
|
-
dappConfig,
|
|
108
|
-
disableTelemetry,
|
|
109
|
-
hideWallets ? hideWallets : ["Petra Web"]
|
|
167
|
+
// src/components/AboutAptosConnect.tsx
|
|
168
|
+
import { Fragment, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
169
|
+
var EXPLORE_ECOSYSTEM_URL = "https://aptosnetwork.com/ecosystem/directory/category/defi";
|
|
170
|
+
var AboutAptosConnectContext = createContext(null);
|
|
171
|
+
function useAboutAptosConnectContext(displayName) {
|
|
172
|
+
const context = useContext(AboutAptosConnectContext);
|
|
173
|
+
if (!context) {
|
|
174
|
+
throw new Error(
|
|
175
|
+
`\`${displayName}\` must be used within \`AboutAptosConnect\``
|
|
110
176
|
);
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
177
|
+
}
|
|
178
|
+
return context;
|
|
179
|
+
}
|
|
180
|
+
var educationScreens = [
|
|
181
|
+
{
|
|
182
|
+
Graphic: LinkGraphic,
|
|
183
|
+
Title: createHeadlessComponent("EducationScreen.Title", "h3", {
|
|
184
|
+
children: "A better way to login."
|
|
185
|
+
}),
|
|
186
|
+
Description: createHeadlessComponent("EducationScreen.Description", "p", {
|
|
187
|
+
children: "Petra Web is a web3 wallet that uses a Social Login to create accounts on the Aptos blockchain."
|
|
188
|
+
})
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
Graphic: WalletGraphic,
|
|
192
|
+
Title: createHeadlessComponent("EducationScreen.Title", "h2", {
|
|
193
|
+
children: "What is a wallet?"
|
|
194
|
+
}),
|
|
195
|
+
Description: createHeadlessComponent("EducationScreen.Description", "p", {
|
|
196
|
+
children: "Wallets are a secure way to send, receive, and interact with digital assets like cryptocurrencies & NFTs."
|
|
197
|
+
})
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
Graphic: Web3Graphic,
|
|
201
|
+
Title: createHeadlessComponent("EducationScreen.Title", "h2", {
|
|
202
|
+
children: "Explore more of web3."
|
|
203
|
+
}),
|
|
204
|
+
Description: createHeadlessComponent("EducationScreen.Description", "p", {
|
|
205
|
+
children: /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
206
|
+
"Petra Web lets you take one account across any application built on Aptos.",
|
|
207
|
+
" ",
|
|
208
|
+
/* @__PURE__ */ jsx5(
|
|
209
|
+
"a",
|
|
210
|
+
{
|
|
211
|
+
href: EXPLORE_ECOSYSTEM_URL,
|
|
212
|
+
target: "_blank",
|
|
213
|
+
rel: "noopener noreferrer",
|
|
214
|
+
children: "Explore the ecosystem"
|
|
215
|
+
}
|
|
216
|
+
),
|
|
217
|
+
"."
|
|
218
|
+
] })
|
|
219
|
+
})
|
|
220
|
+
}
|
|
221
|
+
];
|
|
222
|
+
var educationScreenIndicators = Array(educationScreens.length).fill(null).map(
|
|
223
|
+
(_, index) => createHeadlessComponent(
|
|
224
|
+
"AboutAptosConnect.ScreenIndicator",
|
|
225
|
+
"button",
|
|
226
|
+
(displayName) => {
|
|
227
|
+
const context = useAboutAptosConnectContext(displayName);
|
|
228
|
+
const isActive = context.screenIndex - 1 === index;
|
|
229
|
+
return {
|
|
230
|
+
"aria-label": `Go to screen ${index + 1}`,
|
|
231
|
+
"aria-current": isActive ? "step" : void 0,
|
|
232
|
+
"data-active": isActive || void 0,
|
|
233
|
+
onClick: () => {
|
|
234
|
+
context.setScreenIndex(index + 1);
|
|
235
|
+
}
|
|
236
|
+
};
|
|
122
237
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
238
|
+
)
|
|
239
|
+
);
|
|
240
|
+
var Root = ({ renderEducationScreen, children }) => {
|
|
241
|
+
const [screenIndex, setScreenIndex] = useState(0);
|
|
242
|
+
const currentEducationScreen = useMemo(
|
|
243
|
+
() => educationScreens.map((screen, i) => ({
|
|
244
|
+
...screen,
|
|
245
|
+
screenIndex: i,
|
|
246
|
+
totalScreens: educationScreens.length,
|
|
247
|
+
screenIndicators: educationScreenIndicators,
|
|
248
|
+
back: () => {
|
|
249
|
+
setScreenIndex(screenIndex - 1);
|
|
250
|
+
},
|
|
251
|
+
next: () => {
|
|
252
|
+
setScreenIndex(
|
|
253
|
+
screenIndex === educationScreens.length ? 0 : screenIndex + 1
|
|
254
|
+
);
|
|
255
|
+
},
|
|
256
|
+
cancel: () => {
|
|
257
|
+
setScreenIndex(0);
|
|
127
258
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const walletName = localStorage.getItem("AptosWalletName");
|
|
131
|
-
if (!walletName) {
|
|
132
|
-
didAttemptAutoConnectRef.current = true;
|
|
133
|
-
if (!initialLoadCompletedRef.current) {
|
|
134
|
-
initialLoadCompletedRef.current = true;
|
|
135
|
-
setIsLoading(false);
|
|
136
|
-
}
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
const selectedWallet = walletCore.wallets.find(
|
|
140
|
-
(e) => e.name === walletName
|
|
141
|
-
);
|
|
142
|
-
if (!selectedWallet || selectedWallet.readyState !== WalletReadyState.Installed) {
|
|
143
|
-
if (!initialLoadCompletedRef.current) {
|
|
144
|
-
initialLoadCompletedRef.current = true;
|
|
145
|
-
setIsLoading(false);
|
|
146
|
-
}
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
didAttemptAutoConnectRef.current = true;
|
|
150
|
-
if (!connected) {
|
|
151
|
-
(() => __async(void 0, null, function* () {
|
|
152
|
-
try {
|
|
153
|
-
let shouldConnect = true;
|
|
154
|
-
if (typeof autoConnect === "function") {
|
|
155
|
-
shouldConnect = yield autoConnect(walletCore, selectedWallet);
|
|
156
|
-
} else {
|
|
157
|
-
shouldConnect = autoConnect;
|
|
158
|
-
}
|
|
159
|
-
if (shouldConnect) yield connect(walletName);
|
|
160
|
-
} catch (error) {
|
|
161
|
-
if (onError) onError(error);
|
|
162
|
-
return Promise.reject(error);
|
|
163
|
-
} finally {
|
|
164
|
-
initialLoadCompletedRef.current = true;
|
|
165
|
-
setIsLoading(false);
|
|
166
|
-
}
|
|
167
|
-
}))();
|
|
168
|
-
} else {
|
|
169
|
-
initialLoadCompletedRef.current = true;
|
|
170
|
-
setIsLoading(false);
|
|
171
|
-
}
|
|
172
|
-
}, [autoConnect, wallets]);
|
|
173
|
-
const connect = (walletName) => __async(void 0, null, function* () {
|
|
174
|
-
try {
|
|
175
|
-
setIsLoading(true);
|
|
176
|
-
yield walletCore == null ? void 0 : walletCore.connect(walletName);
|
|
177
|
-
} catch (error) {
|
|
178
|
-
if (onError) onError(error);
|
|
179
|
-
return Promise.reject(error);
|
|
180
|
-
} finally {
|
|
181
|
-
setIsLoading(false);
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
const signIn = (args) => __async(void 0, null, function* () {
|
|
185
|
-
if (!walletCore) {
|
|
186
|
-
throw new Error("WalletCore is not initialized");
|
|
187
|
-
}
|
|
188
|
-
try {
|
|
189
|
-
setIsLoading(true);
|
|
190
|
-
return yield walletCore == null ? void 0 : walletCore.signIn(args);
|
|
191
|
-
} catch (error) {
|
|
192
|
-
if (onError) onError(error);
|
|
193
|
-
return Promise.reject(error);
|
|
194
|
-
} finally {
|
|
195
|
-
setIsLoading(false);
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
const disconnect = () => __async(void 0, null, function* () {
|
|
199
|
-
try {
|
|
200
|
-
yield walletCore == null ? void 0 : walletCore.disconnect();
|
|
201
|
-
} catch (error) {
|
|
202
|
-
if (onError) onError(error);
|
|
203
|
-
return Promise.reject(error);
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
const signAndSubmitTransaction = (transaction) => __async(void 0, null, function* () {
|
|
207
|
-
try {
|
|
208
|
-
if (!walletCore) {
|
|
209
|
-
throw new Error("WalletCore is not initialized");
|
|
210
|
-
}
|
|
211
|
-
return yield walletCore.signAndSubmitTransaction(transaction);
|
|
212
|
-
} catch (error) {
|
|
213
|
-
if (onError) onError(error);
|
|
214
|
-
return Promise.reject(error);
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
const signTransaction = (args) => __async(void 0, null, function* () {
|
|
218
|
-
const { transactionOrPayload, asFeePayer, options } = args;
|
|
219
|
-
if (!walletCore) {
|
|
220
|
-
throw new Error("WalletCore is not initialized");
|
|
221
|
-
}
|
|
222
|
-
try {
|
|
223
|
-
return yield walletCore.signTransaction({
|
|
224
|
-
transactionOrPayload,
|
|
225
|
-
asFeePayer
|
|
226
|
-
});
|
|
227
|
-
} catch (error) {
|
|
228
|
-
if (onError) onError(error);
|
|
229
|
-
return Promise.reject(error);
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
const submitTransaction = (transaction) => __async(void 0, null, function* () {
|
|
233
|
-
if (!walletCore) {
|
|
234
|
-
throw new Error("WalletCore is not initialized");
|
|
235
|
-
}
|
|
236
|
-
try {
|
|
237
|
-
return yield walletCore == null ? void 0 : walletCore.submitTransaction(transaction);
|
|
238
|
-
} catch (error) {
|
|
239
|
-
if (onError) onError(error);
|
|
240
|
-
return Promise.reject(error);
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
const signMessage = (message) => __async(void 0, null, function* () {
|
|
244
|
-
if (!walletCore) {
|
|
245
|
-
throw new Error("WalletCore is not initialized");
|
|
246
|
-
}
|
|
247
|
-
try {
|
|
248
|
-
return yield walletCore == null ? void 0 : walletCore.signMessage(message);
|
|
249
|
-
} catch (error) {
|
|
250
|
-
if (onError) onError(error);
|
|
251
|
-
return Promise.reject(error);
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
const signMessageAndVerify = (message) => __async(void 0, null, function* () {
|
|
255
|
-
if (!walletCore) {
|
|
256
|
-
throw new Error("WalletCore is not initialized");
|
|
257
|
-
}
|
|
258
|
-
try {
|
|
259
|
-
return yield walletCore == null ? void 0 : walletCore.signMessageAndVerify(message);
|
|
260
|
-
} catch (error) {
|
|
261
|
-
if (onError) onError(error);
|
|
262
|
-
return Promise.reject(error);
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
const changeNetwork = (network2) => __async(void 0, null, function* () {
|
|
266
|
-
if (!walletCore) {
|
|
267
|
-
throw new Error("WalletCore is not initialized");
|
|
268
|
-
}
|
|
269
|
-
try {
|
|
270
|
-
return yield walletCore == null ? void 0 : walletCore.changeNetwork(network2);
|
|
271
|
-
} catch (error) {
|
|
272
|
-
if (onError) onError(error);
|
|
273
|
-
return Promise.reject(error);
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
const handleConnect = () => {
|
|
277
|
-
setState((state) => {
|
|
278
|
-
return __spreadProps(__spreadValues({}, state), {
|
|
279
|
-
connected: true,
|
|
280
|
-
account: (walletCore == null ? void 0 : walletCore.account) || null,
|
|
281
|
-
network: (walletCore == null ? void 0 : walletCore.network) || null,
|
|
282
|
-
wallet: (walletCore == null ? void 0 : walletCore.wallet) || null
|
|
283
|
-
});
|
|
284
|
-
});
|
|
285
|
-
};
|
|
286
|
-
const handleAccountChange = useCallback(() => {
|
|
287
|
-
if (!connected) return;
|
|
288
|
-
if (!(walletCore == null ? void 0 : walletCore.wallet)) return;
|
|
289
|
-
setState((state) => {
|
|
290
|
-
return __spreadProps(__spreadValues({}, state), {
|
|
291
|
-
account: (walletCore == null ? void 0 : walletCore.account) || null
|
|
292
|
-
});
|
|
293
|
-
});
|
|
294
|
-
}, [connected]);
|
|
295
|
-
const handleNetworkChange = useCallback(() => {
|
|
296
|
-
if (!connected) return;
|
|
297
|
-
if (!(walletCore == null ? void 0 : walletCore.wallet)) return;
|
|
298
|
-
setState((state) => {
|
|
299
|
-
return __spreadProps(__spreadValues({}, state), {
|
|
300
|
-
network: (walletCore == null ? void 0 : walletCore.network) || null
|
|
301
|
-
});
|
|
302
|
-
});
|
|
303
|
-
}, [connected]);
|
|
304
|
-
useEffect(() => {
|
|
305
|
-
if (connected) {
|
|
306
|
-
walletCore == null ? void 0 : walletCore.onAccountChange();
|
|
307
|
-
walletCore == null ? void 0 : walletCore.onNetworkChange();
|
|
308
|
-
}
|
|
309
|
-
}, [connected]);
|
|
310
|
-
const handleDisconnect = () => {
|
|
311
|
-
if (!connected) return;
|
|
312
|
-
setState((state) => {
|
|
313
|
-
return __spreadProps(__spreadValues({}, state), {
|
|
314
|
-
connected: false,
|
|
315
|
-
account: (walletCore == null ? void 0 : walletCore.account) || null,
|
|
316
|
-
network: (walletCore == null ? void 0 : walletCore.network) || null,
|
|
317
|
-
wallet: null
|
|
318
|
-
});
|
|
319
|
-
});
|
|
320
|
-
};
|
|
321
|
-
const handleStandardWalletsAdded = (standardWallet) => {
|
|
322
|
-
const existingWalletIndex = wallets.findIndex(
|
|
323
|
-
(wallet2) => wallet2.name == standardWallet.name
|
|
324
|
-
);
|
|
325
|
-
if (existingWalletIndex !== -1) {
|
|
326
|
-
setWallets((wallets2) => [
|
|
327
|
-
...wallets2.slice(0, existingWalletIndex),
|
|
328
|
-
standardWallet,
|
|
329
|
-
...wallets2.slice(existingWalletIndex + 1)
|
|
330
|
-
]);
|
|
331
|
-
} else {
|
|
332
|
-
setWallets((wallets2) => [...wallets2, standardWallet]);
|
|
333
|
-
}
|
|
334
|
-
};
|
|
335
|
-
const handleStandardWalletsHiddenAdded = (standardWallet) => {
|
|
336
|
-
const existingWalletIndex = hiddenWallets.findIndex(
|
|
337
|
-
(wallet2) => wallet2.name === standardWallet.name
|
|
338
|
-
);
|
|
339
|
-
if (existingWalletIndex !== -1) {
|
|
340
|
-
setHiddenWallets((hiddenWallets2) => [
|
|
341
|
-
...hiddenWallets2.slice(0, existingWalletIndex),
|
|
342
|
-
standardWallet,
|
|
343
|
-
...hiddenWallets2.slice(existingWalletIndex + 1)
|
|
344
|
-
]);
|
|
345
|
-
} else {
|
|
346
|
-
setHiddenWallets((hiddenWallets2) => [...hiddenWallets2, standardWallet]);
|
|
347
|
-
}
|
|
348
|
-
};
|
|
349
|
-
const handleStandardNotDetectedWalletsAdded = (notDetectedWallet) => {
|
|
350
|
-
const existingWalletIndex = wallets.findIndex(
|
|
351
|
-
(wallet2) => wallet2.name == notDetectedWallet.name
|
|
352
|
-
);
|
|
353
|
-
if (existingWalletIndex !== -1) {
|
|
354
|
-
setNotDetectedWallets((wallets2) => [
|
|
355
|
-
...wallets2.slice(0, existingWalletIndex),
|
|
356
|
-
notDetectedWallet,
|
|
357
|
-
...wallets2.slice(existingWalletIndex + 1)
|
|
358
|
-
]);
|
|
359
|
-
} else {
|
|
360
|
-
setNotDetectedWallets((wallets2) => [...wallets2, notDetectedWallet]);
|
|
361
|
-
}
|
|
362
|
-
};
|
|
363
|
-
useEffect(() => {
|
|
364
|
-
walletCore == null ? void 0 : walletCore.on("connect", handleConnect);
|
|
365
|
-
walletCore == null ? void 0 : walletCore.on("accountChange", handleAccountChange);
|
|
366
|
-
walletCore == null ? void 0 : walletCore.on("networkChange", handleNetworkChange);
|
|
367
|
-
walletCore == null ? void 0 : walletCore.on("disconnect", handleDisconnect);
|
|
368
|
-
walletCore == null ? void 0 : walletCore.on("standardWalletsAdded", handleStandardWalletsAdded);
|
|
369
|
-
walletCore == null ? void 0 : walletCore.on(
|
|
370
|
-
"standardWalletsHiddenAdded",
|
|
371
|
-
handleStandardWalletsHiddenAdded
|
|
372
|
-
);
|
|
373
|
-
walletCore == null ? void 0 : walletCore.on(
|
|
374
|
-
"standardNotDetectedWalletAdded",
|
|
375
|
-
handleStandardNotDetectedWalletsAdded
|
|
376
|
-
);
|
|
377
|
-
return () => {
|
|
378
|
-
walletCore == null ? void 0 : walletCore.off("connect", handleConnect);
|
|
379
|
-
walletCore == null ? void 0 : walletCore.off("accountChange", handleAccountChange);
|
|
380
|
-
walletCore == null ? void 0 : walletCore.off("networkChange", handleNetworkChange);
|
|
381
|
-
walletCore == null ? void 0 : walletCore.off("disconnect", handleDisconnect);
|
|
382
|
-
walletCore == null ? void 0 : walletCore.off("standardWalletsAdded", handleStandardWalletsAdded);
|
|
383
|
-
walletCore == null ? void 0 : walletCore.off(
|
|
384
|
-
"standardWalletsHiddenAdded",
|
|
385
|
-
handleStandardWalletsHiddenAdded
|
|
386
|
-
);
|
|
387
|
-
walletCore == null ? void 0 : walletCore.off(
|
|
388
|
-
"standardNotDetectedWalletAdded",
|
|
389
|
-
handleStandardNotDetectedWalletsAdded
|
|
390
|
-
);
|
|
391
|
-
};
|
|
392
|
-
}, [wallets, account]);
|
|
393
|
-
return /* @__PURE__ */ jsx(
|
|
394
|
-
WalletContext.Provider,
|
|
395
|
-
{
|
|
396
|
-
value: {
|
|
397
|
-
connect,
|
|
398
|
-
signIn,
|
|
399
|
-
disconnect,
|
|
400
|
-
signAndSubmitTransaction,
|
|
401
|
-
signTransaction,
|
|
402
|
-
signMessage,
|
|
403
|
-
signMessageAndVerify,
|
|
404
|
-
changeNetwork,
|
|
405
|
-
submitTransaction,
|
|
406
|
-
account,
|
|
407
|
-
network,
|
|
408
|
-
connected,
|
|
409
|
-
wallet,
|
|
410
|
-
wallets,
|
|
411
|
-
notDetectedWallets,
|
|
412
|
-
hiddenWallets,
|
|
413
|
-
isLoading
|
|
414
|
-
},
|
|
415
|
-
children
|
|
416
|
-
}
|
|
259
|
+
}))[screenIndex - 1],
|
|
260
|
+
[screenIndex]
|
|
417
261
|
);
|
|
262
|
+
return /* @__PURE__ */ jsx5(AboutAptosConnectContext.Provider, { value: { screenIndex, setScreenIndex }, children: screenIndex === 0 ? children : renderEducationScreen(currentEducationScreen) });
|
|
418
263
|
};
|
|
264
|
+
Root.displayName = "AboutAptosConnect";
|
|
265
|
+
var Trigger = createHeadlessComponent(
|
|
266
|
+
"AboutAptosConnect.Trigger",
|
|
267
|
+
"button",
|
|
268
|
+
(displayName) => {
|
|
269
|
+
const context = useAboutAptosConnectContext(displayName);
|
|
270
|
+
return {
|
|
271
|
+
onClick: () => {
|
|
272
|
+
context.setScreenIndex(1);
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
);
|
|
277
|
+
var AboutAptosConnect = Object.assign(Root, {
|
|
278
|
+
Trigger
|
|
279
|
+
});
|
|
419
280
|
|
|
420
|
-
// src/components/
|
|
281
|
+
// src/components/AboutPetraWeb.tsx
|
|
421
282
|
import {
|
|
422
283
|
createContext as createContext2,
|
|
423
284
|
useContext as useContext2,
|
|
424
|
-
useMemo,
|
|
285
|
+
useMemo as useMemo2,
|
|
425
286
|
useState as useState2
|
|
426
287
|
} from "react";
|
|
427
|
-
|
|
428
|
-
// src/graphics/LinkGraphic.tsx
|
|
429
|
-
import { forwardRef } from "react";
|
|
430
|
-
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
431
|
-
var LinkGraphic = forwardRef(
|
|
432
|
-
(props, ref) => {
|
|
433
|
-
return /* @__PURE__ */ jsx2(
|
|
434
|
-
"svg",
|
|
435
|
-
__spreadProps(__spreadValues({
|
|
436
|
-
ref,
|
|
437
|
-
width: "102",
|
|
438
|
-
height: "132",
|
|
439
|
-
viewBox: "0 0 102 132",
|
|
440
|
-
fill: "none"
|
|
441
|
-
}, props), {
|
|
442
|
-
children: /* @__PURE__ */ jsxs("g", { stroke: "currentColor", strokeMiterlimit: "10", children: [
|
|
443
|
-
/* @__PURE__ */ jsx2("path", { 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" }),
|
|
444
|
-
/* @__PURE__ */ jsx2("path", { 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" }),
|
|
445
|
-
/* @__PURE__ */ jsx2("path", { 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" }),
|
|
446
|
-
/* @__PURE__ */ jsx2("path", { 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" }),
|
|
447
|
-
/* @__PURE__ */ jsx2("path", { 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" }),
|
|
448
|
-
/* @__PURE__ */ jsx2("path", { 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" })
|
|
449
|
-
] })
|
|
450
|
-
})
|
|
451
|
-
);
|
|
452
|
-
}
|
|
453
|
-
);
|
|
454
|
-
LinkGraphic.displayName = "LinkGraphic";
|
|
455
|
-
|
|
456
|
-
// src/graphics/WalletGraphic.tsx
|
|
457
|
-
import { forwardRef as forwardRef2 } from "react";
|
|
458
|
-
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
459
|
-
var WalletGraphic = forwardRef2(
|
|
460
|
-
(props, ref) => {
|
|
461
|
-
return /* @__PURE__ */ jsxs2(
|
|
462
|
-
"svg",
|
|
463
|
-
__spreadProps(__spreadValues({
|
|
464
|
-
ref,
|
|
465
|
-
width: "128",
|
|
466
|
-
height: "102",
|
|
467
|
-
viewBox: "0 0 128 102",
|
|
468
|
-
fill: "none"
|
|
469
|
-
}, props), {
|
|
470
|
-
children: [
|
|
471
|
-
/* @__PURE__ */ jsx3(
|
|
472
|
-
"path",
|
|
473
|
-
{
|
|
474
|
-
fill: "currentColor",
|
|
475
|
-
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"
|
|
476
|
-
}
|
|
477
|
-
),
|
|
478
|
-
/* @__PURE__ */ jsx3(
|
|
479
|
-
"path",
|
|
480
|
-
{
|
|
481
|
-
stroke: "currentColor",
|
|
482
|
-
strokeMiterlimit: "10",
|
|
483
|
-
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"
|
|
484
|
-
}
|
|
485
|
-
),
|
|
486
|
-
/* @__PURE__ */ jsx3(
|
|
487
|
-
"path",
|
|
488
|
-
{
|
|
489
|
-
stroke: "currentColor",
|
|
490
|
-
strokeMiterlimit: "10",
|
|
491
|
-
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"
|
|
492
|
-
}
|
|
493
|
-
),
|
|
494
|
-
/* @__PURE__ */ jsx3(
|
|
495
|
-
"path",
|
|
496
|
-
{
|
|
497
|
-
stroke: "currentColor",
|
|
498
|
-
strokeMiterlimit: "10",
|
|
499
|
-
d: "M9.86 23.69V5.72h107.97v18.04H84.65"
|
|
500
|
-
}
|
|
501
|
-
),
|
|
502
|
-
/* @__PURE__ */ jsx3(
|
|
503
|
-
"path",
|
|
504
|
-
{
|
|
505
|
-
stroke: "currentColor",
|
|
506
|
-
strokeMiterlimit: "10",
|
|
507
|
-
d: "M117.83 20.46h3.39V1H13.25v4.72M9.36 23.69h31.78"
|
|
508
|
-
}
|
|
509
|
-
)
|
|
510
|
-
]
|
|
511
|
-
})
|
|
512
|
-
);
|
|
513
|
-
}
|
|
514
|
-
);
|
|
515
|
-
WalletGraphic.displayName = "WalletGraphic";
|
|
516
|
-
|
|
517
|
-
// src/graphics/Web3Graphic.tsx
|
|
518
|
-
import { forwardRef as forwardRef3 } from "react";
|
|
519
|
-
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
520
|
-
var Web3Graphic = forwardRef3(
|
|
521
|
-
(props, ref) => {
|
|
522
|
-
return /* @__PURE__ */ jsx4(
|
|
523
|
-
"svg",
|
|
524
|
-
__spreadProps(__spreadValues({
|
|
525
|
-
ref,
|
|
526
|
-
width: "142",
|
|
527
|
-
height: "108",
|
|
528
|
-
viewBox: "0 0 142 108",
|
|
529
|
-
fill: "none"
|
|
530
|
-
}, props), {
|
|
531
|
-
children: /* @__PURE__ */ jsxs3("g", { stroke: "currentColor", strokeLinejoin: "round", children: [
|
|
532
|
-
/* @__PURE__ */ jsx4("path", { 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" }),
|
|
533
|
-
/* @__PURE__ */ jsx4("path", { 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" }),
|
|
534
|
-
/* @__PURE__ */ jsx4("path", { d: "M36.55 30.8s-.08 5.92-.1 9l.1-9ZM71 59.51v-9.07L36.55 30.8l-.1 9L63.5 55" }),
|
|
535
|
-
/* @__PURE__ */ jsx4("path", { d: "M71 59.51v-9.07L36.44 70.78l-.1 9.14L55.5 68.5" }),
|
|
536
|
-
/* @__PURE__ */ jsx4("path", { 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" }),
|
|
537
|
-
/* @__PURE__ */ jsx4("path", { d: "m105.44 30.8.11 9-.1-9Z" }),
|
|
538
|
-
/* @__PURE__ */ jsx4("path", { d: "M71 59.51v-9.07l34.44-19.64.11 9L78.5 55" }),
|
|
539
|
-
/* @__PURE__ */ jsx4("path", { d: "M71 59.51v-9.07l34.56 20.34.1 9.14L87 69" }),
|
|
540
|
-
/* @__PURE__ */ jsx4("path", { 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" }),
|
|
541
|
-
/* @__PURE__ */ jsx4("path", { 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" }),
|
|
542
|
-
/* @__PURE__ */ jsx4("path", { d: "m71.3 97.6 19.96-23.83.06 9.33L71.3 107v-9.4Z" })
|
|
543
|
-
] })
|
|
544
|
-
})
|
|
545
|
-
);
|
|
546
|
-
}
|
|
547
|
-
);
|
|
548
|
-
Web3Graphic.displayName = "Web3Graphic";
|
|
549
|
-
|
|
550
|
-
// src/components/utils.tsx
|
|
551
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
552
|
-
import { cloneElement, forwardRef as forwardRef4, isValidElement } from "react";
|
|
553
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
554
|
-
function createHeadlessComponent(displayName, elementType, props) {
|
|
555
|
-
const component = forwardRef4(({ className, asChild, children }, ref) => {
|
|
556
|
-
const Component = asChild ? Slot : elementType;
|
|
557
|
-
const _a = typeof props === "function" ? props(displayName) : props != null ? props : {}, { children: defaultChildren } = _a, resolvedProps = __objRest(_a, ["children"]);
|
|
558
|
-
const resolvedChildren = (
|
|
559
|
-
/**
|
|
560
|
-
* Use props' default children if no children are set in the component element's children and when asChild is true.
|
|
561
|
-
*/
|
|
562
|
-
asChild && isValidElement(children) && !children.props.children ? cloneElement(children, {}, defaultChildren) : children != null ? children : defaultChildren
|
|
563
|
-
);
|
|
564
|
-
return (
|
|
565
|
-
/**
|
|
566
|
-
* Due to the complexity of the types at play, TypeScript reports the
|
|
567
|
-
* following error for our JSX below:
|
|
568
|
-
*
|
|
569
|
-
* `Expression produces a union type that is too complex to represent.`
|
|
570
|
-
*
|
|
571
|
-
* We can safely ignore this error and retain accurate return types for
|
|
572
|
-
* consumers of this function. The only drawback is that type-checking is
|
|
573
|
-
* ignored for the JSX block below.
|
|
574
|
-
*/
|
|
575
|
-
// @ts-expect-error
|
|
576
|
-
/* @__PURE__ */ jsx5(Component, __spreadProps(__spreadValues({ ref, className }, resolvedProps), { children: resolvedChildren }))
|
|
577
|
-
);
|
|
578
|
-
});
|
|
579
|
-
component.displayName = displayName;
|
|
580
|
-
return component;
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
// src/components/AboutAptosConnect.tsx
|
|
584
|
-
import { Fragment, jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
585
|
-
var EXPLORE_ECOSYSTEM_URL = "https://aptosnetwork.com/ecosystem/directory/category/defi";
|
|
586
|
-
var AboutAptosConnectContext = createContext2(null);
|
|
587
|
-
function useAboutAptosConnectContext(displayName) {
|
|
588
|
-
const context = useContext2(AboutAptosConnectContext);
|
|
589
|
-
if (!context) {
|
|
590
|
-
throw new Error(
|
|
591
|
-
`\`${displayName}\` must be used within \`AboutAptosConnect\``
|
|
592
|
-
);
|
|
593
|
-
}
|
|
594
|
-
return context;
|
|
595
|
-
}
|
|
596
|
-
var educationScreens = [
|
|
597
|
-
{
|
|
598
|
-
Graphic: LinkGraphic,
|
|
599
|
-
Title: createHeadlessComponent("EducationScreen.Title", "h3", {
|
|
600
|
-
children: "A better way to login."
|
|
601
|
-
}),
|
|
602
|
-
Description: createHeadlessComponent("EducationScreen.Description", "p", {
|
|
603
|
-
children: "Petra Web is a web3 wallet that uses a Social Login to create accounts on the Aptos blockchain."
|
|
604
|
-
})
|
|
605
|
-
},
|
|
606
|
-
{
|
|
607
|
-
Graphic: WalletGraphic,
|
|
608
|
-
Title: createHeadlessComponent("EducationScreen.Title", "h2", {
|
|
609
|
-
children: "What is a wallet?"
|
|
610
|
-
}),
|
|
611
|
-
Description: createHeadlessComponent("EducationScreen.Description", "p", {
|
|
612
|
-
children: "Wallets are a secure way to send, receive, and interact with digital assets like cryptocurrencies & NFTs."
|
|
613
|
-
})
|
|
614
|
-
},
|
|
615
|
-
{
|
|
616
|
-
Graphic: Web3Graphic,
|
|
617
|
-
Title: createHeadlessComponent("EducationScreen.Title", "h2", {
|
|
618
|
-
children: "Explore more of web3."
|
|
619
|
-
}),
|
|
620
|
-
Description: createHeadlessComponent("EducationScreen.Description", "p", {
|
|
621
|
-
children: /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
622
|
-
"Petra Web lets you take one account across any application built on Aptos.",
|
|
623
|
-
" ",
|
|
624
|
-
/* @__PURE__ */ jsx6(
|
|
625
|
-
"a",
|
|
626
|
-
{
|
|
627
|
-
href: EXPLORE_ECOSYSTEM_URL,
|
|
628
|
-
target: "_blank",
|
|
629
|
-
rel: "noopener noreferrer",
|
|
630
|
-
children: "Explore the ecosystem"
|
|
631
|
-
}
|
|
632
|
-
),
|
|
633
|
-
"."
|
|
634
|
-
] })
|
|
635
|
-
})
|
|
636
|
-
}
|
|
637
|
-
];
|
|
638
|
-
var educationScreenIndicators = Array(educationScreens.length).fill(null).map(
|
|
639
|
-
(_, index) => createHeadlessComponent(
|
|
640
|
-
"AboutAptosConnect.ScreenIndicator",
|
|
641
|
-
"button",
|
|
642
|
-
(displayName) => {
|
|
643
|
-
const context = useAboutAptosConnectContext(displayName);
|
|
644
|
-
const isActive = context.screenIndex - 1 === index;
|
|
645
|
-
return {
|
|
646
|
-
"aria-label": `Go to screen ${index + 1}`,
|
|
647
|
-
"aria-current": isActive ? "step" : void 0,
|
|
648
|
-
"data-active": isActive || void 0,
|
|
649
|
-
onClick: () => {
|
|
650
|
-
context.setScreenIndex(index + 1);
|
|
651
|
-
}
|
|
652
|
-
};
|
|
653
|
-
}
|
|
654
|
-
)
|
|
655
|
-
);
|
|
656
|
-
var Root = ({ renderEducationScreen, children }) => {
|
|
657
|
-
const [screenIndex, setScreenIndex] = useState2(0);
|
|
658
|
-
const currentEducationScreen = useMemo(
|
|
659
|
-
() => educationScreens.map((screen, i) => __spreadProps(__spreadValues({}, screen), {
|
|
660
|
-
screenIndex: i,
|
|
661
|
-
totalScreens: educationScreens.length,
|
|
662
|
-
screenIndicators: educationScreenIndicators,
|
|
663
|
-
back: () => {
|
|
664
|
-
setScreenIndex(screenIndex - 1);
|
|
665
|
-
},
|
|
666
|
-
next: () => {
|
|
667
|
-
setScreenIndex(
|
|
668
|
-
screenIndex === educationScreens.length ? 0 : screenIndex + 1
|
|
669
|
-
);
|
|
670
|
-
},
|
|
671
|
-
cancel: () => {
|
|
672
|
-
setScreenIndex(0);
|
|
673
|
-
}
|
|
674
|
-
}))[screenIndex - 1],
|
|
675
|
-
[screenIndex]
|
|
676
|
-
);
|
|
677
|
-
return /* @__PURE__ */ jsx6(AboutAptosConnectContext.Provider, { value: { screenIndex, setScreenIndex }, children: screenIndex === 0 ? children : renderEducationScreen(currentEducationScreen) });
|
|
678
|
-
};
|
|
679
|
-
Root.displayName = "AboutAptosConnect";
|
|
680
|
-
var Trigger = createHeadlessComponent(
|
|
681
|
-
"AboutAptosConnect.Trigger",
|
|
682
|
-
"button",
|
|
683
|
-
(displayName) => {
|
|
684
|
-
const context = useAboutAptosConnectContext(displayName);
|
|
685
|
-
return {
|
|
686
|
-
onClick: () => {
|
|
687
|
-
context.setScreenIndex(1);
|
|
688
|
-
}
|
|
689
|
-
};
|
|
690
|
-
}
|
|
691
|
-
);
|
|
692
|
-
var AboutAptosConnect = Object.assign(Root, {
|
|
693
|
-
Trigger
|
|
694
|
-
});
|
|
695
|
-
|
|
696
|
-
// src/components/AboutPetraWeb.tsx
|
|
697
|
-
import {
|
|
698
|
-
createContext as createContext3,
|
|
699
|
-
useContext as useContext3,
|
|
700
|
-
useMemo as useMemo2,
|
|
701
|
-
useState as useState3
|
|
702
|
-
} from "react";
|
|
703
|
-
import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
288
|
+
import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
704
289
|
var EXPLORE_ECOSYSTEM_URL2 = "https://aptosnetwork.com/ecosystem/directory/category/defi";
|
|
705
|
-
var AboutPetraWebContext =
|
|
290
|
+
var AboutPetraWebContext = createContext2(null);
|
|
706
291
|
function useAboutPetraWebContext(displayName) {
|
|
707
|
-
const context =
|
|
292
|
+
const context = useContext2(AboutPetraWebContext);
|
|
708
293
|
if (!context) {
|
|
709
294
|
throw new Error(`\`${displayName}\` must be used within \`AboutPetraWeb\``);
|
|
710
295
|
}
|
|
@@ -738,7 +323,7 @@ var educationScreens2 = [
|
|
|
738
323
|
children: /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
739
324
|
"Petra Web lets you take one account across any application built on Aptos.",
|
|
740
325
|
" ",
|
|
741
|
-
/* @__PURE__ */
|
|
326
|
+
/* @__PURE__ */ jsx6(
|
|
742
327
|
"a",
|
|
743
328
|
{
|
|
744
329
|
href: EXPLORE_ECOSYSTEM_URL2,
|
|
@@ -771,9 +356,10 @@ var educationScreenIndicators2 = Array(educationScreens2.length).fill(null).map(
|
|
|
771
356
|
)
|
|
772
357
|
);
|
|
773
358
|
var Root2 = ({ renderEducationScreen, children }) => {
|
|
774
|
-
const [screenIndex, setScreenIndex] =
|
|
359
|
+
const [screenIndex, setScreenIndex] = useState2(0);
|
|
775
360
|
const currentEducationScreen = useMemo2(
|
|
776
|
-
() => educationScreens2.map((screen, i) =>
|
|
361
|
+
() => educationScreens2.map((screen, i) => ({
|
|
362
|
+
...screen,
|
|
777
363
|
screenIndex: i,
|
|
778
364
|
totalScreens: educationScreens2.length,
|
|
779
365
|
screenIndicators: educationScreenIndicators2,
|
|
@@ -791,7 +377,7 @@ var Root2 = ({ renderEducationScreen, children }) => {
|
|
|
791
377
|
}))[screenIndex - 1],
|
|
792
378
|
[screenIndex]
|
|
793
379
|
);
|
|
794
|
-
return /* @__PURE__ */
|
|
380
|
+
return /* @__PURE__ */ jsx6(AboutPetraWebContext.Provider, { value: { screenIndex, setScreenIndex }, children: screenIndex === 0 ? children : renderEducationScreen(currentEducationScreen) });
|
|
795
381
|
};
|
|
796
382
|
Root2.displayName = "AboutPetraWeb";
|
|
797
383
|
var Trigger2 = createHeadlessComponent(
|
|
@@ -815,18 +401,18 @@ import { forwardRef as forwardRef6 } from "react";
|
|
|
815
401
|
|
|
816
402
|
// src/graphics/SmallAptosLogo.tsx
|
|
817
403
|
import { forwardRef as forwardRef5 } from "react";
|
|
818
|
-
import { jsx as
|
|
404
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
819
405
|
var SmallAptosLogo = forwardRef5((props, ref) => {
|
|
820
|
-
return /* @__PURE__ */
|
|
406
|
+
return /* @__PURE__ */ jsx7(
|
|
821
407
|
"svg",
|
|
822
|
-
|
|
408
|
+
{
|
|
823
409
|
ref,
|
|
824
410
|
width: "12",
|
|
825
411
|
height: "12",
|
|
826
412
|
viewBox: "0 0 12 12",
|
|
827
|
-
fill: "none"
|
|
828
|
-
|
|
829
|
-
children: /* @__PURE__ */
|
|
413
|
+
fill: "none",
|
|
414
|
+
...props,
|
|
415
|
+
children: /* @__PURE__ */ jsx7(
|
|
830
416
|
"path",
|
|
831
417
|
{
|
|
832
418
|
fillRule: "evenodd",
|
|
@@ -835,13 +421,13 @@ var SmallAptosLogo = forwardRef5((props, ref) => {
|
|
|
835
421
|
fill: "currentColor"
|
|
836
422
|
}
|
|
837
423
|
)
|
|
838
|
-
}
|
|
424
|
+
}
|
|
839
425
|
);
|
|
840
426
|
});
|
|
841
427
|
SmallAptosLogo.displayName = "SmallAptosLogo";
|
|
842
428
|
|
|
843
429
|
// src/components/AptosPrivacyPolicy.tsx
|
|
844
|
-
import { jsx as
|
|
430
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
845
431
|
var APTOS_PRIVACY_POLICY_URL = "https://aptoslabs.com/privacy";
|
|
846
432
|
var Root3 = createHeadlessComponent("AptosPrivacyPolicy.Root", "div");
|
|
847
433
|
var Disclaimer = createHeadlessComponent(
|
|
@@ -857,9 +443,9 @@ var Link = createHeadlessComponent("AptosPrivacyPolicy.Disclaimer", "a", {
|
|
|
857
443
|
});
|
|
858
444
|
var PoweredBy = forwardRef6(({ className }, ref) => {
|
|
859
445
|
return /* @__PURE__ */ jsxs6("div", { ref, className, children: [
|
|
860
|
-
/* @__PURE__ */
|
|
861
|
-
/* @__PURE__ */
|
|
862
|
-
/* @__PURE__ */
|
|
446
|
+
/* @__PURE__ */ jsx8("span", { children: "Powered by" }),
|
|
447
|
+
/* @__PURE__ */ jsx8(SmallAptosLogo, {}),
|
|
448
|
+
/* @__PURE__ */ jsx8("span", { children: "Aptos Labs" })
|
|
863
449
|
] });
|
|
864
450
|
});
|
|
865
451
|
PoweredBy.displayName = "AptosPrivacyPolicy.PoweredBy";
|
|
@@ -871,13 +457,31 @@ var AptosPrivacyPolicy = Object.assign(Root3, {
|
|
|
871
457
|
|
|
872
458
|
// src/components/WalletItem.tsx
|
|
873
459
|
import {
|
|
874
|
-
WalletReadyState as WalletReadyState2,
|
|
875
460
|
isRedirectable,
|
|
876
|
-
shouldUseFallbackWallet
|
|
461
|
+
shouldUseFallbackWallet,
|
|
462
|
+
WalletReadyState
|
|
877
463
|
} from "@aptos-labs/wallet-adapter-core";
|
|
878
464
|
import { Slot as Slot2 } from "@radix-ui/react-slot";
|
|
879
|
-
import { createContext as createContext4, forwardRef as forwardRef7, useCallback
|
|
880
|
-
|
|
465
|
+
import { createContext as createContext4, forwardRef as forwardRef7, useCallback, useContext as useContext4 } from "react";
|
|
466
|
+
|
|
467
|
+
// src/useWallet.tsx
|
|
468
|
+
import { createContext as createContext3, useContext as useContext3 } from "react";
|
|
469
|
+
var DEFAULT_CONTEXT = {
|
|
470
|
+
connected: false
|
|
471
|
+
};
|
|
472
|
+
var WalletContext = createContext3(
|
|
473
|
+
DEFAULT_CONTEXT
|
|
474
|
+
);
|
|
475
|
+
function useWallet() {
|
|
476
|
+
const context = useContext3(WalletContext);
|
|
477
|
+
if (!context) {
|
|
478
|
+
throw new Error("useWallet must be used within a WalletContextState");
|
|
479
|
+
}
|
|
480
|
+
return context;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
// src/components/WalletItem.tsx
|
|
484
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
881
485
|
function useWalletItemContext(displayName) {
|
|
882
486
|
const context = useContext4(WalletItemContext);
|
|
883
487
|
if (!context) {
|
|
@@ -887,20 +491,27 @@ function useWalletItemContext(displayName) {
|
|
|
887
491
|
}
|
|
888
492
|
var WalletItemContext = createContext4(null);
|
|
889
493
|
var Root4 = forwardRef7(
|
|
890
|
-
({
|
|
494
|
+
({
|
|
495
|
+
wallet,
|
|
496
|
+
onConnect,
|
|
497
|
+
showAllOnMobile = false,
|
|
498
|
+
className,
|
|
499
|
+
asChild,
|
|
500
|
+
children
|
|
501
|
+
}, ref) => {
|
|
891
502
|
const { connect } = useWallet();
|
|
892
|
-
const isWalletReady = wallet.readyState ===
|
|
503
|
+
const isWalletReady = wallet.readyState === WalletReadyState.Installed;
|
|
893
504
|
const mobileSupport = "deeplinkProvider" in wallet && wallet.deeplinkProvider;
|
|
894
|
-
const connectWallet =
|
|
505
|
+
const connectWallet = useCallback(() => {
|
|
895
506
|
const connectionWallet = shouldUseFallbackWallet(wallet) ? wallet.fallbackWallet : wallet;
|
|
896
507
|
if (!connectionWallet) return;
|
|
897
508
|
connect(connectionWallet.name);
|
|
898
|
-
onConnect
|
|
509
|
+
onConnect?.();
|
|
899
510
|
}, [wallet, connect, onConnect]);
|
|
900
511
|
if (!isWalletReady && isRedirectable() && !mobileSupport && !showAllOnMobile)
|
|
901
512
|
return null;
|
|
902
513
|
const Component = asChild ? Slot2 : "div";
|
|
903
|
-
return /* @__PURE__ */
|
|
514
|
+
return /* @__PURE__ */ jsx9(WalletItemContext.Provider, { value: { wallet, connectWallet }, children: /* @__PURE__ */ jsx9(Component, { ref, className, children }) });
|
|
904
515
|
}
|
|
905
516
|
);
|
|
906
517
|
Root4.displayName = "WalletItem";
|
|
@@ -955,6 +566,360 @@ var WalletItem = Object.assign(Root4, {
|
|
|
955
566
|
ConnectButton,
|
|
956
567
|
InstallLink
|
|
957
568
|
});
|
|
569
|
+
|
|
570
|
+
// src/WalletProvider.tsx
|
|
571
|
+
import {
|
|
572
|
+
WalletCore,
|
|
573
|
+
WalletReadyState as WalletReadyState2
|
|
574
|
+
} from "@aptos-labs/wallet-adapter-core";
|
|
575
|
+
import {
|
|
576
|
+
useCallback as useCallback2,
|
|
577
|
+
useEffect,
|
|
578
|
+
useRef,
|
|
579
|
+
useState as useState3
|
|
580
|
+
} from "react";
|
|
581
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
582
|
+
var initialState = {
|
|
583
|
+
connected: false,
|
|
584
|
+
account: null,
|
|
585
|
+
network: null,
|
|
586
|
+
wallet: null
|
|
587
|
+
};
|
|
588
|
+
var AptosWalletAdapterProvider = ({
|
|
589
|
+
children,
|
|
590
|
+
optInWallets,
|
|
591
|
+
hideWallets,
|
|
592
|
+
autoConnect = false,
|
|
593
|
+
dappConfig,
|
|
594
|
+
disableTelemetry = false,
|
|
595
|
+
onError
|
|
596
|
+
}) => {
|
|
597
|
+
const didAttemptAutoConnectRef = useRef(false);
|
|
598
|
+
const initialLoadCompletedRef = useRef(false);
|
|
599
|
+
const [{ account, network, connected, wallet }, setState] = useState3(initialState);
|
|
600
|
+
const [isLoading, setIsLoading] = useState3(true);
|
|
601
|
+
const [walletCore, setWalletCore] = useState3();
|
|
602
|
+
const [wallets, setWallets] = useState3([]);
|
|
603
|
+
const [hiddenWallets, setHiddenWallets] = useState3([]);
|
|
604
|
+
const [notDetectedWallets, setNotDetectedWallets] = useState3([]);
|
|
605
|
+
useEffect(() => {
|
|
606
|
+
const walletCore2 = new WalletCore(
|
|
607
|
+
optInWallets,
|
|
608
|
+
dappConfig,
|
|
609
|
+
disableTelemetry,
|
|
610
|
+
hideWallets ? hideWallets : ["Petra Web"]
|
|
611
|
+
);
|
|
612
|
+
setWalletCore(walletCore2);
|
|
613
|
+
}, []);
|
|
614
|
+
useEffect(() => {
|
|
615
|
+
setWallets(walletCore?.wallets ?? []);
|
|
616
|
+
setHiddenWallets(walletCore?.hiddenWallets ?? []);
|
|
617
|
+
setNotDetectedWallets(walletCore?.notDetectedWallets ?? []);
|
|
618
|
+
}, [walletCore]);
|
|
619
|
+
useEffect(() => {
|
|
620
|
+
if (didAttemptAutoConnectRef.current || !walletCore?.wallets.length) {
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
if (!autoConnect) {
|
|
624
|
+
if (!initialLoadCompletedRef.current) {
|
|
625
|
+
initialLoadCompletedRef.current = true;
|
|
626
|
+
setIsLoading(false);
|
|
627
|
+
}
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
const walletName = localStorage.getItem("AptosWalletName");
|
|
631
|
+
if (!walletName) {
|
|
632
|
+
didAttemptAutoConnectRef.current = true;
|
|
633
|
+
if (!initialLoadCompletedRef.current) {
|
|
634
|
+
initialLoadCompletedRef.current = true;
|
|
635
|
+
setIsLoading(false);
|
|
636
|
+
}
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
const selectedWallet = walletCore.wallets.find(
|
|
640
|
+
(e) => e.name === walletName
|
|
641
|
+
);
|
|
642
|
+
if (!selectedWallet || selectedWallet.readyState !== WalletReadyState2.Installed) {
|
|
643
|
+
if (!initialLoadCompletedRef.current) {
|
|
644
|
+
initialLoadCompletedRef.current = true;
|
|
645
|
+
setIsLoading(false);
|
|
646
|
+
}
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
649
|
+
didAttemptAutoConnectRef.current = true;
|
|
650
|
+
if (!connected) {
|
|
651
|
+
(async () => {
|
|
652
|
+
try {
|
|
653
|
+
let shouldConnect = true;
|
|
654
|
+
if (typeof autoConnect === "function") {
|
|
655
|
+
shouldConnect = await autoConnect(walletCore, selectedWallet);
|
|
656
|
+
} else {
|
|
657
|
+
shouldConnect = autoConnect;
|
|
658
|
+
}
|
|
659
|
+
if (shouldConnect) await connect(walletName);
|
|
660
|
+
} catch (error) {
|
|
661
|
+
if (onError) onError(error);
|
|
662
|
+
return Promise.reject(error);
|
|
663
|
+
} finally {
|
|
664
|
+
initialLoadCompletedRef.current = true;
|
|
665
|
+
setIsLoading(false);
|
|
666
|
+
}
|
|
667
|
+
})();
|
|
668
|
+
} else {
|
|
669
|
+
initialLoadCompletedRef.current = true;
|
|
670
|
+
setIsLoading(false);
|
|
671
|
+
}
|
|
672
|
+
}, [autoConnect, wallets]);
|
|
673
|
+
const connect = async (walletName) => {
|
|
674
|
+
try {
|
|
675
|
+
setIsLoading(true);
|
|
676
|
+
await walletCore?.connect(walletName);
|
|
677
|
+
} catch (error) {
|
|
678
|
+
if (onError) onError(error);
|
|
679
|
+
return Promise.reject(error);
|
|
680
|
+
} finally {
|
|
681
|
+
setIsLoading(false);
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
const signIn = async (args) => {
|
|
685
|
+
if (!walletCore) {
|
|
686
|
+
throw new Error("WalletCore is not initialized");
|
|
687
|
+
}
|
|
688
|
+
try {
|
|
689
|
+
setIsLoading(true);
|
|
690
|
+
return await walletCore?.signIn(args);
|
|
691
|
+
} catch (error) {
|
|
692
|
+
if (onError) onError(error);
|
|
693
|
+
return Promise.reject(error);
|
|
694
|
+
} finally {
|
|
695
|
+
setIsLoading(false);
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
const disconnect = async () => {
|
|
699
|
+
try {
|
|
700
|
+
await walletCore?.disconnect();
|
|
701
|
+
} catch (error) {
|
|
702
|
+
if (onError) onError(error);
|
|
703
|
+
return Promise.reject(error);
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
const signAndSubmitTransaction = async (transaction) => {
|
|
707
|
+
try {
|
|
708
|
+
if (!walletCore) {
|
|
709
|
+
throw new Error("WalletCore is not initialized");
|
|
710
|
+
}
|
|
711
|
+
return await walletCore.signAndSubmitTransaction(transaction);
|
|
712
|
+
} catch (error) {
|
|
713
|
+
if (onError) onError(error);
|
|
714
|
+
return Promise.reject(error);
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
|
+
const signTransaction = async (args) => {
|
|
718
|
+
const { transactionOrPayload, asFeePayer } = args;
|
|
719
|
+
if (!walletCore) {
|
|
720
|
+
throw new Error("WalletCore is not initialized");
|
|
721
|
+
}
|
|
722
|
+
try {
|
|
723
|
+
return await walletCore.signTransaction({
|
|
724
|
+
transactionOrPayload,
|
|
725
|
+
asFeePayer
|
|
726
|
+
});
|
|
727
|
+
} catch (error) {
|
|
728
|
+
if (onError) onError(error);
|
|
729
|
+
return Promise.reject(error);
|
|
730
|
+
}
|
|
731
|
+
};
|
|
732
|
+
const submitTransaction = async (transaction) => {
|
|
733
|
+
if (!walletCore) {
|
|
734
|
+
throw new Error("WalletCore is not initialized");
|
|
735
|
+
}
|
|
736
|
+
try {
|
|
737
|
+
return await walletCore?.submitTransaction(transaction);
|
|
738
|
+
} catch (error) {
|
|
739
|
+
if (onError) onError(error);
|
|
740
|
+
return Promise.reject(error);
|
|
741
|
+
}
|
|
742
|
+
};
|
|
743
|
+
const signMessage = async (message) => {
|
|
744
|
+
if (!walletCore) {
|
|
745
|
+
throw new Error("WalletCore is not initialized");
|
|
746
|
+
}
|
|
747
|
+
try {
|
|
748
|
+
return await walletCore?.signMessage(message);
|
|
749
|
+
} catch (error) {
|
|
750
|
+
if (onError) onError(error);
|
|
751
|
+
return Promise.reject(error);
|
|
752
|
+
}
|
|
753
|
+
};
|
|
754
|
+
const signMessageAndVerify = async (message) => {
|
|
755
|
+
if (!walletCore) {
|
|
756
|
+
throw new Error("WalletCore is not initialized");
|
|
757
|
+
}
|
|
758
|
+
try {
|
|
759
|
+
return await walletCore?.signMessageAndVerify(message);
|
|
760
|
+
} catch (error) {
|
|
761
|
+
if (onError) onError(error);
|
|
762
|
+
return Promise.reject(error);
|
|
763
|
+
}
|
|
764
|
+
};
|
|
765
|
+
const changeNetwork = async (network2) => {
|
|
766
|
+
if (!walletCore) {
|
|
767
|
+
throw new Error("WalletCore is not initialized");
|
|
768
|
+
}
|
|
769
|
+
try {
|
|
770
|
+
return await walletCore?.changeNetwork(network2);
|
|
771
|
+
} catch (error) {
|
|
772
|
+
if (onError) onError(error);
|
|
773
|
+
return Promise.reject(error);
|
|
774
|
+
}
|
|
775
|
+
};
|
|
776
|
+
const handleConnect = () => {
|
|
777
|
+
setState((state) => {
|
|
778
|
+
return {
|
|
779
|
+
...state,
|
|
780
|
+
connected: true,
|
|
781
|
+
account: walletCore?.account || null,
|
|
782
|
+
network: walletCore?.network || null,
|
|
783
|
+
wallet: walletCore?.wallet || null
|
|
784
|
+
};
|
|
785
|
+
});
|
|
786
|
+
};
|
|
787
|
+
const handleAccountChange = useCallback2(() => {
|
|
788
|
+
if (!connected) return;
|
|
789
|
+
if (!walletCore?.wallet) return;
|
|
790
|
+
setState((state) => {
|
|
791
|
+
return {
|
|
792
|
+
...state,
|
|
793
|
+
account: walletCore?.account || null
|
|
794
|
+
};
|
|
795
|
+
});
|
|
796
|
+
}, [connected]);
|
|
797
|
+
const handleNetworkChange = useCallback2(() => {
|
|
798
|
+
if (!connected) return;
|
|
799
|
+
if (!walletCore?.wallet) return;
|
|
800
|
+
setState((state) => {
|
|
801
|
+
return {
|
|
802
|
+
...state,
|
|
803
|
+
network: walletCore?.network || null
|
|
804
|
+
};
|
|
805
|
+
});
|
|
806
|
+
}, [connected]);
|
|
807
|
+
useEffect(() => {
|
|
808
|
+
if (connected) {
|
|
809
|
+
walletCore?.onAccountChange();
|
|
810
|
+
walletCore?.onNetworkChange();
|
|
811
|
+
}
|
|
812
|
+
}, [connected]);
|
|
813
|
+
const handleDisconnect = () => {
|
|
814
|
+
if (!connected) return;
|
|
815
|
+
setState((state) => {
|
|
816
|
+
return {
|
|
817
|
+
...state,
|
|
818
|
+
connected: false,
|
|
819
|
+
account: walletCore?.account || null,
|
|
820
|
+
network: walletCore?.network || null,
|
|
821
|
+
wallet: null
|
|
822
|
+
};
|
|
823
|
+
});
|
|
824
|
+
};
|
|
825
|
+
const handleStandardWalletsAdded = (standardWallet) => {
|
|
826
|
+
const existingWalletIndex = wallets.findIndex(
|
|
827
|
+
(wallet2) => wallet2.name === standardWallet.name
|
|
828
|
+
);
|
|
829
|
+
if (existingWalletIndex !== -1) {
|
|
830
|
+
setWallets((wallets2) => [
|
|
831
|
+
...wallets2.slice(0, existingWalletIndex),
|
|
832
|
+
standardWallet,
|
|
833
|
+
...wallets2.slice(existingWalletIndex + 1)
|
|
834
|
+
]);
|
|
835
|
+
} else {
|
|
836
|
+
setWallets((wallets2) => [...wallets2, standardWallet]);
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
const handleStandardWalletsHiddenAdded = (standardWallet) => {
|
|
840
|
+
const existingWalletIndex = hiddenWallets.findIndex(
|
|
841
|
+
(wallet2) => wallet2.name === standardWallet.name
|
|
842
|
+
);
|
|
843
|
+
if (existingWalletIndex !== -1) {
|
|
844
|
+
setHiddenWallets((hiddenWallets2) => [
|
|
845
|
+
...hiddenWallets2.slice(0, existingWalletIndex),
|
|
846
|
+
standardWallet,
|
|
847
|
+
...hiddenWallets2.slice(existingWalletIndex + 1)
|
|
848
|
+
]);
|
|
849
|
+
} else {
|
|
850
|
+
setHiddenWallets((hiddenWallets2) => [...hiddenWallets2, standardWallet]);
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
const handleStandardNotDetectedWalletsAdded = (notDetectedWallet) => {
|
|
854
|
+
const existingWalletIndex = wallets.findIndex(
|
|
855
|
+
(wallet2) => wallet2.name === notDetectedWallet.name
|
|
856
|
+
);
|
|
857
|
+
if (existingWalletIndex !== -1) {
|
|
858
|
+
setNotDetectedWallets((wallets2) => [
|
|
859
|
+
...wallets2.slice(0, existingWalletIndex),
|
|
860
|
+
notDetectedWallet,
|
|
861
|
+
...wallets2.slice(existingWalletIndex + 1)
|
|
862
|
+
]);
|
|
863
|
+
} else {
|
|
864
|
+
setNotDetectedWallets((wallets2) => [...wallets2, notDetectedWallet]);
|
|
865
|
+
}
|
|
866
|
+
};
|
|
867
|
+
useEffect(() => {
|
|
868
|
+
walletCore?.on("connect", handleConnect);
|
|
869
|
+
walletCore?.on("accountChange", handleAccountChange);
|
|
870
|
+
walletCore?.on("networkChange", handleNetworkChange);
|
|
871
|
+
walletCore?.on("disconnect", handleDisconnect);
|
|
872
|
+
walletCore?.on("standardWalletsAdded", handleStandardWalletsAdded);
|
|
873
|
+
walletCore?.on(
|
|
874
|
+
"standardWalletsHiddenAdded",
|
|
875
|
+
handleStandardWalletsHiddenAdded
|
|
876
|
+
);
|
|
877
|
+
walletCore?.on(
|
|
878
|
+
"standardNotDetectedWalletAdded",
|
|
879
|
+
handleStandardNotDetectedWalletsAdded
|
|
880
|
+
);
|
|
881
|
+
return () => {
|
|
882
|
+
walletCore?.off("connect", handleConnect);
|
|
883
|
+
walletCore?.off("accountChange", handleAccountChange);
|
|
884
|
+
walletCore?.off("networkChange", handleNetworkChange);
|
|
885
|
+
walletCore?.off("disconnect", handleDisconnect);
|
|
886
|
+
walletCore?.off("standardWalletsAdded", handleStandardWalletsAdded);
|
|
887
|
+
walletCore?.off(
|
|
888
|
+
"standardWalletsHiddenAdded",
|
|
889
|
+
handleStandardWalletsHiddenAdded
|
|
890
|
+
);
|
|
891
|
+
walletCore?.off(
|
|
892
|
+
"standardNotDetectedWalletAdded",
|
|
893
|
+
handleStandardNotDetectedWalletsAdded
|
|
894
|
+
);
|
|
895
|
+
};
|
|
896
|
+
}, [wallets, account]);
|
|
897
|
+
return /* @__PURE__ */ jsx10(
|
|
898
|
+
WalletContext.Provider,
|
|
899
|
+
{
|
|
900
|
+
value: {
|
|
901
|
+
connect,
|
|
902
|
+
signIn,
|
|
903
|
+
disconnect,
|
|
904
|
+
signAndSubmitTransaction,
|
|
905
|
+
signTransaction,
|
|
906
|
+
signMessage,
|
|
907
|
+
signMessageAndVerify,
|
|
908
|
+
changeNetwork,
|
|
909
|
+
submitTransaction,
|
|
910
|
+
account,
|
|
911
|
+
network,
|
|
912
|
+
connected,
|
|
913
|
+
wallet,
|
|
914
|
+
wallets,
|
|
915
|
+
notDetectedWallets,
|
|
916
|
+
hiddenWallets,
|
|
917
|
+
isLoading
|
|
918
|
+
},
|
|
919
|
+
children
|
|
920
|
+
}
|
|
921
|
+
);
|
|
922
|
+
};
|
|
958
923
|
export {
|
|
959
924
|
APTOS_PRIVACY_POLICY_URL,
|
|
960
925
|
AboutAptosConnect,
|