@moveindustries/wallet-adapter-react 7.2.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/LICENSE +201 -0
- package/README.md +306 -0
- package/dist/WalletProvider.d.ts +12 -0
- package/dist/WalletProvider.d.ts.map +1 -0
- package/dist/components/AboutMovementConnect.d.ts +29 -0
- package/dist/components/AboutMovementConnect.d.ts.map +1 -0
- package/dist/components/AboutPetraWeb.d.ts +31 -0
- package/dist/components/AboutPetraWeb.d.ts.map +1 -0
- package/dist/components/MovementPrivacyPolicy.d.ts +12 -0
- package/dist/components/MovementPrivacyPolicy.d.ts.map +1 -0
- package/dist/components/WalletItem.d.ts +16 -0
- package/dist/components/WalletItem.d.ts.map +1 -0
- package/dist/components/utils.d.ts +20 -0
- package/dist/components/utils.d.ts.map +1 -0
- package/dist/graphics/LinkGraphic.d.ts +3 -0
- package/dist/graphics/LinkGraphic.d.ts.map +1 -0
- package/dist/graphics/SmallMovementLogo.d.ts +3 -0
- package/dist/graphics/SmallMovementLogo.d.ts.map +1 -0
- package/dist/graphics/WalletGraphic.d.ts +3 -0
- package/dist/graphics/WalletGraphic.d.ts.map +1 -0
- package/dist/graphics/Web3Graphic.d.ts +3 -0
- package/dist/graphics/Web3Graphic.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +632 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +606 -0
- package/dist/index.mjs.map +1 -0
- package/dist/useWallet.d.ts +31 -0
- package/dist/useWallet.d.ts.map +1 -0
- package/package.json +60 -0
- package/src/WalletProvider.tsx +424 -0
- package/src/components/AboutMovementConnect.tsx +60 -0
- package/src/components/AboutPetraWeb.tsx +63 -0
- package/src/components/MovementPrivacyPolicy.tsx +44 -0
- package/src/components/WalletItem.tsx +122 -0
- package/src/components/utils.tsx +70 -0
- package/src/graphics/LinkGraphic.tsx +26 -0
- package/src/graphics/SmallMovementLogo.tsx +25 -0
- package/src/graphics/WalletGraphic.tsx +42 -0
- package/src/graphics/Web3Graphic.tsx +31 -0
- package/src/index.tsx +7 -0
- package/src/useWallet.tsx +67 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SmallMovementLogo.d.ts","sourceRoot":"","sources":["../../src/graphics/SmallMovementLogo.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAc,MAAM,OAAO,CAAC;AAE7C,eAAO,MAAM,iBAAiB,gIAqB5B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WalletGraphic.d.ts","sourceRoot":"","sources":["../../src/graphics/WalletGraphic.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAc,MAAM,OAAO,CAAC;AAE7C,eAAO,MAAM,aAAa,gIAsCzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Web3Graphic.d.ts","sourceRoot":"","sources":["../../src/graphics/Web3Graphic.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAc,MAAM,OAAO,CAAC;AAE7C,eAAO,MAAM,WAAW,gIA2BvB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "@moveindustries/wallet-adapter-core";
|
|
2
|
+
export * from "./WalletProvider";
|
|
3
|
+
export * from "./components/AboutMovementConnect";
|
|
4
|
+
export * from "./components/AboutPetraWeb";
|
|
5
|
+
export * from "./components/MovementPrivacyPolicy";
|
|
6
|
+
export * from "./components/WalletItem";
|
|
7
|
+
export * from "./useWallet";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,cAAc,kBAAkB,CAAC;AACjC,cAAc,mCAAmC,CAAC;AAClD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC;AACnD,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,632 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
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
|
+
var __export = (target, all) => {
|
|
36
|
+
for (var name in all)
|
|
37
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
38
|
+
};
|
|
39
|
+
var __copyProps = (to, from, except, desc) => {
|
|
40
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
41
|
+
for (let key of __getOwnPropNames(from))
|
|
42
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
43
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
44
|
+
}
|
|
45
|
+
return to;
|
|
46
|
+
};
|
|
47
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
48
|
+
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
|
+
|
|
70
|
+
// src/index.tsx
|
|
71
|
+
var index_exports = {};
|
|
72
|
+
__export(index_exports, {
|
|
73
|
+
AboutMovementConnect: () => AboutMovementConnect,
|
|
74
|
+
AboutPetraWeb: () => AboutPetraWeb,
|
|
75
|
+
EXPLORE_ECOSYSTEM_URL: () => EXPLORE_ECOSYSTEM_URL,
|
|
76
|
+
MOVEMENT_PRIVACY_POLICY_URL: () => MOVEMENT_PRIVACY_POLICY_URL,
|
|
77
|
+
MovementPrivacyPolicy: () => MovementPrivacyPolicy,
|
|
78
|
+
MovementWalletAdapterProvider: () => MovementWalletAdapterProvider,
|
|
79
|
+
WalletContext: () => WalletContext,
|
|
80
|
+
WalletItem: () => WalletItem,
|
|
81
|
+
useWallet: () => useWallet
|
|
82
|
+
});
|
|
83
|
+
module.exports = __toCommonJS(index_exports);
|
|
84
|
+
__reExport(index_exports, require("@moveindustries/wallet-adapter-core"), module.exports);
|
|
85
|
+
|
|
86
|
+
// src/WalletProvider.tsx
|
|
87
|
+
var import_wallet_adapter_core = require("@moveindustries/wallet-adapter-core");
|
|
88
|
+
var import_react2 = require("react");
|
|
89
|
+
|
|
90
|
+
// src/useWallet.tsx
|
|
91
|
+
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
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
108
|
+
var initialState = {
|
|
109
|
+
connected: false,
|
|
110
|
+
account: null,
|
|
111
|
+
network: null,
|
|
112
|
+
wallet: null
|
|
113
|
+
};
|
|
114
|
+
var MovementWalletAdapterProvider = ({
|
|
115
|
+
children,
|
|
116
|
+
optInWallets,
|
|
117
|
+
autoConnect = false,
|
|
118
|
+
dappConfig,
|
|
119
|
+
disableTelemetry = false,
|
|
120
|
+
onError
|
|
121
|
+
}) => {
|
|
122
|
+
const didAttemptAutoConnectRef = (0, import_react2.useRef)(false);
|
|
123
|
+
const [{ account, network, connected, wallet }, setState] = (0, import_react2.useState)(initialState);
|
|
124
|
+
const [isLoading, setIsLoading] = (0, import_react2.useState)(true);
|
|
125
|
+
const [walletCore, setWalletCore] = (0, import_react2.useState)();
|
|
126
|
+
const [wallets, setWallets] = (0, import_react2.useState)([]);
|
|
127
|
+
const [notDetectedWallets, setNotDetectedWallets] = (0, import_react2.useState)([]);
|
|
128
|
+
(0, import_react2.useEffect)(() => {
|
|
129
|
+
const walletCore2 = new import_wallet_adapter_core.WalletCore(
|
|
130
|
+
optInWallets,
|
|
131
|
+
dappConfig,
|
|
132
|
+
disableTelemetry
|
|
133
|
+
);
|
|
134
|
+
setWalletCore(walletCore2);
|
|
135
|
+
}, []);
|
|
136
|
+
(0, import_react2.useEffect)(() => {
|
|
137
|
+
var _a, _b;
|
|
138
|
+
setWallets((_a = walletCore == null ? void 0 : walletCore.wallets) != null ? _a : []);
|
|
139
|
+
setNotDetectedWallets((_b = walletCore == null ? void 0 : walletCore.notDetectedWallets) != null ? _b : []);
|
|
140
|
+
}, [walletCore]);
|
|
141
|
+
(0, import_react2.useEffect)(() => {
|
|
142
|
+
if (didAttemptAutoConnectRef.current || !(walletCore == null ? void 0 : walletCore.wallets.length)) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
didAttemptAutoConnectRef.current = true;
|
|
146
|
+
if (!autoConnect) {
|
|
147
|
+
setIsLoading(false);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const walletName = localStorage.getItem("MovementWalletName");
|
|
151
|
+
if (!walletName) {
|
|
152
|
+
setIsLoading(false);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const selectedWallet = walletCore.wallets.find(
|
|
156
|
+
(e) => e.name === walletName
|
|
157
|
+
);
|
|
158
|
+
if (!selectedWallet || selectedWallet.readyState !== import_wallet_adapter_core.WalletReadyState.Installed) {
|
|
159
|
+
setIsLoading(false);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (!connected) {
|
|
163
|
+
(() => __async(null, null, function* () {
|
|
164
|
+
try {
|
|
165
|
+
let shouldConnect = true;
|
|
166
|
+
if (typeof autoConnect === "function") {
|
|
167
|
+
shouldConnect = yield autoConnect(walletCore, selectedWallet);
|
|
168
|
+
} else {
|
|
169
|
+
shouldConnect = autoConnect;
|
|
170
|
+
}
|
|
171
|
+
if (shouldConnect) yield connect(walletName);
|
|
172
|
+
} catch (error) {
|
|
173
|
+
if (onError) onError(error);
|
|
174
|
+
return Promise.reject(error);
|
|
175
|
+
} finally {
|
|
176
|
+
setIsLoading(false);
|
|
177
|
+
}
|
|
178
|
+
}))();
|
|
179
|
+
} else {
|
|
180
|
+
setIsLoading(false);
|
|
181
|
+
}
|
|
182
|
+
}, [autoConnect, wallets]);
|
|
183
|
+
const connect = (walletName) => __async(null, null, function* () {
|
|
184
|
+
try {
|
|
185
|
+
setIsLoading(true);
|
|
186
|
+
yield walletCore == null ? void 0 : walletCore.connect(walletName);
|
|
187
|
+
} catch (error) {
|
|
188
|
+
if (onError) onError(error);
|
|
189
|
+
return Promise.reject(error);
|
|
190
|
+
} finally {
|
|
191
|
+
setIsLoading(false);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
const signIn = (args) => __async(null, null, function* () {
|
|
195
|
+
if (!walletCore) {
|
|
196
|
+
throw new Error("WalletCore is not initialized");
|
|
197
|
+
}
|
|
198
|
+
try {
|
|
199
|
+
setIsLoading(true);
|
|
200
|
+
return yield walletCore == null ? void 0 : walletCore.signIn(args);
|
|
201
|
+
} catch (error) {
|
|
202
|
+
if (onError) onError(error);
|
|
203
|
+
return Promise.reject(error);
|
|
204
|
+
} finally {
|
|
205
|
+
setIsLoading(false);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
const disconnect = () => __async(null, null, function* () {
|
|
209
|
+
try {
|
|
210
|
+
yield walletCore == null ? void 0 : walletCore.disconnect();
|
|
211
|
+
} catch (error) {
|
|
212
|
+
if (onError) onError(error);
|
|
213
|
+
return Promise.reject(error);
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
const signAndSubmitTransaction = (transaction) => __async(null, null, function* () {
|
|
217
|
+
try {
|
|
218
|
+
if (!walletCore) {
|
|
219
|
+
throw new Error("WalletCore is not initialized");
|
|
220
|
+
}
|
|
221
|
+
return yield walletCore.signAndSubmitTransaction(transaction);
|
|
222
|
+
} catch (error) {
|
|
223
|
+
if (onError) onError(error);
|
|
224
|
+
return Promise.reject(error);
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
const signTransaction = (args) => __async(null, null, function* () {
|
|
228
|
+
const { transactionOrPayload, asFeePayer, options } = args;
|
|
229
|
+
if (!walletCore) {
|
|
230
|
+
throw new Error("WalletCore is not initialized");
|
|
231
|
+
}
|
|
232
|
+
try {
|
|
233
|
+
return yield walletCore.signTransaction({
|
|
234
|
+
transactionOrPayload,
|
|
235
|
+
asFeePayer
|
|
236
|
+
});
|
|
237
|
+
} catch (error) {
|
|
238
|
+
if (onError) onError(error);
|
|
239
|
+
return Promise.reject(error);
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
const submitTransaction = (transaction) => __async(null, null, function* () {
|
|
243
|
+
if (!walletCore) {
|
|
244
|
+
throw new Error("WalletCore is not initialized");
|
|
245
|
+
}
|
|
246
|
+
try {
|
|
247
|
+
return yield walletCore == null ? void 0 : walletCore.submitTransaction(transaction);
|
|
248
|
+
} catch (error) {
|
|
249
|
+
if (onError) onError(error);
|
|
250
|
+
return Promise.reject(error);
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
const signMessage = (message) => __async(null, null, function* () {
|
|
254
|
+
if (!walletCore) {
|
|
255
|
+
throw new Error("WalletCore is not initialized");
|
|
256
|
+
}
|
|
257
|
+
try {
|
|
258
|
+
return yield walletCore == null ? void 0 : walletCore.signMessage(message);
|
|
259
|
+
} catch (error) {
|
|
260
|
+
if (onError) onError(error);
|
|
261
|
+
return Promise.reject(error);
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
const signMessageAndVerify = (message) => __async(null, null, function* () {
|
|
265
|
+
if (!walletCore) {
|
|
266
|
+
throw new Error("WalletCore is not initialized");
|
|
267
|
+
}
|
|
268
|
+
try {
|
|
269
|
+
return yield walletCore == null ? void 0 : walletCore.signMessageAndVerify(message);
|
|
270
|
+
} catch (error) {
|
|
271
|
+
if (onError) onError(error);
|
|
272
|
+
return Promise.reject(error);
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
const changeNetwork = (network2) => __async(null, null, function* () {
|
|
276
|
+
if (!walletCore) {
|
|
277
|
+
throw new Error("WalletCore is not initialized");
|
|
278
|
+
}
|
|
279
|
+
try {
|
|
280
|
+
return yield walletCore == null ? void 0 : walletCore.changeNetwork(network2);
|
|
281
|
+
} catch (error) {
|
|
282
|
+
if (onError) onError(error);
|
|
283
|
+
return Promise.reject(error);
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
const handleConnect = () => {
|
|
287
|
+
setState((state) => {
|
|
288
|
+
return __spreadProps(__spreadValues({}, state), {
|
|
289
|
+
connected: true,
|
|
290
|
+
account: (walletCore == null ? void 0 : walletCore.account) || null,
|
|
291
|
+
network: (walletCore == null ? void 0 : walletCore.network) || null,
|
|
292
|
+
wallet: (walletCore == null ? void 0 : walletCore.wallet) || null
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
};
|
|
296
|
+
const handleAccountChange = (0, import_react2.useCallback)(() => {
|
|
297
|
+
if (!connected) return;
|
|
298
|
+
if (!(walletCore == null ? void 0 : walletCore.wallet)) return;
|
|
299
|
+
setState((state) => {
|
|
300
|
+
return __spreadProps(__spreadValues({}, state), {
|
|
301
|
+
account: (walletCore == null ? void 0 : walletCore.account) || null
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
}, [connected]);
|
|
305
|
+
const handleNetworkChange = (0, import_react2.useCallback)(() => {
|
|
306
|
+
if (!connected) return;
|
|
307
|
+
if (!(walletCore == null ? void 0 : walletCore.wallet)) return;
|
|
308
|
+
setState((state) => {
|
|
309
|
+
return __spreadProps(__spreadValues({}, state), {
|
|
310
|
+
network: (walletCore == null ? void 0 : walletCore.network) || null
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
}, [connected]);
|
|
314
|
+
(0, import_react2.useEffect)(() => {
|
|
315
|
+
if (connected) {
|
|
316
|
+
walletCore == null ? void 0 : walletCore.onAccountChange();
|
|
317
|
+
walletCore == null ? void 0 : walletCore.onNetworkChange();
|
|
318
|
+
}
|
|
319
|
+
}, [connected]);
|
|
320
|
+
const handleDisconnect = () => {
|
|
321
|
+
if (!connected) return;
|
|
322
|
+
setState((state) => {
|
|
323
|
+
return __spreadProps(__spreadValues({}, state), {
|
|
324
|
+
connected: false,
|
|
325
|
+
account: (walletCore == null ? void 0 : walletCore.account) || null,
|
|
326
|
+
network: (walletCore == null ? void 0 : walletCore.network) || null,
|
|
327
|
+
wallet: null
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
};
|
|
331
|
+
const handleStandardWalletsAdded = (standardWallet) => {
|
|
332
|
+
const existingWalletIndex = wallets.findIndex(
|
|
333
|
+
(wallet2) => wallet2.name == standardWallet.name
|
|
334
|
+
);
|
|
335
|
+
if (existingWalletIndex !== -1) {
|
|
336
|
+
setWallets((wallets2) => [
|
|
337
|
+
...wallets2.slice(0, existingWalletIndex),
|
|
338
|
+
standardWallet,
|
|
339
|
+
...wallets2.slice(existingWalletIndex + 1)
|
|
340
|
+
]);
|
|
341
|
+
} else {
|
|
342
|
+
setWallets((wallets2) => [...wallets2, standardWallet]);
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
const handleStandardNotDetectedWalletsAdded = (notDetectedWallet) => {
|
|
346
|
+
const existingWalletIndex = wallets.findIndex(
|
|
347
|
+
(wallet2) => wallet2.name == notDetectedWallet.name
|
|
348
|
+
);
|
|
349
|
+
if (existingWalletIndex !== -1) {
|
|
350
|
+
setNotDetectedWallets((wallets2) => [
|
|
351
|
+
...wallets2.slice(0, existingWalletIndex),
|
|
352
|
+
notDetectedWallet,
|
|
353
|
+
...wallets2.slice(existingWalletIndex + 1)
|
|
354
|
+
]);
|
|
355
|
+
} else {
|
|
356
|
+
setNotDetectedWallets((wallets2) => [...wallets2, notDetectedWallet]);
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
(0, import_react2.useEffect)(() => {
|
|
360
|
+
walletCore == null ? void 0 : walletCore.on("connect", handleConnect);
|
|
361
|
+
walletCore == null ? void 0 : walletCore.on("accountChange", handleAccountChange);
|
|
362
|
+
walletCore == null ? void 0 : walletCore.on("networkChange", handleNetworkChange);
|
|
363
|
+
walletCore == null ? void 0 : walletCore.on("disconnect", handleDisconnect);
|
|
364
|
+
walletCore == null ? void 0 : walletCore.on("standardWalletsAdded", handleStandardWalletsAdded);
|
|
365
|
+
walletCore == null ? void 0 : walletCore.on(
|
|
366
|
+
"standardNotDetectedWalletAdded",
|
|
367
|
+
handleStandardNotDetectedWalletsAdded
|
|
368
|
+
);
|
|
369
|
+
return () => {
|
|
370
|
+
walletCore == null ? void 0 : walletCore.off("connect", handleConnect);
|
|
371
|
+
walletCore == null ? void 0 : walletCore.off("accountChange", handleAccountChange);
|
|
372
|
+
walletCore == null ? void 0 : walletCore.off("networkChange", handleNetworkChange);
|
|
373
|
+
walletCore == null ? void 0 : walletCore.off("disconnect", handleDisconnect);
|
|
374
|
+
walletCore == null ? void 0 : walletCore.off("standardWalletsAdded", handleStandardWalletsAdded);
|
|
375
|
+
walletCore == null ? void 0 : walletCore.off(
|
|
376
|
+
"standardNotDetectedWalletAdded",
|
|
377
|
+
handleStandardNotDetectedWalletsAdded
|
|
378
|
+
);
|
|
379
|
+
};
|
|
380
|
+
}, [wallets, account]);
|
|
381
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
382
|
+
WalletContext.Provider,
|
|
383
|
+
{
|
|
384
|
+
value: {
|
|
385
|
+
connect,
|
|
386
|
+
signIn,
|
|
387
|
+
disconnect,
|
|
388
|
+
signAndSubmitTransaction,
|
|
389
|
+
signTransaction,
|
|
390
|
+
signMessage,
|
|
391
|
+
signMessageAndVerify,
|
|
392
|
+
changeNetwork,
|
|
393
|
+
submitTransaction,
|
|
394
|
+
account,
|
|
395
|
+
network,
|
|
396
|
+
connected,
|
|
397
|
+
wallet,
|
|
398
|
+
wallets,
|
|
399
|
+
notDetectedWallets,
|
|
400
|
+
isLoading
|
|
401
|
+
},
|
|
402
|
+
children
|
|
403
|
+
}
|
|
404
|
+
);
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
// src/components/utils.tsx
|
|
408
|
+
var import_react_slot = require("@radix-ui/react-slot");
|
|
409
|
+
var import_react3 = require("react");
|
|
410
|
+
var import_jsx_runtime2 = (
|
|
411
|
+
/**
|
|
412
|
+
* Due to the complexity of the types at play, TypeScript reports the
|
|
413
|
+
* following error for our JSX below:
|
|
414
|
+
*
|
|
415
|
+
* `Expression produces a union type that is too complex to represent.`
|
|
416
|
+
*
|
|
417
|
+
* We can safely ignore this error and retain accurate return types for
|
|
418
|
+
* consumers of this function. The only drawback is that type-checking is
|
|
419
|
+
* ignored for the JSX block below.
|
|
420
|
+
*/
|
|
421
|
+
// @ts-expect-error
|
|
422
|
+
require("react/jsx-runtime")
|
|
423
|
+
);
|
|
424
|
+
function createHeadlessComponent(displayName, elementType, props) {
|
|
425
|
+
const component = (0, import_react3.forwardRef)(({ className, asChild, children }, ref) => {
|
|
426
|
+
const Component = asChild ? import_react_slot.Slot : elementType;
|
|
427
|
+
const _a = typeof props === "function" ? props(displayName) : props != null ? props : {}, { children: defaultChildren } = _a, resolvedProps = __objRest(_a, ["children"]);
|
|
428
|
+
const resolvedChildren = (
|
|
429
|
+
/**
|
|
430
|
+
* Use props' default children if no children are set in the component element's children and when asChild is true.
|
|
431
|
+
*/
|
|
432
|
+
asChild && (0, import_react3.isValidElement)(children) && !children.props.children ? (0, import_react3.cloneElement)(children, {}, defaultChildren) : children != null ? children : defaultChildren
|
|
433
|
+
);
|
|
434
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Component, __spreadProps(__spreadValues({ ref, className }, resolvedProps), { children: resolvedChildren }));
|
|
435
|
+
});
|
|
436
|
+
component.displayName = displayName;
|
|
437
|
+
return component;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// src/components/AboutMovementConnect.tsx
|
|
441
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
442
|
+
var Root = ({ children }) => {
|
|
443
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children });
|
|
444
|
+
};
|
|
445
|
+
Root.displayName = "AboutMovementConnect";
|
|
446
|
+
var Trigger = createHeadlessComponent(
|
|
447
|
+
"AboutMovementConnect.Trigger",
|
|
448
|
+
"button",
|
|
449
|
+
() => ({
|
|
450
|
+
// No-op since social sign-in is disabled
|
|
451
|
+
onClick: () => {
|
|
452
|
+
},
|
|
453
|
+
style: { display: "none" }
|
|
454
|
+
})
|
|
455
|
+
);
|
|
456
|
+
var AboutMovementConnect = Object.assign(Root, {
|
|
457
|
+
Trigger
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
// src/components/AboutPetraWeb.tsx
|
|
461
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
462
|
+
var EXPLORE_ECOSYSTEM_URL = "https://movementlabs.xyz/ecosystem";
|
|
463
|
+
var Root2 = ({ children }) => {
|
|
464
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children });
|
|
465
|
+
};
|
|
466
|
+
Root2.displayName = "AboutPetraWeb";
|
|
467
|
+
var Trigger2 = createHeadlessComponent(
|
|
468
|
+
"AboutPetraWeb.Trigger",
|
|
469
|
+
"button",
|
|
470
|
+
() => ({
|
|
471
|
+
// No-op since social sign-in is disabled
|
|
472
|
+
onClick: () => {
|
|
473
|
+
},
|
|
474
|
+
style: { display: "none" }
|
|
475
|
+
})
|
|
476
|
+
);
|
|
477
|
+
var AboutPetraWeb = Object.assign(Root2, {
|
|
478
|
+
Trigger: Trigger2
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
// src/components/MovementPrivacyPolicy.tsx
|
|
482
|
+
var import_react5 = require("react");
|
|
483
|
+
|
|
484
|
+
// src/graphics/SmallMovementLogo.tsx
|
|
485
|
+
var import_react4 = require("react");
|
|
486
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
487
|
+
var SmallMovementLogo = (0, import_react4.forwardRef)((props, ref) => {
|
|
488
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
489
|
+
"svg",
|
|
490
|
+
__spreadProps(__spreadValues({
|
|
491
|
+
ref,
|
|
492
|
+
width: "12",
|
|
493
|
+
height: "12",
|
|
494
|
+
viewBox: "0 0 12 12",
|
|
495
|
+
fill: "none"
|
|
496
|
+
}, props), {
|
|
497
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
498
|
+
"path",
|
|
499
|
+
{
|
|
500
|
+
fillRule: "evenodd",
|
|
501
|
+
clipRule: "evenodd",
|
|
502
|
+
d: "M6 12C9.31371 12 12 9.31371 12 6C12 2.68629 9.31371 0 6 0C2.68629 0 0 2.68629 0 6C0 9.31371 2.68629 12 6 12ZM7.17547 3.67976C7.13401 3.72309 7.07649 3.74757 7.01648 3.74757H3.00775C3.69185 2.83824 4.77995 2.25 6.00569 2.25C7.23142 2.25 8.31953 2.83824 9.00362 3.74757H8.28524C8.20824 3.74757 8.13498 3.71468 8.08401 3.65701L7.81608 3.35416C7.77618 3.30896 7.71882 3.28308 7.6585 3.28308H7.6454C7.58805 3.28308 7.53318 3.30646 7.49343 3.34792L7.17547 3.67976ZM8.05656 4.75897H7.39569C7.31869 4.75897 7.24543 4.72593 7.19447 4.66842L6.92638 4.36557C6.88647 4.32036 6.82896 4.29465 6.7688 4.29465C6.70863 4.29465 6.65112 4.32052 6.61121 4.36557L6.38131 4.6254C6.30603 4.71034 6.19801 4.75913 6.08454 4.75913H2.46703C2.36401 5.05278 2.29683 5.36296 2.27002 5.68467H5.68505C5.74506 5.68467 5.80258 5.66019 5.84404 5.61686L6.16201 5.28502C6.20175 5.24356 6.25662 5.22018 6.31398 5.22018H6.32707C6.38739 5.22018 6.44475 5.24606 6.48465 5.29126L6.75258 5.59411C6.80355 5.65178 6.87681 5.68467 6.95381 5.68467H9.74133C9.71452 5.3628 9.64734 5.05263 9.54431 4.75913H8.05641L8.05656 4.75897ZM4.33651 7.63095C4.39652 7.63095 4.45404 7.60648 4.4955 7.56315L4.81347 7.23131C4.85321 7.18985 4.90808 7.16647 4.96544 7.16647H4.97853C5.03885 7.16647 5.09621 7.19234 5.13611 7.23739L5.40404 7.54024C5.45501 7.59791 5.52827 7.6308 5.60527 7.6308H9.38285C9.52438 7.33839 9.62803 7.02463 9.68975 6.69591H6.06383C5.98683 6.69591 5.91357 6.66287 5.8626 6.60535L5.59467 6.3025C5.55477 6.2573 5.49725 6.23158 5.43709 6.23158C5.37692 6.23158 5.31941 6.25746 5.27951 6.3025L5.0496 6.56233C4.97432 6.64728 4.86631 6.69606 4.75268 6.69606H2.32147C2.3832 7.02479 2.487 7.33855 2.62837 7.63095H4.33651ZM5.57359 8.55745H4.59116C4.51417 8.55745 4.44091 8.52441 4.38994 8.46689L4.12201 8.16404C4.0821 8.11884 4.02459 8.09312 3.96442 8.09312C3.90426 8.09312 3.84675 8.119 3.80684 8.16404L3.57694 8.42387C3.50166 8.50882 3.39364 8.55761 3.28001 8.55761H3.26474C3.94915 9.29096 4.92378 9.74998 6.00596 9.74998C7.08815 9.74998 8.06262 9.29096 8.74719 8.55761H5.57359V8.55745Z",
|
|
503
|
+
fill: "currentColor"
|
|
504
|
+
}
|
|
505
|
+
)
|
|
506
|
+
})
|
|
507
|
+
);
|
|
508
|
+
});
|
|
509
|
+
SmallMovementLogo.displayName = "SmallMovementLogo";
|
|
510
|
+
|
|
511
|
+
// src/components/MovementPrivacyPolicy.tsx
|
|
512
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
513
|
+
var MOVEMENT_PRIVACY_POLICY_URL = "https://movementlabs.xyz/privacy";
|
|
514
|
+
var Root3 = createHeadlessComponent("MovementPrivacyPolicy.Root", "div");
|
|
515
|
+
var Disclaimer = createHeadlessComponent(
|
|
516
|
+
"MovementPrivacyPolicy.Disclaimer",
|
|
517
|
+
"span",
|
|
518
|
+
{ children: "By continuing, you agree to Movement Labs'" }
|
|
519
|
+
);
|
|
520
|
+
var Link = createHeadlessComponent("MovementPrivacyPolicy.Disclaimer", "a", {
|
|
521
|
+
href: MOVEMENT_PRIVACY_POLICY_URL,
|
|
522
|
+
target: "_blank",
|
|
523
|
+
rel: "noopener noreferrer",
|
|
524
|
+
children: "Privacy Policy"
|
|
525
|
+
});
|
|
526
|
+
var PoweredBy = (0, import_react5.forwardRef)(({ className }, ref) => {
|
|
527
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { ref, className, children: [
|
|
528
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "Powered by" }),
|
|
529
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SmallMovementLogo, {}),
|
|
530
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "Movement Labs" })
|
|
531
|
+
] });
|
|
532
|
+
});
|
|
533
|
+
PoweredBy.displayName = "MovementPrivacyPolicy.PoweredBy";
|
|
534
|
+
var MovementPrivacyPolicy = Object.assign(Root3, {
|
|
535
|
+
Disclaimer,
|
|
536
|
+
Link,
|
|
537
|
+
PoweredBy
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
// src/components/WalletItem.tsx
|
|
541
|
+
var import_wallet_adapter_core2 = require("@moveindustries/wallet-adapter-core");
|
|
542
|
+
var import_react_slot2 = require("@radix-ui/react-slot");
|
|
543
|
+
var import_react6 = require("react");
|
|
544
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
545
|
+
function useWalletItemContext(displayName) {
|
|
546
|
+
const context = (0, import_react6.useContext)(WalletItemContext);
|
|
547
|
+
if (!context) {
|
|
548
|
+
throw new Error(`\`${displayName}\` must be used within \`WalletItem\``);
|
|
549
|
+
}
|
|
550
|
+
return context;
|
|
551
|
+
}
|
|
552
|
+
var WalletItemContext = (0, import_react6.createContext)(null);
|
|
553
|
+
var Root4 = (0, import_react6.forwardRef)(
|
|
554
|
+
({ wallet, onConnect, className, asChild, children }, ref) => {
|
|
555
|
+
const { connect } = useWallet();
|
|
556
|
+
const connectWallet = (0, import_react6.useCallback)(() => {
|
|
557
|
+
connect(wallet.name);
|
|
558
|
+
onConnect == null ? void 0 : onConnect();
|
|
559
|
+
}, [connect, wallet.name, onConnect]);
|
|
560
|
+
const isWalletReady = wallet.readyState === import_wallet_adapter_core2.WalletReadyState.Installed;
|
|
561
|
+
const mobileSupport = "deeplinkProvider" in wallet && wallet.deeplinkProvider;
|
|
562
|
+
if (!isWalletReady && (0, import_wallet_adapter_core2.isRedirectable)() && !mobileSupport) return null;
|
|
563
|
+
const Component = asChild ? import_react_slot2.Slot : "div";
|
|
564
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(WalletItemContext.Provider, { value: { wallet, connectWallet }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Component, { ref, className, children }) });
|
|
565
|
+
}
|
|
566
|
+
);
|
|
567
|
+
Root4.displayName = "WalletItem";
|
|
568
|
+
var Icon = createHeadlessComponent(
|
|
569
|
+
"WalletItem.Icon",
|
|
570
|
+
"img",
|
|
571
|
+
(displayName) => {
|
|
572
|
+
const context = useWalletItemContext(displayName);
|
|
573
|
+
return {
|
|
574
|
+
src: context.wallet.icon,
|
|
575
|
+
alt: `${context.wallet.name} icon`
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
);
|
|
579
|
+
var Name = createHeadlessComponent(
|
|
580
|
+
"WalletItem.Name",
|
|
581
|
+
"div",
|
|
582
|
+
(displayName) => {
|
|
583
|
+
const context = useWalletItemContext(displayName);
|
|
584
|
+
return {
|
|
585
|
+
children: context.wallet.name
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
);
|
|
589
|
+
var ConnectButton = createHeadlessComponent(
|
|
590
|
+
"WalletItem.ConnectButton",
|
|
591
|
+
"button",
|
|
592
|
+
(displayName) => {
|
|
593
|
+
const context = useWalletItemContext(displayName);
|
|
594
|
+
return {
|
|
595
|
+
onClick: context.connectWallet,
|
|
596
|
+
children: "Connect"
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
);
|
|
600
|
+
var InstallLink = createHeadlessComponent(
|
|
601
|
+
"WalletItem.InstallLink",
|
|
602
|
+
"a",
|
|
603
|
+
(displayName) => {
|
|
604
|
+
const context = useWalletItemContext(displayName);
|
|
605
|
+
return {
|
|
606
|
+
href: context.wallet.url,
|
|
607
|
+
target: "_blank",
|
|
608
|
+
rel: "noopener noreferrer",
|
|
609
|
+
children: "Install"
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
);
|
|
613
|
+
var WalletItem = Object.assign(Root4, {
|
|
614
|
+
Icon,
|
|
615
|
+
Name,
|
|
616
|
+
ConnectButton,
|
|
617
|
+
InstallLink
|
|
618
|
+
});
|
|
619
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
620
|
+
0 && (module.exports = {
|
|
621
|
+
AboutMovementConnect,
|
|
622
|
+
AboutPetraWeb,
|
|
623
|
+
EXPLORE_ECOSYSTEM_URL,
|
|
624
|
+
MOVEMENT_PRIVACY_POLICY_URL,
|
|
625
|
+
MovementPrivacyPolicy,
|
|
626
|
+
MovementWalletAdapterProvider,
|
|
627
|
+
WalletContext,
|
|
628
|
+
WalletItem,
|
|
629
|
+
useWallet,
|
|
630
|
+
...require("@moveindustries/wallet-adapter-core")
|
|
631
|
+
});
|
|
632
|
+
//# sourceMappingURL=index.js.map
|