@b3dotfun/sdk 0.0.19-alpha.2 → 0.0.19

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.
Files changed (59) hide show
  1. package/dist/cjs/anyspend/react/components/AnySpend.js +1 -0
  2. package/dist/cjs/anyspend/react/components/AnySpendCustom.js +1 -0
  3. package/dist/cjs/anyspend/react/components/common/PanelOnrampPayment.js +1 -0
  4. package/dist/cjs/anyspend/react/components/webview/WebviewOnrampPayment.js +1 -0
  5. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +1 -0
  6. package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +4 -0
  7. package/dist/cjs/anyspend/react/hooks/useGeoOnrampOptions.js +1 -1
  8. package/dist/cjs/anyspend/react/hooks/useStripeSupport.d.ts +1 -1
  9. package/dist/cjs/anyspend/react/hooks/useStripeSupport.js +4 -4
  10. package/dist/cjs/anyspend/services/anyspend.d.ts +1 -1
  11. package/dist/cjs/anyspend/services/anyspend.js +2 -1
  12. package/dist/cjs/anyspend/types/api.d.ts +16 -1
  13. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3.js +2 -2
  14. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +11 -18
  15. package/dist/cjs/global-account/react/components/custom/ManageAccountButton.js +2 -2
  16. package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +0 -2
  17. package/dist/cjs/global-account/react/hooks/useAuthentication.js +1 -12
  18. package/dist/cjs/global-account/react/stores/useAuthStore.d.ts +0 -4
  19. package/dist/cjs/global-account/react/stores/useAuthStore.js +0 -4
  20. package/dist/esm/anyspend/react/components/AnySpend.js +1 -0
  21. package/dist/esm/anyspend/react/components/AnySpendCustom.js +1 -0
  22. package/dist/esm/anyspend/react/components/common/PanelOnrampPayment.js +1 -0
  23. package/dist/esm/anyspend/react/components/webview/WebviewOnrampPayment.js +1 -0
  24. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +1 -0
  25. package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +4 -0
  26. package/dist/esm/anyspend/react/hooks/useGeoOnrampOptions.js +1 -1
  27. package/dist/esm/anyspend/react/hooks/useStripeSupport.d.ts +1 -1
  28. package/dist/esm/anyspend/react/hooks/useStripeSupport.js +4 -4
  29. package/dist/esm/anyspend/services/anyspend.d.ts +1 -1
  30. package/dist/esm/anyspend/services/anyspend.js +2 -1
  31. package/dist/esm/anyspend/types/api.d.ts +16 -1
  32. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3.js +2 -2
  33. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +12 -19
  34. package/dist/esm/global-account/react/components/custom/ManageAccountButton.js +2 -2
  35. package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +0 -2
  36. package/dist/esm/global-account/react/hooks/useAuthentication.js +1 -12
  37. package/dist/esm/global-account/react/stores/useAuthStore.d.ts +0 -4
  38. package/dist/esm/global-account/react/stores/useAuthStore.js +0 -4
  39. package/dist/types/anyspend/react/hooks/useAnyspendCreateOnrampOrder.d.ts +1 -0
  40. package/dist/types/anyspend/react/hooks/useStripeSupport.d.ts +1 -1
  41. package/dist/types/anyspend/services/anyspend.d.ts +1 -1
  42. package/dist/types/anyspend/types/api.d.ts +16 -1
  43. package/dist/types/global-account/react/hooks/useAuthentication.d.ts +0 -2
  44. package/dist/types/global-account/react/stores/useAuthStore.d.ts +0 -4
  45. package/package.json +1 -1
  46. package/src/anyspend/react/components/AnySpend.tsx +1 -0
  47. package/src/anyspend/react/components/AnySpendCustom.tsx +1 -0
  48. package/src/anyspend/react/components/common/PanelOnrampPayment.tsx +1 -0
  49. package/src/anyspend/react/components/webview/WebviewOnrampPayment.tsx +1 -0
  50. package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +6 -0
  51. package/src/anyspend/react/hooks/useGeoOnrampOptions.ts +1 -0
  52. package/src/anyspend/react/hooks/useStripeSupport.ts +4 -3
  53. package/src/anyspend/services/anyspend.ts +2 -0
  54. package/src/anyspend/types/api.ts +16 -1
  55. package/src/global-account/react/components/SignInWithB3/SignInWithB3.tsx +2 -2
  56. package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +11 -19
  57. package/src/global-account/react/components/custom/ManageAccountButton.tsx +2 -2
  58. package/src/global-account/react/hooks/useAuthentication.ts +1 -12
  59. package/src/global-account/react/stores/useAuthStore.ts +0 -8
