wallet-stack 1.0.0-alpha.121

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1288) hide show
  1. package/README.md +86 -0
  2. package/app.plugin.js +1 -0
  3. package/locales/base/translation.json +2998 -0
  4. package/locales/de/translation.json +2998 -0
  5. package/locales/en-US/translation.json +2998 -0
  6. package/locales/es-419/translation.json +2998 -0
  7. package/locales/fr-FR/translation.json +2998 -0
  8. package/locales/index.ts +163 -0
  9. package/locales/it-IT/translation.json +2998 -0
  10. package/locales/pl-PL/translation.json +3004 -0
  11. package/locales/pt-BR/translation.json +2998 -0
  12. package/locales/ru-RU/translation.json +3004 -0
  13. package/locales/th-TH/translation.json +2995 -0
  14. package/locales/tr-TR/translation.json +2998 -0
  15. package/locales/uk-UA/translation.json +3004 -0
  16. package/locales/vi-VN/translation.json +2995 -0
  17. package/locales/zh-CN/translation.json +2995 -0
  18. package/metro-config.js +40 -0
  19. package/package.json +227 -0
  20. package/plugin/build/consts.d.ts +2 -0
  21. package/plugin/build/consts.js +6 -0
  22. package/plugin/build/index.d.ts +8 -0
  23. package/plugin/build/index.js +21 -0
  24. package/plugin/build/withAndroidUserAgent.d.ts +8 -0
  25. package/plugin/build/withAndroidUserAgent.js +86 -0
  26. package/plugin/build/withAndroidWindowSoftInputModeAdjustNothing.d.ts +6 -0
  27. package/plugin/build/withAndroidWindowSoftInputModeAdjustNothing.js +16 -0
  28. package/plugin/build/withIosAppDelegateResetKeychain.d.ts +2 -0
  29. package/plugin/build/withIosAppDelegateResetKeychain.js +77 -0
  30. package/plugin/build/withIosUserAgent.d.ts +8 -0
  31. package/plugin/build/withIosUserAgent.js +56 -0
  32. package/plugin/tsconfig.json +13 -0
  33. package/src/RevokePhoneNumber.tsx +117 -0
  34. package/src/abis/IWalletJumpstart.ts +472 -0
  35. package/src/account/AccountErrorScreen.test.tsx +47 -0
  36. package/src/account/AccountErrorScreen.tsx +72 -0
  37. package/src/account/AccountKeyEducation.test.tsx +20 -0
  38. package/src/account/AccountKeyEducation.tsx +83 -0
  39. package/src/account/AccountSetupFailureScreen.test.tsx +59 -0
  40. package/src/account/AccountSetupFailureScreen.tsx +42 -0
  41. package/src/account/Education.test.tsx +48 -0
  42. package/src/account/Education.tsx +235 -0
  43. package/src/account/GoldEducation.test.tsx +35 -0
  44. package/src/account/GoldEducation.tsx +82 -0
  45. package/src/account/LegalSubmenu.test.tsx +84 -0
  46. package/src/account/LegalSubmenu.tsx +74 -0
  47. package/src/account/LicenseDisclaimer.txt +15310 -0
  48. package/src/account/Licenses.test.tsx +17 -0
  49. package/src/account/Licenses.tsx +43 -0
  50. package/src/account/PreferencesSubmenu.test.tsx +66 -0
  51. package/src/account/PreferencesSubmenu.tsx +87 -0
  52. package/src/account/PrivateKey.test.tsx +241 -0
  53. package/src/account/PrivateKey.tsx +169 -0
  54. package/src/account/Profile.test.tsx +77 -0
  55. package/src/account/Profile.tsx +153 -0
  56. package/src/account/ProfileSubmenu.test.tsx +105 -0
  57. package/src/account/ProfileSubmenu.tsx +89 -0
  58. package/src/account/SecuritySubmenu.test.tsx +305 -0
  59. package/src/account/SecuritySubmenu.tsx +435 -0
  60. package/src/account/ShakeForSupport.test.tsx +23 -0
  61. package/src/account/ShakeForSupport.tsx +112 -0
  62. package/src/account/StoreWipeRecoveryScreen.test.tsx +39 -0
  63. package/src/account/StoreWipeRecoveryScreen.tsx +50 -0
  64. package/src/account/Support.test.tsx +67 -0
  65. package/src/account/Support.tsx +69 -0
  66. package/src/account/SupportContact.test.tsx +95 -0
  67. package/src/account/SupportContact.tsx +265 -0
  68. package/src/account/__snapshots__/AccountKeyEducation.test.tsx.snap +579 -0
  69. package/src/account/__snapshots__/Education.test.tsx.snap +286 -0
  70. package/src/account/__snapshots__/GoldEducation.test.tsx.snap +579 -0
  71. package/src/account/__snapshots__/Licenses.test.tsx.snap +33 -0
  72. package/src/account/__snapshots__/ShakeForSupport.test.tsx.snap +3 -0
  73. package/src/account/actions.ts +270 -0
  74. package/src/account/reducer.test.ts +28 -0
  75. package/src/account/reducer.ts +296 -0
  76. package/src/account/saga.test.ts +209 -0
  77. package/src/account/saga.ts +249 -0
  78. package/src/account/selectors.test.ts +18 -0
  79. package/src/account/selectors.ts +60 -0
  80. package/src/account/updateAccountRegistration.ts +35 -0
  81. package/src/account/utils.ts +36 -0
  82. package/src/account/zendesk.test.ts +166 -0
  83. package/src/account/zendesk.ts +199 -0
  84. package/src/alert/AlertBanner.test.tsx +123 -0
  85. package/src/alert/AlertBanner.tsx +84 -0
  86. package/src/alert/actions.ts +127 -0
  87. package/src/alert/reducer.ts +52 -0
  88. package/src/analytics/AppAnalytics.test.ts +334 -0
  89. package/src/analytics/AppAnalytics.ts +369 -0
  90. package/src/analytics/AsyncStoragePersistor.ts +34 -0
  91. package/src/analytics/Events.test.tsx +49 -0
  92. package/src/analytics/Events.tsx +648 -0
  93. package/src/analytics/InjectTraits.ts +34 -0
  94. package/src/analytics/Properties.tsx +1645 -0
  95. package/src/analytics/README.md +24 -0
  96. package/src/analytics/docs.ts +675 -0
  97. package/src/analytics/saga.test.ts +57 -0
  98. package/src/analytics/saga.ts +21 -0
  99. package/src/analytics/selectors.test.ts +391 -0
  100. package/src/analytics/selectors.ts +200 -0
  101. package/src/analytics/types.ts +46 -0
  102. package/src/app/App.test.tsx +25 -0
  103. package/src/app/App.tsx +124 -0
  104. package/src/app/AppInitGate.test.tsx +100 -0
  105. package/src/app/AppInitGate.tsx +77 -0
  106. package/src/app/AppLoading.test.tsx +11 -0
  107. package/src/app/AppLoading.tsx +79 -0
  108. package/src/app/DebugImages.tsx +110 -0
  109. package/src/app/ErrorBoundary.test.tsx +19 -0
  110. package/src/app/ErrorBoundary.tsx +41 -0
  111. package/src/app/ErrorMessages.ts +40 -0
  112. package/src/app/ErrorScreen.test.tsx +26 -0
  113. package/src/app/ErrorScreen.tsx +57 -0
  114. package/src/app/SanctionedCountryErrorScreen.tsx +37 -0
  115. package/src/app/UpgradeScreen.tsx +28 -0
  116. package/src/app/__snapshots__/AppLoading.test.tsx.snap +35 -0
  117. package/src/app/__snapshots__/ErrorScreen.test.tsx.snap +365 -0
  118. package/src/app/actions.ts +301 -0
  119. package/src/app/crowd_mobile.png +0 -0
  120. package/src/app/reducers.ts +204 -0
  121. package/src/app/saga.test.ts +651 -0
  122. package/src/app/saga.ts +367 -0
  123. package/src/app/selectors.ts +53 -0
  124. package/src/app/useDeepLinks.test.tsx +43 -0
  125. package/src/app/useDeepLinks.ts +72 -0
  126. package/src/app/utils.ts +14 -0
  127. package/src/appConfig.test.ts +37 -0
  128. package/src/appConfig.ts +20 -0
  129. package/src/backup/BackupComplete.test.tsx +61 -0
  130. package/src/backup/BackupComplete.tsx +69 -0
  131. package/src/backup/BackupIntroduction.test.tsx +37 -0
  132. package/src/backup/BackupIntroduction.tsx +157 -0
  133. package/src/backup/BackupPhrase.test.tsx +71 -0
  134. package/src/backup/BackupPhrase.tsx +208 -0
  135. package/src/backup/BackupPhraseContainer.test.tsx +43 -0
  136. package/src/backup/BackupPhraseContainer.tsx +207 -0
  137. package/src/backup/BackupQuiz.test.tsx +130 -0
  138. package/src/backup/BackupQuiz.tsx +429 -0
  139. package/src/backup/CancelConfirm.tsx +60 -0
  140. package/src/backup/QuizzBottom.tsx +57 -0
  141. package/src/backup/__snapshots__/BackupComplete.test.tsx.snap +58 -0
  142. package/src/backup/__snapshots__/BackupPhrase.test.tsx.snap +906 -0
  143. package/src/backup/__snapshots__/BackupPhraseContainer.test.tsx.snap +719 -0
  144. package/src/backup/__snapshots__/BackupQuiz.test.tsx.snap +1313 -0
  145. package/src/backup/utils.test.ts +91 -0
  146. package/src/backup/utils.ts +103 -0
  147. package/src/celoNews/CeloNewsFeed.test.tsx +157 -0
  148. package/src/celoNews/CeloNewsFeed.tsx +161 -0
  149. package/src/celoNews/CeloNewsFeedItem.test.tsx +46 -0
  150. package/src/celoNews/CeloNewsFeedItem.tsx +104 -0
  151. package/src/celoNews/types.ts +14 -0
  152. package/src/components/AccountNumber.test.tsx +25 -0
  153. package/src/components/AccountNumber.tsx +78 -0
  154. package/src/components/AccountNumberCard.tsx +23 -0
  155. package/src/components/Avatar.test.tsx +67 -0
  156. package/src/components/Avatar.tsx +72 -0
  157. package/src/components/BackButton.tsx +44 -0
  158. package/src/components/BeatingHeartLoader.tsx +39 -0
  159. package/src/components/BorderlessButton.tsx +25 -0
  160. package/src/components/BottomSheet.tsx +84 -0
  161. package/src/components/BottomSheetBase.tsx +87 -0
  162. package/src/components/BottomSheetScrollView.tsx +54 -0
  163. package/src/components/Button.test.tsx +94 -0
  164. package/src/components/Button.tsx +259 -0
  165. package/src/components/CallToActionsBar.tsx +68 -0
  166. package/src/components/CancelButton.test.tsx +11 -0
  167. package/src/components/CancelButton.tsx +58 -0
  168. package/src/components/Card.tsx +34 -0
  169. package/src/components/CircleButton.test.tsx +35 -0
  170. package/src/components/CircleButton.tsx +64 -0
  171. package/src/components/ClipboardAwarePasteButton.tsx +65 -0
  172. package/src/components/CloseButton.tsx +41 -0
  173. package/src/components/CodeInput.test.tsx +26 -0
  174. package/src/components/CodeInput.tsx +124 -0
  175. package/src/components/CodeRow.test.tsx +27 -0
  176. package/src/components/CodeRow.tsx +163 -0
  177. package/src/components/ContactCircle.test.tsx +67 -0
  178. package/src/components/ContactCircle.tsx +133 -0
  179. package/src/components/ContactCircleSelf.tsx +28 -0
  180. package/src/components/CurrencyDisplay.tsx +242 -0
  181. package/src/components/DataFieldWithCopy.tsx +75 -0
  182. package/src/components/DevSkipButton.tsx +105 -0
  183. package/src/components/Dialog.test.tsx +14 -0
  184. package/src/components/Dialog.tsx +124 -0
  185. package/src/components/Dropdown.tsx +98 -0
  186. package/src/components/EmptyView.tsx +34 -0
  187. package/src/components/ErrorMessageInline.tsx +78 -0
  188. package/src/components/ExchangesBottomSheet.test.tsx +84 -0
  189. package/src/components/ExchangesBottomSheet.tsx +74 -0
  190. package/src/components/Expandable.tsx +57 -0
  191. package/src/components/FeeDrawer.test.tsx +150 -0
  192. package/src/components/FeeDrawer.tsx +127 -0
  193. package/src/components/FeeIcon.test.tsx +14 -0
  194. package/src/components/FeeIcon.tsx +95 -0
  195. package/src/components/FeeInfoBottomSheet.test.tsx +320 -0
  196. package/src/components/FeeInfoBottomSheet.tsx +219 -0
  197. package/src/components/FilterChipsCarousel.tsx +143 -0
  198. package/src/components/FormField.tsx +23 -0
  199. package/src/components/FormLabel.tsx +21 -0
  200. package/src/components/FormTextInput.tsx +16 -0
  201. package/src/components/FullscreenCTA.test.tsx +58 -0
  202. package/src/components/FullscreenCTA.tsx +60 -0
  203. package/src/components/GasFeeWarning.test.tsx +126 -0
  204. package/src/components/GasFeeWarning.tsx +124 -0
  205. package/src/components/GradientBlock.tsx +20 -0
  206. package/src/components/HorizontalLine.tsx +18 -0
  207. package/src/components/IconWithNetworkBadge.test.tsx +49 -0
  208. package/src/components/IconWithNetworkBadge.tsx +69 -0
  209. package/src/components/InLineNotification.test.tsx +74 -0
  210. package/src/components/InLineNotification.tsx +160 -0
  211. package/src/components/InfoBottomSheet.test.tsx +55 -0
  212. package/src/components/InfoBottomSheet.tsx +79 -0
  213. package/src/components/ItemSeparator.test.tsx +8 -0
  214. package/src/components/ItemSeparator.tsx +16 -0
  215. package/src/components/KeyboardAwareScrollView.tsx +104 -0
  216. package/src/components/KeyboardSpacer.tsx +168 -0
  217. package/src/components/LabelWithInfo.tsx +57 -0
  218. package/src/components/LegacyTokenDisplay.test.tsx +282 -0
  219. package/src/components/LegacyTokenDisplay.tsx +63 -0
  220. package/src/components/LegacyTokenTotalLineItem.test.tsx +90 -0
  221. package/src/components/LegacyTokenTotalLineItem.tsx +38 -0
  222. package/src/components/LineItemRow.tsx +74 -0
  223. package/src/components/ListItem.test.tsx +19 -0
  224. package/src/components/ListItem.tsx +44 -0
  225. package/src/components/MessagingCard.tsx +21 -0
  226. package/src/components/Modal.tsx +57 -0
  227. package/src/components/NumberKeypad.test.tsx +21 -0
  228. package/src/components/NumberKeypad.tsx +102 -0
  229. package/src/components/NumberTicker.tsx +115 -0
  230. package/src/components/OnboardingCard.tsx +61 -0
  231. package/src/components/Pagination.tsx +39 -0
  232. package/src/components/PercentageIndicator.test.tsx +118 -0
  233. package/src/components/PercentageIndicator.tsx +75 -0
  234. package/src/components/PhoneNumberInput.test.tsx +99 -0
  235. package/src/components/PhoneNumberInput.tsx +132 -0
  236. package/src/components/PhoneNumberWithFlag.tsx +54 -0
  237. package/src/components/QrScanButton.test.tsx +21 -0
  238. package/src/components/QrScanButton.tsx +30 -0
  239. package/src/components/RecoveryPhraseInput.test.tsx +26 -0
  240. package/src/components/RecoveryPhraseInput.tsx +188 -0
  241. package/src/components/ReviewHeader.test.tsx +21 -0
  242. package/src/components/ReviewHeader.tsx +36 -0
  243. package/src/components/ReviewTransaction.test.tsx +474 -0
  244. package/src/components/ReviewTransaction.tsx +526 -0
  245. package/src/components/RowDivider.tsx +36 -0
  246. package/src/components/SearchInput.tsx +40 -0
  247. package/src/components/SectionHead.test.tsx +9 -0
  248. package/src/components/SectionHead.tsx +33 -0
  249. package/src/components/SegmentedControl.test.tsx +28 -0
  250. package/src/components/SegmentedControl.tsx +156 -0
  251. package/src/components/SelectRecipientButton.tsx +89 -0
  252. package/src/components/SelectionOption.test.tsx +18 -0
  253. package/src/components/SelectionOption.tsx +62 -0
  254. package/src/components/SettingsGearButton.tsx +30 -0
  255. package/src/components/SettingsItem.test.tsx +80 -0
  256. package/src/components/SettingsItem.tsx +195 -0
  257. package/src/components/SimpleMessagingCard.test.tsx +54 -0
  258. package/src/components/SimpleMessagingCard.tsx +90 -0
  259. package/src/components/SingleDigitInput.tsx +53 -0
  260. package/src/components/SkeletonPlaceholder.tsx +33 -0
  261. package/src/components/SmallButton.test.tsx +41 -0
  262. package/src/components/SmallButton.tsx +74 -0
  263. package/src/components/SmartTopAlert.test.tsx +22 -0
  264. package/src/components/SmartTopAlert.tsx +183 -0
  265. package/src/components/Switch.tsx +19 -0
  266. package/src/components/TextButton.tsx +22 -0
  267. package/src/components/TextInput.tsx +133 -0
  268. package/src/components/TextInputWithButtons.test.tsx +24 -0
  269. package/src/components/TextInputWithButtons.tsx +54 -0
  270. package/src/components/Toast.test.tsx +62 -0
  271. package/src/components/Toast.tsx +180 -0
  272. package/src/components/TokenBalance.test.tsx +389 -0
  273. package/src/components/TokenBalance.tsx +321 -0
  274. package/src/components/TokenBottomSheet.test.tsx +356 -0
  275. package/src/components/TokenBottomSheet.tsx +413 -0
  276. package/src/components/TokenDisplay.test.tsx +274 -0
  277. package/src/components/TokenDisplay.tsx +104 -0
  278. package/src/components/TokenEnterAmount.test.tsx +461 -0
  279. package/src/components/TokenEnterAmount.tsx +591 -0
  280. package/src/components/TokenIcon.test.tsx +93 -0
  281. package/src/components/TokenIcon.tsx +142 -0
  282. package/src/components/TokenTotalLineItem.test.tsx +199 -0
  283. package/src/components/TokenTotalLineItem.tsx +103 -0
  284. package/src/components/Touchable.tsx +48 -0
  285. package/src/components/ValidatedTextInput.tsx +96 -0
  286. package/src/components/WebView.tsx +43 -0
  287. package/src/components/WithPasteAware.tsx +113 -0
  288. package/src/components/WithTextInputPasteAware.tsx +51 -0
  289. package/src/components/__snapshots__/AccountNumber.test.tsx.snap +87 -0
  290. package/src/components/__snapshots__/Avatar.test.tsx.snap +435 -0
  291. package/src/components/__snapshots__/Button.test.tsx.snap +292 -0
  292. package/src/components/__snapshots__/CircleButton.test.tsx.snap +211 -0
  293. package/src/components/__snapshots__/CodeRow.test.tsx.snap +211 -0
  294. package/src/components/__snapshots__/ContactCircle.test.tsx.snap +46 -0
  295. package/src/components/__snapshots__/Dialog.test.tsx.snap +248 -0
  296. package/src/components/__snapshots__/FeeIcon.test.tsx.snap +147 -0
  297. package/src/components/__snapshots__/FullscreenCTA.test.tsx.snap +183 -0
  298. package/src/components/__snapshots__/ItemSeparator.test.tsx.snap +13 -0
  299. package/src/components/__snapshots__/NumberKeypad.test.tsx.snap +1434 -0
  300. package/src/components/__snapshots__/PhoneNumberInput.test.tsx.snap +202 -0
  301. package/src/components/__snapshots__/SectionHead.test.tsx.snap +32 -0
  302. package/src/components/__snapshots__/SelectionOption.test.tsx.snap +197 -0
  303. package/src/components/__snapshots__/SettingsItem.test.tsx.snap +226 -0
  304. package/src/components/__snapshots__/SmartTopAlert.test.tsx.snap +103 -0
  305. package/src/components/__snapshots__/TextInputWithButtons.test.tsx.snap +78 -0
  306. package/src/components/header/CustomHeader.tsx +56 -0
  307. package/src/components/multiSelect/MultiSelectBottomSheet.test.tsx +175 -0
  308. package/src/components/multiSelect/MultiSelectBottomSheet.tsx +249 -0
  309. package/src/components/multiSelect/NetworkMultiSelectBottomSheet.test.tsx +77 -0
  310. package/src/components/multiSelect/NetworkMultiSelectBottomSheet.tsx +56 -0
  311. package/src/components/useShowOrHideAnimation.tsx +33 -0
  312. package/src/config.enc +0 -0
  313. package/src/config.ts +186 -0
  314. package/src/dapps/DappShortcutTransactionRequest.test.tsx +187 -0
  315. package/src/dapps/DappShortcutTransactionRequest.tsx +270 -0
  316. package/src/dapps/DappShortcutsRewards.test.tsx +292 -0
  317. package/src/dapps/DappShortcutsRewards.tsx +284 -0
  318. package/src/dapps/DappsScreen.test.tsx +716 -0
  319. package/src/dapps/DappsScreen.tsx +365 -0
  320. package/src/dapps/saga.test.ts +194 -0
  321. package/src/dapps/saga.ts +136 -0
  322. package/src/dapps/selectors.test.ts +127 -0
  323. package/src/dapps/selectors.ts +123 -0
  324. package/src/dapps/slice.ts +110 -0
  325. package/src/dapps/types.ts +30 -0
  326. package/src/dappsExplorer/DappCard.tsx +141 -0
  327. package/src/dappsExplorer/DappFeaturedActions.test.tsx +72 -0
  328. package/src/dappsExplorer/DappFeaturedActions.tsx +121 -0
  329. package/src/dappsExplorer/DiscoverDappsCard.tsx +186 -0
  330. package/src/dappsExplorer/NoResults.tsx +126 -0
  331. package/src/dappsExplorer/TabDiscover.test.tsx +397 -0
  332. package/src/dappsExplorer/TabDiscover.tsx +76 -0
  333. package/src/dappsExplorer/searchDappList.test.tsx +69 -0
  334. package/src/dappsExplorer/searchDappList.tsx +113 -0
  335. package/src/dappsExplorer/useDappFavoritedToast.tsx +56 -0
  336. package/src/dappsExplorer/useOpenDapp.tsx +31 -0
  337. package/src/divviProtocol/saga.test.ts +51 -0
  338. package/src/divviProtocol/saga.ts +44 -0
  339. package/src/earn/ActionCard.tsx +46 -0
  340. package/src/earn/EarnDepositConfirmationScreen.test.tsx +603 -0
  341. package/src/earn/EarnDepositConfirmationScreen.tsx +596 -0
  342. package/src/earn/EarnEnterAmount.test.tsx +1296 -0
  343. package/src/earn/EarnEnterAmount.tsx +815 -0
  344. package/src/earn/EarnEntrypoint.test.tsx +100 -0
  345. package/src/earn/EarnEntrypoint.tsx +127 -0
  346. package/src/earn/EarnHome.test.tsx +237 -0
  347. package/src/earn/EarnHome.tsx +411 -0
  348. package/src/earn/EarnInfoScreen.test.tsx +96 -0
  349. package/src/earn/EarnInfoScreen.tsx +174 -0
  350. package/src/earn/EarnTabBar.test.tsx +43 -0
  351. package/src/earn/EarnTabBar.tsx +73 -0
  352. package/src/earn/EarnWithdrawConfirmationScreen.test.tsx +1022 -0
  353. package/src/earn/EarnWithdrawConfirmationScreen.tsx +476 -0
  354. package/src/earn/PoolCard.test.tsx +68 -0
  355. package/src/earn/PoolCard.tsx +218 -0
  356. package/src/earn/PoolList.tsx +87 -0
  357. package/src/earn/TabEarn.test.tsx +159 -0
  358. package/src/earn/TabEarn.tsx +354 -0
  359. package/src/earn/hooks.test.tsx +328 -0
  360. package/src/earn/hooks.ts +178 -0
  361. package/src/earn/poolInfoScreen/BeforeDepositBottomSheet.test.tsx +411 -0
  362. package/src/earn/poolInfoScreen/BeforeDepositBottomSheet.tsx +448 -0
  363. package/src/earn/poolInfoScreen/Cards.tsx +383 -0
  364. package/src/earn/poolInfoScreen/EarnPoolInfoScreen.test.tsx +498 -0
  365. package/src/earn/poolInfoScreen/EarnPoolInfoScreen.tsx +595 -0
  366. package/src/earn/poolInfoScreen/SafetyCard.test.tsx +108 -0
  367. package/src/earn/poolInfoScreen/SafetyCard.tsx +165 -0
  368. package/src/earn/poolInfoScreen/TokenIcons.tsx +37 -0
  369. package/src/earn/poolInfoScreen/WithdrawBottomSheet.test.tsx +235 -0
  370. package/src/earn/poolInfoScreen/WithdrawBottomSheet.tsx +168 -0
  371. package/src/earn/prepareTransactions.test.ts +616 -0
  372. package/src/earn/prepareTransactions.ts +281 -0
  373. package/src/earn/saga.test.ts +1149 -0
  374. package/src/earn/saga.ts +456 -0
  375. package/src/earn/selectors.ts +5 -0
  376. package/src/earn/simulateTransactions.test.ts +121 -0
  377. package/src/earn/simulateTransactions.ts +58 -0
  378. package/src/earn/slice.test.ts +87 -0
  379. package/src/earn/slice.ts +73 -0
  380. package/src/earn/types.ts +70 -0
  381. package/src/earn/utils.test.ts +48 -0
  382. package/src/earn/utils.ts +54 -0
  383. package/src/fiatExchanges/BidaliScreen.test.tsx +163 -0
  384. package/src/fiatExchanges/BidaliScreen.tsx +189 -0
  385. package/src/fiatExchanges/CashInSuccess.test.tsx +54 -0
  386. package/src/fiatExchanges/CashInSuccess.tsx +104 -0
  387. package/src/fiatExchanges/ExchangeQR.test.tsx +100 -0
  388. package/src/fiatExchanges/ExchangeQR.tsx +94 -0
  389. package/src/fiatExchanges/ExternalExchanges.test.tsx +67 -0
  390. package/src/fiatExchanges/ExternalExchanges.tsx +104 -0
  391. package/src/fiatExchanges/FiatExchangeAmount.test.tsx +418 -0
  392. package/src/fiatExchanges/FiatExchangeAmount.tsx +305 -0
  393. package/src/fiatExchanges/FiatExchangeCurrencyBottomSheet.test.tsx +309 -0
  394. package/src/fiatExchanges/FiatExchangeCurrencyBottomSheet.tsx +139 -0
  395. package/src/fiatExchanges/PaymentMethodSection.test.tsx +259 -0
  396. package/src/fiatExchanges/PaymentMethodSection.tsx +378 -0
  397. package/src/fiatExchanges/ReviewFees.test.tsx +74 -0
  398. package/src/fiatExchanges/ReviewFees.tsx +202 -0
  399. package/src/fiatExchanges/SelectProvider.test.tsx +415 -0
  400. package/src/fiatExchanges/SelectProvider.tsx +649 -0
  401. package/src/fiatExchanges/SimplexScreen.test.tsx +109 -0
  402. package/src/fiatExchanges/SimplexScreen.tsx +185 -0
  403. package/src/fiatExchanges/Spend.tsx +104 -0
  404. package/src/fiatExchanges/WithdrawSpend.test.tsx +37 -0
  405. package/src/fiatExchanges/WithdrawSpend.tsx +139 -0
  406. package/src/fiatExchanges/__snapshots__/CashInSuccess.test.tsx.snap +351 -0
  407. package/src/fiatExchanges/__snapshots__/FiatExchangeAmount.test.tsx.snap +397 -0
  408. package/src/fiatExchanges/__snapshots__/ReviewFees.test.tsx.snap +844 -0
  409. package/src/fiatExchanges/__snapshots__/SimplexScreen.test.tsx.snap +1083 -0
  410. package/src/fiatExchanges/actions.ts +67 -0
  411. package/src/fiatExchanges/amount.test.tsx +48 -0
  412. package/src/fiatExchanges/amount.tsx +45 -0
  413. package/src/fiatExchanges/quotes/ExternalQuote.test.ts +172 -0
  414. package/src/fiatExchanges/quotes/ExternalQuote.ts +121 -0
  415. package/src/fiatExchanges/quotes/FiatConnectQuote.test.ts +718 -0
  416. package/src/fiatExchanges/quotes/FiatConnectQuote.ts +343 -0
  417. package/src/fiatExchanges/quotes/NormalizedQuote.ts +47 -0
  418. package/src/fiatExchanges/quotes/constants.ts +63 -0
  419. package/src/fiatExchanges/quotes/normalizeQuotes.test.ts +102 -0
  420. package/src/fiatExchanges/quotes/normalizeQuotes.ts +76 -0
  421. package/src/fiatExchanges/quotes/utils.ts +31 -0
  422. package/src/fiatExchanges/reducer.ts +65 -0
  423. package/src/fiatExchanges/saga.test.ts +281 -0
  424. package/src/fiatExchanges/saga.ts +195 -0
  425. package/src/fiatExchanges/types.ts +104 -0
  426. package/src/fiatExchanges/utils.test.ts +159 -0
  427. package/src/fiatExchanges/utils.tsx +287 -0
  428. package/src/fiatconnect/FiatDetailsScreen.test.tsx +371 -0
  429. package/src/fiatconnect/FiatDetailsScreen.tsx +441 -0
  430. package/src/fiatconnect/LinkAccountScreen.test.tsx +107 -0
  431. package/src/fiatconnect/LinkAccountScreen.tsx +180 -0
  432. package/src/fiatconnect/RefetchQuoteScreen.test.tsx +119 -0
  433. package/src/fiatconnect/RefetchQuoteScreen.tsx +68 -0
  434. package/src/fiatconnect/ReviewScreen.test.tsx +505 -0
  435. package/src/fiatconnect/ReviewScreen.tsx +708 -0
  436. package/src/fiatconnect/TransferStatusScreen.test.tsx +399 -0
  437. package/src/fiatconnect/TransferStatusScreen.tsx +351 -0
  438. package/src/fiatconnect/clients.test.tsx +83 -0
  439. package/src/fiatconnect/clients.ts +69 -0
  440. package/src/fiatconnect/consts.ts +41 -0
  441. package/src/fiatconnect/fiatAccountSchemas/accountNumber.test.ts +60 -0
  442. package/src/fiatconnect/fiatAccountSchemas/accountNumber.ts +55 -0
  443. package/src/fiatconnect/fiatAccountSchemas/ibanNumber.test.ts +53 -0
  444. package/src/fiatconnect/fiatAccountSchemas/ibanNumber.ts +56 -0
  445. package/src/fiatconnect/fiatAccountSchemas/ifscAccount.test.ts +45 -0
  446. package/src/fiatconnect/fiatAccountSchemas/ifscAccount.ts +58 -0
  447. package/src/fiatconnect/fiatAccountSchemas/index.test.ts +119 -0
  448. package/src/fiatconnect/fiatAccountSchemas/index.ts +89 -0
  449. package/src/fiatconnect/fiatAccountSchemas/mobileMoney.test.ts +29 -0
  450. package/src/fiatconnect/fiatAccountSchemas/mobileMoney.ts +61 -0
  451. package/src/fiatconnect/fiatAccountSchemas/pixAccount.test.ts +45 -0
  452. package/src/fiatconnect/fiatAccountSchemas/pixAccount.ts +62 -0
  453. package/src/fiatconnect/fiatAccountSchemas/types.ts +40 -0
  454. package/src/fiatconnect/index.test.ts +244 -0
  455. package/src/fiatconnect/index.ts +179 -0
  456. package/src/fiatconnect/kyc/KycDenied.test.tsx +139 -0
  457. package/src/fiatconnect/kyc/KycDenied.tsx +144 -0
  458. package/src/fiatconnect/kyc/KycExpired.test.tsx +128 -0
  459. package/src/fiatconnect/kyc/KycExpired.tsx +127 -0
  460. package/src/fiatconnect/kyc/KycInactive.test.tsx +139 -0
  461. package/src/fiatconnect/kyc/KycInactive.tsx +100 -0
  462. package/src/fiatconnect/kyc/KycPending.test.tsx +82 -0
  463. package/src/fiatconnect/kyc/KycPending.tsx +106 -0
  464. package/src/fiatconnect/kyc/getNavigationOptions.tsx +72 -0
  465. package/src/fiatconnect/saga.test.ts +2594 -0
  466. package/src/fiatconnect/saga.ts +1133 -0
  467. package/src/fiatconnect/selectors.ts +24 -0
  468. package/src/fiatconnect/slice.test.ts +79 -0
  469. package/src/fiatconnect/slice.ts +380 -0
  470. package/src/fiatconnect/types.ts +24 -0
  471. package/src/firebase/actions.ts +11 -0
  472. package/src/firebase/db-rules.json +129 -0
  473. package/src/firebase/firebase.test.ts +190 -0
  474. package/src/firebase/firebase.ts +315 -0
  475. package/src/firebase/notifications.test.ts +180 -0
  476. package/src/firebase/notifications.ts +106 -0
  477. package/src/firebase/saga.test.ts +23 -0
  478. package/src/firebase/saga.ts +81 -0
  479. package/src/flags.ts +76 -0
  480. package/src/home/ActionsCarousel.test.tsx +162 -0
  481. package/src/home/ActionsCarousel.tsx +161 -0
  482. package/src/home/DivviBottomSheet.test.tsx +59 -0
  483. package/src/home/DivviBottomSheet.tsx +197 -0
  484. package/src/home/GetStarted.test.tsx +47 -0
  485. package/src/home/GetStarted.tsx +115 -0
  486. package/src/home/NotificationBell.test.tsx +81 -0
  487. package/src/home/NotificationBell.tsx +42 -0
  488. package/src/home/NotificationBox.test.tsx +373 -0
  489. package/src/home/NotificationBox.tsx +362 -0
  490. package/src/home/NotificationCenter.test.tsx +466 -0
  491. package/src/home/NotificationCenter.tsx +185 -0
  492. package/src/home/SendBar.tsx +60 -0
  493. package/src/home/TabHome.test.tsx +336 -0
  494. package/src/home/TabHome.tsx +181 -0
  495. package/src/home/__snapshots__/NotificationBox.test.tsx.snap +933 -0
  496. package/src/home/actions.ts +154 -0
  497. package/src/home/celebration/ConfettiCelebration.tsx +170 -0
  498. package/src/home/celebration/NftCelebration.test.tsx +137 -0
  499. package/src/home/celebration/NftCelebration.tsx +207 -0
  500. package/src/home/celebration/NftReward.test.tsx +94 -0
  501. package/src/home/celebration/NftReward.tsx +172 -0
  502. package/src/home/celebration/confettiAnimation.json +5126 -0
  503. package/src/home/celebration/utils.test.ts +32 -0
  504. package/src/home/celebration/utils.ts +21 -0
  505. package/src/home/reducers.test.ts +245 -0
  506. package/src/home/reducers.ts +191 -0
  507. package/src/home/saga.test.ts +34 -0
  508. package/src/home/saga.ts +87 -0
  509. package/src/home/selectors.test.ts +302 -0
  510. package/src/home/selectors.ts +82 -0
  511. package/src/home/types.ts +31 -0
  512. package/src/i18n/i18n.test.ts +106 -0
  513. package/src/i18n/index.ts +88 -0
  514. package/src/i18n/otaTranslations.test.ts +34 -0
  515. package/src/i18n/otaTranslations.ts +15 -0
  516. package/src/i18n/saga.test.ts +106 -0
  517. package/src/i18n/saga.ts +92 -0
  518. package/src/i18n/selectors.ts +12 -0
  519. package/src/i18n/slice.ts +46 -0
  520. package/src/i18n/useChangeLanguage.test.tsx +53 -0
  521. package/src/i18n/useChangeLanguage.ts +19 -0
  522. package/src/icons/Activity.tsx +21 -0
  523. package/src/icons/Apple.tsx +14 -0
  524. package/src/icons/ArrowDown.tsx +19 -0
  525. package/src/icons/ArrowRightThick.tsx +16 -0
  526. package/src/icons/Attention.tsx +22 -0
  527. package/src/icons/BackChevron.tsx +24 -0
  528. package/src/icons/Backspace.tsx +31 -0
  529. package/src/icons/BankIcon.tsx +23 -0
  530. package/src/icons/Celebration.tsx +18 -0
  531. package/src/icons/CheckCircle.tsx +19 -0
  532. package/src/icons/Checkmark.tsx +26 -0
  533. package/src/icons/CircleArrowIcon.tsx +39 -0
  534. package/src/icons/CircledIcon.tsx +47 -0
  535. package/src/icons/Clipboard.tsx +17 -0
  536. package/src/icons/ClockIcon.tsx +23 -0
  537. package/src/icons/CloudCheck.tsx +19 -0
  538. package/src/icons/ComingSoon.tsx +18 -0
  539. package/src/icons/CopyIcon.tsx +14 -0
  540. package/src/icons/CrossChainIndicator.tsx +36 -0
  541. package/src/icons/DataDown.tsx +16 -0
  542. package/src/icons/DataUp.tsx +16 -0
  543. package/src/icons/DownArrowIcon.tsx +37 -0
  544. package/src/icons/EarnCoins.tsx +22 -0
  545. package/src/icons/Error.tsx +30 -0
  546. package/src/icons/Exit.tsx +18 -0
  547. package/src/icons/ExploreTokens.tsx +17 -0
  548. package/src/icons/EyeIcon.tsx +22 -0
  549. package/src/icons/ForwardChevron.tsx +30 -0
  550. package/src/icons/GearIcon.tsx +19 -0
  551. package/src/icons/Google.tsx +14 -0
  552. package/src/icons/GradientIcon.tsx +70 -0
  553. package/src/icons/GreenLoadingSpinner.tsx +16 -0
  554. package/src/icons/GreenLoadingSpinnerToCheck.tsx +16 -0
  555. package/src/icons/HamburgerCard.tsx +55 -0
  556. package/src/icons/Help.tsx +21 -0
  557. package/src/icons/HiddenEyeIcon.tsx +26 -0
  558. package/src/icons/ImageErrorIcon.tsx +26 -0
  559. package/src/icons/InfoIcon.tsx +33 -0
  560. package/src/icons/KeylessBackup.tsx +32 -0
  561. package/src/icons/LinkArrow.tsx +27 -0
  562. package/src/icons/LoadingSpinner.tsx +25 -0
  563. package/src/icons/Lock.tsx +19 -0
  564. package/src/icons/MagicWand.tsx +20 -0
  565. package/src/icons/Manage.tsx +22 -0
  566. package/src/icons/NotificationBellIcon.tsx +25 -0
  567. package/src/icons/OpenLinkIcon.tsx +18 -0
  568. package/src/icons/Paste.tsx +33 -0
  569. package/src/icons/Phone.tsx +20 -0
  570. package/src/icons/Preferences.tsx +21 -0
  571. package/src/icons/QRCode.tsx +14 -0
  572. package/src/icons/RadioButton.tsx +39 -0
  573. package/src/icons/RedLoadingSpinnerToInfo.tsx +16 -0
  574. package/src/icons/Refresh.tsx +30 -0
  575. package/src/icons/Reward.tsx +29 -0
  576. package/src/icons/ScanIcon.tsx +26 -0
  577. package/src/icons/Search.tsx +25 -0
  578. package/src/icons/Share.tsx +21 -0
  579. package/src/icons/Social.tsx +15 -0
  580. package/src/icons/Stack.tsx +21 -0
  581. package/src/icons/StarOutline.tsx +14 -0
  582. package/src/icons/SwapAndDeposit.tsx +20 -0
  583. package/src/icons/SwapArrows.tsx +20 -0
  584. package/src/icons/ThumbsUpIllustration.tsx +64 -0
  585. package/src/icons/Times.tsx +38 -0
  586. package/src/icons/TripleDotVertical.tsx +18 -0
  587. package/src/icons/Trophy.tsx +18 -0
  588. package/src/icons/User.tsx +19 -0
  589. package/src/icons/Warning.tsx +22 -0
  590. package/src/icons/biometry/Face.tsx +28 -0
  591. package/src/icons/biometry/FaceID.tsx +18 -0
  592. package/src/icons/biometry/Fingerprint.tsx +16 -0
  593. package/src/icons/biometry/Iris.tsx +22 -0
  594. package/src/icons/biometry/TouchID.tsx +44 -0
  595. package/src/icons/loadingSpinnerGreen.json +401 -0
  596. package/src/icons/lottie-json/greenLoadingSpinner.json +370 -0
  597. package/src/icons/lottie-json/greenLoadingSpinnerToCheck.json +666 -0
  598. package/src/icons/lottie-json/redLoadingSpinnerToInfo.json +950 -0
  599. package/src/icons/navigator/Discover.tsx +17 -0
  600. package/src/icons/navigator/Home.tsx +18 -0
  601. package/src/icons/navigator/Wallet.tsx +18 -0
  602. package/src/icons/quick-actions/Add.tsx +18 -0
  603. package/src/icons/quick-actions/More.tsx +19 -0
  604. package/src/icons/quick-actions/Receive.tsx +18 -0
  605. package/src/icons/quick-actions/Send.tsx +18 -0
  606. package/src/icons/quick-actions/Withdraw.tsx +18 -0
  607. package/src/identity/actions.ts +244 -0
  608. package/src/identity/contactMapping.test.ts +391 -0
  609. package/src/identity/contactMapping.ts +422 -0
  610. package/src/identity/reducer.ts +243 -0
  611. package/src/identity/saga.test.ts +103 -0
  612. package/src/identity/saga.ts +122 -0
  613. package/src/identity/secureSend.ts +171 -0
  614. package/src/identity/selectors.ts +16 -0
  615. package/src/identity/types.ts +14 -0
  616. package/src/images/Blob.tsx +20 -0
  617. package/src/images/Celebration.tsx +35 -0
  618. package/src/images/DivviLogo.tsx +22 -0
  619. package/src/images/GuideKeyIcon.tsx +51 -0
  620. package/src/images/Images.ts +22 -0
  621. package/src/images/Logo.tsx +66 -0
  622. package/src/images/LogoHeart.tsx +206 -0
  623. package/src/images/NftReceivedIcon.tsx +18 -0
  624. package/src/images/NftSentIcon.tsx +18 -0
  625. package/src/images/Palm.tsx +21 -0
  626. package/src/images/Star.tsx +20 -0
  627. package/src/images/WelcomeLogo.tsx +19 -0
  628. package/src/images/assets/account-key-1.png +0 -0
  629. package/src/images/assets/account-key-1@1.5x.png +0 -0
  630. package/src/images/assets/account-key-1@2x.png +0 -0
  631. package/src/images/assets/account-key-1@3x.png +0 -0
  632. package/src/images/assets/account-key-1@4x.png +0 -0
  633. package/src/images/assets/account-key-2.png +0 -0
  634. package/src/images/assets/account-key-2@1.5x.png +0 -0
  635. package/src/images/assets/account-key-2@2x.png +0 -0
  636. package/src/images/assets/account-key-2@3x.png +0 -0
  637. package/src/images/assets/account-key-2@4x.png +0 -0
  638. package/src/images/assets/account-key-3.png +0 -0
  639. package/src/images/assets/account-key-3@1.5x.png +0 -0
  640. package/src/images/assets/account-key-3@2x.png +0 -0
  641. package/src/images/assets/account-key-3@3x.png +0 -0
  642. package/src/images/assets/account-key-3@4x.png +0 -0
  643. package/src/images/assets/account-key-4.png +0 -0
  644. package/src/images/assets/account-key-4@1.5x.png +0 -0
  645. package/src/images/assets/account-key-4@2x.png +0 -0
  646. package/src/images/assets/account-key-4@3x.png +0 -0
  647. package/src/images/assets/account-key-4@4x.png +0 -0
  648. package/src/images/assets/biometry-face-id.png +0 -0
  649. package/src/images/assets/biometry-face-id@1.5x.png +0 -0
  650. package/src/images/assets/biometry-face-id@2x.png +0 -0
  651. package/src/images/assets/biometry-face-id@3x.png +0 -0
  652. package/src/images/assets/biometry-face-id@4x.png +0 -0
  653. package/src/images/assets/biometry-face.png +0 -0
  654. package/src/images/assets/biometry-face@1.5x.png +0 -0
  655. package/src/images/assets/biometry-face@2x.png +0 -0
  656. package/src/images/assets/biometry-face@3x.png +0 -0
  657. package/src/images/assets/biometry-face@4x.png +0 -0
  658. package/src/images/assets/biometry-fingerprint.png +0 -0
  659. package/src/images/assets/biometry-fingerprint@1.5x.png +0 -0
  660. package/src/images/assets/biometry-fingerprint@2x.png +0 -0
  661. package/src/images/assets/biometry-fingerprint@3x.png +0 -0
  662. package/src/images/assets/biometry-fingerprint@4x.png +0 -0
  663. package/src/images/assets/biometry-iris.png +0 -0
  664. package/src/images/assets/biometry-iris@1.5x.png +0 -0
  665. package/src/images/assets/biometry-iris@2x.png +0 -0
  666. package/src/images/assets/biometry-iris@3x.png +0 -0
  667. package/src/images/assets/biometry-iris@4x.png +0 -0
  668. package/src/images/assets/biometry-touch-id.png +0 -0
  669. package/src/images/assets/biometry-touch-id@1.5x.png +0 -0
  670. package/src/images/assets/biometry-touch-id@2x.png +0 -0
  671. package/src/images/assets/biometry-touch-id@3x.png +0 -0
  672. package/src/images/assets/biometry-touch-id@4x.png +0 -0
  673. package/src/images/assets/celo-education-1.png +0 -0
  674. package/src/images/assets/celo-education-1@1.5x.png +0 -0
  675. package/src/images/assets/celo-education-1@2x.png +0 -0
  676. package/src/images/assets/celo-education-1@3x.png +0 -0
  677. package/src/images/assets/celo-education-1@4x.png +0 -0
  678. package/src/images/assets/celo-education-2.png +0 -0
  679. package/src/images/assets/celo-education-2@1.5x.png +0 -0
  680. package/src/images/assets/celo-education-2@2x.png +0 -0
  681. package/src/images/assets/celo-education-2@3x.png +0 -0
  682. package/src/images/assets/celo-education-2@4x.png +0 -0
  683. package/src/images/assets/celo-education-3.png +0 -0
  684. package/src/images/assets/celo-education-3@1.5x.png +0 -0
  685. package/src/images/assets/celo-education-3@2x.png +0 -0
  686. package/src/images/assets/celo-education-3@3x.png +0 -0
  687. package/src/images/assets/celo-education-3@4x.png +0 -0
  688. package/src/images/assets/celo-education-4.png +0 -0
  689. package/src/images/assets/celo-education-4@1.5x.png +0 -0
  690. package/src/images/assets/celo-education-4@2x.png +0 -0
  691. package/src/images/assets/celo-education-4@3x.png +0 -0
  692. package/src/images/assets/celo-education-4@4x.png +0 -0
  693. package/src/images/assets/earn-card-background.png +0 -0
  694. package/src/images/assets/earn-card-background@1.5x.png +0 -0
  695. package/src/images/assets/earn-card-background@2x.png +0 -0
  696. package/src/images/assets/earn-card-background@3x.png +0 -0
  697. package/src/images/assets/earn-card-background@4x.png +0 -0
  698. package/src/images/assets/email.png +0 -0
  699. package/src/images/assets/email@1.5x.png +0 -0
  700. package/src/images/assets/email@2x.png +0 -0
  701. package/src/images/assets/email@3x.png +0 -0
  702. package/src/images/assets/email@4x.png +0 -0
  703. package/src/images/assets/fiat-exchange.png +0 -0
  704. package/src/images/assets/fiat-exchange@1.5x.png +0 -0
  705. package/src/images/assets/fiat-exchange@2x.png +0 -0
  706. package/src/images/assets/fiat-exchange@3x.png +0 -0
  707. package/src/images/assets/fiat-exchange@4x.png +0 -0
  708. package/src/images/assets/get-verified.png +0 -0
  709. package/src/images/assets/get-verified@1.5x.png +0 -0
  710. package/src/images/assets/get-verified@2x.png +0 -0
  711. package/src/images/assets/get-verified@3x.png +0 -0
  712. package/src/images/assets/get-verified@4x.png +0 -0
  713. package/src/images/assets/learn-celo.png +0 -0
  714. package/src/images/assets/learn-celo@1.5x.png +0 -0
  715. package/src/images/assets/learn-celo@2x.png +0 -0
  716. package/src/images/assets/learn-celo@3x.png +0 -0
  717. package/src/images/assets/learn-celo@4x.png +0 -0
  718. package/src/images/assets/pie.png +0 -0
  719. package/src/images/assets/pie@1.5x.png +0 -0
  720. package/src/images/assets/pie@2x.png +0 -0
  721. package/src/images/assets/pie@3x.png +0 -0
  722. package/src/images/assets/pie@4x.png +0 -0
  723. package/src/images/assets/points-card-background.png +0 -0
  724. package/src/images/assets/points-card-background@1.5x.png +0 -0
  725. package/src/images/assets/points-card-background@2x.png +0 -0
  726. package/src/images/assets/points-card-background@3x.png +0 -0
  727. package/src/images/assets/points-card-background@4x.png +0 -0
  728. package/src/images/assets/points-illustration.png +0 -0
  729. package/src/images/assets/points-illustration@1.5x.png +0 -0
  730. package/src/images/assets/points-illustration@2x.png +0 -0
  731. package/src/images/assets/points-illustration@3x.png +0 -0
  732. package/src/images/assets/points-illustration@4x.png +0 -0
  733. package/src/images/assets/wallet-safe.png +0 -0
  734. package/src/images/assets/wallet-safe@1.5x.png +0 -0
  735. package/src/images/assets/wallet-safe@2x.png +0 -0
  736. package/src/images/assets/wallet-safe@3x.png +0 -0
  737. package/src/images/assets/wallet-safe@4x.png +0 -0
  738. package/src/import/ImportWallet.test.tsx +102 -0
  739. package/src/import/ImportWallet.tsx +277 -0
  740. package/src/import/actions.ts +41 -0
  741. package/src/import/reducer.ts +28 -0
  742. package/src/import/saga.test.ts +165 -0
  743. package/src/import/saga.ts +250 -0
  744. package/src/in-house-liquidity/client.test.ts +34 -0
  745. package/src/in-house-liquidity/client.ts +38 -0
  746. package/src/in-house-liquidity/index.test.ts +258 -0
  747. package/src/in-house-liquidity/index.ts +187 -0
  748. package/src/index.d.ts +25 -0
  749. package/src/jumpstart/JumpstartTransactionDetailsScreen.test.tsx +329 -0
  750. package/src/jumpstart/JumpstartTransactionDetailsScreen.tsx +407 -0
  751. package/src/jumpstart/fetchClaimStatus.ts +46 -0
  752. package/src/jumpstart/saga.test.ts +117 -0
  753. package/src/jumpstart/saga.ts +82 -0
  754. package/src/jumpstart/selectors.ts +5 -0
  755. package/src/jumpstart/slice.test.ts +51 -0
  756. package/src/jumpstart/slice.ts +64 -0
  757. package/src/keylessBackup/EnvelopeIcon.tsx +19 -0
  758. package/src/keylessBackup/KeylessBackupCancelButton.test.tsx +55 -0
  759. package/src/keylessBackup/KeylessBackupCancelButton.tsx +26 -0
  760. package/src/keylessBackup/KeylessBackupIntro.test.tsx +76 -0
  761. package/src/keylessBackup/KeylessBackupIntro.tsx +175 -0
  762. package/src/keylessBackup/KeylessBackupPhoneCodeInput.test.tsx +256 -0
  763. package/src/keylessBackup/KeylessBackupPhoneCodeInput.tsx +257 -0
  764. package/src/keylessBackup/KeylessBackupPhoneInput.test.tsx +67 -0
  765. package/src/keylessBackup/KeylessBackupPhoneInput.tsx +203 -0
  766. package/src/keylessBackup/KeylessBackupProgress.test.tsx +371 -0
  767. package/src/keylessBackup/KeylessBackupProgress.tsx +495 -0
  768. package/src/keylessBackup/LinkPhoneNumber.test.tsx +57 -0
  769. package/src/keylessBackup/LinkPhoneNumber.tsx +107 -0
  770. package/src/keylessBackup/SignInWithEmail.test.tsx +271 -0
  771. package/src/keylessBackup/SignInWithEmail.tsx +348 -0
  772. package/src/keylessBackup/SmartphoneIcon.tsx +19 -0
  773. package/src/keylessBackup/WalletSecurityPrimer.test.tsx +31 -0
  774. package/src/keylessBackup/WalletSecurityPrimer.tsx +81 -0
  775. package/src/keylessBackup/encryption.test.ts +139 -0
  776. package/src/keylessBackup/encryption.ts +121 -0
  777. package/src/keylessBackup/hooks.ts +179 -0
  778. package/src/keylessBackup/index.test.ts +204 -0
  779. package/src/keylessBackup/index.ts +98 -0
  780. package/src/keylessBackup/keychain.test.ts +55 -0
  781. package/src/keylessBackup/keychain.ts +30 -0
  782. package/src/keylessBackup/saga.test.ts +427 -0
  783. package/src/keylessBackup/saga.ts +264 -0
  784. package/src/keylessBackup/selectors.ts +8 -0
  785. package/src/keylessBackup/slice.ts +108 -0
  786. package/src/keylessBackup/types.ts +25 -0
  787. package/src/keylessBackup/web3auth.test.ts +74 -0
  788. package/src/keylessBackup/web3auth.ts +54 -0
  789. package/src/language/Language.test.tsx +41 -0
  790. package/src/language/Language.tsx +99 -0
  791. package/src/localCurrency/SelectLocalCurrency.test.tsx +19 -0
  792. package/src/localCurrency/SelectLocalCurrency.tsx +83 -0
  793. package/src/localCurrency/actions.ts +49 -0
  794. package/src/localCurrency/consts.test.ts +9 -0
  795. package/src/localCurrency/consts.ts +97 -0
  796. package/src/localCurrency/convert.test.ts +30 -0
  797. package/src/localCurrency/convert.ts +66 -0
  798. package/src/localCurrency/hooks.test.tsx +146 -0
  799. package/src/localCurrency/hooks.ts +47 -0
  800. package/src/localCurrency/reducer.ts +59 -0
  801. package/src/localCurrency/saga.test.ts +34 -0
  802. package/src/localCurrency/saga.ts +61 -0
  803. package/src/localCurrency/selectors.test.ts +47 -0
  804. package/src/localCurrency/selectors.ts +66 -0
  805. package/src/localCurrency/types.ts +6 -0
  806. package/src/missingGlobals.ts +21 -0
  807. package/src/nameGenerator/index.test.ts +46 -0
  808. package/src/nameGenerator/index.ts +17 -0
  809. package/src/nameGenerator/names.ts +938 -0
  810. package/src/navigator/DemoModeAuthBlock.test.tsx +60 -0
  811. package/src/navigator/DemoModeAuthBlock.tsx +61 -0
  812. package/src/navigator/DemoModeChipIndicator.test.tsx +109 -0
  813. package/src/navigator/DemoModeChipIndicator.tsx +76 -0
  814. package/src/navigator/Headers.tsx +263 -0
  815. package/src/navigator/NavigationService.test.tsx +74 -0
  816. package/src/navigator/NavigationService.ts +244 -0
  817. package/src/navigator/Navigator.tsx +760 -0
  818. package/src/navigator/NavigatorWrapper.test.tsx +65 -0
  819. package/src/navigator/NavigatorWrapper.tsx +248 -0
  820. package/src/navigator/QRNavigator.test.tsx +61 -0
  821. package/src/navigator/QRNavigator.tsx +144 -0
  822. package/src/navigator/Screens.tsx +107 -0
  823. package/src/navigator/ScrollAwareHeader.tsx +57 -0
  824. package/src/navigator/SettingsMenu.test.tsx +253 -0
  825. package/src/navigator/SettingsMenu.tsx +353 -0
  826. package/src/navigator/TabNavigator.test.tsx +181 -0
  827. package/src/navigator/TabNavigator.tsx +142 -0
  828. package/src/navigator/TopBarButton.test.tsx +44 -0
  829. package/src/navigator/TopBarButton.tsx +88 -0
  830. package/src/navigator/TopBarIconButtonV2.test.tsx +17 -0
  831. package/src/navigator/TopBarIconButtonV2.tsx +85 -0
  832. package/src/navigator/initialRoute.test.tsx +32 -0
  833. package/src/navigator/initialRoute.tsx +29 -0
  834. package/src/navigator/types.tsx +346 -0
  835. package/src/networkInfo/actions.ts +28 -0
  836. package/src/networkInfo/reducer.ts +44 -0
  837. package/src/networkInfo/saga.test.ts +43 -0
  838. package/src/networkInfo/saga.ts +100 -0
  839. package/src/networkInfo/selectors.ts +4 -0
  840. package/src/nfts/NftMedia.test.tsx +114 -0
  841. package/src/nfts/NftMedia.tsx +205 -0
  842. package/src/nfts/NftsInfoCarousel.test.tsx +218 -0
  843. package/src/nfts/NftsInfoCarousel.tsx +344 -0
  844. package/src/nfts/NftsLoadError.test.tsx +37 -0
  845. package/src/nfts/NftsLoadError.tsx +111 -0
  846. package/src/nfts/saga.test.tsx +502 -0
  847. package/src/nfts/saga.ts +198 -0
  848. package/src/nfts/selectors.ts +13 -0
  849. package/src/nfts/slice.ts +45 -0
  850. package/src/nfts/types.ts +51 -0
  851. package/src/notifications/NotificationList.test.tsx +25 -0
  852. package/src/notifications/NotificationList.tsx +45 -0
  853. package/src/notifications/__snapshots__/NotificationList.test.tsx.snap +35 -0
  854. package/src/notifications/types.ts +31 -0
  855. package/src/onboarding/LanguageButton.tsx +26 -0
  856. package/src/onboarding/TopBarTextButtonOnboarding.test.tsx +22 -0
  857. package/src/onboarding/TopBarTextButtonOnboarding.tsx +17 -0
  858. package/src/onboarding/actions.ts +46 -0
  859. package/src/onboarding/registration/EnableBiometry.test.tsx +168 -0
  860. package/src/onboarding/registration/EnableBiometry.tsx +207 -0
  861. package/src/onboarding/registration/ImportSelect.test.tsx +54 -0
  862. package/src/onboarding/registration/ImportSelect.tsx +167 -0
  863. package/src/onboarding/registration/OnboardingRecoveryPhrase.test.tsx +83 -0
  864. package/src/onboarding/registration/OnboardingRecoveryPhrase.tsx +197 -0
  865. package/src/onboarding/registration/ProtectWallet.test.tsx +96 -0
  866. package/src/onboarding/registration/ProtectWallet.tsx +153 -0
  867. package/src/onboarding/registration/RegulatoryTerms.test.tsx +75 -0
  868. package/src/onboarding/registration/RegulatoryTerms.tsx +174 -0
  869. package/src/onboarding/registration/SelectCountry.test.tsx +51 -0
  870. package/src/onboarding/registration/SelectCountry.tsx +88 -0
  871. package/src/onboarding/registration/SelectCountryItem.tsx +59 -0
  872. package/src/onboarding/steps.test.ts +464 -0
  873. package/src/onboarding/steps.ts +303 -0
  874. package/src/onboarding/success/OnboardingSuccessScreen.tsx +64 -0
  875. package/src/onboarding/types.ts +14 -0
  876. package/src/onboarding/welcome/Welcome.test.tsx +234 -0
  877. package/src/onboarding/welcome/Welcome.tsx +182 -0
  878. package/src/pincode/PasswordCache.ts +71 -0
  879. package/src/pincode/Pincode.tsx +109 -0
  880. package/src/pincode/PincodeDisplay.tsx +92 -0
  881. package/src/pincode/PincodeEnter.test.tsx +85 -0
  882. package/src/pincode/PincodeEnter.tsx +103 -0
  883. package/src/pincode/PincodeLock.test.tsx +144 -0
  884. package/src/pincode/PincodeLock.tsx +121 -0
  885. package/src/pincode/PincodeSet.test.tsx +213 -0
  886. package/src/pincode/PincodeSet.tsx +263 -0
  887. package/src/pincode/authentication.test.ts +654 -0
  888. package/src/pincode/authentication.ts +425 -0
  889. package/src/points/ActivityCard.test.tsx +63 -0
  890. package/src/points/ActivityCard.tsx +101 -0
  891. package/src/points/ActivityCardSection.tsx +126 -0
  892. package/src/points/PointsDiscoverCard.test.tsx +106 -0
  893. package/src/points/PointsDiscoverCard.tsx +122 -0
  894. package/src/points/PointsHistoryBottomSheet.test.tsx +179 -0
  895. package/src/points/PointsHistoryBottomSheet.tsx +264 -0
  896. package/src/points/PointsHome.test.tsx +230 -0
  897. package/src/points/PointsHome.tsx +357 -0
  898. package/src/points/PointsIntro.test.tsx +67 -0
  899. package/src/points/PointsIntro.tsx +85 -0
  900. package/src/points/cardDefinitions.tsx +94 -0
  901. package/src/points/cardSort.test.ts +58 -0
  902. package/src/points/cardSort.ts +18 -0
  903. package/src/points/saga.test.ts +769 -0
  904. package/src/points/saga.ts +379 -0
  905. package/src/points/selectors.test.ts +73 -0
  906. package/src/points/selectors.ts +68 -0
  907. package/src/points/slice.test.ts +76 -0
  908. package/src/points/slice.ts +164 -0
  909. package/src/points/types.ts +94 -0
  910. package/src/positions/HooksPreviewModeBanner.test.tsx +56 -0
  911. package/src/positions/HooksPreviewModeBanner.tsx +69 -0
  912. package/src/positions/actions.ts +11 -0
  913. package/src/positions/getPositionBalanceUsd.ts +14 -0
  914. package/src/positions/saga.test.ts +468 -0
  915. package/src/positions/saga.ts +378 -0
  916. package/src/positions/selectors.test.ts +281 -0
  917. package/src/positions/selectors.ts +189 -0
  918. package/src/positions/slice.ts +219 -0
  919. package/src/positions/transactions.ts +21 -0
  920. package/src/positions/types.ts +137 -0
  921. package/src/priceHistory/PriceHistoryChart.test.tsx +200 -0
  922. package/src/priceHistory/PriceHistoryChart.tsx +345 -0
  923. package/src/priceHistory/__snapshots__/PriceHistoryChart.test.tsx.snap +419 -0
  924. package/src/priceHistory/saga.test.ts +120 -0
  925. package/src/priceHistory/saga.ts +62 -0
  926. package/src/priceHistory/selectors.test.ts +52 -0
  927. package/src/priceHistory/selectors.ts +17 -0
  928. package/src/priceHistory/slice.test.ts +94 -0
  929. package/src/priceHistory/slice.ts +68 -0
  930. package/src/public/components/Button.tsx +66 -0
  931. package/src/public/createApp.ts +67 -0
  932. package/src/public/getFees.test.ts +24 -0
  933. package/src/public/getFees.ts +8 -0
  934. package/src/public/getPublicClient.test.ts +19 -0
  935. package/src/public/getPublicClient.ts +25 -0
  936. package/src/public/getWalletClient.test.ts +30 -0
  937. package/src/public/getWalletClient.ts +32 -0
  938. package/src/public/hooks/toAsyncStatus.ts +19 -0
  939. package/src/public/hooks/usePrepareTransactions.test.ts +63 -0
  940. package/src/public/hooks/usePrepareTransactions.ts +15 -0
  941. package/src/public/hooks/usePublicClient.test.ts +24 -0
  942. package/src/public/hooks/usePublicClient.ts +7 -0
  943. package/src/public/hooks/useSendTransactions.test.ts +49 -0
  944. package/src/public/hooks/useSendTransactions.ts +15 -0
  945. package/src/public/hooks/useWallet.ts +52 -0
  946. package/src/public/hooks/useWalletClient.test.ts +35 -0
  947. package/src/public/hooks/useWalletClient.ts +24 -0
  948. package/src/public/index.ts +29 -0
  949. package/src/public/navigate.test.ts +168 -0
  950. package/src/public/navigate.ts +168 -0
  951. package/src/public/prepareTransactions.test.ts +76 -0
  952. package/src/public/prepareTransactions.ts +78 -0
  953. package/src/public/sendTransactions.test.ts +37 -0
  954. package/src/public/sendTransactions.ts +25 -0
  955. package/src/public/types.tsx +278 -0
  956. package/src/public/unlockAccount.test.ts +79 -0
  957. package/src/public/unlockAccount.ts +43 -0
  958. package/src/qrcode/NotAuthorizedView.test.tsx +11 -0
  959. package/src/qrcode/NotAuthorizedView.tsx +47 -0
  960. package/src/qrcode/QRCode.test.tsx +117 -0
  961. package/src/qrcode/QRCode.tsx +190 -0
  962. package/src/qrcode/QRScanner.tsx +249 -0
  963. package/src/qrcode/QRTabBar.tsx +137 -0
  964. package/src/qrcode/StyledQRCode.tsx +31 -0
  965. package/src/qrcode/StyledQRGen.tsx +26 -0
  966. package/src/qrcode/__snapshots__/NotAuthorizedView.test.tsx.snap +90 -0
  967. package/src/qrcode/schema.test.ts +121 -0
  968. package/src/qrcode/schema.ts +45 -0
  969. package/src/qrcode/utils.test.tsx +293 -0
  970. package/src/qrcode/utils.ts +230 -0
  971. package/src/recaptcha/RecaptchaService.ts +105 -0
  972. package/src/recaptcha/saga.ts +24 -0
  973. package/src/recipients/RecipientItemV2.test.tsx +153 -0
  974. package/src/recipients/RecipientItemV2.tsx +142 -0
  975. package/src/recipients/RecipientPickerV2.test.tsx +110 -0
  976. package/src/recipients/RecipientPickerV2.tsx +61 -0
  977. package/src/recipients/recipient.test.ts +113 -0
  978. package/src/recipients/recipient.ts +313 -0
  979. package/src/recipients/reducer.ts +107 -0
  980. package/src/recipients/resolve-id.ts +21 -0
  981. package/src/recipients/saga.ts +87 -0
  982. package/src/redux/apiReducersList.ts +11 -0
  983. package/src/redux/createMigrate.test.ts +113 -0
  984. package/src/redux/createMigrate.ts +46 -0
  985. package/src/redux/hooks.ts +7 -0
  986. package/src/redux/migrations.test.ts +1925 -0
  987. package/src/redux/migrations.ts +2069 -0
  988. package/src/redux/persist-helper.ts +14 -0
  989. package/src/redux/reducers.ts +29 -0
  990. package/src/redux/reducersForSchemaGeneration.ts +20 -0
  991. package/src/redux/reducersList.ts +57 -0
  992. package/src/redux/sagas-helpers.ts +29 -0
  993. package/src/redux/sagas.test.ts +19 -0
  994. package/src/redux/sagas.ts +155 -0
  995. package/src/redux/selectors.ts +3 -0
  996. package/src/redux/store.test.ts +391 -0
  997. package/src/redux/store.ts +151 -0
  998. package/src/send/EnterAmount.test.tsx +1030 -0
  999. package/src/send/EnterAmount.tsx +360 -0
  1000. package/src/send/EnterAmountOptions.tsx +170 -0
  1001. package/src/send/PasteAddressButton.tsx +81 -0
  1002. package/src/send/SelectRecipientButtons.test.tsx +256 -0
  1003. package/src/send/SelectRecipientButtons.tsx +202 -0
  1004. package/src/send/SendConfirmation.test.tsx +233 -0
  1005. package/src/send/SendConfirmation.tsx +317 -0
  1006. package/src/send/SendEnterAmount.test.tsx +235 -0
  1007. package/src/send/SendEnterAmount.tsx +123 -0
  1008. package/src/send/SendSelectRecipient.test.tsx +765 -0
  1009. package/src/send/SendSelectRecipient.tsx +504 -0
  1010. package/src/send/SendSelectRecipientSearchInput.tsx +72 -0
  1011. package/src/send/ValidateRecipientAccount.test.tsx +181 -0
  1012. package/src/send/ValidateRecipientAccount.tsx +387 -0
  1013. package/src/send/ValidateRecipientIntro.test.tsx +61 -0
  1014. package/src/send/ValidateRecipientIntro.tsx +136 -0
  1015. package/src/send/__snapshots__/ValidateRecipientAccount.test.tsx.snap +777 -0
  1016. package/src/send/actions.ts +142 -0
  1017. package/src/send/hooks.test.tsx +371 -0
  1018. package/src/send/hooks.ts +445 -0
  1019. package/src/send/reducers.ts +90 -0
  1020. package/src/send/saga.test.ts +247 -0
  1021. package/src/send/saga.ts +176 -0
  1022. package/src/send/selectors.ts +22 -0
  1023. package/src/send/types.ts +18 -0
  1024. package/src/send/useFetchRecipientVerificationStatus.ts +67 -0
  1025. package/src/send/usePrepareSendTransactions.test.ts +135 -0
  1026. package/src/send/usePrepareSendTransactions.ts +69 -0
  1027. package/src/send/utils.test.ts +361 -0
  1028. package/src/send/utils.ts +116 -0
  1029. package/src/sendCalls/constants.ts +11 -0
  1030. package/src/sendCalls/saga.test.ts +31 -0
  1031. package/src/sendCalls/saga.ts +15 -0
  1032. package/src/sendCalls/selectors.test.ts +40 -0
  1033. package/src/sendCalls/selectors.ts +8 -0
  1034. package/src/sendCalls/slice.test.ts +85 -0
  1035. package/src/sendCalls/slice.ts +72 -0
  1036. package/src/sentry/Sentry.ts +75 -0
  1037. package/src/sentry/SentrySpanHub.ts +27 -0
  1038. package/src/sentry/SentrySpans.tsx +57 -0
  1039. package/src/sentry/actions.ts +11 -0
  1040. package/src/sentry/saga.ts +8 -0
  1041. package/src/shared/DisconnectBanner.test.tsx +25 -0
  1042. package/src/shared/DisconnectBanner.tsx +81 -0
  1043. package/src/shared/__snapshots__/DisconnectBanner.test.tsx.snap +29 -0
  1044. package/src/shared/conts.ts +16 -0
  1045. package/src/statsig/client.test.ts +62 -0
  1046. package/src/statsig/client.ts +97 -0
  1047. package/src/statsig/constants.ts +177 -0
  1048. package/src/statsig/index.test.ts +351 -0
  1049. package/src/statsig/index.ts +186 -0
  1050. package/src/statsig/selector.ts +17 -0
  1051. package/src/statsig/types.ts +52 -0
  1052. package/src/storage/keychain.tsx +92 -0
  1053. package/src/styles/accessibility.ts +7 -0
  1054. package/src/styles/appTheme.ts +13 -0
  1055. package/src/styles/colors.tsx +78 -0
  1056. package/src/styles/fonts.tsx +143 -0
  1057. package/src/styles/hapticFeedback.ts +27 -0
  1058. package/src/styles/progressDots.ts +23 -0
  1059. package/src/styles/styles.ts +67 -0
  1060. package/src/styles/variables.tsx +16 -0
  1061. package/src/swap/SwapAmountInput.tsx +228 -0
  1062. package/src/swap/SwapScreen.test.tsx +1927 -0
  1063. package/src/swap/SwapScreen.tsx +1156 -0
  1064. package/src/swap/SwapScreenV2.test.tsx +2180 -0
  1065. package/src/swap/SwapScreenV2.tsx +1201 -0
  1066. package/src/swap/SwapTransactionDetails.test.tsx +217 -0
  1067. package/src/swap/SwapTransactionDetails.tsx +274 -0
  1068. package/src/swap/UnfavorableRateBottomSheet.test.tsx +150 -0
  1069. package/src/swap/UnfavorableRateBottomSheet.tsx +288 -0
  1070. package/src/swap/getCrossChainFee.ts +64 -0
  1071. package/src/swap/getSwapTxsAnalyticsProperties.tsx +49 -0
  1072. package/src/swap/saga.test.ts +863 -0
  1073. package/src/swap/saga.ts +324 -0
  1074. package/src/swap/selectors.ts +5 -0
  1075. package/src/swap/slice.test.ts +133 -0
  1076. package/src/swap/slice.ts +93 -0
  1077. package/src/swap/types.ts +98 -0
  1078. package/src/swap/useFilterChips.ts +69 -0
  1079. package/src/swap/useSwapQuote.ts +292 -0
  1080. package/src/tokens/AssetList.test.tsx +270 -0
  1081. package/src/tokens/AssetList.tsx +388 -0
  1082. package/src/tokens/AssetTabBar.test.tsx +130 -0
  1083. package/src/tokens/AssetTabBar.tsx +106 -0
  1084. package/src/tokens/PasteButton.test.tsx +30 -0
  1085. package/src/tokens/PasteButton.tsx +34 -0
  1086. package/src/tokens/PositionIcon.tsx +22 -0
  1087. package/src/tokens/PositionItem.test.tsx +132 -0
  1088. package/src/tokens/PositionItem.tsx +131 -0
  1089. package/src/tokens/TabWallet.test.tsx +386 -0
  1090. package/src/tokens/TabWallet.tsx +237 -0
  1091. package/src/tokens/TokenBalanceItem.test.tsx +119 -0
  1092. package/src/tokens/TokenBalanceItem.tsx +143 -0
  1093. package/src/tokens/TokenDetails.test.tsx +476 -0
  1094. package/src/tokens/TokenDetails.tsx +391 -0
  1095. package/src/tokens/TokenDetailsMoreActions.test.tsx +120 -0
  1096. package/src/tokens/TokenDetailsMoreActions.tsx +87 -0
  1097. package/src/tokens/TokenImport.test.tsx +376 -0
  1098. package/src/tokens/TokenImport.tsx +381 -0
  1099. package/src/tokens/hooks.test.tsx +419 -0
  1100. package/src/tokens/hooks.ts +164 -0
  1101. package/src/tokens/saga.test.ts +527 -0
  1102. package/src/tokens/saga.ts +248 -0
  1103. package/src/tokens/selectors.test.ts +888 -0
  1104. package/src/tokens/selectors.ts +516 -0
  1105. package/src/tokens/slice.ts +173 -0
  1106. package/src/tokens/types.ts +29 -0
  1107. package/src/tokens/utils.test.tsx +330 -0
  1108. package/src/tokens/utils.ts +218 -0
  1109. package/src/transactions/NoActivity.test.tsx +30 -0
  1110. package/src/transactions/NoActivity.tsx +73 -0
  1111. package/src/transactions/TransferAvatars.tsx +39 -0
  1112. package/src/transactions/UserSection.tsx +133 -0
  1113. package/src/transactions/api.ts +67 -0
  1114. package/src/transactions/apiTestHelpers.ts +55 -0
  1115. package/src/transactions/feed/ClaimRewardFeedItem.test.tsx +164 -0
  1116. package/src/transactions/feed/ClaimRewardFeedItem.tsx +142 -0
  1117. package/src/transactions/feed/DepositOrWithdrawFeedItem.test.tsx +138 -0
  1118. package/src/transactions/feed/DepositOrWithdrawFeedItem.tsx +178 -0
  1119. package/src/transactions/feed/EarnFeedItem.test.tsx +189 -0
  1120. package/src/transactions/feed/EarnFeedItem.tsx +190 -0
  1121. package/src/transactions/feed/NftFeedItem.test.tsx +102 -0
  1122. package/src/transactions/feed/NftFeedItem.tsx +99 -0
  1123. package/src/transactions/feed/SwapFeedItem.test.tsx +137 -0
  1124. package/src/transactions/feed/SwapFeedItem.tsx +128 -0
  1125. package/src/transactions/feed/TokenApprovalFeedItem.test.tsx +37 -0
  1126. package/src/transactions/feed/TokenApprovalFeedItem.tsx +59 -0
  1127. package/src/transactions/feed/TransactionDetails.tsx +160 -0
  1128. package/src/transactions/feed/TransactionDetailsScreen.test.tsx +1228 -0
  1129. package/src/transactions/feed/TransactionDetailsScreen.tsx +157 -0
  1130. package/src/transactions/feed/TransactionFeed.test.tsx +474 -0
  1131. package/src/transactions/feed/TransactionFeed.tsx +172 -0
  1132. package/src/transactions/feed/TransactionFeedItemImage.test.tsx +66 -0
  1133. package/src/transactions/feed/TransactionFeedItemImage.tsx +116 -0
  1134. package/src/transactions/feed/TransactionFeedV2.test.tsx +576 -0
  1135. package/src/transactions/feed/TransactionFeedV2.tsx +504 -0
  1136. package/src/transactions/feed/TransactionPrimaryAction.test.tsx +62 -0
  1137. package/src/transactions/feed/TransactionPrimaryAction.tsx +83 -0
  1138. package/src/transactions/feed/TransactionStatusIndicator.test.tsx +15 -0
  1139. package/src/transactions/feed/TransactionStatusIndicator.tsx +63 -0
  1140. package/src/transactions/feed/TransferFeedItem.test.tsx +579 -0
  1141. package/src/transactions/feed/TransferFeedItem.tsx +148 -0
  1142. package/src/transactions/feed/detailContent/ClaimRewardContent.tsx +84 -0
  1143. package/src/transactions/feed/detailContent/DepositOrWithdrawContent.tsx +169 -0
  1144. package/src/transactions/feed/detailContent/EarnContent.tsx +259 -0
  1145. package/src/transactions/feed/detailContent/FeeRowItem.tsx +90 -0
  1146. package/src/transactions/feed/detailContent/RewardReceivedContent.tsx +46 -0
  1147. package/src/transactions/feed/detailContent/SwapContent.tsx +127 -0
  1148. package/src/transactions/feed/detailContent/TokenApprovalDetails.tsx +59 -0
  1149. package/src/transactions/feed/detailContent/TransferReceivedContent.tsx +73 -0
  1150. package/src/transactions/feed/detailContent/TransferSentContent.tsx +117 -0
  1151. package/src/transactions/feed/queryHelper.test.ts +229 -0
  1152. package/src/transactions/feed/queryHelper.ts +941 -0
  1153. package/src/transactions/saga.test.ts +482 -0
  1154. package/src/transactions/saga.ts +322 -0
  1155. package/src/transactions/selectors.ts +120 -0
  1156. package/src/transactions/send.test.ts +29 -0
  1157. package/src/transactions/send.ts +51 -0
  1158. package/src/transactions/slice.test.ts +372 -0
  1159. package/src/transactions/slice.ts +262 -0
  1160. package/src/transactions/transferFeedUtils.ts +225 -0
  1161. package/src/transactions/types.ts +355 -0
  1162. package/src/transactions/utils.test.ts +98 -0
  1163. package/src/transactions/utils.ts +122 -0
  1164. package/src/utils/AppRestart.ts +12 -0
  1165. package/src/utils/Countries.test.ts +180 -0
  1166. package/src/utils/Countries.ts +121 -0
  1167. package/src/utils/IosVersionUtils.ts +6 -0
  1168. package/src/utils/Logger.test.ts +113 -0
  1169. package/src/utils/Logger.ts +304 -0
  1170. package/src/utils/LoggerLevels.ts +6 -0
  1171. package/src/utils/account.test.ts +390 -0
  1172. package/src/utils/account.ts +497 -0
  1173. package/src/utils/accountChecker.test.ts +75 -0
  1174. package/src/utils/accountChecker.ts +77 -0
  1175. package/src/utils/address.test.ts +62 -0
  1176. package/src/utils/address.ts +34 -0
  1177. package/src/utils/aes.test.ts +36 -0
  1178. package/src/utils/aes.ts +46 -0
  1179. package/src/utils/contacts.ts +78 -0
  1180. package/src/utils/contentTranslations.ts +18 -0
  1181. package/src/utils/country.json +257 -0
  1182. package/src/utils/countryFeatures.ts +21 -0
  1183. package/src/utils/currencies.ts +72 -0
  1184. package/src/utils/displayFormatting.ts +11 -0
  1185. package/src/utils/ensureError.test.ts +32 -0
  1186. package/src/utils/ensureError.ts +13 -0
  1187. package/src/utils/fetchWithTimeout.test.ts +55 -0
  1188. package/src/utils/fetchWithTimeout.ts +15 -0
  1189. package/src/utils/formatting.test.ts +93 -0
  1190. package/src/utils/formatting.ts +107 -0
  1191. package/src/utils/getCountryEmoji.ts +28 -0
  1192. package/src/utils/getPhoneHash.ts +29 -0
  1193. package/src/utils/gql.ts +8 -0
  1194. package/src/utils/identifier.ts +81 -0
  1195. package/src/utils/inputValidation.test.ts +53 -0
  1196. package/src/utils/inputValidation.ts +76 -0
  1197. package/src/utils/io.ts +39 -0
  1198. package/src/utils/linking.ts +42 -0
  1199. package/src/utils/moneyAmount.ts +16 -0
  1200. package/src/utils/parsing.test.ts +30 -0
  1201. package/src/utils/parsing.ts +20 -0
  1202. package/src/utils/phoneNumber.test.ts +236 -0
  1203. package/src/utils/phoneNumbers.ts +240 -0
  1204. package/src/utils/random.test.ts +53 -0
  1205. package/src/utils/random.ts +48 -0
  1206. package/src/utils/safely.test.ts +101 -0
  1207. package/src/utils/safely.ts +30 -0
  1208. package/src/utils/sleep.ts +3 -0
  1209. package/src/utils/string.ts +8 -0
  1210. package/src/utils/stylize.ts +30 -0
  1211. package/src/utils/time.test.ts +76 -0
  1212. package/src/utils/time.ts +99 -0
  1213. package/src/utils/typescript.ts +38 -0
  1214. package/src/utils/useBackHandler.ts +10 -0
  1215. package/src/utils/useClipboard.ts +56 -0
  1216. package/src/utils/versionCheck.test.ts +47 -0
  1217. package/src/utils/versionCheck.ts +35 -0
  1218. package/src/verify/ResendButtonWithDelay.tsx +56 -0
  1219. package/src/verify/VerificationCodeInput.test.tsx +87 -0
  1220. package/src/verify/VerificationCodeInput.tsx +103 -0
  1221. package/src/verify/VerificationCodeInputScreen.test.tsx +364 -0
  1222. package/src/verify/VerificationCodeInputScreen.tsx +138 -0
  1223. package/src/verify/VerificationStartScreen.test.tsx +218 -0
  1224. package/src/verify/VerificationStartScreen.tsx +311 -0
  1225. package/src/verify/hooks.test.tsx +85 -0
  1226. package/src/verify/hooks.ts +261 -0
  1227. package/src/viem/estimateFeesPerGas.test.ts +129 -0
  1228. package/src/viem/estimateFeesPerGas.ts +70 -0
  1229. package/src/viem/getLockableWallet.test.ts +263 -0
  1230. package/src/viem/getLockableWallet.ts +120 -0
  1231. package/src/viem/index.ts +86 -0
  1232. package/src/viem/keychainAccountToAccount.test.ts +55 -0
  1233. package/src/viem/keychainAccountToAccount.ts +58 -0
  1234. package/src/viem/prepareTransactions.test.ts +1668 -0
  1235. package/src/viem/prepareTransactions.ts +741 -0
  1236. package/src/viem/preparedTransactionSerialization.test.ts +192 -0
  1237. package/src/viem/preparedTransactionSerialization.ts +100 -0
  1238. package/src/viem/saga.test.ts +227 -0
  1239. package/src/viem/saga.ts +118 -0
  1240. package/src/walletConnect/actions.test.ts +94 -0
  1241. package/src/walletConnect/actions.ts +232 -0
  1242. package/src/walletConnect/analytics.ts +58 -0
  1243. package/src/walletConnect/capabilities.ts +175 -0
  1244. package/src/walletConnect/constants.ts +157 -0
  1245. package/src/walletConnect/reducer.ts +105 -0
  1246. package/src/walletConnect/request.test.ts +698 -0
  1247. package/src/walletConnect/request.ts +225 -0
  1248. package/src/walletConnect/saga.test.ts +1875 -0
  1249. package/src/walletConnect/saga.ts +1159 -0
  1250. package/src/walletConnect/screens/ActionRequest.test.tsx +727 -0
  1251. package/src/walletConnect/screens/ActionRequest.tsx +227 -0
  1252. package/src/walletConnect/screens/ActionRequestPayload.tsx +84 -0
  1253. package/src/walletConnect/screens/ConnectionTimedOut.tsx +34 -0
  1254. package/src/walletConnect/screens/DappsDisclaimer.tsx +31 -0
  1255. package/src/walletConnect/screens/EstimatedNetworkFee.test.tsx +88 -0
  1256. package/src/walletConnect/screens/EstimatedNetworkFee.tsx +134 -0
  1257. package/src/walletConnect/screens/Logos.tsx +89 -0
  1258. package/src/walletConnect/screens/RequestContent.tsx +224 -0
  1259. package/src/walletConnect/screens/SessionRequest.test.tsx +274 -0
  1260. package/src/walletConnect/screens/SessionRequest.tsx +221 -0
  1261. package/src/walletConnect/screens/Sessions.tsx +142 -0
  1262. package/src/walletConnect/screens/WalletConnectRequest.tsx +63 -0
  1263. package/src/walletConnect/screens/useIsDappListed.test.tsx +51 -0
  1264. package/src/walletConnect/screens/useIsDappListed.ts +20 -0
  1265. package/src/walletConnect/selectors.ts +25 -0
  1266. package/src/walletConnect/types.ts +99 -0
  1267. package/src/walletConnect/walletConnect.ts +87 -0
  1268. package/src/web3/KeychainAccounts.test.ts +326 -0
  1269. package/src/web3/KeychainAccounts.ts +309 -0
  1270. package/src/web3/actions.ts +30 -0
  1271. package/src/web3/consts.ts +8 -0
  1272. package/src/web3/contracts.test.ts +115 -0
  1273. package/src/web3/contracts.ts +74 -0
  1274. package/src/web3/networkConfig.test.ts +18 -0
  1275. package/src/web3/networkConfig.ts +621 -0
  1276. package/src/web3/reducer.ts +39 -0
  1277. package/src/web3/saga.test.ts +200 -0
  1278. package/src/web3/saga.ts +229 -0
  1279. package/src/web3/selectors.ts +47 -0
  1280. package/src/web3/utils.test.ts +12 -0
  1281. package/src/web3/utils.ts +11 -0
  1282. package/src/webview/WebViewAndroidBottomSheet.test.tsx +58 -0
  1283. package/src/webview/WebViewAndroidBottomSheet.tsx +83 -0
  1284. package/src/webview/WebViewScreen.test.tsx +84 -0
  1285. package/src/webview/WebViewScreen.tsx +296 -0
  1286. package/src/webview/__snapshots__/WebViewAndroidBottomSheet.test.tsx.snap +249 -0
  1287. package/tsconfig.base.json +5 -0
  1288. package/tsconfig.json +30 -0
