@b3dotfun/sdk 0.0.71-alpha.0 → 0.0.71-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -90,7 +90,7 @@ function StripePaymentForm({ order, onPaymentSuccess, }) {
90
90
  },
91
91
  } }) })), error && ((0, jsx_runtime_1.jsx)("div", { className: "mt-4 rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-600", children: error })), (0, jsx_runtime_1.jsx)("button", { type: "submit", disabled: !stripe || isProcessing, className: "mt-6 w-full rounded-xl bg-blue-600 px-4 py-3 font-medium text-white hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-50", children: isProcessing ? ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-center gap-2", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "h-5 w-5 animate-spin" }), (0, jsx_runtime_1.jsx)("span", { children: "Processing..." })] })) : ((0, jsx_runtime_1.jsx)("span", { children: "Complete Payment" })) })] }) }) }));
92
92
  }
93
- function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinationToken, anyspendQuote, onPaymentSuccess, userId, partnerId, }) {
93
+ function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinationToken, anyspendQuote, onPaymentSuccess, userId, }) {
94
94
  const [createdOrder, setCreatedOrder] = (0, react_3.useState)(null);
95
95
  const orderCreationAttempted = (0, react_3.useRef)(false);
96
96
  const { geoData, stripeWeb2Support, isLoading: isLoadingGeoOnramp } = (0, react_1.useGeoOnrampOptions)(srcAmountOnRamp);
@@ -136,7 +136,6 @@ function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinat
136
136
  redirectUrl: `${window.location.origin}${userId ? `?userId=${userId}` : ""}`,
137
137
  },
138
138
  expectedDstAmount: anyspendQuote.data?.currencyOut?.amount?.toString() || "0",
139
- partnerId,
140
139
  });
141
140
  }
142
141
  catch (err) {
@@ -154,7 +153,6 @@ function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinat
154
153
  createOrder,
155
154
  destinationToken,
156
155
  userId,
157
- partnerId,
158
156
  stripeWeb2Support.isSupport,
159
157
  ]);
160
158
  // Check if all required data is loaded
@@ -4,9 +4,10 @@ exports.useAnyspendCreateOnrampOrder = useAnyspendCreateOnrampOrder;
4
4
  const constants_1 = require("../../../anyspend/constants");
5
5
  const anyspend_1 = require("../../../anyspend/services/anyspend");
6
6
  const utils_1 = require("../../../anyspend/utils");
7
+ const react_1 = require("../../../global-account/react");
7
8
  const fingerprintjs_pro_react_1 = require("@fingerprintjs/fingerprintjs-pro-react");
8
9
  const react_query_1 = require("@tanstack/react-query");
9
- const react_1 = require("react");
10
+ const react_2 = require("react");
10
11
  const viem_1 = require("viem");
11
12
  const chains_1 = require("viem/chains");
12
13
  const useValidatedClientReferenceId_1 = require("./useValidatedClientReferenceId");
@@ -15,6 +16,8 @@ const useValidatedClientReferenceId_1 = require("./useValidatedClientReferenceId
15
16
  * Specifically handles orders that involve fiat-to-crypto onramp functionality
16
17
  */
17
18
  function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
19
+ // Get B3 context values
20
+ const { partnerId } = (0, react_1.useB3)();
18
21
  // Get validated client reference ID from B3 context
19
22
  const validatedClientReferenceId = (0, useValidatedClientReferenceId_1.useValidatedClientReferenceId)();
20
23
  // Get fingerprint data
@@ -25,7 +28,7 @@ function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
25
28
  };
