@funkit/connect-rn 0.2.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2694 -0
- package/dist/index.js.map +7 -0
- package/dist/src/flow/FunkitFlowProvider.d.ts +20 -0
- package/dist/src/flow/FunkitFlowProvider.d.ts.map +1 -0
- package/dist/src/flow/depositFlowConfig.d.ts +70 -0
- package/dist/src/flow/depositFlowConfig.d.ts.map +1 -0
- package/dist/src/geo/useUserIpInfo.d.ts +22 -0
- package/dist/src/geo/useUserIpInfo.d.ts.map +1 -0
- package/dist/src/icons/ChainClusterIcon.d.ts +12 -0
- package/dist/src/icons/ChainClusterIcon.d.ts.map +1 -0
- package/dist/src/icons/FunIcon.d.ts +18 -0
- package/dist/src/icons/FunIcon.d.ts.map +1 -0
- package/dist/src/icons/assetLogos.d.ts +12 -0
- package/dist/src/icons/assetLogos.d.ts.map +1 -0
- package/dist/src/icons/funIconUri.d.ts +16 -0
- package/dist/src/icons/funIconUri.d.ts.map +1 -0
- package/dist/src/identity/IdentityContext.d.ts +52 -0
- package/dist/src/identity/IdentityContext.d.ts.map +1 -0
- package/dist/src/logging/consoleLogTransport.d.ts +10 -0
- package/dist/src/logging/consoleLogTransport.d.ts.map +1 -0
- package/dist/src/logging/datadogHttpLogTransport.d.ts +46 -0
- package/dist/src/logging/datadogHttpLogTransport.d.ts.map +1 -0
- package/dist/src/logging/logger.d.ts +9 -0
- package/dist/src/logging/logger.d.ts.map +1 -0
- package/dist/src/providers/FunkitProvider.d.ts +55 -0
- package/dist/src/providers/FunkitProvider.d.ts.map +1 -0
- package/dist/src/providers/FunkitStatsigProvider.d.ts +13 -0
- package/dist/src/providers/FunkitStatsigProvider.d.ts.map +1 -0
- package/dist/src/providers/index.d.ts +2 -0
- package/dist/src/providers/index.d.ts.map +1 -0
- package/dist/src/providers/useFunkitCheckout.d.ts +14 -0
- package/dist/src/providers/useFunkitCheckout.d.ts.map +1 -0
- package/dist/src/screens/AddMoneyScreen.d.ts +31 -0
- package/dist/src/screens/AddMoneyScreen.d.ts.map +1 -0
- package/dist/src/screens/ChooseChainScreen.d.ts +35 -0
- package/dist/src/screens/ChooseChainScreen.d.ts.map +1 -0
- package/dist/src/screens/CryptoCashToggle.d.ts +17 -0
- package/dist/src/screens/CryptoCashToggle.d.ts.map +1 -0
- package/dist/src/screens/QrCodeScreen.d.ts +26 -0
- package/dist/src/screens/QrCodeScreen.d.ts.map +1 -0
- package/dist/src/screens/SupportedTokensScreen.d.ts +44 -0
- package/dist/src/screens/SupportedTokensScreen.d.ts.map +1 -0
- package/dist/src/screens/TransferCryptoScreen.d.ts +29 -0
- package/dist/src/screens/TransferCryptoScreen.d.ts.map +1 -0
- package/dist/src/statsig/StatsigClientRN.d.ts +6 -0
- package/dist/src/statsig/StatsigClientRN.d.ts.map +1 -0
- package/dist/src/statsig/StatsigProviderRN.d.ts +7 -0
- package/dist/src/statsig/StatsigProviderRN.d.ts.map +1 -0
- package/dist/src/statsig/appVisibilityShim.d.ts +2 -0
- package/dist/src/statsig/appVisibilityShim.d.ts.map +1 -0
- package/dist/src/statsig/preloadedAsyncStorage.d.ts +3 -0
- package/dist/src/statsig/preloadedAsyncStorage.d.ts.map +1 -0
- package/dist/src/statsig/rnSetup.d.ts +3 -0
- package/dist/src/statsig/rnSetup.d.ts.map +1 -0
- package/dist/src/statsig/statsigMetadata.d.ts +2 -0
- package/dist/src/statsig/statsigMetadata.d.ts.map +1 -0
- package/dist/src/statsig/useClientAsyncInitRN.d.ts +7 -0
- package/dist/src/statsig/useClientAsyncInitRN.d.ts.map +1 -0
- package/dist/src/statsig/useClientBootstrapInitRN.d.ts +4 -0
- package/dist/src/statsig/useClientBootstrapInitRN.d.ts.map +1 -0
- package/dist/src/swapped/SwappedScreen.d.ts +21 -0
- package/dist/src/swapped/SwappedScreen.d.ts.map +1 -0
- package/dist/src/swapped/SwappedWebView.d.ts +18 -0
- package/dist/src/swapped/SwappedWebView.d.ts.map +1 -0
- package/dist/src/swapped/webViewSwappedTransport.d.ts +47 -0
- package/dist/src/swapped/webViewSwappedTransport.d.ts.map +1 -0
- package/dist/src/theme/FunkitProvider.d.ts +45 -0
- package/dist/src/theme/FunkitProvider.d.ts.map +1 -0
- package/dist/src/theme/FunkitThemeProvider.d.ts +50 -0
- package/dist/src/theme/FunkitThemeProvider.d.ts.map +1 -0
- package/dist/src/theme/index.d.ts +7 -0
- package/dist/src/theme/index.d.ts.map +1 -0
- package/dist/src/theme/restyle.d.ts +5125 -0
- package/dist/src/theme/restyle.d.ts.map +1 -0
- package/dist/src/theme/toRestyleTheme.d.ts +448 -0
- package/dist/src/theme/toRestyleTheme.d.ts.map +1 -0
- package/dist/src/theme/tokens.d.ts +115 -0
- package/dist/src/theme/tokens.d.ts.map +1 -0
- package/dist/src/theme/useColorScheme.d.ts +25 -0
- package/dist/src/theme/useColorScheme.d.ts.map +1 -0
- package/dist/src/theme/useFunkitTheme.d.ts +29 -0
- package/dist/src/theme/useFunkitTheme.d.ts.map +1 -0
- package/dist/src/transfer/QrCode.d.ts +15 -0
- package/dist/src/transfer/QrCode.d.ts.map +1 -0
- package/dist/src/transfer/clipboard.d.ts +15 -0
- package/dist/src/transfer/clipboard.d.ts.map +1 -0
- package/dist/src/transfer/fops.d.ts +26 -0
- package/dist/src/transfer/fops.d.ts.map +1 -0
- package/dist/src/transfer/formatDepositAddress.d.ts +9 -0
- package/dist/src/transfer/formatDepositAddress.d.ts.map +1 -0
- package/dist/src/transfer/hooks/useFops.d.ts +38 -0
- package/dist/src/transfer/hooks/useFops.d.ts.map +1 -0
- package/dist/src/transfer/hooks/useSupportedTokens.d.ts +26 -0
- package/dist/src/transfer/hooks/useSupportedTokens.d.ts.map +1 -0
- package/dist/src/transfer/hooks/useTokenTransfer.d.ts +33 -0
- package/dist/src/transfer/hooks/useTokenTransfer.d.ts.map +1 -0
- package/dist/src/transfer/hooks/useTransferInit.d.ts +27 -0
- package/dist/src/transfer/hooks/useTransferInit.d.ts.map +1 -0
- package/dist/src/transfer/hooks/useUDAParams.d.ts +9 -0
- package/dist/src/transfer/hooks/useUDAParams.d.ts.map +1 -0
- package/dist/src/transfer/supportedTokens.d.ts +23 -0
- package/dist/src/transfer/supportedTokens.d.ts.map +1 -0
- package/dist/src/version.d.ts +2 -0
- package/dist/src/version.d.ts.map +1 -0
- package/package.json +80 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2694 @@
|
|
|
1
|
+
// index.ts
|
|
2
|
+
export * from "@funkit/connect-core";
|
|
3
|
+
|
|
4
|
+
// src/theme/tokens.ts
|
|
5
|
+
var lightTokens = {
|
|
6
|
+
colors: {
|
|
7
|
+
bgModal: "#FFFFFF",
|
|
8
|
+
bgSecondary: "#F9F9F9",
|
|
9
|
+
btnPrimary: "#0F0F0F",
|
|
10
|
+
btnPrimaryHover: "#1B1B1B",
|
|
11
|
+
btnPrimaryPressed: "#1B1B1B",
|
|
12
|
+
btnPrimaryFocused: "#0F0F0F",
|
|
13
|
+
btnPrimaryDisabled: "#0F0F0F",
|
|
14
|
+
btnSecondary: "#F9F9F9",
|
|
15
|
+
btnSecondaryHover: "#EFEFEF",
|
|
16
|
+
btnSecondaryPressed: "#DDDDDD",
|
|
17
|
+
btnSecondaryFocused: "#F9F9F9",
|
|
18
|
+
btnSecondaryDisabled: "#F9F9F9",
|
|
19
|
+
btnTertiary: "#FFFFFF",
|
|
20
|
+
btnTertiaryHover: "#F9F9F9",
|
|
21
|
+
btnTertiaryPressed: "#EFEFEF",
|
|
22
|
+
btnTertiaryFocused: "#FFFFFF",
|
|
23
|
+
btnTertiaryDisabled: "#FFFFFF",
|
|
24
|
+
btnIcon: "#FFFFFF",
|
|
25
|
+
btnIconHover: "#F9F9F9",
|
|
26
|
+
btnIconPressed: "#EFEFEF",
|
|
27
|
+
btnIconFocused: "#FFFFFF",
|
|
28
|
+
btnIconDisabled: "#FFFFFF",
|
|
29
|
+
btnDestructive: "#F34126",
|
|
30
|
+
btnDestructiveHover: "#DB3B22",
|
|
31
|
+
btnDestructivePressed: "#C2341E",
|
|
32
|
+
btnDestructiveFocused: "#F34126",
|
|
33
|
+
btnDestructiveDisabled: "#F34126",
|
|
34
|
+
pill: "#FFFFFF",
|
|
35
|
+
pillHover: "#F9F9F9",
|
|
36
|
+
pillPressed: "#EFEFEF",
|
|
37
|
+
pillFocused: "#FFFFFF",
|
|
38
|
+
pillDisabled: "#FFFFFF",
|
|
39
|
+
textPrimary: "#0F0F0F",
|
|
40
|
+
textSecondary: "#6C6C6C",
|
|
41
|
+
textSuccess: "#52A300",
|
|
42
|
+
textError: "#F34126",
|
|
43
|
+
textHyperlink: "#0F0F0F",
|
|
44
|
+
textWarning: "#F97316",
|
|
45
|
+
onBtnPrimary: "#FFFFFF",
|
|
46
|
+
onBtnPrimaryLoading: "#FFFFFF",
|
|
47
|
+
onBtnSecondary: "#0F0F0F",
|
|
48
|
+
onBtnSecondaryLoading: "#000000",
|
|
49
|
+
onBtnTertiary: "#0F0F0F",
|
|
50
|
+
onBtnIcon: "#6C6C6C",
|
|
51
|
+
onBtnDestructive: "#FFFFFF",
|
|
52
|
+
onBtnDestructiveLoading: "#FFFFFF",
|
|
53
|
+
borderModal: "#FFFFFF",
|
|
54
|
+
borderDefault: "#EFEFEF",
|
|
55
|
+
borderFocused: "#BEBEBE",
|
|
56
|
+
borderSelected: "#0F0F0F",
|
|
57
|
+
borderBtnPrimary: "#0F0F0F",
|
|
58
|
+
borderBtnSecondary: "#F9F9F9",
|
|
59
|
+
brandPrimary: "#0F0F0F"
|
|
60
|
+
},
|
|
61
|
+
radii: {
|
|
62
|
+
modal: 24,
|
|
63
|
+
element: 12,
|
|
64
|
+
elementInner: 8,
|
|
65
|
+
button: 12,
|
|
66
|
+
rounded: 999
|
|
67
|
+
},
|
|
68
|
+
borderWidths: {
|
|
69
|
+
modal: 1,
|
|
70
|
+
elementsDefault: 1,
|
|
71
|
+
elementsFocused: 2,
|
|
72
|
+
elementsSelected: 1,
|
|
73
|
+
button: 0
|
|
74
|
+
},
|
|
75
|
+
spacing: {
|
|
76
|
+
none: 0,
|
|
77
|
+
elementsHorizontal: 12,
|
|
78
|
+
modalHorizontal: 16
|
|
79
|
+
},
|
|
80
|
+
sizes: {
|
|
81
|
+
topBar: 56,
|
|
82
|
+
buttonHeight: 42,
|
|
83
|
+
buttonXs: 32,
|
|
84
|
+
buttonSm: 36,
|
|
85
|
+
buttonMd: 40,
|
|
86
|
+
buttonLg: 48,
|
|
87
|
+
iconXs: 16,
|
|
88
|
+
iconSm: 16,
|
|
89
|
+
iconMd: 20,
|
|
90
|
+
iconLg: 20
|
|
91
|
+
},
|
|
92
|
+
fontFamilies: {
|
|
93
|
+
body: "Inter",
|
|
94
|
+
header: "Inter"
|
|
95
|
+
},
|
|
96
|
+
fontWeights: {
|
|
97
|
+
base: "400",
|
|
98
|
+
medium: "500"
|
|
99
|
+
},
|
|
100
|
+
fontSizes: {
|
|
101
|
+
bodyBase: 16,
|
|
102
|
+
bodyDetail: 14,
|
|
103
|
+
headerTitle: 13,
|
|
104
|
+
headerSubtitle: 15,
|
|
105
|
+
amountInput: 48,
|
|
106
|
+
amountSummary: 48
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
var darkTokens = {
|
|
110
|
+
colors: {
|
|
111
|
+
bgModal: "#0F0F0F",
|
|
112
|
+
bgSecondary: "#1B1B1B",
|
|
113
|
+
btnPrimary: "#F9F9F9",
|
|
114
|
+
btnPrimaryHover: "#EFEFEF",
|
|
115
|
+
btnPrimaryPressed: "#EFEFEF",
|
|
116
|
+
btnPrimaryFocused: "#F9F9F9",
|
|
117
|
+
btnPrimaryDisabled: "#F9F9F9",
|
|
118
|
+
btnSecondary: "#1B1B1B",
|
|
119
|
+
btnSecondaryHover: "#2D2D2D",
|
|
120
|
+
btnSecondaryPressed: "#464646",
|
|
121
|
+
btnSecondaryFocused: "#1B1B1B",
|
|
122
|
+
btnSecondaryDisabled: "#1B1B1B",
|
|
123
|
+
btnTertiary: "#0F0F0F",
|
|
124
|
+
btnTertiaryHover: "#2D2D2D",
|
|
125
|
+
btnTertiaryPressed: "#464646",
|
|
126
|
+
btnTertiaryFocused: "#0F0F0F",
|
|
127
|
+
btnTertiaryDisabled: "#0F0F0F",
|
|
128
|
+
btnIcon: "#0F0F0F",
|
|
129
|
+
btnIconHover: "#1B1B1B",
|
|
130
|
+
btnIconPressed: "#2D2D2D",
|
|
131
|
+
btnIconFocused: "#0F0F0F",
|
|
132
|
+
btnIconDisabled: "#0F0F0F",
|
|
133
|
+
btnDestructive: "#DB3B22",
|
|
134
|
+
btnDestructiveHover: "#F34126",
|
|
135
|
+
btnDestructivePressed: "#F88877",
|
|
136
|
+
btnDestructiveFocused: "#DB3B22",
|
|
137
|
+
btnDestructiveDisabled: "#DB3B22",
|
|
138
|
+
pill: "#0F0F0F",
|
|
139
|
+
pillHover: "#1B1B1B",
|
|
140
|
+
pillPressed: "#2D2D2D",
|
|
141
|
+
pillFocused: "#0F0F0F",
|
|
142
|
+
pillDisabled: "#0F0F0F",
|
|
143
|
+
textPrimary: "#FFFFFF",
|
|
144
|
+
textSecondary: "#929292",
|
|
145
|
+
textSuccess: "#52A300",
|
|
146
|
+
textError: "#F34126",
|
|
147
|
+
textHyperlink: "#4971F0",
|
|
148
|
+
textWarning: "#F97316",
|
|
149
|
+
onBtnPrimary: "#000000",
|
|
150
|
+
onBtnPrimaryLoading: "#000000",
|
|
151
|
+
onBtnSecondary: "#F9F9F9",
|
|
152
|
+
onBtnSecondaryLoading: "#FFFFFF",
|
|
153
|
+
onBtnTertiary: "#F9F9F9",
|
|
154
|
+
onBtnIcon: "#929292",
|
|
155
|
+
onBtnDestructive: "#FFFFFF",
|
|
156
|
+
onBtnDestructiveLoading: "#FFFFFF",
|
|
157
|
+
borderModal: "#1B1B1B",
|
|
158
|
+
borderDefault: "#2D2D2D",
|
|
159
|
+
borderFocused: "#464646",
|
|
160
|
+
borderSelected: "#F9F9F9",
|
|
161
|
+
borderBtnPrimary: "#F9F9F9",
|
|
162
|
+
borderBtnSecondary: "#1B1B1B",
|
|
163
|
+
brandPrimary: "#FFFFFF"
|
|
164
|
+
},
|
|
165
|
+
radii: {
|
|
166
|
+
modal: 24,
|
|
167
|
+
element: 12,
|
|
168
|
+
elementInner: 8,
|
|
169
|
+
button: 24,
|
|
170
|
+
rounded: 999
|
|
171
|
+
},
|
|
172
|
+
borderWidths: {
|
|
173
|
+
modal: 1,
|
|
174
|
+
elementsDefault: 1,
|
|
175
|
+
elementsFocused: 2,
|
|
176
|
+
elementsSelected: 1,
|
|
177
|
+
button: 0
|
|
178
|
+
},
|
|
179
|
+
spacing: {
|
|
180
|
+
none: 0,
|
|
181
|
+
elementsHorizontal: 12,
|
|
182
|
+
modalHorizontal: 16
|
|
183
|
+
},
|
|
184
|
+
sizes: {
|
|
185
|
+
topBar: 56,
|
|
186
|
+
buttonHeight: 42,
|
|
187
|
+
buttonXs: 32,
|
|
188
|
+
buttonSm: 36,
|
|
189
|
+
buttonMd: 40,
|
|
190
|
+
buttonLg: 48,
|
|
191
|
+
iconXs: 16,
|
|
192
|
+
iconSm: 16,
|
|
193
|
+
iconMd: 20,
|
|
194
|
+
iconLg: 20
|
|
195
|
+
},
|
|
196
|
+
fontFamilies: {
|
|
197
|
+
body: "Inter",
|
|
198
|
+
header: "Inter"
|
|
199
|
+
},
|
|
200
|
+
fontWeights: {
|
|
201
|
+
base: "400",
|
|
202
|
+
medium: "500"
|
|
203
|
+
},
|
|
204
|
+
fontSizes: {
|
|
205
|
+
bodyBase: 16,
|
|
206
|
+
bodyDetail: 14,
|
|
207
|
+
headerTitle: 13,
|
|
208
|
+
headerSubtitle: 15,
|
|
209
|
+
amountInput: 32,
|
|
210
|
+
amountSummary: 40
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
// src/theme/toRestyleTheme.ts
|
|
215
|
+
import { createTheme } from "@shopify/restyle";
|
|
216
|
+
function toRestyleTheme(tokens) {
|
|
217
|
+
return createTheme({
|
|
218
|
+
colors: {
|
|
219
|
+
...tokens.colors,
|
|
220
|
+
transparent: "transparent"
|
|
221
|
+
},
|
|
222
|
+
spacing: tokens.spacing,
|
|
223
|
+
borderRadii: tokens.radii,
|
|
224
|
+
borderWidths: tokens.borderWidths,
|
|
225
|
+
sizes: tokens.sizes,
|
|
226
|
+
breakpoints: {
|
|
227
|
+
phone: 0,
|
|
228
|
+
tablet: 768
|
|
229
|
+
},
|
|
230
|
+
textVariants: {
|
|
231
|
+
defaults: {
|
|
232
|
+
fontFamily: tokens.fontFamilies.body,
|
|
233
|
+
fontWeight: tokens.fontWeights.base,
|
|
234
|
+
fontSize: tokens.fontSizes.bodyBase,
|
|
235
|
+
color: "textPrimary"
|
|
236
|
+
},
|
|
237
|
+
body: {
|
|
238
|
+
fontFamily: tokens.fontFamilies.body,
|
|
239
|
+
fontWeight: tokens.fontWeights.base,
|
|
240
|
+
fontSize: tokens.fontSizes.bodyBase,
|
|
241
|
+
color: "textPrimary"
|
|
242
|
+
},
|
|
243
|
+
bodyMedium: {
|
|
244
|
+
fontFamily: tokens.fontFamilies.body,
|
|
245
|
+
fontWeight: tokens.fontWeights.medium,
|
|
246
|
+
fontSize: tokens.fontSizes.bodyBase,
|
|
247
|
+
color: "textPrimary"
|
|
248
|
+
},
|
|
249
|
+
detail: {
|
|
250
|
+
fontFamily: tokens.fontFamilies.body,
|
|
251
|
+
fontWeight: tokens.fontWeights.base,
|
|
252
|
+
fontSize: tokens.fontSizes.bodyDetail,
|
|
253
|
+
color: "textSecondary"
|
|
254
|
+
},
|
|
255
|
+
headerTitle: {
|
|
256
|
+
fontFamily: tokens.fontFamilies.header,
|
|
257
|
+
fontWeight: tokens.fontWeights.medium,
|
|
258
|
+
fontSize: tokens.fontSizes.headerTitle,
|
|
259
|
+
color: "textPrimary",
|
|
260
|
+
textAlign: "center"
|
|
261
|
+
},
|
|
262
|
+
headerSubtitle: {
|
|
263
|
+
fontFamily: tokens.fontFamilies.header,
|
|
264
|
+
fontWeight: tokens.fontWeights.medium,
|
|
265
|
+
fontSize: tokens.fontSizes.headerSubtitle,
|
|
266
|
+
color: "textSecondary",
|
|
267
|
+
textAlign: "center"
|
|
268
|
+
},
|
|
269
|
+
amountInput: {
|
|
270
|
+
fontFamily: tokens.fontFamilies.header,
|
|
271
|
+
fontWeight: tokens.fontWeights.medium,
|
|
272
|
+
fontSize: tokens.fontSizes.amountInput,
|
|
273
|
+
color: "textPrimary"
|
|
274
|
+
},
|
|
275
|
+
amountSummary: {
|
|
276
|
+
fontFamily: tokens.fontFamilies.header,
|
|
277
|
+
fontWeight: tokens.fontWeights.medium,
|
|
278
|
+
fontSize: tokens.fontSizes.amountSummary,
|
|
279
|
+
color: "textPrimary"
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
var defaultLightTheme = toRestyleTheme(lightTokens);
|
|
285
|
+
var defaultDarkTheme = toRestyleTheme(darkTokens);
|
|
286
|
+
|
|
287
|
+
// src/theme/useColorScheme.ts
|
|
288
|
+
import { useEffect, useState } from "react";
|
|
289
|
+
import { Appearance } from "react-native";
|
|
290
|
+
function resolveColorScheme(controlled, override, system) {
|
|
291
|
+
if (controlled) {
|
|
292
|
+
return controlled;
|
|
293
|
+
}
|
|
294
|
+
return override ?? system ?? "light";
|
|
295
|
+
}
|
|
296
|
+
function normalizeColorScheme(scheme) {
|
|
297
|
+
return scheme === "light" || scheme === "dark" ? scheme : void 0;
|
|
298
|
+
}
|
|
299
|
+
function useColorScheme() {
|
|
300
|
+
const [scheme, setScheme] = useState(
|
|
301
|
+
() => normalizeColorScheme(Appearance.getColorScheme())
|
|
302
|
+
);
|
|
303
|
+
useEffect(() => {
|
|
304
|
+
const subscription = Appearance.addChangeListener(({ colorScheme }) => {
|
|
305
|
+
setScheme(normalizeColorScheme(colorScheme));
|
|
306
|
+
});
|
|
307
|
+
return () => subscription.remove();
|
|
308
|
+
}, []);
|
|
309
|
+
return scheme;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// src/theme/useFunkitTheme.ts
|
|
313
|
+
import { useMemo } from "react";
|
|
314
|
+
var DEFAULT_THEME_SET = {
|
|
315
|
+
light: defaultLightTheme,
|
|
316
|
+
dark: defaultDarkTheme
|
|
317
|
+
};
|
|
318
|
+
function selectTheme(themeSet, scheme) {
|
|
319
|
+
const primary = scheme === "dark" ? themeSet.dark : themeSet.light;
|
|
320
|
+
const fallback = scheme === "dark" ? themeSet.light : themeSet.dark;
|
|
321
|
+
if (primary) {
|
|
322
|
+
return primary;
|
|
323
|
+
}
|
|
324
|
+
if (fallback) {
|
|
325
|
+
return fallback;
|
|
326
|
+
}
|
|
327
|
+
throw new Error(
|
|
328
|
+
"FunkitProvider: `themes` must include at least one of { light, dark }"
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
function useFunkitTheme(themeSet = DEFAULT_THEME_SET) {
|
|
332
|
+
const scheme = useColorScheme();
|
|
333
|
+
return useMemo(
|
|
334
|
+
() => selectTheme(themeSet, scheme),
|
|
335
|
+
[scheme, themeSet.light, themeSet.dark]
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// src/theme/restyle.ts
|
|
340
|
+
import {
|
|
341
|
+
createBox,
|
|
342
|
+
createText,
|
|
343
|
+
useTheme as useRestyleTheme
|
|
344
|
+
} from "@shopify/restyle";
|
|
345
|
+
var Box = createBox();
|
|
346
|
+
var Text = createText();
|
|
347
|
+
var useTheme = () => useRestyleTheme();
|
|
348
|
+
|
|
349
|
+
// src/theme/FunkitThemeProvider.tsx
|
|
350
|
+
import { ThemeProvider } from "@shopify/restyle";
|
|
351
|
+
import {
|
|
352
|
+
createContext,
|
|
353
|
+
useCallback,
|
|
354
|
+
useContext,
|
|
355
|
+
useMemo as useMemo2,
|
|
356
|
+
useState as useState2
|
|
357
|
+
} from "react";
|
|
358
|
+
import { jsx } from "react/jsx-runtime";
|
|
359
|
+
var DEFAULT_THEMES = {
|
|
360
|
+
light: defaultLightTheme,
|
|
361
|
+
dark: defaultDarkTheme
|
|
362
|
+
};
|
|
363
|
+
var FunkitColorSchemeContext = createContext(
|
|
364
|
+
null
|
|
365
|
+
);
|
|
366
|
+
function FunkitThemeProvider({
|
|
367
|
+
children,
|
|
368
|
+
themes = DEFAULT_THEMES,
|
|
369
|
+
colorScheme
|
|
370
|
+
}) {
|
|
371
|
+
const isControlled = colorScheme != null;
|
|
372
|
+
const systemScheme = useColorScheme();
|
|
373
|
+
const [override, setOverride] = useState2(void 0);
|
|
374
|
+
const activeScheme = resolveColorScheme(colorScheme, override, systemScheme);
|
|
375
|
+
const toggleColorScheme = useCallback(
|
|
376
|
+
(next) => {
|
|
377
|
+
if (colorScheme != null) {
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
setOverride((prev) => {
|
|
381
|
+
if (next != null) {
|
|
382
|
+
return next;
|
|
383
|
+
}
|
|
384
|
+
const current = resolveColorScheme(void 0, prev, systemScheme);
|
|
385
|
+
return current === "dark" ? "light" : "dark";
|
|
386
|
+
});
|
|
387
|
+
},
|
|
388
|
+
[colorScheme, systemScheme]
|
|
389
|
+
);
|
|
390
|
+
const theme = selectTheme(themes, activeScheme);
|
|
391
|
+
const value = useMemo2(
|
|
392
|
+
() => ({ colorScheme: activeScheme, toggleColorScheme, isControlled }),
|
|
393
|
+
[activeScheme, toggleColorScheme, isControlled]
|
|
394
|
+
);
|
|
395
|
+
return /* @__PURE__ */ jsx(FunkitColorSchemeContext.Provider, { value, children: /* @__PURE__ */ jsx(ThemeProvider, { theme, children }) });
|
|
396
|
+
}
|
|
397
|
+
function useFunkitColorScheme() {
|
|
398
|
+
const value = useContext(FunkitColorSchemeContext);
|
|
399
|
+
if (value == null) {
|
|
400
|
+
throw new Error("useFunkitColorScheme must be used within <FunkitProvider>");
|
|
401
|
+
}
|
|
402
|
+
return value;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// src/providers/FunkitProvider.tsx
|
|
406
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
407
|
+
import { useEffect as useEffect5, useMemo as useMemo8, useRef as useRef3 } from "react";
|
|
408
|
+
|
|
409
|
+
// src/flow/FunkitFlowProvider.tsx
|
|
410
|
+
import {
|
|
411
|
+
createContext as createContext3,
|
|
412
|
+
useCallback as useCallback3,
|
|
413
|
+
useContext as useContext3,
|
|
414
|
+
useMemo as useMemo6,
|
|
415
|
+
useState as useState5
|
|
416
|
+
} from "react";
|
|
417
|
+
import { Modal, Pressable as Pressable6, Share } from "react-native";
|
|
418
|
+
|
|
419
|
+
// src/icons/FunIcon.tsx
|
|
420
|
+
import { useEffect as useEffect2, useState as useState3 } from "react";
|
|
421
|
+
import { Image } from "react-native";
|
|
422
|
+
import { SvgXml } from "react-native-svg";
|
|
423
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
424
|
+
var svgCache = /* @__PURE__ */ new Map();
|
|
425
|
+
function ensureViewBox(svg) {
|
|
426
|
+
if (/\bviewBox\s*=/.test(svg)) {
|
|
427
|
+
return svg;
|
|
428
|
+
}
|
|
429
|
+
const width = svg.match(/\bwidth="([\d.]+)"/)?.[1];
|
|
430
|
+
const height = svg.match(/\bheight="([\d.]+)"/)?.[1];
|
|
431
|
+
if (!width || !height) {
|
|
432
|
+
return svg;
|
|
433
|
+
}
|
|
434
|
+
return svg.replace(/<svg\b/, `<svg viewBox="0 0 ${width} ${height}"`);
|
|
435
|
+
}
|
|
436
|
+
function FunIcon({ uri, size = 32, fallbackUri }) {
|
|
437
|
+
const [currentUri, setCurrentUri] = useState3(uri);
|
|
438
|
+
const isSvg = currentUri.endsWith(".svg");
|
|
439
|
+
const [xml, setXml] = useState3(
|
|
440
|
+
() => svgCache.get(currentUri) ?? null
|
|
441
|
+
);
|
|
442
|
+
const [rasterLoaded, setRasterLoaded] = useState3(false);
|
|
443
|
+
useEffect2(() => {
|
|
444
|
+
setCurrentUri(uri);
|
|
445
|
+
setRasterLoaded(false);
|
|
446
|
+
setXml(svgCache.get(uri) ?? null);
|
|
447
|
+
}, [uri]);
|
|
448
|
+
const onFailure = () => {
|
|
449
|
+
if (fallbackUri && currentUri !== fallbackUri) {
|
|
450
|
+
setCurrentUri(fallbackUri);
|
|
451
|
+
setRasterLoaded(false);
|
|
452
|
+
setXml(svgCache.get(fallbackUri) ?? null);
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
useEffect2(() => {
|
|
456
|
+
if (!isSvg) {
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
const cached = svgCache.get(currentUri);
|
|
460
|
+
if (cached != null) {
|
|
461
|
+
setXml(cached);
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
let active = true;
|
|
465
|
+
fetch(currentUri).then((res) => res.text()).then((text) => {
|
|
466
|
+
const normalized = ensureViewBox(text);
|
|
467
|
+
svgCache.set(currentUri, normalized);
|
|
468
|
+
if (active) {
|
|
469
|
+
setXml(normalized);
|
|
470
|
+
}
|
|
471
|
+
}).catch(() => {
|
|
472
|
+
if (active) {
|
|
473
|
+
onFailure();
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
return () => {
|
|
477
|
+
active = false;
|
|
478
|
+
};
|
|
479
|
+
}, [currentUri, isSvg]);
|
|
480
|
+
const ready = isSvg ? xml != null : rasterLoaded;
|
|
481
|
+
const clip = { overflow: "hidden" };
|
|
482
|
+
return /* @__PURE__ */ jsx2(
|
|
483
|
+
Box,
|
|
484
|
+
{
|
|
485
|
+
width: size,
|
|
486
|
+
height: size,
|
|
487
|
+
borderRadius: "rounded",
|
|
488
|
+
backgroundColor: ready ? void 0 : "bgSecondary",
|
|
489
|
+
style: clip,
|
|
490
|
+
children: isSvg ? xml != null ? /* @__PURE__ */ jsx2(SvgXml, { xml, width: size, height: size }) : null : /* @__PURE__ */ jsx2(
|
|
491
|
+
Image,
|
|
492
|
+
{
|
|
493
|
+
source: { uri: currentUri },
|
|
494
|
+
style: { width: size, height: size },
|
|
495
|
+
onLoad: () => setRasterLoaded(true),
|
|
496
|
+
onError: onFailure
|
|
497
|
+
}
|
|
498
|
+
)
|
|
499
|
+
}
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// src/icons/assetLogos.ts
|
|
504
|
+
var ASSET_LOGO_SRCS = {
|
|
505
|
+
$MFER: "https://sdk-cdn.fun.xyz/images/mfer.png",
|
|
506
|
+
AARBUSDCN: "https://sdk-cdn.fun.xyz/images/aarbusdcn.png",
|
|
507
|
+
AAVE: "https://sdk-cdn.fun.xyz/images/aave.svg",
|
|
508
|
+
AERO: "https://sdk-cdn.fun.xyz/images/aero.svg",
|
|
509
|
+
APE: "https://sdk-cdn.fun.xyz/images/ape.svg",
|
|
510
|
+
APOLWMATIC: "https://sdk-cdn.fun.xyz/images/apolwmatic.png",
|
|
511
|
+
ARB: "https://sdk-cdn.fun.xyz/images/arb.svg",
|
|
512
|
+
BEHYPE: "https://sdk-cdn.fun.xyz/images/behype.svg",
|
|
513
|
+
BENTO: "https://sdk-cdn.fun.xyz/images/bento.png",
|
|
514
|
+
BLERF: "https://sdk-cdn.fun.xyz/images/blerf.png",
|
|
515
|
+
BRETT: "https://sdk-cdn.fun.xyz/images/brett.svg",
|
|
516
|
+
BSHIB: "https://sdk-cdn.fun.xyz/images/bshib.png",
|
|
517
|
+
BTC: "https://sdk-cdn.fun.xyz/images/btc.svg",
|
|
518
|
+
CBBTC: "https://sdk-cdn.fun.xyz/images/cbbtc.svg",
|
|
519
|
+
CBETH: "https://sdk-cdn.fun.xyz/images/cbeth.png",
|
|
520
|
+
CRO: "https://sdk-cdn.fun.xyz/images/cro.svg",
|
|
521
|
+
CRV: "https://sdk-cdn.fun.xyz/images/crv.svg",
|
|
522
|
+
DAI: "https://sdk-cdn.fun.xyz/images/dai.svg",
|
|
523
|
+
DEGEN: "https://sdk-cdn.fun.xyz/images/degen.svg",
|
|
524
|
+
ETH: "https://sdk-cdn.fun.xyz/images/eth.svg",
|
|
525
|
+
GMX: "https://sdk-cdn.fun.xyz/images/gmx.svg",
|
|
526
|
+
GRT: "https://sdk-cdn.fun.xyz/images/grt.svg",
|
|
527
|
+
HYPE: "https://sdk-cdn.fun.xyz/images/hype.svg",
|
|
528
|
+
IMX: "https://sdk-cdn.fun.xyz/images/imx.svg",
|
|
529
|
+
INJ: "https://sdk-cdn.fun.xyz/images/inj.svg",
|
|
530
|
+
LDO: "https://sdk-cdn.fun.xyz/images/ldo.svg",
|
|
531
|
+
LINK: "https://sdk-cdn.fun.xyz/images/link.png",
|
|
532
|
+
LUCK: "https://sdk-cdn.fun.xyz/images/luck.png",
|
|
533
|
+
MATIC: "https://sdk-cdn.fun.xyz/images/matic.svg",
|
|
534
|
+
MFER: "https://sdk-cdn.fun.xyz/images/mfer.png",
|
|
535
|
+
MKR: "https://sdk-cdn.fun.xyz/images/mkr.svg",
|
|
536
|
+
MNT: "https://sdk-cdn.fun.xyz/images/mnt.svg",
|
|
537
|
+
OP: "https://sdk-cdn.fun.xyz/images/optimism.svg",
|
|
538
|
+
PENDLE: "https://sdk-cdn.fun.xyz/images/pendle.svg",
|
|
539
|
+
POL: "https://sdk-cdn.fun.xyz/images/matic.svg",
|
|
540
|
+
PYUSD: "https://sdk-cdn.fun.xyz/images/pyusd.svg",
|
|
541
|
+
QNT: "https://sdk-cdn.fun.xyz/images/qnt.svg",
|
|
542
|
+
RNDR: "https://sdk-cdn.fun.xyz/images/rndr.svg",
|
|
543
|
+
ROOST: "https://sdk-cdn.fun.xyz/images/roost.png",
|
|
544
|
+
SAND: "https://sdk-cdn.fun.xyz/images/sand.svg",
|
|
545
|
+
SHIB: "https://sdk-cdn.fun.xyz/images/shib.svg",
|
|
546
|
+
SNX: "https://sdk-cdn.fun.xyz/images/snx.svg",
|
|
547
|
+
SOL: "https://sdk-cdn.fun.xyz/images/sol.svg",
|
|
548
|
+
SUSDS: "https://sdk-cdn.fun.xyz/images/susds.svg",
|
|
549
|
+
TYBG: "https://sdk-cdn.fun.xyz/images/tybg.png",
|
|
550
|
+
UNI: "https://sdk-cdn.fun.xyz/images/uni.png",
|
|
551
|
+
USDC: "https://sdk-cdn.fun.xyz/images/usdc.svg",
|
|
552
|
+
"USDC.E": "https://sdk-cdn.fun.xyz/images/usdc.svg",
|
|
553
|
+
USDBC: "https://sdk-cdn.fun.xyz/images/usdc.svg",
|
|
554
|
+
USDE: "https://sdk-cdn.fun.xyz/images/usde.svg",
|
|
555
|
+
WUSDE: "https://sdk-cdn.fun.xyz/images/usde.svg",
|
|
556
|
+
EUSDE: "https://sdk-cdn.fun.xyz/images/eusde.svg",
|
|
557
|
+
USDT: "https://sdk-cdn.fun.xyz/images/usdt.svg",
|
|
558
|
+
"USD\u20AE0": "https://sdk-cdn.fun.xyz/images/usdt0.svg",
|
|
559
|
+
USDT0: "https://sdk-cdn.fun.xyz/images/usdt0.svg",
|
|
560
|
+
USDS: "https://sdk-cdn.fun.xyz/images/usds.svg",
|
|
561
|
+
USDH: "https://sdk-cdn.fun.xyz/images/usdh.svg",
|
|
562
|
+
VRTX: "https://sdk-cdn.fun.xyz/images/vrtx.svg",
|
|
563
|
+
WBTC: "https://sdk-cdn.fun.xyz/images/wbtc.svg",
|
|
564
|
+
WEETH: "https://sdk-cdn.fun.xyz/images/weeth.png",
|
|
565
|
+
WETH: "https://sdk-cdn.fun.xyz/images/weth.svg",
|
|
566
|
+
WHYPE: "https://sdk-cdn.fun.xyz/images/whype.png",
|
|
567
|
+
WSTETH: "https://sdk-cdn.fun.xyz/images/wsteth.png",
|
|
568
|
+
TRUMP: "https://sdk-cdn.fun.xyz/images/trump.png",
|
|
569
|
+
BNB: "https://sdk-cdn.fun.xyz/images/bsc.svg",
|
|
570
|
+
WBNB: "https://sdk-cdn.fun.xyz/images/bsc.svg",
|
|
571
|
+
BTCB: "https://sdk-cdn.fun.xyz/images/btc.svg",
|
|
572
|
+
UBTC: "https://sdk-cdn.fun.xyz/images/btc.svg",
|
|
573
|
+
BUSD: "https://sdk-cdn.fun.xyz/images/busd.svg",
|
|
574
|
+
XAUT: "https://sdk-cdn.fun.xyz/images/xaut.png",
|
|
575
|
+
ADA: "https://sdk-cdn.fun.xyz/images/ada.svg",
|
|
576
|
+
XRP: "https://sdk-cdn.fun.xyz/images/xrp.svg",
|
|
577
|
+
UDOGE: "https://sdk-cdn.fun.xyz/images/doge.svg",
|
|
578
|
+
DOGE: "https://sdk-cdn.fun.xyz/images/doge.svg",
|
|
579
|
+
LTC: "https://sdk-cdn.fun.xyz/images/ltc.svg",
|
|
580
|
+
HNT: "https://sdk-cdn.fun.xyz/images/hnt.svg",
|
|
581
|
+
COMP: "https://sdk-cdn.fun.xyz/images/comp.svg",
|
|
582
|
+
PEPE: "https://sdk-cdn.fun.xyz/images/pepe.svg",
|
|
583
|
+
LSTHYPE: "https://sdk-cdn.fun.xyz/images/lsthype.svg",
|
|
584
|
+
HBUSDT: "https://sdk-cdn.fun.xyz/images/hbusdt.svg",
|
|
585
|
+
WVLP: "https://sdk-cdn.fun.xyz/images/wvlp.svg",
|
|
586
|
+
LIQUIDHYPE: "https://sdk-cdn.fun.xyz/images/liquidhype.svg",
|
|
587
|
+
VHYPE: "https://sdk-cdn.fun.xyz/images/vhype.png",
|
|
588
|
+
HBHYPE: "https://sdk-cdn.fun.xyz/images/hbhype.svg",
|
|
589
|
+
MON: "https://sdk-cdn.fun.xyz/images/monad.svg",
|
|
590
|
+
WMON: "https://sdk-cdn.fun.xyz/images/wmon.svg",
|
|
591
|
+
AUSD: "https://sdk-cdn.fun.xyz/images/ausd.svg",
|
|
592
|
+
SUSHI: "https://sdk-cdn.fun.xyz/images/sushi.svg",
|
|
593
|
+
SKY: "https://sdk-cdn.fun.xyz/images/sky.svg",
|
|
594
|
+
LIT: "https://sdk-cdn.fun.xyz/images/lit.svg",
|
|
595
|
+
AZTEC: "https://sdk-cdn.fun.xyz/images/aztec.svg",
|
|
596
|
+
U: "https://sdk-cdn.fun.xyz/images/u.png",
|
|
597
|
+
PUSD: "https://sdk-cdn.fun.xyz/images/pusd.svg"
|
|
598
|
+
};
|
|
599
|
+
var FALLBACK_ASSET_LOGO = "https://sdk-cdn.fun.xyz/images/dollar_circle.png";
|
|
600
|
+
|
|
601
|
+
// src/icons/funIconUri.ts
|
|
602
|
+
var CDN_BASE = "https://sdk-cdn.fun.xyz/images";
|
|
603
|
+
var chainIconUri = (chainKey) => `${CDN_BASE}/${chainKey}.svg`;
|
|
604
|
+
var tokenLogoUri = (symbol) => ASSET_LOGO_SRCS[symbol.toUpperCase()] ?? `${CDN_BASE}/${symbol.toLowerCase()}.svg`;
|
|
605
|
+
|
|
606
|
+
// src/icons/ChainClusterIcon.tsx
|
|
607
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
608
|
+
function ChainClusterIcon({ chains, size = 32 }) {
|
|
609
|
+
if (chains.length === 0) {
|
|
610
|
+
return /* @__PURE__ */ jsx3(
|
|
611
|
+
Box,
|
|
612
|
+
{
|
|
613
|
+
width: size,
|
|
614
|
+
height: size,
|
|
615
|
+
borderRadius: "rounded",
|
|
616
|
+
backgroundColor: "pillPressed"
|
|
617
|
+
}
|
|
618
|
+
);
|
|
619
|
+
}
|
|
620
|
+
if (chains.length === 1) {
|
|
621
|
+
return /* @__PURE__ */ jsx3(FunIcon, { uri: chainIconUri(chains[0]), size });
|
|
622
|
+
}
|
|
623
|
+
const mini = Math.round(size * 0.44);
|
|
624
|
+
return /* @__PURE__ */ jsx3(
|
|
625
|
+
Box,
|
|
626
|
+
{
|
|
627
|
+
width: size,
|
|
628
|
+
height: size,
|
|
629
|
+
borderRadius: "rounded",
|
|
630
|
+
backgroundColor: "pillPressed",
|
|
631
|
+
alignItems: "center",
|
|
632
|
+
justifyContent: "center",
|
|
633
|
+
children: /* @__PURE__ */ jsx3(Box, { flexDirection: "row", flexWrap: "wrap", style: grid(mini), children: chains.slice(0, 4).map((chain) => /* @__PURE__ */ jsx3(FunIcon, { uri: chainIconUri(chain), size: mini }, chain)) })
|
|
634
|
+
}
|
|
635
|
+
);
|
|
636
|
+
}
|
|
637
|
+
var grid = (mini) => ({ width: mini * 2 + 1, gap: 1 });
|
|
638
|
+
|
|
639
|
+
// src/screens/AddMoneyScreen.tsx
|
|
640
|
+
import { Pressable, ScrollView } from "react-native";
|
|
641
|
+
import { jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
642
|
+
function AddMoneyScreen({
|
|
643
|
+
methods,
|
|
644
|
+
onSelectMethod,
|
|
645
|
+
title = "Add money"
|
|
646
|
+
}) {
|
|
647
|
+
return /* @__PURE__ */ jsxs(
|
|
648
|
+
Box,
|
|
649
|
+
{
|
|
650
|
+
backgroundColor: "bgModal",
|
|
651
|
+
borderTopLeftRadius: "modal",
|
|
652
|
+
borderTopRightRadius: "modal",
|
|
653
|
+
children: [
|
|
654
|
+
/* @__PURE__ */ jsxs(Box, { alignItems: "center", style: topBar, children: [
|
|
655
|
+
/* @__PURE__ */ jsx4(Box, { backgroundColor: "borderFocused", style: grabber }),
|
|
656
|
+
/* @__PURE__ */ jsx4(Text, { variant: "bodyMedium", color: "textPrimary", children: title })
|
|
657
|
+
] }),
|
|
658
|
+
/* @__PURE__ */ jsx4(
|
|
659
|
+
ScrollView,
|
|
660
|
+
{
|
|
661
|
+
contentContainerStyle: listContent,
|
|
662
|
+
showsVerticalScrollIndicator: false,
|
|
663
|
+
children: methods.map((method) => /* @__PURE__ */ jsx4(
|
|
664
|
+
Pressable,
|
|
665
|
+
{
|
|
666
|
+
onPress: () => onSelectMethod(method.id),
|
|
667
|
+
accessibilityRole: "button",
|
|
668
|
+
accessibilityLabel: method.title,
|
|
669
|
+
children: /* @__PURE__ */ jsx4(PaymentMethodRow, { method })
|
|
670
|
+
},
|
|
671
|
+
method.id
|
|
672
|
+
))
|
|
673
|
+
}
|
|
674
|
+
)
|
|
675
|
+
]
|
|
676
|
+
}
|
|
677
|
+
);
|
|
678
|
+
}
|
|
679
|
+
function PaymentMethodRow({ method }) {
|
|
680
|
+
return /* @__PURE__ */ jsxs(
|
|
681
|
+
Box,
|
|
682
|
+
{
|
|
683
|
+
flexDirection: "row",
|
|
684
|
+
alignItems: "center",
|
|
685
|
+
gap: "elementsHorizontal",
|
|
686
|
+
borderRadius: "element",
|
|
687
|
+
style: row,
|
|
688
|
+
children: [
|
|
689
|
+
/* @__PURE__ */ jsx4(
|
|
690
|
+
Box,
|
|
691
|
+
{
|
|
692
|
+
width: 48,
|
|
693
|
+
height: 48,
|
|
694
|
+
borderRadius: "rounded",
|
|
695
|
+
backgroundColor: "bgSecondary",
|
|
696
|
+
alignItems: "center",
|
|
697
|
+
justifyContent: "center",
|
|
698
|
+
children: method.icon
|
|
699
|
+
}
|
|
700
|
+
),
|
|
701
|
+
/* @__PURE__ */ jsxs(Box, { flex: 1, style: details, children: [
|
|
702
|
+
/* @__PURE__ */ jsx4(Text, { variant: "bodyMedium", color: "textPrimary", children: method.title }),
|
|
703
|
+
method.subtitle ? /* @__PURE__ */ jsx4(Text, { variant: "detail", color: "textSecondary", children: method.subtitle }) : null
|
|
704
|
+
] }),
|
|
705
|
+
method.trailing
|
|
706
|
+
]
|
|
707
|
+
}
|
|
708
|
+
);
|
|
709
|
+
}
|
|
710
|
+
var topBar = { paddingTop: 20, paddingBottom: 12 };
|
|
711
|
+
var grabber = {
|
|
712
|
+
position: "absolute",
|
|
713
|
+
top: 8,
|
|
714
|
+
width: 36,
|
|
715
|
+
height: 5,
|
|
716
|
+
borderRadius: 999
|
|
717
|
+
};
|
|
718
|
+
var listContent = {
|
|
719
|
+
paddingHorizontal: 16,
|
|
720
|
+
paddingBottom: 16,
|
|
721
|
+
gap: 6
|
|
722
|
+
};
|
|
723
|
+
var row = { paddingVertical: 10 };
|
|
724
|
+
var details = { gap: 2 };
|
|
725
|
+
|
|
726
|
+
// src/screens/ChooseChainScreen.tsx
|
|
727
|
+
import { Pressable as Pressable2 } from "react-native";
|
|
728
|
+
import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
729
|
+
function ChooseChainScreen({
|
|
730
|
+
chains,
|
|
731
|
+
onSelectChain,
|
|
732
|
+
onBack,
|
|
733
|
+
title = "Transfer Crypto"
|
|
734
|
+
}) {
|
|
735
|
+
return /* @__PURE__ */ jsxs2(
|
|
736
|
+
Box,
|
|
737
|
+
{
|
|
738
|
+
backgroundColor: "bgModal",
|
|
739
|
+
borderTopLeftRadius: "modal",
|
|
740
|
+
borderTopRightRadius: "modal",
|
|
741
|
+
children: [
|
|
742
|
+
/* @__PURE__ */ jsxs2(Box, { flexDirection: "row", alignItems: "center", gap: "none", style: topBar2, children: [
|
|
743
|
+
/* @__PURE__ */ jsx5(Box, { backgroundColor: "borderFocused", style: grabber2 }),
|
|
744
|
+
/* @__PURE__ */ jsx5(
|
|
745
|
+
Pressable2,
|
|
746
|
+
{
|
|
747
|
+
onPress: onBack,
|
|
748
|
+
hitSlop: 12,
|
|
749
|
+
accessibilityRole: "button",
|
|
750
|
+
accessibilityLabel: "Back",
|
|
751
|
+
children: /* @__PURE__ */ jsx5(Text, { color: "textPrimary", style: chevron, children: "\u2039" })
|
|
752
|
+
}
|
|
753
|
+
),
|
|
754
|
+
/* @__PURE__ */ jsx5(Box, { flex: 1, alignItems: "center", children: /* @__PURE__ */ jsx5(Text, { variant: "bodyMedium", color: "textPrimary", children: title }) }),
|
|
755
|
+
/* @__PURE__ */ jsx5(Box, { style: topBarSpacer })
|
|
756
|
+
] }),
|
|
757
|
+
/* @__PURE__ */ jsx5(Box, { style: content, children: chains.map((chain) => /* @__PURE__ */ jsx5(
|
|
758
|
+
Pressable2,
|
|
759
|
+
{
|
|
760
|
+
onPress: () => onSelectChain(chain.id),
|
|
761
|
+
accessibilityRole: "button",
|
|
762
|
+
accessibilityLabel: chain.label,
|
|
763
|
+
children: /* @__PURE__ */ jsxs2(
|
|
764
|
+
Box,
|
|
765
|
+
{
|
|
766
|
+
flexDirection: "row",
|
|
767
|
+
alignItems: "center",
|
|
768
|
+
gap: "elementsHorizontal",
|
|
769
|
+
borderRadius: "button",
|
|
770
|
+
style: row2,
|
|
771
|
+
children: [
|
|
772
|
+
chain.icon ?? /* @__PURE__ */ jsx5(ChainIconFallback, {}),
|
|
773
|
+
/* @__PURE__ */ jsx5(Text, { variant: "bodyMedium", color: "textPrimary", children: chain.label })
|
|
774
|
+
]
|
|
775
|
+
}
|
|
776
|
+
)
|
|
777
|
+
},
|
|
778
|
+
chain.id
|
|
779
|
+
)) })
|
|
780
|
+
]
|
|
781
|
+
}
|
|
782
|
+
);
|
|
783
|
+
}
|
|
784
|
+
function ChainIconFallback() {
|
|
785
|
+
return /* @__PURE__ */ jsx5(
|
|
786
|
+
Box,
|
|
787
|
+
{
|
|
788
|
+
width: 32,
|
|
789
|
+
height: 32,
|
|
790
|
+
borderRadius: "rounded",
|
|
791
|
+
backgroundColor: "pillPressed"
|
|
792
|
+
}
|
|
793
|
+
);
|
|
794
|
+
}
|
|
795
|
+
var topBar2 = {
|
|
796
|
+
paddingTop: 20,
|
|
797
|
+
paddingBottom: 12,
|
|
798
|
+
paddingHorizontal: 12
|
|
799
|
+
};
|
|
800
|
+
var topBarSpacer = { width: 32, height: 32 };
|
|
801
|
+
var grabber2 = {
|
|
802
|
+
position: "absolute",
|
|
803
|
+
top: 8,
|
|
804
|
+
left: "50%",
|
|
805
|
+
marginLeft: -18,
|
|
806
|
+
width: 36,
|
|
807
|
+
height: 5,
|
|
808
|
+
borderRadius: 999
|
|
809
|
+
};
|
|
810
|
+
var chevron = {
|
|
811
|
+
fontSize: 26,
|
|
812
|
+
lineHeight: 28,
|
|
813
|
+
width: 24,
|
|
814
|
+
textAlign: "center"
|
|
815
|
+
};
|
|
816
|
+
var content = { paddingHorizontal: 16, paddingBottom: 16 };
|
|
817
|
+
var row2 = { paddingHorizontal: 16, paddingVertical: 10 };
|
|
818
|
+
|
|
819
|
+
// src/screens/QrCodeScreen.tsx
|
|
820
|
+
import { Pressable as Pressable3 } from "react-native";
|
|
821
|
+
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
822
|
+
function QrCodeScreen({
|
|
823
|
+
qrCode,
|
|
824
|
+
accountName,
|
|
825
|
+
onClose,
|
|
826
|
+
onShare,
|
|
827
|
+
onSupportedChainsPress
|
|
828
|
+
}) {
|
|
829
|
+
return /* @__PURE__ */ jsxs3(
|
|
830
|
+
Box,
|
|
831
|
+
{
|
|
832
|
+
backgroundColor: "bgModal",
|
|
833
|
+
borderTopLeftRadius: "modal",
|
|
834
|
+
borderTopRightRadius: "modal",
|
|
835
|
+
style: sheet,
|
|
836
|
+
children: [
|
|
837
|
+
/* @__PURE__ */ jsxs3(Box, { flexDirection: "row", alignItems: "center", style: topBar3, children: [
|
|
838
|
+
/* @__PURE__ */ jsx6(Box, { backgroundColor: "borderFocused", style: grabber3 }),
|
|
839
|
+
/* @__PURE__ */ jsx6(
|
|
840
|
+
Pressable3,
|
|
841
|
+
{
|
|
842
|
+
onPress: onClose,
|
|
843
|
+
hitSlop: 12,
|
|
844
|
+
accessibilityRole: "button",
|
|
845
|
+
accessibilityLabel: "Close",
|
|
846
|
+
children: /* @__PURE__ */ jsx6(Text, { color: "textPrimary", style: closeGlyph, children: "\u2715" })
|
|
847
|
+
}
|
|
848
|
+
),
|
|
849
|
+
/* @__PURE__ */ jsx6(Box, { flex: 1 }),
|
|
850
|
+
/* @__PURE__ */ jsx6(Box, { style: topBarSpacer2 })
|
|
851
|
+
] }),
|
|
852
|
+
/* @__PURE__ */ jsxs3(Box, { alignItems: "center", style: content2, children: [
|
|
853
|
+
/* @__PURE__ */ jsxs3(Text, { variant: "body", color: "textSecondary", style: caption, children: [
|
|
854
|
+
`Scan to deposit to this ${accountName ? `${accountName} ` : ""}account.
|
|
855
|
+
`,
|
|
856
|
+
"Use it only for",
|
|
857
|
+
" ",
|
|
858
|
+
/* @__PURE__ */ jsx6(
|
|
859
|
+
Text,
|
|
860
|
+
{
|
|
861
|
+
variant: "body",
|
|
862
|
+
color: "textSecondary",
|
|
863
|
+
style: link,
|
|
864
|
+
onPress: onSupportedChainsPress,
|
|
865
|
+
accessibilityRole: "link",
|
|
866
|
+
accessibilityLabel: "supported chains",
|
|
867
|
+
children: "supported chains"
|
|
868
|
+
}
|
|
869
|
+
)
|
|
870
|
+
] }),
|
|
871
|
+
/* @__PURE__ */ jsx6(
|
|
872
|
+
Box,
|
|
873
|
+
{
|
|
874
|
+
backgroundColor: "bgModal",
|
|
875
|
+
borderColor: "borderDefault",
|
|
876
|
+
borderWidth: 2,
|
|
877
|
+
alignItems: "center",
|
|
878
|
+
justifyContent: "center",
|
|
879
|
+
style: qrFrame,
|
|
880
|
+
children: qrCode
|
|
881
|
+
}
|
|
882
|
+
),
|
|
883
|
+
/* @__PURE__ */ jsx6(
|
|
884
|
+
Pressable3,
|
|
885
|
+
{
|
|
886
|
+
onPress: onShare,
|
|
887
|
+
accessibilityRole: "button",
|
|
888
|
+
accessibilityLabel: "Share",
|
|
889
|
+
children: /* @__PURE__ */ jsx6(
|
|
890
|
+
Box,
|
|
891
|
+
{
|
|
892
|
+
width: 68,
|
|
893
|
+
height: 68,
|
|
894
|
+
borderRadius: "rounded",
|
|
895
|
+
backgroundColor: "bgSecondary",
|
|
896
|
+
alignItems: "center",
|
|
897
|
+
justifyContent: "center",
|
|
898
|
+
children: /* @__PURE__ */ jsx6(Text, { color: "textPrimary", style: shareGlyph, children: "\u2191" })
|
|
899
|
+
}
|
|
900
|
+
)
|
|
901
|
+
}
|
|
902
|
+
)
|
|
903
|
+
] })
|
|
904
|
+
]
|
|
905
|
+
}
|
|
906
|
+
);
|
|
907
|
+
}
|
|
908
|
+
var sheet = { paddingBottom: 32 };
|
|
909
|
+
var topBar3 = {
|
|
910
|
+
paddingTop: 20,
|
|
911
|
+
paddingBottom: 8,
|
|
912
|
+
paddingHorizontal: 12
|
|
913
|
+
};
|
|
914
|
+
var topBarSpacer2 = { width: 32, height: 32 };
|
|
915
|
+
var grabber3 = {
|
|
916
|
+
position: "absolute",
|
|
917
|
+
top: 8,
|
|
918
|
+
left: "50%",
|
|
919
|
+
marginLeft: -18,
|
|
920
|
+
width: 36,
|
|
921
|
+
height: 5,
|
|
922
|
+
borderRadius: 999
|
|
923
|
+
};
|
|
924
|
+
var content2 = { paddingHorizontal: 20, paddingTop: 16, gap: 32 };
|
|
925
|
+
var caption = { textAlign: "center" };
|
|
926
|
+
var link = { textDecorationLine: "underline" };
|
|
927
|
+
var qrFrame = {
|
|
928
|
+
width: 275,
|
|
929
|
+
height: 275,
|
|
930
|
+
borderRadius: 20,
|
|
931
|
+
padding: 16
|
|
932
|
+
};
|
|
933
|
+
var closeGlyph = { fontSize: 18, lineHeight: 22 };
|
|
934
|
+
var shareGlyph = { fontSize: 28, lineHeight: 32, fontWeight: "500" };
|
|
935
|
+
|
|
936
|
+
// src/screens/SupportedTokensScreen.tsx
|
|
937
|
+
import { useTheme as useTheme2 } from "@shopify/restyle";
|
|
938
|
+
import { Pressable as Pressable4, ScrollView as ScrollView2, TextInput } from "react-native";
|
|
939
|
+
import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
940
|
+
function SupportedTokensScreen({
|
|
941
|
+
tokens,
|
|
942
|
+
onSelectToken,
|
|
943
|
+
searchValue,
|
|
944
|
+
onSearchChange,
|
|
945
|
+
searchPlaceholder = "Search token",
|
|
946
|
+
chainFilters = [],
|
|
947
|
+
selectedChainFilterId,
|
|
948
|
+
onSelectChainFilter,
|
|
949
|
+
onBack,
|
|
950
|
+
title = "Supported tokens"
|
|
951
|
+
}) {
|
|
952
|
+
const theme = useTheme2();
|
|
953
|
+
return /* @__PURE__ */ jsxs4(
|
|
954
|
+
Box,
|
|
955
|
+
{
|
|
956
|
+
backgroundColor: "bgModal",
|
|
957
|
+
borderTopLeftRadius: "modal",
|
|
958
|
+
borderTopRightRadius: "modal",
|
|
959
|
+
children: [
|
|
960
|
+
/* @__PURE__ */ jsxs4(Box, { flexDirection: "row", alignItems: "center", gap: "none", style: topBar4, children: [
|
|
961
|
+
/* @__PURE__ */ jsx7(Box, { backgroundColor: "borderFocused", style: grabber4 }),
|
|
962
|
+
/* @__PURE__ */ jsx7(
|
|
963
|
+
Pressable4,
|
|
964
|
+
{
|
|
965
|
+
onPress: onBack,
|
|
966
|
+
hitSlop: 12,
|
|
967
|
+
accessibilityRole: "button",
|
|
968
|
+
accessibilityLabel: "Back",
|
|
969
|
+
children: /* @__PURE__ */ jsx7(Text, { color: "textPrimary", style: chevron2, children: "\u2039" })
|
|
970
|
+
}
|
|
971
|
+
),
|
|
972
|
+
/* @__PURE__ */ jsx7(Box, { flex: 1, alignItems: "center", children: /* @__PURE__ */ jsx7(Text, { variant: "bodyMedium", color: "textPrimary", children: title }) }),
|
|
973
|
+
/* @__PURE__ */ jsx7(Box, { style: topBarSpacer3 })
|
|
974
|
+
] }),
|
|
975
|
+
/* @__PURE__ */ jsxs4(Box, { style: content3, children: [
|
|
976
|
+
/* @__PURE__ */ jsxs4(
|
|
977
|
+
Box,
|
|
978
|
+
{
|
|
979
|
+
flexDirection: "row",
|
|
980
|
+
alignItems: "center",
|
|
981
|
+
gap: "elementsHorizontal",
|
|
982
|
+
backgroundColor: "bgModal",
|
|
983
|
+
borderColor: "borderDefault",
|
|
984
|
+
borderWidth: 1,
|
|
985
|
+
borderRadius: "element",
|
|
986
|
+
style: searchBox,
|
|
987
|
+
children: [
|
|
988
|
+
/* @__PURE__ */ jsx7(SearchGlyph, {}),
|
|
989
|
+
/* @__PURE__ */ jsx7(
|
|
990
|
+
TextInput,
|
|
991
|
+
{
|
|
992
|
+
value: searchValue,
|
|
993
|
+
onChangeText: onSearchChange,
|
|
994
|
+
placeholder: searchPlaceholder,
|
|
995
|
+
placeholderTextColor: theme.colors.textSecondary,
|
|
996
|
+
style: [searchInput, { color: theme.colors.textPrimary }]
|
|
997
|
+
}
|
|
998
|
+
)
|
|
999
|
+
]
|
|
1000
|
+
}
|
|
1001
|
+
),
|
|
1002
|
+
chainFilters.length > 0 ? /* @__PURE__ */ jsx7(
|
|
1003
|
+
ScrollView2,
|
|
1004
|
+
{
|
|
1005
|
+
horizontal: true,
|
|
1006
|
+
showsHorizontalScrollIndicator: false,
|
|
1007
|
+
contentContainerStyle: chipRow,
|
|
1008
|
+
children: chainFilters.map((filter) => {
|
|
1009
|
+
const selected = filter.id === selectedChainFilterId;
|
|
1010
|
+
return /* @__PURE__ */ jsx7(
|
|
1011
|
+
Pressable4,
|
|
1012
|
+
{
|
|
1013
|
+
onPress: () => onSelectChainFilter?.(filter.id),
|
|
1014
|
+
accessibilityRole: "button",
|
|
1015
|
+
accessibilityLabel: filter.label,
|
|
1016
|
+
accessibilityState: { selected },
|
|
1017
|
+
children: /* @__PURE__ */ jsx7(
|
|
1018
|
+
Box,
|
|
1019
|
+
{
|
|
1020
|
+
backgroundColor: selected ? "btnPrimary" : "bgSecondary",
|
|
1021
|
+
borderRadius: "rounded",
|
|
1022
|
+
style: chip,
|
|
1023
|
+
children: /* @__PURE__ */ jsx7(
|
|
1024
|
+
Text,
|
|
1025
|
+
{
|
|
1026
|
+
variant: "bodyMedium",
|
|
1027
|
+
color: selected ? "onBtnPrimary" : "textPrimary",
|
|
1028
|
+
children: filter.label
|
|
1029
|
+
}
|
|
1030
|
+
)
|
|
1031
|
+
}
|
|
1032
|
+
)
|
|
1033
|
+
},
|
|
1034
|
+
filter.id
|
|
1035
|
+
);
|
|
1036
|
+
})
|
|
1037
|
+
}
|
|
1038
|
+
) : null,
|
|
1039
|
+
/* @__PURE__ */ jsx7(ScrollView2, { style: list, showsVerticalScrollIndicator: false, children: tokens.map((token) => /* @__PURE__ */ jsx7(
|
|
1040
|
+
Pressable4,
|
|
1041
|
+
{
|
|
1042
|
+
onPress: () => onSelectToken?.(token.id),
|
|
1043
|
+
accessibilityRole: "button",
|
|
1044
|
+
accessibilityLabel: `${token.symbol} on ${token.chainLabel}`,
|
|
1045
|
+
children: /* @__PURE__ */ jsxs4(
|
|
1046
|
+
Box,
|
|
1047
|
+
{
|
|
1048
|
+
flexDirection: "row",
|
|
1049
|
+
alignItems: "center",
|
|
1050
|
+
gap: "elementsHorizontal",
|
|
1051
|
+
borderRadius: "element",
|
|
1052
|
+
style: row3,
|
|
1053
|
+
children: [
|
|
1054
|
+
token.icon ?? /* @__PURE__ */ jsx7(TokenIconFallback, {}),
|
|
1055
|
+
/* @__PURE__ */ jsx7(Box, { flex: 1, children: /* @__PURE__ */ jsx7(Text, { variant: "bodyMedium", color: "textPrimary", children: token.symbol }) }),
|
|
1056
|
+
/* @__PURE__ */ jsx7(Text, { variant: "detail", color: "textSecondary", children: token.chainLabel })
|
|
1057
|
+
]
|
|
1058
|
+
}
|
|
1059
|
+
)
|
|
1060
|
+
},
|
|
1061
|
+
token.id
|
|
1062
|
+
)) })
|
|
1063
|
+
] })
|
|
1064
|
+
]
|
|
1065
|
+
}
|
|
1066
|
+
);
|
|
1067
|
+
}
|
|
1068
|
+
function TokenIconFallback() {
|
|
1069
|
+
return /* @__PURE__ */ jsx7(
|
|
1070
|
+
Box,
|
|
1071
|
+
{
|
|
1072
|
+
width: 32,
|
|
1073
|
+
height: 32,
|
|
1074
|
+
borderRadius: "rounded",
|
|
1075
|
+
backgroundColor: "pillPressed"
|
|
1076
|
+
}
|
|
1077
|
+
);
|
|
1078
|
+
}
|
|
1079
|
+
function SearchGlyph() {
|
|
1080
|
+
return /* @__PURE__ */ jsxs4(Box, { width: 16, height: 16, children: [
|
|
1081
|
+
/* @__PURE__ */ jsx7(Box, { borderWidth: 1.5, borderColor: "textSecondary", style: searchLens }),
|
|
1082
|
+
/* @__PURE__ */ jsx7(Box, { backgroundColor: "textSecondary", style: searchHandle })
|
|
1083
|
+
] });
|
|
1084
|
+
}
|
|
1085
|
+
var topBar4 = {
|
|
1086
|
+
paddingTop: 20,
|
|
1087
|
+
paddingBottom: 12,
|
|
1088
|
+
paddingHorizontal: 12
|
|
1089
|
+
};
|
|
1090
|
+
var topBarSpacer3 = { width: 32, height: 32 };
|
|
1091
|
+
var grabber4 = {
|
|
1092
|
+
position: "absolute",
|
|
1093
|
+
top: 8,
|
|
1094
|
+
left: "50%",
|
|
1095
|
+
marginLeft: -18,
|
|
1096
|
+
width: 36,
|
|
1097
|
+
height: 5,
|
|
1098
|
+
borderRadius: 999
|
|
1099
|
+
};
|
|
1100
|
+
var chevron2 = {
|
|
1101
|
+
fontSize: 26,
|
|
1102
|
+
lineHeight: 28,
|
|
1103
|
+
width: 24,
|
|
1104
|
+
textAlign: "center"
|
|
1105
|
+
};
|
|
1106
|
+
var content3 = { paddingHorizontal: 16, paddingBottom: 16, gap: 12 };
|
|
1107
|
+
var searchBox = {
|
|
1108
|
+
height: 44,
|
|
1109
|
+
paddingHorizontal: 12
|
|
1110
|
+
};
|
|
1111
|
+
var searchInput = {
|
|
1112
|
+
flex: 1,
|
|
1113
|
+
fontFamily: "Inter",
|
|
1114
|
+
fontSize: 16,
|
|
1115
|
+
padding: 0
|
|
1116
|
+
};
|
|
1117
|
+
var chipRow = { gap: 8 };
|
|
1118
|
+
var chip = { paddingHorizontal: 16, paddingVertical: 10 };
|
|
1119
|
+
var list = { maxHeight: 360 };
|
|
1120
|
+
var row3 = { padding: 16 };
|
|
1121
|
+
var searchLens = {
|
|
1122
|
+
width: 11,
|
|
1123
|
+
height: 11,
|
|
1124
|
+
borderRadius: 999
|
|
1125
|
+
};
|
|
1126
|
+
var searchHandle = {
|
|
1127
|
+
position: "absolute",
|
|
1128
|
+
right: 0,
|
|
1129
|
+
bottom: 1,
|
|
1130
|
+
width: 5,
|
|
1131
|
+
height: 1.5,
|
|
1132
|
+
transform: [{ rotate: "45deg" }]
|
|
1133
|
+
};
|
|
1134
|
+
|
|
1135
|
+
// src/screens/TransferCryptoScreen.tsx
|
|
1136
|
+
import { useEffect as useEffect3, useRef, useState as useState4 } from "react";
|
|
1137
|
+
import { Pressable as Pressable5 } from "react-native";
|
|
1138
|
+
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1139
|
+
function TransferCryptoScreen({
|
|
1140
|
+
depositAddress,
|
|
1141
|
+
networkLabel,
|
|
1142
|
+
networkIcon,
|
|
1143
|
+
title = "Transfer Crypto",
|
|
1144
|
+
depositAddressLabel = "Your deposit address",
|
|
1145
|
+
copiedFeedbackMs = 1800,
|
|
1146
|
+
onBack,
|
|
1147
|
+
onShowQrCode,
|
|
1148
|
+
onChangeNetwork,
|
|
1149
|
+
onShowSupportedTokens,
|
|
1150
|
+
onCopyAddress,
|
|
1151
|
+
onShareAddress
|
|
1152
|
+
}) {
|
|
1153
|
+
const [copied, setCopied] = useState4(false);
|
|
1154
|
+
const copyTimer = useRef(void 0);
|
|
1155
|
+
useEffect3(() => () => clearTimeout(copyTimer.current), []);
|
|
1156
|
+
const handleCopy = () => {
|
|
1157
|
+
onCopyAddress?.();
|
|
1158
|
+
setCopied(true);
|
|
1159
|
+
clearTimeout(copyTimer.current);
|
|
1160
|
+
copyTimer.current = setTimeout(() => setCopied(false), copiedFeedbackMs);
|
|
1161
|
+
};
|
|
1162
|
+
return /* @__PURE__ */ jsxs5(
|
|
1163
|
+
Box,
|
|
1164
|
+
{
|
|
1165
|
+
backgroundColor: "bgModal",
|
|
1166
|
+
borderTopLeftRadius: "modal",
|
|
1167
|
+
borderTopRightRadius: "modal",
|
|
1168
|
+
children: [
|
|
1169
|
+
/* @__PURE__ */ jsxs5(Box, { flexDirection: "row", alignItems: "center", gap: "none", style: topBar5, children: [
|
|
1170
|
+
/* @__PURE__ */ jsx8(Box, { backgroundColor: "borderFocused", style: grabber5 }),
|
|
1171
|
+
/* @__PURE__ */ jsx8(
|
|
1172
|
+
Pressable5,
|
|
1173
|
+
{
|
|
1174
|
+
onPress: onBack,
|
|
1175
|
+
hitSlop: 12,
|
|
1176
|
+
accessibilityRole: "button",
|
|
1177
|
+
accessibilityLabel: "Back",
|
|
1178
|
+
children: /* @__PURE__ */ jsx8(Text, { color: "textPrimary", style: chevron3, children: "\u2039" })
|
|
1179
|
+
}
|
|
1180
|
+
),
|
|
1181
|
+
/* @__PURE__ */ jsx8(Box, { flex: 1, alignItems: "center", children: /* @__PURE__ */ jsx8(Text, { variant: "bodyMedium", color: "textPrimary", children: title }) }),
|
|
1182
|
+
/* @__PURE__ */ jsx8(
|
|
1183
|
+
Pressable5,
|
|
1184
|
+
{
|
|
1185
|
+
onPress: onShowQrCode,
|
|
1186
|
+
hitSlop: 12,
|
|
1187
|
+
accessibilityRole: "button",
|
|
1188
|
+
accessibilityLabel: "Show QR code",
|
|
1189
|
+
children: /* @__PURE__ */ jsx8(QrGlyph, {})
|
|
1190
|
+
}
|
|
1191
|
+
)
|
|
1192
|
+
] }),
|
|
1193
|
+
/* @__PURE__ */ jsxs5(Box, { style: content4, children: [
|
|
1194
|
+
/* @__PURE__ */ jsxs5(
|
|
1195
|
+
Box,
|
|
1196
|
+
{
|
|
1197
|
+
flexDirection: "row",
|
|
1198
|
+
alignItems: "center",
|
|
1199
|
+
justifyContent: "space-between",
|
|
1200
|
+
backgroundColor: "bgSecondary",
|
|
1201
|
+
borderColor: "borderDefault",
|
|
1202
|
+
borderWidth: 1,
|
|
1203
|
+
borderRadius: "button",
|
|
1204
|
+
style: networkRow,
|
|
1205
|
+
children: [
|
|
1206
|
+
/* @__PURE__ */ jsx8(
|
|
1207
|
+
Pressable5,
|
|
1208
|
+
{
|
|
1209
|
+
onPress: onShowSupportedTokens,
|
|
1210
|
+
accessibilityRole: "button",
|
|
1211
|
+
accessibilityLabel: "Supported tokens",
|
|
1212
|
+
style: networkInfoPress,
|
|
1213
|
+
children: /* @__PURE__ */ jsxs5(
|
|
1214
|
+
Box,
|
|
1215
|
+
{
|
|
1216
|
+
flexDirection: "row",
|
|
1217
|
+
alignItems: "center",
|
|
1218
|
+
gap: "elementsHorizontal",
|
|
1219
|
+
children: [
|
|
1220
|
+
networkIcon ?? /* @__PURE__ */ jsx8(NetworkIconFallback, {}),
|
|
1221
|
+
/* @__PURE__ */ jsxs5(Box, { flexDirection: "row", alignItems: "center", style: labelInfo, children: [
|
|
1222
|
+
/* @__PURE__ */ jsx8(Text, { variant: "bodyMedium", color: "textPrimary", children: networkLabel }),
|
|
1223
|
+
/* @__PURE__ */ jsx8(InfoGlyph, {})
|
|
1224
|
+
] })
|
|
1225
|
+
]
|
|
1226
|
+
}
|
|
1227
|
+
)
|
|
1228
|
+
}
|
|
1229
|
+
),
|
|
1230
|
+
/* @__PURE__ */ jsx8(
|
|
1231
|
+
Pressable5,
|
|
1232
|
+
{
|
|
1233
|
+
onPress: onChangeNetwork,
|
|
1234
|
+
accessibilityRole: "button",
|
|
1235
|
+
accessibilityLabel: "Change network",
|
|
1236
|
+
hitSlop: 8,
|
|
1237
|
+
children: /* @__PURE__ */ jsx8(Text, { variant: "bodyMedium", color: "textSecondary", children: "Change" })
|
|
1238
|
+
}
|
|
1239
|
+
)
|
|
1240
|
+
]
|
|
1241
|
+
}
|
|
1242
|
+
),
|
|
1243
|
+
/* @__PURE__ */ jsxs5(
|
|
1244
|
+
Box,
|
|
1245
|
+
{
|
|
1246
|
+
flexDirection: "row",
|
|
1247
|
+
alignItems: "center",
|
|
1248
|
+
gap: "elementsHorizontal",
|
|
1249
|
+
borderColor: "borderDefault",
|
|
1250
|
+
borderWidth: 1,
|
|
1251
|
+
borderRadius: "button",
|
|
1252
|
+
style: addressCard,
|
|
1253
|
+
children: [
|
|
1254
|
+
/* @__PURE__ */ jsxs5(Box, { flex: 1, style: addressDetails, children: [
|
|
1255
|
+
/* @__PURE__ */ jsx8(
|
|
1256
|
+
Text,
|
|
1257
|
+
{
|
|
1258
|
+
variant: "detail",
|
|
1259
|
+
color: copied ? "textSuccess" : "textSecondary",
|
|
1260
|
+
children: copied ? "Copied!" : depositAddressLabel
|
|
1261
|
+
}
|
|
1262
|
+
),
|
|
1263
|
+
/* @__PURE__ */ jsx8(Text, { variant: "bodyMedium", color: "textPrimary", children: depositAddress })
|
|
1264
|
+
] }),
|
|
1265
|
+
/* @__PURE__ */ jsx8(
|
|
1266
|
+
CircleIconButton,
|
|
1267
|
+
{
|
|
1268
|
+
label: copied ? "Address copied" : "Copy address",
|
|
1269
|
+
onPress: handleCopy,
|
|
1270
|
+
children: copied ? /* @__PURE__ */ jsx8(Text, { color: "textSuccess", style: shareGlyph2, children: "\u2713" }) : /* @__PURE__ */ jsx8(CopyGlyph, {})
|
|
1271
|
+
}
|
|
1272
|
+
),
|
|
1273
|
+
/* @__PURE__ */ jsx8(CircleIconButton, { label: "Share address", onPress: onShareAddress, children: /* @__PURE__ */ jsx8(Text, { color: "textPrimary", style: shareGlyph2, children: "\u2191" }) })
|
|
1274
|
+
]
|
|
1275
|
+
}
|
|
1276
|
+
)
|
|
1277
|
+
] })
|
|
1278
|
+
]
|
|
1279
|
+
}
|
|
1280
|
+
);
|
|
1281
|
+
}
|
|
1282
|
+
function CircleIconButton({
|
|
1283
|
+
children,
|
|
1284
|
+
label,
|
|
1285
|
+
onPress
|
|
1286
|
+
}) {
|
|
1287
|
+
return /* @__PURE__ */ jsx8(
|
|
1288
|
+
Pressable5,
|
|
1289
|
+
{
|
|
1290
|
+
onPress,
|
|
1291
|
+
accessibilityRole: "button",
|
|
1292
|
+
accessibilityLabel: label,
|
|
1293
|
+
children: /* @__PURE__ */ jsx8(
|
|
1294
|
+
Box,
|
|
1295
|
+
{
|
|
1296
|
+
width: 48,
|
|
1297
|
+
height: 48,
|
|
1298
|
+
borderRadius: "rounded",
|
|
1299
|
+
backgroundColor: "bgSecondary",
|
|
1300
|
+
alignItems: "center",
|
|
1301
|
+
justifyContent: "center",
|
|
1302
|
+
children
|
|
1303
|
+
}
|
|
1304
|
+
)
|
|
1305
|
+
}
|
|
1306
|
+
);
|
|
1307
|
+
}
|
|
1308
|
+
function InfoGlyph() {
|
|
1309
|
+
return /* @__PURE__ */ jsx8(
|
|
1310
|
+
Box,
|
|
1311
|
+
{
|
|
1312
|
+
width: 16,
|
|
1313
|
+
height: 16,
|
|
1314
|
+
borderRadius: "rounded",
|
|
1315
|
+
borderWidth: 1,
|
|
1316
|
+
borderColor: "textSecondary",
|
|
1317
|
+
alignItems: "center",
|
|
1318
|
+
justifyContent: "center",
|
|
1319
|
+
children: /* @__PURE__ */ jsx8(Text, { color: "textSecondary", style: infoChar, children: "i" })
|
|
1320
|
+
}
|
|
1321
|
+
);
|
|
1322
|
+
}
|
|
1323
|
+
function NetworkIconFallback() {
|
|
1324
|
+
return /* @__PURE__ */ jsx8(
|
|
1325
|
+
Box,
|
|
1326
|
+
{
|
|
1327
|
+
width: 32,
|
|
1328
|
+
height: 32,
|
|
1329
|
+
borderRadius: "rounded",
|
|
1330
|
+
backgroundColor: "pillPressed"
|
|
1331
|
+
}
|
|
1332
|
+
);
|
|
1333
|
+
}
|
|
1334
|
+
function QrGlyph() {
|
|
1335
|
+
return /* @__PURE__ */ jsx8(
|
|
1336
|
+
Box,
|
|
1337
|
+
{
|
|
1338
|
+
width: 20,
|
|
1339
|
+
height: 20,
|
|
1340
|
+
flexDirection: "row",
|
|
1341
|
+
flexWrap: "wrap",
|
|
1342
|
+
style: qrGrid,
|
|
1343
|
+
children: [0, 1, 2, 3].map((i) => /* @__PURE__ */ jsx8(
|
|
1344
|
+
Box,
|
|
1345
|
+
{
|
|
1346
|
+
width: 8,
|
|
1347
|
+
height: 8,
|
|
1348
|
+
backgroundColor: "textPrimary",
|
|
1349
|
+
borderRadius: "elementInner"
|
|
1350
|
+
},
|
|
1351
|
+
i
|
|
1352
|
+
))
|
|
1353
|
+
}
|
|
1354
|
+
);
|
|
1355
|
+
}
|
|
1356
|
+
function CopyGlyph() {
|
|
1357
|
+
return /* @__PURE__ */ jsxs5(Box, { width: 18, height: 18, children: [
|
|
1358
|
+
/* @__PURE__ */ jsx8(Box, { borderWidth: 1.5, borderColor: "textPrimary", style: copyBack }),
|
|
1359
|
+
/* @__PURE__ */ jsx8(
|
|
1360
|
+
Box,
|
|
1361
|
+
{
|
|
1362
|
+
borderWidth: 1.5,
|
|
1363
|
+
borderColor: "textPrimary",
|
|
1364
|
+
backgroundColor: "bgSecondary",
|
|
1365
|
+
style: copyFront
|
|
1366
|
+
}
|
|
1367
|
+
)
|
|
1368
|
+
] });
|
|
1369
|
+
}
|
|
1370
|
+
var topBar5 = {
|
|
1371
|
+
paddingTop: 20,
|
|
1372
|
+
paddingBottom: 12,
|
|
1373
|
+
paddingHorizontal: 12
|
|
1374
|
+
};
|
|
1375
|
+
var grabber5 = {
|
|
1376
|
+
position: "absolute",
|
|
1377
|
+
top: 8,
|
|
1378
|
+
left: "50%",
|
|
1379
|
+
marginLeft: -18,
|
|
1380
|
+
width: 36,
|
|
1381
|
+
height: 5,
|
|
1382
|
+
borderRadius: 999
|
|
1383
|
+
};
|
|
1384
|
+
var chevron3 = {
|
|
1385
|
+
fontSize: 26,
|
|
1386
|
+
lineHeight: 28,
|
|
1387
|
+
width: 24,
|
|
1388
|
+
textAlign: "center"
|
|
1389
|
+
};
|
|
1390
|
+
var content4 = {
|
|
1391
|
+
paddingHorizontal: 20,
|
|
1392
|
+
paddingBottom: 16,
|
|
1393
|
+
paddingTop: 8,
|
|
1394
|
+
gap: 8
|
|
1395
|
+
};
|
|
1396
|
+
var networkRow = { paddingHorizontal: 16, paddingVertical: 10 };
|
|
1397
|
+
var networkInfoPress = { flexShrink: 1 };
|
|
1398
|
+
var labelInfo = { gap: 6 };
|
|
1399
|
+
var infoChar = { fontSize: 11, lineHeight: 13, fontWeight: "600" };
|
|
1400
|
+
var addressCard = { padding: 16 };
|
|
1401
|
+
var addressDetails = { gap: 4 };
|
|
1402
|
+
var shareGlyph2 = { fontSize: 18, lineHeight: 20, fontWeight: "500" };
|
|
1403
|
+
var qrGrid = { gap: 2 };
|
|
1404
|
+
var copyBack = {
|
|
1405
|
+
position: "absolute",
|
|
1406
|
+
right: 0,
|
|
1407
|
+
top: 0,
|
|
1408
|
+
width: 13,
|
|
1409
|
+
height: 13,
|
|
1410
|
+
borderRadius: 3
|
|
1411
|
+
};
|
|
1412
|
+
var copyFront = {
|
|
1413
|
+
position: "absolute",
|
|
1414
|
+
left: 0,
|
|
1415
|
+
bottom: 0,
|
|
1416
|
+
width: 13,
|
|
1417
|
+
height: 13,
|
|
1418
|
+
borderRadius: 3
|
|
1419
|
+
};
|
|
1420
|
+
|
|
1421
|
+
// src/swapped/SwappedScreen.tsx
|
|
1422
|
+
import { useCallback as useCallback2 } from "react";
|
|
1423
|
+
|
|
1424
|
+
// src/logging/logger.ts
|
|
1425
|
+
import { FunLogger } from "@funkit/connect-core";
|
|
1426
|
+
|
|
1427
|
+
// src/logging/datadogHttpLogTransport.ts
|
|
1428
|
+
var DEFAULT_SERVICE = "connect-rn";
|
|
1429
|
+
var DEFAULT_SITE = "datadoghq.com";
|
|
1430
|
+
var DEFAULT_FLUSH_INTERVAL_MS = 5e3;
|
|
1431
|
+
var DEFAULT_MAX_BATCH_SIZE = 50;
|
|
1432
|
+
var DatadogHttpLogTransport = class {
|
|
1433
|
+
constructor(options) {
|
|
1434
|
+
this.consent = "granted";
|
|
1435
|
+
this.queue = [];
|
|
1436
|
+
this.flushTimer = null;
|
|
1437
|
+
const site = options.site ?? DEFAULT_SITE;
|
|
1438
|
+
this.service = options.service ?? DEFAULT_SERVICE;
|
|
1439
|
+
this.env = options.env;
|
|
1440
|
+
this.flushIntervalMs = options.flushIntervalMs ?? DEFAULT_FLUSH_INTERVAL_MS;
|
|
1441
|
+
this.maxBatchSize = options.maxBatchSize ?? DEFAULT_MAX_BATCH_SIZE;
|
|
1442
|
+
this.intakeUrl = `https://browser-intake-${site}/api/v2/logs?dd-api-key=${encodeURIComponent(options.clientToken)}&ddsource=react-native&dd-evp-origin=react-native`;
|
|
1443
|
+
}
|
|
1444
|
+
setEnv(environment) {
|
|
1445
|
+
this.env = environment;
|
|
1446
|
+
}
|
|
1447
|
+
setTrackingConsent(consent) {
|
|
1448
|
+
this.consent = consent;
|
|
1449
|
+
if (consent !== "granted") {
|
|
1450
|
+
this.queue = [];
|
|
1451
|
+
this.clearTimer();
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
log({ level, title, context, error }) {
|
|
1455
|
+
if (this.consent !== "granted") {
|
|
1456
|
+
return;
|
|
1457
|
+
}
|
|
1458
|
+
const entry = {
|
|
1459
|
+
ddsource: "react-native",
|
|
1460
|
+
service: this.service,
|
|
1461
|
+
status: level,
|
|
1462
|
+
message: title,
|
|
1463
|
+
...this.env ? { ddtags: `env:${this.env}` } : {},
|
|
1464
|
+
...context,
|
|
1465
|
+
...error ? {
|
|
1466
|
+
error: {
|
|
1467
|
+
message: error.message,
|
|
1468
|
+
stack: error.stack,
|
|
1469
|
+
kind: error.name
|
|
1470
|
+
}
|
|
1471
|
+
} : {}
|
|
1472
|
+
};
|
|
1473
|
+
this.queue.push(entry);
|
|
1474
|
+
if (this.queue.length >= this.maxBatchSize) {
|
|
1475
|
+
this.flush();
|
|
1476
|
+
} else {
|
|
1477
|
+
this.scheduleFlush();
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
/** Send the buffered batch. Fire-and-forget; network errors are swallowed. */
|
|
1481
|
+
flush() {
|
|
1482
|
+
this.clearTimer();
|
|
1483
|
+
if (this.queue.length === 0) {
|
|
1484
|
+
return;
|
|
1485
|
+
}
|
|
1486
|
+
if (typeof fetch !== "function") {
|
|
1487
|
+
this.queue = [];
|
|
1488
|
+
return;
|
|
1489
|
+
}
|
|
1490
|
+
const batch = this.queue;
|
|
1491
|
+
this.queue = [];
|
|
1492
|
+
fetch(this.intakeUrl, {
|
|
1493
|
+
method: "POST",
|
|
1494
|
+
headers: { "Content-Type": "application/json" },
|
|
1495
|
+
body: JSON.stringify(batch)
|
|
1496
|
+
}).catch(() => {
|
|
1497
|
+
});
|
|
1498
|
+
}
|
|
1499
|
+
scheduleFlush() {
|
|
1500
|
+
if (this.flushTimer != null) {
|
|
1501
|
+
return;
|
|
1502
|
+
}
|
|
1503
|
+
this.flushTimer = setTimeout(() => {
|
|
1504
|
+
this.flushTimer = null;
|
|
1505
|
+
this.flush();
|
|
1506
|
+
}, this.flushIntervalMs);
|
|
1507
|
+
}
|
|
1508
|
+
clearTimer() {
|
|
1509
|
+
if (this.flushTimer != null) {
|
|
1510
|
+
clearTimeout(this.flushTimer);
|
|
1511
|
+
this.flushTimer = null;
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
};
|
|
1515
|
+
|
|
1516
|
+
// src/logging/logger.ts
|
|
1517
|
+
var DDOG_CLIENT_TOKEN = "pub4f86c6be8c792cb48dc156a8c17d9a47";
|
|
1518
|
+
var logger = new FunLogger(
|
|
1519
|
+
new DatadogHttpLogTransport({
|
|
1520
|
+
clientToken: DDOG_CLIENT_TOKEN
|
|
1521
|
+
// service defaults to 'connect-rn' (see DatadogHttpLogTransport).
|
|
1522
|
+
})
|
|
1523
|
+
);
|
|
1524
|
+
|
|
1525
|
+
// src/swapped/SwappedWebView.tsx
|
|
1526
|
+
import { useEffect as useEffect4, useMemo as useMemo3, useRef as useRef2 } from "react";
|
|
1527
|
+
import { WebView } from "react-native-webview";
|
|
1528
|
+
|
|
1529
|
+
// src/swapped/webViewSwappedTransport.ts
|
|
1530
|
+
import {
|
|
1531
|
+
getSwappedOrigin
|
|
1532
|
+
} from "@funkit/connect-core";
|
|
1533
|
+
var SWAPPED_WEBVIEW_INJECTED_JS = `(function () {
|
|
1534
|
+
function forwardToNative(message) {
|
|
1535
|
+
try {
|
|
1536
|
+
var data = typeof message === 'string' ? message : JSON.stringify(message);
|
|
1537
|
+
window.ReactNativeWebView && window.ReactNativeWebView.postMessage(data);
|
|
1538
|
+
} catch (e) {}
|
|
1539
|
+
}
|
|
1540
|
+
// The embed posts to window.parent (and sometimes window) \u2014 redirect both.
|
|
1541
|
+
try { if (window.parent) { window.parent.postMessage = forwardToNative; } } catch (e) {}
|
|
1542
|
+
try { window.postMessage = forwardToNative; } catch (e) {}
|
|
1543
|
+
true;
|
|
1544
|
+
})();
|
|
1545
|
+
true;`;
|
|
1546
|
+
function handleWebViewMessage(rawData, url) {
|
|
1547
|
+
if (url != null && getSwappedOrigin(url) == null) {
|
|
1548
|
+
return null;
|
|
1549
|
+
}
|
|
1550
|
+
let parsed;
|
|
1551
|
+
if (typeof rawData === "string") {
|
|
1552
|
+
try {
|
|
1553
|
+
parsed = JSON.parse(rawData);
|
|
1554
|
+
} catch {
|
|
1555
|
+
return null;
|
|
1556
|
+
}
|
|
1557
|
+
} else {
|
|
1558
|
+
parsed = rawData;
|
|
1559
|
+
}
|
|
1560
|
+
const data = parsed;
|
|
1561
|
+
if (!data || typeof data.type !== "string") {
|
|
1562
|
+
return null;
|
|
1563
|
+
}
|
|
1564
|
+
return data;
|
|
1565
|
+
}
|
|
1566
|
+
function createWebViewSwappedTransport({
|
|
1567
|
+
getWebView
|
|
1568
|
+
}) {
|
|
1569
|
+
const handlers = /* @__PURE__ */ new Set();
|
|
1570
|
+
const transport = {
|
|
1571
|
+
send(msg) {
|
|
1572
|
+
const webView = getWebView();
|
|
1573
|
+
if (!webView) {
|
|
1574
|
+
return false;
|
|
1575
|
+
}
|
|
1576
|
+
webView.postMessage(JSON.stringify(msg));
|
|
1577
|
+
return true;
|
|
1578
|
+
},
|
|
1579
|
+
onMessage(handler) {
|
|
1580
|
+
handlers.add(handler);
|
|
1581
|
+
return () => {
|
|
1582
|
+
handlers.delete(handler);
|
|
1583
|
+
};
|
|
1584
|
+
}
|
|
1585
|
+
};
|
|
1586
|
+
function dispatch(rawData, url) {
|
|
1587
|
+
const msg = handleWebViewMessage(rawData, url);
|
|
1588
|
+
if (msg) {
|
|
1589
|
+
for (const handler of handlers) {
|
|
1590
|
+
handler(msg);
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
return { transport, dispatch };
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
// src/swapped/SwappedWebView.tsx
|
|
1598
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
1599
|
+
function SwappedWebView({ url, onMessage, style }) {
|
|
1600
|
+
const webViewRef = useRef2(null);
|
|
1601
|
+
const { transport, dispatch } = useMemo3(
|
|
1602
|
+
() => createWebViewSwappedTransport({
|
|
1603
|
+
getWebView: () => webViewRef.current
|
|
1604
|
+
}),
|
|
1605
|
+
[]
|
|
1606
|
+
);
|
|
1607
|
+
const handlerRef = useRef2(onMessage);
|
|
1608
|
+
handlerRef.current = onMessage;
|
|
1609
|
+
useEffect4(
|
|
1610
|
+
() => transport.onMessage((msg) => handlerRef.current(msg)),
|
|
1611
|
+
[transport]
|
|
1612
|
+
);
|
|
1613
|
+
const handleMessage = (event) => {
|
|
1614
|
+
dispatch(event.nativeEvent.data, event.nativeEvent.url);
|
|
1615
|
+
};
|
|
1616
|
+
const handleError = (event) => {
|
|
1617
|
+
logger.warn("connect-rn:swapped:webview:error", {
|
|
1618
|
+
code: String(event.nativeEvent.code),
|
|
1619
|
+
description: event.nativeEvent.description,
|
|
1620
|
+
url: event.nativeEvent.url
|
|
1621
|
+
});
|
|
1622
|
+
};
|
|
1623
|
+
const handleHttpError = (event) => {
|
|
1624
|
+
logger.warn("connect-rn:swapped:webview:httpError", {
|
|
1625
|
+
status: String(event.nativeEvent.statusCode),
|
|
1626
|
+
url: event.nativeEvent.url
|
|
1627
|
+
});
|
|
1628
|
+
};
|
|
1629
|
+
return /* @__PURE__ */ jsx9(
|
|
1630
|
+
WebView,
|
|
1631
|
+
{
|
|
1632
|
+
ref: webViewRef,
|
|
1633
|
+
source: { uri: url },
|
|
1634
|
+
onMessage: handleMessage,
|
|
1635
|
+
onError: handleError,
|
|
1636
|
+
onHttpError: handleHttpError,
|
|
1637
|
+
injectedJavaScriptBeforeContentLoaded: SWAPPED_WEBVIEW_INJECTED_JS,
|
|
1638
|
+
startInLoadingState: true,
|
|
1639
|
+
javaScriptEnabled: true,
|
|
1640
|
+
domStorageEnabled: true,
|
|
1641
|
+
sharedCookiesEnabled: true,
|
|
1642
|
+
thirdPartyCookiesEnabled: true,
|
|
1643
|
+
allowsInlineMediaPlayback: true,
|
|
1644
|
+
setSupportMultipleWindows: false,
|
|
1645
|
+
originWhitelist: ["https://*"],
|
|
1646
|
+
style
|
|
1647
|
+
}
|
|
1648
|
+
);
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
// src/swapped/SwappedScreen.tsx
|
|
1652
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
1653
|
+
function SwappedScreen({
|
|
1654
|
+
url,
|
|
1655
|
+
onClose,
|
|
1656
|
+
onBack,
|
|
1657
|
+
onSuccess
|
|
1658
|
+
}) {
|
|
1659
|
+
const handleMessage = useCallback2(
|
|
1660
|
+
(msg) => {
|
|
1661
|
+
switch (msg.type) {
|
|
1662
|
+
case "SWAPPED_GO_BACK":
|
|
1663
|
+
case "SWAPPED_NEW_DEPOSIT":
|
|
1664
|
+
onBack();
|
|
1665
|
+
break;
|
|
1666
|
+
case "SWAPPED_CLOSE":
|
|
1667
|
+
onClose();
|
|
1668
|
+
break;
|
|
1669
|
+
case "SWAPPED_TRANSACTION_SUCCESSFUL":
|
|
1670
|
+
logger.info("connect-rn:swapped:transaction_successful");
|
|
1671
|
+
onSuccess?.();
|
|
1672
|
+
break;
|
|
1673
|
+
case "SWAPPED_ERROR":
|
|
1674
|
+
logger.warn("connect-rn:swapped:error", {
|
|
1675
|
+
data: JSON.stringify(msg.data ?? {})
|
|
1676
|
+
});
|
|
1677
|
+
break;
|
|
1678
|
+
default:
|
|
1679
|
+
break;
|
|
1680
|
+
}
|
|
1681
|
+
},
|
|
1682
|
+
[onBack, onClose, onSuccess]
|
|
1683
|
+
);
|
|
1684
|
+
return /* @__PURE__ */ jsx10(
|
|
1685
|
+
Box,
|
|
1686
|
+
{
|
|
1687
|
+
backgroundColor: "bgModal",
|
|
1688
|
+
borderTopLeftRadius: "modal",
|
|
1689
|
+
borderTopRightRadius: "modal",
|
|
1690
|
+
style: sheet2,
|
|
1691
|
+
children: /* @__PURE__ */ jsx10(SwappedWebView, { url, onMessage: handleMessage, style: fill })
|
|
1692
|
+
}
|
|
1693
|
+
);
|
|
1694
|
+
}
|
|
1695
|
+
var SHEET_HEIGHT = 550;
|
|
1696
|
+
var sheet2 = { height: SHEET_HEIGHT, overflow: "hidden" };
|
|
1697
|
+
var fill = { flex: 1 };
|
|
1698
|
+
|
|
1699
|
+
// src/transfer/QrCode.tsx
|
|
1700
|
+
import QRCode from "react-native-qrcode-svg";
|
|
1701
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
1702
|
+
function QrCode({ value, size = 220 }) {
|
|
1703
|
+
const theme = useTheme();
|
|
1704
|
+
return /* @__PURE__ */ jsx11(
|
|
1705
|
+
QRCode,
|
|
1706
|
+
{
|
|
1707
|
+
value,
|
|
1708
|
+
size,
|
|
1709
|
+
color: theme.colors.textPrimary,
|
|
1710
|
+
backgroundColor: "#FFFFFF"
|
|
1711
|
+
}
|
|
1712
|
+
);
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
// src/transfer/clipboard.ts
|
|
1716
|
+
async function copyToClipboard(value) {
|
|
1717
|
+
try {
|
|
1718
|
+
const { default: Clipboard } = await import("@react-native-clipboard/clipboard");
|
|
1719
|
+
Clipboard.setString(value);
|
|
1720
|
+
return true;
|
|
1721
|
+
} catch (error) {
|
|
1722
|
+
logger.warn(
|
|
1723
|
+
"connect-rn: clipboard unavailable (is @react-native-clipboard/clipboard linked?); address not copied",
|
|
1724
|
+
{ error: error instanceof Error ? error.message : String(error) }
|
|
1725
|
+
);
|
|
1726
|
+
return false;
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
// src/transfer/fops.ts
|
|
1731
|
+
import {
|
|
1732
|
+
FormOfPaymentType
|
|
1733
|
+
} from "@funkit/api-base";
|
|
1734
|
+
import { getFopsLimit } from "@funkit/connect-core";
|
|
1735
|
+
var BANK_TRANSFER_TIME = "1-2 days";
|
|
1736
|
+
function toFopRows(fops, exchangeRates) {
|
|
1737
|
+
return fops.map((fop) => {
|
|
1738
|
+
const limit = `${getFopsLimit(fop, exchangeRates)} limit`;
|
|
1739
|
+
const subtitle = fop.fopType === FormOfPaymentType.BANK_TRANSFER ? `${limit} \xB7 ${BANK_TRANSFER_TIME}` : limit;
|
|
1740
|
+
return {
|
|
1741
|
+
id: `${fop.fopType}:${fop.name}`,
|
|
1742
|
+
name: fop.name,
|
|
1743
|
+
iconUri: fop.iconImageUrl,
|
|
1744
|
+
subtitle,
|
|
1745
|
+
disabled: !fop.embeddedFlowUrl
|
|
1746
|
+
};
|
|
1747
|
+
});
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
// src/transfer/formatDepositAddress.ts
|
|
1751
|
+
function formatDepositAddress(address, leading = 6, trailing = 6) {
|
|
1752
|
+
if (!address) {
|
|
1753
|
+
return "";
|
|
1754
|
+
}
|
|
1755
|
+
if (address.length <= leading + trailing) {
|
|
1756
|
+
return address;
|
|
1757
|
+
}
|
|
1758
|
+
return `${address.slice(0, leading)}\u2026${address.slice(-trailing)}`;
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
// src/transfer/hooks/useFops.ts
|
|
1762
|
+
import {
|
|
1763
|
+
getFops
|
|
1764
|
+
} from "@funkit/api-base";
|
|
1765
|
+
import {
|
|
1766
|
+
FUNKIT_CONNECT_CHECKOUT_NATIVE_CURRENCY_ADDRESS,
|
|
1767
|
+
solanaChain
|
|
1768
|
+
} from "@funkit/chains";
|
|
1769
|
+
import {
|
|
1770
|
+
FOPS_STALE_TIME,
|
|
1771
|
+
getDepositAddressForChain,
|
|
1772
|
+
sortFops,
|
|
1773
|
+
useDynamicConfig as useDynamicConfig2
|
|
1774
|
+
} from "@funkit/connect-core";
|
|
1775
|
+
import { useQuery as useQuery3 } from "@tanstack/react-query";
|
|
1776
|
+
|
|
1777
|
+
// src/geo/useUserIpInfo.ts
|
|
1778
|
+
import { useQuery } from "@tanstack/react-query";
|
|
1779
|
+
var MOONPAY_LIVE_API_KEY = "pk_live_IxayBRQuBC3RzpPZkbGPrwUsRWAaeO";
|
|
1780
|
+
function errData(error) {
|
|
1781
|
+
return { error: error instanceof Error ? error.message : String(error) };
|
|
1782
|
+
}
|
|
1783
|
+
async function getIpViaMoonpay() {
|
|
1784
|
+
const res = await fetch(
|
|
1785
|
+
`https://api.moonpay.com/v3/ip_address?apiKey=${MOONPAY_LIVE_API_KEY}`
|
|
1786
|
+
);
|
|
1787
|
+
if (!res.ok) {
|
|
1788
|
+
throw new Error(res.statusText);
|
|
1789
|
+
}
|
|
1790
|
+
const data = await res.json();
|
|
1791
|
+
return { alpha2: data.alpha2, state: data.state };
|
|
1792
|
+
}
|
|
1793
|
+
async function getIpViaIpApi() {
|
|
1794
|
+
const res = await fetch("https://ipapi.co/json");
|
|
1795
|
+
if (!res.ok) {
|
|
1796
|
+
throw new Error(res.statusText);
|
|
1797
|
+
}
|
|
1798
|
+
const data = await res.json();
|
|
1799
|
+
return { alpha2: data.country_code, state: data.region_code };
|
|
1800
|
+
}
|
|
1801
|
+
function useUserIpInfo() {
|
|
1802
|
+
const { data: userIpInfo, isLoading: isLoadingGeoCheck } = useQuery({
|
|
1803
|
+
queryKey: ["getUserIpInfo"],
|
|
1804
|
+
queryFn: async () => {
|
|
1805
|
+
try {
|
|
1806
|
+
return await getIpViaMoonpay();
|
|
1807
|
+
} catch (moonpayError) {
|
|
1808
|
+
logger.warn(
|
|
1809
|
+
"connect-rn:getUserIpViaMoonpay:error",
|
|
1810
|
+
errData(moonpayError)
|
|
1811
|
+
);
|
|
1812
|
+
try {
|
|
1813
|
+
return await getIpViaIpApi();
|
|
1814
|
+
} catch (ipApiError) {
|
|
1815
|
+
logger.warn("connect-rn:getUserIpViaIpApi:error", errData(ipApiError));
|
|
1816
|
+
throw ipApiError;
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
},
|
|
1820
|
+
// Location is stable within a session; don't refetch aggressively.
|
|
1821
|
+
staleTime: Number.POSITIVE_INFINITY,
|
|
1822
|
+
refetchOnMount: false,
|
|
1823
|
+
refetchOnReconnect: true,
|
|
1824
|
+
refetchOnWindowFocus: false
|
|
1825
|
+
});
|
|
1826
|
+
return { userIpInfo, isLoadingGeoCheck };
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1829
|
+
// src/identity/IdentityContext.tsx
|
|
1830
|
+
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
1831
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
1832
|
+
function generateSyntheticUserId(apiKey, externalUserId) {
|
|
1833
|
+
return `${apiKey}|${externalUserId}`;
|
|
1834
|
+
}
|
|
1835
|
+
function resolveFunkitIdentity(config, walletAddress) {
|
|
1836
|
+
const address = walletAddress || "0x";
|
|
1837
|
+
const userId = config.externalUserId ? generateSyntheticUserId(config.apiKey, config.externalUserId) : address;
|
|
1838
|
+
return {
|
|
1839
|
+
apiKey: config.apiKey,
|
|
1840
|
+
userId,
|
|
1841
|
+
walletAddress: address,
|
|
1842
|
+
loginType: config.loginType
|
|
1843
|
+
};
|
|
1844
|
+
}
|
|
1845
|
+
var FunkitIdentityContext = createContext2(null);
|
|
1846
|
+
function FunkitIdentityProvider({
|
|
1847
|
+
identity,
|
|
1848
|
+
children
|
|
1849
|
+
}) {
|
|
1850
|
+
return /* @__PURE__ */ jsx12(FunkitIdentityContext.Provider, { value: identity, children });
|
|
1851
|
+
}
|
|
1852
|
+
function useFunkitIdentity() {
|
|
1853
|
+
const identity = useContext2(FunkitIdentityContext);
|
|
1854
|
+
if (identity == null) {
|
|
1855
|
+
throw new Error(
|
|
1856
|
+
"useFunkitIdentity must be used within a <FunkitIdentityProvider> (mounted by <FunkitProvider>)"
|
|
1857
|
+
);
|
|
1858
|
+
}
|
|
1859
|
+
return identity;
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1862
|
+
// src/transfer/hooks/useTransferInit.ts
|
|
1863
|
+
import {
|
|
1864
|
+
initializeCheckoutTokenTransferAddress
|
|
1865
|
+
} from "@funkit/api-base";
|
|
1866
|
+
import {
|
|
1867
|
+
getCheckoutTokenTransferParams
|
|
1868
|
+
} from "@funkit/connect-core";
|
|
1869
|
+
import { useQuery as useQuery2 } from "@tanstack/react-query";
|
|
1870
|
+
|
|
1871
|
+
// src/transfer/hooks/useUDAParams.ts
|
|
1872
|
+
import { useDynamicConfig } from "@funkit/connect-core";
|
|
1873
|
+
import { useMemo as useMemo4 } from "react";
|
|
1874
|
+
function useUDAParams(dynamicRoutingId) {
|
|
1875
|
+
const udaParams = useDynamicConfig("uda_params");
|
|
1876
|
+
return useMemo4(
|
|
1877
|
+
() => udaParams.find((param) => param.dynamicRoutingId === dynamicRoutingId)?.params,
|
|
1878
|
+
[udaParams, dynamicRoutingId]
|
|
1879
|
+
);
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
// src/transfer/hooks/useTransferInit.ts
|
|
1883
|
+
var TRANSFER_CLIENT_METADATA = {};
|
|
1884
|
+
function useTransferInit({
|
|
1885
|
+
checkoutConfig,
|
|
1886
|
+
recipientAddr,
|
|
1887
|
+
dynamicRoutingId,
|
|
1888
|
+
enabled = true
|
|
1889
|
+
}) {
|
|
1890
|
+
const { apiKey, userId, walletAddress } = useFunkitIdentity();
|
|
1891
|
+
const udaParams = useUDAParams(dynamicRoutingId);
|
|
1892
|
+
const resolvedRecipient = recipientAddr || walletAddress || "0x";
|
|
1893
|
+
const params = getCheckoutTokenTransferParams({
|
|
1894
|
+
checkoutConfig,
|
|
1895
|
+
userId,
|
|
1896
|
+
apiKey,
|
|
1897
|
+
recipientAddr: resolvedRecipient,
|
|
1898
|
+
udaParams
|
|
1899
|
+
});
|
|
1900
|
+
const { data, isLoading, isFetching } = useQuery2({
|
|
1901
|
+
queryKey: ["initializeCheckoutTokenTransferAddress", params],
|
|
1902
|
+
queryFn: ({ queryKey: [, queryParams] }) => queryParams ? initializeCheckoutTokenTransferAddress({
|
|
1903
|
+
...queryParams,
|
|
1904
|
+
logger,
|
|
1905
|
+
clientMetadata: TRANSFER_CLIENT_METADATA
|
|
1906
|
+
}) : void 0,
|
|
1907
|
+
enabled: enabled && !!params,
|
|
1908
|
+
refetchOnWindowFocus: false,
|
|
1909
|
+
refetchOnMount: false
|
|
1910
|
+
});
|
|
1911
|
+
return {
|
|
1912
|
+
transferInit: isFetching ? void 0 : data,
|
|
1913
|
+
recipientAddr: resolvedRecipient,
|
|
1914
|
+
isLoading,
|
|
1915
|
+
isFetching
|
|
1916
|
+
};
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1919
|
+
// src/transfer/hooks/useFops.ts
|
|
1920
|
+
var DEFAULT_FIAT_CURRENCY = "USD";
|
|
1921
|
+
var DEFAULT_COUNTRY_CODE = "US";
|
|
1922
|
+
function useFops({
|
|
1923
|
+
checkoutConfig,
|
|
1924
|
+
dynamicRoutingId,
|
|
1925
|
+
enabled = true
|
|
1926
|
+
}) {
|
|
1927
|
+
const { apiKey, userId } = useFunkitIdentity();
|
|
1928
|
+
const isSwappedEnabled = !!useDynamicConfig2("enableswappeddeposit");
|
|
1929
|
+
const fopPriority = useDynamicConfig2("foppriority");
|
|
1930
|
+
const { userIpInfo } = useUserIpInfo();
|
|
1931
|
+
const countryCode = userIpInfo?.alpha2 || DEFAULT_COUNTRY_CODE;
|
|
1932
|
+
const {
|
|
1933
|
+
transferInit,
|
|
1934
|
+
isLoading: isTransferInitLoading,
|
|
1935
|
+
isFetching: isTransferInitFetching
|
|
1936
|
+
} = useTransferInit({
|
|
1937
|
+
checkoutConfig,
|
|
1938
|
+
dynamicRoutingId,
|
|
1939
|
+
enabled: enabled && isSwappedEnabled
|
|
1940
|
+
});
|
|
1941
|
+
const targetAsset = checkoutConfig?.targetAsset;
|
|
1942
|
+
const targetChain = checkoutConfig?.targetChain;
|
|
1943
|
+
const recipientAddress = targetChain ? getDepositAddressForChain(Number(targetChain), transferInit) : void 0;
|
|
1944
|
+
const isEnabled = enabled && isSwappedEnabled && !!apiKey && !!targetAsset && !!targetChain && !!recipientAddress && !!transferInit;
|
|
1945
|
+
const query = useQuery3({
|
|
1946
|
+
queryKey: [
|
|
1947
|
+
"fops",
|
|
1948
|
+
userId,
|
|
1949
|
+
recipientAddress,
|
|
1950
|
+
targetAsset,
|
|
1951
|
+
targetChain,
|
|
1952
|
+
apiKey,
|
|
1953
|
+
countryCode,
|
|
1954
|
+
fopPriority
|
|
1955
|
+
],
|
|
1956
|
+
queryFn: async () => {
|
|
1957
|
+
if (!recipientAddress || !targetChain || !targetAsset) {
|
|
1958
|
+
return { genericFormsOfPayments: [], savedFormsOfPayments: [] };
|
|
1959
|
+
}
|
|
1960
|
+
const destinationToken = { chainId: targetChain, address: targetAsset };
|
|
1961
|
+
const recipientTargets = [
|
|
1962
|
+
{ recipientAddress, destinationToken },
|
|
1963
|
+
...transferInit?.solanaAddr ? [
|
|
1964
|
+
{
|
|
1965
|
+
recipientAddress: transferInit.solanaAddr,
|
|
1966
|
+
destinationToken: {
|
|
1967
|
+
chainId: solanaChain.id.toString(),
|
|
1968
|
+
address: FUNKIT_CONNECT_CHECKOUT_NATIVE_CURRENCY_ADDRESS
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
] : []
|
|
1972
|
+
];
|
|
1973
|
+
const response = await getFops({
|
|
1974
|
+
apiKey,
|
|
1975
|
+
logger,
|
|
1976
|
+
params: {
|
|
1977
|
+
recipientAddress,
|
|
1978
|
+
userId,
|
|
1979
|
+
destinationToken,
|
|
1980
|
+
fiatCurrencyCode: DEFAULT_FIAT_CURRENCY,
|
|
1981
|
+
countryCode,
|
|
1982
|
+
recipientTargets
|
|
1983
|
+
}
|
|
1984
|
+
});
|
|
1985
|
+
return {
|
|
1986
|
+
genericFormsOfPayments: sortFops(
|
|
1987
|
+
response.genericFormsOfPayments,
|
|
1988
|
+
fopPriority
|
|
1989
|
+
),
|
|
1990
|
+
savedFormsOfPayments: sortFops(
|
|
1991
|
+
response.savedFormsOfPayments,
|
|
1992
|
+
fopPriority
|
|
1993
|
+
)
|
|
1994
|
+
};
|
|
1995
|
+
},
|
|
1996
|
+
enabled: isEnabled,
|
|
1997
|
+
staleTime: FOPS_STALE_TIME,
|
|
1998
|
+
refetchOnWindowFocus: false
|
|
1999
|
+
});
|
|
2000
|
+
return {
|
|
2001
|
+
savedFops: query.data?.savedFormsOfPayments ?? [],
|
|
2002
|
+
genericFops: query.data?.genericFormsOfPayments ?? [],
|
|
2003
|
+
isLoading: query.isLoading || isTransferInitLoading,
|
|
2004
|
+
isFetching: isTransferInitFetching,
|
|
2005
|
+
isSwappedEnabled
|
|
2006
|
+
};
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
|
+
// src/transfer/hooks/useSupportedTokens.ts
|
|
2010
|
+
import { getSupportedAssets } from "@funkit/api-base";
|
|
2011
|
+
import {
|
|
2012
|
+
isTransferChainEnabled,
|
|
2013
|
+
resolveTokenTransferConfig,
|
|
2014
|
+
useDynamicConfig as useDynamicConfig3
|
|
2015
|
+
} from "@funkit/connect-core";
|
|
2016
|
+
import { useQuery as useQuery4 } from "@tanstack/react-query";
|
|
2017
|
+
import { useMemo as useMemo5 } from "react";
|
|
2018
|
+
|
|
2019
|
+
// src/transfer/supportedTokens.ts
|
|
2020
|
+
function buildSupportedTokenList(resolved) {
|
|
2021
|
+
const priorityIndex = new Map(
|
|
2022
|
+
resolved.priorityTokenSymbols.map((symbol, i) => [symbol, i])
|
|
2023
|
+
);
|
|
2024
|
+
const tokens = [];
|
|
2025
|
+
const chainFilters = [{ id: "all", label: "All" }];
|
|
2026
|
+
for (const chainId of resolved.chainIdSortOrder) {
|
|
2027
|
+
const assets = Object.values(resolved.supportedAssets[chainId] ?? {});
|
|
2028
|
+
if (assets.length === 0) {
|
|
2029
|
+
continue;
|
|
2030
|
+
}
|
|
2031
|
+
chainFilters.push({ id: String(chainId), label: assets[0].chainName });
|
|
2032
|
+
for (const asset of assets) {
|
|
2033
|
+
tokens.push({
|
|
2034
|
+
id: `${asset.chainId}:${asset.address}`,
|
|
2035
|
+
symbol: asset.symbol,
|
|
2036
|
+
chainLabel: asset.chainName,
|
|
2037
|
+
chainId: Number(asset.chainId),
|
|
2038
|
+
address: asset.address
|
|
2039
|
+
});
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
const rank = (symbol) => priorityIndex.get(symbol) ?? Number.POSITIVE_INFINITY;
|
|
2043
|
+
tokens.sort((a, b) => rank(a.symbol) - rank(b.symbol));
|
|
2044
|
+
return { tokens, chainFilters };
|
|
2045
|
+
}
|
|
2046
|
+
function filterSupportedTokens(tokens, {
|
|
2047
|
+
search = "",
|
|
2048
|
+
chainFilterId = "all"
|
|
2049
|
+
}) {
|
|
2050
|
+
const query = search.trim().toLowerCase();
|
|
2051
|
+
return tokens.filter((token) => {
|
|
2052
|
+
if (chainFilterId !== "all" && String(token.chainId) !== chainFilterId) {
|
|
2053
|
+
return false;
|
|
2054
|
+
}
|
|
2055
|
+
if (!query) {
|
|
2056
|
+
return true;
|
|
2057
|
+
}
|
|
2058
|
+
return token.symbol.toLowerCase().includes(query) || token.chainLabel.toLowerCase().includes(query);
|
|
2059
|
+
});
|
|
2060
|
+
}
|
|
2061
|
+
|
|
2062
|
+
// src/transfer/hooks/useSupportedTokens.ts
|
|
2063
|
+
function useSupportedTokens({
|
|
2064
|
+
enabled = true,
|
|
2065
|
+
transferInit
|
|
2066
|
+
} = {}) {
|
|
2067
|
+
const { apiKey } = useFunkitIdentity();
|
|
2068
|
+
const tokenTransferConfig = useDynamicConfig3("tokentransferconfig");
|
|
2069
|
+
const disabledChainAssets = useDynamicConfig3(
|
|
2070
|
+
"disabletokentransferchainsandassets"
|
|
2071
|
+
);
|
|
2072
|
+
const { data, isLoading } = useQuery4({
|
|
2073
|
+
queryKey: ["getSupportedAssets", apiKey],
|
|
2074
|
+
queryFn: ({ queryKey: [, key] }) => getSupportedAssets({ apiKey: key, logger }),
|
|
2075
|
+
enabled: enabled && !!apiKey,
|
|
2076
|
+
staleTime: 5 * 6e4,
|
|
2077
|
+
refetchOnWindowFocus: false
|
|
2078
|
+
});
|
|
2079
|
+
const { tokens, chainFilters } = useMemo5(() => {
|
|
2080
|
+
if (!data) {
|
|
2081
|
+
return { tokens: [], chainFilters: [{ id: "all", label: "All" }] };
|
|
2082
|
+
}
|
|
2083
|
+
const resolved = resolveTokenTransferConfig({
|
|
2084
|
+
chainConfigs: tokenTransferConfig.chains ?? [],
|
|
2085
|
+
priorityTokens: tokenTransferConfig.priorityTokens ?? [],
|
|
2086
|
+
disabledChainAssets,
|
|
2087
|
+
supportedAssets: data,
|
|
2088
|
+
logger
|
|
2089
|
+
});
|
|
2090
|
+
const built = buildSupportedTokenList(resolved);
|
|
2091
|
+
const isEnabled = (chainId) => chainId == null || isTransferChainEnabled(chainId, transferInit);
|
|
2092
|
+
return {
|
|
2093
|
+
tokens: built.tokens.filter((t) => isEnabled(t.chainId)),
|
|
2094
|
+
chainFilters: built.chainFilters.filter(
|
|
2095
|
+
(c) => c.id === "all" || isEnabled(Number(c.id))
|
|
2096
|
+
)
|
|
2097
|
+
};
|
|
2098
|
+
}, [data, tokenTransferConfig, disabledChainAssets, transferInit]);
|
|
2099
|
+
return { tokens, chainFilters, isLoading };
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
// src/transfer/hooks/useTokenTransfer.ts
|
|
2103
|
+
import { bitcoinChain, solanaChain as solanaChain2, tronChain } from "@funkit/chains";
|
|
2104
|
+
import {
|
|
2105
|
+
getDepositAddressForChain as getDepositAddressForChain2,
|
|
2106
|
+
getMinTransferValueForChain,
|
|
2107
|
+
getTransferTokenQrCodeUri,
|
|
2108
|
+
useDynamicConfig as useDynamicConfig4
|
|
2109
|
+
} from "@funkit/connect-core";
|
|
2110
|
+
var DEFAULT_MAX_SLIPPAGE_PERCENT = 0.25;
|
|
2111
|
+
function resolveBlockchain(chainId) {
|
|
2112
|
+
if (chainId === solanaChain2.id) {
|
|
2113
|
+
return "solana";
|
|
2114
|
+
}
|
|
2115
|
+
if (chainId === bitcoinChain.id) {
|
|
2116
|
+
return "bitcoin";
|
|
2117
|
+
}
|
|
2118
|
+
if (chainId === tronChain.id) {
|
|
2119
|
+
return "tron";
|
|
2120
|
+
}
|
|
2121
|
+
return "ethereum";
|
|
2122
|
+
}
|
|
2123
|
+
function useTokenTransfer({
|
|
2124
|
+
checkoutConfig,
|
|
2125
|
+
selectedChainId,
|
|
2126
|
+
dynamicRoutingId,
|
|
2127
|
+
enabled
|
|
2128
|
+
}) {
|
|
2129
|
+
const { transferInit, recipientAddr, isLoading } = useTransferInit({
|
|
2130
|
+
checkoutConfig,
|
|
2131
|
+
dynamicRoutingId,
|
|
2132
|
+
enabled
|
|
2133
|
+
});
|
|
2134
|
+
const minTransferLimits = useDynamicConfig4("mintokentransfervalue");
|
|
2135
|
+
const minTransferUsd = selectedChainId !== void 0 ? Math.ceil(
|
|
2136
|
+
getMinTransferValueForChain(selectedChainId, minTransferLimits)
|
|
2137
|
+
) : 0;
|
|
2138
|
+
const depositAddress = selectedChainId !== void 0 ? getDepositAddressForChain2(selectedChainId, transferInit) : void 0;
|
|
2139
|
+
const blockchain = resolveBlockchain(selectedChainId);
|
|
2140
|
+
const qrCodeUri = depositAddress ? getTransferTokenQrCodeUri({ depositAddress, type: blockchain }) : void 0;
|
|
2141
|
+
return {
|
|
2142
|
+
depositAddress,
|
|
2143
|
+
transferInit,
|
|
2144
|
+
recipientAddr,
|
|
2145
|
+
minTransferUsd,
|
|
2146
|
+
maxSlippagePercent: DEFAULT_MAX_SLIPPAGE_PERCENT,
|
|
2147
|
+
qrCodeUri,
|
|
2148
|
+
blockchain,
|
|
2149
|
+
isLoading
|
|
2150
|
+
};
|
|
2151
|
+
}
|
|
2152
|
+
|
|
2153
|
+
// src/flow/FunkitFlowProvider.tsx
|
|
2154
|
+
import { jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
2155
|
+
var CLOSED = {
|
|
2156
|
+
isOpen: false,
|
|
2157
|
+
stack: [],
|
|
2158
|
+
config: null,
|
|
2159
|
+
callbacks: {}
|
|
2160
|
+
};
|
|
2161
|
+
var FunkitFlowContext = createContext3(null);
|
|
2162
|
+
function FunkitFlowProvider({ children }) {
|
|
2163
|
+
const [state, setState] = useState5(CLOSED);
|
|
2164
|
+
const beginDeposit = useCallback3(
|
|
2165
|
+
(config, callbacks = {}) => {
|
|
2166
|
+
callbacks.onOpen?.();
|
|
2167
|
+
setState({ isOpen: true, stack: ["addMoney"], config, callbacks });
|
|
2168
|
+
},
|
|
2169
|
+
[]
|
|
2170
|
+
);
|
|
2171
|
+
const closeFlow = useCallback3(() => {
|
|
2172
|
+
setState((prev) => {
|
|
2173
|
+
prev.callbacks.onClose?.();
|
|
2174
|
+
return CLOSED;
|
|
2175
|
+
});
|
|
2176
|
+
}, []);
|
|
2177
|
+
const navigate = useCallback3((screen) => {
|
|
2178
|
+
setState((prev) => ({ ...prev, stack: [...prev.stack, screen] }));
|
|
2179
|
+
}, []);
|
|
2180
|
+
const back = useCallback3(() => {
|
|
2181
|
+
setState((prev) => {
|
|
2182
|
+
if (prev.stack.length <= 1) {
|
|
2183
|
+
prev.callbacks.onClose?.();
|
|
2184
|
+
return CLOSED;
|
|
2185
|
+
}
|
|
2186
|
+
return { ...prev, stack: prev.stack.slice(0, -1) };
|
|
2187
|
+
});
|
|
2188
|
+
}, []);
|
|
2189
|
+
const value = useMemo6(
|
|
2190
|
+
() => ({ beginDeposit, closeFlow }),
|
|
2191
|
+
[beginDeposit, closeFlow]
|
|
2192
|
+
);
|
|
2193
|
+
const current = state.stack[state.stack.length - 1];
|
|
2194
|
+
const nav = useMemo6(
|
|
2195
|
+
() => ({ navigate, back, closeFlow }),
|
|
2196
|
+
[navigate, back, closeFlow]
|
|
2197
|
+
);
|
|
2198
|
+
return /* @__PURE__ */ jsxs6(FunkitFlowContext.Provider, { value, children: [
|
|
2199
|
+
children,
|
|
2200
|
+
/* @__PURE__ */ jsx13(
|
|
2201
|
+
Modal,
|
|
2202
|
+
{
|
|
2203
|
+
visible: state.isOpen,
|
|
2204
|
+
transparent: true,
|
|
2205
|
+
animationType: "slide",
|
|
2206
|
+
onRequestClose: closeFlow,
|
|
2207
|
+
children: /* @__PURE__ */ jsx13(Pressable6, { style: backdrop, onPress: closeFlow, children: /* @__PURE__ */ jsx13(Pressable6, { onPress: () => void 0, children: state.isOpen && state.config ? /* @__PURE__ */ jsx13(FlowContent, { config: state.config, current, nav }) : null }) })
|
|
2208
|
+
}
|
|
2209
|
+
)
|
|
2210
|
+
] });
|
|
2211
|
+
}
|
|
2212
|
+
function FlowContent({
|
|
2213
|
+
config,
|
|
2214
|
+
current,
|
|
2215
|
+
nav
|
|
2216
|
+
}) {
|
|
2217
|
+
const [selectedChain, setSelectedChain] = useState5(
|
|
2218
|
+
() => config.depositChains.find((c) => c.chainId === config.selectedChainId)
|
|
2219
|
+
);
|
|
2220
|
+
const selectedChainId = selectedChain?.chainId ?? config.selectedChainId;
|
|
2221
|
+
const networkLabel = selectedChain?.label ?? config.networkLabel;
|
|
2222
|
+
const networkIconKeys = selectedChain?.iconKeys ?? config.networkIconChains ?? [];
|
|
2223
|
+
const {
|
|
2224
|
+
depositAddress: generatedAddress,
|
|
2225
|
+
qrCodeUri,
|
|
2226
|
+
transferInit
|
|
2227
|
+
} = useTokenTransfer({
|
|
2228
|
+
checkoutConfig: config.checkoutConfig,
|
|
2229
|
+
selectedChainId,
|
|
2230
|
+
dynamicRoutingId: config.dynamicRoutingId,
|
|
2231
|
+
enabled: true
|
|
2232
|
+
});
|
|
2233
|
+
const fetched = useSupportedTokens({ transferInit });
|
|
2234
|
+
const supportedTokens = config.supportedTokens ?? fetched.tokens;
|
|
2235
|
+
const tokenChainFilters = config.tokenChainFilters ?? fetched.chainFilters;
|
|
2236
|
+
const { savedFops, genericFops, isSwappedEnabled } = useFops({
|
|
2237
|
+
checkoutConfig: config.checkoutConfig,
|
|
2238
|
+
dynamicRoutingId: config.dynamicRoutingId
|
|
2239
|
+
});
|
|
2240
|
+
const [selectedSwappedUrl, setSelectedSwappedUrl] = useState5();
|
|
2241
|
+
const [tokenSearch, setTokenSearch] = useState5("");
|
|
2242
|
+
const [chainFilterId, setChainFilterId] = useState5("all");
|
|
2243
|
+
const filteredTokens = filterSupportedTokens(supportedTokens, {
|
|
2244
|
+
search: tokenSearch,
|
|
2245
|
+
chainFilterId
|
|
2246
|
+
});
|
|
2247
|
+
const selectToken = (id) => {
|
|
2248
|
+
const token = supportedTokens.find((t) => t.id === id);
|
|
2249
|
+
if (token?.chainId != null) {
|
|
2250
|
+
const match = config.depositChains.find(
|
|
2251
|
+
(c) => c.chainId === token.chainId
|
|
2252
|
+
);
|
|
2253
|
+
setSelectedChain(
|
|
2254
|
+
match ?? {
|
|
2255
|
+
id: `chain-${token.chainId}`,
|
|
2256
|
+
label: token.chainLabel,
|
|
2257
|
+
chainId: token.chainId
|
|
2258
|
+
}
|
|
2259
|
+
);
|
|
2260
|
+
}
|
|
2261
|
+
nav.back();
|
|
2262
|
+
};
|
|
2263
|
+
const rawAddress = generatedAddress ?? config.depositAddress;
|
|
2264
|
+
const displayAddress = rawAddress ? formatDepositAddress(rawAddress) : "Generating\u2026";
|
|
2265
|
+
const networkChains = config.networkIconChains ?? [];
|
|
2266
|
+
switch (current) {
|
|
2267
|
+
case "addMoney": {
|
|
2268
|
+
const cryptoMethod = config.paymentMethods.map(
|
|
2269
|
+
(method) => method.id === config.cryptoMethodId && method.icon == null ? { ...method, icon: /* @__PURE__ */ jsx13(ChainClusterIcon, { chains: networkChains }) } : method
|
|
2270
|
+
);
|
|
2271
|
+
const toCashRows = (fops) => toFopRows(fops).map((row4) => ({
|
|
2272
|
+
id: row4.id,
|
|
2273
|
+
title: row4.name,
|
|
2274
|
+
subtitle: row4.subtitle,
|
|
2275
|
+
icon: /* @__PURE__ */ jsx13(FunIcon, { uri: row4.iconUri, fallbackUri: FALLBACK_ASSET_LOGO })
|
|
2276
|
+
}));
|
|
2277
|
+
const methods = isSwappedEnabled ? [
|
|
2278
|
+
...toCashRows(savedFops),
|
|
2279
|
+
...cryptoMethod,
|
|
2280
|
+
...toCashRows(genericFops)
|
|
2281
|
+
] : cryptoMethod;
|
|
2282
|
+
return /* @__PURE__ */ jsx13(
|
|
2283
|
+
AddMoneyScreen,
|
|
2284
|
+
{
|
|
2285
|
+
methods,
|
|
2286
|
+
onSelectMethod: (id) => {
|
|
2287
|
+
if (id === config.cryptoMethodId) {
|
|
2288
|
+
nav.navigate("transfer");
|
|
2289
|
+
return;
|
|
2290
|
+
}
|
|
2291
|
+
if (id.includes(":")) {
|
|
2292
|
+
const fop = [...savedFops, ...genericFops].find(
|
|
2293
|
+
(f) => `${f.fopType}:${f.name}` === id
|
|
2294
|
+
);
|
|
2295
|
+
if (fop?.embeddedFlowUrl) {
|
|
2296
|
+
setSelectedSwappedUrl(fop.embeddedFlowUrl);
|
|
2297
|
+
nav.navigate("swapped");
|
|
2298
|
+
}
|
|
2299
|
+
return;
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2303
|
+
);
|
|
2304
|
+
}
|
|
2305
|
+
case "transfer":
|
|
2306
|
+
return /* @__PURE__ */ jsx13(
|
|
2307
|
+
TransferCryptoScreen,
|
|
2308
|
+
{
|
|
2309
|
+
depositAddress: displayAddress,
|
|
2310
|
+
networkLabel,
|
|
2311
|
+
networkIcon: /* @__PURE__ */ jsx13(ChainClusterIcon, { chains: networkIconKeys }),
|
|
2312
|
+
onBack: nav.back,
|
|
2313
|
+
onChangeNetwork: () => nav.navigate("chooseChain"),
|
|
2314
|
+
onShowSupportedTokens: () => nav.navigate("supportedTokens"),
|
|
2315
|
+
onShowQrCode: () => nav.navigate("qrCode"),
|
|
2316
|
+
onCopyAddress: rawAddress ? () => void copyToClipboard(rawAddress) : void 0,
|
|
2317
|
+
onShareAddress: rawAddress ? () => void Share.share({ message: rawAddress }) : void 0
|
|
2318
|
+
}
|
|
2319
|
+
);
|
|
2320
|
+
case "chooseChain":
|
|
2321
|
+
return /* @__PURE__ */ jsx13(
|
|
2322
|
+
ChooseChainScreen,
|
|
2323
|
+
{
|
|
2324
|
+
chains: config.depositChains.map(
|
|
2325
|
+
(chain) => chain.icon == null && chain.iconKeys != null ? { ...chain, icon: /* @__PURE__ */ jsx13(ChainClusterIcon, { chains: chain.iconKeys }) } : chain
|
|
2326
|
+
),
|
|
2327
|
+
onBack: nav.back,
|
|
2328
|
+
onSelectChain: (id) => {
|
|
2329
|
+
const picked = config.depositChains.find((c) => c.id === id);
|
|
2330
|
+
if (picked) {
|
|
2331
|
+
setSelectedChain(picked);
|
|
2332
|
+
}
|
|
2333
|
+
nav.back();
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
);
|
|
2337
|
+
case "supportedTokens":
|
|
2338
|
+
return /* @__PURE__ */ jsx13(
|
|
2339
|
+
SupportedTokensScreen,
|
|
2340
|
+
{
|
|
2341
|
+
tokens: filteredTokens.map(
|
|
2342
|
+
(token) => token.icon == null ? {
|
|
2343
|
+
...token,
|
|
2344
|
+
icon: /* @__PURE__ */ jsx13(
|
|
2345
|
+
FunIcon,
|
|
2346
|
+
{
|
|
2347
|
+
uri: tokenLogoUri(token.symbol),
|
|
2348
|
+
fallbackUri: FALLBACK_ASSET_LOGO
|
|
2349
|
+
}
|
|
2350
|
+
)
|
|
2351
|
+
} : token
|
|
2352
|
+
),
|
|
2353
|
+
searchValue: tokenSearch,
|
|
2354
|
+
onSearchChange: setTokenSearch,
|
|
2355
|
+
chainFilters: tokenChainFilters,
|
|
2356
|
+
selectedChainFilterId: chainFilterId,
|
|
2357
|
+
onSelectChainFilter: setChainFilterId,
|
|
2358
|
+
onSelectToken: selectToken,
|
|
2359
|
+
onBack: nav.back
|
|
2360
|
+
}
|
|
2361
|
+
);
|
|
2362
|
+
case "qrCode":
|
|
2363
|
+
return /* @__PURE__ */ jsx13(
|
|
2364
|
+
QrCodeScreen,
|
|
2365
|
+
{
|
|
2366
|
+
qrCode: config.qrCode ?? (qrCodeUri ? /* @__PURE__ */ jsx13(QrCode, { value: qrCodeUri }) : null),
|
|
2367
|
+
onClose: nav.back,
|
|
2368
|
+
onSupportedChainsPress: () => nav.navigate("supportedTokens")
|
|
2369
|
+
}
|
|
2370
|
+
);
|
|
2371
|
+
case "swapped":
|
|
2372
|
+
return selectedSwappedUrl ? /* @__PURE__ */ jsx13(
|
|
2373
|
+
SwappedScreen,
|
|
2374
|
+
{
|
|
2375
|
+
url: selectedSwappedUrl,
|
|
2376
|
+
onBack: nav.back,
|
|
2377
|
+
onClose: nav.closeFlow
|
|
2378
|
+
}
|
|
2379
|
+
) : null;
|
|
2380
|
+
default:
|
|
2381
|
+
return null;
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
function useFunkitFlow() {
|
|
2385
|
+
const value = useContext3(FunkitFlowContext);
|
|
2386
|
+
if (value == null) {
|
|
2387
|
+
throw new Error("useFunkitFlow must be used within <FunkitProvider>");
|
|
2388
|
+
}
|
|
2389
|
+
return value;
|
|
2390
|
+
}
|
|
2391
|
+
var backdrop = {
|
|
2392
|
+
flex: 1,
|
|
2393
|
+
backgroundColor: "rgba(0,0,0,0.45)",
|
|
2394
|
+
justifyContent: "flex-end"
|
|
2395
|
+
};
|
|
2396
|
+
|
|
2397
|
+
// src/version.ts
|
|
2398
|
+
var CONNECT_RN_VERSION = true ? "0.2.0-next.0" : "0.0.0-dev";
|
|
2399
|
+
|
|
2400
|
+
// src/providers/FunkitStatsigProvider.tsx
|
|
2401
|
+
import {
|
|
2402
|
+
LogEventCompressionMode,
|
|
2403
|
+
LogLevel,
|
|
2404
|
+
StatsigProvider
|
|
2405
|
+
} from "@statsig/react-bindings";
|
|
2406
|
+
import { useMemo as useMemo7 } from "react";
|
|
2407
|
+
|
|
2408
|
+
// src/statsig/useClientAsyncInitRN.ts
|
|
2409
|
+
import {
|
|
2410
|
+
useStatsigInternalClientFactoryAsync
|
|
2411
|
+
} from "@statsig/react-bindings";
|
|
2412
|
+
|
|
2413
|
+
// src/statsig/StatsigClientRN.ts
|
|
2414
|
+
import {
|
|
2415
|
+
StatsigClient
|
|
2416
|
+
} from "@statsig/react-bindings";
|
|
2417
|
+
|
|
2418
|
+
// src/statsig/rnSetup.ts
|
|
2419
|
+
import {
|
|
2420
|
+
SDKType,
|
|
2421
|
+
StatsigMetadataProvider
|
|
2422
|
+
} from "@statsig/react-bindings";
|
|
2423
|
+
|
|
2424
|
+
// src/statsig/appVisibilityShim.ts
|
|
2425
|
+
import { _notifyVisibilityChanged } from "@statsig/react-bindings";
|
|
2426
|
+
import { AppState } from "react-native";
|
|
2427
|
+
var isApplied = false;
|
|
2428
|
+
function applyAppStateVisibilityShim() {
|
|
2429
|
+
if (isApplied) {
|
|
2430
|
+
return;
|
|
2431
|
+
}
|
|
2432
|
+
isApplied = true;
|
|
2433
|
+
AppState.addEventListener(
|
|
2434
|
+
"change",
|
|
2435
|
+
(nextAppState) => _notifyVisibilityChanged(
|
|
2436
|
+
nextAppState === "active" ? "foreground" : "background"
|
|
2437
|
+
)
|
|
2438
|
+
);
|
|
2439
|
+
}
|
|
2440
|
+
|
|
2441
|
+
// src/statsig/preloadedAsyncStorage.ts
|
|
2442
|
+
import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
2443
|
+
import { Log } from "@statsig/react-bindings";
|
|
2444
|
+
var NOT_READY_ERROR = "Attempting to alter AsyncStorage before it is ready. Values will not be persisted.";
|
|
2445
|
+
function createPreloadedAsyncStorage() {
|
|
2446
|
+
const inMemoryStore = {};
|
|
2447
|
+
let isResolved = false;
|
|
2448
|
+
let readyPromise = null;
|
|
2449
|
+
const enforceIsResolved = () => {
|
|
2450
|
+
if (!isResolved) {
|
|
2451
|
+
Log.error(NOT_READY_ERROR);
|
|
2452
|
+
}
|
|
2453
|
+
return isResolved;
|
|
2454
|
+
};
|
|
2455
|
+
const provider = {
|
|
2456
|
+
getProviderName: () => "AsyncStorage",
|
|
2457
|
+
isReady: () => isResolved,
|
|
2458
|
+
isReadyResolver: () => {
|
|
2459
|
+
if (!readyPromise) {
|
|
2460
|
+
readyPromise = prefetchFromAsyncStorage(inMemoryStore).finally(() => {
|
|
2461
|
+
isResolved = true;
|
|
2462
|
+
});
|
|
2463
|
+
}
|
|
2464
|
+
return readyPromise;
|
|
2465
|
+
},
|
|
2466
|
+
getItem: (key) => {
|
|
2467
|
+
if (!enforceIsResolved()) {
|
|
2468
|
+
return null;
|
|
2469
|
+
}
|
|
2470
|
+
return inMemoryStore[key] ?? null;
|
|
2471
|
+
},
|
|
2472
|
+
setItem: (key, value) => {
|
|
2473
|
+
inMemoryStore[key] = value;
|
|
2474
|
+
if (!enforceIsResolved()) {
|
|
2475
|
+
return;
|
|
2476
|
+
}
|
|
2477
|
+
AsyncStorage.setItem(key, value).catch(Log.error);
|
|
2478
|
+
},
|
|
2479
|
+
removeItem: (key) => {
|
|
2480
|
+
delete inMemoryStore[key];
|
|
2481
|
+
if (!enforceIsResolved()) {
|
|
2482
|
+
return;
|
|
2483
|
+
}
|
|
2484
|
+
AsyncStorage.removeItem(key).catch(Log.error);
|
|
2485
|
+
},
|
|
2486
|
+
getAllKeys: () => {
|
|
2487
|
+
if (!enforceIsResolved()) {
|
|
2488
|
+
return [];
|
|
2489
|
+
}
|
|
2490
|
+
return Object.keys(inMemoryStore);
|
|
2491
|
+
}
|
|
2492
|
+
};
|
|
2493
|
+
return provider;
|
|
2494
|
+
}
|
|
2495
|
+
async function prefetchFromAsyncStorage(inMemoryStore) {
|
|
2496
|
+
const keys = await AsyncStorage.getAllKeys();
|
|
2497
|
+
await Promise.all(
|
|
2498
|
+
keys.map(async (key) => {
|
|
2499
|
+
if (!key.startsWith("statsig.")) {
|
|
2500
|
+
return;
|
|
2501
|
+
}
|
|
2502
|
+
const cache = await AsyncStorage.getItem(key);
|
|
2503
|
+
if (!cache) {
|
|
2504
|
+
return;
|
|
2505
|
+
}
|
|
2506
|
+
inMemoryStore[key] = cache;
|
|
2507
|
+
})
|
|
2508
|
+
);
|
|
2509
|
+
}
|
|
2510
|
+
|
|
2511
|
+
// src/statsig/rnSetup.ts
|
|
2512
|
+
function setupStatsigForReactNative(statsigMetadataAdditions, options) {
|
|
2513
|
+
applyAppStateVisibilityShim();
|
|
2514
|
+
SDKType._setBindingType("rn");
|
|
2515
|
+
if (statsigMetadataAdditions) {
|
|
2516
|
+
StatsigMetadataProvider.add(statsigMetadataAdditions);
|
|
2517
|
+
}
|
|
2518
|
+
if (options.storageProvider == null) {
|
|
2519
|
+
options.storageProvider = createPreloadedAsyncStorage();
|
|
2520
|
+
}
|
|
2521
|
+
applyNetworkFix(options);
|
|
2522
|
+
}
|
|
2523
|
+
function applyNetworkFix(options) {
|
|
2524
|
+
if (options.networkConfig?.networkOverrideFunc != null) {
|
|
2525
|
+
return;
|
|
2526
|
+
}
|
|
2527
|
+
const networkOverrideFunc = (url, args) => {
|
|
2528
|
+
if (args.body != null && args.method === "POST") {
|
|
2529
|
+
args.headers = {
|
|
2530
|
+
"Content-Type": "application/json",
|
|
2531
|
+
...args.headers
|
|
2532
|
+
};
|
|
2533
|
+
}
|
|
2534
|
+
return fetch(url, args);
|
|
2535
|
+
};
|
|
2536
|
+
options.networkConfig = {
|
|
2537
|
+
networkOverrideFunc,
|
|
2538
|
+
...options.networkConfig
|
|
2539
|
+
};
|
|
2540
|
+
}
|
|
2541
|
+
|
|
2542
|
+
// src/statsig/statsigMetadata.ts
|
|
2543
|
+
import { NativeModules, Platform } from "react-native";
|
|
2544
|
+
function resolveLocale() {
|
|
2545
|
+
if (Platform.OS === "android") {
|
|
2546
|
+
const i18nManager = NativeModules.I18nManager;
|
|
2547
|
+
return i18nManager?.localIdentifer ?? void 0;
|
|
2548
|
+
}
|
|
2549
|
+
if (Platform.OS === "ios") {
|
|
2550
|
+
const settings = NativeModules.SettingsManager?.settings;
|
|
2551
|
+
return settings?.AppLocale ?? settings?.AppleLanguages?.[0] ?? void 0;
|
|
2552
|
+
}
|
|
2553
|
+
return void 0;
|
|
2554
|
+
}
|
|
2555
|
+
function getStatsigMetadataAdditions() {
|
|
2556
|
+
return {
|
|
2557
|
+
// Device-info-derived fields are dropped (no react-native-device-info).
|
|
2558
|
+
appVersion: void 0,
|
|
2559
|
+
systemVersion: void 0,
|
|
2560
|
+
deviceModelName: void 0,
|
|
2561
|
+
deviceModel: void 0,
|
|
2562
|
+
// Available without any native module:
|
|
2563
|
+
systemName: Platform.OS,
|
|
2564
|
+
locale: resolveLocale()
|
|
2565
|
+
};
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2568
|
+
// src/statsig/StatsigClientRN.ts
|
|
2569
|
+
var StatsigClientRN = class extends StatsigClient {
|
|
2570
|
+
constructor(sdkKey, user, options = null) {
|
|
2571
|
+
const opts = options ?? {};
|
|
2572
|
+
setupStatsigForReactNative(getStatsigMetadataAdditions(), opts);
|
|
2573
|
+
super(sdkKey, user, opts);
|
|
2574
|
+
this.__isRnClient = true;
|
|
2575
|
+
}
|
|
2576
|
+
};
|
|
2577
|
+
|
|
2578
|
+
// src/statsig/useClientAsyncInitRN.ts
|
|
2579
|
+
function useClientAsyncInitRN(sdkKey, initialUser, statsigOptions = null) {
|
|
2580
|
+
return useStatsigInternalClientFactoryAsync(
|
|
2581
|
+
(args) => new StatsigClientRN(args.sdkKey, args.initialUser, args.statsigOptions),
|
|
2582
|
+
{
|
|
2583
|
+
sdkKey,
|
|
2584
|
+
initialUser,
|
|
2585
|
+
statsigOptions
|
|
2586
|
+
}
|
|
2587
|
+
);
|
|
2588
|
+
}
|
|
2589
|
+
|
|
2590
|
+
// src/providers/FunkitStatsigProvider.tsx
|
|
2591
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
2592
|
+
var STATSIG_API = "https://data-api.fun.xyz/v1";
|
|
2593
|
+
var STATSIG_CLIENT_KEY = "client-UmFd8WIJljA7cLmZuDqs3X25M8sKd5WIQP4BSC2bRbM";
|
|
2594
|
+
function FunkitStatsigProvider({
|
|
2595
|
+
children,
|
|
2596
|
+
apiKey,
|
|
2597
|
+
userId,
|
|
2598
|
+
isDevelopment = false
|
|
2599
|
+
}) {
|
|
2600
|
+
const user = useMemo7(
|
|
2601
|
+
() => ({ userID: userId, customIDs: { apiKey } }),
|
|
2602
|
+
[userId, apiKey]
|
|
2603
|
+
);
|
|
2604
|
+
const { client } = useClientAsyncInitRN(STATSIG_CLIENT_KEY, user, {
|
|
2605
|
+
networkConfig: {
|
|
2606
|
+
api: STATSIG_API,
|
|
2607
|
+
// default timeout (10s) is too large; statsig usually responds <200ms
|
|
2608
|
+
networkTimeoutMs: 5e3
|
|
2609
|
+
},
|
|
2610
|
+
// Our proxy supports compression; force it on to save bandwidth.
|
|
2611
|
+
logEventCompressionMode: LogEventCompressionMode.Forced,
|
|
2612
|
+
// Silence harmless warnings from hooks running before async init (we have
|
|
2613
|
+
// bootstrap fallbacks).
|
|
2614
|
+
logLevel: isDevelopment ? void 0 : LogLevel.Error,
|
|
2615
|
+
environment: {
|
|
2616
|
+
tier: isDevelopment ? "development" : "production"
|
|
2617
|
+
}
|
|
2618
|
+
});
|
|
2619
|
+
return /* @__PURE__ */ jsx14(StatsigProvider, { client, children });
|
|
2620
|
+
}
|
|
2621
|
+
|
|
2622
|
+
// src/providers/FunkitProvider.tsx
|
|
2623
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
2624
|
+
var ANONYMOUS_CONFIG = { apiKey: "" };
|
|
2625
|
+
function FunkitProvider({
|
|
2626
|
+
children,
|
|
2627
|
+
config,
|
|
2628
|
+
walletAddress,
|
|
2629
|
+
queryClient,
|
|
2630
|
+
themes,
|
|
2631
|
+
colorScheme,
|
|
2632
|
+
debug = false
|
|
2633
|
+
}) {
|
|
2634
|
+
const fallbackClient = useRef3(void 0);
|
|
2635
|
+
fallbackClient.current ??= new QueryClient();
|
|
2636
|
+
const client = queryClient ?? fallbackClient.current;
|
|
2637
|
+
const identity = useMemo8(
|
|
2638
|
+
() => resolveFunkitIdentity(config ?? ANONYMOUS_CONFIG, walletAddress),
|
|
2639
|
+
[config, walletAddress]
|
|
2640
|
+
);
|
|
2641
|
+
useEffect5(() => {
|
|
2642
|
+
if (!config?.apiKey) {
|
|
2643
|
+
return;
|
|
2644
|
+
}
|
|
2645
|
+
logger.configure(config.apiKey, debug, CONNECT_RN_VERSION);
|
|
2646
|
+
}, [config?.apiKey, debug]);
|
|
2647
|
+
useEffect5(() => {
|
|
2648
|
+
logger.setUserInfo(
|
|
2649
|
+
identity.userId,
|
|
2650
|
+
identity.walletAddress,
|
|
2651
|
+
"",
|
|
2652
|
+
identity.loginType ?? "",
|
|
2653
|
+
""
|
|
2654
|
+
);
|
|
2655
|
+
}, [identity]);
|
|
2656
|
+
return /* @__PURE__ */ jsx15(
|
|
2657
|
+
FunkitStatsigProvider,
|
|
2658
|
+
{
|
|
2659
|
+
apiKey: identity.apiKey,
|
|
2660
|
+
userId: identity.userId,
|
|
2661
|
+
isDevelopment: debug,
|
|
2662
|
+
children: /* @__PURE__ */ jsx15(QueryClientProvider, { client, children: /* @__PURE__ */ jsx15(FunkitIdentityProvider, { identity, children: /* @__PURE__ */ jsx15(FunkitThemeProvider, { themes, colorScheme, children: /* @__PURE__ */ jsx15(FunkitFlowProvider, { children }) }) }) })
|
|
2663
|
+
}
|
|
2664
|
+
);
|
|
2665
|
+
}
|
|
2666
|
+
|
|
2667
|
+
// src/providers/useFunkitCheckout.ts
|
|
2668
|
+
import { useCallback as useCallback4 } from "react";
|
|
2669
|
+
function useFunkitCheckout(callbacks = {}) {
|
|
2670
|
+
const { beginDeposit: begin } = useFunkitFlow();
|
|
2671
|
+
const beginDeposit = useCallback4(
|
|
2672
|
+
(config) => begin(config, callbacks),
|
|
2673
|
+
[begin, callbacks]
|
|
2674
|
+
);
|
|
2675
|
+
return { beginDeposit };
|
|
2676
|
+
}
|
|
2677
|
+
export {
|
|
2678
|
+
Box,
|
|
2679
|
+
FunkitProvider,
|
|
2680
|
+
FunkitThemeProvider,
|
|
2681
|
+
Text,
|
|
2682
|
+
darkTokens,
|
|
2683
|
+
defaultDarkTheme,
|
|
2684
|
+
defaultLightTheme,
|
|
2685
|
+
lightTokens,
|
|
2686
|
+
normalizeColorScheme,
|
|
2687
|
+
resolveColorScheme,
|
|
2688
|
+
toRestyleTheme,
|
|
2689
|
+
useColorScheme,
|
|
2690
|
+
useFunkitCheckout,
|
|
2691
|
+
useFunkitColorScheme,
|
|
2692
|
+
useFunkitTheme
|
|
2693
|
+
};
|
|
2694
|
+
//# sourceMappingURL=index.js.map
|