@b3dotfun/sdk 0.0.1-alpha.8 → 0.0.3-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.
Files changed (75) hide show
  1. package/dist/cjs/anyspend/react/components/AnySpend.d.ts +2 -1
  2. package/dist/cjs/anyspend/react/components/AnySpend.js +4 -4
  3. package/dist/cjs/anyspend/react/components/AnySpendBuySpin.d.ts +2 -1
  4. package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +124 -53
  5. package/dist/cjs/global-account/react/components/B3DynamicModal.js +2 -2
  6. package/dist/cjs/global-account/react/components/{B3Provider.d.ts → B3Provider/B3Provider.d.ts} +3 -29
  7. package/dist/cjs/global-account/react/components/{B3Provider.js → B3Provider/B3Provider.js} +6 -34
  8. package/dist/{esm/global-account/react/components → cjs/global-account/react/components/B3Provider}/B3Provider.native.d.ts +2 -25
  9. package/dist/cjs/global-account/react/components/{B3Provider.native.js → B3Provider/B3Provider.native.js} +5 -28
  10. package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +25 -0
  11. package/dist/cjs/global-account/react/components/B3Provider/types.js +20 -0
  12. package/dist/cjs/global-account/react/components/B3Provider/useB3.d.ts +5 -0
  13. package/dist/cjs/global-account/react/components/B3Provider/useB3.js +17 -0
  14. package/dist/cjs/global-account/react/components/StyleRoot.js +2 -2
  15. package/dist/cjs/global-account/react/components/index.d.ts +8 -6
  16. package/dist/cjs/global-account/react/components/index.js +18 -16
  17. package/dist/cjs/global-account/react/index.native.d.ts +5 -3
  18. package/dist/cjs/global-account/react/index.native.js +10 -6
  19. package/dist/cjs/global-account/react/stores/useModalStore.d.ts +2 -0
  20. package/dist/cjs/global-account/types/chain-networks.d.ts +34 -34
  21. package/dist/cjs/global-account/types/feature-flags.d.ts +5 -5
  22. package/dist/cjs/shared/constants/chains/b3Chain.d.ts +1 -1
  23. package/dist/cjs/shared/constants/chains/supported.d.ts +4 -3
  24. package/dist/cjs/shared/constants/chains/supported.js +3 -1
  25. package/dist/esm/anyspend/react/components/AnySpend.d.ts +2 -1
  26. package/dist/esm/anyspend/react/components/AnySpend.js +4 -4
  27. package/dist/esm/anyspend/react/components/AnySpendBuySpin.d.ts +2 -1
  28. package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +124 -53
  29. package/dist/esm/global-account/react/components/B3DynamicModal.js +1 -1
  30. package/dist/esm/global-account/react/components/{B3Provider.d.ts → B3Provider/B3Provider.d.ts} +3 -29
  31. package/dist/esm/global-account/react/components/{B3Provider.js → B3Provider/B3Provider.js} +5 -32
  32. package/dist/{cjs/global-account/react/components → esm/global-account/react/components/B3Provider}/B3Provider.native.d.ts +2 -25
  33. package/dist/esm/global-account/react/components/{B3Provider.native.js → B3Provider/B3Provider.native.js} +5 -26
  34. package/dist/esm/global-account/react/components/B3Provider/types.d.ts +25 -0
  35. package/dist/esm/global-account/react/components/B3Provider/types.js +17 -0
  36. package/dist/esm/global-account/react/components/B3Provider/useB3.d.ts +5 -0
  37. package/dist/esm/global-account/react/components/B3Provider/useB3.js +14 -0
  38. package/dist/esm/global-account/react/components/StyleRoot.js +1 -1
  39. package/dist/esm/global-account/react/components/index.d.ts +8 -6
  40. package/dist/esm/global-account/react/components/index.js +7 -5
  41. package/dist/esm/global-account/react/index.native.d.ts +5 -3
  42. package/dist/esm/global-account/react/index.native.js +5 -3
  43. package/dist/esm/global-account/react/stores/useModalStore.d.ts +2 -0
  44. package/dist/esm/global-account/types/chain-networks.d.ts +34 -34
  45. package/dist/esm/global-account/types/feature-flags.d.ts +5 -5
  46. package/dist/esm/shared/constants/chains/b3Chain.d.ts +1 -1
  47. package/dist/esm/shared/constants/chains/supported.d.ts +4 -3
  48. package/dist/esm/shared/constants/chains/supported.js +2 -0
  49. package/dist/styles/index.css +1 -1
  50. package/dist/types/anyspend/react/components/AnySpend.d.ts +2 -1
  51. package/dist/types/anyspend/react/components/AnySpendBuySpin.d.ts +2 -1
  52. package/dist/types/global-account/react/components/{B3Provider.d.ts → B3Provider/B3Provider.d.ts} +2 -28
  53. package/dist/types/global-account/react/components/{B3Provider.native.d.ts → B3Provider/B3Provider.native.d.ts} +1 -24
  54. package/dist/types/global-account/react/components/B3Provider/types.d.ts +25 -0
  55. package/dist/types/global-account/react/components/B3Provider/useB3.d.ts +5 -0
  56. package/dist/types/global-account/react/components/index.d.ts +8 -6
  57. package/dist/types/global-account/react/index.native.d.ts +5 -3
  58. package/dist/types/global-account/react/stores/useModalStore.d.ts +2 -0
  59. package/dist/types/global-account/types/chain-networks.d.ts +34 -34
  60. package/dist/types/global-account/types/feature-flags.d.ts +5 -5
  61. package/dist/types/shared/constants/chains/b3Chain.d.ts +1 -1
  62. package/dist/types/shared/constants/chains/supported.d.ts +4 -3
  63. package/package.json +4 -3
  64. package/src/anyspend/react/components/AnySpend.tsx +6 -5
  65. package/src/anyspend/react/components/AnySpendBuySpin.tsx +233 -184
  66. package/src/global-account/react/components/B3DynamicModal.tsx +1 -1
  67. package/src/global-account/react/components/{B3Provider.native.tsx → B3Provider/B3Provider.native.tsx} +4 -45
  68. package/src/global-account/react/components/{B3Provider.tsx → B3Provider/B3Provider.tsx} +4 -53
  69. package/src/global-account/react/components/B3Provider/types.ts +40 -0
  70. package/src/global-account/react/components/B3Provider/useB3.ts +17 -0
  71. package/src/global-account/react/components/StyleRoot.tsx +1 -1
  72. package/src/global-account/react/components/index.ts +8 -6
  73. package/src/global-account/react/index.native.ts +5 -3
  74. package/src/global-account/react/stores/useModalStore.ts +2 -0
  75. package/src/shared/constants/chains/supported.ts +2 -0
