@b3dotfun/sdk 0.0.33-alpha.4 → 0.0.33-alpha.5
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/cjs/global-account/react/components/LinkAccount/LinkAccount.js +7 -8
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +17 -1
- package/dist/esm/global-account/react/components/LinkAccount/LinkAccount.js +4 -8
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +17 -1
- package/package.json +2 -2
- package/src/global-account/react/components/LinkAccount/LinkAccount.tsx +4 -8
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +17 -1
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.LinkAccount = LinkAccount;
|
|
4
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
@@ -9,11 +12,11 @@ const react_1 = require("react");
|
|
|
9
12
|
const sonner_1 = require("sonner");
|
|
10
13
|
const react_2 = require("thirdweb/react");
|
|
11
14
|
const wallets_1 = require("thirdweb/wallets");
|
|
12
|
-
const useSiwe_1 = require("../../hooks/useSiwe");
|
|
13
15
|
const useModalStore_1 = require("../../stores/useModalStore");
|
|
14
16
|
const profileDisplay_1 = require("../../utils/profileDisplay");
|
|
15
17
|
const useB3_1 = require("../B3Provider/useB3");
|
|
16
18
|
const button_1 = require("../ui/button");
|
|
19
|
+
const app_1 = __importDefault(require("../../../../global-account/app"));
|
|
17
20
|
const AUTH_METHODS = [
|
|
18
21
|
{ id: "email", label: "Email", enabled: true },
|
|
19
22
|
{ id: "phone", label: "Phone", enabled: true },
|
|
@@ -44,9 +47,8 @@ function LinkAccount({ onSuccess: onSuccessCallback, onError, onClose, chain, pa
|
|
|
44
47
|
...(0, profileDisplay_1.getProfileDisplayInfo)(profile),
|
|
45
48
|
originalProfile: profile,
|
|
46
49
|
}));
|
|
47
|
-
const { account
|
|
50
|
+
const { account } = (0, useB3_1.useB3)();
|
|
48
51
|
const { mutate: linkProfile } = (0, react_2.useLinkProfile)();
|
|
49
|
-
const { authenticate } = (0, useSiwe_1.useSiwe)();
|
|
50
52
|
const onSuccess = (0, react_1.useCallback)(async () => {
|
|
51
53
|
await onSuccessCallback?.();
|
|
52
54
|
}, [onSuccessCallback]);
|
|
@@ -68,11 +70,8 @@ function LinkAccount({ onSuccess: onSuccessCallback, onError, onClose, chain, pa
|
|
|
68
70
|
onSuccess: async (data) => {
|
|
69
71
|
console.log("Raw Link Account Data:", data);
|
|
70
72
|
try {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const userAuth = await authenticate(account, partnerId);
|
|
74
|
-
setUser(userAuth.user);
|
|
75
|
-
}
|
|
73
|
+
console.log("Sync user data...");
|
|
74
|
+
await app_1.default.service("users").syncTwProfiles({});
|
|
76
75
|
}
|
|
77
76
|
catch (refreshError) {
|
|
78
77
|
console.warn("⚠️ Could not sync user data:", refreshError);
|
|
@@ -66,6 +66,22 @@ function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit, chain
|
|
|
66
66
|
const [isEditingCode, setIsEditingCode] = (0, react_2.useState)(false);
|
|
67
67
|
const referallCodeRef = (0, react_2.useRef)(null);
|
|
68
68
|
const { data: referrals, isLoading: isLoadingReferrals } = (0, react_1.useQueryB3)("referrals", "find", { query: { referrerId: user?.userId } }, !!user?.userId);
|
|
69
|
+
const mutationOptions = {
|
|
70
|
+
onError: (error) => {
|
|
71
|
+
console.error("Error Unlinking account:", error);
|
|
72
|
+
sonner_1.toast.error(error.message);
|
|
73
|
+
},
|
|
74
|
+
onSuccess: async (data) => {
|
|
75
|
+
console.log("Raw Link Account Data:", data);
|
|
76
|
+
try {
|
|
77
|
+
console.log("Sync user data...");
|
|
78
|
+
await app_1.default.service("users").syncTwProfiles({});
|
|
79
|
+
}
|
|
80
|
+
catch (refreshError) {
|
|
81
|
+
console.warn("⚠️ Could not sync user data:", refreshError);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
};
|
|
69
85
|
// Fetch referred users
|
|
70
86
|
const currentReferralCode = user?.referralCode || user?.userId || "";
|
|
71
87
|
const handleCopyCode = async () => {
|
|
@@ -108,7 +124,7 @@ function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit, chain
|
|
|
108
124
|
const handleUnlink = async (profile) => {
|
|
109
125
|
setUnlinkingAccountId(profile.title);
|
|
110
126
|
try {
|
|
111
|
-
unlinkProfile({ client: thirdweb_1.client, profileToUnlink: profile.originalProfile });
|
|
127
|
+
unlinkProfile({ client: thirdweb_1.client, profileToUnlink: profile.originalProfile }, mutationOptions);
|
|
112
128
|
}
|
|
113
129
|
catch (error) {
|
|
114
130
|
console.error("Error unlinking account:", error);
|
|
@@ -6,11 +6,11 @@ import { useCallback, useEffect, useState } from "react";
|
|
|
6
6
|
import { toast } from "sonner";
|
|
7
7
|
import { useLinkProfile, useProfiles } from "thirdweb/react";
|
|
8
8
|
import { preAuthenticate } from "thirdweb/wallets";
|
|
9
|
-
import { useSiwe } from "../../hooks/useSiwe.js";
|
|
10
9
|
import { useModalStore } from "../../stores/useModalStore.js";
|
|
11
10
|
import { getProfileDisplayInfo } from "../../utils/profileDisplay.js";
|
|
12
11
|
import { useB3 } from "../B3Provider/useB3.js";
|
|
13
12
|
import { Button } from "../ui/button.js";
|
|
13
|
+
import app from "../../../../global-account/app.js";
|
|
14
14
|
const AUTH_METHODS = [
|
|
15
15
|
{ id: "email", label: "Email", enabled: true },
|
|
16
16
|
{ id: "phone", label: "Phone", enabled: true },
|
|
@@ -41,9 +41,8 @@ export function LinkAccount({ onSuccess: onSuccessCallback, onError, onClose, ch
|
|
|
41
41
|
...getProfileDisplayInfo(profile),
|
|
42
42
|
originalProfile: profile,
|
|
43
43
|
}));
|
|
44
|
-
const { account
|
|
44
|
+
const { account } = useB3();
|
|
45
45
|
const { mutate: linkProfile } = useLinkProfile();
|
|
46
|
-
const { authenticate } = useSiwe();
|
|
47
46
|
const onSuccess = useCallback(async () => {
|
|
48
47
|
await onSuccessCallback?.();
|
|
49
48
|
}, [onSuccessCallback]);
|
|
@@ -65,11 +64,8 @@ export function LinkAccount({ onSuccess: onSuccessCallback, onError, onClose, ch
|
|
|
65
64
|
onSuccess: async (data) => {
|
|
66
65
|
console.log("Raw Link Account Data:", data);
|
|
67
66
|
try {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const userAuth = await authenticate(account, partnerId);
|
|
71
|
-
setUser(userAuth.user);
|
|
72
|
-
}
|
|
67
|
+
console.log("Sync user data...");
|
|
68
|
+
await app.service("users").syncTwProfiles({});
|
|
73
69
|
}
|
|
74
70
|
catch (refreshError) {
|
|
75
71
|
console.warn("⚠️ Could not sync user data:", refreshError);
|
|
@@ -60,6 +60,22 @@ export function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit
|
|
|
60
60
|
const [isEditingCode, setIsEditingCode] = useState(false);
|
|
61
61
|
const referallCodeRef = useRef(null);
|
|
62
62
|
const { data: referrals, isLoading: isLoadingReferrals } = useQueryB3("referrals", "find", { query: { referrerId: user?.userId } }, !!user?.userId);
|
|
63
|
+
const mutationOptions = {
|
|
64
|
+
onError: (error) => {
|
|
65
|
+
console.error("Error Unlinking account:", error);
|
|
66
|
+
toast.error(error.message);
|
|
67
|
+
},
|
|
68
|
+
onSuccess: async (data) => {
|
|
69
|
+
console.log("Raw Link Account Data:", data);
|
|
70
|
+
try {
|
|
71
|
+
console.log("Sync user data...");
|
|
72
|
+
await app.service("users").syncTwProfiles({});
|
|
73
|
+
}
|
|
74
|
+
catch (refreshError) {
|
|
75
|
+
console.warn("⚠️ Could not sync user data:", refreshError);
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
};
|
|
63
79
|
// Fetch referred users
|
|
64
80
|
const currentReferralCode = user?.referralCode || user?.userId || "";
|
|
65
81
|
const handleCopyCode = async () => {
|
|
@@ -102,7 +118,7 @@ export function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit
|
|
|
102
118
|
const handleUnlink = async (profile) => {
|
|
103
119
|
setUnlinkingAccountId(profile.title);
|
|
104
120
|
try {
|
|
105
|
-
unlinkProfile({ client, profileToUnlink: profile.originalProfile });
|
|
121
|
+
unlinkProfile({ client, profileToUnlink: profile.originalProfile }, mutationOptions);
|
|
106
122
|
}
|
|
107
123
|
catch (error) {
|
|
108
124
|
console.error("Error unlinking account:", error);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@b3dotfun/sdk",
|
|
3
|
-
"version": "0.0.33-alpha.
|
|
3
|
+
"version": "0.0.33-alpha.5",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"react-native": "./dist/cjs/index.native.js",
|
|
@@ -237,7 +237,7 @@
|
|
|
237
237
|
"constants"
|
|
238
238
|
],
|
|
239
239
|
"dependencies": {
|
|
240
|
-
"@b3dotfun/b3-api": "0.0.
|
|
240
|
+
"@b3dotfun/b3-api": "0.0.47",
|
|
241
241
|
"@b3dotfun/basement-api": "0.0.11",
|
|
242
242
|
"@feathersjs/authentication-client": "5.0.33",
|
|
243
243
|
"@feathersjs/feathers": "5.0.33",
|
|
@@ -5,11 +5,11 @@ import { useCallback, useEffect, useState } from "react";
|
|
|
5
5
|
import { toast } from "sonner";
|
|
6
6
|
import { useLinkProfile, useProfiles } from "thirdweb/react";
|
|
7
7
|
import { preAuthenticate } from "thirdweb/wallets";
|
|
8
|
-
import { useSiwe } from "../../hooks/useSiwe";
|
|
9
8
|
import { LinkAccountModalProps, useModalStore } from "../../stores/useModalStore";
|
|
10
9
|
import { getProfileDisplayInfo } from "../../utils/profileDisplay";
|
|
11
10
|
import { useB3 } from "../B3Provider/useB3";
|
|
12
11
|
import { Button } from "../ui/button";
|
|
12
|
+
import app from "@b3dotfun/sdk/global-account/app";
|
|
13
13
|
type OTPStrategy = "email" | "phone";
|
|
14
14
|
type SocialStrategy = "google" | "x" | "discord" | "apple" | "farcaster";
|
|
15
15
|
type Strategy = OTPStrategy | SocialStrategy;
|
|
@@ -64,9 +64,8 @@ export function LinkAccount({
|
|
|
64
64
|
originalProfile: profile,
|
|
65
65
|
}));
|
|
66
66
|
|
|
67
|
-
const { account
|
|
67
|
+
const { account } = useB3();
|
|
68
68
|
const { mutate: linkProfile } = useLinkProfile();
|
|
69
|
-
const { authenticate } = useSiwe();
|
|
70
69
|
|
|
71
70
|
const onSuccess = useCallback(async () => {
|
|
72
71
|
await onSuccessCallback?.();
|
|
@@ -91,11 +90,8 @@ export function LinkAccount({
|
|
|
91
90
|
onSuccess: async (data: any) => {
|
|
92
91
|
console.log("Raw Link Account Data:", data);
|
|
93
92
|
try {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const userAuth = await authenticate(account, partnerId);
|
|
97
|
-
setUser(userAuth.user);
|
|
98
|
-
}
|
|
93
|
+
console.log("Sync user data...");
|
|
94
|
+
await app.service("users").syncTwProfiles({});
|
|
99
95
|
} catch (refreshError) {
|
|
100
96
|
console.warn("⚠️ Could not sync user data:", refreshError);
|
|
101
97
|
}
|
|
@@ -146,6 +146,22 @@ export function ManageAccount({
|
|
|
146
146
|
!!user?.userId,
|
|
147
147
|
);
|
|
148
148
|
|
|
149
|
+
const mutationOptions = {
|
|
150
|
+
onError: (error: Error) => {
|
|
151
|
+
console.error("Error Unlinking account:", error);
|
|
152
|
+
toast.error(error.message);
|
|
153
|
+
},
|
|
154
|
+
onSuccess: async (data: any) => {
|
|
155
|
+
console.log("Raw Link Account Data:", data);
|
|
156
|
+
try {
|
|
157
|
+
console.log("Sync user data...");
|
|
158
|
+
await app.service("users").syncTwProfiles({});
|
|
159
|
+
} catch (refreshError) {
|
|
160
|
+
console.warn("⚠️ Could not sync user data:", refreshError);
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
|
|
149
165
|
// Fetch referred users
|
|
150
166
|
const currentReferralCode = user?.referralCode || user?.userId || "";
|
|
151
167
|
|
|
@@ -189,7 +205,7 @@ export function ManageAccount({
|
|
|
189
205
|
const handleUnlink = async (profile: any) => {
|
|
190
206
|
setUnlinkingAccountId(profile.title);
|
|
191
207
|
try {
|
|
192
|
-
unlinkProfile({ client, profileToUnlink: profile.originalProfile });
|
|
208
|
+
unlinkProfile({ client, profileToUnlink: profile.originalProfile }, mutationOptions);
|
|
193
209
|
} catch (error) {
|
|
194
210
|
console.error("Error unlinking account:", error);
|
|
195
211
|
} finally {
|