26
29
  const { mutate: createOrder, isPending } = (0, react_query_1.useMutation)({
27
30
  mutationFn: async (params) => {
28
- const { recipientAddress, orderType, dstChain, dstToken, srcFiatAmount, onramp, creatorAddress, expectedDstAmount, nft, tournament, payload, partnerId, } = params;
31
+ const { recipientAddress, orderType, dstChain, dstToken, srcFiatAmount, onramp, creatorAddress, expectedDstAmount, nft, tournament, payload, } = params;
29
32
  try {
30
33
  // Validate required onramp fields
31
34
  if (!onramp.vendor || !onramp.country) {
@@ -88,7 +91,7 @@ function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
88
91
  onError?.(error);
89
92
  },
90
93
  });
91
- return (0, react_1.useMemo)(() => ({
94
+ return (0, react_2.useMemo)(() => ({
92
95
  createOrder,
93
96
  isCreatingOrder: isPending,
94
97
  }), [createOrder, isPending]);
@@ -17,7 +17,6 @@ export type CreateOrderParams = {
17
17
  };
18
18
  creatorAddress?: string;
19
19
  payload?: any;
20
- partnerId?: string;
21
20
  };
22
21
  export type UseAnyspendCreateOrderProps = {
23
22
  onSuccess?: (data: any) => void;
@@ -3,9 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useAnyspendCreateOrder = useAnyspendCreateOrder;
4
4
  const anyspend_1 = require("../../../anyspend/services/anyspend");
5
5
  const utils_1 = require("../../../anyspend/utils");
6
+ const react_1 = require("../../../global-account/react");
6
7
  const fingerprintjs_pro_react_1 = require("@fingerprintjs/fingerprintjs-pro-react");
7
8
  const react_query_1 = require("@tanstack/react-query");
8
- const react_1 = require("react");
9
+ const react_2 = require("react");
9
10
  const useValidatedClientReferenceId_1 = require("./useValidatedClientReferenceId");
10
11
  /**
11
12
  * Hook for creating orders in the Anyspend protocol
@@ -13,6 +14,8 @@ const useValidatedClientReferenceId_1 = require("./useValidatedClientReferenceId
13
14
  * For onramp orders, use useAnyspendCreateOnrampOrder instead.
14
15
  */
15
16
  function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
17
+ // Get B3 context values
18
+ const { partnerId } = (0, react_1.useB3)();
16
19
  // Get validated client reference ID from B3 context
17
20
  const validatedClientReferenceId = (0, useValidatedClientReferenceId_1.useValidatedClientReferenceId)();
18
21
  // Get fingerprint data
@@ -56,6 +59,7 @@ function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
56
59
  },
57
60
  }),
58
61
  creatorAddress: creatorAddress ? (0, utils_1.normalizeAddress)(creatorAddress) : undefined,
62
+ partnerId,
59
63
  clientReferenceId: validatedClientReferenceId,
60
64
  visitorData,
61
65
  });
@@ -76,7 +80,7 @@ function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
76
80
  onError?.(error);
77
81
  },
78
82
  });
79
- return (0, react_1.useMemo)(() => ({
83
+ return (0, react_2.useMemo)(() => ({
80
84
  createOrder,
81
85
  isCreatingOrder: isPending,
82
86
  }), [createOrder, isPending]);
@@ -81,7 +81,8 @@ exports.useCurrencyStore = (0, zustand_1.create)()((0, middleware_1.persist)((se
81
81
  removeCurrency: code => {
82
82
  set(state => {
83
83
  // Remove the currency
84
- const { [code]: _removed, ...remaining } = state.customCurrencies;
84
+ const customCurrencies = state.customCurrencies;
85
+ const remaining = Object.fromEntries(Object.entries(customCurrencies).filter(([key]) => key !== code));
85
86
  // Remove all exchange rates involving this currency
86
87
  const filteredRates = {};
87
88
  for (const [key, rate] of Object.entries(state.customExchangeRates)) {
@@ -84,7 +84,7 @@ function StripePaymentForm({ order, onPaymentSuccess, }) {
84
84
  },
85
85
  } }) })), error && (_jsx("div", { className: "mt-4 rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-600", children: error })), _jsx("button", { type: "submit", disabled: !stripe || isProcessing, className: "mt-6 w-full rounded-xl bg-blue-600 px-4 py-3 font-medium text-white hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-50", children: isProcessing ? (_jsxs("div", { className: "flex items-center justify-center gap-2", children: [_jsx(Loader2, { className: "h-5 w-5 animate-spin" }), _jsx("span", { children: "Processing..." })] })) : (_jsx("span", { children: "Complete Payment" })) })] }) }) }));
86
86
  }
87
- function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinationToken, anyspendQuote, onPaymentSuccess, userId, partnerId, }) {
87
+ function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinationToken, anyspendQuote, onPaymentSuccess, userId, }) {
88
88
  const [createdOrder, setCreatedOrder] = useState(null);
89
89
  const orderCreationAttempted = useRef(false);
90
90
  const { geoData, stripeWeb2Support, isLoading: isLoadingGeoOnramp } = useGeoOnrampOptions(srcAmountOnRamp);
@@ -130,7 +130,6 @@ function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinat
130
130
  redirectUrl: `${window.location.origin}${userId ? `?userId=${userId}` : ""}`,
131
131
  },
132
132
  expectedDstAmount: anyspendQuote.data?.currencyOut?.amount?.toString() || "0",
133
- partnerId,
134
133
  });
135
134
  }