@@ -11,7 +11,7 @@ export declare enum PanelView {
11
11
  LOADING = 3,
12
12
  FIAT_PAYMENT = 4
13
13
  }
14
- export declare function AnySpend({ destinationTokenAddress, destinationTokenChainId, isMainnet, mode, defaultActiveTab, loadOrder, hideTransactionHistoryButton }: {
14
+ export declare function AnySpend({ destinationTokenAddress, destinationTokenChainId, isMainnet, mode, defaultActiveTab, loadOrder, hideTransactionHistoryButton, recipientAddress: recipientAddressFromProps }: {
15
15
  destinationTokenAddress?: string;
16
16
  destinationTokenChainId?: number;
17
17
  isMainnet?: boolean;
@@ -19,4 +19,5 @@ export declare function AnySpend({ destinationTokenAddress, destinationTokenChai
19
19
  defaultActiveTab?: "crypto" | "fiat";
20
20
  loadOrder?: string;
21
21
  hideTransactionHistoryButton?: boolean;
22
+ recipientAddress?: string;
22
23
  }): import("react/jsx-runtime").JSX.Element;
@@ -9,8 +9,8 @@ exports.AnySpend = AnySpend;
9
9
  const jsx_runtime_1 = require("react/jsx-runtime");
10
10
  const anyspend_1 = require("../../../anyspend");
11
11
  const react_1 = require("../../../global-account/react");
12
- const formatAddress_1 = require("../../../shared/utils/formatAddress");
13
12
  const cn_1 = require("../../../shared/utils/cn");
13
+ const formatAddress_1 = require("../../../shared/utils/formatAddress");
14
14
  const number_1 = require("../../../shared/utils/number");
15
15
  const framer_motion_1 = require("framer-motion");
16
16
  const invariant_1 = __importDefault(require("invariant"));
@@ -36,7 +36,7 @@ var PanelView;
36
36
  PanelView[PanelView["FIAT_PAYMENT"] = 4] = "FIAT_PAYMENT";
37
37
  })(PanelView || (exports.PanelView = PanelView = {}));
38
38
  const ANYSPEND_RECIPIENTS_KEY = "anyspend_recipients";
39
- function AnySpend({ destinationTokenAddress, destinationTokenChainId, isMainnet = true, mode = "modal", defaultActiveTab = "crypto", loadOrder, hideTransactionHistoryButton }) {
39
+ function AnySpend({ destinationTokenAddress, destinationTokenChainId, isMainnet = true, mode = "modal", defaultActiveTab = "crypto", loadOrder, hideTransactionHistoryButton, recipientAddress: recipientAddressFromProps }) {
40
40
  const searchParams = (0, react_1.useSearchParamsSSR)();
41
41
  const router = (0, react_1.useRouter)();
42
42
  // Determine if we're in "buy mode" based on whether destination token props are provided
@@ -279,8 +279,8 @@ function AnySpend({ destinationTokenAddress, destinationTokenChainId, isMainnet
279
279
  const { address: globalAddress, wallet: globalWallet } = (0, react_1.useAccountWallet)();
280
280
  // Set default recipient address when wallet changes
281
281
  (0, react_2.useEffect)(() => {
282
- setRecipientAddress(globalAddress);
283
- }, [globalAddress]);
282
+ setRecipientAddress(recipientAddressFromProps || globalAddress);
283
+ }, [recipientAddressFromProps, globalAddress]);
284
284
  // Get anyspend price
285
285
  const activeInputAmountInWei = isSrcInputDirty
286
286
  ? (0, viem_1.parseUnits)(srcAmount.replaceAll(",", ""), selectedSrcToken.decimals).toString()
@@ -1,9 +1,10 @@
1
- export declare function AnySpendBuySpin({ isMainnet, loadOrder, mode, spinwheelContractAddress, chainId, recipientAddress, onSuccess }: {
1
+ export declare function AnySpendBuySpin({ isMainnet, loadOrder, mode, spinwheelContractAddress, chainId, recipientAddress, prefillQuantity, onSuccess }: {
2
2
  isMainnet?: boolean;
3
3
  loadOrder?: string;
4
4
  mode?: "modal" | "page";
5
5
  spinwheelContractAddress: string;
6
6
  chainId: number;
7
7
  recipientAddress: string;
8
+ prefillQuantity?: string;
8
9
  onSuccess?: (txHash?: string) => void;
9
10
  }): import("react/jsx-runtime").JSX.Element;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.AnySpendBuySpin = AnySpendBuySpin;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const anyspend_1 = require("../../../anyspend");
9
+ const supported_1 = require("../../../shared/constants/chains/supported");
9
10
  const EthIcon_1 = require("./icons/EthIcon");
10
11
  const SolIcon_1 = require("./icons/SolIcon");
11
12
  const USDCIcon_1 = require("./icons/USDCIcon");
@@ -17,7 +18,6 @@ const lucide_react_1 = require("lucide-react");
17
18
  const react_3 = require("react");
18
19
  const sonner_1 = require("sonner");
19
20
  const viem_1 = require("viem");
20
- const chains_1 = require("viem/chains");
21
21
  const wagmi_1 = require("wagmi");
22
22
  const AnySpendCustom_1 = require("./AnySpendCustom");
23
23
  const SPIN_WHEEL_ABI = [
@@ -49,8 +49,37 @@ const SPIN_WHEEL_ABI = [
49
49
  outputs: [],
50
50
  stateMutability: "payable",
51
51
  type: "function"
52
+ },
53
+ {
54
+ inputs: [],
55
+ name: "getWheelInfo",
56
+ outputs: [
57
+ { internalType: "address", name: "creator_", type: "address" },
58
+ { internalType: "uint256", name: "startTime_", type: "uint256" },
59
+ { internalType: "uint256", name: "endTime_", type: "uint256" },
60
+ { internalType: "uint256", name: "totalPrizesAvailable_", type: "uint256" },
61
+ { internalType: "uint256", name: "prizesRequestedCount_", type: "uint256" },
62
+ { internalType: "enum SpinWheelV2.WheelState", name: "state_", type: "uint8" }
63
+ ],
64
+ stateMutability: "view",
65
+ type: "function"
52
66
  }
53
67
  ];
68
+ function getWheelStatus(wheelInfo) {
69
+ const now = BigInt(Math.floor(Date.now() / 1000));
70
+ console.log("@@anyspend-buy-spin:now:", now);
71
+ console.log("@@anyspend-buy-spin:wheelInfo:", wheelInfo);
72
+ if (now < wheelInfo.startTime_) {
73
+ return "not_started";
74
+ }
75
+ if (now > wheelInfo.endTime_) {
76
+ return "ended";
77
+ }
78
+ if (wheelInfo.totalPrizesAvailable_ <= wheelInfo.prizesRequestedCount_) {
79
+ return "sold_out";
80
+ }
81
+ return "active";
82
+ }
54
83
  function generateEncodedDataForBuyEntriesAndSpin(user, quantity) {
55
84
  (0, invariant_1.default)(BigInt(quantity) > 0, "Quantity must be greater than zero");
56
85
  console.log("@@anyspend-buy-spin:encoded-data:", { user, quantity });
@@ -62,16 +91,17 @@ function generateEncodedDataForBuyEntriesAndSpin(user, quantity) {
62
91
  return encodedData;
63
92
  }
64
93
  const basePublicClient = (0, viem_1.createPublicClient)({
65
- chain: chains_1.base,
94
+ chain: supported_1.baseMainnet,
66
95
  transport: (0, viem_1.http)()
67
96
  });
68
- function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", spinwheelContractAddress, chainId, recipientAddress, onSuccess }) {
97
+ function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", spinwheelContractAddress, chainId, recipientAddress, prefillQuantity, onSuccess }) {
69
98
  const hasMounted = (0, react_2.useHasMounted)();
70
99
  const { setB3ModalOpen } = (0, react_2.useModalStore)();
71
100
  // Payment config state
72
101
  const [paymentConfig, setPaymentConfig] = (0, react_3.useState)(null);
73
102
  const [isLoadingConfig, setIsLoadingConfig] = (0, react_3.useState)(true);
74
103
  const [configError, setConfigError] = (0, react_3.useState)("");
104
+ const [wheelInfo, setWheelInfo] = (0, react_3.useState)(null);
75
105
  // Fetch B3 token balance
76
106
  const { formattedBalance: b3Balance, isLoading: isBalanceLoading, rawBalance: b3RawBalance } = (0, react_2.useTokenBalance)({
77
107
  token: anyspend_1.B3_TOKEN
@@ -83,22 +113,29 @@ function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", spinwhee
83
113
  // State for direct buying flow (when user has B3 tokens)
84
114
  const [isBuying, setIsBuying] = (0, react_3.useState)(false);
85
115
  const [buyingTxHash, setBuyingTxHash] = (0, react_3.useState)("");
86
- const [showSuccessModal, setShowSuccessModal] = (0, react_3.useState)(false);
87
- // Wait for transaction confirmation
88
- const { isLoading: isTxPending, isSuccess: isTxSuccess } = (0, wagmi_1.useWaitForTransactionReceipt)({
116
+ const { isLoading: isTxPending, isSuccess: isTxSuccess, isError: isTxError, error: txError } = (0, wagmi_1.useWaitForTransactionReceipt)({
89
117
  hash: buyingTxHash,
90
118
  query: {
91
119
  structuralSharing: false
92
120
  }
93
121
  });
94
- // Show success modal when transaction is confirmed
122
+ // Handle transaction status
95
123
  (0, react_3.useEffect)(() => {
96
- if (isTxSuccess && buyingTxHash) {
97
- setShowAmountPrompt(false);
98
- setShowSuccessModal(true);
124
+ if (!buyingTxHash)
125
+ return;
126
+ if (isTxSuccess) {
127
+ setB3ModalOpen(false);
128
+ onSuccess?.(buyingTxHash);
129
+ sonner_1.toast.success("Spin purchase transaction confirmed!");
130
+ setIsBuying(false);
131
+ }
132
+ else if (isTxError) {
133
+ console.error("@@anyspend-buy-spin:tx-error:", txError);
134
+ sonner_1.toast.error("Transaction failed. Please try again.");
135
+ setB3ModalOpen(false);
99
136
  setIsBuying(false);
100
137
  }
101
- }, [isTxSuccess, buyingTxHash]);
138
+ }, [isTxSuccess, isTxError, buyingTxHash, onSuccess, setB3ModalOpen, txError]);
102
139
  // Spin quantity state
103
140
  const [userSpinQuantity, setUserSpinQuantity] = (0, react_3.useState)("");
104
141
  const [showAmountPrompt, setShowAmountPrompt] = (0, react_3.useState)(true);
@@ -106,9 +143,17 @@ function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", spinwhee
106
143
  const [validationError, setValidationError] = (0, react_3.useState)("");
107
144
  const [displayQuantity, setDisplayQuantity] = (0, react_3.useState)("");
108
145
  const [debouncedQuantity, setDebouncedQuantity] = (0, react_3.useState)("");
146
+ const [debouncedUserSpinQuantity, setDebouncedUserSpinQuantity] = (0, react_3.useState)("");
147
+ (0, react_3.useEffect)(() => {
148
+ if (prefillQuantity && wheelInfo) {
149
+ const remainingSpins = wheelInfo.totalPrizesAvailable_ - wheelInfo.prizesRequestedCount_;
150
+ const adjustedQuantity = BigInt(prefillQuantity) > remainingSpins ? remainingSpins.toString() : prefillQuantity;
151
+ validateAndSetQuantity(adjustedQuantity);
152
+ }
153
+ }, [prefillQuantity, wheelInfo]);
109
154
  // Calculate total cost
110
155
  const totalCost = paymentConfig && userSpinQuantity ? paymentConfig.pricePerEntry * BigInt(userSpinQuantity) : BigInt(0);
111
- // Fetch payment configuration
156
+ // Fetch payment configuration and wheel info
112
157
  const fetchPaymentConfig = (0, react_3.useCallback)(async () => {
113
158
  if (!basePublicClient || !spinwheelContractAddress)
114
159
  return;
@@ -116,7 +161,7 @@ function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", spinwhee
116
161
  setIsLoadingConfig(true);
117
162
  setConfigError("");
118
163
  console.log("@@anyspend-buy-spin:fetch-config:", { spinwheelContractAddress, chainId });
119
- const [config, entryModuleAddress] = await Promise.all([
164
+ const [config, entryModuleAddress, wheelInfo] = await Promise.all([
120
165
  basePublicClient.readContract({
121
166
  address: spinwheelContractAddress,
122
167
  abi: SPIN_WHEEL_ABI,
@@ -126,6 +171,11 @@ function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", spinwhee
126
171
  address: spinwheelContractAddress,
127
172
  abi: SPIN_WHEEL_ABI,
128
173
  functionName: "entryModule"
174
+ }),
175
+ basePublicClient.readContract({
176
+ address: spinwheelContractAddress,
177
+ abi: SPIN_WHEEL_ABI,
178
+ functionName: "getWheelInfo"
129
179
  })
130
180
  ]);
131
181
  const paymentConfig = {
@@ -134,13 +184,16 @@ function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", spinwhee
134
184
  paymentRecipient: config[3],
135
185
  entryModule: entryModuleAddress
136
186
  };
137
- console.log("@@anyspend-buy-spin:config-fetched:", {
138
- pricePerEntry: paymentConfig.pricePerEntry.toString(),
139
- maxEntriesPerUser: paymentConfig.maxEntriesPerUser.toString(),
140
- paymentRecipient: paymentConfig.paymentRecipient,
141
- entryModule: paymentConfig.entryModule
142
- });
187
+ const wheelInfoData = {
188
+ creator_: wheelInfo[0],
189
+ startTime_: wheelInfo[1],
190
+ endTime_: wheelInfo[2],
191
+ totalPrizesAvailable_: wheelInfo[3],
192
+ prizesRequestedCount_: wheelInfo[4],
193
+ state_: wheelInfo[5]
194
+ };
143
195
  setPaymentConfig(paymentConfig);
196
+ setWheelInfo(wheelInfoData);
144
197
  }
145
198
  catch (error) {
146
199
  console.error("@@anyspend-buy-spin:config-error:", error);
@@ -159,6 +212,7 @@ function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", spinwhee
159
212
  (0, react_3.useEffect)(() => {
160
213
  const timer = setTimeout(() => {
161
214
  setDebouncedQuantity(displayQuantity);
215
+ setDebouncedUserSpinQuantity(userSpinQuantity);
162
216
  }, 500);
163
217
  return () => clearTimeout(timer);
164
218
  }, [displayQuantity, userSpinQuantity]);
@@ -184,14 +238,19 @@ function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", spinwhee
184
238
  return;
185
239
  }
186
240
  // Check maximum entries per user (0 means no limit)
187
- if (paymentConfig &&
188
- paymentConfig.maxEntriesPerUser > BigInt(0) &&
189
- BigInt(numValue) > paymentConfig.maxEntriesPerUser) {
241
+ if (paymentConfig && paymentConfig.maxEntriesPerUser > 0n && BigInt(numValue) > paymentConfig.maxEntriesPerUser) {
190
242
  setIsQuantityValid(false);
191
243
  setUserSpinQuantity("");
192
244
  setValidationError(`Maximum ${paymentConfig.maxEntriesPerUser.toString()} spins allowed`);
193
245
  return;
194
246
  }
247
+ // Check if quantity exceeds remaining entries
248
+ if (wheelInfo && BigInt(numValue) > wheelInfo.totalPrizesAvailable_ - wheelInfo.prizesRequestedCount_) {
249
+ setIsQuantityValid(false);
250
+ setUserSpinQuantity("");
251
+ setValidationError(`Only ${(wheelInfo.totalPrizesAvailable_ - wheelInfo.prizesRequestedCount_).toString()} spins remaining`);
252
+ return;
253
+ }
195
254
  setUserSpinQuantity(value);
196
255
  setIsQuantityValid(true);
197
256
  setValidationError("");
@@ -241,7 +300,7 @@ function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", spinwhee
241
300
  catch (error) {
242
301
  console.error("@@anyspend-buy-spin:error:", error);
243
302
  sonner_1.toast.error("Spin purchase failed. Please try again.");
244
- setShowSuccessModal(false);
303
+ setB3ModalOpen(false);
245
304
  }
246
305
  finally {
247
306
  setIsBuying(false);
@@ -279,46 +338,58 @@ function AnySpendBuySpin({ isMainnet = true, loadOrder, mode = "modal", spinwhee
279
338
  // Render quantity input prompt
280
339
  if (showAmountPrompt) {
281
340
  const pricePerEntry = (0, viem_1.formatUnits)(paymentConfig.pricePerEntry, 18);
341
+ const remainingEntries = wheelInfo ? wheelInfo.totalPrizesAvailable_ - wheelInfo.prizesRequestedCount_ : 0n;
342
+ const wheelStatus = wheelInfo ? getWheelStatus(wheelInfo) : null;
343
+ const isSoldOut = wheelStatus === "sold_out";
344
+ const isActive = wheelStatus === "active";
345
+ const getStatusMessage = () => {
346
+ if (!wheelInfo)
347
+ return null;
348
+ const formatDate = (timestamp) => {
349
+ return new Date(Number(timestamp) * 1000).toLocaleString();
350
+ };
351
+ switch (wheelStatus) {
352
+ case "not_started":
353
+ return {
354
+ title: "Spin Wheel Not Started",
355
+ message: `Starts at ${formatDate(wheelInfo.startTime_)}`
356
+ };
357
+ case "ended":
358
+ return {
359
+ title: "Spin Wheel Ended",
360
+ message: `Ended at ${formatDate(wheelInfo.endTime_)}`
361
+ };
362
+ case "sold_out":
363
+ return {
364
+ title: "All Spins Have Been Claimed",
365
+ message: "Stay tuned for the next spin wheel event!"
366
+ };
367
+ default:
368
+ return null;
369
+ }
370
+ };
371
+ const statusInfo = getStatusMessage();
282
372
  return ((0, jsx_runtime_1.jsx)(react_1.StyleRoot, { children: (0, jsx_runtime_1.jsxs)("div", { className: "bg-b3-react-background flex w-full flex-col items-center", children: [(0, jsx_runtime_1.jsxs)("div", { className: "w-full px-4 pb-2 pt-4", children: [(0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { initial: false, animate: {
283
373
  opacity: hasMounted ? 1 : 0,
284
374
  y: hasMounted ? 0 : 20,
285
375
  filter: hasMounted ? "blur(0px)" : "blur(10px)"
286
- }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "mb-4 flex justify-center", children: (0, jsx_runtime_1.jsx)("img", { alt: "B3 Token", loading: "lazy", width: "64", height: "64", decoding: "async", className: "rounded-full", src: "https://cdn.b3.fun/b3-coin-3d.png" }) }), (0, jsx_runtime_1.jsxs)(framer_motion_1.motion.div, { initial: false, animate: {
287
- opacity: hasMounted ? 1 : 0,
288
- y: hasMounted ? 0 : 20,
289
- filter: hasMounted ? "blur(0px)" : "blur(10px)"
290
- }, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "text-center", children: [(0, jsx_runtime_1.jsx)("h2", { className: "font-sf-rounded text-as-primary mb-2 text-2xl font-bold", children: (() => {
291
- const hasEnoughBalance = b3RawBalance && totalCost <= b3RawBalance;
292
- return hasEnoughBalance || !debouncedQuantity ? "Buy Spins" : `Swap & Buy Spins`;
293
- })() }), (0, jsx_runtime_1.jsx)("div", { className: "bg-as-on-surface-2/50 inline-flex items-center gap-2 rounded-full border border-white/10 px-3 py-1 backdrop-blur-sm", children: (0, jsx_runtime_1.jsxs)("p", { className: "text-as-primary/80 text-sm", children: [pricePerEntry, " $B3 per spin"] }) })] })] }), (0, jsx_runtime_1.jsxs)(framer_motion_1.motion.div, { initial: false, animate: {
294
- opacity: hasMounted ? 1 : 0,
295
- y: hasMounted ? 0 : 20,
296
- filter: hasMounted ? "blur(0px)" : "blur(10px)"
297
- }, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "space-y-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("p", { className: "text-as-primary/70 text-sm font-medium", children: "Number of spins" }), (0, jsx_runtime_1.jsxs)("span", { className: "text-as-primary/50 flex items-center gap-1 text-sm", children: ["Available: ", isBalanceLoading ? (0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "h-3 w-3 animate-spin" }) : `${b3Balance} B3`] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "relative", children: [(0, jsx_runtime_1.jsx)(react_2.Input, { onFocus: onFocusQuantityInput, type: "text", placeholder: "1", value: displayQuantity, onChange: e => validateAndSetQuantity(e.target.value), className: `h-14 px-4 pr-20 text-lg ${!isQuantityValid && displayQuantity ? "border-as-red" : "border-b3-react-border"}` }), (0, jsx_runtime_1.jsx)("div", { className: "font-pack absolute right-4 top-1/2 -translate-y-1/2 text-lg font-medium text-blue-500/70", children: displayQuantity === "1" ? "Spin" : "Spins" })] }), !isQuantityValid && displayQuantity && (0, jsx_runtime_1.jsx)("p", { className: "text-as-red text-sm", children: validationError }), (0, jsx_runtime_1.jsx)("div", { className: "bg-as-on-surface-2/30 rounded-lg border border-white/10 p-4 backdrop-blur-sm", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/70 text-sm font-medium", children: "Total Cost:" }), (0, jsx_runtime_1.jsx)("div", { className: "flex items-center gap-2", children: (0, jsx_runtime_1.jsxs)("span", { className: "text-as-primary text-lg font-bold", children: [displayQuantity && isQuantityValid ? (0, viem_1.formatUnits)(totalCost, 18) : "0", " B3"] }) })] }) })] }), (0, jsx_runtime_1.jsx)("div", { className: "mt-4", children: (() => {
298
- const hasEnoughBalance = b3RawBalance && totalCost <= b3RawBalance;
299
- if (!hasEnoughBalance && debouncedQuantity) {
300
- return ((0, jsx_runtime_1.jsxs)("div", { className: "bg-as-brand/10 flex flex-col items-center gap-2 rounded-lg p-4 pb-5", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-center gap-2", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-primary text-sm font-semibold", children: "Swap & buy from any token" }), (0, jsx_runtime_1.jsxs)(react_2.TextLoop, { children: [(0, jsx_runtime_1.jsx)(EthIcon_1.EthIcon, { className: "h-8 w-8" }), (0, jsx_runtime_1.jsx)(SolIcon_1.SolIcon, { className: "h-8 w-8" }), (0, jsx_runtime_1.jsx)(USDCIcon_1.UsdcIcon, { className: "h-8 w-8" })] }), (0, jsx_runtime_1.jsx)(lucide_react_1.ArrowRight, { className: "text-as-primary h-4 w-4" }), (0, jsx_runtime_1.jsx)("img", { src: "https://cdn.b3.fun/b3-coin-3d.png", className: "h-7 w-7", alt: "B3 Token" })] }), (0, jsx_runtime_1.jsx)("p", { className: "text-as-primary/50 text-sm font-medium", children: "No problem, we'll help you swap to B3 for your spins!" })] }));
301
- }
302
- })() }), (0, jsx_runtime_1.jsx)(react_2.Button, { onClick: confirmQuantity, disabled: !isQuantityValid || !displayQuantity || isBuying || isTxPending, className: "bg-as-brand hover:bg-as-brand/90 text-as-primary mt-4 h-14 w-full rounded-xl text-lg font-medium", children: isBuying ? "Buying..." : isTxPending ? "Confirming..." : "Continue" })] })] }) }));
303
- }
304
- // Success Modal for Direct Buying
305
- if (showSuccessModal) {
306
- return ((0, jsx_runtime_1.jsx)(react_1.StyleRoot, { children: (0, jsx_runtime_1.jsxs)("div", { className: "bg-b3-react-background flex w-full flex-col items-center", children: [(0, jsx_runtime_1.jsxs)("div", { className: "w-full p-4", children: [(0, jsx_runtime_1.jsxs)(framer_motion_1.motion.div, { initial: false, animate: {
307
- opacity: hasMounted ? 1 : 0,
308
- y: hasMounted ? 0 : 20,
309
- filter: hasMounted ? "blur(0px)" : "blur(10px)"
310
- }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative mx-auto mb-4 size-[120px]", children: [(0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 scale-95 rounded-[50%] bg-gradient-to-br from-green-500/30 to-blue-500/30 blur-xl" }), (0, jsx_runtime_1.jsxs)(react_2.GlareCardRounded, { className: "overflow-hidden rounded-full border-none bg-gradient-to-br from-green-500/10 to-blue-500/10 backdrop-blur-sm", children: [(0, jsx_runtime_1.jsx)("img", { alt: "B3 Token", loading: "lazy", width: "120", height: "120", decoding: "async", "data-nimg": "1", className: "size-full shrink-0 bg-transparent text-transparent", src: "https://cdn.b3.fun/b3-coin-3d.png" }), (0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 rounded-[50%] border border-white/20" })] })] }), (0, jsx_runtime_1.jsxs)(framer_motion_1.motion.div, { initial: false, animate: {
376
+ }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: `flex justify-center ${isActive ? "mb-4" : ""}`, children: (0, jsx_runtime_1.jsx)("img", { alt: "B3 Token", loading: "lazy", width: "64", height: "64", decoding: "async", className: "rounded-full", src: "https://cdn.b3.fun/b3-coin-3d.png" }) }), (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { initial: false, animate: {
311
377
  opacity: hasMounted ? 1 : 0,
312
378
  y: hasMounted ? 0 : 20,
313
379
  filter: hasMounted ? "blur(0px)" : "blur(10px)"
314
- }, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "text-center", children: [(0, jsx_runtime_1.jsx)("h2", { className: "font-sf-rounded mb-3 bg-gradient-to-r from-green-400 to-blue-500 bg-clip-text text-3xl font-bold text-transparent", children: "\uD83C\uDF89 Purchase Complete!" }), (0, jsx_runtime_1.jsx)("div", { className: "bg-as-on-surface-2/50 inline-flex items-center gap-2 rounded-full border border-white/10 px-4 py-2 backdrop-blur-sm", children: (0, jsx_runtime_1.jsxs)("span", { className: "text-as-primary/80 text-sm font-medium", children: [userSpinQuantity, " Spin", userSpinQuantity !== "1" ? "s" : "", " \u2022 ", (0, viem_1.formatUnits)(totalCost, 18), " B3"] }) })] })] }), (0, jsx_runtime_1.jsxs)(framer_motion_1.motion.div, { initial: false, animate: {
380
+ }, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "text-center", children: isActive ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("h2", { className: "font-sf-rounded text-as-primary mb-4 text-2xl font-bold", children: (() => {
381
+ const hasEnoughBalance = b3RawBalance && totalCost <= b3RawBalance;
382
+ return hasEnoughBalance || !debouncedQuantity ? "Buy Spins" : `Swap & Buy Spins`;
383
+ })() }), wheelInfo && ((0, jsx_runtime_1.jsxs)("div", { className: "inline-flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-as-brand/10 border-as-brand/10 inline-flex items-center rounded-full border px-3 py-1", children: (0, jsx_runtime_1.jsxs)("p", { className: "text-as-brand text-sm font-medium", children: [pricePerEntry, " $B3 per spin"] }) }), (0, jsx_runtime_1.jsx)("div", { className: "bg-as-brand/10 border-as-brand/10 inline-flex items-center rounded-full border px-3 py-1", children: (0, jsx_runtime_1.jsxs)("p", { className: "text-as-brand text-sm font-medium", children: [remainingEntries.toString(), " remaining"] }) })] }))] })) : (statusInfo && ((0, jsx_runtime_1.jsxs)("div", { className: "text-center", children: [(0, jsx_runtime_1.jsx)("p", { className: "text-as-primary text-lg font-semibold", children: statusInfo.title }), (0, jsx_runtime_1.jsx)("p", { className: "text-as-primary/70 mt-2 text-sm", children: statusInfo.message })] }))) })] }), (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { initial: false, animate: {
315
384
  opacity: hasMounted ? 1 : 0,
316
385
  y: hasMounted ? 0 : 20,
317
386
  filter: hasMounted ? "blur(0px)" : "blur(10px)"
318
- }, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: [(0, jsx_runtime_1.jsx)("div", { className: "mb-6", children: (0, jsx_runtime_1.jsx)("a", { href: `https://basescan.org/tx/${buyingTxHash}`, target: "_blank", rel: "noopener noreferrer", className: "text-as-primary/70 hover:text-as-primary block break-all text-center font-mono text-sm underline transition-colors", children: "View transaction" }) }), (0, jsx_runtime_1.jsx)(react_2.Button, { onClick: () => {
319
- setB3ModalOpen(false);
320
- onSuccess?.(buyingTxHash);
321
- }, className: "bg-as-brand hover:bg-as-brand/90 text-as-primary h-14 w-full rounded-xl text-lg font-medium", children: "Done" })] })] }) }));
387
+ }, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: isActive ? ((0, jsx_runtime_1.jsxs)("div", { className: "space-y-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("p", { className: "text-as-primary/70 text-sm font-medium", children: "Number of spins" }), (0, jsx_runtime_1.jsxs)("span", { className: "text-as-primary/50 flex items-center gap-1 text-sm", children: ["Available: ", isBalanceLoading ? (0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "h-3 w-3 animate-spin" }) : `${b3Balance} B3`] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "relative", children: [(0, jsx_runtime_1.jsx)(react_2.Input, { onFocus: onFocusQuantityInput, type: "text", placeholder: "1", value: displayQuantity, onChange: e => validateAndSetQuantity(e.target.value), className: `h-14 px-4 pr-20 text-lg ${!isQuantityValid && displayQuantity ? "border-as-red" : "border-b3-react-border"}` }), (0, jsx_runtime_1.jsx)("div", { className: "font-pack absolute right-4 top-1/2 -translate-y-1/2 text-lg font-medium text-blue-500/70", children: displayQuantity === "1" ? "Spin" : "Spins" })] }), !isQuantityValid && displayQuantity && (0, jsx_runtime_1.jsx)("p", { className: "text-as-red text-sm", children: validationError }), (0, jsx_runtime_1.jsx)("div", { className: "bg-as-on-surface-2/30 rounded-lg border border-white/10 p-4 backdrop-blur-sm", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/70 text-sm font-medium", children: "Total Cost:" }), (0, jsx_runtime_1.jsx)("div", { className: "flex items-center gap-2", children: (0, jsx_runtime_1.jsxs)("span", { className: "text-as-primary text-lg font-bold", children: [displayQuantity && isQuantityValid ? (0, viem_1.formatUnits)(totalCost, 18) : "0", " B3"] }) })] }) }), (0, jsx_runtime_1.jsx)("div", { className: "mt-4", children: (() => {
388
+ const hasEnoughBalance = b3RawBalance && totalCost <= b3RawBalance;
389
+ if (!hasEnoughBalance && debouncedQuantity) {
390
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "bg-as-brand/10 flex flex-col items-center gap-2 rounded-lg p-4 pb-5", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-center gap-2", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-primary text-sm font-semibold", children: "Swap & buy from any token" }), (0, jsx_runtime_1.jsxs)(react_2.TextLoop, { children: [(0, jsx_runtime_1.jsx)(EthIcon_1.EthIcon, { className: "h-8 w-8" }), (0, jsx_runtime_1.jsx)(SolIcon_1.SolIcon, { className: "h-8 w-8" }), (0, jsx_runtime_1.jsx)(USDCIcon_1.UsdcIcon, { className: "h-8 w-8" })] }), (0, jsx_runtime_1.jsx)(lucide_react_1.ArrowRight, { className: "text-as-primary h-4 w-4" }), (0, jsx_runtime_1.jsx)("img", { src: "https://cdn.b3.fun/b3-coin-3d.png", className: "h-7 w-7", alt: "B3 Token" })] }), (0, jsx_runtime_1.jsx)("p", { className: "text-as-primary/50 text-sm font-medium", children: "No problem, we'll help you swap to B3 for your spins!" })] }));
391
+ }
392
+ })() }), (0, jsx_runtime_1.jsx)(react_2.Button, { onClick: confirmQuantity, disabled: !isQuantityValid || !displayQuantity || isBuying || isTxPending, className: "bg-as-brand hover:bg-as-brand/90 text-as-primary mt-4 h-14 w-full rounded-xl text-lg font-medium", children: isBuying ? "Buying..." : isTxPending ? "Confirming..." : "Continue" })] })) : null })] }) }));
322
393
  }
