@b3dotfun/sdk 0.0.47-alpha.2 → 0.0.47-test.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/README.md +6 -225
  2. package/dist/cjs/anyspend/react/components/AnySpendCustom.js +3 -5
  3. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +3 -2
  4. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +15 -64
  5. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.d.ts +6 -2
  6. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +26 -21
  7. package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +2 -0
  8. package/dist/cjs/global-account/react/components/B3Provider/types.js +2 -0
  9. package/dist/cjs/global-account/react/components/ManageAccount/BalanceContent.d.ts +1 -2
  10. package/dist/cjs/global-account/react/components/ManageAccount/BalanceContent.js +2 -2
  11. package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +1 -1
  12. package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +2 -2
  13. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3.js +1 -1
  14. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
  15. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +6 -22
  16. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +1 -2
  17. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +3 -2
  18. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -2
  19. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +10 -45
  20. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.d.ts +1 -2
  21. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +2 -1
  22. package/dist/cjs/global-account/react/components/custom/ManageAccountButton.js +2 -1
  23. package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +51 -2
  24. package/dist/cjs/global-account/react/hooks/useAuthentication.js +141 -81
  25. package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +1 -1
  26. package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.js +2 -1
  27. package/dist/cjs/global-account/react/hooks/useUserQuery.d.ts +58 -0
  28. package/dist/cjs/global-account/react/hooks/useUserQuery.js +86 -0
  29. package/dist/cjs/global-account/react/hooks/useWagmiConfig.d.ts +13 -0
  30. package/dist/cjs/global-account/react/hooks/useWagmiConfig.js +42 -0
  31. package/dist/cjs/global-account/react/stores/useModalStore.d.ts +0 -2
  32. package/dist/cjs/shared/react/hooks/__tests__/useCurrencyConversion.test.js +245 -0
  33. package/dist/cjs/shared/utils/index.d.ts +0 -1
  34. package/dist/cjs/shared/utils/index.js +0 -1
  35. package/dist/esm/anyspend/react/components/AnySpendCustom.js +3 -5
  36. package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +3 -2
  37. package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +19 -68
  38. package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.d.ts +6 -2
  39. package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +24 -19
  40. package/dist/esm/global-account/react/components/B3Provider/types.d.ts +2 -0
  41. package/dist/esm/global-account/react/components/B3Provider/types.js +2 -0
  42. package/dist/esm/global-account/react/components/ManageAccount/BalanceContent.d.ts +1 -2
  43. package/dist/esm/global-account/react/components/ManageAccount/BalanceContent.js +2 -2
  44. package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +1 -1
  45. package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +2 -2
  46. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3.js +2 -2
  47. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
  48. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +7 -23
  49. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +1 -2
  50. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +4 -3
  51. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -2
  52. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +11 -46
  53. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.d.ts +1 -2
  54. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +3 -2
  55. package/dist/esm/global-account/react/components/custom/ManageAccountButton.js +3 -2
  56. package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +51 -2
  57. package/dist/esm/global-account/react/hooks/useAuthentication.js +144 -84
  58. package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +1 -1
  59. package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.js +3 -2
  60. package/dist/esm/global-account/react/hooks/useUserQuery.d.ts +58 -0
  61. package/dist/esm/global-account/react/hooks/useUserQuery.js +83 -0
  62. package/dist/esm/global-account/react/hooks/useWagmiConfig.d.ts +13 -0
  63. package/dist/esm/global-account/react/hooks/useWagmiConfig.js +39 -0
  64. package/dist/esm/global-account/react/stores/useModalStore.d.ts +0 -2
  65. package/dist/esm/shared/react/hooks/__tests__/useCurrencyConversion.test.d.ts +1 -0
  66. package/dist/esm/shared/react/hooks/__tests__/useCurrencyConversion.test.js +243 -0
  67. package/dist/esm/shared/utils/index.d.ts +0 -1
  68. package/dist/esm/shared/utils/index.js +0 -1
  69. package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +3 -2
  70. package/dist/types/global-account/react/components/B3Provider/B3Provider.native.d.ts +6 -2
  71. package/dist/types/global-account/react/components/B3Provider/types.d.ts +2 -0
  72. package/dist/types/global-account/react/components/ManageAccount/BalanceContent.d.ts +1 -2
  73. package/dist/types/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
  74. package/dist/types/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +1 -2
  75. package/dist/types/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -2
  76. package/dist/types/global-account/react/components/SignInWithB3/steps/LoginStepCustom.d.ts +1 -2
  77. package/dist/types/global-account/react/hooks/useAuthentication.d.ts +51 -2
  78. package/dist/types/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +1 -1
  79. package/dist/types/global-account/react/hooks/useUserQuery.d.ts +58 -0
  80. package/dist/types/global-account/react/hooks/useWagmiConfig.d.ts +13 -0
  81. package/dist/types/global-account/react/stores/useModalStore.d.ts +0 -2
  82. package/dist/types/shared/react/hooks/__tests__/useCurrencyConversion.test.d.ts +1 -0
  83. package/dist/types/shared/utils/index.d.ts +0 -1
  84. package/package.json +3 -23
  85. package/src/anyspend/react/components/AnySpendCustom.tsx +3 -5
  86. package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +51 -35
  87. package/src/global-account/react/components/B3Provider/B3Provider.tsx +28 -72
  88. package/src/global-account/react/components/B3Provider/types.ts +4 -0
  89. package/src/global-account/react/components/ManageAccount/BalanceContent.tsx +2 -3
  90. package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +1 -1
  91. package/src/global-account/react/components/SignInWithB3/SignIn.tsx +2 -2
  92. package/src/global-account/react/components/SignInWithB3/SignInWithB3.tsx +2 -2
  93. package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +4 -23
  94. package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +4 -3
  95. package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +8 -46
  96. package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +2 -2
  97. package/src/global-account/react/components/custom/ManageAccountButton.tsx +3 -2
  98. package/src/global-account/react/hooks/useAuthentication.ts +170 -89
  99. package/src/global-account/react/hooks/useHandleConnectWithPrivy.tsx +3 -2
  100. package/src/global-account/react/hooks/useUserQuery.ts +95 -0
  101. package/src/global-account/react/hooks/useWagmiConfig.tsx +44 -0
  102. package/src/global-account/react/stores/useModalStore.ts +0 -2
  103. package/src/shared/utils/index.ts +0 -1
  104. package/dist/cjs/notifications/index.d.ts +0 -3
  105. package/dist/cjs/notifications/index.js +0 -25
  106. package/dist/cjs/notifications/react/hooks/index.d.ts +0 -1
  107. package/dist/cjs/notifications/react/hooks/index.js +0 -17
  108. package/dist/cjs/notifications/react/hooks/useNotifications.d.ts +0 -42
  109. package/dist/cjs/notifications/react/hooks/useNotifications.js +0 -148
  110. package/dist/cjs/notifications/react/index.d.ts +0 -1
  111. package/dist/cjs/notifications/react/index.js +0 -17
  112. package/dist/cjs/notifications/services/api.d.ts +0 -67
  113. package/dist/cjs/notifications/services/api.js +0 -184
  114. package/dist/cjs/notifications/services/index.d.ts +0 -1
  115. package/dist/cjs/notifications/services/index.js +0 -17
  116. package/dist/cjs/notifications/types/index.d.ts +0 -51
  117. package/dist/cjs/notifications/types/index.js +0 -2
  118. package/dist/cjs/shared/utils/auth-token.d.ts +0 -7
  119. package/dist/cjs/shared/utils/auth-token.js +0 -17
  120. package/dist/esm/notifications/index.d.ts +0 -3
  121. package/dist/esm/notifications/index.js +0 -7
  122. package/dist/esm/notifications/react/hooks/index.d.ts +0 -1
  123. package/dist/esm/notifications/react/hooks/index.js +0 -1
  124. package/dist/esm/notifications/react/hooks/useNotifications.d.ts +0 -42
  125. package/dist/esm/notifications/react/hooks/useNotifications.js +0 -145
  126. package/dist/esm/notifications/react/index.d.ts +0 -1
  127. package/dist/esm/notifications/react/index.js +0 -1
  128. package/dist/esm/notifications/services/api.d.ts +0 -67
  129. package/dist/esm/notifications/services/api.js +0 -179
  130. package/dist/esm/notifications/services/index.d.ts +0 -1
  131. package/dist/esm/notifications/services/index.js +0 -1
  132. package/dist/esm/notifications/types/index.d.ts +0 -51
  133. package/dist/esm/shared/utils/auth-token.d.ts +0 -7
  134. package/dist/esm/shared/utils/auth-token.js +0 -11
  135. package/dist/types/notifications/index.d.ts +0 -3
  136. package/dist/types/notifications/react/hooks/index.d.ts +0 -1
  137. package/dist/types/notifications/react/hooks/useNotifications.d.ts +0 -42
  138. package/dist/types/notifications/react/index.d.ts +0 -1
  139. package/dist/types/notifications/services/api.d.ts +0 -67
  140. package/dist/types/notifications/services/index.d.ts +0 -1
  141. package/dist/types/notifications/types/index.d.ts +0 -51
  142. package/dist/types/shared/utils/auth-token.d.ts +0 -7
  143. package/src/notifications/index.ts +0 -9
  144. package/src/notifications/react/hooks/index.ts +0 -1
  145. package/src/notifications/react/hooks/useNotifications.ts +0 -153
  146. package/src/notifications/react/index.ts +0 -1
  147. package/src/notifications/services/api.ts +0 -217
  148. package/src/notifications/services/index.ts +0 -1
  149. package/src/notifications/types/index.ts +0 -58
  150. package/src/shared/utils/auth-token.ts +0 -13
  151. /package/dist/{esm/notifications/types/index.js → cjs/shared/react/hooks/__tests__/useCurrencyConversion.test.d.ts} +0 -0
