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