323
394
  // AnySpend flow for when user needs to swap to B3
324
395
  const encodedData = generateEncodedDataForBuyEntriesAndSpin(address || "", userSpinQuantity);
@@ -5,7 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("../../../anyspend/react");
6
6
  const react_2 = require("../../../global-account/react");
7
7
  const debug_1 = require("../../../shared/utils/debug");
8
- const B3Provider_1 = require("./B3Provider");
8
+ const useB3_1 = require("./B3Provider/useB3");
9
9
  const ManageAccount_1 = require("./ManageAccount/ManageAccount");
10
10
  const RequestPermissions_1 = require("./RequestPermissions/RequestPermissions");
11
11
  const SignInWithB3Flow_1 = require("./SignInWithB3/SignInWithB3Flow");
@@ -15,7 +15,7 @@ const drawer_1 = require("./ui/drawer");
15
15
  const debug = (0, debug_1.debugB3React)("B3DynamicModal");
16
16
  function B3DynamicModal() {
17
17
  const { isOpen, setB3ModalOpen, contentType, history, navigateBack } = (0, react_2.useModalStore)();
18
- const { theme } = (0, B3Provider_1.useB3)();
18
+ const { theme } = (0, useB3_1.useB3)();
19
19
  const isMobile = (0, react_2.useIsMobile)();
20
20
  let contentClass = `b3-modal ${theme === "dark" ? "dark" : ""}`;
21
21
  let hideCloseButton = false;
@@ -1,34 +1,8 @@
1
- import { User } from "../../../global-account/types/b3-api.types";
2
- import { PermissionsConfig } from "../../../global-account/types/permissions";
3
- import { Account, Wallet } from "thirdweb/wallets";
1
+ import { PermissionsConfig } from "../../../../global-account/types/permissions";
2
+ import { Account } from "thirdweb/wallets";
4
3
  import "@reservoir0x/relay-kit-ui/styles.css";
4
+ import { B3ContextType } from "./types";
5
5
  export declare const wagmiConfig: import("wagmi").Config<readonly [import("viem").Chain, ...import("viem").Chain[]], any, readonly import("wagmi").CreateConnectorFn[]>;
6
- /**
7
- * Context type for B3Provider
8
- */
9
- export interface B3ContextType {
10
- account?: Account;
11
- automaticallySetFirstEoa: boolean;
12
- user?: User;
13
- setAccount: (account: Account) => void;
14
- setWallet: (wallet: Wallet) => void;
15
- wallet?: Wallet;
16
- setUser: (user?: User) => void;
17
- initialized: boolean;
18
- ready: boolean;
19
- environment?: "development" | "production";
20
- defaultPermissions?: PermissionsConfig;
21
- theme: "light" | "dark";
22
- }
23
- /**
24
- * Context for B3 provider
25
- */
26
- export declare const B3Context: import("react").Context<B3ContextType>;
27
- /**
28
- * Hook to access the B3 context
29
- * @throws Error if used outside a B3Provider
30
- */
31
- export declare function useB3(): B3ContextType;
32
6
  /**
33
7
  * Main B3Provider component
34
8
  */
@@ -1,19 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.B3Context = exports.wagmiConfig = void 0;
4
- exports.useB3 = useB3;
3
+ exports.wagmiConfig = void 0;
5
4
  exports.B3Provider = B3Provider;
6
5
  exports.InnerProvider = InnerProvider;
7
6
  const jsx_runtime_1 = require("react/jsx-runtime");
8
- const supported_1 = require("../../../shared/constants/chains/supported");
7
+ const supported_1 = require("../../../../shared/constants/chains/supported");
9
8
  const react_query_1 = require("@tanstack/react-query");
10
9
  const react_1 = require("react");
11
10
  const sonner_1 = require("sonner");
12
11
  const react_2 = require("thirdweb/react");
13
12
  const wagmi_1 = require("wagmi");
14
- const RelayKitProviderWrapper_1 = require("./RelayKitProviderWrapper");
15
- const StyleRoot_1 = require("./StyleRoot");
13
+ const RelayKitProviderWrapper_1 = require("../RelayKitProviderWrapper");
14
+ const StyleRoot_1 = require("../StyleRoot");
16
15
  require("@reservoir0x/relay-kit-ui/styles.css");
16
+ const types_1 = require("./types");
17
17
  /**
18
18
  * Default permissions configuration for B3 provider
19
19
  */
@@ -27,34 +27,6 @@ exports.wagmiConfig = (0, wagmi_1.createConfig)({
27
27
  chains: [supported_1.supportedChains[0], ...supported_1.supportedChains.slice(1)],
28
28
  transports: Object.fromEntries(supported_1.supportedChains.map(chain => [chain.id, (0, wagmi_1.http)()]))
29
29
  });
30
- /**
31
- * Context for B3 provider
32
- */
33
- exports.B3Context = (0, react_1.createContext)({
34
- account: undefined,
35
- automaticallySetFirstEoa: false,
36
- user: undefined,
37
- setAccount: () => { },
38
- setWallet: () => { },
39
- wallet: undefined,
40
- setUser: () => { },
41
- initialized: false,
42
- ready: false,
43
- environment: "development",
44
- theme: "light"
45
- });
46
- /**
47
- * Hook to access the B3 context
48
- * @throws Error if used outside a B3Provider
49
- */
50
- function useB3() {
51
- const context = (0, react_1.useContext)(exports.B3Context);
52
- if (!context.initialized) {
53
- throw new Error("useB3 must be used within a B3Provider");
54
- }
55
- // Return a stable reference
56
- return (0, react_1.useMemo)(() => context, [context]);
57
- }
58
30
  // Create queryClient instance
59
31
  const queryClient = new react_query_1.QueryClient();
60
32
  /**
@@ -98,7 +70,7 @@ function InnerProvider({ children, accountOverride, environment, defaultPermissi
98
70
  }
99
71
  // eslint-disable-next-line react-hooks/exhaustive-deps
100
72
  }, [automaticallySetFirstEoa, wallets]);
101
- return ((0, jsx_runtime_1.jsx)(exports.B3Context.Provider, { value: {
73
+ return ((0, jsx_runtime_1.jsx)(types_1.B3Context.Provider, { value: {
102
74
  account: effectiveAccount,
103
75
  setAccount,
104
76
  setWallet,
@@ -1,29 +1,6 @@
1
- import { PermissionsConfig } from "../../../global-account/types/permissions";
1
+ import { PermissionsConfig } from "../../../../global-account/types/permissions";
2
2
  import { Account } from "thirdweb/wallets";
3
- import { User } from "../../../global-account/types/b3-api.types";
4
- /**
5
- * Context type for B3Provider
6
- */
7
- export interface B3ContextType {
8
- account?: Account;
9
- user?: User;
10
- setAccount: (account: Account) => void;
11
- setUser: (user?: User) => void;
12
- initialized: boolean;
13
- ready: boolean;
14
- environment?: "development" | "production";
15
- defaultPermissions?: PermissionsConfig;
16
- theme: "light" | "dark";
17
- }
18
- /**
19
- * Context for B3 provider
20
- */
21
- export declare const B3Context: import("react").Context<B3ContextType>;
22
- /**
23
- * Hook to access the B3 context
24
- * @throws Error if used outside a B3Provider
25
- */
26
- export declare function useB3(): B3ContextType;
3
+ import { B3ContextType } from "./types";
27
4
  /**
28
5
  * Main B3Provider component
29
6
  */
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.B3Context = void 0;
4
- exports.useB3 = useB3;
5
3
  exports.B3Provider = B3Provider;
6
4
  exports.InnerProvider = InnerProvider;
7
5
  const jsx_runtime_1 = require("react/jsx-runtime");
8
6
  const react_query_1 = require("@tanstack/react-query");
9
7
  const react_1 = require("react");
10
8
  const react_2 = require("thirdweb/react");
9
+ const types_1 = require("./types");
11
10
  /**
12
11
  * Default permissions configuration for B3 provider
13
12
  */
@@ -17,31 +16,6 @@ const DEFAULT_PERMISSIONS = {
17
16
  startDate: new Date(),
18
17
  endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365) // 1 year from now
19
18
  };