@@ -0,0 +1,243 @@
1
+ import { describe, it, expect, vi, beforeEach } from "vitest";
2
+ import { renderHook } from "@testing-library/react";
3
+ import { useCurrencyConversion } from "../useCurrencyConversion.js";
4
+ // Mock the external dependencies
5
+ // Store mock rates for different quote currencies
6
+ const mockRates = {};
7
+ // Mock store state
8
+ const mockStoreState = {
9
+ selectedCurrency: "B3",
10
+ baseCurrency: "B3",
11
+ setSelectedCurrency: vi.fn(),
12
+ setBaseCurrency: vi.fn(),
13
+ };
14
+ vi.mock("@b3dotfun/sdk/global-account/react", () => ({
15
+ useExchangeRate: vi.fn((params) => {
16
+ const rate = mockRates[params?.quoteCurrency];
17
+ return { rate };
18
+ }),
19
+ }));
20
+ vi.mock("@b3dotfun/sdk/shared/utils/number", () => ({
21
+ formatDisplayNumber: vi.fn((value) => {
22
+ const num = Number(value);
23
+ if (isNaN(num))
24
+ return "0";
25
+ return num.toLocaleString("en-US", { maximumFractionDigits: 6 });
26
+ }),
27
+ }));
28
+ vi.mock("../../stores/currencyStore", () => ({
29
+ useCurrencyStore: vi.fn((selector) => {
30
+ if (selector) {
31
+ return selector(mockStoreState);
32
+ }
33
+ return mockStoreState;
34
+ }),
35
+ CURRENCY_SYMBOLS: {
36
+ B3: "B3",
37
+ USD: "$",
38
+ EUR: "€",
39
+ GBP: "£",
40
+ JPY: "¥",
41
+ CAD: "C$",
42
+ AUD: "A$",
43
+ ETH: "ETH",
44
+ SOL: "SOL",
45
+ KRW: "₩",
46
+ },
47
+ }));
48
+ describe("useCurrencyConversion", () => {
49
+ beforeEach(() => {
50
+ vi.clearAllMocks();
51
+ // Reset mock rates to default
52
+ Object.keys(mockRates).forEach(key => delete mockRates[key]);
53
+ mockRates.USD = 1.0;
54
+ // Reset store state
55
+ mockStoreState.selectedCurrency = "B3";
56
+ mockStoreState.baseCurrency = "B3";
57
+ });
58
+ describe("formatCurrencyValue", () => {
59
+ it("should format base currency (B3) without conversion", () => {
60
+ mockStoreState.selectedCurrency = "B3";
61
+ mockStoreState.baseCurrency = "B3";
62
+ const { result } = renderHook(() => useCurrencyConversion());
63
+ const formatted = result.current.formatCurrencyValue(100);
64
+ expect(formatted).toContain("B3");
65
+ expect(formatted).toContain("100");
66
+ });
67
+ it("should show base currency when exchange rate is unavailable", () => {
68
+ mockRates.USD = undefined;
69
+ mockStoreState.selectedCurrency = "USD";
70
+ mockStoreState.baseCurrency = "B3";
71
+ const { result } = renderHook(() => useCurrencyConversion());
72
+ const formatted = result.current.formatCurrencyValue(100);
73
+ expect(formatted).toContain("B3");
74
+ expect(formatted).not.toContain("$");
75
+ });
76
+ it("should format USD with prefix symbol", () => {
77
+ mockRates.USD = 2.0;
78
+ mockStoreState.selectedCurrency = "USD";
79
+ mockStoreState.baseCurrency = "B3";
80
+ const { result } = renderHook(() => useCurrencyConversion());
81
+ const formatted = result.current.formatCurrencyValue(100);
82
+ expect(formatted).toMatch(/^\$/);
83
+ expect(formatted).toContain("200");
84
+ });
85
+ it("should format EUR with prefix symbol", () => {
86
+ mockRates.EUR = 1.8;
87
+ mockRates.USD = 2.0;
88
+ mockStoreState.selectedCurrency = "EUR";
89
+ mockStoreState.baseCurrency = "B3";
90
+ const { result } = renderHook(() => useCurrencyConversion());
91
+ const formatted = result.current.formatCurrencyValue(100);
92
+ expect(formatted).toMatch(/^€/);
93
+ });
94
+ it("should format JPY without decimals", () => {
95
+ mockRates.JPY = 150;
96
+ mockRates.USD = 2.0;
97
+ mockStoreState.selectedCurrency = "JPY";
98
+ mockStoreState.baseCurrency = "B3";
99
+ const { result } = renderHook(() => useCurrencyConversion());
100
+ const formatted = result.current.formatCurrencyValue(100);
101
+ expect(formatted).toContain("¥");
102
+ expect(formatted).not.toContain(".");
103
+ });
104
+ it("should format KRW without decimals", () => {
105
+ mockRates.KRW = 1300;
106
+ mockRates.USD = 2.0;
107
+ mockStoreState.selectedCurrency = "KRW";
108
+ mockStoreState.baseCurrency = "B3";
109
+ const { result } = renderHook(() => useCurrencyConversion());
110
+ const formatted = result.current.formatCurrencyValue(100);
111
+ expect(formatted).toContain("₩");
112
+ expect(formatted).not.toContain(".");
113
+ });
114
+ it("should format ETH with suffix symbol", () => {
115
+ mockRates.ETH = 0.0005;
116
+ mockRates.USD = 2.0;
117
+ mockStoreState.selectedCurrency = "ETH";
118
+ mockStoreState.baseCurrency = "B3";
119
+ const { result } = renderHook(() => useCurrencyConversion());
120
+ const formatted = result.current.formatCurrencyValue(100);
121
+ expect(formatted).toContain("ETH");
122
+ expect(formatted).not.toMatch(/^ETH/);
123
+ });
124
+ it("should format SOL with suffix symbol", () => {
125
+ mockRates.SOL = 0.05;
126
+ mockRates.USD = 2.0;
127
+ mockStoreState.selectedCurrency = "SOL";
128
+ mockStoreState.baseCurrency = "B3";
129
+ const { result } = renderHook(() => useCurrencyConversion());
130
+ const formatted = result.current.formatCurrencyValue(100);
131
+ expect(formatted).toContain("SOL");
132
+ expect(formatted).not.toMatch(/^SOL/);
133
+ });
134
+ it("should handle small USD amounts with proper conversion", () => {
135
+ mockRates.USD = 1.5;
136
+ mockStoreState.selectedCurrency = "USD";
137
+ mockStoreState.baseCurrency = "B3";
138
+ const { result } = renderHook(() => useCurrencyConversion());
139
+ const formatted = result.current.formatCurrencyValue(10);
140
+ // 10 * 1.5 = 15
141
+ expect(formatted).toMatch(/^\$/);
142
+ expect(formatted).toContain("15");
143
+ });
144
+ it("should apply correct exchange rate conversion", () => {
145
+ const testRate = 3.5;
146
+ mockRates.USD = testRate;
147
+ mockStoreState.selectedCurrency = "USD";
148
+ mockStoreState.baseCurrency = "B3";
149
+ const { result } = renderHook(() => useCurrencyConversion());
150
+ const inputValue = 100;
151
+ const formatted = result.current.formatCurrencyValue(inputValue);
152
+ expect(formatted).toContain("350");
153
+ });
154
+ });
155
+ describe("return values", () => {
156
+ it("should return selected currency", () => {
157
+ mockStoreState.selectedCurrency = "USD";
158
+ mockStoreState.baseCurrency = "B3";
159
+ const { result } = renderHook(() => useCurrencyConversion());
160
+ expect(result.current.selectedCurrency).toBe("USD");
161
+ });
162
+ it("should return base currency", () => {
163
+ mockStoreState.selectedCurrency = "USD";
164
+ mockStoreState.baseCurrency = "B3";
165
+ const { result } = renderHook(() => useCurrencyConversion());
166
+ expect(result.current.baseCurrency).toBe("B3");
167
+ });
168
+ it("should return exchange rate", () => {
169
+ const testRate = 2.5;
170
+ mockRates.USD = testRate;
171
+ mockStoreState.selectedCurrency = "USD";
172
+ mockStoreState.baseCurrency = "B3";
173
+ const { result } = renderHook(() => useCurrencyConversion());
174
+ expect(result.current.exchangeRate).toBe(testRate);
175
+ });
176
+ it("should return correct currency symbols", () => {
177
+ mockStoreState.selectedCurrency = "EUR";
178
+ mockStoreState.baseCurrency = "B3";
179
+ const { result } = renderHook(() => useCurrencyConversion());
180
+ expect(result.current.selectedCurrencySymbol).toBe("€");
181
+ expect(result.current.baseCurrencySymbol).toBe("B3");
182
+ });
183
+ });
184
+ describe("formatTooltipValue", () => {
185
+ it("should show USD equivalent when displaying base currency", () => {
186
+ mockRates.USD = 1.5;
187
+ mockStoreState.selectedCurrency = "B3";
188
+ mockStoreState.baseCurrency = "B3";
189
+ const { result } = renderHook(() => useCurrencyConversion());
190
+ const tooltip = result.current.formatTooltipValue(100);
191
+ expect(tooltip).toContain("USD");
192
+ expect(tooltip).toContain("150");
193
+ });
194
+ it("should show base currency when displaying other currency", () => {
195
+ mockRates.EUR = 0.9;
196
+ mockRates.USD = 1.2;
197
+ mockStoreState.selectedCurrency = "EUR";
198
+ mockStoreState.baseCurrency = "B3";
199
+ const { result } = renderHook(() => useCurrencyConversion());
200
+ const tooltip = result.current.formatTooltipValue(100);
201
+ expect(tooltip).toContain("B3");
202
+ expect(tooltip).toContain("100");
203
+ });
204
+ it("should handle custom currency for base currency", () => {
205
+ mockRates.USD = 2.0;
206
+ mockRates.EUR = 1.8;
207
+ mockStoreState.selectedCurrency = "EUR";
208
+ mockStoreState.baseCurrency = "B3";
209
+ const { result } = renderHook(() => useCurrencyConversion());
210
+ const tooltip = result.current.formatTooltipValue(100, "B3");
211
+ expect(tooltip).toContain("USD");
212
+ expect(tooltip).toContain("200");
213
+ });
214
+ it("should handle custom currency for non-base currency", () => {
215
+ mockRates.USD = 2.0;
216
+ mockStoreState.selectedCurrency = "USD";
217
+ mockStoreState.baseCurrency = "B3";
218
+ const { result } = renderHook(() => useCurrencyConversion());
219
+ const tooltip = result.current.formatTooltipValue(50, "ETH");
220
+ expect(tooltip).toContain("ETH");
221
+ expect(tooltip).toContain("50");
222
+ });
223
+ it("should handle absolute values for negative amounts", () => {
224
+ mockRates.USD = 1.5;
225
+ mockStoreState.selectedCurrency = "B3";
226
+ mockStoreState.baseCurrency = "B3";
227
+ const { result } = renderHook(() => useCurrencyConversion());
228
+ const tooltip = result.current.formatTooltipValue(-100);
229
+ expect(tooltip).toContain("USD");
230
+ expect(tooltip).toContain("150");
231
+ expect(tooltip).not.toContain("-");
232
+ });
233
+ it("should handle exchange rate unavailable", () => {
234
+ mockRates.USD = undefined;
235
+ mockStoreState.selectedCurrency = "B3";
236
+ mockStoreState.baseCurrency = "B3";
237
+ const { result } = renderHook(() => useCurrencyConversion());
238
+ const tooltip = result.current.formatTooltipValue(100);
239
+ expect(tooltip).toContain("USD");
240
+ expect(tooltip).toContain("100");
241
+ });
242
+ });
243
+ });
@@ -1,4 +1,3 @@
1
- export * from "./auth-token";
2
1
  export * from "./cn";