136
135
  catch (err) {
@@ -148,7 +147,6 @@ function WebviewOnrampPaymentInner({ srcAmountOnRamp, recipientAddress, destinat
148
147
  createOrder,
149
148
  destinationToken,
150
149
  userId,
151
- partnerId,
152
150
  stripeWeb2Support.isSupport,
153
151
  ]);
154
152
  // Check if all required data is loaded
@@ -1,6 +1,7 @@
1
1
  import { USDC_BASE } from "../../../anyspend/constants/index.js";
2
2
  import { anyspendService } from "../../../anyspend/services/anyspend.js";
3
3
  import { buildMetadata, buildPayload, normalizeAddress } from "../../../anyspend/utils/index.js";
4
+ import { useB3 } from "../../../global-account/react/index.js";
4
5
  import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
5
6
  import { useMutation } from "@tanstack/react-query";
6
7
  import { useMemo } from "react";
@@ -12,6 +13,8 @@ import { useValidatedClientReferenceId } from "./useValidatedClientReferenceId.j
12
13
  * Specifically handles orders that involve fiat-to-crypto onramp functionality
13
14
  */
14
15
  export function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
16
+ // Get B3 context values
17
+ const { partnerId } = useB3();
15
18
  // Get validated client reference ID from B3 context
16
19
  const validatedClientReferenceId = useValidatedClientReferenceId();
17
20
  // Get fingerprint data
@@ -22,7 +25,7 @@ export function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
22
25
  };
23
26
  const { mutate: createOrder, isPending } = useMutation({
24
27
  mutationFn: async (params) => {
25
- const { recipientAddress, orderType, dstChain, dstToken, srcFiatAmount, onramp, creatorAddress, expectedDstAmount, nft, tournament, payload, partnerId, } = params;
28
+ const { recipientAddress, orderType, dstChain, dstToken, srcFiatAmount, onramp, creatorAddress, expectedDstAmount, nft, tournament, payload, } = params;
26
29
  try {
27
30
  // Validate required onramp fields
28
31
  if (!onramp.vendor || !onramp.country) {
@@ -17,7 +17,6 @@ export type CreateOrderParams = {
17
17
  };
18
18
  creatorAddress?: string;
19
19
  payload?: any;
20
- partnerId?: string;
21
20
  };
22
21
  export type UseAnyspendCreateOrderProps = {
23
22
  onSuccess?: (data: any) => void;
@@ -1,5 +1,6 @@
1
1
  import { anyspendService } from "../../../anyspend/services/anyspend.js";
2
2
  import { buildMetadata, buildPayload, normalizeAddress } from "../../../anyspend/utils/index.js";
3
+ import { useB3 } from "../../../global-account/react/index.js";
3
4
  import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
4
5
  import { useMutation } from "@tanstack/react-query";
5
6
  import { useMemo } from "react";
@@ -10,6 +11,8 @@ import { useValidatedClientReferenceId } from "./useValidatedClientReferenceId.j
10
11
  * For onramp orders, use useAnyspendCreateOnrampOrder instead.
11
12
  */
12
13
  export function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
14
+ // Get B3 context values
15
+ const { partnerId } = useB3();
13
16
  // Get validated client reference ID from B3 context
14
17
  const validatedClientReferenceId = useValidatedClientReferenceId();
15
18
  // Get fingerprint data
@@ -53,6 +56,7 @@ export function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
53
56
  },
54
57
  }),
55
58
  creatorAddress: creatorAddress ? normalizeAddress(creatorAddress) : undefined,
59
+ partnerId,
56
60
  clientReferenceId: validatedClientReferenceId,
57
61
  visitorData,
58
62
  });