20
- /**
21
- * Context for B3 provider
22
- */
23
- exports.B3Context = (0, react_1.createContext)({
24
- account: undefined,
25
- user: undefined,
26
- setAccount: () => { },
27
- setUser: () => { },
28
- initialized: false,
29
- ready: false,
30
- environment: "development",
31
- theme: "light"
32
- });
33
- /**
34
- * Hook to access the B3 context
35
- * @throws Error if used outside a B3Provider
36
- */
37
- function useB3() {
38
- const context = (0, react_1.useContext)(exports.B3Context);
39
- if (!context.initialized) {
40
- throw new Error("useB3 must be used within a B3Provider");
41
- }
42
- // Return a stable reference
43
- return (0, react_1.useMemo)(() => context, [context]);
44
- }
45
19
  // Create queryClient instance
46
20
  const queryClient = new react_query_1.QueryClient();
47
21
  /**
@@ -62,8 +36,11 @@ function InnerProvider({ children, accountOverride, environment, defaultPermissi
62
36
  const setAccount = (account) => {
63
37
  setManuallySetAccount(account);
64
38
  };
65
- return ((0, jsx_runtime_1.jsx)(exports.B3Context.Provider, { value: {
39
+ return ((0, jsx_runtime_1.jsx)(types_1.B3Context.Provider, { value: {
66
40
  account: effectiveAccount,
41
+ automaticallySetFirstEoa: false,
42
+ setWallet: () => { },
43
+ wallet: undefined,
67
44
  setAccount,
68
45
  user,
69
46
  setUser,
@@ -0,0 +1,25 @@
1
+ import { Account } from "thirdweb/wallets";
2
+ import { User } from "../../../../global-account/types/b3-api.types";
3
+ import { Wallet } from "thirdweb/wallets";
4
+ import { PermissionsConfig } from "../../../../global-account/types/permissions";
5
+ /**
6
+ * Context type for B3Provider
7
+ */
8
+ export interface B3ContextType {
9
+ account?: Account;
10
+ automaticallySetFirstEoa: boolean;
11
+ user?: User;
12
+ setAccount: (account: Account) => void;
13
+ setWallet: (wallet: Wallet) => void;
14
+ wallet?: Wallet;
15
+ setUser: (user?: User) => void;
16
+ initialized: boolean;
17
+ ready: boolean;
18
+ environment?: "development" | "production";
19
+ defaultPermissions?: PermissionsConfig;
20
+ theme: "light" | "dark";
21
+ }
22
+ /**
23
+ * Context for B3 provider
24
+ */
25
+ export declare const B3Context: import("react").Context<B3ContextType>;