3
2
  export * from "./formatNumber";
4
3
  export * from "./formatUsername";
@@ -1,5 +1,4 @@
1
1
  // Export utility functions
2
- export * from "./auth-token.js";
3
2
  export * from "./cn.js";
4
3
  export * from "./formatNumber.js";
5
4
  export * from "./formatUsername.js";
@@ -19,12 +19,12 @@ export declare function B3Provider({ theme, children, accountOverride, environme
19
19
  };
20
20
  clientType?: ClientType;
21
21
  rpcUrls?: Record<number, string>;
22
- partnerId?: string;
22
+ partnerId: string;
23
23
  }): import("react/jsx-runtime").JSX.Element;
24
24
  /**
25
25
  * Inner provider component that provides the actual B3Context
26
26
  */
27
- export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, clientType, }: {
27
+ export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, clientType, partnerId, }: {
28
28
  children: React.ReactNode;
29
29
  accountOverride?: Account;
30
30
  environment: B3ContextType["environment"];
@@ -32,4 +32,5 @@ export declare function InnerProvider({ children, accountOverride, environment,
32
32
  automaticallySetFirstEoa: boolean;
33
33
  theme: "light" | "dark";
34
34
  clientType?: ClientType;
35
+ partnerId: string;
35
36
  }): import("react/jsx-runtime").JSX.Element;
@@ -5,21 +5,25 @@ import { B3ContextType } from "./types";
5
5
  /**
6
6
  * Main B3Provider component
7
7
  */
8
- export declare function B3Provider({ theme, children, accountOverride, environment, clientType, }: {
8
+ export declare function B3Provider({ theme, children, accountOverride, environment, clientType, partnerId, rpcUrls, }: {
9
9
  theme: "light" | "dark";
10
10
  children: React.ReactNode;
11
11
  accountOverride?: Account;
12
12
  environment: B3ContextType["environment"];
13
13
  clientType?: ClientType;
14
+ partnerId: string;
15
+ rpcUrls?: Record<number, string>;
14
16
  }): import("react/jsx-runtime").JSX.Element;
15
17
  /**
16
18
  * Inner provider component that provides the actual B3Context
17
19
  */
18
- export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, theme, clientType, }: {
20
+ export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, theme, clientType, partnerId, rpcUrls, }: {
19
21
  children: React.ReactNode;
20
22
  accountOverride?: Account;
21
23
  environment: B3ContextType["environment"];
22
24
  defaultPermissions?: PermissionsConfig;
23
25
  theme: "light" | "dark";
24
26
  clientType?: ClientType;
27
+ partnerId: string;
28
+ rpcUrls?: Record<number, string>;
25
29
  }): import("react/jsx-runtime").JSX.Element;
@@ -12,12 +12,14 @@ export interface B3ContextType {
12
12
  setWallet: (wallet: Wallet) => void;
13
13
  wallet?: Wallet;
14
14
  setUser: (user?: Users) => void;
15
+ refetchUser: () => Promise<any>;
15
16
  initialized: boolean;
16
17
  ready: boolean;
17
18
  environment?: "development" | "production";
18
19
  defaultPermissions?: PermissionsConfig;
19
20
  theme: "light" | "dark";
20
21
  clientType: ClientType;
22
+ partnerId: string;
21
23
  }
22
24
  /**
23
25
  * Context for B3 provider
@@ -1,8 +1,7 @@
1
1
  interface BalanceContentProps {
2
2
  onLogout?: () => void;
3
- partnerId: string;
4
3
  showDeposit?: boolean;
5
4
  showSwap?: boolean;
6
5
  }
7
- export declare function BalanceContent({ onLogout, partnerId, showDeposit, showSwap }: BalanceContentProps): import("react/jsx-runtime").JSX.Element;
6
+ export declare function BalanceContent({ onLogout, showDeposit, showSwap }: BalanceContentProps): import("react/jsx-runtime").JSX.Element;
8
7
  export {};
@@ -3,4 +3,4 @@ import { SignInWithB3ModalProps } from "@b3dotfun/sdk/global-account/react";
3
3
  * Component that manages the authentication flow for Sign In With B3
4
4
  * Handles different login providers, authentication steps, and session key management
5
5
  */
6
- export declare function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin, loginWithSiwe, source, signersEnabled, }: SignInWithB3ModalProps): import("react/jsx-runtime").JSX.Element | null;
6
+ export declare function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin, source, signersEnabled, }: SignInWithB3ModalProps): import("react/jsx-runtime").JSX.Element | null;
@@ -4,8 +4,7 @@ interface SignInWithB3PrivyProps {
4
4
  onError?: (error: Error) => Promise<void>;
5
5
  onSuccess: (account: Account) => Promise<void>;
6
6
  accessToken?: string;
7
- partnerId: string;
8
7
  chain: Chain;
9
8
  }