@@ -725,6 +725,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
725
725
  vendor: vendor,
726
726
  paymentMethod: paymentMethodString,
727
727
  country: geoData?.country || "US",
728
+ ipAddress: geoData?.ip,
728
729
  redirectUrl: window.location.origin === "https://basement.fun" ? "https://basement.fun/deposit" : window.location.origin,
729
730
  },
730
731
  expectedDstAmount: anyspendQuote?.data?.currencyOut?.amount?.toString() || "0",
@@ -306,6 +306,7 @@ 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,
309
310
  redirectUrl: window.location.origin === "https://basement.fun"
310
311
  ? "https://basement.fun/deposit"
311
312
  : window.location.origin,
@@ -79,6 +79,7 @@ function PanelOnrampPaymentInner(props) {
79
79
  vendor: vendor,
80
80
  paymentMethod: paymentMethod || "",
81
81
  country: geoData?.country || "US",
82
+ ipAddress: geoData?.ip,
82
83
  redirectUrl: window.location.origin === "https://basement.fun" ? "https://basement.fun/deposit" : window.location.origin,
83
84
  },
84
85
  expectedDstAmount: anyspendQuote?.data?.currencyOut?.amount?.toString() || "0",
@@ -134,6 +134,7 @@ function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinat
134
134
  vendor: "stripe-web2",
135
135
  paymentMethod: "",
136
136
  country: geoData.country || "US",
137
+ ipAddress: geoData.ip,
137
138
  redirectUrl: `${window.location.origin}${userId ? `?userId=${userId}` : ""}`,
138
139
  },
139
140
  expectedDstAmount: anyspendQuote.data?.currencyOut?.amount?.toString() || "0",
@@ -5,6 +5,7 @@ export type OnrampOptions = {
5
5
  paymentMethod: string;
6
6
  country: string;
7
7
  redirectUrl: string;
8
+ ipAddress?: string;
8
9
  };
9
10
  export type CreateOnrampOrderParams = Omit<CreateOrderParams, "srcChain" | "srcToken" | "srcAmount"> & {
10
11
  srcFiatAmount: string;
@@ -24,6 +24,10 @@ 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
+ }
27
31
  // Validate required onramp fields
28
32
  if (!onramp.vendor || !onramp.country) {
29
33
  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, srcFiatAmount, visitorData);