@@ -0,0 +1,2180 @@
1
+ import { act, fireEvent, render, waitFor, within } from '@testing-library/react-native'
2
+ import BigNumber from 'bignumber.js'
3
+ import { FetchMock } from 'jest-fetch-mock/types'
4
+ import React from 'react'
5
+ import { DeviceEventEmitter } from 'react-native'
6
+ import { Provider } from 'react-redux'
7
+ import { ReactTestInstance } from 'react-test-renderer'
8
+ import { showError } from 'src/alert/actions'
9
+ import AppAnalytics from 'src/analytics/AppAnalytics'
10
+ import { SwapEvents } from 'src/analytics/Events'
11
+ import { ErrorMessages } from 'src/app/ErrorMessages'
12
+ import { APPROX_SYMBOL } from 'src/components/TokenEnterAmount'
13
+ import { navigate } from 'src/navigator/NavigationService'
14
+ import { Screens } from 'src/navigator/Screens'
15
+ import { NETWORK_NAMES } from 'src/shared/conts'
16
+ import { getDynamicConfigParams, getExperimentParams, getFeatureGate } from 'src/statsig'
17
+ import { StatsigFeatureGates } from 'src/statsig/types'
18
+ import SwapScreenV2 from 'src/swap/SwapScreenV2'
19
+ import { swapStart } from 'src/swap/slice'
20
+ import { FetchQuoteResponse, Field } from 'src/swap/types'
21
+ import { NO_QUOTE_ERROR_MESSAGE } from 'src/swap/useSwapQuote'
22
+ import { NetworkId } from 'src/transactions/types'
23
+ import { publicClient } from 'src/viem'
24
+ import { SerializableTransactionRequest } from 'src/viem/preparedTransactionSerialization'
25
+ import networkConfig from 'src/web3/networkConfig'
26
+ import MockedNavigator from 'test/MockedNavigator'
27
+ import { createMockStore } from 'test/utils'
28
+ import {
29
+ mockAccount,
30
+ mockCeloAddress,
31
+ mockCeloTokenId,
32
+ mockCeurTokenId,
33
+ mockCusdAddress,
34
+ mockCusdTokenId,
35
+ mockEthTokenId,
36
+ mockPoofTokenId,
37
+ mockTestTokenTokenId,
38
+ mockTokenBalances,
39
+ mockUSDCTokenId,
40
+ } from 'test/values'
41
+ import { v4 as uuidv4 } from 'uuid'
42
+
43
+ const mockFetch = fetch as FetchMock
44
+ const mockGetNumberFormatSettings = jest.fn()
45
+
46
+ // Use comma as decimal separator for all tests here
47
+ // Input with "." will still work, but it will also work with ",".
48
+ jest.mock('react-native-localize', () => ({
49
+ getNumberFormatSettings: () => mockGetNumberFormatSettings(),
50
+ }))
51
+
52
+ jest.mock('src/web3/networkConfig', () => {
53
+ const originalModule = jest.requireActual('src/web3/networkConfig')
54
+ return {
55
+ ...originalModule,
56
+ __esModule: true,
57
+ default: {
58
+ ...originalModule.default,
59
+ defaultNetworkId: 'celo-alfajores',
60
+ },
61
+ }
62
+ })
63
+
64
+ jest.mock('src/statsig')
65
+
66
+ jest.mock('viem/actions', () => ({
67
+ ...jest.requireActual('viem/actions'),
68
+ estimateGas: jest.fn(async () => BigInt(21_000)),
69
+ }))
70
+
71
+ jest.mock('src/viem/estimateFeesPerGas', () => ({
72
+ estimateFeesPerGas: jest.fn(async () => ({
73
+ maxFeePerGas: BigInt(12_000_000_000),
74
+ maxPriorityFeePerGas: BigInt(2_000_000_000),
75
+ baseFeePerGas: BigInt(6_000_000_000),
76
+ })),
77
+ }))
78
+
79
+ jest.mock('uuid', () => ({
80
+ v4: jest.fn().mockReturnValue('mocked-uuid'),
81
+ }))
82
+
83
+ const mockedUuidv4 = uuidv4 as jest.Mock
84
+
85
+ const mockStoreTokenBalances = {
86
+ [mockCeurTokenId]: {
87
+ ...mockTokenBalances[mockCeurTokenId],
88
+ isSwappable: true,
89
+ balance: '0',
90
+ priceUsd: '5.03655958698530226301',
91
+ },
92
+ [mockCusdTokenId]: {
93
+ ...mockTokenBalances[mockCusdTokenId],
94
+ isSwappable: true,
95
+ priceUsd: '1',
96
+ },
97
+ [mockCeloTokenId]: {
98
+ ...mockTokenBalances[mockCeloTokenId],
99
+ isSwappable: true,
100
+ priceUsd: '0.81',
101
+ },
102
+ [mockTestTokenTokenId]: {
103
+ tokenId: mockTestTokenTokenId,
104
+ networkId: NetworkId['celo-alfajores'],
105
+ symbol: 'TT',
106
+ name: 'Test Token',
107
+ isSwappable: false,
108
+ balance: '100',
109
+ // no priceUsd
110
+ priceUsd: undefined,
111
+ },
112
+ [mockPoofTokenId]: {
113
+ ...mockTokenBalances[mockPoofTokenId],
114
+ isSwappable: true,
115
+ balance: '100',
116
+ // no priceUsd
117
+ priceUsd: undefined,
118
+ },
119
+ [mockEthTokenId]: {
120
+ ...mockTokenBalances[mockEthTokenId],
121
+ isSwappable: true,
122
+ priceUsd: '2000',
123
+ balance: '10',
124
+ },
125
+ [mockUSDCTokenId]: {
126
+ ...mockTokenBalances[mockUSDCTokenId],
127
+ isSwappable: true,
128
+ balance: '10',
129
+ priceUsd: '1',
130
+ imageUrl: 'https://example.com/usdc.png',
131
+ },
132
+ }
133
+
134
+ const renderScreen = ({
135
+ celoBalance = '10',
136
+ cUSDBalance = '20.456',
137
+ fromTokenId = undefined,
138
+ isPoofSwappable = true,
139
+ poofBalance = '100',
140
+ lastSwapped = [],
141
+ toTokenNetworkId = undefined,
142
+ }: {
143
+ celoBalance?: string
144
+ cUSDBalance?: string
145
+ fromTokenId?: string
146
+ isPoofSwappable?: boolean
147
+ poofBalance?: string
148
+ lastSwapped?: string[]
149
+ toTokenNetworkId?: NetworkId
150
+ }) => {
151
+ const store = createMockStore({
152
+ tokens: {
153
+ tokenBalances: {
154
+ ...mockStoreTokenBalances,
155
+ [mockCusdTokenId]: {
156
+ ...mockStoreTokenBalances[mockCusdTokenId],
157
+ balance: cUSDBalance,
158
+ },
159
+ [mockCeloTokenId]: {
160
+ ...mockStoreTokenBalances[mockCeloTokenId],
161
+ balance: celoBalance,
162
+ },
163
+ [mockPoofTokenId]: {
164
+ ...mockStoreTokenBalances[mockPoofTokenId],
165
+ isSwappable: isPoofSwappable,
166
+ balance: poofBalance,
167
+ },
168
+ },
169
+ },
170
+ swap: {
171
+ lastSwapped,
172
+ },
173
+ })
174
+
175
+ const tree = render(
176
+ <Provider store={store}>
177
+ <MockedNavigator component={SwapScreenV2} params={{ fromTokenId, toTokenNetworkId }} />
178
+ </Provider>
179
+ )
180
+ const [swapFromContainer, swapToContainer] = tree.getAllByTestId('SwapAmountInput')
181
+ const tokenBottomSheets = tree.getAllByTestId('TokenBottomSheet')
182
+ const swapScreen = tree.getByTestId('SwapScreen')
183
+
184
+ return {
185
+ ...tree,
186
+ store,
187
+ swapFromContainer,
188
+ swapToContainer,
189
+ tokenBottomSheets,
190
+ swapScreen,
191
+ }
192
+ }
193
+
194
+ const quoteCusdToCelo: FetchQuoteResponse = {
195
+ unvalidatedSwapTransaction: {
196
+ swapType: 'same-chain',
197
+ chainId: 44787,
198
+ price: '1.2345678', // ~ 1 / 0.81
199
+ guaranteedPrice: '1.1234567',
200
+ appFeePercentageIncludedInPrice: undefined,
201
+ sellTokenAddress: mockCeloAddress,
202
+ buyTokenAddress: mockCusdAddress,
203
+ sellAmount: '1234000000000000000',
204
+ buyAmount: '1523456665200000000',
205
+ allowanceTarget: '0x0000000000000000000000000000000000000123',
206
+ from: mockAccount,
207
+ to: '0x0000000000000000000000000000000000000123',
208
+ value: '0',
209
+ data: '0x0',
210
+ gas: '1800000',
211
+ estimatedGasUse: undefined,
212
+ estimatedPriceImpact: '0.1',
213
+ },
214
+ details: {
215
+ swapProvider: 'someProvider',
216
+ },
217
+ }
218
+ const quoteCeloToCusd: FetchQuoteResponse = {
219
+ ...quoteCusdToCelo,
220
+ unvalidatedSwapTransaction: {
221
+ ...quoteCusdToCelo.unvalidatedSwapTransaction,
222
+ sellTokenAddress: mockCusdAddress,
223
+ buyTokenAddress: mockCeloAddress,
224
+ price: '0.81', // same as celo price
225
+ guaranteedPrice: '0.805',
226
+ sellAmount: '1523456665200000000',
227
+ buyAmount: '1234000000000000000',
228
+ },
229
+ }
230
+ const quoteCusdToCeloResponse = JSON.stringify(quoteCusdToCelo)
231
+ const quoteCeloToCusdResponse = JSON.stringify(quoteCeloToCusd)
232
+
233
+ const preparedTransactions: SerializableTransactionRequest[] = [
234
+ {
235
+ data: '0x095ea7b30000000000000000000000000000000000000000000000000000000000000123000000000000000000000000000000000000000000000000152467c3eff27c00',
236
+ from: '0x0000000000000000000000000000000000007E57',
237
+ gas: '21000',
238
+ maxFeePerGas: '12000000000',
239
+ maxPriorityFeePerGas: '2000000000',
240
+ _baseFeePerGas: '6000000000',
241
+ to: '0xf194afdf50b03e69bd7d057c1aa9e10c9954e4c9',
242
+ },
243
+ {
244
+ data: '0x0',
245
+ from: '0x0000000000000000000000000000000000007E57',
246
+ gas: '1800000',
247
+ maxFeePerGas: '12000000000',
248
+ maxPriorityFeePerGas: '2000000000',
249
+ _baseFeePerGas: '6000000000',
250
+ to: '0x0000000000000000000000000000000000000123',
251
+ value: '0',
252
+ },
253
+ ]
254
+
255
+ const mockTxFeesLearnMoreUrl = 'https://example.com/tx-fees-learn-more'
256
+
257
+ const selectSingleSwapToken = (
258
+ swapAmountContainer: ReactTestInstance,
259
+ tokenSymbol: string,
260
+ swapScreen: ReactTestInstance,
261
+ swapFieldType: Field
262
+ ) => {
263
+ const token = Object.values(mockStoreTokenBalances).find((token) => token.symbol === tokenSymbol)
264
+ expect(token).toBeTruthy()
265
+
266
+ const [fromTokenBottomSheet, toTokenBottomSheet] =
267
+ within(swapScreen).getAllByTestId('TokenBottomSheet')
268
+ const tokenBottomSheet = swapFieldType === Field.FROM ? fromTokenBottomSheet : toTokenBottomSheet
269
+
270
+ fireEvent.press(within(swapAmountContainer).getByTestId('SwapAmountInput/TokenSelect'))
271
+ fireEvent.press(within(tokenBottomSheet).getByText(token!.name))
272
+
273
+ if (swapFieldType === Field.TO && !token!.priceUsd) {
274
+ fireEvent.press(within(swapScreen).getByText('swapScreen.noUsdPriceWarning.ctaConfirm'))
275
+ }
276
+
277
+ expect(
278
+ within(swapAmountContainer).getByText(
279
+ `tokenEnterAmount.tokenDescription, {"tokenName":"${token!.symbol}","tokenNetwork":"${NETWORK_NAMES[token!.networkId]}"}`
280
+ )
281
+ ).toBeTruthy()
282
+
283
+ if (swapFieldType === Field.TO && !token!.priceUsd) {
284
+ expect(
285
+ within(swapScreen).getByText(
286
+ `swapScreen.noUsdPriceWarning.description, {"localCurrency":"PHP","tokenSymbol":"${tokenSymbol}"}`
287
+ )
288
+ ).toBeTruthy()
289
+ }
290
+ }
291
+
292
+ const selectSwapTokens = (
293
+ fromTokenSymbol: string,
294
+ toTokenSymbol: string,
295
+ swapScreen: ReactTestInstance
296
+ ) => {
297
+ const tokenSymbols = [fromTokenSymbol, toTokenSymbol]
298
+ const swapInputContainers = within(swapScreen).getAllByTestId('SwapAmountInput')
299
+
300
+ for (let i = 0; i < 2; i++) {
301
+ const tokenSymbol = tokenSymbols[i]
302
+ const swapInputContainer = swapInputContainers[i]
303
+
304
+ selectSingleSwapToken(
305
+ swapInputContainer,
306
+ tokenSymbol,
307
+ swapScreen,
308
+ i === 0 ? Field.FROM : Field.TO
309
+ )
310
+ }
311
+ }
312
+
313
+ const selectMaxFromAmount = async (swapScreen: ReactTestInstance) => {
314
+ await act(() => {
315
+ DeviceEventEmitter.emit('keyboardDidShow', { endCoordinates: { height: 100 } })
316
+ })
317
+
318
+ const amountPercentageComponent = within(swapScreen).getByTestId('SwapEnterAmount/AmountOptions')
319
+ fireEvent.press(within(amountPercentageComponent).getByText('maxSymbol'))
320
+ }
321
+
322
+ describe('SwapScreen', () => {
323
+ beforeEach(() => {
324
+ jest.clearAllMocks()
325
+ mockFetch.resetMocks()
326
+
327
+ mockGetNumberFormatSettings.mockReturnValue({ decimalSeparator: '.' })
328
+ BigNumber.config({
329
+ FORMAT: {
330
+ decimalSeparator: '.',
331
+ },
332
+ })
333
+
334
+ jest.mocked(getFeatureGate).mockReset()
335
+ jest.mocked(getExperimentParams).mockReturnValue({
336
+ swapBuyAmountEnabled: true,
337
+ })
338
+ jest.mocked(getDynamicConfigParams).mockReturnValue({
339
+ maxSlippagePercentage: '0.3',
340
+ popularTokenIds: [],
341
+ links: {
342
+ transactionFeesLearnMore: mockTxFeesLearnMoreUrl,
343
+ },
344
+ priceImpactWarningThreshold: 4,
345
+ minReceivedFiatWarningPercent: 95,
346
+ })
347
+
348
+ const originalReadContract = publicClient.celo.readContract
349
+ jest.spyOn(publicClient.celo, 'readContract').mockImplementation(async (args) => {
350
+ if (args.functionName === 'allowance') {
351
+ return 0
352
+ }
353
+ return originalReadContract(args)
354
+ })
355
+ })
356
+
357
+ it('should display the correct elements on load', () => {
358
+ const { getByText, swapFromContainer, swapToContainer } = renderScreen({})
359
+
360
+ expect(getByText('swapScreen.title')).toBeTruthy()
361
+ expect(getByText('swapScreen.confirmSwap')).toBeDisabled()
362
+
363
+ expect(within(swapFromContainer).getByText('tokenEnterAmount.selectToken')).toBeTruthy()
364
+ expect(within(swapFromContainer).getByTestId('SwapAmountInput/TokenSelect')).toBeTruthy()
365
+
366
+ expect(within(swapToContainer).getByText('tokenEnterAmount.selectToken')).toBeTruthy()
367
+ expect(within(swapToContainer).getByTestId('SwapAmountInput/TokenSelect')).toBeTruthy()
368
+ })
369
+
370
+ it('should display the UK compliant variants', () => {
371
+ const mockedPopularTokens = [mockUSDCTokenId, mockPoofTokenId]
372
+ jest.mocked(getDynamicConfigParams).mockReturnValue({
373
+ popularTokenIds: mockedPopularTokens,
374
+ maxSlippagePercentage: '0.3',
375
+ })
376
+ jest
377
+ .mocked(getFeatureGate)
378
+ .mockImplementation((gate) => gate === StatsigFeatureGates.SHOW_UK_COMPLIANT_VARIANT)
379
+
380
+ const { getByText, tokenBottomSheets } = renderScreen({})
381
+
382
+ expect(getByText('swapScreen.confirmSwap, {"context":"UK"}')).toBeTruthy()
383
+ expect(getByText('swapScreen.disclaimer, {"context":"UK"}')).toBeTruthy()
384
+ // popular token filter chip is not shown
385
+ expect(within(tokenBottomSheets[0]).queryByText('tokenBottomSheet.filters.popular')).toBeFalsy()
386
+ expect(within(tokenBottomSheets[1]).queryByText('tokenBottomSheet.filters.popular')).toBeFalsy()
387
+ })
388
+
389
+ it('should display the token set via fromTokenId prop', () => {
390
+ const { swapFromContainer, swapToContainer } = renderScreen({ fromTokenId: mockCeurTokenId })
391
+
392
+ expect(
393
+ within(swapFromContainer).getByText(
394
+ 'tokenEnterAmount.tokenDescription, {"tokenName":"cEUR","tokenNetwork":"Celo Alfajores"}'
395
+ )
396
+ ).toBeTruthy()
397
+ expect(within(swapToContainer).getByText('tokenEnterAmount.selectToken')).toBeTruthy()
398
+ })
399
+
400
+ it('should allow selecting tokens', async () => {
401
+ const { swapFromContainer, swapToContainer, swapScreen } = renderScreen({})
402
+
403
+ expect(within(swapFromContainer).getByText('tokenEnterAmount.selectToken')).toBeTruthy()
404
+ expect(within(swapToContainer).getByText('tokenEnterAmount.selectToken')).toBeTruthy()
405
+
406
+ selectSwapTokens('CELO', 'cUSD', swapScreen)
407
+
408
+ const commonAnalyticsProps = {
409
+ areSwapTokensShuffled: false,
410
+ fromTokenId: 'celo-alfajores:native',
411
+ fromTokenNetworkId: 'celo-alfajores',
412
+ fromTokenSymbol: 'CELO',
413
+ switchedNetworkId: false,
414
+ tokenNetworkId: 'celo-alfajores',
415
+ }
416
+ expect(AppAnalytics.track).toHaveBeenCalledWith(SwapEvents.swap_screen_confirm_token, {
417
+ ...commonAnalyticsProps,
418
+ fieldType: 'FROM',
419
+ tokenId: 'celo-alfajores:native',
420
+ tokenPositionInList: 3,
421
+ tokenSymbol: 'CELO',
422
+ })
423
+ expect(AppAnalytics.track).toHaveBeenCalledWith(SwapEvents.swap_screen_confirm_token, {
424
+ ...commonAnalyticsProps,
425
+ fieldType: 'TO',
426
+ tokenId: 'celo-alfajores:0x874069fa1eb16d44d622f2e0ca25eea172369bc1',
427
+ tokenPositionInList: 1,
428
+ tokenSymbol: 'cUSD',
429
+ toTokenId: 'celo-alfajores:0x874069fa1eb16d44d622f2e0ca25eea172369bc1',
430
+ toTokenNetworkId: 'celo-alfajores',
431
+ toTokenSymbol: 'cUSD',
432
+ })
433
+ })
434
+
435
+ it('should show only the allowed to and from tokens', async () => {
436
+ const { swapFromContainer, swapToContainer, tokenBottomSheets } = renderScreen({
437
+ isPoofSwappable: false,
438
+ poofBalance: '0',
439
+ })
440
+ const [fromTokenBottomSheet, toTokenBottomSheet] = tokenBottomSheets
441
+
442
+ fireEvent.press(within(swapFromContainer).getByTestId('SwapAmountInput/TokenSelect'))
443
+
444
+ expect(within(fromTokenBottomSheet).getByText('Celo Dollar')).toBeTruthy()
445
+ // should see TT even though it is marked as not swappable, because there is a balance
446
+ expect(within(fromTokenBottomSheet).getByText('Test Token')).toBeTruthy()
447
+ // should see not see POOF because it is marked as not swappable and there is no balance
448
+ expect(within(fromTokenBottomSheet).queryByText('Poof Governance Token')).toBeFalsy()
449
+
450
+ // finish the token selection
451
+ fireEvent.press(within(fromTokenBottomSheet).getByText('Celo Dollar'))
452
+ expect(
453
+ within(swapFromContainer).getByText(
454
+ 'tokenEnterAmount.tokenDescription, {"tokenName":"cUSD","tokenNetwork":"Celo Alfajores"}'
455
+ )
456
+ ).toBeTruthy()
457
+
458
+ fireEvent.press(within(swapToContainer).getByTestId('SwapAmountInput/TokenSelect'))
459
+
460
+ expect(within(toTokenBottomSheet).getByText('Celo Dollar')).toBeTruthy()
461
+ expect(within(toTokenBottomSheet).queryByText('Test Token')).toBeFalsy()
462
+ expect(within(toTokenBottomSheet).queryByText('Poof Governance Token')).toBeFalsy()
463
+ })
464
+
465
+ it('should not select a token without usd price if the user dismisses the warning', async () => {
466
+ const { swapToContainer, queryByText, getByText, tokenBottomSheets } = renderScreen({})
467
+ const tokenBottomSheet = tokenBottomSheets[1] // "from" token selection
468
+
469
+ fireEvent.press(within(swapToContainer).getByTestId('SwapAmountInput/TokenSelect'))
470
+ fireEvent.press(
471
+ within(tokenBottomSheet).getByText(mockStoreTokenBalances[mockPoofTokenId].name)
472
+ )
473
+
474
+ expect(
475
+ getByText(
476
+ 'swapScreen.noUsdPriceWarning.description, {"localCurrency":"PHP","tokenSymbol":"POOF"}'
477
+ )
478
+ ).toBeTruthy()
479
+
480
+ fireEvent.press(getByText('swapScreen.noUsdPriceWarning.ctaDismiss'))
481
+
482
+ expect(
483
+ queryByText(
484
+ 'swapScreen.noUsdPriceWarning.description, {"localCurrency":"PHP","tokenSymbol":"POOF"}'
485
+ )
486
+ ).toBeFalsy()
487
+ expect(tokenBottomSheet).toBeVisible()
488
+ expect(within(swapToContainer).getByText('tokenEnterAmount.selectToken')).toBeTruthy()
489
+ expect(AppAnalytics.track).not.toHaveBeenCalledWith(
490
+ SwapEvents.swap_screen_confirm_token,
491
+ expect.anything()
492
+ )
493
+ })
494
+
495
+ it('should swap the to/from tokens if the same token is selected', async () => {
496
+ const { swapFromContainer, swapToContainer, swapScreen } = renderScreen({})
497
+
498
+ selectSingleSwapToken(swapFromContainer, 'CELO', swapScreen, Field.FROM)
499
+ selectSingleSwapToken(swapToContainer, 'cUSD', swapScreen, Field.TO)
500
+ selectSingleSwapToken(swapFromContainer, 'cUSD', swapScreen, Field.FROM)
501
+
502
+ expect(
503
+ within(swapFromContainer).getByText(
504
+ 'tokenEnterAmount.tokenDescription, {"tokenName":"cUSD","tokenNetwork":"Celo Alfajores"}'
505
+ )
506
+ ).toBeTruthy()
507
+ expect(
508
+ within(swapToContainer).getByText(
509
+ 'tokenEnterAmount.tokenDescription, {"tokenName":"CELO","tokenNetwork":"Celo Alfajores"}'
510
+ )
511
+ ).toBeTruthy()
512
+ })
513
+
514
+ it('should swap the to/from tokens even if the to token was not selected', async () => {
515
+ const { swapFromContainer, swapToContainer, swapScreen } = renderScreen({})
516
+
517
+ selectSwapTokens('CELO', 'CELO', swapScreen)
518
+
519
+ expect(within(swapFromContainer).getByText('tokenEnterAmount.selectToken')).toBeTruthy()
520
+ expect(
521
+ within(swapToContainer).getByText(
522
+ 'tokenEnterAmount.tokenDescription, {"tokenName":"CELO","tokenNetwork":"Celo Alfajores"}'
523
+ )
524
+ ).toBeTruthy()
525
+ })
526
+
527
+ it('should keep the to amount in sync with the exchange rate', async () => {
528
+ mockFetch.mockResponse(quoteCusdToCeloResponse)
529
+ const { swapFromContainer, swapToContainer, swapScreen, getByText, getByTestId } = renderScreen(
530
+ {}
531
+ )
532
+
533
+ selectSwapTokens('cUSD', 'CELO', swapScreen)
534
+
535
+ fireEvent.changeText(
536
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput'),
537
+ '1.234'
538
+ )
539
+
540
+ await act(() => {
541
+ jest.runOnlyPendingTimers()
542
+ })
543
+
544
+ expect(getByTestId('SwapTransactionDetails/ExchangeRate')).toHaveTextContent(
545
+ '1 cUSD ≈ 1.23456 CELO',
546
+ { exact: false }
547
+ )
548
+ expect(
549
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput').props.value
550
+ ).toBe('1.234')
551
+ expect(
552
+ within(swapFromContainer).getByTestId('SwapAmountInput/ExchangeAmount')
553
+ ).toHaveTextContent(`${APPROX_SYMBOL} ₱1.64`, { exact: false })
554
+ expect(
555
+ within(swapToContainer).getByTestId('SwapAmountInput/TokenAmountInput').props.value
556
+ ).toBe('1.5234566652')
557
+ expect(within(swapToContainer).getByTestId('SwapAmountInput/ExchangeAmount')).toHaveTextContent(
558
+ `${APPROX_SYMBOL} ₱1.64`,
559
+ { exact: false }
560
+ )
561
+ expect(getByText('swapScreen.confirmSwap')).not.toBeDisabled()
562
+ })
563
+
564
+ it('should display a loader when initially fetching exchange rate', async () => {
565
+ mockFetch.mockResponse(quoteCeloToCusdResponse)
566
+ const { swapScreen, swapFromContainer, swapToContainer, getByText, getByTestId } = renderScreen(
567
+ {}
568
+ )
569
+
570
+ selectSwapTokens('CELO', 'cUSD', swapScreen)
571
+ fireEvent.changeText(
572
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput'),
573
+ '1.234'
574
+ )
575
+
576
+ await act(() => {
577
+ jest.runOnlyPendingTimers()
578
+ })
579
+
580
+ expect(mockFetch.mock.calls.length).toEqual(1)
581
+ expect(mockFetch.mock.calls[0][0]).toEqual(
582
+ `${
583
+ networkConfig.getSwapQuoteUrl
584
+ }?buyToken=${mockCusdAddress}&buyIsNative=false&buyNetworkId=${
585
+ NetworkId['celo-alfajores']
586
+ }&sellToken=${mockCeloAddress}&sellIsNative=true&sellNetworkId=${
587
+ NetworkId['celo-alfajores']
588
+ }&sellAmount=1234000000000000000&userAddress=${mockAccount.toLowerCase()}&slippagePercentage=0.3`
589
+ )
590
+
591
+ expect(getByTestId('SwapTransactionDetails/ExchangeRate')).toHaveTextContent(
592
+ '1 CELO ≈ 0.81000 cUSD',
593
+ { exact: false }
594
+ )
595
+ expect(
596
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput').props.value
597
+ ).toBe('1.234')
598
+ expect(
599
+ within(swapToContainer).getByTestId('SwapAmountInput/TokenAmountInput').props.value
600
+ ).toBe('0.99954')
601
+ expect(getByText('swapScreen.confirmSwap')).not.toBeDisabled()
602
+ })
603
+
604
+ it('should allow selecting cross-chain tokens and show cross-chain message', async () => {
605
+ jest
606
+ .mocked(getFeatureGate)
607
+ .mockImplementation((gate) => gate === StatsigFeatureGates.ALLOW_CROSS_CHAIN_SWAPS)
608
+
609
+ const { getByText, queryByText, swapScreen } = renderScreen({})
610
+
611
+ selectSwapTokens('CELO', 'USDC', swapScreen)
612
+ expect(
613
+ queryByText('swapScreen.switchedToNetworkWarning.title, {"networkName":"Ethereum Sepolia"}')
614
+ ).toBeFalsy()
615
+
616
+ expect(getByText('swapScreen.crossChainNotification')).toBeTruthy()
617
+ })
618
+
619
+ it("should show warning on cross-chain swap when user can't afford cross-chain fees and swapping fee currency", async () => {
620
+ jest
621
+ .mocked(getFeatureGate)
622
+ .mockImplementation((gate) => gate === StatsigFeatureGates.ALLOW_CROSS_CHAIN_SWAPS)
623
+ mockFetch.mockResponseOnce(
624
+ JSON.stringify({
625
+ ...quoteCusdToCelo,
626
+ unvalidatedSwapTransaction: {
627
+ ...quoteCusdToCelo.unvalidatedSwapTransaction,
628
+ swapType: 'cross-chain',
629
+ sellAmount: new BigNumber(10).times(new BigNumber(10).pow(18)).toString(),
630
+ maxCrossChainFee: new BigNumber(10).pow(18).toString(),
631
+ },
632
+ })
633
+ )
634
+
635
+ const { getByText, swapScreen, swapFromContainer } = renderScreen({
636
+ celoBalance: '10',
637
+ })
638
+ selectSwapTokens('CELO', 'USDC', swapScreen)
639
+
640
+ fireEvent.changeText(
641
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput'),
642
+ '10'
643
+ )
644
+ await act(() => {
645
+ jest.runOnlyPendingTimers()
646
+ })
647
+
648
+ expect(getByText('swapScreen.confirmSwap')).toBeDisabled()
649
+ expect(
650
+ getByText(
651
+ 'swapScreen.crossChainFeeWarning.body, {"networkName":"Celo Alfajores","tokenSymbol":"CELO","tokenAmount":"1"}'
652
+ )
653
+ ).toBeTruthy()
654
+ })
655
+
656
+ it("should show warning on cross-chain swap when user can't afford cross-chain fees and swapping non-fee currency", async () => {
657
+ jest
658
+ .mocked(getFeatureGate)
659
+ .mockImplementation((gate) => gate === StatsigFeatureGates.ALLOW_CROSS_CHAIN_SWAPS)
660
+ mockFetch.mockResponseOnce(
661
+ JSON.stringify({
662
+ ...quoteCusdToCelo,
663
+ unvalidatedSwapTransaction: {
664
+ ...quoteCusdToCelo.unvalidatedSwapTransaction,
665
+ swapType: 'cross-chain',
666
+ sellAmount: new BigNumber(10).times(new BigNumber(10).pow(18)).toString(),
667
+ maxCrossChainFee: new BigNumber(10).pow(18).toString(),
668
+ },
669
+ })
670
+ )
671
+
672
+ const { getByText, swapScreen, swapFromContainer } = renderScreen({
673
+ celoBalance: '0',
674
+ cUSDBalance: '10',
675
+ })
676
+ selectSwapTokens('cUSD', 'USDC', swapScreen)
677
+
678
+ fireEvent.changeText(
679
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput'),
680
+ '10'
681
+ )
682
+ await act(() => {
683
+ jest.runOnlyPendingTimers()
684
+ })
685
+
686
+ expect(getByText('swapScreen.confirmSwap')).toBeDisabled()
687
+ expect(
688
+ getByText(
689
+ 'swapScreen.crossChainFeeWarning.body, {"networkName":"Celo Alfajores","tokenSymbol":"CELO","tokenAmount":"1"}'
690
+ )
691
+ ).toBeTruthy()
692
+ })
693
+
694
+ it('should allow cross-chain swap when user can pay for cross-chain fee', async () => {
695
+ jest
696
+ .mocked(getFeatureGate)
697
+ .mockImplementation((gate) => gate === StatsigFeatureGates.ALLOW_CROSS_CHAIN_SWAPS)
698
+ mockFetch.mockResponseOnce(
699
+ JSON.stringify({
700
+ ...quoteCusdToCelo,
701
+ unvalidatedSwapTransaction: {
702
+ ...quoteCusdToCelo.unvalidatedSwapTransaction,
703
+ swapType: 'cross-chain',
704
+ sellAmount: new BigNumber(10).times(new BigNumber(10).pow(18)).toString(),
705
+ maxCrossChainFee: new BigNumber(10).pow(18).toString(),
706
+ },
707
+ })
708
+ )
709
+
710
+ const { getByText, queryByText, swapScreen, swapFromContainer } = renderScreen({
711
+ celoBalance: '10',
712
+ })
713
+ selectSwapTokens('CELO', 'USDC', swapScreen)
714
+
715
+ fireEvent.changeText(
716
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput'),
717
+ '5'
718
+ )
719
+ await act(() => {
720
+ jest.runOnlyPendingTimers()
721
+ })
722
+
723
+ expect(getByText('swapScreen.confirmSwap')).toBeDisabled()
724
+ expect(queryByText('swapScreen.crossChainFeeWarning.title')).toBeFalsy()
725
+ })
726
+
727
+ it('should show and hide the price impact warning', async () => {
728
+ // mock priceUsd data: CELO price ~$13, cUSD price = $1
729
+ const lowPriceImpactPrice = '13.12345' // within 4% price impact
730
+ const highPriceImpactPrice = '12.44445' // more than 4% price impact
731
+
732
+ const lowPriceImpact = '1.88' // within 4% price impact
733
+ const highPriceImpact = '5.2' // more than 4% price impact
734
+
735
+ mockFetch.mockResponseOnce(
736
+ JSON.stringify({
737
+ ...quoteCusdToCelo,
738
+ unvalidatedSwapTransaction: {
739
+ ...quoteCusdToCelo.unvalidatedSwapTransaction,
740
+ price: highPriceImpactPrice,
741
+ estimatedPriceImpact: highPriceImpact,
742
+ },
743
+ })
744
+ )
745
+ mockFetch.mockResponseOnce(
746
+ JSON.stringify({
747
+ ...quoteCusdToCelo,
748
+ unvalidatedSwapTransaction: {
749
+ ...quoteCusdToCelo.unvalidatedSwapTransaction,
750
+ price: lowPriceImpactPrice,
751
+ estimatedPriceImpact: lowPriceImpact,
752
+ },
753
+ })
754
+ )
755
+
756
+ const { swapFromContainer, swapScreen, getByText, queryByText, getByTestId } = renderScreen({
757
+ celoBalance: '1000000',
758
+ })
759
+
760
+ // select 100000 CELO to cUSD swap
761
+ selectSwapTokens('CELO', 'cUSD', swapScreen)
762
+ fireEvent.changeText(
763
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput'),
764
+ '100000'
765
+ )
766
+ await act(() => {
767
+ jest.runOnlyPendingTimers()
768
+ })
769
+
770
+ expect(getByTestId('SwapTransactionDetails/ExchangeRate')).toHaveTextContent(
771
+ '1 CELO ≈ 12.44445 cUSD',
772
+ { exact: false }
773
+ )
774
+ expect(getByText('swapScreen.priceImpactWarning.title')).toBeTruthy()
775
+ expect(AppAnalytics.track).toHaveBeenCalledWith(
776
+ SwapEvents.swap_price_impact_warning_displayed,
777
+ {
778
+ toToken: mockCusdAddress,
779
+ toTokenId: mockCusdTokenId,
780
+ toTokenNetworkId: NetworkId['celo-alfajores'],
781
+ toTokenIsImported: false,
782
+ fromToken: mockCeloAddress,
783
+ fromTokenId: mockCeloTokenId,
784
+ fromTokenNetworkId: NetworkId['celo-alfajores'],
785
+ fromTokenIsImported: false,
786
+ amount: '100000',
787
+ amountType: 'sellAmount',
788
+ priceImpact: '5.2',
789
+ provider: 'someProvider',
790
+ }
791
+ )
792
+
793
+ // select 100 CELO to cUSD swap
794
+ fireEvent.changeText(
795
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput'),
796
+ '100'
797
+ )
798
+ await act(() => {
799
+ jest.runOnlyPendingTimers()
800
+ })
801
+
802
+ expect(getByTestId('SwapTransactionDetails/ExchangeRate')).toHaveTextContent(
803
+ '1 CELO ≈ 13.12345 cUSD',
804
+ { exact: false }
805
+ )
806
+ expect(queryByText('swapScreen.priceImpactWarning.title')).toBeFalsy()
807
+ })
808
+
809
+ it('should show and hide the missing price impact warning', async () => {
810
+ const lowPriceImpactPrice = '13.12345'
811
+ const highPriceImpactPrice = '12.44445'
812
+
813
+ mockFetch.mockResponseOnce(
814
+ JSON.stringify({
815
+ ...quoteCusdToCelo,
816
+ unvalidatedSwapTransaction: {
817
+ ...quoteCusdToCelo.unvalidatedSwapTransaction,
818
+ price: highPriceImpactPrice,
819
+ estimatedPriceImpact: null,
820
+ },
821
+ })
822
+ )
823
+ mockFetch.mockResponseOnce(
824
+ JSON.stringify({
825
+ ...quoteCusdToCelo,
826
+ unvalidatedSwapTransaction: {
827
+ ...quoteCusdToCelo.unvalidatedSwapTransaction,
828
+ price: lowPriceImpactPrice,
829
+ estimatedPriceImpact: '2.3',
830
+ },
831
+ })
832
+ )
833
+
834
+ const { swapFromContainer, swapScreen, getByText, queryByText, getByTestId } = renderScreen({
835
+ celoBalance: '1000000',
836
+ })
837
+
838
+ // select 100000 CELO to cUSD swap
839
+ selectSwapTokens('CELO', 'cUSD', swapScreen)
840
+ fireEvent.changeText(
841
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput'),
842
+ '100000'
843
+ )
844
+ await act(() => {
845
+ jest.runOnlyPendingTimers()
846
+ })
847
+
848
+ expect(getByTestId('SwapTransactionDetails/ExchangeRate')).toHaveTextContent(
849
+ '1 CELO ≈ 12.44445 cUSD',
850
+ { exact: false }
851
+ )
852
+ expect(getByText('swapScreen.missingSwapImpactWarning.title')).toBeTruthy()
853
+ expect(AppAnalytics.track).toHaveBeenCalledWith(
854
+ SwapEvents.swap_price_impact_warning_displayed,
855
+ {
856
+ toToken: mockCusdAddress,
857
+ toTokenId: mockCusdTokenId,
858
+ toTokenNetworkId: NetworkId['celo-alfajores'],
859
+ toTokenIsImported: false,
860
+ fromToken: mockCeloAddress,
861
+ fromTokenId: mockCeloTokenId,
862
+ fromTokenNetworkId: NetworkId['celo-alfajores'],
863
+ fromTokenIsImported: false,
864
+ amount: '100000',
865
+ amountType: 'sellAmount',
866
+ priceImpact: null,
867
+ provider: 'someProvider',
868
+ }
869
+ )
870
+
871
+ // select 100 CELO to cUSD swap
872
+ fireEvent.changeText(
873
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput'),
874
+ '100'
875
+ )
876
+ await act(() => {
877
+ jest.runOnlyPendingTimers()
878
+ })
879
+
880
+ expect(getByTestId('SwapTransactionDetails/ExchangeRate')).toHaveTextContent(
881
+ '1 CELO ≈ 13.12345 cUSD',
882
+ { exact: false }
883
+ )
884
+ expect(queryByText('swapScreen.missingSwapImpactWarning.title')).toBeFalsy()
885
+ })
886
+
887
+ it('should prioritise showing the no priceUsd warning when there is also a high price impact', async () => {
888
+ mockFetch.mockResponseOnce(
889
+ JSON.stringify({
890
+ ...quoteCusdToCelo,
891
+ unvalidatedSwapTransaction: {
892
+ ...quoteCusdToCelo.unvalidatedSwapTransaction,
893
+ estimatedPriceImpact: 5, // above warning threshold
894
+ },
895
+ })
896
+ )
897
+
898
+ const { swapFromContainer, swapScreen, getByText, queryByText, getByTestId } = renderScreen({
899
+ celoBalance: '100000',
900
+ })
901
+
902
+ selectSwapTokens('CELO', 'POOF', swapScreen) // no priceUsd
903
+ fireEvent.changeText(
904
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput'),
905
+ '100'
906
+ )
907
+ await act(() => {
908
+ jest.runOnlyPendingTimers()
909
+ })
910
+
911
+ expect(getByTestId('SwapTransactionDetails/ExchangeRate')).toHaveTextContent(
912
+ '1 CELO ≈ 1.23456 POOF',
913
+ { exact: false }
914
+ )
915
+
916
+ expect(getByText('swapScreen.noUsdPriceWarning.title, {"localCurrency":"PHP"}')).toBeTruthy()
917
+ expect(queryByText('swapScreen.priceImpactWarning.title')).toBeFalsy()
918
+ expect(queryByText('swapScreen.missingSwapImpactWarning.title')).toBeFalsy()
919
+ })
920
+
921
+ it('should support from amount with comma as the decimal separator', async () => {
922
+ // This only changes the display format, the input is parsed with getNumberFormatSettings
923
+ BigNumber.config({
924
+ FORMAT: {
925
+ decimalSeparator: ',',
926
+ },
927
+ })
928
+ mockGetNumberFormatSettings.mockReturnValue({ decimalSeparator: ',' })
929
+ mockFetch.mockResponse(quoteCeloToCusdResponse)
930
+ const { swapScreen, swapFromContainer, swapToContainer, getByText, getByTestId } = renderScreen(
931
+ {}
932
+ )
933
+
934
+ selectSwapTokens('CELO', 'cUSD', swapScreen)
935
+ fireEvent.changeText(
936
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput'),
937
+ '1,234'
938
+ )
939
+
940
+ await act(() => {
941
+ jest.runOnlyPendingTimers()
942
+ })
943
+
944
+ expect(mockFetch.mock.calls.length).toEqual(1)
945
+ expect(mockFetch.mock.calls[0][0]).toEqual(
946
+ `${
947
+ networkConfig.getSwapQuoteUrl
948
+ }?buyToken=${mockCusdAddress}&buyIsNative=false&buyNetworkId=${
949
+ NetworkId['celo-alfajores']
950
+ }&sellToken=${mockCeloAddress}&sellIsNative=true&sellNetworkId=${
951
+ NetworkId['celo-alfajores']
952
+ }&sellAmount=1234000000000000000&userAddress=${mockAccount.toLowerCase()}&slippagePercentage=0.3`
953
+ )
954
+
955
+ expect(getByTestId('SwapTransactionDetails/ExchangeRate')).toHaveTextContent(
956
+ '1 CELO ≈ 0,81000 cUSD',
957
+ { exact: false }
958
+ )
959
+ expect(
960
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput').props.value
961
+ ).toBe('1,234')
962
+ expect(
963
+ within(swapFromContainer).getByTestId('SwapAmountInput/ExchangeAmount')
964
+ ).toHaveTextContent(`${APPROX_SYMBOL} ₱1,33`, { exact: false })
965
+ expect(
966
+ within(swapToContainer).getByTestId('SwapAmountInput/TokenAmountInput').props.value
967
+ ).toBe('0,99954')
968
+ expect(within(swapToContainer).getByTestId('SwapAmountInput/ExchangeAmount')).toHaveTextContent(
969
+ `${APPROX_SYMBOL} ₱1,33`,
970
+ { exact: false }
971
+ )
972
+ expect(getByTestId('SwapTransactionDetails/Slippage')).toHaveTextContent('0,3%', {
973
+ exact: false,
974
+ })
975
+ expect(getByText('swapScreen.confirmSwap')).not.toBeDisabled()
976
+ })
977
+
978
+ it.each([
979
+ // mock store has 10 CELO balance
980
+ // mock CELO -> cUSD exchange rate is 1.2345678
981
+ {
982
+ amountLabel: 'percentage, {"percentage":25}',
983
+ percentage: 25,
984
+ expectedFromAmount: '2.5', // 25% of 10
985
+ expectedToAmount: '3.0864195', // expectedFromAmount * exchange rate = 2.5 * 1.2345678
986
+ },
987
+ {
988
+ amountLabel: 'percentage, {"percentage":50}',
989
+ percentage: 50,
990
+ expectedFromAmount: '5',
991
+ expectedToAmount: '6.172839',
992
+ },
993
+ {
994
+ amountLabel: 'percentage, {"percentage":75}',
995
+ percentage: 75,
996
+ expectedFromAmount: '7.5',
997
+ expectedToAmount: '9.2592585',
998
+ },
999
+ {
1000
+ amountLabel: 'maxSymbol',
1001
+ percentage: 100,
1002
+ expectedFromAmount: '10',
1003
+ expectedToAmount: '12.345678',
1004
+ },
1005
+ ])(
1006
+ 'sets the expected amount when the $amountLabel chip is selected',
1007
+ async ({ amountLabel, percentage, expectedToAmount, expectedFromAmount }) => {
1008
+ mockFetch.mockResponse(quoteCusdToCeloResponse)
1009
+ const { swapFromContainer, swapToContainer, getByText, getByTestId, swapScreen } =
1010
+ renderScreen({})
1011
+
1012
+ selectSwapTokens('CELO', 'cUSD', swapScreen)
1013
+
1014
+ await act(() => {
1015
+ DeviceEventEmitter.emit('keyboardDidShow', { endCoordinates: { height: 100 } })
1016
+ })
1017
+
1018
+ fireEvent.press(within(getByTestId('SwapEnterAmount/AmountOptions')).getByText(amountLabel))
1019
+
1020
+ await waitFor(() =>
1021
+ expect(getByTestId('SwapTransactionDetails/ExchangeRate')).toHaveTextContent(
1022
+ '1 CELO ≈ 1.23456 cUSD',
1023
+ { exact: false }
1024
+ )
1025
+ )
1026
+ expect(
1027
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput').props.value
1028
+ ).toBe(expectedFromAmount)
1029
+ expect(
1030
+ within(swapToContainer).getByTestId('SwapAmountInput/TokenAmountInput').props.value
1031
+ ).toBe(expectedToAmount)
1032
+ expect(getByText('swapScreen.confirmSwap')).not.toBeDisabled()
1033
+ }
1034
+ )
1035
+
1036
+ it('should show and hide the max warning for fee currencies', async () => {
1037
+ mockFetch.mockResponse(quoteCusdToCeloResponse)
1038
+ const { swapFromContainer, getByText, queryByTestId, swapScreen } = renderScreen({
1039
+ celoBalance: '0',
1040
+ cUSDBalance: '10',
1041
+ }) // so that cUSD is the only feeCurrency with a balance
1042
+
1043
+ selectSingleSwapToken(swapFromContainer, 'cUSD', swapScreen, Field.FROM)
1044
+ await selectMaxFromAmount(swapScreen)
1045
+ await waitFor(() =>
1046
+ expect(
1047
+ getByText('swapScreen.maxSwapAmountWarning.bodyV1_74, {"tokenSymbol":"cUSD"}')
1048
+ ).toBeTruthy()
1049
+ )
1050
+
1051
+ fireEvent.press(getByText('swapScreen.maxSwapAmountWarning.learnMore'))
1052
+ expect(navigate).toHaveBeenCalledWith(Screens.WebViewScreen, {
1053
+ uri: mockTxFeesLearnMoreUrl,
1054
+ })
1055
+
1056
+ fireEvent.changeText(
1057
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput'),
1058
+ '1.234'
1059
+ )
1060
+ await waitFor(() => expect(queryByTestId('MaxSwapAmountWarning')).toBeFalsy())
1061
+ })
1062
+
1063
+ it("shouldn't show the max warning when there's balance for more than 1 fee currency", async () => {
1064
+ mockFetch.mockResponse(quoteCusdToCeloResponse)
1065
+ const { swapFromContainer, queryByTestId, swapScreen } = renderScreen({
1066
+ celoBalance: '10',
1067
+ cUSDBalance: '20',
1068
+ })
1069
+
1070
+ selectSingleSwapToken(swapFromContainer, 'CELO', swapScreen, Field.FROM)
1071
+ await selectMaxFromAmount(swapScreen)
1072
+ await waitFor(() => expect(queryByTestId('MaxSwapAmountWarning')).toBeFalsy())
1073
+ })
1074
+
1075
+ it('should fetch the quote if the amount is cleared and re-entered', async () => {
1076
+ mockFetch.mockResponse(quoteCusdToCeloResponse)
1077
+ const { swapFromContainer, swapToContainer, getByText, getByTestId, swapScreen } = renderScreen(
1078
+ {}
1079
+ )
1080
+
1081
+ selectSwapTokens('CELO', 'cUSD', swapScreen)
1082
+ await selectMaxFromAmount(swapScreen)
1083
+
1084
+ await act(() => {
1085
+ jest.runOnlyPendingTimers()
1086
+ })
1087
+
1088
+ expect(mockFetch.mock.calls.length).toEqual(1)
1089
+ expect(getByText('swapScreen.confirmSwap')).not.toBeDisabled()
1090
+
1091
+ fireEvent.changeText(
1092
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput'),
1093
+ ''
1094
+ )
1095
+
1096
+ expect(
1097
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput').props.value
1098
+ ).toBe('')
1099
+ expect(
1100
+ within(swapToContainer).getByTestId('SwapAmountInput/TokenAmountInput').props.value
1101
+ ).toBe('')
1102
+ expect(getByText('swapScreen.confirmSwap')).toBeDisabled()
1103
+ expect(mockFetch.mock.calls.length).toEqual(1)
1104
+
1105
+ await selectMaxFromAmount(swapScreen)
1106
+
1107
+ await act(() => {
1108
+ jest.runOnlyPendingTimers()
1109
+ })
1110
+
1111
+ expect(getByTestId('SwapTransactionDetails/ExchangeRate')).toHaveTextContent(
1112
+ '1 CELO ≈ 1.23456 cUSD',
1113
+ { exact: false }
1114
+ )
1115
+ expect(
1116
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput').props.value
1117
+ ).toBe(
1118
+ '10' // matching the value inside the mocked store
1119
+ )
1120
+ expect(
1121
+ within(swapToContainer).getByTestId('SwapAmountInput/TokenAmountInput').props.value
1122
+ ).toBe('12.345678')
1123
+ expect(getByText('swapScreen.confirmSwap')).not.toBeDisabled()
1124
+ expect(mockFetch.mock.calls.length).toEqual(2)
1125
+ })
1126
+
1127
+ it('should set max value if it is zero', async () => {
1128
+ const { swapFromContainer, swapToContainer, getByText, swapScreen } = renderScreen({
1129
+ celoBalance: '0',
1130
+ cUSDBalance: '0',
1131
+ })
1132
+
1133
+ selectSwapTokens('CELO', 'cUSD', swapScreen)
1134
+ await selectMaxFromAmount(swapScreen)
1135
+
1136
+ expect(
1137
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput').props.value
1138
+ ).toBe('0')
1139
+ expect(
1140
+ within(swapToContainer).getByTestId('SwapAmountInput/TokenAmountInput').props.value
1141
+ ).toBe('')
1142
+ expect(mockFetch).not.toHaveBeenCalled()
1143
+ expect(getByText('swapScreen.confirmSwap')).toBeDisabled()
1144
+ })
1145
+
1146
+ it('should display an error banner if api request fails', async () => {
1147
+ mockFetch.mockReject(new Error('Failed to fetch'))
1148
+
1149
+ const { swapFromContainer, getByText, store, swapScreen } = renderScreen({})
1150
+
1151
+ selectSwapTokens('CELO', 'cUSD', swapScreen)
1152
+ fireEvent.changeText(
1153
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput'),
1154
+ '1.234'
1155
+ )
1156
+
1157
+ await act(() => {
1158
+ jest.runOnlyPendingTimers()
1159
+ })
1160
+
1161
+ expect(getByText('swapScreen.confirmSwap')).toBeDisabled()
1162
+ expect(store.getActions()).toEqual(
1163
+ expect.arrayContaining([showError(ErrorMessages.FETCH_SWAP_QUOTE_FAILED)])
1164
+ )
1165
+ })
1166
+
1167
+ it('should display an unsupported notification if quote is not available', async () => {
1168
+ mockFetch.mockReject(new Error(NO_QUOTE_ERROR_MESSAGE))
1169
+
1170
+ const { swapFromContainer, getByText, swapScreen } = renderScreen({})
1171
+
1172
+ selectSwapTokens('CELO', 'cUSD', swapScreen)
1173
+ fireEvent.changeText(
1174
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput'),
1175
+ '1.234'
1176
+ )
1177
+
1178
+ await act(() => {
1179
+ jest.runOnlyPendingTimers()
1180
+ })
1181
+
1182
+ expect(getByText('swapScreen.confirmSwap')).toBeDisabled()
1183
+ expect(getByText('swapScreen.unsupportedTokensWarning.title')).toBeTruthy()
1184
+ })
1185
+
1186
+ it('should be able to start a swap', async () => {
1187
+ const quoteReceivedTimestamp = 1000
1188
+ jest.spyOn(Date, 'now').mockReturnValue(quoteReceivedTimestamp) // quote received timestamp
1189
+
1190
+ mockFetch.mockResponse(quoteCeloToCusdResponse)
1191
+ const { getByText, store, swapScreen } = renderScreen({})
1192
+
1193
+ selectSwapTokens('CELO', 'cUSD', swapScreen)
1194
+ await selectMaxFromAmount(swapScreen)
1195
+
1196
+ await act(() => {
1197
+ jest.runOnlyPendingTimers()
1198
+ })
1199
+
1200
+ expect(getByText('swapScreen.confirmSwap')).not.toBeDisabled()
1201
+ fireEvent.press(getByText('swapScreen.confirmSwap'))
1202
+
1203
+ expect(store.getActions()).toEqual(
1204
+ expect.arrayContaining([
1205
+ swapStart({
1206
+ swapId: expect.any(String),
1207
+ quote: {
1208
+ preparedTransactions,
1209
+ receivedAt: quoteReceivedTimestamp,
1210
+ price: quoteCeloToCusd.unvalidatedSwapTransaction.price,
1211
+ appFeePercentageIncludedInPrice:
1212
+ quoteCeloToCusd.unvalidatedSwapTransaction.appFeePercentageIncludedInPrice,
1213
+ provider: quoteCeloToCusd.details.swapProvider,
1214
+ estimatedPriceImpact: quoteCusdToCelo.unvalidatedSwapTransaction.estimatedPriceImpact,
1215
+ allowanceTarget: quoteCusdToCelo.unvalidatedSwapTransaction.allowanceTarget,
1216
+ swapType: 'same-chain',
1217
+ },
1218
+ userInput: {
1219
+ toTokenId: mockCusdTokenId,
1220
+ fromTokenId: mockCeloTokenId,
1221
+ swapAmount: {
1222
+ [Field.FROM]: '10',
1223
+ [Field.TO]: '8.1', // 10 * 0.81
1224
+ },
1225
+ updatedField: Field.FROM,
1226
+ },
1227
+ areSwapTokensShuffled: false,
1228
+ }),
1229
+ ])
1230
+ )
1231
+ })
1232
+
1233
+ it('should start the swap without an approval transaction if the allowance is high enough', async () => {
1234
+ jest.spyOn(publicClient.celo, 'readContract').mockResolvedValueOnce(BigInt(11 * 1e18)) // greater than swap amount of 10
1235
+ mockFetch.mockResponse(
1236
+ JSON.stringify({
1237
+ ...quoteCusdToCelo,
1238
+ unvalidatedSwapTransaction: {
1239
+ ...quoteCusdToCelo.unvalidatedSwapTransaction,
1240
+ buyTokenAddress: mockCeloAddress,
1241
+ sellTokenAddress: mockCusdAddress,
1242
+ },
1243
+ })
1244
+ )
1245
+ const { getByText, store, swapScreen, swapFromContainer } = renderScreen({})
1246
+
1247
+ selectSwapTokens('cUSD', 'CELO', swapScreen)
1248
+ fireEvent.changeText(
1249
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput'),
1250
+ '10'
1251
+ )
1252
+
1253
+ await act(() => {
1254
+ jest.runOnlyPendingTimers()
1255
+ })
1256
+
1257
+ expect(getByText('swapScreen.confirmSwap')).not.toBeDisabled()
1258
+ fireEvent.press(getByText('swapScreen.confirmSwap'))
1259
+
1260
+ expect(store.getActions()).toEqual(
1261
+ expect.arrayContaining([
1262
+ swapStart({
1263
+ swapId: expect.any(String),
1264
+ quote: {
1265
+ preparedTransactions: [preparedTransactions[1]], // no approval transaction
1266
+ receivedAt: expect.any(Number),
1267
+ price: quoteCusdToCelo.unvalidatedSwapTransaction.price,
1268
+ appFeePercentageIncludedInPrice:
1269
+ quoteCusdToCelo.unvalidatedSwapTransaction.appFeePercentageIncludedInPrice,
1270
+ provider: quoteCusdToCelo.details.swapProvider,
1271
+ estimatedPriceImpact: quoteCusdToCelo.unvalidatedSwapTransaction.estimatedPriceImpact,
1272
+ allowanceTarget: quoteCusdToCelo.unvalidatedSwapTransaction.allowanceTarget,
1273
+ swapType: 'same-chain',
1274
+ },
1275
+ userInput: {
1276
+ toTokenId: mockCeloTokenId,
1277
+ fromTokenId: mockCusdTokenId,
1278
+ swapAmount: {
1279
+ [Field.FROM]: '10',
1280
+ [Field.TO]: '12.345678', // 10 * 1.2345678
1281
+ },
1282
+ updatedField: Field.FROM,
1283
+ },
1284
+ areSwapTokensShuffled: false,
1285
+ }),
1286
+ ])
1287
+ )
1288
+ })
1289
+
1290
+ it('should be able to start a swap when the entered value uses comma as the decimal separator', async () => {
1291
+ const quoteReceivedTimestamp = 1000
1292
+ jest.spyOn(Date, 'now').mockReturnValue(quoteReceivedTimestamp) // quote received timestamp
1293
+
1294
+ mockGetNumberFormatSettings.mockReturnValue({ decimalSeparator: ',' })
1295
+ mockFetch.mockResponse(quoteCeloToCusdResponse)
1296
+ const { swapScreen, swapFromContainer, getByText, store } = renderScreen({})
1297
+
1298
+ selectSwapTokens('CELO', 'cUSD', swapScreen)
1299
+ fireEvent.changeText(
1300
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput'),
1301
+ '1.5'
1302
+ )
1303
+
1304
+ await act(() => {
1305
+ jest.runOnlyPendingTimers()
1306
+ })
1307
+
1308
+ expect(getByText('swapScreen.confirmSwap')).not.toBeDisabled()
1309
+ fireEvent.press(getByText('swapScreen.confirmSwap'))
1310
+
1311
+ expect(store.getActions()).toEqual(
1312
+ expect.arrayContaining([
1313
+ swapStart({
1314
+ swapId: expect.any(String),
1315
+ quote: {
1316
+ preparedTransactions,
1317
+ receivedAt: quoteReceivedTimestamp,
1318
+ price: quoteCeloToCusd.unvalidatedSwapTransaction.price,
1319
+ appFeePercentageIncludedInPrice:
1320
+ quoteCeloToCusd.unvalidatedSwapTransaction.appFeePercentageIncludedInPrice,
1321
+ provider: quoteCeloToCusd.details.swapProvider,
1322
+ estimatedPriceImpact: quoteCusdToCelo.unvalidatedSwapTransaction.estimatedPriceImpact,
1323
+ allowanceTarget: quoteCusdToCelo.unvalidatedSwapTransaction.allowanceTarget,
1324
+ swapType: 'same-chain',
1325
+ },
1326
+ userInput: {
1327
+ toTokenId: mockCusdTokenId,
1328
+ fromTokenId: mockCeloTokenId,
1329
+ swapAmount: {
1330
+ [Field.FROM]: '1.5',
1331
+ [Field.TO]: '1.215', // 1.5 * 0.81
1332
+ },
1333
+ updatedField: Field.FROM,
1334
+ },
1335
+ areSwapTokensShuffled: false,
1336
+ }),
1337
+ ])
1338
+ )
1339
+ })
1340
+
1341
+ it('should have correct analytics on swap submission', async () => {
1342
+ mockFetch.mockResponse(quoteCeloToCusdResponse)
1343
+
1344
+ const mockSwapId = 'test-swap-id'
1345
+ mockedUuidv4.mockReturnValue(mockSwapId)
1346
+
1347
+ const { getByText, swapScreen } = renderScreen({})
1348
+
1349
+ selectSwapTokens('CELO', 'cUSD', swapScreen)
1350
+ await selectMaxFromAmount(swapScreen)
1351
+
1352
+ await act(() => {
1353
+ jest.runOnlyPendingTimers()
1354
+ })
1355
+
1356
+ expect(getByText('swapScreen.confirmSwap')).not.toBeDisabled()
1357
+
1358
+ // Clear any previous events
1359
+ jest.mocked(AppAnalytics.track).mockClear()
1360
+
1361
+ fireEvent.press(getByText('swapScreen.confirmSwap'))
1362
+ expect(AppAnalytics.track).toHaveBeenCalledWith(SwapEvents.swap_review_submit, {
1363
+ toToken: mockCusdAddress,
1364
+ toTokenId: mockCusdTokenId,
1365
+ toTokenNetworkId: NetworkId['celo-alfajores'],
1366
+ toTokenIsImported: false,
1367
+ fromToken: mockCeloAddress,
1368
+ fromTokenId: mockCeloTokenId,
1369
+ fromTokenNetworkId: NetworkId['celo-alfajores'],
1370
+ fromTokenIsImported: false,
1371
+ amount: '10',
1372
+ amountType: 'sellAmount',
1373
+ allowanceTarget: quoteCeloToCusd.unvalidatedSwapTransaction.allowanceTarget,
1374
+ estimatedPriceImpact: quoteCeloToCusd.unvalidatedSwapTransaction.estimatedPriceImpact,
1375
+ price: quoteCeloToCusd.unvalidatedSwapTransaction.price,
1376
+ provider: quoteCeloToCusd.details.swapProvider,
1377
+ web3Library: 'viem',
1378
+ gas: 1821000,
1379
+ maxGasFee: 0.021852,
1380
+ maxGasFeeUsd: 0.01770012,
1381
+ estimatedGasFee: 0.014568,
1382
+ estimatedGasFeeUsd: 0.01180008,
1383
+ feeCurrency: undefined,
1384
+ feeCurrencySymbol: 'CELO',
1385
+ txCount: 2,
1386
+ swapType: 'same-chain',
1387
+ swapId: mockSwapId,
1388
+ isUnfavorableRate: false,
1389
+ })
1390
+ })
1391
+
1392
+ describe.each([
1393
+ { testName: 'price impact too high', estimatedPriceImpact: '5.2', price: '0.81' },
1394
+ { testName: 'unfavorable exchange rate', estimatedPriceImpact: '0.1', price: '0.4' },
1395
+ ])('with $testName', ({ estimatedPriceImpact, price }) => {
1396
+ const analyticsProps = {
1397
+ toToken: mockCusdAddress,
1398
+ toTokenId: mockCusdTokenId,
1399
+ toTokenNetworkId: NetworkId['celo-alfajores'],
1400
+ toTokenIsImported: false,
1401
+ fromToken: mockCeloAddress,
1402
+ fromTokenId: mockCeloTokenId,
1403
+ fromTokenNetworkId: NetworkId['celo-alfajores'],
1404
+ fromTokenIsImported: false,
1405
+ amount: '10',
1406
+ amountType: 'sellAmount',
1407
+ estimatedPriceImpact,
1408
+ price,
1409
+ appFeePercentageIncludedInPrice:
1410
+ quoteCeloToCusd.unvalidatedSwapTransaction.appFeePercentageIncludedInPrice,
1411
+ provider: quoteCeloToCusd.details.swapProvider,
1412
+ swapType: 'same-chain',
1413
+ }
1414
+
1415
+ beforeEach(() => {
1416
+ mockFetch.mockResponseOnce(
1417
+ JSON.stringify({
1418
+ ...quoteCeloToCusd,
1419
+ unvalidatedSwapTransaction: {
1420
+ ...quoteCeloToCusd.unvalidatedSwapTransaction,
1421
+ estimatedPriceImpact,
1422
+ price,
1423
+ },
1424
+ })
1425
+ )
1426
+ })
1427
+
1428
+ it('should show unfavorable rate bottom sheet', async () => {
1429
+ const { getByText, store, swapScreen } = renderScreen({})
1430
+
1431
+ selectSwapTokens('CELO', 'cUSD', swapScreen)
1432
+ await selectMaxFromAmount(swapScreen)
1433
+
1434
+ await act(() => {
1435
+ jest.runOnlyPendingTimers()
1436
+ })
1437
+
1438
+ expect(getByText('swapScreen.confirmSwap')).not.toBeDisabled()
1439
+ fireEvent.press(getByText('swapScreen.confirmSwap'))
1440
+
1441
+ expect(store.getActions()).toEqual([])
1442
+ expect(AppAnalytics.track).toHaveBeenCalledWith(
1443
+ SwapEvents.swap_unfavorable_rate_warning_displayed,
1444
+ analyticsProps
1445
+ )
1446
+ })
1447
+
1448
+ it('pressing cancel fires analytics and does nothing else', async () => {
1449
+ const { getByText, getByTestId, store, swapScreen } = renderScreen({})
1450
+
1451
+ selectSwapTokens('CELO', 'cUSD', swapScreen)
1452
+ await selectMaxFromAmount(swapScreen)
1453
+
1454
+ await act(() => {
1455
+ jest.runOnlyPendingTimers()
1456
+ })
1457
+ fireEvent.press(getByText('swapScreen.confirmSwap'))
1458
+
1459
+ fireEvent.press(getByTestId('unfavorable-rate-cancel'))
1460
+
1461
+ expect(store.getActions()).toEqual([])
1462
+ expect(AppAnalytics.track).toHaveBeenCalledWith(
1463
+ SwapEvents.swap_unfavorable_rate_warning_cancelled,
1464
+ analyticsProps
1465
+ )
1466
+ })
1467
+
1468
+ it('selecting confirm and submits the swap', async () => {
1469
+ const quoteReceivedTimestamp = 1000
1470
+ jest.spyOn(Date, 'now').mockReturnValue(quoteReceivedTimestamp) // quote received timestamp
1471
+ const { getByText, getByTestId, store, swapScreen, swapFromContainer } = renderScreen({})
1472
+
1473
+ selectSwapTokens('CELO', 'cUSD', swapScreen)
1474
+ fireEvent.changeText(
1475
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput'),
1476
+ '1'
1477
+ )
1478
+
1479
+ await act(() => {
1480
+ jest.runOnlyPendingTimers()
1481
+ })
1482
+ fireEvent.press(getByText('swapScreen.confirmSwap'))
1483
+
1484
+ fireEvent.press(getByTestId('unfavorable-rate-confirm'))
1485
+
1486
+ expect(store.getActions()).toEqual(
1487
+ expect.arrayContaining([
1488
+ swapStart({
1489
+ swapId: expect.any(String),
1490
+ quote: {
1491
+ preparedTransactions,
1492
+ receivedAt: quoteReceivedTimestamp,
1493
+ price,
1494
+ appFeePercentageIncludedInPrice:
1495
+ quoteCeloToCusd.unvalidatedSwapTransaction.appFeePercentageIncludedInPrice,
1496
+ provider: quoteCeloToCusd.details.swapProvider,
1497
+ estimatedPriceImpact,
1498
+ allowanceTarget: quoteCusdToCelo.unvalidatedSwapTransaction.allowanceTarget,
1499
+ swapType: 'same-chain',
1500
+ },
1501
+ userInput: {
1502
+ toTokenId: mockCusdTokenId,
1503
+ fromTokenId: mockCeloTokenId,
1504
+ swapAmount: {
1505
+ [Field.FROM]: '1',
1506
+ [Field.TO]: price,
1507
+ },
1508
+ updatedField: Field.FROM,
1509
+ },
1510
+ areSwapTokensShuffled: false,
1511
+ }),
1512
+ ])
1513
+ )
1514
+ })
1515
+ })
1516
+
1517
+ it('should show swappable tokens and search box', async () => {
1518
+ const { swapToContainer, swapFromContainer, swapScreen, tokenBottomSheets } = renderScreen({})
1519
+ const tokenBottomSheet = tokenBottomSheets[1] // "to" token selection
1520
+
1521
+ selectSingleSwapToken(swapFromContainer, 'CELO', swapScreen, Field.FROM)
1522
+ fireEvent.press(within(swapToContainer).getByTestId('SwapAmountInput/TokenSelect'))
1523
+
1524
+ expect(
1525
+ within(tokenBottomSheet).getByPlaceholderText('tokenBottomSheet.searchAssets')
1526
+ ).toBeTruthy()
1527
+
1528
+ expect(within(tokenBottomSheet).getByText('Celo Dollar')).toBeTruthy()
1529
+ expect(within(tokenBottomSheet).getByText('Celo Euro')).toBeTruthy()
1530
+ expect(within(tokenBottomSheet).getByText('Celo native asset')).toBeTruthy()
1531
+ expect(within(tokenBottomSheet).getByText('Poof Governance Token')).toBeTruthy()
1532
+ expect(within(tokenBottomSheet).queryByText('Test Token')).toBeFalsy()
1533
+ })
1534
+
1535
+ it('should not show input sections if tokens are not selected', () => {
1536
+ jest.mocked(getExperimentParams).mockReturnValue({
1537
+ swapBuyAmountEnabled: false,
1538
+ })
1539
+ const { swapFromContainer, swapToContainer } = renderScreen({})
1540
+
1541
+ expect(within(swapFromContainer).queryByTestId('SwapAmountInput/TokenAmountInput')).toBeFalsy()
1542
+ expect(within(swapToContainer).queryByTestId('SwapAmountInput/TokenAmountInput')).toBeFalsy()
1543
+ })
1544
+
1545
+ it('should be able to switch tokens by pressing arrow button', async () => {
1546
+ jest.mocked(getExperimentParams).mockReturnValue({
1547
+ swapBuyAmountEnabled: false,
1548
+ })
1549
+ const { swapFromContainer, swapToContainer, swapScreen, getByTestId } = renderScreen({})
1550
+
1551
+ selectSwapTokens('CELO', 'cUSD', swapScreen)
1552
+
1553
+ expect(within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput')).toBeTruthy()
1554
+ expect(within(swapToContainer).getByTestId('SwapAmountInput/TokenAmountInput')).toBeTruthy()
1555
+
1556
+ fireEvent.press(getByTestId('SwapScreen/SwitchTokens'))
1557
+
1558
+ expect(within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput')).toBeTruthy()
1559
+ expect(within(swapToContainer).getByTestId('SwapAmountInput/TokenAmountInput')).toBeTruthy()
1560
+ })
1561
+
1562
+ it('should disable editing of the buy token amount', () => {
1563
+ const { swapFromContainer, swapToContainer, swapScreen } = renderScreen({})
1564
+
1565
+ selectSwapTokens('CELO', 'cUSD', swapScreen)
1566
+
1567
+ expect(
1568
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput').props.editable
1569
+ ).toBe(true)
1570
+ expect(
1571
+ within(swapToContainer).getByTestId('SwapAmountInput/TokenAmountInput').props.editable
1572
+ ).toBe(false)
1573
+ })
1574
+
1575
+ it('should display the correct transaction details', async () => {
1576
+ mockFetch.mockResponse(quoteCeloToCusdResponse)
1577
+ const { getByTestId, swapFromContainer, swapScreen } = renderScreen({
1578
+ celoBalance: '10',
1579
+ cUSDBalance: '10',
1580
+ })
1581
+
1582
+ selectSwapTokens('CELO', 'cUSD', swapScreen)
1583
+ fireEvent.changeText(
1584
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput'),
1585
+ '2'
1586
+ )
1587
+
1588
+ await act(() => {
1589
+ jest.runOnlyPendingTimers()
1590
+ })
1591
+
1592
+ const transactionDetails = getByTestId('SwapTransactionDetails')
1593
+ expect(transactionDetails).toHaveTextContent('swapScreen.transactionDetails.fee', {
1594
+ exact: false,
1595
+ })
1596
+ // matches mocked value (0.015 CELO) provided to estimateFeesPerGas, estimateGas, and gas in defaultQuoteResponse
1597
+ expect(getByTestId('SwapTransactionDetails/Fees')).toHaveTextContent('≈ ₱0.016', {
1598
+ exact: false,
1599
+ })
1600
+ expect(transactionDetails).toHaveTextContent(
1601
+ 'swapScreen.transactionDetails.slippagePercentage',
1602
+ { exact: false }
1603
+ )
1604
+ expect(getByTestId('SwapTransactionDetails/Slippage')).toHaveTextContent('0.3%', {
1605
+ exact: false,
1606
+ })
1607
+ })
1608
+
1609
+ it('should disable the confirm button after a swap has been submitted', async () => {
1610
+ mockFetch.mockResponse(quoteCusdToCeloResponse)
1611
+ const { update, getByText, getByTestId, swapScreen, store } = renderScreen({})
1612
+
1613
+ selectSwapTokens('CELO', 'cUSD', swapScreen)
1614
+ await selectMaxFromAmount(swapScreen)
1615
+
1616
+ await act(() => {
1617
+ jest.runOnlyPendingTimers()
1618
+ })
1619
+
1620
+ expect(getByText('swapScreen.confirmSwap')).not.toBeDisabled()
1621
+ fireEvent.press(getByText('swapScreen.confirmSwap'))
1622
+
1623
+ const swapAction = store.getActions().find((action) => action.type === swapStart.type)
1624
+ const swapId = swapAction.payload.swapId
1625
+ expect(swapId).toBeTruthy()
1626
+
1627
+ // Simulate swap in progress
1628
+ const state = store.getState()
1629
+ const updatedStore = createMockStore({
1630
+ ...state,
1631
+ swap: {
1632
+ ...state.swap,
1633
+ currentSwap: {
1634
+ id: swapId,
1635
+ status: 'started',
1636
+ },
1637
+ },
1638
+
1639
+ // as per test/utils.ts, line 105
1640
+ transactionFeedV2Api: undefined,
1641
+ })
1642
+
1643
+ update(
1644
+ <Provider store={updatedStore}>
1645
+ <MockedNavigator component={SwapScreenV2} />
1646
+ </Provider>
1647
+ )
1648
+
1649
+ // Using testID because the button is in loading state, not showing the text
1650
+ expect(getByTestId('ConfirmSwapButton')).toBeDisabled()
1651
+ })
1652
+
1653
+ it('should show and hide the error warning', async () => {
1654
+ mockFetch.mockResponse(quoteCusdToCeloResponse)
1655
+ const { update, getByText, queryByText, swapFromContainer, swapScreen, store } = renderScreen(
1656
+ {}
1657
+ )
1658
+
1659
+ selectSwapTokens('CELO', 'cUSD', swapScreen)
1660
+ await selectMaxFromAmount(swapScreen)
1661
+
1662
+ await act(() => {
1663
+ jest.runOnlyPendingTimers()
1664
+ })
1665
+
1666
+ expect(getByText('swapScreen.confirmSwap')).not.toBeDisabled()
1667
+ fireEvent.press(getByText('swapScreen.confirmSwap'))
1668
+
1669
+ const swapAction = store.getActions().find((action) => action.type === swapStart.type)
1670
+ const swapId = swapAction.payload.swapId
1671
+ expect(swapId).toBeTruthy()
1672
+
1673
+ expect(queryByText('swapScreen.confirmSwapFailedWarning.title')).toBeFalsy()
1674
+ expect(queryByText('swapScreen.confirmSwapFailedWarning.body')).toBeFalsy()
1675
+
1676
+ // Simulate swap error
1677
+ const state = store.getState()
1678
+ const updatedStore = createMockStore({
1679
+ ...state,
1680
+ swap: {
1681
+ ...state.swap,
1682
+ currentSwap: {
1683
+ id: swapId,
1684
+ status: 'error',
1685
+ },
1686
+ },
1687
+
1688
+ // as per test/utils.ts, line 105
1689
+ transactionFeedV2Api: undefined,
1690
+ })
1691
+
1692
+ update(
1693
+ <Provider store={updatedStore}>
1694
+ <MockedNavigator component={SwapScreenV2} />
1695
+ </Provider>
1696
+ )
1697
+
1698
+ expect(getByText('swapScreen.confirmSwapFailedWarning.title')).toBeTruthy()
1699
+ expect(getByText('swapScreen.confirmSwapFailedWarning.body')).toBeTruthy()
1700
+ // NOT disabled, so users can retry
1701
+ expect(getByText('swapScreen.confirmSwap')).not.toBeDisabled()
1702
+
1703
+ // Now change some input, and the warning should disappear
1704
+ fireEvent.changeText(
1705
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput'),
1706
+ '2'
1707
+ )
1708
+
1709
+ expect(queryByText('swapScreen.confirmSwapFailedWarning.title')).toBeFalsy()
1710
+ expect(queryByText('swapScreen.confirmSwapFailedWarning.body')).toBeFalsy()
1711
+ })
1712
+
1713
+ it('should show and hide the switched network warning if cross chain swaps disabled', async () => {
1714
+ mockFetch.mockResponse(quoteCusdToCeloResponse)
1715
+ jest.mocked(getFeatureGate).mockImplementation(() => false)
1716
+ const {
1717
+ getByText,
1718
+ getByTestId,
1719
+ queryByTestId,
1720
+ swapToContainer,
1721
+ swapFromContainer,
1722
+ swapScreen,
1723
+ } = renderScreen({ cUSDBalance: '0' })
1724
+
1725
+ // First get a quote for a network
1726
+ selectSwapTokens('CELO', 'cUSD', swapScreen)
1727
+ await selectMaxFromAmount(swapScreen)
1728
+
1729
+ await act(() => {
1730
+ jest.runOnlyPendingTimers()
1731
+ })
1732
+
1733
+ expect(getByTestId('SwapTransactionDetails/ExchangeRate')).toHaveTextContent(
1734
+ '1 CELO ≈ 1.23456 cUSD',
1735
+ { exact: false }
1736
+ )
1737
+ expect(queryByTestId('SwitchedToNetworkWarning')).toBeFalsy()
1738
+ expect(getByTestId('MaxSwapAmountWarning')).toBeTruthy()
1739
+
1740
+ // Now select a "to" token from a different network, the warning should appear
1741
+ selectSingleSwapToken(swapToContainer, 'USDC', swapScreen, Field.TO)
1742
+
1743
+ expect(
1744
+ getByText('swapScreen.switchedToNetworkWarning.title, {"networkName":"Ethereum Sepolia"}')
1745
+ ).toBeTruthy()
1746
+ expect(
1747
+ getByText(
1748
+ 'swapScreen.switchedToNetworkWarning.body, {"networkName":"Ethereum Sepolia","context":"swapFrom"}'
1749
+ )
1750
+ ).toBeTruthy()
1751
+
1752
+ // Make sure the max warning is not shown
1753
+ expect(queryByTestId('MaxSwapAmountWarning')).toBeFalsy()
1754
+
1755
+ // Check the quote is cleared
1756
+ expect(queryByTestId('SwapTransactionDetails/ExchangeRate')).toBeFalsy()
1757
+
1758
+ // Disabled, until the user selects a token from the same network
1759
+ expect(getByText('swapScreen.confirmSwap')).toBeDisabled()
1760
+
1761
+ // Now select a "from" token from the same network, the warning should disappear
1762
+ selectSingleSwapToken(swapFromContainer, 'ETH', swapScreen, Field.FROM)
1763
+
1764
+ expect(queryByTestId('SwitchedToNetworkWarning')).toBeFalsy()
1765
+ // Max warning is shown again, because both ETH and CELO have the same balance
1766
+ // and we previously selected the max value for CELO
1767
+ expect(queryByTestId('MaxSwapAmountWarning')).toBeTruthy()
1768
+
1769
+ // Now select a "from" token from a different network again, the warning should reappear
1770
+ selectSingleSwapToken(swapFromContainer, 'cUSD', swapScreen, Field.FROM)
1771
+
1772
+ expect(
1773
+ getByText('swapScreen.switchedToNetworkWarning.title, {"networkName":"Celo Alfajores"}')
1774
+ ).toBeTruthy()
1775
+ expect(
1776
+ getByText(
1777
+ 'swapScreen.switchedToNetworkWarning.body, {"networkName":"Celo Alfajores","context":"swapTo"}'
1778
+ )
1779
+ ).toBeTruthy()
1780
+ })
1781
+
1782
+ it("should warn when the balances for feeCurrencies are 0 and can't cover the fee", async () => {
1783
+ // Swap from POOF to CELO, when no feeCurrency has any balance
1784
+ mockFetch.mockResponse(quoteCusdToCeloResponse)
1785
+ const { getByText, swapScreen } = renderScreen({
1786
+ celoBalance: '0',
1787
+ cUSDBalance: '0',
1788
+ })
1789
+
1790
+ selectSwapTokens('POOF', 'CELO', swapScreen)
1791
+ await selectMaxFromAmount(swapScreen)
1792
+
1793
+ await act(() => {
1794
+ jest.runOnlyPendingTimers()
1795
+ })
1796
+
1797
+ expect(getByText('swapScreen.confirmSwap')).toBeDisabled()
1798
+
1799
+ expect(
1800
+ getByText(
1801
+ 'swapScreen.notEnoughBalanceForGas.description, {"feeCurrencies":"CELO, cEUR, cUSD"}'
1802
+ )
1803
+ ).toBeTruthy()
1804
+ })
1805
+
1806
+ it('should warn when the balances for feeCurrencies are too low to cover the fee', async () => {
1807
+ // Swap from POOF to CELO, when no feeCurrency has any balance
1808
+ mockFetch.mockResponse(quoteCusdToCeloResponse)
1809
+ const { getByText, swapScreen } = renderScreen({
1810
+ celoBalance: '0.001',
1811
+ cUSDBalance: '0.001',
1812
+ })
1813
+
1814
+ selectSwapTokens('POOF', 'CELO', swapScreen)
1815
+ await selectMaxFromAmount(swapScreen)
1816
+
1817
+ await act(() => {
1818
+ jest.runOnlyPendingTimers()
1819
+ })
1820
+
1821
+ expect(getByText('swapScreen.confirmSwap')).toBeDisabled()
1822
+
1823
+ expect(
1824
+ getByText(
1825
+ 'swapScreen.notEnoughBalanceForGas.description, {"feeCurrencies":"CELO, cUSD, cEUR"} '
1826
+ )
1827
+ ).toBeTruthy()
1828
+ })
1829
+
1830
+ it('should prompt the user to decrease the swap amount when swapping the max amount of a feeCurrency, and no other feeCurrency has enough balance to pay for the fee', async () => {
1831
+ // Swap CELO to cUSD, when only CELO has balance
1832
+ mockFetch.mockResponse(quoteCusdToCeloResponse)
1833
+ const { getByText, queryByText, swapScreen, swapFromContainer } = renderScreen({
1834
+ celoBalance: '1.234',
1835
+ cUSDBalance: '0',
1836
+ })
1837
+
1838
+ selectSwapTokens('CELO', 'cUSD', swapScreen)
1839
+ await selectMaxFromAmount(swapScreen)
1840
+
1841
+ await act(() => {
1842
+ jest.runOnlyPendingTimers()
1843
+ })
1844
+
1845
+ expect(
1846
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput').props.value
1847
+ ).toBe(
1848
+ '1.234' // matching the value inside the mocked store
1849
+ )
1850
+
1851
+ expect(getByText('swapScreen.confirmSwap')).toBeDisabled()
1852
+
1853
+ const confirmDecrease = getByText('swapScreen.decreaseSwapAmountForGasWarning.cta')
1854
+ expect(confirmDecrease).toBeTruthy()
1855
+
1856
+ // Mock next call with the decreased amount
1857
+ mockFetch.mockResponse(
1858
+ JSON.stringify({
1859
+ ...quoteCusdToCelo,
1860
+ unvalidatedSwapTransaction: {
1861
+ ...quoteCusdToCelo.unvalidatedSwapTransaction,
1862
+ sellAmount: '1207057600000000000',
1863
+ },
1864
+ })
1865
+ )
1866
+
1867
+ // Now, decrease the swap amount
1868
+ fireEvent.press(confirmDecrease)
1869
+
1870
+ expect(
1871
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput').props.value
1872
+ ).toBe(
1873
+ '1.2077776' // 1.234 minus the max fee calculated for the swap
1874
+ )
1875
+
1876
+ await act(() => {
1877
+ jest.runOnlyPendingTimers()
1878
+ })
1879
+
1880
+ expect(queryByText('swapScreen.decreaseSwapAmountForGasWarning.cta')).toBeFalsy()
1881
+ })
1882
+
1883
+ it('should prompt the user to decrease the swap amount when swapping close to the max amount of a feeCurrency, and no other feeCurrency has enough balance to pay for the fee', async () => {
1884
+ // Swap CELO to cUSD, when only CELO has balance
1885
+ mockFetch.mockResponse(
1886
+ JSON.stringify({
1887
+ ...quoteCusdToCelo,
1888
+ unvalidatedSwapTransaction: {
1889
+ ...quoteCusdToCelo.unvalidatedSwapTransaction,
1890
+ sellAmount: '1233000000000000000', // 1.233
1891
+ },
1892
+ })
1893
+ )
1894
+ const { getByText, queryByText, swapScreen, swapFromContainer } = renderScreen({
1895
+ celoBalance: '1.234',
1896
+ cUSDBalance: '0',
1897
+ })
1898
+
1899
+ selectSwapTokens('CELO', 'cUSD', swapScreen)
1900
+ fireEvent.changeText(
1901
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput'),
1902
+ '1.233'
1903
+ )
1904
+
1905
+ await act(() => {
1906
+ jest.runOnlyPendingTimers()
1907
+ })
1908
+
1909
+ expect(getByText('swapScreen.confirmSwap')).toBeDisabled()
1910
+
1911
+ const confirmDecrease = getByText('swapScreen.decreaseSwapAmountForGasWarning.cta')
1912
+ expect(confirmDecrease).toBeTruthy()
1913
+
1914
+ // Mock next call with the decreased amount
1915
+ mockFetch.mockResponse(
1916
+ JSON.stringify({
1917
+ ...quoteCusdToCelo,
1918
+ unvalidatedSwapTransaction: {
1919
+ ...quoteCusdToCelo.unvalidatedSwapTransaction,
1920
+ sellAmount: '1207057600000000000',
1921
+ },
1922
+ })
1923
+ )
1924
+
1925
+ // Now, decrease the swap amount
1926
+ fireEvent.press(confirmDecrease)
1927
+
1928
+ expect(
1929
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput').props.value
1930
+ ).toBe(
1931
+ '1.2077776' // 1.234 (max balance) minus the max fee calculated for the swap
1932
+ )
1933
+
1934
+ await act(() => {
1935
+ jest.runOnlyPendingTimers()
1936
+ })
1937
+
1938
+ expect(queryByText('swapScreen.decreaseSwapAmountForGasWarning.cta')).toBeFalsy()
1939
+ })
1940
+
1941
+ it("should allow swapping the entered amount of a feeCurrency when there's enough balance to cover for the fee, while no other feeCurrency can pay for the fee", async () => {
1942
+ // Swap CELO to cUSD, when only CELO has balance
1943
+ mockFetch.mockResponse(
1944
+ JSON.stringify({
1945
+ ...quoteCusdToCelo,
1946
+ unvalidatedSwapTransaction: {
1947
+ ...quoteCusdToCelo.unvalidatedSwapTransaction,
1948
+ sellAmount: '1000000000000000000', // 1
1949
+ },
1950
+ })
1951
+ )
1952
+ const { getByText, queryByTestId, swapFromContainer, swapScreen } = renderScreen({
1953
+ celoBalance: '1.234',
1954
+ cUSDBalance: '0',
1955
+ })
1956
+
1957
+ selectSwapTokens('CELO', 'cUSD', swapScreen)
1958
+ fireEvent.changeText(
1959
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput'),
1960
+ '1'
1961
+ )
1962
+
1963
+ await act(() => {
1964
+ jest.runOnlyPendingTimers()
1965
+ })
1966
+
1967
+ expect(getByText('swapScreen.confirmSwap')).not.toBeDisabled()
1968
+ fireEvent.press(getByText('swapScreen.confirmSwap'))
1969
+
1970
+ expect(queryByTestId('QuoteResultNotEnoughBalanceForGasBottomSheet')).toBeFalsy()
1971
+ expect(queryByTestId('QuoteResultNeedDecreaseSwapAmountForGasBottomSheet')).toBeFalsy()
1972
+ })
1973
+
1974
+ it("should allow swapping the max balance of a feeCurrency when there's another feeCurrency to pay for the fee", async () => {
1975
+ // Swap full CELO balance to cUSD
1976
+ mockFetch.mockResponse(quoteCusdToCeloResponse)
1977
+ const { getByText, queryByTestId, swapScreen, swapFromContainer } = renderScreen({
1978
+ celoBalance: '1.234',
1979
+ cUSDBalance: '10',
1980
+ })
1981
+
1982
+ selectSwapTokens('CELO', 'cUSD', swapScreen)
1983
+ await selectMaxFromAmount(swapScreen)
1984
+
1985
+ await act(() => {
1986
+ jest.runOnlyPendingTimers()
1987
+ })
1988
+
1989
+ expect(
1990
+ within(swapFromContainer).getByTestId('SwapAmountInput/TokenAmountInput').props.value
1991
+ ).toBe(
1992
+ '1.234' // matching the value inside the mocked store
1993
+ )
1994
+
1995
+ expect(getByText('swapScreen.confirmSwap')).not.toBeDisabled()
1996
+ fireEvent.press(getByText('swapScreen.confirmSwap'))
1997
+
1998
+ expect(queryByTestId('QuoteResultNotEnoughBalanceForGasBottomSheet')).toBeFalsy()
1999
+ expect(queryByTestId('QuoteResultNeedDecreaseSwapAmountForGasBottomSheet')).toBeFalsy()
2000
+ })
2001
+
2002
+ describe('filter tokens', () => {
2003
+ beforeEach(() => {
2004
+ jest
2005
+ .mocked(getFeatureGate)
2006
+ .mockImplementation((gate) => gate === StatsigFeatureGates.SHOW_SWAP_TOKEN_FILTERS)
2007
+ })
2008
+
2009
+ const expectedAllFromTokens = Object.values(mockStoreTokenBalances).filter(
2010
+ (token) => token.isSwappable !== false || token.balance !== '0' // include unswappable tokens with balance because it is the "from" token
2011
+ )
2012
+ const expectedAllToTokens = Object.values(mockStoreTokenBalances).filter(
2013
+ (token) => token.isSwappable !== false
2014
+ )
2015
+
2016
+ it('should show "my tokens" for the "from" token selection by default', () => {
2017
+ const mockedZeroBalanceTokens = [mockCeurTokenId, mockCusdTokenId, mockPoofTokenId]
2018
+ const expectedTokensWithBalance = expectedAllFromTokens.filter(
2019
+ (token) => !mockedZeroBalanceTokens.includes(token.tokenId)
2020
+ )
2021
+
2022
+ const { swapFromContainer, tokenBottomSheets } = renderScreen({
2023
+ cUSDBalance: '0',
2024
+ poofBalance: '0', // cEUR also has 0 balance in the global mock
2025
+ })
2026
+ const tokenBottomSheet = tokenBottomSheets[0] // "from" token selection
2027
+
2028
+ fireEvent.press(within(swapFromContainer).getByTestId('SwapAmountInput/TokenSelect'))
2029
+
2030
+ expectedTokensWithBalance.forEach((token) => {
2031
+ expect(within(tokenBottomSheet).getByText(token.name)).toBeTruthy()
2032
+ })
2033
+ const displayedTokens = within(tokenBottomSheet).getAllByTestId('TokenBalanceItem')
2034
+ expect(displayedTokens.length).toBe(expectedTokensWithBalance.length)
2035
+
2036
+ // deselect pre-selected filters to show all tokens
2037
+ fireEvent.press(within(tokenBottomSheet).getByText('tokenBottomSheet.filters.myTokens'))
2038
+
2039
+ expectedAllFromTokens.forEach((token) => {
2040
+ expect(within(tokenBottomSheet).getByText(token.name)).toBeTruthy()
2041
+ })
2042
+ })
2043
+
2044
+ it('should show "recently swapped" tokens', () => {
2045
+ const mockedLastSwapped = [mockCeurTokenId, mockCusdTokenId, mockPoofTokenId]
2046
+ const expectedLastSwapTokens = expectedAllFromTokens.filter((token) =>
2047
+ mockedLastSwapped.includes(token.tokenId)
2048
+ )
2049
+
2050
+ const { swapFromContainer, tokenBottomSheets } = renderScreen({
2051
+ lastSwapped: mockedLastSwapped,
2052
+ })
2053
+ const tokenBottomSheet = tokenBottomSheets[0] // "from" token selection
2054
+
2055
+ fireEvent.press(within(swapFromContainer).getByTestId('SwapAmountInput/TokenSelect'))
2056
+ // deselect pre-selected filters to show all tokens
2057
+ fireEvent.press(within(tokenBottomSheet).getByText('tokenBottomSheet.filters.myTokens'))
2058
+ // select last swapped filter
2059
+ fireEvent.press(
2060
+ within(tokenBottomSheet).getByText('tokenBottomSheet.filters.recentlySwapped')
2061
+ )
2062
+
2063
+ expectedLastSwapTokens.forEach((token) => {
2064
+ expect(within(tokenBottomSheet).getByText(token.name)).toBeTruthy()
2065
+ })
2066
+ const displayedTokens = within(tokenBottomSheet).getAllByTestId('TokenBalanceItem')
2067
+ expect(displayedTokens.length).toBe(expectedLastSwapTokens.length)
2068
+
2069
+ // de-select last swapped filter
2070
+ fireEvent.press(
2071
+ within(tokenBottomSheet).getByText('tokenBottomSheet.filters.recentlySwapped')
2072
+ )
2073
+
2074
+ expectedAllFromTokens.forEach((token) => {
2075
+ expect(within(tokenBottomSheet).getByText(token.name)).toBeTruthy()
2076
+ })
2077
+ })
2078
+
2079
+ it('should show "popular" tokens', () => {
2080
+ const mockedPopularTokens = [mockUSDCTokenId, mockPoofTokenId]
2081
+ jest.mocked(getDynamicConfigParams).mockReturnValue({
2082
+ popularTokenIds: mockedPopularTokens,
2083
+ maxSlippagePercentage: '0.3',
2084
+ })
2085
+ const expectedPopularTokens = expectedAllFromTokens.filter((token) =>
2086
+ mockedPopularTokens.includes(token.tokenId)
2087
+ )
2088
+
2089
+ const { swapFromContainer, tokenBottomSheets } = renderScreen({})
2090
+ const tokenBottomSheet = tokenBottomSheets[0] // "from" token selection
2091
+
2092
+ fireEvent.press(within(swapFromContainer).getByTestId('SwapAmountInput/TokenSelect'))
2093
+ // deselect pre-selected filters to show all tokens
2094
+ fireEvent.press(within(tokenBottomSheet).getByText('tokenBottomSheet.filters.myTokens'))
2095
+ // select popular filter
2096
+ fireEvent.press(within(tokenBottomSheet).getByText('tokenBottomSheet.filters.popular'))
2097
+
2098
+ expectedPopularTokens.forEach((token) => {
2099
+ expect(within(tokenBottomSheet).getByText(token.name)).toBeTruthy()
2100
+ })
2101
+ const displayedTokens = within(tokenBottomSheet).getAllByTestId('TokenBalanceItem')
2102
+ expect(displayedTokens.length).toBe(expectedPopularTokens.length)
2103
+
2104
+ // de-select filter
2105
+ fireEvent.press(within(tokenBottomSheet).getByText('tokenBottomSheet.filters.popular'))
2106
+
2107
+ expectedAllFromTokens.forEach((token) => {
2108
+ expect(within(tokenBottomSheet).getByText(token.name)).toBeTruthy()
2109
+ })
2110
+ })
2111
+
2112
+ it('should show the network filters when there are multiple supported networks', () => {
2113
+ const expectedEthTokens = expectedAllFromTokens.filter(
2114
+ (token) => token.networkId === NetworkId['ethereum-sepolia']
2115
+ )
2116
+ const expectedCeloTokens = expectedAllFromTokens.filter(
2117
+ (token) => token.networkId === NetworkId['celo-alfajores']
2118
+ )
2119
+
2120
+ const { swapFromContainer, tokenBottomSheets, getAllByTestId } = renderScreen({})
2121
+ const tokenBottomSheet = tokenBottomSheets[0] // "from" token selection
2122
+ const networkMultiSelect = getAllByTestId('MultiSelectBottomSheet')[0]
2123
+
2124
+ fireEvent.press(within(swapFromContainer).getByTestId('SwapAmountInput/TokenSelect'))
2125
+ // deselect pre-selected filters to show all tokens
2126
+ fireEvent.press(within(tokenBottomSheet).getByText('tokenBottomSheet.filters.myTokens'))
2127
+
2128
+ // open network bottom sheet
2129
+ fireEvent.press(within(tokenBottomSheet).getByText('tokenBottomSheet.filters.selectNetwork'))
2130
+
2131
+ // select celo filter
2132
+ fireEvent.press(within(networkMultiSelect).getByTestId('Celo Alfajores-icon'))
2133
+
2134
+ expectedCeloTokens.forEach((token) => {
2135
+ expect(within(tokenBottomSheet).getByText(token.name)).toBeTruthy()
2136
+ })
2137
+ expect(within(tokenBottomSheet).getAllByTestId('TokenBalanceItem').length).toBe(
2138
+ expectedCeloTokens.length
2139
+ )
2140
+
2141
+ // select eth filter
2142
+ fireEvent.press(within(networkMultiSelect).getByTestId('Ethereum Sepolia-icon'))
2143
+
2144
+ expectedEthTokens.forEach((token) => {
2145
+ expect(within(tokenBottomSheet).getByText(token.name)).toBeTruthy()
2146
+ })
2147
+ expect(within(tokenBottomSheet).getAllByTestId('TokenBalanceItem').length).toBe(
2148
+ expectedEthTokens.length
2149
+ )
2150
+
2151
+ // select all networks
2152
+ fireEvent.press(within(networkMultiSelect).getByText('multiSelect.allNetworks'))
2153
+
2154
+ expectedCeloTokens.forEach((token) => {
2155
+ expect(within(tokenBottomSheet).getByText(token.name)).toBeTruthy()
2156
+ })
2157
+ expectedEthTokens.forEach((token) => {
2158
+ expect(within(tokenBottomSheet).getByText(token.name)).toBeTruthy()
2159
+ })
2160
+ })
2161
+
2162
+ it('should show pre-selected network filter from route params', async () => {
2163
+ const expectedCeloTokens = expectedAllToTokens.filter(
2164
+ (token) => token.networkId === NetworkId['celo-alfajores']
2165
+ )
2166
+ const { tokenBottomSheets } = renderScreen({
2167
+ toTokenNetworkId: NetworkId['celo-alfajores'],
2168
+ })
2169
+ const tokenBottomSheet = tokenBottomSheets[1] // "to" token selection
2170
+
2171
+ const filteredTokens = within(tokenBottomSheet).getAllByTestId('TokenBalanceItem')
2172
+
2173
+ // only the celo network tokens are displayed
2174
+ expect(filteredTokens.length).toBe(expectedCeloTokens.length)
2175
+ expectedCeloTokens.forEach((token) => {
2176
+ expect(within(tokenBottomSheet).getByText(token.name)).toBeTruthy()
2177
+ })
2178
+ })
2179
+ })
2180
+ })