10
- export declare function SignInWithB3Privy({ onSuccess, onError, partnerId, chain }: SignInWithB3PrivyProps): import("react/jsx-runtime").JSX.Element;
9
+ export declare function SignInWithB3Privy({ onSuccess, onError, chain }: SignInWithB3PrivyProps): import("react/jsx-runtime").JSX.Element;
11
10
  export {};
@@ -9,7 +9,6 @@ interface LoginStepProps {
9
9
  /** Optional callback function called when an error occurs */
10
10
  onError?: (error: Error) => Promise<void>;
11
11
  /** Partner ID used for authentication */
12
- partnerId: string;
13
12
  /** Blockchain chain information */
14
13
  chain: Chain;
15
14
  /** Optional authentication strategy options */
@@ -20,5 +19,5 @@ interface LoginStepContainerProps {
20
19
  partnerId?: string;
21
20
  }
22
21
  export declare function LoginStepContainer({ children, partnerId }: LoginStepContainerProps): import("react/jsx-runtime").JSX.Element;
23
- export declare function LoginStep({ onSuccess, onError, partnerId, chain }: LoginStepProps): import("react/jsx-runtime").JSX.Element;
22
+ export declare function LoginStep({ onSuccess, chain }: LoginStepProps): import("react/jsx-runtime").JSX.Element;
24
23
  export {};
@@ -5,10 +5,9 @@ interface LoginStepCustomProps {
5
5
  automaticallySetFirstEoa: boolean;
6
6
  onSuccess: (account: Account) => Promise<void>;
7
7
  onError?: (error: Error) => Promise<void>;
8
- partnerId: string;
9
8
  chain: Chain;
10
9
  strategies: AllowedStrategy[];
11
10
  maxInitialWallets?: number;
12
11
  }
13
- export declare function LoginStepCustom({ onSuccess, onError, partnerId, chain, strategies, maxInitialWallets, automaticallySetFirstEoa, }: LoginStepCustomProps): import("react/jsx-runtime").JSX.Element;
12
+ export declare function LoginStepCustom({ onSuccess, onError, chain, strategies, maxInitialWallets, automaticallySetFirstEoa, }: LoginStepCustomProps): import("react/jsx-runtime").JSX.Element;
14
13
  export {};
@@ -1,5 +1,6 @@
1
+ import { Wallet } from "thirdweb/wallets";
1
2
  import { preAuthenticate } from "thirdweb/wallets/in-app";
2
- export declare function useAuthentication(partnerId: string, loginWithSiwe?: boolean): {
3
+ export declare function useAuthentication(partnerId: string): {
3
4
  logout: (callback?: () => void) => Promise<void>;
4
5
  isAuthenticated: boolean;
5
6
  isReady: boolean;
@@ -7,6 +8,54 @@ export declare function useAuthentication(partnerId: string, loginWithSiwe?: boo
7
8
  isConnected: boolean;
8
9
  wallet: import("thirdweb/dist/types/wallets/in-app/core/wallet/types").EcosystemWallet;
9
10
  preAuthenticate: typeof preAuthenticate;
10
- connect: (strategyOptions?: import("thirdweb/wallets").SingleStepAuthArgsType) => Promise<import("thirdweb/wallets").Wallet | null>;
11
+ connect: (wallet: Wallet) => Promise<void>;
11
12
  isAuthenticating: boolean;
13
+ onConnect: (wallet: Wallet) => Promise<void>;
14
+ user: {
15
+ email?: string | undefined;
16
+ username?: string | undefined;
17
+ telNumber?: string | undefined;
18
+ ens?: string | undefined;
19
+ avatar?: string | undefined;
20
+ preferences?: {} | undefined;
21
+ referredBy?: string | {} | undefined;
22
+ sourceApp?: string | undefined;
23
+ referralCode?: string | undefined;
24
+ userGroups?: number[] | undefined;
25
+ isMigratedFromBSMNT?: boolean | undefined;
26
+ privyLinkedAccounts?: {
27
+ name?: string | undefined;
28
+ address?: string | undefined;
29
+ email?: string | undefined;
30
+ chain_type?: string | undefined;
31
+ lv?: number | undefined;
32
+ wallet_client_type?: string | undefined;
33
+ smart_wallet_type?: string | undefined;
34
+ subject?: string | undefined;
35
+ type: string;
36
+ }[] | undefined;
37
+ twProfiles?: {
38
+ type: string;
39
+ details: {
40
+ id?: string | undefined;
41
+ name?: string | undefined;
42
+ address?: string | undefined;
43
+ email?: string | undefined;
44
+ phone?: string | undefined;
45
+ username?: string | undefined;
46
+ fid?: string | undefined;
47
+ };
48
+ }[] | undefined;
49
+ _id: string | {};
50
+ userId: string;
51
+ smartAccountAddress: string;
52
+ createdAt: number;
53
+ updatedAt: number;
54
+ partnerIds: {
55
+ privyId?: string | undefined;
56
+ thirdwebId?: string | undefined;
57
+ };
58
+ } | undefined;
59
+ refetchUser: (wallet?: Wallet) => Promise<void>;
60
+ setUser: (newUser?: import("@b3dotfun/b3-api").Users) => void;
12
61
  };
@@ -4,7 +4,7 @@ import { Account } from "thirdweb/wallets";
4
4
  * This essentially wraps our useConnect hook to handle the Privy auth flow.
5
5
  * Currently, this is for the basement-privy strategy
6
6
  */
7
- export declare function useHandleConnectWithPrivy(partnerId: string, chain?: Chain, onSuccess?: (account: Account) => void): {
7
+ export declare function useHandleConnectWithPrivy(chain?: Chain, onSuccess?: (account: Account) => void): {
8
8
  connectTw: () => Promise<import("thirdweb/wallets").Wallet | null | undefined>;
9
9
  isLoading: boolean;
10
10
  fullToken: string | null;
@@ -0,0 +1,58 @@
1
+ import { Users } from "@b3dotfun/b3-api";
2
+ /**
3
+ * NOTE: THIS IS ONLY MEANT FOR INTERNAL USE, from useOnConnect
4
+ *
5
+ * Custom hook to manage user state with react-query
6
+ * This allows for invalidation and refetching of user data
7
+ */
8
+ export declare function useUserQuery(): {
9
+ user: {
10
+ email?: string | undefined;
11
+ username?: string | undefined;
12
+ telNumber?: string | undefined;
13
+ ens?: string | undefined;
14
+ avatar?: string | undefined;
15
+ preferences?: {} | undefined;
16
+ referredBy?: string | {} | undefined;
17
+ sourceApp?: string | undefined;
18
+ referralCode?: string | undefined;
19
+ userGroups?: number[] | undefined;
20
+ isMigratedFromBSMNT?: boolean | undefined;
21
+ privyLinkedAccounts?: {
22
+ name?: string | undefined;
23
+ address?: string | undefined;
24
+ email?: string | undefined;
25
+ chain_type?: string | undefined;
26
+ lv?: number | undefined;
27
+ wallet_client_type?: string | undefined;
28
+ smart_wallet_type?: string | undefined;
29
+ subject?: string | undefined;
30
+ type: string;
31
+ }[] | undefined;
32
+ twProfiles?: {
33
+ type: string;
34
+ details: {
35
+ id?: string | undefined;
36
+ name?: string | undefined;
37
+ address?: string | undefined;
38
+ email?: string | undefined;
39
+ phone?: string | undefined;
40
+ username?: string | undefined;
41
+ fid?: string | undefined;
42
+ };
43
+ }[] | undefined;
44
+ _id: string | {};
45
+ userId: string;
46
+ smartAccountAddress: string;
47
+ createdAt: number;
48
+ updatedAt: number;
49
+ partnerIds: {
50
+ privyId?: string | undefined;
51
+ thirdwebId?: string | undefined;
52
+ };
53
+ } | undefined;
54
+ setUser: (newUser?: Users) => void;
55
+ refetchUser: () => Promise<void>;
56
+ clearUser: () => void;
57
+ queryKey: string[];
58
+ };
@@ -0,0 +1,13 @@
1
+ export declare function useWagmiConfig(partnerId: string, rpcUrls?: Record<number, string>): import("wagmi").Config<readonly [import("viem").Chain, ...import("viem").Chain[]], {
2
+ [k: string]: import("viem").HttpTransport<undefined, false>;
3
+ }, readonly [import("wagmi").CreateConnectorFn<import("thirdweb/dist/types/adapters/eip1193").EIP1193Provider | undefined, {
4
+ connect<withCapabilities extends boolean = false>(parameters?: import("@thirdweb-dev/wagmi-adapter").ConnectionOptions<withCapabilities> | undefined): Promise<{
5
+ accounts: withCapabilities extends true ? readonly {
6
+ address: `0x${string}`;
7
+ capabilities: Record<string, unknown>;
8
+ }[] : readonly `0x${string}`[];
9
+ chainId: number;
10
+ }>;
11
+ }, {
12
+ "thirdweb:lastChainId": number;
13
+ }>]>;
@@ -32,8 +32,6 @@ export interface SignInWithB3ModalProps extends BaseModalProps {
32
32
  sessionKeyAddress?: Address;
33
33
  /** Unique identifier for the partner application */
34
34
  partnerId: string;
35
- /** Whether to authenticate with Sign In With Ethereum */
36
- loginWithSiwe?: boolean;
37
35
  /** Whether to close the modal after successful login */
38
36
  closeAfterLogin?: boolean;
39
37
  /** Source of the sign-in request */
@@ -1,4 +1,3 @@
1
- export * from "./auth-token";
2
1
  export * from "./cn";
3
2
  export * from "./formatNumber";
4
3
  export * from "./formatUsername";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b3dotfun/sdk",
3
- "version": "0.0.47-alpha.2",
3
+ "version": "0.0.47-test.5",
4
4
  "source": "src/index.ts",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "react-native": "./dist/cjs/index.native.js",
@@ -170,26 +170,6 @@
170
170
  "import": "./dist/esm/global-account/server.js",
171
171
  "require": "./dist/cjs/global-account/server.js"
172
172
  },
173
- "./notifications": {
174
- "types": "./dist/types/notifications/index.d.ts",
175
- "import": "./dist/esm/notifications/index.js",
176
- "require": "./dist/cjs/notifications/index.js"
177
- },
178
- "./notifications/react": {
179
- "types": "./dist/types/notifications/react/index.d.ts",
180
- "import": "./dist/esm/notifications/react/index.js",
181
- "require": "./dist/cjs/notifications/react/index.js"
182
- },
183
- "./notifications/services": {
184
- "types": "./dist/types/notifications/services/index.d.ts",
185
- "import": "./dist/esm/notifications/services/index.js",
186
- "require": "./dist/cjs/notifications/services/index.js"
187
- },
188
- "./notifications/types": {
189
- "types": "./dist/types/notifications/types/index.d.ts",
190
- "import": "./dist/esm/notifications/types/index.js",
191
- "require": "./dist/cjs/notifications/types/index.js"
192
- },
193
173
  "./shared/utils": {
194
174
  "types": "./dist/types/shared/utils/index.d.ts",
195
175
  "import": "./dist/esm/shared/utils/index.js",
@@ -301,7 +281,7 @@
301
281
  "@solana/web3.js": "^1.98.2",
302
282
  "@stripe/react-stripe-js": "^3.7.0",
303
283
  "@stripe/stripe-js": "^7.3.1",
304
- "@thirdweb-dev/wagmi-adapter": "^0.2.141",
284
+ "@thirdweb-dev/wagmi-adapter": "0.2.159",
305
285
  "@web3icons/react": "3.16.0",
306
286
  "big.js": "^7.0.1",
307
287
  "class-variance-authority": "0.7.0",
@@ -374,7 +354,7 @@
374
354
  "react": "^18.0.0 || ^19.0.0",
375
355
  "react-dom": "^18.0.0 || ^19.0.0",
376
356
  "react-native-mmkv": "^3.2.0",
377
- "thirdweb": "5.106.0",
357
+ "thirdweb": "5.108.9",
378
358
  "three": "^0.175.0",
379
359
  "viem": "^2.28.1",
380
360
  "wagmi": "^2.14.15"
@@ -395,13 +395,11 @@ function AnySpendCustomInner({
395
395
  useEffect(() => {
396
396
  if (oat?.data?.order.status === "executed" && !onSuccessCalled.current) {
397
397
  console.log("Calling onSuccess");
398
- const relayTxs = oat?.data?.relayTxs;
399
- const lastRelayTxHash = relayTxs?.[relayTxs.length - 1]?.txHash;
400
- const txHash = oat?.data?.executeTx?.txHash || lastRelayTxHash;
398
+ const txHash = oat?.data?.executeTx?.txHash;
401
399
  onSuccess?.(txHash);
402
400
  onSuccessCalled.current = true;
403
401
  }
404
- }, [oat?.data?.order.status, oat?.data?.executeTx?.txHash, oat?.data?.relayTxs, onSuccess]);
402
+ }, [oat?.data?.order.status, oat?.data?.executeTx?.txHash, onSuccess]);
405
403
 
406
404
  // Reset flag when orderId changes
407
405
  useEffect(() => {
@@ -667,7 +665,7 @@ function AnySpendCustomInner({
667
665
  const orderDetailsView = (
668
666
  <div
669
667
  className={cn(
670
- "mx-auto flex w-full flex-col items-center gap-4 p-5",
668
+ "mx-auto flex w-full flex-col items-center gap-4",
671
669
  mode === "modal" && "bg-b3-react-background rounded-xl",
672
670
  )}
673
671
  >