@avalabs/avacloud-waas-react 1.0.9 → 1.0.12
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/README.md +105 -37
- package/dist/index.d.mts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +78 -136
- package/dist/index.mjs +81 -136
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ __export(index_exports, {
|
|
|
32
32
|
WalletButton: () => WalletButton,
|
|
33
33
|
WalletCard: () => WalletCard,
|
|
34
34
|
WalletDisplay: () => WalletDisplay,
|
|
35
|
+
avaCloudWallet: () => avaCloudWallet,
|
|
35
36
|
useAuth: () => useAuth,
|
|
36
37
|
useAvaCloudWallet: () => useAvaCloudWallet,
|
|
37
38
|
useChainId: () => useChainId,
|
|
@@ -142,14 +143,10 @@ function usePostMessage({
|
|
|
142
143
|
const isExpired = Date.now() - timestamp > 30 * 60 * 1e3;
|
|
143
144
|
if (!isExpired) {
|
|
144
145
|
const { _timestamp, ...configWithoutTimestamp } = cachedConfig;
|
|
145
|
-
console.log("Using cached org config:", configWithoutTimestamp);
|
|
146
146
|
onOrgConfigUpdate(configWithoutTimestamp);
|
|
147
|
-
} else {
|
|
148
|
-
console.log("Cached org config expired, will fetch fresh data");
|
|
149
147
|
}
|
|
150
148
|
}
|
|
151
149
|
} catch (error) {
|
|
152
|
-
console.error("Error loading cached org config:", error);
|
|
153
150
|
}
|
|
154
151
|
}
|
|
155
152
|
}, [orgId, environment, onOrgConfigUpdate]);
|
|
@@ -158,12 +155,10 @@ function usePostMessage({
|
|
|
158
155
|
try {
|
|
159
156
|
if (message.type === "SIGNUP_REQUEST") {
|
|
160
157
|
if (globalAuthState.signupInProgress) {
|
|
161
|
-
console.log("Global signup already in progress, ignoring duplicate request");
|
|
162
158
|
return;
|
|
163
159
|
}
|
|
164
160
|
const now = Date.now();
|
|
165
161
|
if (now - globalAuthState.lastSignupTimestamp < 3e3) {
|
|
166
|
-
console.log("Ignoring duplicate signup attempt (global debounce)");
|
|
167
162
|
return;
|
|
168
163
|
}
|
|
169
164
|
globalAuthState.signupInProgress = true;
|
|
@@ -187,18 +182,15 @@ function usePostMessage({
|
|
|
187
182
|
if ("requestId" in messageToSend && messageToSend.requestId) {
|
|
188
183
|
globalAuthState.processingMessageIds.add(messageToSend.requestId);
|
|
189
184
|
}
|
|
190
|
-
console.log("Sending message to auth iframe:", messageToSend);
|
|
191
185
|
iframe.contentWindow.postMessage(messageToSend, authServiceUrl);
|
|
192
186
|
return;
|
|
193
187
|
}
|
|
194
188
|
if (message.type === "LOGIN_REQUEST") {
|
|
195
189
|
if (globalAuthState.loginInProgress) {
|
|
196
|
-
console.log("Global login already in progress, ignoring duplicate request");
|
|
197
190
|
return;
|
|
198
191
|
}
|
|
199
192
|
const now = Date.now();
|
|
200
193
|
if (now - globalAuthState.lastLoginTimestamp < 3e3) {
|
|
201
|
-
console.log("Ignoring duplicate login attempt (global debounce)");
|
|
202
194
|
return;
|
|
203
195
|
}
|
|
204
196
|
globalAuthState.loginInProgress = true;
|
|
@@ -213,14 +205,11 @@ function usePostMessage({
|
|
|
213
205
|
if (finalMessage.requestId) {
|
|
214
206
|
globalAuthState.processingMessageIds.add(finalMessage.requestId);
|
|
215
207
|
}
|
|
216
|
-
console.log("Sending message to auth iframe:", finalMessage);
|
|
217
208
|
iframe.contentWindow.postMessage(finalMessage, authServiceUrl);
|
|
218
209
|
return;
|
|
219
210
|
}
|
|
220
|
-
console.log("Sending message to auth iframe:", message);
|
|
221
211
|
iframe.contentWindow.postMessage(message, authServiceUrl);
|
|
222
212
|
} catch (error) {
|
|
223
|
-
console.error("Error sending message to iframe:", error);
|
|
224
213
|
if (message.type === "SIGNUP_REQUEST") {
|
|
225
214
|
globalAuthState.signupInProgress = false;
|
|
226
215
|
}
|
|
@@ -228,15 +217,12 @@ function usePostMessage({
|
|
|
228
217
|
globalAuthState.loginInProgress = false;
|
|
229
218
|
}
|
|
230
219
|
}
|
|
231
|
-
} else {
|
|
232
|
-
console.error("No iframe available to send message");
|
|
233
220
|
}
|
|
234
221
|
}, [iframe, authServiceUrl]);
|
|
235
222
|
(0, import_react.useEffect)(() => {
|
|
236
223
|
const handleMessage = async (event) => {
|
|
237
224
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
238
225
|
if (isHandlingMessageRef.current) {
|
|
239
|
-
console.log("Already handling a message, skipping");
|
|
240
226
|
return;
|
|
241
227
|
}
|
|
242
228
|
if (event.origin !== new URL(authServiceUrl).origin) {
|
|
@@ -246,12 +232,10 @@ function usePostMessage({
|
|
|
246
232
|
return;
|
|
247
233
|
}
|
|
248
234
|
if (event.data.requestId && globalAuthState.processingMessageIds.has(event.data.requestId)) {
|
|
249
|
-
console.log(`Already processed message with requestId: ${event.data.requestId}, ignoring duplicate`);
|
|
250
235
|
return;
|
|
251
236
|
}
|
|
252
237
|
try {
|
|
253
238
|
isHandlingMessageRef.current = true;
|
|
254
|
-
console.log("Received message from iframe:", event.data);
|
|
255
239
|
if (event.data.type === "ERROR") {
|
|
256
240
|
globalAuthState.signupInProgress = false;
|
|
257
241
|
globalAuthState.loginInProgress = false;
|
|
@@ -265,19 +249,14 @@ function usePostMessage({
|
|
|
265
249
|
}
|
|
266
250
|
switch (event.data.type) {
|
|
267
251
|
case "IFRAME_READY":
|
|
268
|
-
console.log("Iframe ready message received, setting isIframeReady to true");
|
|
269
|
-
console.log("\u2705 Connection established: Parent received IFRAME_READY from auth service.");
|
|
270
252
|
setIsIframeReady(true);
|
|
271
253
|
break;
|
|
272
254
|
case "RECEIVE_OIDC":
|
|
273
|
-
console.log("Received OIDC token payload:", event.data.payload);
|
|
274
255
|
if (typeof ((_b = event.data.payload) == null ? void 0 : _b.idToken) === "string") {
|
|
275
256
|
const oidcToken = event.data.payload.idToken;
|
|
276
|
-
console.log("Triggering onOidcReceived callback with token...");
|
|
277
257
|
hasRequestedOidcRef.current = false;
|
|
278
258
|
onOidcReceived == null ? void 0 : onOidcReceived(oidcToken);
|
|
279
259
|
} else {
|
|
280
|
-
console.warn("RECEIVE_OIDC message missing idToken in payload.");
|
|
281
260
|
hasRequestedOidcRef.current = false;
|
|
282
261
|
}
|
|
283
262
|
break;
|
|
@@ -290,7 +269,6 @@ function usePostMessage({
|
|
|
290
269
|
}
|
|
291
270
|
const authStateChanged = lastAuthStateRef.current.isAuthenticated !== newIsAuthenticated || lastAuthStateRef.current.userId !== newUserId;
|
|
292
271
|
if (authStateChanged) {
|
|
293
|
-
console.log("Auth status changed:", { newIsAuthenticated, newUserId });
|
|
294
272
|
setIsAuthenticated(newIsAuthenticated);
|
|
295
273
|
if (event.data.user) {
|
|
296
274
|
const userInfo = {
|
|
@@ -300,11 +278,9 @@ function usePostMessage({
|
|
|
300
278
|
displayName: event.data.user.nickname || event.data.user.name || ((_e = event.data.user.email) == null ? void 0 : _e.split("@")[0]) || "User",
|
|
301
279
|
rawUserData: event.data.user
|
|
302
280
|
};
|
|
303
|
-
console.log("Setting user info:", userInfo);
|
|
304
281
|
setUser(userInfo);
|
|
305
282
|
if (newIsAuthenticated && !cubistClient && !hasRequestedOidcRef.current) {
|
|
306
283
|
hasRequestedOidcRef.current = true;
|
|
307
|
-
console.log("User newly authenticated, sending GET_OIDC message");
|
|
308
284
|
sendMessage({ type: "GET_OIDC" });
|
|
309
285
|
return;
|
|
310
286
|
}
|
|
@@ -329,7 +305,6 @@ function usePostMessage({
|
|
|
329
305
|
}
|
|
330
306
|
}
|
|
331
307
|
if (event.data.orgConfig && onOrgConfigUpdate) {
|
|
332
|
-
console.log("Received organization config:", event.data.orgConfig);
|
|
333
308
|
onOrgConfigUpdate(event.data.orgConfig);
|
|
334
309
|
if (orgId) {
|
|
335
310
|
try {
|
|
@@ -339,9 +314,7 @@ function usePostMessage({
|
|
|
339
314
|
_timestamp: Date.now()
|
|
340
315
|
};
|
|
341
316
|
localStorage.setItem(cachedConfigKey, JSON.stringify(configWithTimestamp));
|
|
342
|
-
console.log("Cached organization config for future use");
|
|
343
317
|
} catch (error) {
|
|
344
|
-
console.error("Error caching org config:", error);
|
|
345
318
|
}
|
|
346
319
|
}
|
|
347
320
|
}
|
|
@@ -351,12 +324,10 @@ function usePostMessage({
|
|
|
351
324
|
break;
|
|
352
325
|
}
|
|
353
326
|
case "REGISTER_SUCCESS": {
|
|
354
|
-
console.log("Registration successful:", event.data.payload);
|
|
355
327
|
const userId = (_f = event.data.payload) == null ? void 0 : _f.userId;
|
|
356
328
|
if (userId) {
|
|
357
329
|
localStorage.setItem(CUBIST_USER_ID_KEY, userId);
|
|
358
330
|
if (!hasRequestedOidcRef.current) {
|
|
359
|
-
console.log("Registration complete, sending GET_OIDC message");
|
|
360
331
|
hasRequestedOidcRef.current = true;
|
|
361
332
|
sendMessage({ type: "GET_OIDC" });
|
|
362
333
|
}
|
|
@@ -365,11 +336,9 @@ function usePostMessage({
|
|
|
365
336
|
}
|
|
366
337
|
case "ERROR":
|
|
367
338
|
if (event.data.error === "User not authenticated in iframe") {
|
|
368
|
-
console.log("Ignoring expected auth iframe error:", event.data.error);
|
|
369
339
|
isHandlingMessageRef.current = false;
|
|
370
340
|
return;
|
|
371
341
|
}
|
|
372
|
-
console.error("Error from auth service:", event.data.error);
|
|
373
342
|
onAuthError == null ? void 0 : onAuthError(new Error((_g = event.data.error) != null ? _g : "Unknown error"));
|
|
374
343
|
setIsLoading(false);
|
|
375
344
|
break;
|
|
@@ -397,7 +366,6 @@ function usePostMessage({
|
|
|
397
366
|
]);
|
|
398
367
|
(0, import_react.useEffect)(() => {
|
|
399
368
|
if (isIframeReady && (iframe == null ? void 0 : iframe.contentWindow)) {
|
|
400
|
-
console.log("\u23F3 Connection attempt: Parent sending CHECK_AUTH_STATUS to auth service.");
|
|
401
369
|
sendMessage({
|
|
402
370
|
type: "CHECK_AUTH_STATUS",
|
|
403
371
|
payload: {
|
|
@@ -437,6 +405,10 @@ function PoweredByAvaCloud() {
|
|
|
437
405
|
] });
|
|
438
406
|
}
|
|
439
407
|
|
|
408
|
+
// src/constants/legal.ts
|
|
409
|
+
var TERMS_OF_SERVICE_URL = "https://app.avacloud.io/legal/waas/user-terms";
|
|
410
|
+
var PRIVACY_POLICY_URL = "https://www.avalabs.org/privacy-policy";
|
|
411
|
+
|
|
440
412
|
// src/components/SignInContent.tsx
|
|
441
413
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
442
414
|
function SignInContent({
|
|
@@ -521,7 +493,6 @@ function SignInContent({
|
|
|
521
493
|
onEmailSignup(email, password);
|
|
522
494
|
};
|
|
523
495
|
const handleForgotPassword = () => {
|
|
524
|
-
console.log("Forgot password clicked");
|
|
525
496
|
};
|
|
526
497
|
const handleToggleSignup = () => {
|
|
527
498
|
setIsSignupMode(!isSignupMode);
|
|
@@ -663,7 +634,7 @@ function SignInContent({
|
|
|
663
634
|
{
|
|
664
635
|
variant: "text",
|
|
665
636
|
component: "a",
|
|
666
|
-
href:
|
|
637
|
+
href: TERMS_OF_SERVICE_URL,
|
|
667
638
|
target: "_blank",
|
|
668
639
|
rel: "noopener noreferrer",
|
|
669
640
|
sx: {
|
|
@@ -689,7 +660,7 @@ function SignInContent({
|
|
|
689
660
|
{
|
|
690
661
|
variant: "text",
|
|
691
662
|
component: "a",
|
|
692
|
-
href:
|
|
663
|
+
href: PRIVACY_POLICY_URL,
|
|
693
664
|
target: "_blank",
|
|
694
665
|
rel: "noopener noreferrer",
|
|
695
666
|
sx: {
|
|
@@ -806,14 +777,14 @@ function SignInContent({
|
|
|
806
777
|
}
|
|
807
778
|
},
|
|
808
779
|
children: [
|
|
809
|
-
"By
|
|
780
|
+
"By continuing, you agree to our",
|
|
810
781
|
" ",
|
|
811
782
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
812
783
|
import_core_k2_components2.Button,
|
|
813
784
|
{
|
|
814
785
|
variant: "text",
|
|
815
786
|
component: "a",
|
|
816
|
-
href:
|
|
787
|
+
href: TERMS_OF_SERVICE_URL,
|
|
817
788
|
target: "_blank",
|
|
818
789
|
rel: "noopener noreferrer",
|
|
819
790
|
sx: {
|
|
@@ -828,7 +799,7 @@ function SignInContent({
|
|
|
828
799
|
backgroundColor: "transparent"
|
|
829
800
|
}
|
|
830
801
|
},
|
|
831
|
-
children: "Terms of
|
|
802
|
+
children: "Terms of Use"
|
|
832
803
|
}
|
|
833
804
|
),
|
|
834
805
|
" ",
|
|
@@ -839,7 +810,7 @@ function SignInContent({
|
|
|
839
810
|
{
|
|
840
811
|
variant: "text",
|
|
841
812
|
component: "a",
|
|
842
|
-
href:
|
|
813
|
+
href: PRIVACY_POLICY_URL,
|
|
843
814
|
target: "_blank",
|
|
844
815
|
rel: "noopener noreferrer",
|
|
845
816
|
sx: {
|
|
@@ -971,7 +942,7 @@ function SignInContent({
|
|
|
971
942
|
{
|
|
972
943
|
variant: "text",
|
|
973
944
|
component: "a",
|
|
974
|
-
href:
|
|
945
|
+
href: TERMS_OF_SERVICE_URL,
|
|
975
946
|
target: "_blank",
|
|
976
947
|
rel: "noopener noreferrer",
|
|
977
948
|
sx: {
|
|
@@ -997,7 +968,7 @@ function SignInContent({
|
|
|
997
968
|
{
|
|
998
969
|
variant: "text",
|
|
999
970
|
component: "a",
|
|
1000
|
-
href:
|
|
971
|
+
href: PRIVACY_POLICY_URL,
|
|
1001
972
|
target: "_blank",
|
|
1002
973
|
rel: "noopener noreferrer",
|
|
1003
974
|
sx: {
|
|
@@ -1038,14 +1009,8 @@ function LoginModal({ open, onClose }) {
|
|
|
1038
1009
|
if (!event.data || typeof event.data.type !== "string") {
|
|
1039
1010
|
return;
|
|
1040
1011
|
}
|
|
1041
|
-
console.log(
|
|
1042
|
-
"Modal received message from iframe:",
|
|
1043
|
-
event.data.type,
|
|
1044
|
-
event.data.payload ? "has payload" : "no payload"
|
|
1045
|
-
);
|
|
1046
1012
|
if (event.data.type === "ERROR") {
|
|
1047
1013
|
if (event.data.payload === "User not authenticated in iframe") {
|
|
1048
|
-
console.log("Ignoring transient auth error during signup process");
|
|
1049
1014
|
return;
|
|
1050
1015
|
}
|
|
1051
1016
|
setError(event.data.payload);
|
|
@@ -1056,7 +1021,6 @@ function LoginModal({ open, onClose }) {
|
|
|
1056
1021
|
timeoutIdRef.current = null;
|
|
1057
1022
|
}
|
|
1058
1023
|
} else if (event.data.type === "AUTH_STATUS" && event.data.isAuthenticated) {
|
|
1059
|
-
console.log("Auth successful, resetting state and closing modal");
|
|
1060
1024
|
setIsSubmitting(false);
|
|
1061
1025
|
signupInProgressRef.current = false;
|
|
1062
1026
|
requestInProgress = false;
|
|
@@ -1083,11 +1047,9 @@ function LoginModal({ open, onClose }) {
|
|
|
1083
1047
|
var _a2;
|
|
1084
1048
|
setError("");
|
|
1085
1049
|
if (!iframe) {
|
|
1086
|
-
console.error("Auth service iframe not found");
|
|
1087
1050
|
setError("Authentication service not available");
|
|
1088
1051
|
return;
|
|
1089
1052
|
}
|
|
1090
|
-
console.log(`Sending LOGIN_REQUEST to auth service iframe with ${provider} connection`);
|
|
1091
1053
|
(_a2 = iframe.contentWindow) == null ? void 0 : _a2.postMessage({
|
|
1092
1054
|
type: "LOGIN_REQUEST",
|
|
1093
1055
|
connection: provider,
|
|
@@ -1100,7 +1062,6 @@ function LoginModal({ open, onClose }) {
|
|
|
1100
1062
|
setError("");
|
|
1101
1063
|
setIsSubmitting(true);
|
|
1102
1064
|
if (!iframe) {
|
|
1103
|
-
console.error("Auth service iframe not found");
|
|
1104
1065
|
setError("Authentication service not available");
|
|
1105
1066
|
setIsSubmitting(false);
|
|
1106
1067
|
return;
|
|
@@ -1109,7 +1070,6 @@ function LoginModal({ open, onClose }) {
|
|
|
1109
1070
|
clearTimeout(timeoutIdRef.current);
|
|
1110
1071
|
timeoutIdRef.current = null;
|
|
1111
1072
|
}
|
|
1112
|
-
console.log("Sending email/password LOGIN_REQUEST to auth service iframe");
|
|
1113
1073
|
(_a2 = iframe.contentWindow) == null ? void 0 : _a2.postMessage({
|
|
1114
1074
|
type: "LOGIN_REQUEST",
|
|
1115
1075
|
email,
|
|
@@ -1117,7 +1077,6 @@ function LoginModal({ open, onClose }) {
|
|
|
1117
1077
|
requestId: `login-${Date.now()}`
|
|
1118
1078
|
}, "*");
|
|
1119
1079
|
timeoutIdRef.current = setTimeout(() => {
|
|
1120
|
-
console.log("No response received from auth service iframe");
|
|
1121
1080
|
setError("Authentication service timed out");
|
|
1122
1081
|
setIsSubmitting(false);
|
|
1123
1082
|
timeoutIdRef.current = null;
|
|
@@ -1125,12 +1084,10 @@ function LoginModal({ open, onClose }) {
|
|
|
1125
1084
|
};
|
|
1126
1085
|
const handleEmailSignup = (email, password) => {
|
|
1127
1086
|
if (signupInProgressRef.current) {
|
|
1128
|
-
console.log("Signup already in progress, ignoring duplicate request");
|
|
1129
1087
|
return;
|
|
1130
1088
|
}
|
|
1131
1089
|
const now = Date.now();
|
|
1132
1090
|
if (now - lastSignupAttemptRef.current < 2e3) {
|
|
1133
|
-
console.log("Ignoring duplicate signup attempt (debounce)");
|
|
1134
1091
|
return;
|
|
1135
1092
|
}
|
|
1136
1093
|
lastSignupAttemptRef.current = now;
|
|
@@ -1144,14 +1101,12 @@ function LoginModal({ open, onClose }) {
|
|
|
1144
1101
|
try {
|
|
1145
1102
|
signup(email, password);
|
|
1146
1103
|
} catch (error2) {
|
|
1147
|
-
console.error("Error initiating signup:", error2);
|
|
1148
1104
|
setError("Failed to initiate signup");
|
|
1149
1105
|
setIsSubmitting(false);
|
|
1150
1106
|
signupInProgressRef.current = false;
|
|
1151
1107
|
return;
|
|
1152
1108
|
}
|
|
1153
1109
|
timeoutIdRef.current = setTimeout(() => {
|
|
1154
|
-
console.log("No response received from auth service iframe");
|
|
1155
1110
|
setError("Authentication service timed out");
|
|
1156
1111
|
setIsSubmitting(false);
|
|
1157
1112
|
signupInProgressRef.current = false;
|
|
@@ -1646,7 +1601,7 @@ var queryClient = new import_react_query2.QueryClient({
|
|
|
1646
1601
|
}
|
|
1647
1602
|
});
|
|
1648
1603
|
function getCubistEnv(environment) {
|
|
1649
|
-
return environment === "
|
|
1604
|
+
return environment === "production" ? import_cubesigner_sdk.envs.prod : import_cubesigner_sdk.envs.gamma;
|
|
1650
1605
|
}
|
|
1651
1606
|
function ViemProviderWrapper({ children, chainId }) {
|
|
1652
1607
|
const { data: blockchain } = useBlockchain(chainId.toString());
|
|
@@ -1694,32 +1649,25 @@ function AvaCloudWalletProvider({
|
|
|
1694
1649
|
try {
|
|
1695
1650
|
const sessionKeys = await client.sessionKeys();
|
|
1696
1651
|
if (!sessionKeys.length) {
|
|
1697
|
-
console.log("[getWalletInfo] No session keys found");
|
|
1698
1652
|
return null;
|
|
1699
1653
|
}
|
|
1700
1654
|
const key = sessionKeys[0];
|
|
1701
1655
|
const address = key.materialId;
|
|
1702
1656
|
if (!(orgConfig == null ? void 0 : orgConfig.walletProviderOrgID)) {
|
|
1703
|
-
console.error("[getWalletInfo] Missing walletProviderOrgID in organization config");
|
|
1704
1657
|
throw new Error("Missing required walletProviderOrgID in organization configuration");
|
|
1705
1658
|
}
|
|
1706
|
-
console.log("[getWalletInfo] Returning wallet info with address:", address);
|
|
1707
1659
|
return {
|
|
1708
1660
|
address,
|
|
1709
1661
|
sessionId,
|
|
1710
1662
|
orgId: orgConfig.walletProviderOrgID
|
|
1711
1663
|
};
|
|
1712
1664
|
} catch (err) {
|
|
1713
|
-
console.error("[getWalletInfo] Error:", err);
|
|
1714
1665
|
setCubistError(err instanceof Error ? err : new Error("Failed to get wallet info"));
|
|
1715
1666
|
return null;
|
|
1716
1667
|
}
|
|
1717
1668
|
}, [orgConfig]);
|
|
1718
1669
|
const loginWithCubist = (0, import_react9.useCallback)(async (oidcToken) => {
|
|
1719
|
-
console.log("[loginWithCubist] Starting...");
|
|
1720
|
-
console.log("[loginWithCubist] Current orgConfig:", orgConfig);
|
|
1721
1670
|
if (!orgConfig || !orgConfig.walletProviderOrgID) {
|
|
1722
|
-
console.error("[loginWithCubist] PREVENTED: Missing walletProviderOrgID in organization config");
|
|
1723
1671
|
const error = new Error("Missing required walletProviderOrgID in organization configuration");
|
|
1724
1672
|
setCubistError(error);
|
|
1725
1673
|
onAuthError == null ? void 0 : onAuthError(error);
|
|
@@ -1730,15 +1678,12 @@ function AvaCloudWalletProvider({
|
|
|
1730
1678
|
setIsCubistLoading(true);
|
|
1731
1679
|
setCubistError(null);
|
|
1732
1680
|
if (!(orgConfig == null ? void 0 : orgConfig.walletProviderOrgID)) {
|
|
1733
|
-
console.error("[loginWithCubist] Missing walletProviderOrgID in organization config");
|
|
1734
1681
|
throw new Error("Missing required walletProviderOrgID in organization configuration");
|
|
1735
1682
|
}
|
|
1736
1683
|
let accessToken;
|
|
1737
1684
|
if (oidcToken) {
|
|
1738
|
-
console.log("[loginWithCubist] Using provided OIDC token.");
|
|
1739
1685
|
accessToken = oidcToken;
|
|
1740
1686
|
} else {
|
|
1741
|
-
console.log("[loginWithCubist] Attempting to get OIDC token from localStorage.");
|
|
1742
1687
|
const tokens = localStorage.getItem(AUTH_TOKENS_KEY);
|
|
1743
1688
|
if (!tokens) {
|
|
1744
1689
|
throw new Error("No authentication tokens found in localStorage");
|
|
@@ -1747,9 +1692,8 @@ function AvaCloudWalletProvider({
|
|
|
1747
1692
|
accessToken = parsed.access_token;
|
|
1748
1693
|
}
|
|
1749
1694
|
try {
|
|
1750
|
-
console.log(`[loginWithCubist] Attempting CubeSignerClient.createOidcSession for Org: ${orgConfig.walletProviderOrgID}`);
|
|
1751
1695
|
const resp = await import_cubesigner_sdk2.CubeSignerClient.createOidcSession(
|
|
1752
|
-
getCubistEnv(environment),
|
|
1696
|
+
getCubistEnv(environment === "production" ? "prod" : "gamma"),
|
|
1753
1697
|
orgConfig.walletProviderOrgID,
|
|
1754
1698
|
accessToken,
|
|
1755
1699
|
["sign:*", "manage:*", "export:*"],
|
|
@@ -1762,39 +1706,27 @@ function AvaCloudWalletProvider({
|
|
|
1762
1706
|
// 90 days
|
|
1763
1707
|
}
|
|
1764
1708
|
);
|
|
1765
|
-
console.log("[loginWithCubist] createOidcSession response received.");
|
|
1766
1709
|
if (resp.requiresMfa()) {
|
|
1767
|
-
console.warn("[loginWithCubist] MFA required, aborting.");
|
|
1768
1710
|
throw new Error("MFA required for Cubist login");
|
|
1769
1711
|
}
|
|
1770
1712
|
const sessionData = resp.data();
|
|
1771
|
-
console.log("[loginWithCubist] Session data obtained, attempting CubeSignerClient.create");
|
|
1772
1713
|
const newClient = await import_cubesigner_sdk2.CubeSignerClient.create(sessionData);
|
|
1773
1714
|
const sessionId = sessionData.session_info.session_id;
|
|
1774
|
-
console.log(`[loginWithCubist] CubeSignerClient created successfully. Session ID: ${sessionId}`);
|
|
1775
|
-
console.log("[loginWithCubist] Attempting getWalletInfo");
|
|
1776
1715
|
const cubistWallet = await getWalletInfo(newClient, sessionId);
|
|
1777
|
-
console.log("[loginWithCubist] getWalletInfo result:", cubistWallet);
|
|
1778
|
-
console.log("[loginWithCubist] Setting cubistClient state.");
|
|
1779
1716
|
setCubistClient(newClient);
|
|
1780
1717
|
if (cubistWallet) {
|
|
1781
|
-
console.log("[loginWithCubist] Setting wallet state with cubistWallet.");
|
|
1782
1718
|
setWallet((prev) => ({
|
|
1783
1719
|
...prev,
|
|
1784
1720
|
address: cubistWallet.address,
|
|
1785
1721
|
cubistWallet
|
|
1786
1722
|
}));
|
|
1787
|
-
console.log("[loginWithCubist] Calling onWalletUpdate callback.");
|
|
1788
1723
|
onWalletUpdate == null ? void 0 : onWalletUpdate({
|
|
1789
1724
|
...wallet,
|
|
1790
1725
|
// Use current wallet state potentially
|
|
1791
1726
|
cubistWallet
|
|
1792
1727
|
});
|
|
1793
|
-
} else {
|
|
1794
|
-
console.warn("[loginWithCubist] cubistWallet is null, not updating wallet state further.");
|
|
1795
1728
|
}
|
|
1796
1729
|
} catch (error) {
|
|
1797
|
-
console.error("[loginWithCubist] Error during Cubist session creation/wallet info:", error);
|
|
1798
1730
|
localStorage.removeItem(AUTH_TOKENS_KEY);
|
|
1799
1731
|
localStorage.removeItem(AUTH0_STORAGE_KEYS.IS_AUTHENTICATED);
|
|
1800
1732
|
setIsAuthenticated(false);
|
|
@@ -1804,11 +1736,9 @@ function AvaCloudWalletProvider({
|
|
|
1804
1736
|
}
|
|
1805
1737
|
} catch (error) {
|
|
1806
1738
|
const err = error instanceof Error ? error : new Error("Failed to create Cubist session");
|
|
1807
|
-
console.error("[loginWithCubist] Final catch block error:", err);
|
|
1808
1739
|
setCubistError(err);
|
|
1809
1740
|
onAuthError == null ? void 0 : onAuthError(err);
|
|
1810
1741
|
} finally {
|
|
1811
|
-
console.log("[loginWithCubist] Setting isCubistLoading to false.");
|
|
1812
1742
|
setIsCubistLoading(false);
|
|
1813
1743
|
}
|
|
1814
1744
|
}, [wallet, onWalletUpdate, onAuthError, getWalletInfo, orgConfig, environment]);
|
|
@@ -1819,62 +1749,46 @@ function AvaCloudWalletProvider({
|
|
|
1819
1749
|
iframe,
|
|
1820
1750
|
isIframeReady,
|
|
1821
1751
|
onAuthSuccess: () => {
|
|
1822
|
-
console.log("[onAuthSuccess] Called");
|
|
1823
1752
|
if (user) {
|
|
1824
1753
|
if (wallet.address) {
|
|
1825
|
-
console.log("[onAuthSuccess] Calling onAuthSuccess callback with user");
|
|
1826
1754
|
onAuthSuccess == null ? void 0 : onAuthSuccess(user);
|
|
1827
|
-
} else {
|
|
1828
|
-
console.log("[onAuthSuccess] Not calling callback yet, waiting for wallet");
|
|
1829
1755
|
}
|
|
1830
|
-
} else {
|
|
1831
|
-
console.log("[onAuthSuccess] No user available");
|
|
1832
1756
|
}
|
|
1833
1757
|
},
|
|
1834
1758
|
onAuthError: (error) => {
|
|
1835
|
-
console.log("[onAuthError] Called with error:", error);
|
|
1836
1759
|
const errorMessage = (error == null ? void 0 : error.message) || "";
|
|
1837
1760
|
if (errorMessage === "User not authenticated in iframe" || errorMessage === "Unknown error" || // Generic error that often appears during signup
|
|
1838
1761
|
errorMessage.includes("OIDC user not found")) {
|
|
1839
|
-
console.log("[onAuthError] Ignoring expected error during auth flow:", errorMessage);
|
|
1840
1762
|
return;
|
|
1841
1763
|
}
|
|
1842
1764
|
setIsCubistLoading(false);
|
|
1843
1765
|
onAuthError == null ? void 0 : onAuthError(error);
|
|
1844
1766
|
},
|
|
1845
1767
|
onWalletUpdate: (newWallet) => {
|
|
1846
|
-
console.log("[onWalletUpdate] Called with wallet:", newWallet);
|
|
1847
1768
|
setWallet(newWallet);
|
|
1848
1769
|
if (user && isAuthenticated) {
|
|
1849
|
-
console.log("[onWalletUpdate] Calling onAuthSuccess callback");
|
|
1850
1770
|
onAuthSuccess == null ? void 0 : onAuthSuccess(user);
|
|
1851
1771
|
}
|
|
1852
1772
|
queryClient.invalidateQueries({ queryKey: ["wallet"] });
|
|
1853
1773
|
onWalletUpdate == null ? void 0 : onWalletUpdate(newWallet);
|
|
1854
1774
|
},
|
|
1855
1775
|
onOidcReceived: (token) => {
|
|
1856
|
-
console.log("[onOidcReceived] Received OIDC token - storing in state only");
|
|
1857
1776
|
setIsCubistLoading(true);
|
|
1858
1777
|
setPendingOidcToken(token);
|
|
1859
|
-
console.log("[onOidcReceived] Current orgConfig:", orgConfig);
|
|
1860
1778
|
const originalLoginWithCubist = loginWithCubist;
|
|
1861
1779
|
window.___tempSafeguard_loginWithCubist = (oidcToken) => {
|
|
1862
1780
|
if (!(orgConfig == null ? void 0 : orgConfig.walletProviderOrgID)) {
|
|
1863
|
-
console.error("[SAFEGUARD] Prevented direct call to loginWithCubist without orgConfig");
|
|
1864
1781
|
return Promise.reject(new Error("Missing required walletProviderOrgID in organization configuration"));
|
|
1865
1782
|
}
|
|
1866
1783
|
return originalLoginWithCubist(oidcToken);
|
|
1867
1784
|
};
|
|
1868
1785
|
},
|
|
1869
1786
|
onOrgConfigUpdate: (config) => {
|
|
1870
|
-
console.log("[onOrgConfigUpdate] Received org config with walletProviderOrgID:", config == null ? void 0 : config.walletProviderOrgID);
|
|
1871
|
-
console.log("[onOrgConfigUpdate] Current pendingOidcToken:", !!pendingOidcToken);
|
|
1872
1787
|
setOrgConfig(config);
|
|
1873
1788
|
},
|
|
1874
1789
|
setIsAuthenticated,
|
|
1875
1790
|
setUser,
|
|
1876
1791
|
setIsLoading: (isLoading2) => {
|
|
1877
|
-
console.log("[setIsLoading] Setting isLoading to:", isLoading2);
|
|
1878
1792
|
setIsLoading(isLoading2);
|
|
1879
1793
|
},
|
|
1880
1794
|
setIsIframeReady,
|
|
@@ -1882,16 +1796,12 @@ function AvaCloudWalletProvider({
|
|
|
1882
1796
|
cubistClient
|
|
1883
1797
|
});
|
|
1884
1798
|
const login = (0, import_react9.useCallback)(() => {
|
|
1885
|
-
console.log("[login] Called");
|
|
1886
1799
|
if (iframe == null ? void 0 : iframe.contentWindow) {
|
|
1887
1800
|
setIsCubistLoading(true);
|
|
1888
1801
|
sendMessage({ type: "LOGIN_REQUEST" });
|
|
1889
|
-
} else {
|
|
1890
|
-
console.error("[login] No iframe available for login");
|
|
1891
1802
|
}
|
|
1892
1803
|
}, [iframe, sendMessage]);
|
|
1893
1804
|
const signup = (0, import_react9.useCallback)((email, password) => {
|
|
1894
|
-
console.log("[signup] Called with email:", email);
|
|
1895
1805
|
if (iframe == null ? void 0 : iframe.contentWindow) {
|
|
1896
1806
|
setIsCubistLoading(true);
|
|
1897
1807
|
sendMessage({
|
|
@@ -1902,12 +1812,9 @@ function AvaCloudWalletProvider({
|
|
|
1902
1812
|
},
|
|
1903
1813
|
requestId: `signup-${Date.now()}`
|
|
1904
1814
|
});
|
|
1905
|
-
} else {
|
|
1906
|
-
console.error("[signup] No iframe available for signup");
|
|
1907
1815
|
}
|
|
1908
1816
|
}, [iframe, sendMessage]);
|
|
1909
1817
|
const logout = (0, import_react9.useCallback)(() => {
|
|
1910
|
-
console.log("[logout] Called");
|
|
1911
1818
|
sendMessage({ type: "LOGOUT_REQUEST" });
|
|
1912
1819
|
setUser(null);
|
|
1913
1820
|
setWallet({ address: null });
|
|
@@ -1928,7 +1835,6 @@ function AvaCloudWalletProvider({
|
|
|
1928
1835
|
setPendingOidcToken(null);
|
|
1929
1836
|
}, [sendMessage, orgId, env]);
|
|
1930
1837
|
const addAccount = (0, import_react9.useCallback)(async (accountIndex) => {
|
|
1931
|
-
console.log("[addAccount] Called with accountIndex:", accountIndex);
|
|
1932
1838
|
if (!isAuthenticated || !user || !wallet.mnemonicId) {
|
|
1933
1839
|
throw new Error("User must be authenticated and have a wallet to add an account");
|
|
1934
1840
|
}
|
|
@@ -1949,19 +1855,13 @@ function AvaCloudWalletProvider({
|
|
|
1949
1855
|
});
|
|
1950
1856
|
}, [sendMessage, isAuthenticated, user, wallet.mnemonicId]);
|
|
1951
1857
|
(0, import_react9.useEffect)(() => {
|
|
1952
|
-
console.log("[useEffect Auth] Running effect with dependencies...");
|
|
1953
|
-
console.log("[useEffect Auth] pendingOidcToken:", !!pendingOidcToken);
|
|
1954
|
-
console.log("[useEffect Auth] orgConfig?.walletProviderOrgID:", orgConfig == null ? void 0 : orgConfig.walletProviderOrgID);
|
|
1955
1858
|
const hasOrgConfig = !!(orgConfig == null ? void 0 : orgConfig.walletProviderOrgID);
|
|
1956
1859
|
const hasOidcToken = !!pendingOidcToken;
|
|
1957
|
-
console.log(`[useEffect Auth] Checking conditions - hasOrgConfig: ${hasOrgConfig}, hasOidcToken: ${hasOidcToken}`);
|
|
1958
1860
|
if (hasOrgConfig && hasOidcToken && pendingOidcToken) {
|
|
1959
|
-
console.log("[useEffect Auth] Both orgConfig and oidcToken are available, calling loginWithCubist");
|
|
1960
1861
|
const doLogin = async () => {
|
|
1961
1862
|
try {
|
|
1962
1863
|
await loginWithCubist(pendingOidcToken);
|
|
1963
1864
|
} catch (error) {
|
|
1964
|
-
console.error("[useEffect Auth] Error in loginWithCubist:", error);
|
|
1965
1865
|
onAuthError == null ? void 0 : onAuthError(error instanceof Error ? error : new Error("Failed to create Cubist session"));
|
|
1966
1866
|
} finally {
|
|
1967
1867
|
setIsCubistLoading(false);
|
|
@@ -1972,7 +1872,6 @@ function AvaCloudWalletProvider({
|
|
|
1972
1872
|
}
|
|
1973
1873
|
}, [orgConfig, pendingOidcToken, loginWithCubist, onAuthError]);
|
|
1974
1874
|
(0, import_react9.useEffect)(() => {
|
|
1975
|
-
console.log("[useEffect Iframe] Setting up iframe...");
|
|
1976
1875
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
1977
1876
|
return;
|
|
1978
1877
|
}
|
|
@@ -1989,9 +1888,7 @@ function AvaCloudWalletProvider({
|
|
|
1989
1888
|
document.body.appendChild(frame);
|
|
1990
1889
|
iframeRef.current = frame;
|
|
1991
1890
|
setIframe(frame);
|
|
1992
|
-
console.log("[useEffect Iframe] Iframe created and added to DOM");
|
|
1993
1891
|
const timeoutId = setTimeout(() => {
|
|
1994
|
-
console.log("[useEffect Iframe] Timeout reached, setting isCubistLoading to false");
|
|
1995
1892
|
setIsCubistLoading(false);
|
|
1996
1893
|
}, 5e3);
|
|
1997
1894
|
return () => {
|
|
@@ -1999,7 +1896,6 @@ function AvaCloudWalletProvider({
|
|
|
1999
1896
|
if (iframeRef.current) {
|
|
2000
1897
|
iframeRef.current.remove();
|
|
2001
1898
|
iframeRef.current = null;
|
|
2002
|
-
console.log("[useEffect Iframe] Iframe removed in cleanup");
|
|
2003
1899
|
}
|
|
2004
1900
|
};
|
|
2005
1901
|
}, [authServiceUrl]);
|
|
@@ -2013,7 +1909,6 @@ function AvaCloudWalletProvider({
|
|
|
2013
1909
|
}
|
|
2014
1910
|
const existingOidcToken = sessionStorage.getItem(OIDC_TOKEN_KEY);
|
|
2015
1911
|
if (existingOidcToken) {
|
|
2016
|
-
console.log("[useEffect Init] Found existing OIDC token in sessionStorage");
|
|
2017
1912
|
setPendingOidcToken(existingOidcToken);
|
|
2018
1913
|
} else {
|
|
2019
1914
|
try {
|
|
@@ -2021,13 +1916,11 @@ function AvaCloudWalletProvider({
|
|
|
2021
1916
|
if (tokensJson) {
|
|
2022
1917
|
const tokens = JSON.parse(tokensJson);
|
|
2023
1918
|
if (tokens.access_token) {
|
|
2024
|
-
console.log("[useEffect Init] Using access_token from localStorage as OIDC token");
|
|
2025
1919
|
sessionStorage.setItem(OIDC_TOKEN_KEY, tokens.access_token);
|
|
2026
1920
|
setPendingOidcToken(tokens.access_token);
|
|
2027
1921
|
}
|
|
2028
1922
|
}
|
|
2029
1923
|
} catch (error) {
|
|
2030
|
-
console.error("[useEffect Init] Error parsing tokens from localStorage:", error);
|
|
2031
1924
|
}
|
|
2032
1925
|
}
|
|
2033
1926
|
}, []);
|
|
@@ -2212,7 +2105,6 @@ function useTransferTokens() {
|
|
|
2212
2105
|
const actualBaseFee = (0, import_viem2.formatEther)(baseFeePerGas * receipt.gasUsed);
|
|
2213
2106
|
const actualPriorityFee = (0, import_viem2.formatEther)(effectivePriorityFee * receipt.gasUsed);
|
|
2214
2107
|
const actualTotalFee = (0, import_viem2.formatEther)(receipt.effectiveGasPrice * receipt.gasUsed);
|
|
2215
|
-
console.log("Transaction confirmed:", receipt);
|
|
2216
2108
|
if ((wallet == null ? void 0 : wallet.address) && ((_a = publicClient.chain) == null ? void 0 : _a.id)) {
|
|
2217
2109
|
const chainId = publicClient.chain.id.toString();
|
|
2218
2110
|
queryClient2.invalidateQueries({
|
|
@@ -2227,7 +2119,6 @@ function useTransferTokens() {
|
|
|
2227
2119
|
actualTotalFee: Number(actualTotalFee).toFixed(6)
|
|
2228
2120
|
}));
|
|
2229
2121
|
} catch (err) {
|
|
2230
|
-
console.error("Failed to send transaction:", err);
|
|
2231
2122
|
setState((prev) => ({
|
|
2232
2123
|
...prev,
|
|
2233
2124
|
error: err instanceof Error ? err.message : "Failed to send transaction",
|
|
@@ -2305,7 +2196,6 @@ function useTransferTokens() {
|
|
|
2305
2196
|
const actualBaseFee = (0, import_viem2.formatEther)(baseFeePerGas * receipt.gasUsed);
|
|
2306
2197
|
const actualPriorityFee = (0, import_viem2.formatEther)(effectivePriorityFee * receipt.gasUsed);
|
|
2307
2198
|
const actualTotalFee = (0, import_viem2.formatEther)(receipt.effectiveGasPrice * receipt.gasUsed);
|
|
2308
|
-
console.log("Transaction confirmed:", receipt);
|
|
2309
2199
|
if ((wallet == null ? void 0 : wallet.address) && ((_a = publicClient.chain) == null ? void 0 : _a.id)) {
|
|
2310
2200
|
const chainId = publicClient.chain.id.toString();
|
|
2311
2201
|
queryClient2.invalidateQueries({
|
|
@@ -2323,7 +2213,6 @@ function useTransferTokens() {
|
|
|
2323
2213
|
actualTotalFee: Number(actualTotalFee).toFixed(6)
|
|
2324
2214
|
}));
|
|
2325
2215
|
} catch (err) {
|
|
2326
|
-
console.error("Failed to send transaction:", err);
|
|
2327
2216
|
setState((prev) => ({
|
|
2328
2217
|
...prev,
|
|
2329
2218
|
error: err instanceof Error ? err.message : "Failed to send transaction",
|
|
@@ -2413,7 +2302,6 @@ function useGasEstimation() {
|
|
|
2413
2302
|
totalWithAmount
|
|
2414
2303
|
}));
|
|
2415
2304
|
} catch (err) {
|
|
2416
|
-
console.error("Failed to estimate gas:", err);
|
|
2417
2305
|
setState((prev) => ({
|
|
2418
2306
|
...prev,
|
|
2419
2307
|
error: err instanceof Error ? err.message : "Failed to estimate gas",
|
|
@@ -3387,7 +3275,6 @@ function ExportView({ onBack }) {
|
|
|
3387
3275
|
};
|
|
3388
3276
|
window.addEventListener("message", handleResponse);
|
|
3389
3277
|
} catch (err) {
|
|
3390
|
-
console.error("Export failed:", err);
|
|
3391
3278
|
setError("Failed to export private key. Please try again.");
|
|
3392
3279
|
}
|
|
3393
3280
|
};
|
|
@@ -4540,12 +4427,6 @@ function useSignTransaction() {
|
|
|
4540
4427
|
}, []);
|
|
4541
4428
|
const signTransaction = (0, import_react25.useCallback)(async (transaction) => {
|
|
4542
4429
|
var _a, _b, _c, _d;
|
|
4543
|
-
console.log("Signing transaction with:", {
|
|
4544
|
-
wallet: wallet == null ? void 0 : wallet.address,
|
|
4545
|
-
hasClient: !!cubistClient,
|
|
4546
|
-
hasPublicClient: !!publicClient,
|
|
4547
|
-
chain: publicClient == null ? void 0 : publicClient.chain
|
|
4548
|
-
});
|
|
4549
4430
|
if (!(wallet == null ? void 0 : wallet.address)) {
|
|
4550
4431
|
setState((prev) => ({
|
|
4551
4432
|
...prev,
|
|
@@ -4590,7 +4471,6 @@ function useSignTransaction() {
|
|
|
4590
4471
|
maxPriorityFeePerGas: (_d = transaction.maxPriorityFeePerGas) == null ? void 0 : _d.toString()
|
|
4591
4472
|
}
|
|
4592
4473
|
};
|
|
4593
|
-
console.log("Signing request:", signReq);
|
|
4594
4474
|
const sig = await key.signEvm(signReq);
|
|
4595
4475
|
const signedTx = sig.data().rlp_signed_tx;
|
|
4596
4476
|
setState((prev) => ({
|
|
@@ -4598,7 +4478,6 @@ function useSignTransaction() {
|
|
|
4598
4478
|
signedTransaction: signedTx
|
|
4599
4479
|
}));
|
|
4600
4480
|
} catch (err) {
|
|
4601
|
-
console.error("Error signing transaction:", err);
|
|
4602
4481
|
setState((prev) => ({
|
|
4603
4482
|
...prev,
|
|
4604
4483
|
error: err instanceof Error ? err.message : "Failed to sign transaction"
|
|
@@ -4646,6 +4525,68 @@ function useUserWallets() {
|
|
|
4646
4525
|
isLoading
|
|
4647
4526
|
};
|
|
4648
4527
|
}
|
|
4528
|
+
|
|
4529
|
+
// src/wagmi/connector.ts
|
|
4530
|
+
var import_core = require("@wagmi/core");
|
|
4531
|
+
var import_viem5 = require("viem");
|
|
4532
|
+
function avaCloudWallet() {
|
|
4533
|
+
return (0, import_core.createConnector)((config) => ({
|
|
4534
|
+
id: "avaCloudWallet",
|
|
4535
|
+
name: "AvaCloud Wallet",
|
|
4536
|
+
type: "injected",
|
|
4537
|
+
async connect() {
|
|
4538
|
+
const { walletClient } = useViem();
|
|
4539
|
+
if (!walletClient) {
|
|
4540
|
+
throw new Error("AvaCloud Wallet not connected");
|
|
4541
|
+
}
|
|
4542
|
+
const accounts = await this.getAccounts();
|
|
4543
|
+
const chainId = await this.getChainId();
|
|
4544
|
+
config.emitter.emit("connect", { accounts, chainId });
|
|
4545
|
+
return { accounts, chainId };
|
|
4546
|
+
},
|
|
4547
|
+
async disconnect() {
|
|
4548
|
+
config.emitter.emit("disconnect");
|
|
4549
|
+
},
|
|
4550
|
+
async getAccounts() {
|
|
4551
|
+
const { walletClient } = useViem();
|
|
4552
|
+
if (!(walletClient == null ? void 0 : walletClient.account)) {
|
|
4553
|
+
throw new Error("AvaCloud Wallet not connected or account not found.");
|
|
4554
|
+
}
|
|
4555
|
+
return [walletClient.account.address];
|
|
4556
|
+
},
|
|
4557
|
+
async getChainId() {
|
|
4558
|
+
const { chainId } = useViem();
|
|
4559
|
+
return chainId;
|
|
4560
|
+
},
|
|
4561
|
+
async getProvider() {
|
|
4562
|
+
const { publicClient } = useViem();
|
|
4563
|
+
if (!publicClient) {
|
|
4564
|
+
throw new Error("Public client not found.");
|
|
4565
|
+
}
|
|
4566
|
+
return publicClient;
|
|
4567
|
+
},
|
|
4568
|
+
async isAuthorized() {
|
|
4569
|
+
const { walletClient } = useViem();
|
|
4570
|
+
return !!walletClient;
|
|
4571
|
+
},
|
|
4572
|
+
onAccountsChanged(accounts) {
|
|
4573
|
+
if (accounts.length === 0) {
|
|
4574
|
+
this.disconnect();
|
|
4575
|
+
} else {
|
|
4576
|
+
config.emitter.emit("change", {
|
|
4577
|
+
accounts: accounts.map((x) => (0, import_viem5.getAddress)(x))
|
|
4578
|
+
});
|
|
4579
|
+
}
|
|
4580
|
+
},
|
|
4581
|
+
onChainChanged(chain) {
|
|
4582
|
+
const chainId = Number(chain);
|
|
4583
|
+
config.emitter.emit("change", { chainId });
|
|
4584
|
+
},
|
|
4585
|
+
onDisconnect() {
|
|
4586
|
+
config.emitter.emit("disconnect");
|
|
4587
|
+
}
|
|
4588
|
+
}));
|
|
4589
|
+
}
|
|
4649
4590
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4650
4591
|
0 && (module.exports = {
|
|
4651
4592
|
AvaCloudWalletProvider,
|
|
@@ -4660,6 +4601,7 @@ function useUserWallets() {
|
|
|
4660
4601
|
WalletButton,
|
|
4661
4602
|
WalletCard,
|
|
4662
4603
|
WalletDisplay,
|
|
4604
|
+
avaCloudWallet,
|
|
4663
4605
|
useAuth,
|
|
4664
4606
|
useAvaCloudWallet,
|
|
4665
4607
|
useChainId,
|