@b3dotfun/sdk 0.0.19 → 0.0.20-alpha.0
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/anyspend/react/components/AnySpend.js +0 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +0 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnrampPayment.js +0 -1
- package/dist/cjs/anyspend/react/components/webview/WebviewOnrampPayment.js +0 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +0 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +0 -4
- package/dist/cjs/anyspend/react/hooks/useGeoOnrampOptions.js +1 -1
- package/dist/cjs/anyspend/react/hooks/useStripeSupport.d.ts +1 -1
- package/dist/cjs/anyspend/react/hooks/useStripeSupport.js +4 -4
- package/dist/cjs/anyspend/services/anyspend.d.ts +1 -1
- package/dist/cjs/anyspend/services/anyspend.js +1 -2
- package/dist/cjs/anyspend/types/api.d.ts +1 -16
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3.js +2 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +18 -11
- package/dist/cjs/global-account/react/components/custom/ManageAccountButton.js +2 -2
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +2 -0
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +12 -1
- package/dist/cjs/global-account/react/stores/useAuthStore.d.ts +4 -0
- package/dist/cjs/global-account/react/stores/useAuthStore.js +4 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +0 -1
- package/dist/esm/anyspend/react/components/common/PanelOnrampPayment.js +0 -1
- package/dist/esm/anyspend/react/components/webview/WebviewOnrampPayment.js +0 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +0 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +0 -4
- package/dist/esm/anyspend/react/hooks/useGeoOnrampOptions.js +1 -1
- package/dist/esm/anyspend/react/hooks/useStripeSupport.d.ts +1 -1
- package/dist/esm/anyspend/react/hooks/useStripeSupport.js +4 -4
- package/dist/esm/anyspend/services/anyspend.d.ts +1 -1
- package/dist/esm/anyspend/services/anyspend.js +1 -2
- package/dist/esm/anyspend/types/api.d.ts +1 -16
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +19 -12
- package/dist/esm/global-account/react/components/custom/ManageAccountButton.js +2 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +2 -0
- package/dist/esm/global-account/react/hooks/useAuthentication.js +12 -1
- package/dist/esm/global-account/react/stores/useAuthStore.d.ts +4 -0
- package/dist/esm/global-account/react/stores/useAuthStore.js +4 -0
- package/dist/types/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +0 -1
- package/dist/types/anyspend/react/hooks/useStripeSupport.d.ts +1 -1
- package/dist/types/anyspend/services/anyspend.d.ts +1 -1
- package/dist/types/anyspend/types/api.d.ts +1 -16
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +2 -0
- package/dist/types/global-account/react/stores/useAuthStore.d.ts +4 -0
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +0 -1
- package/src/anyspend/react/components/AnySpendCustom.tsx +0 -1
- package/src/anyspend/react/components/common/PanelOnrampPayment.tsx +0 -1
- package/src/anyspend/react/components/webview/WebviewOnrampPayment.tsx +0 -1
- package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +0 -6
- package/src/anyspend/react/hooks/useGeoOnrampOptions.ts +0 -1
- package/src/anyspend/react/hooks/useStripeSupport.ts +3 -4
- package/src/anyspend/services/anyspend.ts +0 -2
- package/src/anyspend/types/api.ts +1 -16
- package/src/global-account/react/components/SignInWithB3/SignInWithB3.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +19 -11
- package/src/global-account/react/components/custom/ManageAccountButton.tsx +2 -2
- package/src/global-account/react/hooks/useAuthentication.ts +12 -1
- package/src/global-account/react/stores/useAuthStore.ts +8 -0
|
@@ -725,7 +725,6 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
725
725
|
vendor: vendor,
|
|
726
726
|
paymentMethod: paymentMethodString,
|
|
727
727
|
country: geoData?.country || "US",
|
|
728
|
-
ipAddress: geoData?.ip,
|
|
729
728
|
redirectUrl: window.location.origin === "https://basement.fun" ? "https://basement.fun/deposit" : window.location.origin,
|
|
730
729
|
},
|
|
731
730
|
expectedDstAmount: anyspendQuote?.data?.currencyOut?.amount?.toString() || "0",
|
|
@@ -306,7 +306,6 @@ function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", recipient
|
|
|
306
306
|
vendor: onramp.vendor,
|
|
307
307
|
paymentMethod: onramp.paymentMethod,
|
|
308
308
|
country: geoData?.country || "US",
|
|
309
|
-
ipAddress: geoData?.ip,
|
|
310
309
|
redirectUrl: window.location.origin === "https://basement.fun"
|
|
311
310
|
? "https://basement.fun/deposit"
|
|
312
311
|
: window.location.origin,
|
|
@@ -79,7 +79,6 @@ function PanelOnrampPaymentInner(props) {
|
|
|
79
79
|
vendor: vendor,
|
|
80
80
|
paymentMethod: paymentMethod || "",
|
|
81
81
|
country: geoData?.country || "US",
|
|
82
|
-
ipAddress: geoData?.ip,
|
|
83
82
|
redirectUrl: window.location.origin === "https://basement.fun" ? "https://basement.fun/deposit" : window.location.origin,
|
|
84
83
|
},
|
|
85
84
|
expectedDstAmount: anyspendQuote?.data?.currencyOut?.amount?.toString() || "0",
|
|
@@ -134,7 +134,6 @@ function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinat
|
|
|
134
134
|
vendor: "stripe-web2",
|
|
135
135
|
paymentMethod: "",
|
|
136
136
|
country: geoData.country || "US",
|
|
137
|
-
ipAddress: geoData.ip,
|
|
138
137
|
redirectUrl: `${window.location.origin}${userId ? `?userId=${userId}` : ""}`,
|
|
139
138
|
},
|
|
140
139
|
expectedDstAmount: anyspendQuote.data?.currencyOut?.amount?.toString() || "0",
|
|
@@ -24,10 +24,6 @@ function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
|
24
24
|
mutationFn: async (params) => {
|
|
25
25
|
const { isMainnet, recipientAddress, orderType, dstChain, dstToken, srcFiatAmount, onramp, creatorAddress, expectedDstAmount, nft, tournament, payload, partnerId, } = params;
|
|
26
26
|
try {
|
|
27
|
-
// Validate Stripe onramp options
|
|
28
|
-
if (onramp.vendor === "stripe" && !onramp.ipAddress) {
|
|
29
|
-
throw new Error("IP address is required for Stripe onramp");
|
|
30
|
-
}
|
|
31
27
|
// Validate required onramp fields
|
|
32
28
|
if (!onramp.vendor || !onramp.country) {
|
|
33
29
|
throw new Error("Missing required onramp fields: vendor, country");
|
|
@@ -16,7 +16,7 @@ function useGeoOnrampOptions(isMainnet, srcFiatAmount) {
|
|
|
16
16
|
// Use existing hooks
|
|
17
17
|
const { geoData, loading: isLoadingGeo, error: geoError } = (0, useGetGeo_1.useGetGeo)();
|
|
18
18
|
const { coinbaseOnrampOptions, isLoadingCoinbaseOnrampOptions, coinbaseOnrampOptionsError } = (0, useCoinbaseOnrampOptions_1.useCoinbaseOnrampOptions)(isMainnet, geoData?.country, visitorData);
|
|
19
|
-
const { isStripeOnrampSupported, stripeWeb2Support, isLoadingStripeSupport, stripeSupportError } = (0, useStripeSupport_1.useStripeSupport)(isMainnet,
|
|
19
|
+
const { isStripeOnrampSupported, stripeWeb2Support, isLoadingStripeSupport, stripeSupportError } = (0, useStripeSupport_1.useStripeSupport)(isMainnet, srcFiatAmount, visitorData);
|
|
20
20
|
// Calculate available payment methods based on the amount
|
|
21
21
|
const coinbaseAvailablePaymentMethods = (0, react_1.useMemo)(() => {
|
|
22
22
|
if (!coinbaseOnrampOptions?.paymentCurrencies?.[0]?.limits || !srcFiatAmount)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VisitorData } from "../../../anyspend/types/fingerprint";
|
|
2
|
-
export declare function useStripeSupport(isMainnet: boolean,
|
|
2
|
+
export declare function useStripeSupport(isMainnet: boolean, usdAmount?: string, visitorData?: VisitorData, isLoadingVisitorData?: boolean): {
|
|
3
3
|
isStripeOnrampSupported: boolean;
|
|
4
4
|
stripeWeb2Support: {
|
|
5
5
|
isSupport: false;
|
|
@@ -4,11 +4,11 @@ exports.useStripeSupport = useStripeSupport;
|
|
|
4
4
|
const anyspend_1 = require("../../../anyspend/services/anyspend");
|
|
5
5
|
const react_query_1 = require("@tanstack/react-query");
|
|
6
6
|
const react_1 = require("react");
|
|
7
|
-
function useStripeSupport(isMainnet,
|
|
7
|
+
function useStripeSupport(isMainnet, usdAmount, visitorData, isLoadingVisitorData) {
|
|
8
8
|
const { data, isLoading, error, refetch } = (0, react_query_1.useQuery)({
|
|
9
|
-
queryKey: ["useStripeSupport", isMainnet,
|
|
10
|
-
queryFn: () => anyspend_1.anyspendService.checkStripeSupport(isMainnet,
|
|
11
|
-
enabled:
|
|
9
|
+
queryKey: ["useStripeSupport", isMainnet, usdAmount, visitorData?.requestId, visitorData?.visitorId],
|
|
10
|
+
queryFn: () => anyspend_1.anyspendService.checkStripeSupport(isMainnet, usdAmount, visitorData),
|
|
11
|
+
enabled: !isLoadingVisitorData,
|
|
12
12
|
});
|
|
13
13
|
return (0, react_1.useMemo)(() => ({
|
|
14
14
|
isStripeOnrampSupported: data?.stripeOnramp || false,
|
|
@@ -30,7 +30,7 @@ export declare const anyspendService: {
|
|
|
30
30
|
getOrderAndTransactions: (isMainnet: boolean, orderId: string | undefined) => Promise<GetOrderAndTxsResponse>;
|
|
31
31
|
getOrderHistory: (isMainnet: boolean, creatorAddress: string | undefined, limit?: number, offset?: number) => Promise<GetOrderHistoryResponse>;
|
|
32
32
|
getCoinbaseOnrampOptions: (isMainnet: boolean, country: string, visitorData?: VisitorData) => Promise<GetCoinbaseOnrampOptionsResponse>;
|
|
33
|
-
checkStripeSupport: (isMainnet: boolean,
|
|
33
|
+
checkStripeSupport: (isMainnet: boolean, usdAmount?: string, visitorData?: VisitorData) => Promise<{
|
|
34
34
|
stripeOnramp: boolean;
|
|
35
35
|
stripeWeb2: components["schemas"]["StripeWeb2Support"];
|
|
36
36
|
}>;
|
|
@@ -96,9 +96,8 @@ exports.anyspendService = {
|
|
|
96
96
|
const data = await response.json();
|
|
97
97
|
return data;
|
|
98
98
|
},
|
|
99
|
-
checkStripeSupport: async (isMainnet,
|
|
99
|
+
checkStripeSupport: async (isMainnet, usdAmount, visitorData) => {
|
|
100
100
|
const params = new URLSearchParams({
|
|
101
|
-
ipAddress,
|
|
102
101
|
usdAmount: usdAmount || "",
|
|
103
102
|
});
|
|
104
103
|
const response = await fetch(`${isMainnet ? constants_1.ANYSPEND_MAINNET_BASE_URL : constants_1.ANYSPEND_TESTNET_BASE_URL}/onramp/stripe/supported?${params.toString()}`, {
|
|
@@ -238,12 +238,7 @@ export interface paths {
|
|
|
238
238
|
*/
|
|
239
239
|
get: {
|
|
240
240
|
parameters: {
|
|
241
|
-
query
|
|
242
|
-
/**
|
|
243
|
-
* @description IP address to check location-based support
|
|
244
|
-
* @example 192.168.1.1
|
|
245
|
-
*/
|
|
246
|
-
ipAddress: string;
|
|
241
|
+
query?: {
|
|
247
242
|
/**
|
|
248
243
|
* @description Optional USD amount for transaction limit checks
|
|
249
244
|
* @example 100.00
|
|
@@ -903,11 +898,6 @@ export interface components {
|
|
|
903
898
|
* @example
|
|
904
899
|
*/
|
|
905
900
|
paymentMethod?: string;
|
|
906
|
-
/**
|
|
907
|
-
* @description User's IP address
|
|
908
|
-
* @example 96.225.86.216
|
|
909
|
-
*/
|
|
910
|
-
ipAddress?: string;
|
|
911
901
|
/**
|
|
912
902
|
* @description Redirect URL after payment
|
|
913
903
|
* @example https://www.anyspend.com
|
|
@@ -936,11 +926,6 @@ export interface components {
|
|
|
936
926
|
* @example SG
|
|
937
927
|
*/
|
|
938
928
|
country?: string;
|
|
939
|
-
/**
|
|
940
|
-
* @description User's IP address
|
|
941
|
-
* @example 149.88.23.87
|
|
942
|
-
*/
|
|
943
|
-
ipAddress?: string;
|
|
944
929
|
/**
|
|
945
930
|
* @description URL to redirect after payment
|
|
946
931
|
* @example https://www.anyspend.com
|
|
@@ -9,7 +9,7 @@ const Loading_1 = require("../ui/Loading");
|
|
|
9
9
|
function SignInWithB3(props) {
|
|
10
10
|
const { setB3ModalOpen, setB3ModalContentType, setEcoSystemAccountAddress } = (0, react_1.useModalStore)();
|
|
11
11
|
const { account } = (0, react_1.useB3)();
|
|
12
|
-
const { isAuthenticating,
|
|
12
|
+
const { isAuthenticating, isConnected } = (0, react_1.useAuthentication)(props.partnerId, props.loginWithSiwe);
|
|
13
13
|
const isMobile = (0, react_1.useIsMobile)();
|
|
14
14
|
(0, react_2.useEffect)(() => {
|
|
15
15
|
if (account) {
|
|
@@ -24,7 +24,7 @@ function SignInWithB3(props) {
|
|
|
24
24
|
});
|
|
25
25
|
setB3ModalOpen(true);
|
|
26
26
|
};
|
|
27
|
-
if (
|
|
27
|
+
if (isConnected) {
|
|
28
28
|
return (0, jsx_runtime_1.jsx)(ManageAccountButton_1.ManageAccountButton, { ...props });
|
|
29
29
|
}
|
|
30
30
|
if (isAuthenticating) {
|
|
@@ -19,9 +19,12 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
19
19
|
const { setUser, automaticallySetFirstEoa } = (0, react_1.useB3)();
|
|
20
20
|
const [step, setStep] = (0, react_2.useState)(source === "requestPermissions" ? null : "login");
|
|
21
21
|
const [sessionKeyAdded, setSessionKeyAdded] = (0, react_2.useState)(source === "requestPermissions" ? true : false);
|
|
22
|
-
const { setB3ModalContentType, setB3ModalOpen } = (0, react_1.useModalStore)();
|
|
22
|
+
const { setB3ModalContentType, setB3ModalOpen, isOpen } = (0, react_1.useModalStore)();
|
|
23
23
|
const account = (0, react_3.useActiveAccount)();
|
|
24
|
-
const
|
|
24
|
+
const setIsAuthenticating = (0, react_1.useAuthStore)(state => state.setIsAuthenticating);
|
|
25
|
+
const isAuthenticating = (0, react_1.useAuthStore)(state => state.isAuthenticating);
|
|
26
|
+
const isConnected = (0, react_1.useAuthStore)(state => state.isConnected);
|
|
27
|
+
const setIsConnected = (0, react_1.useAuthStore)(state => state.setIsConnected);
|
|
25
28
|
const [refetchCount, setRefetchCount] = (0, react_2.useState)(0);
|
|
26
29
|
const [refetchError, setRefetchError] = (0, react_2.useState)(null);
|
|
27
30
|
const { data: signers, refetch: refetchSigners, isFetching: isFetchingSigners, } = (0, react_1.useGetAllTWSigners)({
|
|
@@ -32,7 +35,6 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
32
35
|
},
|
|
33
36
|
});
|
|
34
37
|
const { authenticate } = (0, react_1.useSiwe)();
|
|
35
|
-
const [authenticatingWithB3, setAuthenticatingWithB3] = (0, react_2.useState)(false);
|
|
36
38
|
const [refetchQueued, setRefetchQueued] = (0, react_2.useState)(false);
|
|
37
39
|
// Enhanced refetchSigners function that tracks number of attempts
|
|
38
40
|
const handleRefetchSigners = (0, react_2.useCallback)(() => {
|
|
@@ -58,11 +60,14 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
58
60
|
// Handle post-login flow after signers are loaded
|
|
59
61
|
(0, react_2.useEffect)(() => {
|
|
60
62
|
debug("@@SignInWithB3Flow:useEffect", {
|
|
61
|
-
|
|
63
|
+
isConnected,
|
|
64
|
+
isAuthenticating,
|
|
62
65
|
isFetchingSigners,
|
|
66
|
+
closeAfterLogin,
|
|
67
|
+
isOpen,
|
|
63
68
|
source,
|
|
64
69
|
});
|
|
65
|
-
if (
|
|
70
|
+
if (isConnected) {
|
|
66
71
|
// Check if we already have a signer for this partner
|
|
67
72
|
const hasExistingSigner = signers?.some(signer => signer.partner.id === partnerId);
|
|
68
73
|
if (hasExistingSigner) {
|
|
@@ -102,7 +107,6 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
102
107
|
signers,
|
|
103
108
|
isFetchingSigners,
|
|
104
109
|
partnerId,
|
|
105
|
-
loginComplete,
|
|
106
110
|
handleRefetchSigners,
|
|
107
111
|
source,
|
|
108
112
|
closeAfterLogin,
|
|
@@ -111,6 +115,9 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
111
115
|
onSessionKeySuccess,
|
|
112
116
|
setB3ModalOpen,
|
|
113
117
|
signersEnabled,
|
|
118
|
+
isConnected,
|
|
119
|
+
isAuthenticating,
|
|
120
|
+
isOpen,
|
|
114
121
|
]);
|
|
115
122
|
debug("render", {
|
|
116
123
|
step,
|
|
@@ -155,16 +162,16 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
155
162
|
]);
|
|
156
163
|
const handleLoginSuccess = (0, react_2.useCallback)(async (account) => {
|
|
157
164
|
debug("Authenticating with B3 via SIWE");
|
|
165
|
+
setIsConnected(true);
|
|
158
166
|
if (loginWithSiwe) {
|
|
159
|
-
|
|
167
|
+
setIsAuthenticating(true);
|
|
160
168
|
const userAuth = await authenticate(account, partnerId);
|
|
161
169
|
setUser(userAuth.user);
|
|
162
170
|
}
|
|
163
171
|
debug("handleLoginSuccess:account", account);
|
|
164
172
|
onLoginSuccess?.(account);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}, [authenticate, loginWithSiwe, onLoginSuccess, setUser, partnerId]);
|
|
173
|
+
setIsAuthenticating(false);
|
|
174
|
+
}, [loginWithSiwe, onLoginSuccess, setIsAuthenticating, authenticate, partnerId, setUser, setIsConnected]);
|
|
168
175
|
(0, react_2.useEffect)(() => {
|
|
169
176
|
if (step === "permissions") {
|
|
170
177
|
setB3ModalContentType({
|
|
@@ -180,7 +187,7 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
180
187
|
if (refetchError) {
|
|
181
188
|
return ((0, jsx_runtime_1.jsx)(LoginStep_1.LoginStepContainer, { partnerId: partnerId, children: (0, jsx_runtime_1.jsx)("div", { className: "p-4 text-center text-red-500", children: refetchError }) }));
|
|
182
189
|
}
|
|
183
|
-
if (
|
|
190
|
+
if (isAuthenticating || (isFetchingSigners && step === "login") || source === "requestPermissions") {
|
|
184
191
|
return ((0, jsx_runtime_1.jsx)(LoginStep_1.LoginStepContainer, { partnerId: partnerId, children: (0, jsx_runtime_1.jsx)("div", { className: "mt-8 flex items-center justify-center", children: (0, jsx_runtime_1.jsx)(react_1.Loading, { variant: "white", size: "lg" }) }) }));
|
|
185
192
|
}
|
|
186
193
|
if (step === "login") {
|
|
@@ -6,7 +6,7 @@ const react_1 = require("../../../../global-account/react");
|
|
|
6
6
|
const utils_1 = require("../../../../shared/utils");
|
|
7
7
|
function ManageAccountButton(props) {
|
|
8
8
|
const { setB3ModalOpen, setB3ModalContentType } = (0, react_1.useModalStore)();
|
|
9
|
-
const {
|
|
9
|
+
const { isConnected } = (0, react_1.useAuthentication)(props.partnerId, props.loginWithSiwe);
|
|
10
10
|
const handleClickManageAccount = () => {
|
|
11
11
|
setB3ModalContentType({
|
|
12
12
|
...props,
|
|
@@ -14,7 +14,7 @@ function ManageAccountButton(props) {
|
|
|
14
14
|
});
|
|
15
15
|
setB3ModalOpen(true);
|
|
16
16
|
};
|
|
17
|
-
if (!
|
|
17
|
+
if (!isConnected)
|
|
18
18
|
return null;
|
|
19
19
|
return ((0, jsx_runtime_1.jsx)(react_1.StyleRoot, { children: (0, jsx_runtime_1.jsxs)(react_1.Button, { onClick: handleClickManageAccount, style: { backgroundColor: "#3368ef" }, className: (0, utils_1.cn)("b3-manage-account-button flex items-center gap-2 text-white", props.className), children: [props.withLogo !== false && ((0, jsx_runtime_1.jsx)("img", { src: "https://cdn.b3.fun/b3_logo_white.svg", alt: "B3 Logo", className: "h-5 w-5" })), props.loggedInButtonText || "Manage Account"] }) }));
|
|
20
20
|
}
|
|
@@ -4,6 +4,8 @@ export declare function useAuthentication(partnerId: string, loginWithSiwe?: boo
|
|
|
4
4
|
isAuthenticating: boolean;
|
|
5
5
|
isAuthenticated: boolean;
|
|
6
6
|
isReady: boolean;
|
|
7
|
+
isConnecting: boolean;
|
|
8
|
+
isConnected: boolean;
|
|
7
9
|
wallet: import("thirdweb/dist/types/wallets/in-app/core/wallet/types").EcosystemWallet;
|
|
8
10
|
preAuthenticate: typeof preAuthenticate;
|
|
9
11
|
connect: (strategyOptions?: import("thirdweb/wallets").SingleStepAuthArgsType) => Promise<import("thirdweb/wallets").Wallet | null>;
|
|
@@ -27,6 +27,10 @@ function useAuthentication(partnerId, loginWithSiwe) {
|
|
|
27
27
|
const isAuthenticated = (0, react_1.useAuthStore)(state => state.isAuthenticated);
|
|
28
28
|
const setIsAuthenticated = (0, react_1.useAuthStore)(state => state.setIsAuthenticated);
|
|
29
29
|
const setIsAuthenticating = (0, react_1.useAuthStore)(state => state.setIsAuthenticating);
|
|
30
|
+
const setIsConnecting = (0, react_1.useAuthStore)(state => state.setIsConnecting);
|
|
31
|
+
const setIsConnected = (0, react_1.useAuthStore)(state => state.setIsConnected);
|
|
32
|
+
const isConnecting = (0, react_1.useAuthStore)(state => state.isConnecting);
|
|
33
|
+
const isConnected = (0, react_1.useAuthStore)(state => state.isConnected);
|
|
30
34
|
const { connect } = (0, useConnect_1.useConnect)(partnerId, supported_1.b3MainnetThirdWeb);
|
|
31
35
|
const wallet = (0, wallets_1.ecosystemWallet)(constants_1.ecosystemWalletId, {
|
|
32
36
|
partnerId: partnerId,
|
|
@@ -36,6 +40,7 @@ function useAuthentication(partnerId, loginWithSiwe) {
|
|
|
36
40
|
wallets: [wallet],
|
|
37
41
|
onConnect: async (wallet) => {
|
|
38
42
|
try {
|
|
43
|
+
setIsConnected(true);
|
|
39
44
|
if (!loginWithSiwe) {
|
|
40
45
|
debug("Skipping SIWE login", { loginWithSiwe });
|
|
41
46
|
setIsAuthenticated(true);
|
|
@@ -73,19 +78,22 @@ function useAuthentication(partnerId, loginWithSiwe) {
|
|
|
73
78
|
(0, react_2.useEffect)(() => {
|
|
74
79
|
if (useAutoConnectLoading) {
|
|
75
80
|
setIsAuthenticating(true);
|
|
81
|
+
setIsConnecting(true);
|
|
76
82
|
}
|
|
77
83
|
else if (!isAuthenticated) {
|
|
78
84
|
// Only set isAuthenticating to false if we're not authenticated
|
|
79
85
|
// This prevents the flicker state where both isAuthenticating and isAuthenticated are false
|
|
80
86
|
const timeout = setTimeout(() => {
|
|
81
87
|
setIsAuthenticating(false);
|
|
88
|
+
setIsConnecting(false);
|
|
82
89
|
}, 100); // Add a small delay to prevent quick flickers
|
|
83
90
|
return () => clearTimeout(timeout);
|
|
84
91
|
}
|
|
85
92
|
else {
|
|
86
93
|
setIsAuthenticating(false);
|
|
94
|
+
setIsConnecting(false);
|
|
87
95
|
}
|
|
88
|
-
}, [useAutoConnectLoading, isAuthenticated, setIsAuthenticating]);
|
|
96
|
+
}, [useAutoConnectLoading, isAuthenticated, setIsAuthenticating, setIsConnecting, setIsConnected]);
|
|
89
97
|
const logout = async (callback) => {
|
|
90
98
|
if (activeWallet) {
|
|
91
99
|
debug("@@logout:activeWallet", activeWallet);
|
|
@@ -108,6 +116,7 @@ function useAuthentication(partnerId, loginWithSiwe) {
|
|
|
108
116
|
app_1.default.logout();
|
|
109
117
|
debug("@@logout:loggedOut");
|
|
110
118
|
setIsAuthenticated(false);
|
|
119
|
+
setIsConnected(false);
|
|
111
120
|
setUser();
|
|
112
121
|
callback?.();
|
|
113
122
|
};
|
|
@@ -117,6 +126,8 @@ function useAuthentication(partnerId, loginWithSiwe) {
|
|
|
117
126
|
isAuthenticating: useAutoConnectLoading || isAuthenticating,
|
|
118
127
|
isAuthenticated,
|
|
119
128
|
isReady,
|
|
129
|
+
isConnecting,
|
|
130
|
+
isConnected,
|
|
120
131
|
wallet,
|
|
121
132
|
preAuthenticate: in_app_1.preAuthenticate,
|
|
122
133
|
connect,
|
|
@@ -7,10 +7,14 @@ interface AuthState {
|
|
|
7
7
|
chain?: Chain;
|
|
8
8
|
isAuthenticating: boolean;
|
|
9
9
|
isAuthenticated: boolean;
|
|
10
|
+
isConnecting: boolean;
|
|
11
|
+
isConnected: boolean;
|
|
10
12
|
onSuccess?: (account: any) => void;
|
|
11
13
|
onError?: (error: Error) => void;
|
|
12
14
|
setB3ModalOpen: (isOpen: boolean) => void;
|
|
13
15
|
setStep: (step: "login" | "permissions") => void;
|
|
16
|
+
setIsConnecting: (isConnecting: boolean) => void;
|
|
17
|
+
setIsConnected: (isConnected: boolean) => void;
|
|
14
18
|
setIsAuthenticating: (isAuthenticating: boolean) => void;
|
|
15
19
|
setIsAuthenticated: (isAuthenticated: boolean) => void;
|
|
16
20
|
startAuth: (params: {
|
|
@@ -10,10 +10,14 @@ exports.useAuthStore = (0, zustand_1.create)(set => ({
|
|
|
10
10
|
chain: undefined,
|
|
11
11
|
isAuthenticating: false,
|
|
12
12
|
isAuthenticated: false,
|
|
13
|
+
isConnecting: false,
|
|
14
|
+
isConnected: false,
|
|
13
15
|
onSuccess: undefined,
|
|
14
16
|
onError: undefined,
|
|
15
17
|
setB3ModalOpen: isOpen => set({ isOpen }),
|
|
16
18
|
setStep: step => set({ step }),
|
|
19
|
+
setIsConnecting: isConnecting => set({ isConnecting }),
|
|
20
|
+
setIsConnected: isConnected => set({ isConnected }),
|
|
17
21
|
setIsAuthenticating: isAuthenticating => set({ isAuthenticating }),
|
|
18
22
|
setIsAuthenticated: isAuthenticated => set({ isAuthenticated }),
|
|
19
23
|
startAuth: params => set({
|
|
@@ -718,7 +718,6 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
|
|
|
718
718
|
vendor: vendor,
|
|
719
719
|
paymentMethod: paymentMethodString,
|
|
720
720
|
country: geoData?.country || "US",
|
|
721
|
-
ipAddress: geoData?.ip,
|
|
722
721
|
redirectUrl: window.location.origin === "https://basement.fun" ? "https://basement.fun/deposit" : window.location.origin,
|
|
723
722
|
},
|
|
724
723
|
expectedDstAmount: anyspendQuote?.data?.currencyOut?.amount?.toString() || "0",
|
|
@@ -300,7 +300,6 @@ export function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", re
|
|
|
300
300
|
vendor: onramp.vendor,
|
|
301
301
|
paymentMethod: onramp.paymentMethod,
|
|
302
302
|
country: geoData?.country || "US",
|
|
303
|
-
ipAddress: geoData?.ip,
|
|
304
303
|
redirectUrl: window.location.origin === "https://basement.fun"
|
|
305
304
|
? "https://basement.fun/deposit"
|
|
306
305
|
: window.location.origin,
|
|
@@ -73,7 +73,6 @@ function PanelOnrampPaymentInner(props) {
|
|
|
73
73
|
vendor: vendor,
|
|
74
74
|
paymentMethod: paymentMethod || "",
|
|
75
75
|
country: geoData?.country || "US",
|
|
76
|
-
ipAddress: geoData?.ip,
|
|
77
76
|
redirectUrl: window.location.origin === "https://basement.fun" ? "https://basement.fun/deposit" : window.location.origin,
|
|
78
77
|
},
|
|
79
78
|
expectedDstAmount: anyspendQuote?.data?.currencyOut?.amount?.toString() || "0",
|
|
@@ -128,7 +128,6 @@ function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinat
|
|
|
128
128
|
vendor: "stripe-web2",
|
|
129
129
|
paymentMethod: "",
|
|
130
130
|
country: geoData.country || "US",
|
|
131
|
-
ipAddress: geoData.ip,
|
|
132
131
|
redirectUrl: `${window.location.origin}${userId ? `?userId=${userId}` : ""}`,
|
|
133
132
|
},
|
|
134
133
|
expectedDstAmount: anyspendQuote.data?.currencyOut?.amount?.toString() || "0",
|
|
@@ -21,10 +21,6 @@ export function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
|
21
21
|
mutationFn: async (params) => {
|
|
22
22
|
const { isMainnet, recipientAddress, orderType, dstChain, dstToken, srcFiatAmount, onramp, creatorAddress, expectedDstAmount, nft, tournament, payload, partnerId, } = params;
|
|
23
23
|
try {
|
|
24
|
-
// Validate Stripe onramp options
|
|
25
|
-
if (onramp.vendor === "stripe" && !onramp.ipAddress) {
|
|
26
|
-
throw new Error("IP address is required for Stripe onramp");
|
|
27
|
-
}
|
|
28
24
|
// Validate required onramp fields
|
|
29
25
|
if (!onramp.vendor || !onramp.country) {
|
|
30
26
|
throw new Error("Missing required onramp fields: vendor, country");
|
|
@@ -13,7 +13,7 @@ export function useGeoOnrampOptions(isMainnet, srcFiatAmount) {
|
|
|
13
13
|
// Use existing hooks
|
|
14
14
|
const { geoData, loading: isLoadingGeo, error: geoError } = useGetGeo();
|
|
15
15
|
const { coinbaseOnrampOptions, isLoadingCoinbaseOnrampOptions, coinbaseOnrampOptionsError } = useCoinbaseOnrampOptions(isMainnet, geoData?.country, visitorData);
|
|
16
|
-
const { isStripeOnrampSupported, stripeWeb2Support, isLoadingStripeSupport, stripeSupportError } = useStripeSupport(isMainnet,
|
|
16
|
+
const { isStripeOnrampSupported, stripeWeb2Support, isLoadingStripeSupport, stripeSupportError } = useStripeSupport(isMainnet, srcFiatAmount, visitorData);
|
|
17
17
|
// Calculate available payment methods based on the amount
|
|
18
18
|
const coinbaseAvailablePaymentMethods = useMemo(() => {
|
|
19
19
|
if (!coinbaseOnrampOptions?.paymentCurrencies?.[0]?.limits || !srcFiatAmount)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VisitorData } from "../../../anyspend/types/fingerprint";
|
|
2
|
-
export declare function useStripeSupport(isMainnet: boolean,
|
|
2
|
+
export declare function useStripeSupport(isMainnet: boolean, usdAmount?: string, visitorData?: VisitorData, isLoadingVisitorData?: boolean): {
|
|
3
3
|
isStripeOnrampSupported: boolean;
|
|
4
4
|
stripeWeb2Support: {
|
|
5
5
|
isSupport: false;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { anyspendService } from "../../../anyspend/services/anyspend.js";
|
|
2
2
|
import { useQuery } from "@tanstack/react-query";
|
|
3
3
|
import { useMemo } from "react";
|
|
4
|
-
export function useStripeSupport(isMainnet,
|
|
4
|
+
export function useStripeSupport(isMainnet, usdAmount, visitorData, isLoadingVisitorData) {
|
|
5
5
|
const { data, isLoading, error, refetch } = useQuery({
|
|
6
|
-
queryKey: ["useStripeSupport", isMainnet,
|
|
7
|
-
queryFn: () => anyspendService.checkStripeSupport(isMainnet,
|
|
8
|
-
enabled:
|
|
6
|
+
queryKey: ["useStripeSupport", isMainnet, usdAmount, visitorData?.requestId, visitorData?.visitorId],
|
|
7
|
+
queryFn: () => anyspendService.checkStripeSupport(isMainnet, usdAmount, visitorData),
|
|
8
|
+
enabled: !isLoadingVisitorData,
|
|
9
9
|
});
|
|
10
10
|
return useMemo(() => ({
|
|
11
11
|
isStripeOnrampSupported: data?.stripeOnramp || false,
|
|
@@ -30,7 +30,7 @@ export declare const anyspendService: {
|
|
|
30
30
|
getOrderAndTransactions: (isMainnet: boolean, orderId: string | undefined) => Promise<GetOrderAndTxsResponse>;
|
|
31
31
|
getOrderHistory: (isMainnet: boolean, creatorAddress: string | undefined, limit?: number, offset?: number) => Promise<GetOrderHistoryResponse>;
|
|
32
32
|
getCoinbaseOnrampOptions: (isMainnet: boolean, country: string, visitorData?: VisitorData) => Promise<GetCoinbaseOnrampOptionsResponse>;
|
|
33
|
-
checkStripeSupport: (isMainnet: boolean,
|
|
33
|
+
checkStripeSupport: (isMainnet: boolean, usdAmount?: string, visitorData?: VisitorData) => Promise<{
|
|
34
34
|
stripeOnramp: boolean;
|
|
35
35
|
stripeWeb2: components["schemas"]["StripeWeb2Support"];
|
|
36
36
|
}>;
|
|
@@ -90,9 +90,8 @@ export const anyspendService = {
|
|
|
90
90
|
const data = await response.json();
|
|
91
91
|
return data;
|
|
92
92
|
},
|
|
93
|
-
checkStripeSupport: async (isMainnet,
|
|
93
|
+
checkStripeSupport: async (isMainnet, usdAmount, visitorData) => {
|
|
94
94
|
const params = new URLSearchParams({
|
|
95
|
-
ipAddress,
|
|
96
95
|
usdAmount: usdAmount || "",
|
|
97
96
|
});
|
|
98
97
|
const response = await fetch(`${isMainnet ? ANYSPEND_MAINNET_BASE_URL : ANYSPEND_TESTNET_BASE_URL}/onramp/stripe/supported?${params.toString()}`, {
|
|
@@ -238,12 +238,7 @@ export interface paths {
|
|
|
238
238
|
*/
|
|
239
239
|
get: {
|
|
240
240
|
parameters: {
|
|
241
|
-
query
|
|
242
|
-
/**
|
|
243
|
-
* @description IP address to check location-based support
|
|
244
|
-
* @example 192.168.1.1
|
|
245
|
-
*/
|
|
246
|
-
ipAddress: string;
|
|
241
|
+
query?: {
|
|
247
242
|
/**
|
|
248
243
|
* @description Optional USD amount for transaction limit checks
|
|
249
244
|
* @example 100.00
|
|
@@ -903,11 +898,6 @@ export interface components {
|
|
|
903
898
|
* @example
|
|
904
899
|
*/
|
|
905
900
|
paymentMethod?: string;
|
|
906
|
-
/**
|
|
907
|
-
* @description User's IP address
|
|
908
|
-
* @example 96.225.86.216
|
|
909
|
-
*/
|
|
910
|
-
ipAddress?: string;
|
|
911
901
|
/**
|
|
912
902
|
* @description Redirect URL after payment
|
|
913
903
|
* @example https://www.anyspend.com
|
|
@@ -936,11 +926,6 @@ export interface components {
|
|
|
936
926
|
* @example SG
|
|
937
927
|
*/
|
|
938
928
|
country?: string;
|
|
939
|
-
/**
|
|
940
|
-
* @description User's IP address
|
|
941
|
-
* @example 149.88.23.87
|
|
942
|
-
*/
|
|
943
|
-
ipAddress?: string;
|
|
944
929
|
/**
|
|
945
930
|
* @description URL to redirect after payment
|
|
946
931
|
* @example https://www.anyspend.com
|
|
@@ -6,7 +6,7 @@ import { Loading } from "../ui/Loading.js";
|
|
|
6
6
|
export function SignInWithB3(props) {
|
|
7
7
|
const { setB3ModalOpen, setB3ModalContentType, setEcoSystemAccountAddress } = useModalStore();
|
|
8
8
|
const { account } = useB3();
|
|
9
|
-
const { isAuthenticating,
|
|
9
|
+
const { isAuthenticating, isConnected } = useAuthentication(props.partnerId, props.loginWithSiwe);
|
|
10
10
|
const isMobile = useIsMobile();
|
|
11
11
|
useEffect(() => {
|
|
12
12
|
if (account) {
|
|
@@ -21,7 +21,7 @@ export function SignInWithB3(props) {
|
|
|
21
21
|
});
|
|
22
22
|
setB3ModalOpen(true);
|
|
23
23
|
};
|
|
24
|
-
if (
|
|
24
|
+
if (isConnected) {
|
|
25
25
|
return _jsx(ManageAccountButton, { ...props });
|
|
26
26
|
}
|
|
27
27
|
if (isAuthenticating) {
|