19
+ const { isStripeOnrampSupported, stripeWeb2Support, isLoadingStripeSupport, stripeSupportError } = (0, useStripeSupport_1.useStripeSupport)(isMainnet, geoData?.ip || "", 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, usdAmount?: string, visitorData?: VisitorData, isLoadingVisitorData?: boolean): {
2
+ export declare function useStripeSupport(isMainnet: boolean, ipAddress: string, 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, usdAmount, visitorData, isLoadingVisitorData) {
7
+ function useStripeSupport(isMainnet, ipAddress, usdAmount, visitorData, isLoadingVisitorData) {
8
8
  const { data, isLoading, error, refetch } = (0, react_query_1.useQuery)({
9
- queryKey: ["useStripeSupport", isMainnet, usdAmount, visitorData?.requestId, visitorData?.visitorId],
10
- queryFn: () => anyspend_1.anyspendService.checkStripeSupport(isMainnet, usdAmount, visitorData),
11
- enabled: !isLoadingVisitorData,
9
+ queryKey: ["useStripeSupport", isMainnet, ipAddress, usdAmount, visitorData?.requestId, visitorData?.visitorId],
10
+ queryFn: () => anyspend_1.anyspendService.checkStripeSupport(isMainnet, ipAddress, usdAmount, visitorData),
11
+ enabled: !!ipAddress && !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, usdAmount?: string, visitorData?: VisitorData) => Promise<{
33
+ checkStripeSupport: (isMainnet: boolean, ipAddress: string, usdAmount?: string, visitorData?: VisitorData) => Promise<{
34
34
  stripeOnramp: boolean;
35
35
  stripeWeb2: components["schemas"]["StripeWeb2Support"];
36
36
  }>;
@@ -96,8 +96,9 @@ exports.anyspendService = {
96
96
  const data = await response.json();
97
97
  return data;
98
98
  },
99
- checkStripeSupport: async (isMainnet, usdAmount, visitorData) => {
99
+ checkStripeSupport: async (isMainnet, ipAddress, usdAmount, visitorData) => {
100
100
  const params = new URLSearchParams({
101
+ ipAddress,
101
102
  usdAmount: usdAmount || "",
102
103
  });
103
104
  const response = await fetch(`${isMainnet ? constants_1.ANYSPEND_MAINNET_BASE_URL : constants_1.ANYSPEND_TESTNET_BASE_URL}/onramp/stripe/supported?${params.toString()}`, {
@@ -238,7 +238,12 @@ export interface paths {
238
238
  */
239
239
  get: {
240
240
  parameters: {
241
- query?: {
241
+ query: {
242
+ /**
243
+ * @description IP address to check location-based support
244
+ * @example 192.168.1.1
245
+ */
246
+ ipAddress: string;
242
247
  /**
243
248
  * @description Optional USD amount for transaction limit checks
244
249
  * @example 100.00
@@ -898,6 +903,11 @@ export interface components {
898
903
  * @example
899
904
  */
900
905
  paymentMethod?: string;
906
+ /**
907
+ * @description User's IP address
908
+ * @example 96.225.86.216
909
+ */
910
+ ipAddress?: string;
901
911
  /**
902
912
  * @description Redirect URL after payment
903
913
  * @example https://www.anyspend.com
@@ -926,6 +936,11 @@ export interface components {
926
936
  * @example SG
927
937
  */
928
938
  country?: string;
939
+ /**
940
+ * @description User's IP address
941
+ * @example 149.88.23.87
942
+ */
943
+ ipAddress?: string;
929
944
  /**
930
945
  * @description URL to redirect after payment
931
946
  * @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, isConnected } = (0, react_1.useAuthentication)(props.partnerId, props.loginWithSiwe);
12
+ const { isAuthenticating, isAuthenticated } = (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 (isConnected) {
27
+ if (isAuthenticated) {
28
28
  return (0, jsx_runtime_1.jsx)(ManageAccountButton_1.ManageAccountButton, { ...props });
29
29
  }
30
30
  if (isAuthenticating) {
@@ -19,12 +19,9 @@ 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, isOpen } = (0, react_1.useModalStore)();
22
+ const { setB3ModalContentType, setB3ModalOpen } = (0, react_1.useModalStore)();
23
23
  const account = (0, react_3.useActiveAccount)();
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);
24
+ const [loginComplete, setLoginComplete] = (0, react_2.useState)(source === "requestPermissions" ? true : false);
28
25
  const [refetchCount, setRefetchCount] = (0, react_2.useState)(0);
29
26
  const [refetchError, setRefetchError] = (0, react_2.useState)(null);
30
27
  const { data: signers, refetch: refetchSigners, isFetching: isFetchingSigners, } = (0, react_1.useGetAllTWSigners)({
@@ -35,6 +32,7 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
35
32
  },
36
33
  });
37
34
  const { authenticate } = (0, react_1.useSiwe)();
35
+ const [authenticatingWithB3, setAuthenticatingWithB3] = (0, react_2.useState)(false);
38
36
  const [refetchQueued, setRefetchQueued] = (0, react_2.useState)(false);
39
37
  // Enhanced refetchSigners function that tracks number of attempts
40
38
  const handleRefetchSigners = (0, react_2.useCallback)(() => {
@@ -60,14 +58,11 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
60
58
  // Handle post-login flow after signers are loaded
61
59
  (0, react_2.useEffect)(() => {
62
60
  debug("@@SignInWithB3Flow:useEffect", {
63
- isConnected,
64
- isAuthenticating,
61
+ loginComplete,
65
62
  isFetchingSigners,
66
- closeAfterLogin,
67
- isOpen,
68
63
  source,
69
64
  });
70
- if (isConnected) {
65
+ if (loginComplete && !isFetchingSigners) {
71
66
  // Check if we already have a signer for this partner
72
67
  const hasExistingSigner = signers?.some(signer => signer.partner.id === partnerId);
73
68
  if (hasExistingSigner) {
@@ -107,6 +102,7 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
107
102
  signers,
108
103
  isFetchingSigners,
109
104
  partnerId,
105
+ loginComplete,
110
106
  handleRefetchSigners,
111
107
  source,
112
108
  closeAfterLogin,
@@ -115,9 +111,6 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
115
111
  onSessionKeySuccess,
116
112
  setB3ModalOpen,
117
113
  signersEnabled,
118
- isConnected,
119
- isAuthenticating,
120
- isOpen,
121
114
  ]);
122
115
  debug("render", {
123
116
  step,
@@ -162,16 +155,16 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
162
155
  ]);
163
156
  const handleLoginSuccess = (0, react_2.useCallback)(async (account) => {
164
157
  debug("Authenticating with B3 via SIWE");
165
- setIsConnected(true);
166
158
  if (loginWithSiwe) {
167
- setIsAuthenticating(true);
159
+ setAuthenticatingWithB3(true);
168
160
  const userAuth = await authenticate(account, partnerId);
169
161
  setUser(userAuth.user);
170
162
  }
171
163
  debug("handleLoginSuccess:account", account);
172
164
  onLoginSuccess?.(account);
173
- setIsAuthenticating(false);
174
- }, [loginWithSiwe, onLoginSuccess, setIsAuthenticating, authenticate, partnerId, setUser, setIsConnected]);
165
+ setLoginComplete(true);
166
+ setAuthenticatingWithB3(false);
167
+ }, [authenticate, loginWithSiwe, onLoginSuccess, setUser, partnerId]);
175
168
  (0, react_2.useEffect)(() => {
176
169
  if (step === "permissions") {
177
170
  setB3ModalContentType({
@@ -187,7 +180,7 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
187
180
  if (refetchError) {
188
181
  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 }) }));
189
182
  }
190
- if (isAuthenticating || (isFetchingSigners && step === "login") || source === "requestPermissions") {
183
+ if (authenticatingWithB3 || (isFetchingSigners && step === "login") || source === "requestPermissions") {
191
184
  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" }) }) }));
192
185
  }
193
186
  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 { isConnected } = (0, react_1.useAuthentication)(props.partnerId, props.loginWithSiwe);
9
+ const { isAuthenticated } = (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 (!isConnected)
17
+ if (!isAuthenticated)
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,8 +4,6 @@ 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;
9
7
  wallet: import("thirdweb/dist/types/wallets/in-app/core/wallet/types").EcosystemWallet;
10
8
  preAuthenticate: typeof preAuthenticate;
11
9
  connect: (strategyOptions?: import("thirdweb/wallets").SingleStepAuthArgsType) => Promise<import("thirdweb/wallets").Wallet | null>;
@@ -27,10 +27,6 @@ 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);
34
30
  const { connect } = (0, useConnect_1.useConnect)(partnerId, supported_1.b3MainnetThirdWeb);
35
31
  const wallet = (0, wallets_1.ecosystemWallet)(constants_1.ecosystemWalletId, {
36
32
  partnerId: partnerId,
@@ -40,7 +36,6 @@ function useAuthentication(partnerId, loginWithSiwe) {
40
36
  wallets: [wallet],
41
37
  onConnect: async (wallet) => {
42
38
  try {
43
- setIsConnected(true);
44
39
  if (!loginWithSiwe) {
45
40
  debug("Skipping SIWE login", { loginWithSiwe });
46
41
  setIsAuthenticated(true);
@@ -78,22 +73,19 @@ function useAuthentication(partnerId, loginWithSiwe) {
78
73
  (0, react_2.useEffect)(() => {
79
74
  if (useAutoConnectLoading) {
80
75
  setIsAuthenticating(true);
81
- setIsConnecting(true);
82
76
  }
83
77
  else if (!isAuthenticated) {
84
78
  // Only set isAuthenticating to false if we're not authenticated
85
79
  // This prevents the flicker state where both isAuthenticating and isAuthenticated are false
86
80
  const timeout = setTimeout(() => {
87
81
  setIsAuthenticating(false);
88
- setIsConnecting(false);
89
82
  }, 100); // Add a small delay to prevent quick flickers
90
83
  return () => clearTimeout(timeout);
91
84
  }
92
85
  else {
93
86
  setIsAuthenticating(false);
94
- setIsConnecting(false);
95
87
  }
96
- }, [useAutoConnectLoading, isAuthenticated, setIsAuthenticating, setIsConnecting, setIsConnected]);
88
+ }, [useAutoConnectLoading, isAuthenticated, setIsAuthenticating]);
97
89
  const logout = async (callback) => {
98
90
  if (activeWallet) {
99
91
  debug("@@logout:activeWallet", activeWallet);
@@ -116,7 +108,6 @@ function useAuthentication(partnerId, loginWithSiwe) {
116
108
  app_1.default.logout();
117
109
  debug("@@logout:loggedOut");
118
110
  setIsAuthenticated(false);
119
- setIsConnected(false);
120
111
  setUser();
121
112
  callback?.();
122
113
  };
@@ -126,8 +117,6 @@ function useAuthentication(partnerId, loginWithSiwe) {
126
117
  isAuthenticating: useAutoConnectLoading || isAuthenticating,
127
118
  isAuthenticated,
128
119
  isReady,
129
- isConnecting,
130
- isConnected,
131
120
  wallet,
132
121
  preAuthenticate: in_app_1.preAuthenticate,
133
122
  connect,
@@ -7,14 +7,10 @@ interface AuthState {
7
7
  chain?: Chain;
8
8
  isAuthenticating: boolean;
9
9
  isAuthenticated: boolean;
10
- isConnecting: boolean;
11
- isConnected: boolean;
12
10
  onSuccess?: (account: any) => void;
13
11
  onError?: (error: Error) => void;
14
12
  setB3ModalOpen: (isOpen: boolean) => void;
15
13
  setStep: (step: "login" | "permissions") => void;
16
- setIsConnecting: (isConnecting: boolean) => void;
17
- setIsConnected: (isConnected: boolean) => void;
18
14
  setIsAuthenticating: (isAuthenticating: boolean) => void;
19
15
  setIsAuthenticated: (isAuthenticated: boolean) => void;
20
16
  startAuth: (params: {
@@ -10,14 +10,10 @@ 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,
15
13
  onSuccess: undefined,
16
14
  onError: undefined,
17
15
  setB3ModalOpen: isOpen => set({ isOpen }),
18
16
  setStep: step => set({ step }),
19
- setIsConnecting: isConnecting => set({ isConnecting }),
20
- setIsConnected: isConnected => set({ isConnected }),
21
17
  setIsAuthenticating: isAuthenticating => set({ isAuthenticating }),
22
18
  setIsAuthenticated: isAuthenticated => set({ isAuthenticated }),
23
19
  startAuth: params => set({
@@ -718,6 +718,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, isMai
718
718
  vendor: vendor,
719
719
  paymentMethod: paymentMethodString,
720
720
  country: geoData?.country || "US",
721
+ ipAddress: geoData?.ip,
721
722
  redirectUrl: window.location.origin === "https://basement.fun" ? "https://basement.fun/deposit" : window.location.origin,
722
723
  },
723
724
  expectedDstAmount: anyspendQuote?.data?.currencyOut?.amount?.toString() || "0",
@@ -300,6 +300,7 @@ 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,
303
304
  redirectUrl: window.location.origin === "https://basement.fun"
304
305
  ? "https://basement.fun/deposit"
305
306
  : window.location.origin,
@@ -73,6 +73,7 @@ function PanelOnrampPaymentInner(props) {
73
73
  vendor: vendor,
74
74
  paymentMethod: paymentMethod || "",
75
75
  country: geoData?.country || "US",
76
+ ipAddress: geoData?.ip,
76
77
  redirectUrl: window.location.origin === "https://basement.fun" ? "https://basement.fun/deposit" : window.location.origin,
77
78
  },
78
79
  expectedDstAmount: anyspendQuote?.data?.currencyOut?.amount?.toString() || "0",
@@ -128,6 +128,7 @@ function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinat
128
128
  vendor: "stripe-web2",
129
129
  paymentMethod: "",
130
130
  country: geoData.country || "US",
131
+ ipAddress: geoData.ip,
131
132
  redirectUrl: `${window.location.origin}${userId ? `?userId=${userId}` : ""}`,
132
133
  },
133
134
  expectedDstAmount: anyspendQuote.data?.currencyOut?.amount?.toString() || "0",
@@ -5,6 +5,7 @@ export type OnrampOptions = {
5
5
  paymentMethod: string;
6
6
  country: string;
7
7
  redirectUrl: string;
8
+ ipAddress?: string;
8
9
  };
9
10
  export type CreateOnrampOrderParams = Omit<CreateOrderParams, "srcChain" | "srcToken" | "srcAmount"> & {
10
11
  srcFiatAmount: string;
@@ -21,6 +21,10 @@ 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
+ }
24
28
  // Validate required onramp fields
25
29
  if (!onramp.vendor || !onramp.country) {
26
30
  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, srcFiatAmount, visitorData);
16
+ const { isStripeOnrampSupported, stripeWeb2Support, isLoadingStripeSupport, stripeSupportError } = useStripeSupport(isMainnet, geoData?.ip || "", 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, usdAmount?: string, visitorData?: VisitorData, isLoadingVisitorData?: boolean): {
2
+ export declare function useStripeSupport(isMainnet: boolean, ipAddress: string, 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, usdAmount, visitorData, isLoadingVisitorData) {
4
+ export function useStripeSupport(isMainnet, ipAddress, usdAmount, visitorData, isLoadingVisitorData) {
5
5
  const { data, isLoading, error, refetch } = useQuery({
6
- queryKey: ["useStripeSupport", isMainnet, usdAmount, visitorData?.requestId, visitorData?.visitorId],
7
- queryFn: () => anyspendService.checkStripeSupport(isMainnet, usdAmount, visitorData),
8
- enabled: !isLoadingVisitorData,
6
+ queryKey: ["useStripeSupport", isMainnet, ipAddress, usdAmount, visitorData?.requestId, visitorData?.visitorId],
7
+ queryFn: () => anyspendService.checkStripeSupport(isMainnet, ipAddress, usdAmount, visitorData),
8
+ enabled: !!ipAddress && !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, usdAmount?: string, visitorData?: VisitorData) => Promise<{
33
+ checkStripeSupport: (isMainnet: boolean, ipAddress: string, usdAmount?: string, visitorData?: VisitorData) => Promise<{
34
34
  stripeOnramp: boolean;
35
35
  stripeWeb2: components["schemas"]["StripeWeb2Support"];
36
36
  }>;
@@ -90,8 +90,9 @@ export const anyspendService = {
90
90
  const data = await response.json();
91
91
  return data;
92
92
  },
93
- checkStripeSupport: async (isMainnet, usdAmount, visitorData) => {
93
+ checkStripeSupport: async (isMainnet, ipAddress, usdAmount, visitorData) => {
94
94
  const params = new URLSearchParams({
95
+ ipAddress,
95
96
  usdAmount: usdAmount || "",
96
97
  });
97
98
  const response = await fetch(`${isMainnet ? ANYSPEND_MAINNET_BASE_URL : ANYSPEND_TESTNET_BASE_URL}/onramp/stripe/supported?${params.toString()}`, {
@@ -238,7 +238,12 @@ export interface paths {
238
238
  */
239
239
  get: {
240
240
  parameters: {
241
- query?: {
241
+ query: {
242
+ /**
243
+ * @description IP address to check location-based support
244
+ * @example 192.168.1.1
245
+ */
246
+ ipAddress: string;
242
247
  /**
243
248
  * @description Optional USD amount for transaction limit checks
244
249
  * @example 100.00
@@ -898,6 +903,11 @@ export interface components {
898
903
  * @example
899
904
  */
900
905
  paymentMethod?: string;
906
+ /**
907
+ * @description User's IP address
908
+ * @example 96.225.86.216
909
+ */
910
+ ipAddress?: string;
901
911
  /**
902
912
  * @description Redirect URL after payment
903
913
  * @example https://www.anyspend.com
@@ -926,6 +936,11 @@ export interface components {
926
936
  * @example SG
927
937
  */
928
938
  country?: string;
939
+ /**
940
+ * @description User's IP address
941
+ * @example 149.88.23.87
942
+ */
943
+ ipAddress?: string;
929
944
  /**
930
945
  * @description URL to redirect after payment
931
946
  * @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, isConnected } = useAuthentication(props.partnerId, props.loginWithSiwe);
9
+ const { isAuthenticating, isAuthenticated } = 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 (isConnected) {
24
+ if (isAuthenticated) {
25
25
  return _jsx(ManageAccountButton, { ...props });
26
26
  }
27
27
  if (isAuthenticating) {