@@ -74,7 +74,8 @@ export const useCurrencyStore = create()(persist((set, get) => ({
74
74
  removeCurrency: code => {
75
75
  set(state => {
76
76
  // Remove the currency
77
- const { [code]: _removed, ...remaining } = state.customCurrencies;
77
+ const customCurrencies = state.customCurrencies;
78
+ const remaining = Object.fromEntries(Object.entries(customCurrencies).filter(([key]) => key !== code));
78
79
  // Remove all exchange rates involving this currency
79
80
  const filteredRates = {};
80
81
  for (const [key, rate] of Object.entries(state.customExchangeRates)) {
@@ -17,7 +17,6 @@ export type CreateOrderParams = {
17
17
  };
18
18
  creatorAddress?: string;
19
19
  payload?: any;
20
- partnerId?: string;
21
20
  };
22
21
  export type UseAnyspendCreateOrderProps = {
23
22
  onSuccess?: (data: any) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b3dotfun/sdk",
3
- "version": "0.0.71-alpha.0",
3
+ "version": "0.0.71-alpha.2",
4
4
  "source": "src/index.ts",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "react-native": "./dist/cjs/index.native.js",
@@ -157,7 +157,6 @@ function WebviewOnrampPaymentInner({
157
157
  anyspendQuote,
158
158
  onPaymentSuccess,
159
159
  userId,
160
- partnerId,
161
160
  }: WebviewOnrampPaymentProps) {
162
161
  const [createdOrder, setCreatedOrder] = useState<components["schemas"]["Order"] | null>(null);
163
162
  const orderCreationAttempted = useRef(false);
@@ -214,7 +213,6 @@ function WebviewOnrampPaymentInner({
214
213
  redirectUrl: `${window.location.origin}${userId ? `?userId=${userId}` : ""}`,
215
214
  },
216
215
  expectedDstAmount: anyspendQuote.data?.currencyOut?.amount?.toString() || "0",
217
- partnerId,
218
216
  });
219
217
  } catch (err: any) {
220
218
  console.error(err);
@@ -232,7 +230,6 @@ function WebviewOnrampPaymentInner({
232
230
  createOrder,
233
231
  destinationToken,
234
232
  userId,
235
- partnerId,
236
233
  stripeWeb2Support.isSupport,
237
234
  ]);
238
235
 
@@ -3,6 +3,7 @@ import { anyspendService } from "@b3dotfun/sdk/anyspend/services/anyspend";
3
3
  import { components } from "@b3dotfun/sdk/anyspend/types/api";
4
4
  import { VisitorData } from "@b3dotfun/sdk/anyspend/types/fingerprint";
5
5
  import { buildMetadata, buildPayload, normalizeAddress } from "@b3dotfun/sdk/anyspend/utils";
6
+ import { useB3 } from "@b3dotfun/sdk/global-account/react";
6
7
  import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
7
8
  import { useMutation } from "@tanstack/react-query";
8
9
  import { useMemo } from "react";
@@ -34,6 +35,9 @@ export type UseAnyspendCreateOnrampOrderProps = {
34
35
  * Specifically handles orders that involve fiat-to-crypto onramp functionality
35
36
  */
36
37
  export function useAnyspendCreateOnrampOrder({ onSuccess, onError }: UseAnyspendCreateOnrampOrderProps = {}) {
38
+ // Get B3 context values
39
+ const { partnerId } = useB3();
40
+
37
41
  // Get validated client reference ID from B3 context
38
42
  const validatedClientReferenceId = useValidatedClientReferenceId();
39
43
 
@@ -58,7 +62,6 @@ export function useAnyspendCreateOnrampOrder({ onSuccess, onError }: UseAnyspend
58
62
  nft,
59
63
  tournament,
60
64
  payload,
61
- partnerId,
62
65
  } = params;
63
66
 
64
67
  try {
@@ -2,6 +2,7 @@ import { anyspendService } from "@b3dotfun/sdk/anyspend/services/anyspend";
2
2
  import { components } from "@b3dotfun/sdk/anyspend/types/api";
3
3
  import { VisitorData } from "@b3dotfun/sdk/anyspend/types/fingerprint";
4
4
  import { buildMetadata, buildPayload, normalizeAddress } from "@b3dotfun/sdk/anyspend/utils";
5
+ import { useB3 } from "@b3dotfun/sdk/global-account/react";
5
6
  import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
6
7
  import { useMutation } from "@tanstack/react-query";
7
8
  import { useMemo } from "react";
@@ -20,7 +21,6 @@ export type CreateOrderParams = {
20
21
  tournament?: components["schemas"]["Tournament"] & { contractAddress: string; entryPriceOrFundAmount: string };
21
22
  creatorAddress?: string;
22
23
  payload?: any;
23
- partnerId?: string;
24
24
  };
25
25
 
26
26
  export type UseAnyspendCreateOrderProps = {
@@ -34,6 +34,9 @@ export type UseAnyspendCreateOrderProps = {
34
34
  * For onramp orders, use useAnyspendCreateOnrampOrder instead.
35
35
  */
36
36
  export function useAnyspendCreateOrder({ onSuccess, onError }: UseAnyspendCreateOrderProps = {}) {
37
+ // Get B3 context values
38
+ const { partnerId } = useB3();
39
+
37
40
  // Get validated client reference ID from B3 context
38
41
  const validatedClientReferenceId = useValidatedClientReferenceId();
39
42
 
@@ -79,6 +82,7 @@ export function useAnyspendCreateOrder({ onSuccess, onError }: UseAnyspendCreate
79
82
  },
80
83
  }),
81
84
  creatorAddress: creatorAddress ? normalizeAddress(creatorAddress) : undefined,
85
+ partnerId,
82
86
  clientReferenceId: validatedClientReferenceId,
83
87
  visitorData,
84
88
  });
@@ -147,7 +147,9 @@ export const useCurrencyStore = create<CurrencyState>()(
147
147
  removeCurrency: code => {
148
148
  set(state => {
149
149
  // Remove the currency
150
- const { [code]: _removed, ...remaining } = state.customCurrencies;
150
+ const customCurrencies = state.customCurrencies;
151
+
152
+ const remaining = Object.fromEntries(Object.entries(customCurrencies).filter(([key]) => key !== code));
151
153
 
152
154
  // Remove all exchange rates involving this currency
153
155
  const filteredRates: Record<string, number> = {};