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.
- package/README.md +86 -0
- package/app.plugin.js +1 -0
- package/locales/base/translation.json +2998 -0
- package/locales/de/translation.json +2998 -0
- package/locales/en-US/translation.json +2998 -0
- package/locales/es-419/translation.json +2998 -0
- package/locales/fr-FR/translation.json +2998 -0
- package/locales/index.ts +163 -0
- package/locales/it-IT/translation.json +2998 -0
- package/locales/pl-PL/translation.json +3004 -0
- package/locales/pt-BR/translation.json +2998 -0
- package/locales/ru-RU/translation.json +3004 -0
- package/locales/th-TH/translation.json +2995 -0
- package/locales/tr-TR/translation.json +2998 -0
- package/locales/uk-UA/translation.json +3004 -0
- package/locales/vi-VN/translation.json +2995 -0
- package/locales/zh-CN/translation.json +2995 -0
- package/metro-config.js +40 -0
- package/package.json +227 -0
- package/plugin/build/consts.d.ts +2 -0
- package/plugin/build/consts.js +6 -0
- package/plugin/build/index.d.ts +8 -0
- package/plugin/build/index.js +21 -0
- package/plugin/build/withAndroidUserAgent.d.ts +8 -0
- package/plugin/build/withAndroidUserAgent.js +86 -0
- package/plugin/build/withAndroidWindowSoftInputModeAdjustNothing.d.ts +6 -0
- package/plugin/build/withAndroidWindowSoftInputModeAdjustNothing.js +16 -0
- package/plugin/build/withIosAppDelegateResetKeychain.d.ts +2 -0
- package/plugin/build/withIosAppDelegateResetKeychain.js +77 -0
- package/plugin/build/withIosUserAgent.d.ts +8 -0
- package/plugin/build/withIosUserAgent.js +56 -0
- package/plugin/tsconfig.json +13 -0
- package/src/RevokePhoneNumber.tsx +117 -0
- package/src/abis/IWalletJumpstart.ts +472 -0
- package/src/account/AccountErrorScreen.test.tsx +47 -0
- package/src/account/AccountErrorScreen.tsx +72 -0
- package/src/account/AccountKeyEducation.test.tsx +20 -0
- package/src/account/AccountKeyEducation.tsx +83 -0
- package/src/account/AccountSetupFailureScreen.test.tsx +59 -0
- package/src/account/AccountSetupFailureScreen.tsx +42 -0
- package/src/account/Education.test.tsx +48 -0
- package/src/account/Education.tsx +235 -0
- package/src/account/GoldEducation.test.tsx +35 -0
- package/src/account/GoldEducation.tsx +82 -0
- package/src/account/LegalSubmenu.test.tsx +84 -0
- package/src/account/LegalSubmenu.tsx +74 -0
- package/src/account/LicenseDisclaimer.txt +15310 -0
- package/src/account/Licenses.test.tsx +17 -0
- package/src/account/Licenses.tsx +43 -0
- package/src/account/PreferencesSubmenu.test.tsx +66 -0
- package/src/account/PreferencesSubmenu.tsx +87 -0
- package/src/account/PrivateKey.test.tsx +241 -0
- package/src/account/PrivateKey.tsx +169 -0
- package/src/account/Profile.test.tsx +77 -0
- package/src/account/Profile.tsx +153 -0
- package/src/account/ProfileSubmenu.test.tsx +105 -0
- package/src/account/ProfileSubmenu.tsx +89 -0
- package/src/account/SecuritySubmenu.test.tsx +305 -0
- package/src/account/SecuritySubmenu.tsx +435 -0
- package/src/account/ShakeForSupport.test.tsx +23 -0
- package/src/account/ShakeForSupport.tsx +112 -0
- package/src/account/StoreWipeRecoveryScreen.test.tsx +39 -0
- package/src/account/StoreWipeRecoveryScreen.tsx +50 -0
- package/src/account/Support.test.tsx +67 -0
- package/src/account/Support.tsx +69 -0
- package/src/account/SupportContact.test.tsx +95 -0
- package/src/account/SupportContact.tsx +265 -0
- package/src/account/__snapshots__/AccountKeyEducation.test.tsx.snap +579 -0
- package/src/account/__snapshots__/Education.test.tsx.snap +286 -0
- package/src/account/__snapshots__/GoldEducation.test.tsx.snap +579 -0
- package/src/account/__snapshots__/Licenses.test.tsx.snap +33 -0
- package/src/account/__snapshots__/ShakeForSupport.test.tsx.snap +3 -0
- package/src/account/actions.ts +270 -0
- package/src/account/reducer.test.ts +28 -0
- package/src/account/reducer.ts +296 -0
- package/src/account/saga.test.ts +209 -0
- package/src/account/saga.ts +249 -0
- package/src/account/selectors.test.ts +18 -0
- package/src/account/selectors.ts +60 -0
- package/src/account/updateAccountRegistration.ts +35 -0
- package/src/account/utils.ts +36 -0
- package/src/account/zendesk.test.ts +166 -0
- package/src/account/zendesk.ts +199 -0
- package/src/alert/AlertBanner.test.tsx +123 -0
- package/src/alert/AlertBanner.tsx +84 -0
- package/src/alert/actions.ts +127 -0
- package/src/alert/reducer.ts +52 -0
- package/src/analytics/AppAnalytics.test.ts +334 -0
- package/src/analytics/AppAnalytics.ts +369 -0
- package/src/analytics/AsyncStoragePersistor.ts +34 -0
- package/src/analytics/Events.test.tsx +49 -0
- package/src/analytics/Events.tsx +648 -0
- package/src/analytics/InjectTraits.ts +34 -0
- package/src/analytics/Properties.tsx +1645 -0
- package/src/analytics/README.md +24 -0
- package/src/analytics/docs.ts +675 -0
- package/src/analytics/saga.test.ts +57 -0
- package/src/analytics/saga.ts +21 -0
- package/src/analytics/selectors.test.ts +391 -0
- package/src/analytics/selectors.ts +200 -0
- package/src/analytics/types.ts +46 -0
- package/src/app/App.test.tsx +25 -0
- package/src/app/App.tsx +124 -0
- package/src/app/AppInitGate.test.tsx +100 -0
- package/src/app/AppInitGate.tsx +77 -0
- package/src/app/AppLoading.test.tsx +11 -0
- package/src/app/AppLoading.tsx +79 -0
- package/src/app/DebugImages.tsx +110 -0
- package/src/app/ErrorBoundary.test.tsx +19 -0
- package/src/app/ErrorBoundary.tsx +41 -0
- package/src/app/ErrorMessages.ts +40 -0
- package/src/app/ErrorScreen.test.tsx +26 -0
- package/src/app/ErrorScreen.tsx +57 -0
- package/src/app/SanctionedCountryErrorScreen.tsx +37 -0
- package/src/app/UpgradeScreen.tsx +28 -0
- package/src/app/__snapshots__/AppLoading.test.tsx.snap +35 -0
- package/src/app/__snapshots__/ErrorScreen.test.tsx.snap +365 -0
- package/src/app/actions.ts +301 -0
- package/src/app/crowd_mobile.png +0 -0
- package/src/app/reducers.ts +204 -0
- package/src/app/saga.test.ts +651 -0
- package/src/app/saga.ts +367 -0
- package/src/app/selectors.ts +53 -0
- package/src/app/useDeepLinks.test.tsx +43 -0
- package/src/app/useDeepLinks.ts +72 -0
- package/src/app/utils.ts +14 -0
- package/src/appConfig.test.ts +37 -0
- package/src/appConfig.ts +20 -0
- package/src/backup/BackupComplete.test.tsx +61 -0
- package/src/backup/BackupComplete.tsx +69 -0
- package/src/backup/BackupIntroduction.test.tsx +37 -0
- package/src/backup/BackupIntroduction.tsx +157 -0
- package/src/backup/BackupPhrase.test.tsx +71 -0
- package/src/backup/BackupPhrase.tsx +208 -0
- package/src/backup/BackupPhraseContainer.test.tsx +43 -0
- package/src/backup/BackupPhraseContainer.tsx +207 -0
- package/src/backup/BackupQuiz.test.tsx +130 -0
- package/src/backup/BackupQuiz.tsx +429 -0
- package/src/backup/CancelConfirm.tsx +60 -0
- package/src/backup/QuizzBottom.tsx +57 -0
- package/src/backup/__snapshots__/BackupComplete.test.tsx.snap +58 -0
- package/src/backup/__snapshots__/BackupPhrase.test.tsx.snap +906 -0
- package/src/backup/__snapshots__/BackupPhraseContainer.test.tsx.snap +719 -0
- package/src/backup/__snapshots__/BackupQuiz.test.tsx.snap +1313 -0
- package/src/backup/utils.test.ts +91 -0
- package/src/backup/utils.ts +103 -0
- package/src/celoNews/CeloNewsFeed.test.tsx +157 -0
- package/src/celoNews/CeloNewsFeed.tsx +161 -0
- package/src/celoNews/CeloNewsFeedItem.test.tsx +46 -0
- package/src/celoNews/CeloNewsFeedItem.tsx +104 -0
- package/src/celoNews/types.ts +14 -0
- package/src/components/AccountNumber.test.tsx +25 -0
- package/src/components/AccountNumber.tsx +78 -0
- package/src/components/AccountNumberCard.tsx +23 -0
- package/src/components/Avatar.test.tsx +67 -0
- package/src/components/Avatar.tsx +72 -0
- package/src/components/BackButton.tsx +44 -0
- package/src/components/BeatingHeartLoader.tsx +39 -0
- package/src/components/BorderlessButton.tsx +25 -0
- package/src/components/BottomSheet.tsx +84 -0
- package/src/components/BottomSheetBase.tsx +87 -0
- package/src/components/BottomSheetScrollView.tsx +54 -0
- package/src/components/Button.test.tsx +94 -0
- package/src/components/Button.tsx +259 -0
- package/src/components/CallToActionsBar.tsx +68 -0
- package/src/components/CancelButton.test.tsx +11 -0
- package/src/components/CancelButton.tsx +58 -0
- package/src/components/Card.tsx +34 -0
- package/src/components/CircleButton.test.tsx +35 -0
- package/src/components/CircleButton.tsx +64 -0
- package/src/components/ClipboardAwarePasteButton.tsx +65 -0
- package/src/components/CloseButton.tsx +41 -0
- package/src/components/CodeInput.test.tsx +26 -0
- package/src/components/CodeInput.tsx +124 -0
- package/src/components/CodeRow.test.tsx +27 -0
- package/src/components/CodeRow.tsx +163 -0
- package/src/components/ContactCircle.test.tsx +67 -0
- package/src/components/ContactCircle.tsx +133 -0
- package/src/components/ContactCircleSelf.tsx +28 -0
- package/src/components/CurrencyDisplay.tsx +242 -0
- package/src/components/DataFieldWithCopy.tsx +75 -0
- package/src/components/DevSkipButton.tsx +105 -0
- package/src/components/Dialog.test.tsx +14 -0
- package/src/components/Dialog.tsx +124 -0
- package/src/components/Dropdown.tsx +98 -0
- package/src/components/EmptyView.tsx +34 -0
- package/src/components/ErrorMessageInline.tsx +78 -0
- package/src/components/ExchangesBottomSheet.test.tsx +84 -0
- package/src/components/ExchangesBottomSheet.tsx +74 -0
- package/src/components/Expandable.tsx +57 -0
- package/src/components/FeeDrawer.test.tsx +150 -0
- package/src/components/FeeDrawer.tsx +127 -0
- package/src/components/FeeIcon.test.tsx +14 -0
- package/src/components/FeeIcon.tsx +95 -0
- package/src/components/FeeInfoBottomSheet.test.tsx +320 -0
- package/src/components/FeeInfoBottomSheet.tsx +219 -0
- package/src/components/FilterChipsCarousel.tsx +143 -0
- package/src/components/FormField.tsx +23 -0
- package/src/components/FormLabel.tsx +21 -0
- package/src/components/FormTextInput.tsx +16 -0
- package/src/components/FullscreenCTA.test.tsx +58 -0
- package/src/components/FullscreenCTA.tsx +60 -0
- package/src/components/GasFeeWarning.test.tsx +126 -0
- package/src/components/GasFeeWarning.tsx +124 -0
- package/src/components/GradientBlock.tsx +20 -0
- package/src/components/HorizontalLine.tsx +18 -0
- package/src/components/IconWithNetworkBadge.test.tsx +49 -0
- package/src/components/IconWithNetworkBadge.tsx +69 -0
- package/src/components/InLineNotification.test.tsx +74 -0
- package/src/components/InLineNotification.tsx +160 -0
- package/src/components/InfoBottomSheet.test.tsx +55 -0
- package/src/components/InfoBottomSheet.tsx +79 -0
- package/src/components/ItemSeparator.test.tsx +8 -0
- package/src/components/ItemSeparator.tsx +16 -0
- package/src/components/KeyboardAwareScrollView.tsx +104 -0
- package/src/components/KeyboardSpacer.tsx +168 -0
- package/src/components/LabelWithInfo.tsx +57 -0
- package/src/components/LegacyTokenDisplay.test.tsx +282 -0
- package/src/components/LegacyTokenDisplay.tsx +63 -0
- package/src/components/LegacyTokenTotalLineItem.test.tsx +90 -0
- package/src/components/LegacyTokenTotalLineItem.tsx +38 -0
- package/src/components/LineItemRow.tsx +74 -0
- package/src/components/ListItem.test.tsx +19 -0
- package/src/components/ListItem.tsx +44 -0
- package/src/components/MessagingCard.tsx +21 -0
- package/src/components/Modal.tsx +57 -0
- package/src/components/NumberKeypad.test.tsx +21 -0
- package/src/components/NumberKeypad.tsx +102 -0
- package/src/components/NumberTicker.tsx +115 -0
- package/src/components/OnboardingCard.tsx +61 -0
- package/src/components/Pagination.tsx +39 -0
- package/src/components/PercentageIndicator.test.tsx +118 -0
- package/src/components/PercentageIndicator.tsx +75 -0
- package/src/components/PhoneNumberInput.test.tsx +99 -0
- package/src/components/PhoneNumberInput.tsx +132 -0
- package/src/components/PhoneNumberWithFlag.tsx +54 -0
- package/src/components/QrScanButton.test.tsx +21 -0
- package/src/components/QrScanButton.tsx +30 -0
- package/src/components/RecoveryPhraseInput.test.tsx +26 -0
- package/src/components/RecoveryPhraseInput.tsx +188 -0
- package/src/components/ReviewHeader.test.tsx +21 -0
- package/src/components/ReviewHeader.tsx +36 -0
- package/src/components/ReviewTransaction.test.tsx +474 -0
- package/src/components/ReviewTransaction.tsx +526 -0
- package/src/components/RowDivider.tsx +36 -0
- package/src/components/SearchInput.tsx +40 -0
- package/src/components/SectionHead.test.tsx +9 -0
- package/src/components/SectionHead.tsx +33 -0
- package/src/components/SegmentedControl.test.tsx +28 -0
- package/src/components/SegmentedControl.tsx +156 -0
- package/src/components/SelectRecipientButton.tsx +89 -0
- package/src/components/SelectionOption.test.tsx +18 -0
- package/src/components/SelectionOption.tsx +62 -0
- package/src/components/SettingsGearButton.tsx +30 -0
- package/src/components/SettingsItem.test.tsx +80 -0
- package/src/components/SettingsItem.tsx +195 -0
- package/src/components/SimpleMessagingCard.test.tsx +54 -0
- package/src/components/SimpleMessagingCard.tsx +90 -0
- package/src/components/SingleDigitInput.tsx +53 -0
- package/src/components/SkeletonPlaceholder.tsx +33 -0
- package/src/components/SmallButton.test.tsx +41 -0
- package/src/components/SmallButton.tsx +74 -0
- package/src/components/SmartTopAlert.test.tsx +22 -0
- package/src/components/SmartTopAlert.tsx +183 -0
- package/src/components/Switch.tsx +19 -0
- package/src/components/TextButton.tsx +22 -0
- package/src/components/TextInput.tsx +133 -0
- package/src/components/TextInputWithButtons.test.tsx +24 -0
- package/src/components/TextInputWithButtons.tsx +54 -0
- package/src/components/Toast.test.tsx +62 -0
- package/src/components/Toast.tsx +180 -0
- package/src/components/TokenBalance.test.tsx +389 -0
- package/src/components/TokenBalance.tsx +321 -0
- package/src/components/TokenBottomSheet.test.tsx +356 -0
- package/src/components/TokenBottomSheet.tsx +413 -0
- package/src/components/TokenDisplay.test.tsx +274 -0
- package/src/components/TokenDisplay.tsx +104 -0
- package/src/components/TokenEnterAmount.test.tsx +461 -0
- package/src/components/TokenEnterAmount.tsx +591 -0
- package/src/components/TokenIcon.test.tsx +93 -0
- package/src/components/TokenIcon.tsx +142 -0
- package/src/components/TokenTotalLineItem.test.tsx +199 -0
- package/src/components/TokenTotalLineItem.tsx +103 -0
- package/src/components/Touchable.tsx +48 -0
- package/src/components/ValidatedTextInput.tsx +96 -0
- package/src/components/WebView.tsx +43 -0
- package/src/components/WithPasteAware.tsx +113 -0
- package/src/components/WithTextInputPasteAware.tsx +51 -0
- package/src/components/__snapshots__/AccountNumber.test.tsx.snap +87 -0
- package/src/components/__snapshots__/Avatar.test.tsx.snap +435 -0
- package/src/components/__snapshots__/Button.test.tsx.snap +292 -0
- package/src/components/__snapshots__/CircleButton.test.tsx.snap +211 -0
- package/src/components/__snapshots__/CodeRow.test.tsx.snap +211 -0
- package/src/components/__snapshots__/ContactCircle.test.tsx.snap +46 -0
- package/src/components/__snapshots__/Dialog.test.tsx.snap +248 -0
- package/src/components/__snapshots__/FeeIcon.test.tsx.snap +147 -0
- package/src/components/__snapshots__/FullscreenCTA.test.tsx.snap +183 -0
- package/src/components/__snapshots__/ItemSeparator.test.tsx.snap +13 -0
- package/src/components/__snapshots__/NumberKeypad.test.tsx.snap +1434 -0
- package/src/components/__snapshots__/PhoneNumberInput.test.tsx.snap +202 -0
- package/src/components/__snapshots__/SectionHead.test.tsx.snap +32 -0
- package/src/components/__snapshots__/SelectionOption.test.tsx.snap +197 -0
- package/src/components/__snapshots__/SettingsItem.test.tsx.snap +226 -0
- package/src/components/__snapshots__/SmartTopAlert.test.tsx.snap +103 -0
- package/src/components/__snapshots__/TextInputWithButtons.test.tsx.snap +78 -0
- package/src/components/header/CustomHeader.tsx +56 -0
- package/src/components/multiSelect/MultiSelectBottomSheet.test.tsx +175 -0
- package/src/components/multiSelect/MultiSelectBottomSheet.tsx +249 -0
- package/src/components/multiSelect/NetworkMultiSelectBottomSheet.test.tsx +77 -0
- package/src/components/multiSelect/NetworkMultiSelectBottomSheet.tsx +56 -0
- package/src/components/useShowOrHideAnimation.tsx +33 -0
- package/src/config.enc +0 -0
- package/src/config.ts +186 -0
- package/src/dapps/DappShortcutTransactionRequest.test.tsx +187 -0
- package/src/dapps/DappShortcutTransactionRequest.tsx +270 -0
- package/src/dapps/DappShortcutsRewards.test.tsx +292 -0
- package/src/dapps/DappShortcutsRewards.tsx +284 -0
- package/src/dapps/DappsScreen.test.tsx +716 -0
- package/src/dapps/DappsScreen.tsx +365 -0
- package/src/dapps/saga.test.ts +194 -0
- package/src/dapps/saga.ts +136 -0
- package/src/dapps/selectors.test.ts +127 -0
- package/src/dapps/selectors.ts +123 -0
- package/src/dapps/slice.ts +110 -0
- package/src/dapps/types.ts +30 -0
- package/src/dappsExplorer/DappCard.tsx +141 -0
- package/src/dappsExplorer/DappFeaturedActions.test.tsx +72 -0
- package/src/dappsExplorer/DappFeaturedActions.tsx +121 -0
- package/src/dappsExplorer/DiscoverDappsCard.tsx +186 -0
- package/src/dappsExplorer/NoResults.tsx +126 -0
- package/src/dappsExplorer/TabDiscover.test.tsx +397 -0
- package/src/dappsExplorer/TabDiscover.tsx +76 -0
- package/src/dappsExplorer/searchDappList.test.tsx +69 -0
- package/src/dappsExplorer/searchDappList.tsx +113 -0
- package/src/dappsExplorer/useDappFavoritedToast.tsx +56 -0
- package/src/dappsExplorer/useOpenDapp.tsx +31 -0
- package/src/divviProtocol/saga.test.ts +51 -0
- package/src/divviProtocol/saga.ts +44 -0
- package/src/earn/ActionCard.tsx +46 -0
- package/src/earn/EarnDepositConfirmationScreen.test.tsx +603 -0
- package/src/earn/EarnDepositConfirmationScreen.tsx +596 -0
- package/src/earn/EarnEnterAmount.test.tsx +1296 -0
- package/src/earn/EarnEnterAmount.tsx +815 -0
- package/src/earn/EarnEntrypoint.test.tsx +100 -0
- package/src/earn/EarnEntrypoint.tsx +127 -0
- package/src/earn/EarnHome.test.tsx +237 -0
- package/src/earn/EarnHome.tsx +411 -0
- package/src/earn/EarnInfoScreen.test.tsx +96 -0
- package/src/earn/EarnInfoScreen.tsx +174 -0
- package/src/earn/EarnTabBar.test.tsx +43 -0
- package/src/earn/EarnTabBar.tsx +73 -0
- package/src/earn/EarnWithdrawConfirmationScreen.test.tsx +1022 -0
- package/src/earn/EarnWithdrawConfirmationScreen.tsx +476 -0
- package/src/earn/PoolCard.test.tsx +68 -0
- package/src/earn/PoolCard.tsx +218 -0
- package/src/earn/PoolList.tsx +87 -0
- package/src/earn/TabEarn.test.tsx +159 -0
- package/src/earn/TabEarn.tsx +354 -0
- package/src/earn/hooks.test.tsx +328 -0
- package/src/earn/hooks.ts +178 -0
- package/src/earn/poolInfoScreen/BeforeDepositBottomSheet.test.tsx +411 -0
- package/src/earn/poolInfoScreen/BeforeDepositBottomSheet.tsx +448 -0
- package/src/earn/poolInfoScreen/Cards.tsx +383 -0
- package/src/earn/poolInfoScreen/EarnPoolInfoScreen.test.tsx +498 -0
- package/src/earn/poolInfoScreen/EarnPoolInfoScreen.tsx +595 -0
- package/src/earn/poolInfoScreen/SafetyCard.test.tsx +108 -0
- package/src/earn/poolInfoScreen/SafetyCard.tsx +165 -0
- package/src/earn/poolInfoScreen/TokenIcons.tsx +37 -0
- package/src/earn/poolInfoScreen/WithdrawBottomSheet.test.tsx +235 -0
- package/src/earn/poolInfoScreen/WithdrawBottomSheet.tsx +168 -0
- package/src/earn/prepareTransactions.test.ts +616 -0
- package/src/earn/prepareTransactions.ts +281 -0
- package/src/earn/saga.test.ts +1149 -0
- package/src/earn/saga.ts +456 -0
- package/src/earn/selectors.ts +5 -0
- package/src/earn/simulateTransactions.test.ts +121 -0
- package/src/earn/simulateTransactions.ts +58 -0
- package/src/earn/slice.test.ts +87 -0
- package/src/earn/slice.ts +73 -0
- package/src/earn/types.ts +70 -0
- package/src/earn/utils.test.ts +48 -0
- package/src/earn/utils.ts +54 -0
- package/src/fiatExchanges/BidaliScreen.test.tsx +163 -0
- package/src/fiatExchanges/BidaliScreen.tsx +189 -0
- package/src/fiatExchanges/CashInSuccess.test.tsx +54 -0
- package/src/fiatExchanges/CashInSuccess.tsx +104 -0
- package/src/fiatExchanges/ExchangeQR.test.tsx +100 -0
- package/src/fiatExchanges/ExchangeQR.tsx +94 -0
- package/src/fiatExchanges/ExternalExchanges.test.tsx +67 -0
- package/src/fiatExchanges/ExternalExchanges.tsx +104 -0
- package/src/fiatExchanges/FiatExchangeAmount.test.tsx +418 -0
- package/src/fiatExchanges/FiatExchangeAmount.tsx +305 -0
- package/src/fiatExchanges/FiatExchangeCurrencyBottomSheet.test.tsx +309 -0
- package/src/fiatExchanges/FiatExchangeCurrencyBottomSheet.tsx +139 -0
- package/src/fiatExchanges/PaymentMethodSection.test.tsx +259 -0
- package/src/fiatExchanges/PaymentMethodSection.tsx +378 -0
- package/src/fiatExchanges/ReviewFees.test.tsx +74 -0
- package/src/fiatExchanges/ReviewFees.tsx +202 -0
- package/src/fiatExchanges/SelectProvider.test.tsx +415 -0
- package/src/fiatExchanges/SelectProvider.tsx +649 -0
- package/src/fiatExchanges/SimplexScreen.test.tsx +109 -0
- package/src/fiatExchanges/SimplexScreen.tsx +185 -0
- package/src/fiatExchanges/Spend.tsx +104 -0
- package/src/fiatExchanges/WithdrawSpend.test.tsx +37 -0
- package/src/fiatExchanges/WithdrawSpend.tsx +139 -0
- package/src/fiatExchanges/__snapshots__/CashInSuccess.test.tsx.snap +351 -0
- package/src/fiatExchanges/__snapshots__/FiatExchangeAmount.test.tsx.snap +397 -0
- package/src/fiatExchanges/__snapshots__/ReviewFees.test.tsx.snap +844 -0
- package/src/fiatExchanges/__snapshots__/SimplexScreen.test.tsx.snap +1083 -0
- package/src/fiatExchanges/actions.ts +67 -0
- package/src/fiatExchanges/amount.test.tsx +48 -0
- package/src/fiatExchanges/amount.tsx +45 -0
- package/src/fiatExchanges/quotes/ExternalQuote.test.ts +172 -0
- package/src/fiatExchanges/quotes/ExternalQuote.ts +121 -0
- package/src/fiatExchanges/quotes/FiatConnectQuote.test.ts +718 -0
- package/src/fiatExchanges/quotes/FiatConnectQuote.ts +343 -0
- package/src/fiatExchanges/quotes/NormalizedQuote.ts +47 -0
- package/src/fiatExchanges/quotes/constants.ts +63 -0
- package/src/fiatExchanges/quotes/normalizeQuotes.test.ts +102 -0
- package/src/fiatExchanges/quotes/normalizeQuotes.ts +76 -0
- package/src/fiatExchanges/quotes/utils.ts +31 -0
- package/src/fiatExchanges/reducer.ts +65 -0
- package/src/fiatExchanges/saga.test.ts +281 -0
- package/src/fiatExchanges/saga.ts +195 -0
- package/src/fiatExchanges/types.ts +104 -0
- package/src/fiatExchanges/utils.test.ts +159 -0
- package/src/fiatExchanges/utils.tsx +287 -0
- package/src/fiatconnect/FiatDetailsScreen.test.tsx +371 -0
- package/src/fiatconnect/FiatDetailsScreen.tsx +441 -0
- package/src/fiatconnect/LinkAccountScreen.test.tsx +107 -0
- package/src/fiatconnect/LinkAccountScreen.tsx +180 -0
- package/src/fiatconnect/RefetchQuoteScreen.test.tsx +119 -0
- package/src/fiatconnect/RefetchQuoteScreen.tsx +68 -0
- package/src/fiatconnect/ReviewScreen.test.tsx +505 -0
- package/src/fiatconnect/ReviewScreen.tsx +708 -0
- package/src/fiatconnect/TransferStatusScreen.test.tsx +399 -0
- package/src/fiatconnect/TransferStatusScreen.tsx +351 -0
- package/src/fiatconnect/clients.test.tsx +83 -0
- package/src/fiatconnect/clients.ts +69 -0
- package/src/fiatconnect/consts.ts +41 -0
- package/src/fiatconnect/fiatAccountSchemas/accountNumber.test.ts +60 -0
- package/src/fiatconnect/fiatAccountSchemas/accountNumber.ts +55 -0
- package/src/fiatconnect/fiatAccountSchemas/ibanNumber.test.ts +53 -0
- package/src/fiatconnect/fiatAccountSchemas/ibanNumber.ts +56 -0
- package/src/fiatconnect/fiatAccountSchemas/ifscAccount.test.ts +45 -0
- package/src/fiatconnect/fiatAccountSchemas/ifscAccount.ts +58 -0
- package/src/fiatconnect/fiatAccountSchemas/index.test.ts +119 -0
- package/src/fiatconnect/fiatAccountSchemas/index.ts +89 -0
- package/src/fiatconnect/fiatAccountSchemas/mobileMoney.test.ts +29 -0
- package/src/fiatconnect/fiatAccountSchemas/mobileMoney.ts +61 -0
- package/src/fiatconnect/fiatAccountSchemas/pixAccount.test.ts +45 -0
- package/src/fiatconnect/fiatAccountSchemas/pixAccount.ts +62 -0
- package/src/fiatconnect/fiatAccountSchemas/types.ts +40 -0
- package/src/fiatconnect/index.test.ts +244 -0
- package/src/fiatconnect/index.ts +179 -0
- package/src/fiatconnect/kyc/KycDenied.test.tsx +139 -0
- package/src/fiatconnect/kyc/KycDenied.tsx +144 -0
- package/src/fiatconnect/kyc/KycExpired.test.tsx +128 -0
- package/src/fiatconnect/kyc/KycExpired.tsx +127 -0
- package/src/fiatconnect/kyc/KycInactive.test.tsx +139 -0
- package/src/fiatconnect/kyc/KycInactive.tsx +100 -0
- package/src/fiatconnect/kyc/KycPending.test.tsx +82 -0
- package/src/fiatconnect/kyc/KycPending.tsx +106 -0
- package/src/fiatconnect/kyc/getNavigationOptions.tsx +72 -0
- package/src/fiatconnect/saga.test.ts +2594 -0
- package/src/fiatconnect/saga.ts +1133 -0
- package/src/fiatconnect/selectors.ts +24 -0
- package/src/fiatconnect/slice.test.ts +79 -0
- package/src/fiatconnect/slice.ts +380 -0
- package/src/fiatconnect/types.ts +24 -0
- package/src/firebase/actions.ts +11 -0
- package/src/firebase/db-rules.json +129 -0
- package/src/firebase/firebase.test.ts +190 -0
- package/src/firebase/firebase.ts +315 -0
- package/src/firebase/notifications.test.ts +180 -0
- package/src/firebase/notifications.ts +106 -0
- package/src/firebase/saga.test.ts +23 -0
- package/src/firebase/saga.ts +81 -0
- package/src/flags.ts +76 -0
- package/src/home/ActionsCarousel.test.tsx +162 -0
- package/src/home/ActionsCarousel.tsx +161 -0
- package/src/home/DivviBottomSheet.test.tsx +59 -0
- package/src/home/DivviBottomSheet.tsx +197 -0
- package/src/home/GetStarted.test.tsx +47 -0
- package/src/home/GetStarted.tsx +115 -0
- package/src/home/NotificationBell.test.tsx +81 -0
- package/src/home/NotificationBell.tsx +42 -0
- package/src/home/NotificationBox.test.tsx +373 -0
- package/src/home/NotificationBox.tsx +362 -0
- package/src/home/NotificationCenter.test.tsx +466 -0
- package/src/home/NotificationCenter.tsx +185 -0
- package/src/home/SendBar.tsx +60 -0
- package/src/home/TabHome.test.tsx +336 -0
- package/src/home/TabHome.tsx +181 -0
- package/src/home/__snapshots__/NotificationBox.test.tsx.snap +933 -0
- package/src/home/actions.ts +154 -0
- package/src/home/celebration/ConfettiCelebration.tsx +170 -0
- package/src/home/celebration/NftCelebration.test.tsx +137 -0
- package/src/home/celebration/NftCelebration.tsx +207 -0
- package/src/home/celebration/NftReward.test.tsx +94 -0
- package/src/home/celebration/NftReward.tsx +172 -0
- package/src/home/celebration/confettiAnimation.json +5126 -0
- package/src/home/celebration/utils.test.ts +32 -0
- package/src/home/celebration/utils.ts +21 -0
- package/src/home/reducers.test.ts +245 -0
- package/src/home/reducers.ts +191 -0
- package/src/home/saga.test.ts +34 -0
- package/src/home/saga.ts +87 -0
- package/src/home/selectors.test.ts +302 -0
- package/src/home/selectors.ts +82 -0
- package/src/home/types.ts +31 -0
- package/src/i18n/i18n.test.ts +106 -0
- package/src/i18n/index.ts +88 -0
- package/src/i18n/otaTranslations.test.ts +34 -0
- package/src/i18n/otaTranslations.ts +15 -0
- package/src/i18n/saga.test.ts +106 -0
- package/src/i18n/saga.ts +92 -0
- package/src/i18n/selectors.ts +12 -0
- package/src/i18n/slice.ts +46 -0
- package/src/i18n/useChangeLanguage.test.tsx +53 -0
- package/src/i18n/useChangeLanguage.ts +19 -0
- package/src/icons/Activity.tsx +21 -0
- package/src/icons/Apple.tsx +14 -0
- package/src/icons/ArrowDown.tsx +19 -0
- package/src/icons/ArrowRightThick.tsx +16 -0
- package/src/icons/Attention.tsx +22 -0
- package/src/icons/BackChevron.tsx +24 -0
- package/src/icons/Backspace.tsx +31 -0
- package/src/icons/BankIcon.tsx +23 -0
- package/src/icons/Celebration.tsx +18 -0
- package/src/icons/CheckCircle.tsx +19 -0
- package/src/icons/Checkmark.tsx +26 -0
- package/src/icons/CircleArrowIcon.tsx +39 -0
- package/src/icons/CircledIcon.tsx +47 -0
- package/src/icons/Clipboard.tsx +17 -0
- package/src/icons/ClockIcon.tsx +23 -0
- package/src/icons/CloudCheck.tsx +19 -0
- package/src/icons/ComingSoon.tsx +18 -0
- package/src/icons/CopyIcon.tsx +14 -0
- package/src/icons/CrossChainIndicator.tsx +36 -0
- package/src/icons/DataDown.tsx +16 -0
- package/src/icons/DataUp.tsx +16 -0
- package/src/icons/DownArrowIcon.tsx +37 -0
- package/src/icons/EarnCoins.tsx +22 -0
- package/src/icons/Error.tsx +30 -0
- package/src/icons/Exit.tsx +18 -0
- package/src/icons/ExploreTokens.tsx +17 -0
- package/src/icons/EyeIcon.tsx +22 -0
- package/src/icons/ForwardChevron.tsx +30 -0
- package/src/icons/GearIcon.tsx +19 -0
- package/src/icons/Google.tsx +14 -0
- package/src/icons/GradientIcon.tsx +70 -0
- package/src/icons/GreenLoadingSpinner.tsx +16 -0
- package/src/icons/GreenLoadingSpinnerToCheck.tsx +16 -0
- package/src/icons/HamburgerCard.tsx +55 -0
- package/src/icons/Help.tsx +21 -0
- package/src/icons/HiddenEyeIcon.tsx +26 -0
- package/src/icons/ImageErrorIcon.tsx +26 -0
- package/src/icons/InfoIcon.tsx +33 -0
- package/src/icons/KeylessBackup.tsx +32 -0
- package/src/icons/LinkArrow.tsx +27 -0
- package/src/icons/LoadingSpinner.tsx +25 -0
- package/src/icons/Lock.tsx +19 -0
- package/src/icons/MagicWand.tsx +20 -0
- package/src/icons/Manage.tsx +22 -0
- package/src/icons/NotificationBellIcon.tsx +25 -0
- package/src/icons/OpenLinkIcon.tsx +18 -0
- package/src/icons/Paste.tsx +33 -0
- package/src/icons/Phone.tsx +20 -0
- package/src/icons/Preferences.tsx +21 -0
- package/src/icons/QRCode.tsx +14 -0
- package/src/icons/RadioButton.tsx +39 -0
- package/src/icons/RedLoadingSpinnerToInfo.tsx +16 -0
- package/src/icons/Refresh.tsx +30 -0
- package/src/icons/Reward.tsx +29 -0
- package/src/icons/ScanIcon.tsx +26 -0
- package/src/icons/Search.tsx +25 -0
- package/src/icons/Share.tsx +21 -0
- package/src/icons/Social.tsx +15 -0
- package/src/icons/Stack.tsx +21 -0
- package/src/icons/StarOutline.tsx +14 -0
- package/src/icons/SwapAndDeposit.tsx +20 -0
- package/src/icons/SwapArrows.tsx +20 -0
- package/src/icons/ThumbsUpIllustration.tsx +64 -0
- package/src/icons/Times.tsx +38 -0
- package/src/icons/TripleDotVertical.tsx +18 -0
- package/src/icons/Trophy.tsx +18 -0
- package/src/icons/User.tsx +19 -0
- package/src/icons/Warning.tsx +22 -0
- package/src/icons/biometry/Face.tsx +28 -0
- package/src/icons/biometry/FaceID.tsx +18 -0
- package/src/icons/biometry/Fingerprint.tsx +16 -0
- package/src/icons/biometry/Iris.tsx +22 -0
- package/src/icons/biometry/TouchID.tsx +44 -0
- package/src/icons/loadingSpinnerGreen.json +401 -0
- package/src/icons/lottie-json/greenLoadingSpinner.json +370 -0
- package/src/icons/lottie-json/greenLoadingSpinnerToCheck.json +666 -0
- package/src/icons/lottie-json/redLoadingSpinnerToInfo.json +950 -0
- package/src/icons/navigator/Discover.tsx +17 -0
- package/src/icons/navigator/Home.tsx +18 -0
- package/src/icons/navigator/Wallet.tsx +18 -0
- package/src/icons/quick-actions/Add.tsx +18 -0
- package/src/icons/quick-actions/More.tsx +19 -0
- package/src/icons/quick-actions/Receive.tsx +18 -0
- package/src/icons/quick-actions/Send.tsx +18 -0
- package/src/icons/quick-actions/Withdraw.tsx +18 -0
- package/src/identity/actions.ts +244 -0
- package/src/identity/contactMapping.test.ts +391 -0
- package/src/identity/contactMapping.ts +422 -0
- package/src/identity/reducer.ts +243 -0
- package/src/identity/saga.test.ts +103 -0
- package/src/identity/saga.ts +122 -0
- package/src/identity/secureSend.ts +171 -0
- package/src/identity/selectors.ts +16 -0
- package/src/identity/types.ts +14 -0
- package/src/images/Blob.tsx +20 -0
- package/src/images/Celebration.tsx +35 -0
- package/src/images/DivviLogo.tsx +22 -0
- package/src/images/GuideKeyIcon.tsx +51 -0
- package/src/images/Images.ts +22 -0
- package/src/images/Logo.tsx +66 -0
- package/src/images/LogoHeart.tsx +206 -0
- package/src/images/NftReceivedIcon.tsx +18 -0
- package/src/images/NftSentIcon.tsx +18 -0
- package/src/images/Palm.tsx +21 -0
- package/src/images/Star.tsx +20 -0
- package/src/images/WelcomeLogo.tsx +19 -0
- package/src/images/assets/account-key-1.png +0 -0
- package/src/images/assets/account-key-1@1.5x.png +0 -0
- package/src/images/assets/account-key-1@2x.png +0 -0
- package/src/images/assets/account-key-1@3x.png +0 -0
- package/src/images/assets/account-key-1@4x.png +0 -0
- package/src/images/assets/account-key-2.png +0 -0
- package/src/images/assets/account-key-2@1.5x.png +0 -0
- package/src/images/assets/account-key-2@2x.png +0 -0
- package/src/images/assets/account-key-2@3x.png +0 -0
- package/src/images/assets/account-key-2@4x.png +0 -0
- package/src/images/assets/account-key-3.png +0 -0
- package/src/images/assets/account-key-3@1.5x.png +0 -0
- package/src/images/assets/account-key-3@2x.png +0 -0
- package/src/images/assets/account-key-3@3x.png +0 -0
- package/src/images/assets/account-key-3@4x.png +0 -0
- package/src/images/assets/account-key-4.png +0 -0
- package/src/images/assets/account-key-4@1.5x.png +0 -0
- package/src/images/assets/account-key-4@2x.png +0 -0
- package/src/images/assets/account-key-4@3x.png +0 -0
- package/src/images/assets/account-key-4@4x.png +0 -0
- package/src/images/assets/biometry-face-id.png +0 -0
- package/src/images/assets/biometry-face-id@1.5x.png +0 -0
- package/src/images/assets/biometry-face-id@2x.png +0 -0
- package/src/images/assets/biometry-face-id@3x.png +0 -0
- package/src/images/assets/biometry-face-id@4x.png +0 -0
- package/src/images/assets/biometry-face.png +0 -0
- package/src/images/assets/biometry-face@1.5x.png +0 -0
- package/src/images/assets/biometry-face@2x.png +0 -0
- package/src/images/assets/biometry-face@3x.png +0 -0
- package/src/images/assets/biometry-face@4x.png +0 -0
- package/src/images/assets/biometry-fingerprint.png +0 -0
- package/src/images/assets/biometry-fingerprint@1.5x.png +0 -0
- package/src/images/assets/biometry-fingerprint@2x.png +0 -0
- package/src/images/assets/biometry-fingerprint@3x.png +0 -0
- package/src/images/assets/biometry-fingerprint@4x.png +0 -0
- package/src/images/assets/biometry-iris.png +0 -0
- package/src/images/assets/biometry-iris@1.5x.png +0 -0
- package/src/images/assets/biometry-iris@2x.png +0 -0
- package/src/images/assets/biometry-iris@3x.png +0 -0
- package/src/images/assets/biometry-iris@4x.png +0 -0
- package/src/images/assets/biometry-touch-id.png +0 -0
- package/src/images/assets/biometry-touch-id@1.5x.png +0 -0
- package/src/images/assets/biometry-touch-id@2x.png +0 -0
- package/src/images/assets/biometry-touch-id@3x.png +0 -0
- package/src/images/assets/biometry-touch-id@4x.png +0 -0
- package/src/images/assets/celo-education-1.png +0 -0
- package/src/images/assets/celo-education-1@1.5x.png +0 -0
- package/src/images/assets/celo-education-1@2x.png +0 -0
- package/src/images/assets/celo-education-1@3x.png +0 -0
- package/src/images/assets/celo-education-1@4x.png +0 -0
- package/src/images/assets/celo-education-2.png +0 -0
- package/src/images/assets/celo-education-2@1.5x.png +0 -0
- package/src/images/assets/celo-education-2@2x.png +0 -0
- package/src/images/assets/celo-education-2@3x.png +0 -0
- package/src/images/assets/celo-education-2@4x.png +0 -0
- package/src/images/assets/celo-education-3.png +0 -0
- package/src/images/assets/celo-education-3@1.5x.png +0 -0
- package/src/images/assets/celo-education-3@2x.png +0 -0
- package/src/images/assets/celo-education-3@3x.png +0 -0
- package/src/images/assets/celo-education-3@4x.png +0 -0
- package/src/images/assets/celo-education-4.png +0 -0
- package/src/images/assets/celo-education-4@1.5x.png +0 -0
- package/src/images/assets/celo-education-4@2x.png +0 -0
- package/src/images/assets/celo-education-4@3x.png +0 -0
- package/src/images/assets/celo-education-4@4x.png +0 -0
- package/src/images/assets/earn-card-background.png +0 -0
- package/src/images/assets/earn-card-background@1.5x.png +0 -0
- package/src/images/assets/earn-card-background@2x.png +0 -0
- package/src/images/assets/earn-card-background@3x.png +0 -0
- package/src/images/assets/earn-card-background@4x.png +0 -0
- package/src/images/assets/email.png +0 -0
- package/src/images/assets/email@1.5x.png +0 -0
- package/src/images/assets/email@2x.png +0 -0
- package/src/images/assets/email@3x.png +0 -0
- package/src/images/assets/email@4x.png +0 -0
- package/src/images/assets/fiat-exchange.png +0 -0
- package/src/images/assets/fiat-exchange@1.5x.png +0 -0
- package/src/images/assets/fiat-exchange@2x.png +0 -0
- package/src/images/assets/fiat-exchange@3x.png +0 -0
- package/src/images/assets/fiat-exchange@4x.png +0 -0
- package/src/images/assets/get-verified.png +0 -0
- package/src/images/assets/get-verified@1.5x.png +0 -0
- package/src/images/assets/get-verified@2x.png +0 -0
- package/src/images/assets/get-verified@3x.png +0 -0
- package/src/images/assets/get-verified@4x.png +0 -0
- package/src/images/assets/learn-celo.png +0 -0
- package/src/images/assets/learn-celo@1.5x.png +0 -0
- package/src/images/assets/learn-celo@2x.png +0 -0
- package/src/images/assets/learn-celo@3x.png +0 -0
- package/src/images/assets/learn-celo@4x.png +0 -0
- package/src/images/assets/pie.png +0 -0
- package/src/images/assets/pie@1.5x.png +0 -0
- package/src/images/assets/pie@2x.png +0 -0
- package/src/images/assets/pie@3x.png +0 -0
- package/src/images/assets/pie@4x.png +0 -0
- package/src/images/assets/points-card-background.png +0 -0
- package/src/images/assets/points-card-background@1.5x.png +0 -0
- package/src/images/assets/points-card-background@2x.png +0 -0
- package/src/images/assets/points-card-background@3x.png +0 -0
- package/src/images/assets/points-card-background@4x.png +0 -0
- package/src/images/assets/points-illustration.png +0 -0
- package/src/images/assets/points-illustration@1.5x.png +0 -0
- package/src/images/assets/points-illustration@2x.png +0 -0
- package/src/images/assets/points-illustration@3x.png +0 -0
- package/src/images/assets/points-illustration@4x.png +0 -0
- package/src/images/assets/wallet-safe.png +0 -0
- package/src/images/assets/wallet-safe@1.5x.png +0 -0
- package/src/images/assets/wallet-safe@2x.png +0 -0
- package/src/images/assets/wallet-safe@3x.png +0 -0
- package/src/images/assets/wallet-safe@4x.png +0 -0
- package/src/import/ImportWallet.test.tsx +102 -0
- package/src/import/ImportWallet.tsx +277 -0
- package/src/import/actions.ts +41 -0
- package/src/import/reducer.ts +28 -0
- package/src/import/saga.test.ts +165 -0
- package/src/import/saga.ts +250 -0
- package/src/in-house-liquidity/client.test.ts +34 -0
- package/src/in-house-liquidity/client.ts +38 -0
- package/src/in-house-liquidity/index.test.ts +258 -0
- package/src/in-house-liquidity/index.ts +187 -0
- package/src/index.d.ts +25 -0
- package/src/jumpstart/JumpstartTransactionDetailsScreen.test.tsx +329 -0
- package/src/jumpstart/JumpstartTransactionDetailsScreen.tsx +407 -0
- package/src/jumpstart/fetchClaimStatus.ts +46 -0
- package/src/jumpstart/saga.test.ts +117 -0
- package/src/jumpstart/saga.ts +82 -0
- package/src/jumpstart/selectors.ts +5 -0
- package/src/jumpstart/slice.test.ts +51 -0
- package/src/jumpstart/slice.ts +64 -0
- package/src/keylessBackup/EnvelopeIcon.tsx +19 -0
- package/src/keylessBackup/KeylessBackupCancelButton.test.tsx +55 -0
- package/src/keylessBackup/KeylessBackupCancelButton.tsx +26 -0
- package/src/keylessBackup/KeylessBackupIntro.test.tsx +76 -0
- package/src/keylessBackup/KeylessBackupIntro.tsx +175 -0
- package/src/keylessBackup/KeylessBackupPhoneCodeInput.test.tsx +256 -0
- package/src/keylessBackup/KeylessBackupPhoneCodeInput.tsx +257 -0
- package/src/keylessBackup/KeylessBackupPhoneInput.test.tsx +67 -0
- package/src/keylessBackup/KeylessBackupPhoneInput.tsx +203 -0
- package/src/keylessBackup/KeylessBackupProgress.test.tsx +371 -0
- package/src/keylessBackup/KeylessBackupProgress.tsx +495 -0
- package/src/keylessBackup/LinkPhoneNumber.test.tsx +57 -0
- package/src/keylessBackup/LinkPhoneNumber.tsx +107 -0
- package/src/keylessBackup/SignInWithEmail.test.tsx +271 -0
- package/src/keylessBackup/SignInWithEmail.tsx +348 -0
- package/src/keylessBackup/SmartphoneIcon.tsx +19 -0
- package/src/keylessBackup/WalletSecurityPrimer.test.tsx +31 -0
- package/src/keylessBackup/WalletSecurityPrimer.tsx +81 -0
- package/src/keylessBackup/encryption.test.ts +139 -0
- package/src/keylessBackup/encryption.ts +121 -0
- package/src/keylessBackup/hooks.ts +179 -0
- package/src/keylessBackup/index.test.ts +204 -0
- package/src/keylessBackup/index.ts +98 -0
- package/src/keylessBackup/keychain.test.ts +55 -0
- package/src/keylessBackup/keychain.ts +30 -0
- package/src/keylessBackup/saga.test.ts +427 -0
- package/src/keylessBackup/saga.ts +264 -0
- package/src/keylessBackup/selectors.ts +8 -0
- package/src/keylessBackup/slice.ts +108 -0
- package/src/keylessBackup/types.ts +25 -0
- package/src/keylessBackup/web3auth.test.ts +74 -0
- package/src/keylessBackup/web3auth.ts +54 -0
- package/src/language/Language.test.tsx +41 -0
- package/src/language/Language.tsx +99 -0
- package/src/localCurrency/SelectLocalCurrency.test.tsx +19 -0
- package/src/localCurrency/SelectLocalCurrency.tsx +83 -0
- package/src/localCurrency/actions.ts +49 -0
- package/src/localCurrency/consts.test.ts +9 -0
- package/src/localCurrency/consts.ts +97 -0
- package/src/localCurrency/convert.test.ts +30 -0
- package/src/localCurrency/convert.ts +66 -0
- package/src/localCurrency/hooks.test.tsx +146 -0
- package/src/localCurrency/hooks.ts +47 -0
- package/src/localCurrency/reducer.ts +59 -0
- package/src/localCurrency/saga.test.ts +34 -0
- package/src/localCurrency/saga.ts +61 -0
- package/src/localCurrency/selectors.test.ts +47 -0
- package/src/localCurrency/selectors.ts +66 -0
- package/src/localCurrency/types.ts +6 -0
- package/src/missingGlobals.ts +21 -0
- package/src/nameGenerator/index.test.ts +46 -0
- package/src/nameGenerator/index.ts +17 -0
- package/src/nameGenerator/names.ts +938 -0
- package/src/navigator/DemoModeAuthBlock.test.tsx +60 -0
- package/src/navigator/DemoModeAuthBlock.tsx +61 -0
- package/src/navigator/DemoModeChipIndicator.test.tsx +109 -0
- package/src/navigator/DemoModeChipIndicator.tsx +76 -0
- package/src/navigator/Headers.tsx +263 -0
- package/src/navigator/NavigationService.test.tsx +74 -0
- package/src/navigator/NavigationService.ts +244 -0
- package/src/navigator/Navigator.tsx +760 -0
- package/src/navigator/NavigatorWrapper.test.tsx +65 -0
- package/src/navigator/NavigatorWrapper.tsx +248 -0
- package/src/navigator/QRNavigator.test.tsx +61 -0
- package/src/navigator/QRNavigator.tsx +144 -0
- package/src/navigator/Screens.tsx +107 -0
- package/src/navigator/ScrollAwareHeader.tsx +57 -0
- package/src/navigator/SettingsMenu.test.tsx +253 -0
- package/src/navigator/SettingsMenu.tsx +353 -0
- package/src/navigator/TabNavigator.test.tsx +181 -0
- package/src/navigator/TabNavigator.tsx +142 -0
- package/src/navigator/TopBarButton.test.tsx +44 -0
- package/src/navigator/TopBarButton.tsx +88 -0
- package/src/navigator/TopBarIconButtonV2.test.tsx +17 -0
- package/src/navigator/TopBarIconButtonV2.tsx +85 -0
- package/src/navigator/initialRoute.test.tsx +32 -0
- package/src/navigator/initialRoute.tsx +29 -0
- package/src/navigator/types.tsx +346 -0
- package/src/networkInfo/actions.ts +28 -0
- package/src/networkInfo/reducer.ts +44 -0
- package/src/networkInfo/saga.test.ts +43 -0
- package/src/networkInfo/saga.ts +100 -0
- package/src/networkInfo/selectors.ts +4 -0
- package/src/nfts/NftMedia.test.tsx +114 -0
- package/src/nfts/NftMedia.tsx +205 -0
- package/src/nfts/NftsInfoCarousel.test.tsx +218 -0
- package/src/nfts/NftsInfoCarousel.tsx +344 -0
- package/src/nfts/NftsLoadError.test.tsx +37 -0
- package/src/nfts/NftsLoadError.tsx +111 -0
- package/src/nfts/saga.test.tsx +502 -0
- package/src/nfts/saga.ts +198 -0
- package/src/nfts/selectors.ts +13 -0
- package/src/nfts/slice.ts +45 -0
- package/src/nfts/types.ts +51 -0
- package/src/notifications/NotificationList.test.tsx +25 -0
- package/src/notifications/NotificationList.tsx +45 -0
- package/src/notifications/__snapshots__/NotificationList.test.tsx.snap +35 -0
- package/src/notifications/types.ts +31 -0
- package/src/onboarding/LanguageButton.tsx +26 -0
- package/src/onboarding/TopBarTextButtonOnboarding.test.tsx +22 -0
- package/src/onboarding/TopBarTextButtonOnboarding.tsx +17 -0
- package/src/onboarding/actions.ts +46 -0
- package/src/onboarding/registration/EnableBiometry.test.tsx +168 -0
- package/src/onboarding/registration/EnableBiometry.tsx +207 -0
- package/src/onboarding/registration/ImportSelect.test.tsx +54 -0
- package/src/onboarding/registration/ImportSelect.tsx +167 -0
- package/src/onboarding/registration/OnboardingRecoveryPhrase.test.tsx +83 -0
- package/src/onboarding/registration/OnboardingRecoveryPhrase.tsx +197 -0
- package/src/onboarding/registration/ProtectWallet.test.tsx +96 -0
- package/src/onboarding/registration/ProtectWallet.tsx +153 -0
- package/src/onboarding/registration/RegulatoryTerms.test.tsx +75 -0
- package/src/onboarding/registration/RegulatoryTerms.tsx +174 -0
- package/src/onboarding/registration/SelectCountry.test.tsx +51 -0
- package/src/onboarding/registration/SelectCountry.tsx +88 -0
- package/src/onboarding/registration/SelectCountryItem.tsx +59 -0
- package/src/onboarding/steps.test.ts +464 -0
- package/src/onboarding/steps.ts +303 -0
- package/src/onboarding/success/OnboardingSuccessScreen.tsx +64 -0
- package/src/onboarding/types.ts +14 -0
- package/src/onboarding/welcome/Welcome.test.tsx +234 -0
- package/src/onboarding/welcome/Welcome.tsx +182 -0
- package/src/pincode/PasswordCache.ts +71 -0
- package/src/pincode/Pincode.tsx +109 -0
- package/src/pincode/PincodeDisplay.tsx +92 -0
- package/src/pincode/PincodeEnter.test.tsx +85 -0
- package/src/pincode/PincodeEnter.tsx +103 -0
- package/src/pincode/PincodeLock.test.tsx +144 -0
- package/src/pincode/PincodeLock.tsx +121 -0
- package/src/pincode/PincodeSet.test.tsx +213 -0
- package/src/pincode/PincodeSet.tsx +263 -0
- package/src/pincode/authentication.test.ts +654 -0
- package/src/pincode/authentication.ts +425 -0
- package/src/points/ActivityCard.test.tsx +63 -0
- package/src/points/ActivityCard.tsx +101 -0
- package/src/points/ActivityCardSection.tsx +126 -0
- package/src/points/PointsDiscoverCard.test.tsx +106 -0
- package/src/points/PointsDiscoverCard.tsx +122 -0
- package/src/points/PointsHistoryBottomSheet.test.tsx +179 -0
- package/src/points/PointsHistoryBottomSheet.tsx +264 -0
- package/src/points/PointsHome.test.tsx +230 -0
- package/src/points/PointsHome.tsx +357 -0
- package/src/points/PointsIntro.test.tsx +67 -0
- package/src/points/PointsIntro.tsx +85 -0
- package/src/points/cardDefinitions.tsx +94 -0
- package/src/points/cardSort.test.ts +58 -0
- package/src/points/cardSort.ts +18 -0
- package/src/points/saga.test.ts +769 -0
- package/src/points/saga.ts +379 -0
- package/src/points/selectors.test.ts +73 -0
- package/src/points/selectors.ts +68 -0
- package/src/points/slice.test.ts +76 -0
- package/src/points/slice.ts +164 -0
- package/src/points/types.ts +94 -0
- package/src/positions/HooksPreviewModeBanner.test.tsx +56 -0
- package/src/positions/HooksPreviewModeBanner.tsx +69 -0
- package/src/positions/actions.ts +11 -0
- package/src/positions/getPositionBalanceUsd.ts +14 -0
- package/src/positions/saga.test.ts +468 -0
- package/src/positions/saga.ts +378 -0
- package/src/positions/selectors.test.ts +281 -0
- package/src/positions/selectors.ts +189 -0
- package/src/positions/slice.ts +219 -0
- package/src/positions/transactions.ts +21 -0
- package/src/positions/types.ts +137 -0
- package/src/priceHistory/PriceHistoryChart.test.tsx +200 -0
- package/src/priceHistory/PriceHistoryChart.tsx +345 -0
- package/src/priceHistory/__snapshots__/PriceHistoryChart.test.tsx.snap +419 -0
- package/src/priceHistory/saga.test.ts +120 -0
- package/src/priceHistory/saga.ts +62 -0
- package/src/priceHistory/selectors.test.ts +52 -0
- package/src/priceHistory/selectors.ts +17 -0
- package/src/priceHistory/slice.test.ts +94 -0
- package/src/priceHistory/slice.ts +68 -0
- package/src/public/components/Button.tsx +66 -0
- package/src/public/createApp.ts +67 -0
- package/src/public/getFees.test.ts +24 -0
- package/src/public/getFees.ts +8 -0
- package/src/public/getPublicClient.test.ts +19 -0
- package/src/public/getPublicClient.ts +25 -0
- package/src/public/getWalletClient.test.ts +30 -0
- package/src/public/getWalletClient.ts +32 -0
- package/src/public/hooks/toAsyncStatus.ts +19 -0
- package/src/public/hooks/usePrepareTransactions.test.ts +63 -0
- package/src/public/hooks/usePrepareTransactions.ts +15 -0
- package/src/public/hooks/usePublicClient.test.ts +24 -0
- package/src/public/hooks/usePublicClient.ts +7 -0
- package/src/public/hooks/useSendTransactions.test.ts +49 -0
- package/src/public/hooks/useSendTransactions.ts +15 -0
- package/src/public/hooks/useWallet.ts +52 -0
- package/src/public/hooks/useWalletClient.test.ts +35 -0
- package/src/public/hooks/useWalletClient.ts +24 -0
- package/src/public/index.ts +29 -0
- package/src/public/navigate.test.ts +168 -0
- package/src/public/navigate.ts +168 -0
- package/src/public/prepareTransactions.test.ts +76 -0
- package/src/public/prepareTransactions.ts +78 -0
- package/src/public/sendTransactions.test.ts +37 -0
- package/src/public/sendTransactions.ts +25 -0
- package/src/public/types.tsx +278 -0
- package/src/public/unlockAccount.test.ts +79 -0
- package/src/public/unlockAccount.ts +43 -0
- package/src/qrcode/NotAuthorizedView.test.tsx +11 -0
- package/src/qrcode/NotAuthorizedView.tsx +47 -0
- package/src/qrcode/QRCode.test.tsx +117 -0
- package/src/qrcode/QRCode.tsx +190 -0
- package/src/qrcode/QRScanner.tsx +249 -0
- package/src/qrcode/QRTabBar.tsx +137 -0
- package/src/qrcode/StyledQRCode.tsx +31 -0
- package/src/qrcode/StyledQRGen.tsx +26 -0
- package/src/qrcode/__snapshots__/NotAuthorizedView.test.tsx.snap +90 -0
- package/src/qrcode/schema.test.ts +121 -0
- package/src/qrcode/schema.ts +45 -0
- package/src/qrcode/utils.test.tsx +293 -0
- package/src/qrcode/utils.ts +230 -0
- package/src/recaptcha/RecaptchaService.ts +105 -0
- package/src/recaptcha/saga.ts +24 -0
- package/src/recipients/RecipientItemV2.test.tsx +153 -0
- package/src/recipients/RecipientItemV2.tsx +142 -0
- package/src/recipients/RecipientPickerV2.test.tsx +110 -0
- package/src/recipients/RecipientPickerV2.tsx +61 -0
- package/src/recipients/recipient.test.ts +113 -0
- package/src/recipients/recipient.ts +313 -0
- package/src/recipients/reducer.ts +107 -0
- package/src/recipients/resolve-id.ts +21 -0
- package/src/recipients/saga.ts +87 -0
- package/src/redux/apiReducersList.ts +11 -0
- package/src/redux/createMigrate.test.ts +113 -0
- package/src/redux/createMigrate.ts +46 -0
- package/src/redux/hooks.ts +7 -0
- package/src/redux/migrations.test.ts +1925 -0
- package/src/redux/migrations.ts +2069 -0
- package/src/redux/persist-helper.ts +14 -0
- package/src/redux/reducers.ts +29 -0
- package/src/redux/reducersForSchemaGeneration.ts +20 -0
- package/src/redux/reducersList.ts +57 -0
- package/src/redux/sagas-helpers.ts +29 -0
- package/src/redux/sagas.test.ts +19 -0
- package/src/redux/sagas.ts +155 -0
- package/src/redux/selectors.ts +3 -0
- package/src/redux/store.test.ts +391 -0
- package/src/redux/store.ts +151 -0
- package/src/send/EnterAmount.test.tsx +1030 -0
- package/src/send/EnterAmount.tsx +360 -0
- package/src/send/EnterAmountOptions.tsx +170 -0
- package/src/send/PasteAddressButton.tsx +81 -0
- package/src/send/SelectRecipientButtons.test.tsx +256 -0
- package/src/send/SelectRecipientButtons.tsx +202 -0
- package/src/send/SendConfirmation.test.tsx +233 -0
- package/src/send/SendConfirmation.tsx +317 -0
- package/src/send/SendEnterAmount.test.tsx +235 -0
- package/src/send/SendEnterAmount.tsx +123 -0
- package/src/send/SendSelectRecipient.test.tsx +765 -0
- package/src/send/SendSelectRecipient.tsx +504 -0
- package/src/send/SendSelectRecipientSearchInput.tsx +72 -0
- package/src/send/ValidateRecipientAccount.test.tsx +181 -0
- package/src/send/ValidateRecipientAccount.tsx +387 -0
- package/src/send/ValidateRecipientIntro.test.tsx +61 -0
- package/src/send/ValidateRecipientIntro.tsx +136 -0
- package/src/send/__snapshots__/ValidateRecipientAccount.test.tsx.snap +777 -0
- package/src/send/actions.ts +142 -0
- package/src/send/hooks.test.tsx +371 -0
- package/src/send/hooks.ts +445 -0
- package/src/send/reducers.ts +90 -0
- package/src/send/saga.test.ts +247 -0
- package/src/send/saga.ts +176 -0
- package/src/send/selectors.ts +22 -0
- package/src/send/types.ts +18 -0
- package/src/send/useFetchRecipientVerificationStatus.ts +67 -0
- package/src/send/usePrepareSendTransactions.test.ts +135 -0
- package/src/send/usePrepareSendTransactions.ts +69 -0
- package/src/send/utils.test.ts +361 -0
- package/src/send/utils.ts +116 -0
- package/src/sendCalls/constants.ts +11 -0
- package/src/sendCalls/saga.test.ts +31 -0
- package/src/sendCalls/saga.ts +15 -0
- package/src/sendCalls/selectors.test.ts +40 -0
- package/src/sendCalls/selectors.ts +8 -0
- package/src/sendCalls/slice.test.ts +85 -0
- package/src/sendCalls/slice.ts +72 -0
- package/src/sentry/Sentry.ts +75 -0
- package/src/sentry/SentrySpanHub.ts +27 -0
- package/src/sentry/SentrySpans.tsx +57 -0
- package/src/sentry/actions.ts +11 -0
- package/src/sentry/saga.ts +8 -0
- package/src/shared/DisconnectBanner.test.tsx +25 -0
- package/src/shared/DisconnectBanner.tsx +81 -0
- package/src/shared/__snapshots__/DisconnectBanner.test.tsx.snap +29 -0
- package/src/shared/conts.ts +16 -0
- package/src/statsig/client.test.ts +62 -0
- package/src/statsig/client.ts +97 -0
- package/src/statsig/constants.ts +177 -0
- package/src/statsig/index.test.ts +351 -0
- package/src/statsig/index.ts +186 -0
- package/src/statsig/selector.ts +17 -0
- package/src/statsig/types.ts +52 -0
- package/src/storage/keychain.tsx +92 -0
- package/src/styles/accessibility.ts +7 -0
- package/src/styles/appTheme.ts +13 -0
- package/src/styles/colors.tsx +78 -0
- package/src/styles/fonts.tsx +143 -0
- package/src/styles/hapticFeedback.ts +27 -0
- package/src/styles/progressDots.ts +23 -0
- package/src/styles/styles.ts +67 -0
- package/src/styles/variables.tsx +16 -0
- package/src/swap/SwapAmountInput.tsx +228 -0
- package/src/swap/SwapScreen.test.tsx +1927 -0
- package/src/swap/SwapScreen.tsx +1156 -0
- package/src/swap/SwapScreenV2.test.tsx +2180 -0
- package/src/swap/SwapScreenV2.tsx +1201 -0
- package/src/swap/SwapTransactionDetails.test.tsx +217 -0
- package/src/swap/SwapTransactionDetails.tsx +274 -0
- package/src/swap/UnfavorableRateBottomSheet.test.tsx +150 -0
- package/src/swap/UnfavorableRateBottomSheet.tsx +288 -0
- package/src/swap/getCrossChainFee.ts +64 -0
- package/src/swap/getSwapTxsAnalyticsProperties.tsx +49 -0
- package/src/swap/saga.test.ts +863 -0
- package/src/swap/saga.ts +324 -0
- package/src/swap/selectors.ts +5 -0
- package/src/swap/slice.test.ts +133 -0
- package/src/swap/slice.ts +93 -0
- package/src/swap/types.ts +98 -0
- package/src/swap/useFilterChips.ts +69 -0
- package/src/swap/useSwapQuote.ts +292 -0
- package/src/tokens/AssetList.test.tsx +270 -0
- package/src/tokens/AssetList.tsx +388 -0
- package/src/tokens/AssetTabBar.test.tsx +130 -0
- package/src/tokens/AssetTabBar.tsx +106 -0
- package/src/tokens/PasteButton.test.tsx +30 -0
- package/src/tokens/PasteButton.tsx +34 -0
- package/src/tokens/PositionIcon.tsx +22 -0
- package/src/tokens/PositionItem.test.tsx +132 -0
- package/src/tokens/PositionItem.tsx +131 -0
- package/src/tokens/TabWallet.test.tsx +386 -0
- package/src/tokens/TabWallet.tsx +237 -0
- package/src/tokens/TokenBalanceItem.test.tsx +119 -0
- package/src/tokens/TokenBalanceItem.tsx +143 -0
- package/src/tokens/TokenDetails.test.tsx +476 -0
- package/src/tokens/TokenDetails.tsx +391 -0
- package/src/tokens/TokenDetailsMoreActions.test.tsx +120 -0
- package/src/tokens/TokenDetailsMoreActions.tsx +87 -0
- package/src/tokens/TokenImport.test.tsx +376 -0
- package/src/tokens/TokenImport.tsx +381 -0
- package/src/tokens/hooks.test.tsx +419 -0
- package/src/tokens/hooks.ts +164 -0
- package/src/tokens/saga.test.ts +527 -0
- package/src/tokens/saga.ts +248 -0
- package/src/tokens/selectors.test.ts +888 -0
- package/src/tokens/selectors.ts +516 -0
- package/src/tokens/slice.ts +173 -0
- package/src/tokens/types.ts +29 -0
- package/src/tokens/utils.test.tsx +330 -0
- package/src/tokens/utils.ts +218 -0
- package/src/transactions/NoActivity.test.tsx +30 -0
- package/src/transactions/NoActivity.tsx +73 -0
- package/src/transactions/TransferAvatars.tsx +39 -0
- package/src/transactions/UserSection.tsx +133 -0
- package/src/transactions/api.ts +67 -0
- package/src/transactions/apiTestHelpers.ts +55 -0
- package/src/transactions/feed/ClaimRewardFeedItem.test.tsx +164 -0
- package/src/transactions/feed/ClaimRewardFeedItem.tsx +142 -0
- package/src/transactions/feed/DepositOrWithdrawFeedItem.test.tsx +138 -0
- package/src/transactions/feed/DepositOrWithdrawFeedItem.tsx +178 -0
- package/src/transactions/feed/EarnFeedItem.test.tsx +189 -0
- package/src/transactions/feed/EarnFeedItem.tsx +190 -0
- package/src/transactions/feed/NftFeedItem.test.tsx +102 -0
- package/src/transactions/feed/NftFeedItem.tsx +99 -0
- package/src/transactions/feed/SwapFeedItem.test.tsx +137 -0
- package/src/transactions/feed/SwapFeedItem.tsx +128 -0
- package/src/transactions/feed/TokenApprovalFeedItem.test.tsx +37 -0
- package/src/transactions/feed/TokenApprovalFeedItem.tsx +59 -0
- package/src/transactions/feed/TransactionDetails.tsx +160 -0
- package/src/transactions/feed/TransactionDetailsScreen.test.tsx +1228 -0
- package/src/transactions/feed/TransactionDetailsScreen.tsx +157 -0
- package/src/transactions/feed/TransactionFeed.test.tsx +474 -0
- package/src/transactions/feed/TransactionFeed.tsx +172 -0
- package/src/transactions/feed/TransactionFeedItemImage.test.tsx +66 -0
- package/src/transactions/feed/TransactionFeedItemImage.tsx +116 -0
- package/src/transactions/feed/TransactionFeedV2.test.tsx +576 -0
- package/src/transactions/feed/TransactionFeedV2.tsx +504 -0
- package/src/transactions/feed/TransactionPrimaryAction.test.tsx +62 -0
- package/src/transactions/feed/TransactionPrimaryAction.tsx +83 -0
- package/src/transactions/feed/TransactionStatusIndicator.test.tsx +15 -0
- package/src/transactions/feed/TransactionStatusIndicator.tsx +63 -0
- package/src/transactions/feed/TransferFeedItem.test.tsx +579 -0
- package/src/transactions/feed/TransferFeedItem.tsx +148 -0
- package/src/transactions/feed/detailContent/ClaimRewardContent.tsx +84 -0
- package/src/transactions/feed/detailContent/DepositOrWithdrawContent.tsx +169 -0
- package/src/transactions/feed/detailContent/EarnContent.tsx +259 -0
- package/src/transactions/feed/detailContent/FeeRowItem.tsx +90 -0
- package/src/transactions/feed/detailContent/RewardReceivedContent.tsx +46 -0
- package/src/transactions/feed/detailContent/SwapContent.tsx +127 -0
- package/src/transactions/feed/detailContent/TokenApprovalDetails.tsx +59 -0
- package/src/transactions/feed/detailContent/TransferReceivedContent.tsx +73 -0
- package/src/transactions/feed/detailContent/TransferSentContent.tsx +117 -0
- package/src/transactions/feed/queryHelper.test.ts +229 -0
- package/src/transactions/feed/queryHelper.ts +941 -0
- package/src/transactions/saga.test.ts +482 -0
- package/src/transactions/saga.ts +322 -0
- package/src/transactions/selectors.ts +120 -0
- package/src/transactions/send.test.ts +29 -0
- package/src/transactions/send.ts +51 -0
- package/src/transactions/slice.test.ts +372 -0
- package/src/transactions/slice.ts +262 -0
- package/src/transactions/transferFeedUtils.ts +225 -0
- package/src/transactions/types.ts +355 -0
- package/src/transactions/utils.test.ts +98 -0
- package/src/transactions/utils.ts +122 -0
- package/src/utils/AppRestart.ts +12 -0
- package/src/utils/Countries.test.ts +180 -0
- package/src/utils/Countries.ts +121 -0
- package/src/utils/IosVersionUtils.ts +6 -0
- package/src/utils/Logger.test.ts +113 -0
- package/src/utils/Logger.ts +304 -0
- package/src/utils/LoggerLevels.ts +6 -0
- package/src/utils/account.test.ts +390 -0
- package/src/utils/account.ts +497 -0
- package/src/utils/accountChecker.test.ts +75 -0
- package/src/utils/accountChecker.ts +77 -0
- package/src/utils/address.test.ts +62 -0
- package/src/utils/address.ts +34 -0
- package/src/utils/aes.test.ts +36 -0
- package/src/utils/aes.ts +46 -0
- package/src/utils/contacts.ts +78 -0
- package/src/utils/contentTranslations.ts +18 -0
- package/src/utils/country.json +257 -0
- package/src/utils/countryFeatures.ts +21 -0
- package/src/utils/currencies.ts +72 -0
- package/src/utils/displayFormatting.ts +11 -0
- package/src/utils/ensureError.test.ts +32 -0
- package/src/utils/ensureError.ts +13 -0
- package/src/utils/fetchWithTimeout.test.ts +55 -0
- package/src/utils/fetchWithTimeout.ts +15 -0
- package/src/utils/formatting.test.ts +93 -0
- package/src/utils/formatting.ts +107 -0
- package/src/utils/getCountryEmoji.ts +28 -0
- package/src/utils/getPhoneHash.ts +29 -0
- package/src/utils/gql.ts +8 -0
- package/src/utils/identifier.ts +81 -0
- package/src/utils/inputValidation.test.ts +53 -0
- package/src/utils/inputValidation.ts +76 -0
- package/src/utils/io.ts +39 -0
- package/src/utils/linking.ts +42 -0
- package/src/utils/moneyAmount.ts +16 -0
- package/src/utils/parsing.test.ts +30 -0
- package/src/utils/parsing.ts +20 -0
- package/src/utils/phoneNumber.test.ts +236 -0
- package/src/utils/phoneNumbers.ts +240 -0
- package/src/utils/random.test.ts +53 -0
- package/src/utils/random.ts +48 -0
- package/src/utils/safely.test.ts +101 -0
- package/src/utils/safely.ts +30 -0
- package/src/utils/sleep.ts +3 -0
- package/src/utils/string.ts +8 -0
- package/src/utils/stylize.ts +30 -0
- package/src/utils/time.test.ts +76 -0
- package/src/utils/time.ts +99 -0
- package/src/utils/typescript.ts +38 -0
- package/src/utils/useBackHandler.ts +10 -0
- package/src/utils/useClipboard.ts +56 -0
- package/src/utils/versionCheck.test.ts +47 -0
- package/src/utils/versionCheck.ts +35 -0
- package/src/verify/ResendButtonWithDelay.tsx +56 -0
- package/src/verify/VerificationCodeInput.test.tsx +87 -0
- package/src/verify/VerificationCodeInput.tsx +103 -0
- package/src/verify/VerificationCodeInputScreen.test.tsx +364 -0
- package/src/verify/VerificationCodeInputScreen.tsx +138 -0
- package/src/verify/VerificationStartScreen.test.tsx +218 -0
- package/src/verify/VerificationStartScreen.tsx +311 -0
- package/src/verify/hooks.test.tsx +85 -0
- package/src/verify/hooks.ts +261 -0
- package/src/viem/estimateFeesPerGas.test.ts +129 -0
- package/src/viem/estimateFeesPerGas.ts +70 -0
- package/src/viem/getLockableWallet.test.ts +263 -0
- package/src/viem/getLockableWallet.ts +120 -0
- package/src/viem/index.ts +86 -0
- package/src/viem/keychainAccountToAccount.test.ts +55 -0
- package/src/viem/keychainAccountToAccount.ts +58 -0
- package/src/viem/prepareTransactions.test.ts +1668 -0
- package/src/viem/prepareTransactions.ts +741 -0
- package/src/viem/preparedTransactionSerialization.test.ts +192 -0
- package/src/viem/preparedTransactionSerialization.ts +100 -0
- package/src/viem/saga.test.ts +227 -0
- package/src/viem/saga.ts +118 -0
- package/src/walletConnect/actions.test.ts +94 -0
- package/src/walletConnect/actions.ts +232 -0
- package/src/walletConnect/analytics.ts +58 -0
- package/src/walletConnect/capabilities.ts +175 -0
- package/src/walletConnect/constants.ts +157 -0
- package/src/walletConnect/reducer.ts +105 -0
- package/src/walletConnect/request.test.ts +698 -0
- package/src/walletConnect/request.ts +225 -0
- package/src/walletConnect/saga.test.ts +1875 -0
- package/src/walletConnect/saga.ts +1159 -0
- package/src/walletConnect/screens/ActionRequest.test.tsx +727 -0
- package/src/walletConnect/screens/ActionRequest.tsx +227 -0
- package/src/walletConnect/screens/ActionRequestPayload.tsx +84 -0
- package/src/walletConnect/screens/ConnectionTimedOut.tsx +34 -0
- package/src/walletConnect/screens/DappsDisclaimer.tsx +31 -0
- package/src/walletConnect/screens/EstimatedNetworkFee.test.tsx +88 -0
- package/src/walletConnect/screens/EstimatedNetworkFee.tsx +134 -0
- package/src/walletConnect/screens/Logos.tsx +89 -0
- package/src/walletConnect/screens/RequestContent.tsx +224 -0
- package/src/walletConnect/screens/SessionRequest.test.tsx +274 -0
- package/src/walletConnect/screens/SessionRequest.tsx +221 -0
- package/src/walletConnect/screens/Sessions.tsx +142 -0
- package/src/walletConnect/screens/WalletConnectRequest.tsx +63 -0
- package/src/walletConnect/screens/useIsDappListed.test.tsx +51 -0
- package/src/walletConnect/screens/useIsDappListed.ts +20 -0
- package/src/walletConnect/selectors.ts +25 -0
- package/src/walletConnect/types.ts +99 -0
- package/src/walletConnect/walletConnect.ts +87 -0
- package/src/web3/KeychainAccounts.test.ts +326 -0
- package/src/web3/KeychainAccounts.ts +309 -0
- package/src/web3/actions.ts +30 -0
- package/src/web3/consts.ts +8 -0
- package/src/web3/contracts.test.ts +115 -0
- package/src/web3/contracts.ts +74 -0
- package/src/web3/networkConfig.test.ts +18 -0
- package/src/web3/networkConfig.ts +621 -0
- package/src/web3/reducer.ts +39 -0
- package/src/web3/saga.test.ts +200 -0
- package/src/web3/saga.ts +229 -0
- package/src/web3/selectors.ts +47 -0
- package/src/web3/utils.test.ts +12 -0
- package/src/web3/utils.ts +11 -0
- package/src/webview/WebViewAndroidBottomSheet.test.tsx +58 -0
- package/src/webview/WebViewAndroidBottomSheet.tsx +83 -0
- package/src/webview/WebViewScreen.test.tsx +84 -0
- package/src/webview/WebViewScreen.tsx +296 -0
- package/src/webview/__snapshots__/WebViewAndroidBottomSheet.test.tsx.snap +249 -0
- package/tsconfig.base.json +5 -0
- package/tsconfig.json +30 -0
|
@@ -0,0 +1,2594 @@
|
|
|
1
|
+
import { Result } from '@badrap/result'
|
|
2
|
+
import { ResponseError } from '@fiatconnect/fiatconnect-sdk'
|
|
3
|
+
import {
|
|
4
|
+
CryptoType,
|
|
5
|
+
FiatAccountSchema,
|
|
6
|
+
FiatAccountType,
|
|
7
|
+
FiatConnectError,
|
|
8
|
+
KycStatus as FiatConnectKycStatus,
|
|
9
|
+
KycSchema,
|
|
10
|
+
TransferStatus,
|
|
11
|
+
} from '@fiatconnect/fiatconnect-types'
|
|
12
|
+
import _ from 'lodash'
|
|
13
|
+
import { expectSaga } from 'redux-saga-test-plan'
|
|
14
|
+
import * as matches from 'redux-saga-test-plan/matchers'
|
|
15
|
+
import { dynamic, throwError } from 'redux-saga-test-plan/providers'
|
|
16
|
+
import { call, select } from 'redux-saga/effects'
|
|
17
|
+
import { showError, showMessage } from 'src/alert/actions'
|
|
18
|
+
import AppAnalytics from 'src/analytics/AppAnalytics'
|
|
19
|
+
import { FiatExchangeEvents } from 'src/analytics/Events'
|
|
20
|
+
import { ErrorMessages } from 'src/app/ErrorMessages'
|
|
21
|
+
import FiatConnectQuote from 'src/fiatExchanges/quotes/FiatConnectQuote'
|
|
22
|
+
import { normalizeFiatConnectQuotes } from 'src/fiatExchanges/quotes/normalizeQuotes'
|
|
23
|
+
import { CICOFlow } from 'src/fiatExchanges/types'
|
|
24
|
+
import {
|
|
25
|
+
FiatConnectProviderInfo,
|
|
26
|
+
FiatConnectQuoteSuccess,
|
|
27
|
+
fetchQuotes,
|
|
28
|
+
getFiatConnectProviders,
|
|
29
|
+
} from 'src/fiatconnect'
|
|
30
|
+
import { getFiatConnectClient } from 'src/fiatconnect/clients'
|
|
31
|
+
import {
|
|
32
|
+
_checkFiatAccountAndNavigate,
|
|
33
|
+
_getFiatAccount,
|
|
34
|
+
_getQuotes,
|
|
35
|
+
_getSpecificQuote,
|
|
36
|
+
_initiateSendTxToProvider,
|
|
37
|
+
_initiateTransferWithProvider,
|
|
38
|
+
_selectQuoteAndFiatAccount,
|
|
39
|
+
_selectQuoteMatchingFiatAccount,
|
|
40
|
+
fetchFiatAccountsSaga,
|
|
41
|
+
handleAttemptReturnUserFlow,
|
|
42
|
+
handleCreateFiatConnectTransfer,
|
|
43
|
+
handleFetchFiatConnectProviders,
|
|
44
|
+
handleFetchFiatConnectQuotes,
|
|
45
|
+
handleKycTryAgain,
|
|
46
|
+
handlePostKyc,
|
|
47
|
+
handleRefetchQuote,
|
|
48
|
+
handleSelectFiatConnectQuote,
|
|
49
|
+
handleSubmitFiatAccount,
|
|
50
|
+
} from 'src/fiatconnect/saga'
|
|
51
|
+
import { fiatConnectProvidersSelector } from 'src/fiatconnect/selectors'
|
|
52
|
+
import {
|
|
53
|
+
attemptReturnUserFlow,
|
|
54
|
+
attemptReturnUserFlowCompleted,
|
|
55
|
+
cacheFiatConnectTransfer,
|
|
56
|
+
cacheQuoteParams,
|
|
57
|
+
createFiatConnectTransfer,
|
|
58
|
+
createFiatConnectTransferCompleted,
|
|
59
|
+
createFiatConnectTransferFailed,
|
|
60
|
+
createFiatConnectTransferTxProcessing,
|
|
61
|
+
fetchFiatConnectProviders,
|
|
62
|
+
fetchFiatConnectProvidersCompleted,
|
|
63
|
+
fetchFiatConnectProvidersFailed,
|
|
64
|
+
fetchFiatConnectQuotes,
|
|
65
|
+
fetchFiatConnectQuotesCompleted,
|
|
66
|
+
fetchFiatConnectQuotesFailed,
|
|
67
|
+
fiatAccountUsed,
|
|
68
|
+
kycTryAgain,
|
|
69
|
+
kycTryAgainCompleted,
|
|
70
|
+
postKyc as postKycAction,
|
|
71
|
+
refetchQuote,
|
|
72
|
+
refetchQuoteCompleted,
|
|
73
|
+
refetchQuoteFailed,
|
|
74
|
+
selectFiatConnectQuote,
|
|
75
|
+
selectFiatConnectQuoteCompleted,
|
|
76
|
+
submitFiatAccount,
|
|
77
|
+
submitFiatAccountCompleted,
|
|
78
|
+
submitFiatAccountKycApproved,
|
|
79
|
+
} from 'src/fiatconnect/slice'
|
|
80
|
+
import { FiatConnectTxError } from 'src/fiatconnect/types'
|
|
81
|
+
import i18n from 'src/i18n'
|
|
82
|
+
import { deleteKyc, getKycStatus, postKyc } from 'src/in-house-liquidity'
|
|
83
|
+
import { getLocalCurrencyCode } from 'src/localCurrency/selectors'
|
|
84
|
+
import { navigate } from 'src/navigator/NavigationService'
|
|
85
|
+
import { Screens } from 'src/navigator/Screens'
|
|
86
|
+
import { userLocationDataSelector } from 'src/networkInfo/selectors'
|
|
87
|
+
import { getDynamicConfigParams } from 'src/statsig'
|
|
88
|
+
import { StatsigDynamicConfigs } from 'src/statsig/types'
|
|
89
|
+
import { tokensByIdSelector } from 'src/tokens/selectors'
|
|
90
|
+
import { TokenBalance } from 'src/tokens/slice'
|
|
91
|
+
import { isTxPossiblyPending } from 'src/transactions/send'
|
|
92
|
+
import { NetworkId } from 'src/transactions/types'
|
|
93
|
+
import Logger from 'src/utils/Logger'
|
|
94
|
+
import { CiCoCurrency } from 'src/utils/currencies'
|
|
95
|
+
import { SerializableTransactionRequest } from 'src/viem/preparedTransactionSerialization'
|
|
96
|
+
import { walletAddressSelector } from 'src/web3/selectors'
|
|
97
|
+
import {
|
|
98
|
+
mockAccount2,
|
|
99
|
+
mockAccount3,
|
|
100
|
+
mockCeloTokenBalance,
|
|
101
|
+
mockCeurTokenBalance,
|
|
102
|
+
mockCrealTokenBalance,
|
|
103
|
+
mockCusdAddress,
|
|
104
|
+
mockCusdTokenBalance,
|
|
105
|
+
mockCusdTokenId,
|
|
106
|
+
mockFiatConnectProviderInfo,
|
|
107
|
+
mockFiatConnectQuotes,
|
|
108
|
+
} from 'test/values'
|
|
109
|
+
import { v4 as uuidv4 } from 'uuid'
|
|
110
|
+
import { Address, encodeFunctionData, erc20Abi } from 'viem'
|
|
111
|
+
|
|
112
|
+
jest.mock('src/statsig')
|
|
113
|
+
jest.mock('src/analytics/AppAnalytics')
|
|
114
|
+
jest.mock('src/fiatconnect')
|
|
115
|
+
jest.mock('uuid')
|
|
116
|
+
jest.mock('src/utils/Logger', () => ({
|
|
117
|
+
__esModule: true,
|
|
118
|
+
namedExport: jest.fn(),
|
|
119
|
+
default: {
|
|
120
|
+
info: jest.fn(),
|
|
121
|
+
warn: jest.fn(),
|
|
122
|
+
error: jest.fn(),
|
|
123
|
+
debug: jest.fn(),
|
|
124
|
+
},
|
|
125
|
+
}))
|
|
126
|
+
|
|
127
|
+
jest.mock('src/fiatconnect/clients', () => ({
|
|
128
|
+
getFiatConnectClient: jest.fn(() => ({
|
|
129
|
+
getFiatAccounts: jest.fn(),
|
|
130
|
+
addFiatAccount: jest.fn(),
|
|
131
|
+
})),
|
|
132
|
+
}))
|
|
133
|
+
|
|
134
|
+
jest.mock('src/in-house-liquidity', () => ({
|
|
135
|
+
getKycStatus: jest.fn(),
|
|
136
|
+
postKyc: jest.fn(),
|
|
137
|
+
deleteKyc: jest.fn(),
|
|
138
|
+
}))
|
|
139
|
+
|
|
140
|
+
jest.mock('src/transactions/send')
|
|
141
|
+
|
|
142
|
+
const mockedSendPreparedTransactions = jest.fn()
|
|
143
|
+
jest.mock('src/viem/saga', () => ({
|
|
144
|
+
...jest.requireActual('src/viem/saga'),
|
|
145
|
+
sendPreparedTransactions: (...args: any[]) => mockedSendPreparedTransactions(...args),
|
|
146
|
+
}))
|
|
147
|
+
|
|
148
|
+
describe('Fiatconnect saga', () => {
|
|
149
|
+
const provideDelay = ({ fn }: { fn: any }, next: any) => (fn.name === 'delayP' ? null : next())
|
|
150
|
+
const normalizedQuote = new FiatConnectQuote({
|
|
151
|
+
quote: mockFiatConnectQuotes[1] as FiatConnectQuoteSuccess,
|
|
152
|
+
fiatAccountType: FiatAccountType.BankAccount,
|
|
153
|
+
flow: CICOFlow.CashOut,
|
|
154
|
+
tokenId: mockCusdTokenId,
|
|
155
|
+
})
|
|
156
|
+
const normalizedQuoteKyc = new FiatConnectQuote({
|
|
157
|
+
quote: mockFiatConnectQuotes[3] as FiatConnectQuoteSuccess,
|
|
158
|
+
fiatAccountType: FiatAccountType.BankAccount,
|
|
159
|
+
flow: CICOFlow.CashOut,
|
|
160
|
+
tokenId: mockCusdTokenId,
|
|
161
|
+
})
|
|
162
|
+
const expectedCacheQuoteParams = {
|
|
163
|
+
providerId: normalizedQuoteKyc.getProviderId(),
|
|
164
|
+
kycSchema: normalizedQuoteKyc.getKycSchema()!,
|
|
165
|
+
cachedQuoteParams: {
|
|
166
|
+
cryptoAmount: normalizedQuoteKyc.getCryptoAmount(),
|
|
167
|
+
fiatAmount: normalizedQuoteKyc.getFiatAmount(),
|
|
168
|
+
flow: normalizedQuoteKyc.flow,
|
|
169
|
+
cryptoType: normalizedQuoteKyc.getCryptoCurrency(),
|
|
170
|
+
fiatType: normalizedQuoteKyc.getFiatType(),
|
|
171
|
+
},
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
jest.mocked(getDynamicConfigParams).mockImplementation(({ configName }) => {
|
|
175
|
+
if (configName === StatsigDynamicConfigs.FIAT_CONNECT_CONFIG) {
|
|
176
|
+
return { fiatConnectCashOutEnabled: true }
|
|
177
|
+
}
|
|
178
|
+
return {} as any
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
beforeEach(() => {
|
|
182
|
+
jest.clearAllMocks()
|
|
183
|
+
})
|
|
184
|
+
describe('handleSubmitFiatAccount', () => {
|
|
185
|
+
const mockAddFiatAccount = jest.fn()
|
|
186
|
+
const mockFcClient = {
|
|
187
|
+
addFiatAccount: mockAddFiatAccount,
|
|
188
|
+
}
|
|
189
|
+
const mockObfuscatedAccount = {
|
|
190
|
+
fiatAccountId: 'some id',
|
|
191
|
+
accountName: 'some account name',
|
|
192
|
+
institutionName: 'some institution',
|
|
193
|
+
fiatAccountType: FiatAccountType.BankAccount,
|
|
194
|
+
fiatAccountSchema: FiatAccountSchema.AccountNumber,
|
|
195
|
+
}
|
|
196
|
+
it('successfully submits account and navigates to review (no KYC)', async () => {
|
|
197
|
+
mockAddFiatAccount.mockResolvedValueOnce(Result.ok(mockObfuscatedAccount))
|
|
198
|
+
await expectSaga(
|
|
199
|
+
handleSubmitFiatAccount,
|
|
200
|
+
submitFiatAccount({
|
|
201
|
+
flow: normalizedQuote.flow,
|
|
202
|
+
quote: normalizedQuote,
|
|
203
|
+
fiatAccountData: { random: 'data' },
|
|
204
|
+
})
|
|
205
|
+
)
|
|
206
|
+
.provide([[matches.call.fn(getFiatConnectClient), mockFcClient], { call: provideDelay }])
|
|
207
|
+
.put(
|
|
208
|
+
showMessage(
|
|
209
|
+
i18n.t('fiatDetailsScreen.addFiatAccountSuccess', {
|
|
210
|
+
provider: normalizedQuote.getProviderName(),
|
|
211
|
+
})
|
|
212
|
+
)
|
|
213
|
+
)
|
|
214
|
+
.put(
|
|
215
|
+
fiatAccountUsed({
|
|
216
|
+
providerId: normalizedQuote.getProviderId(),
|
|
217
|
+
fiatAccountId: mockObfuscatedAccount.fiatAccountId,
|
|
218
|
+
fiatAccountType: mockObfuscatedAccount.fiatAccountType,
|
|
219
|
+
fiatAccountSchema: mockObfuscatedAccount.fiatAccountSchema,
|
|
220
|
+
flow: normalizedQuote.flow,
|
|
221
|
+
cryptoType: normalizedQuote.getCryptoCurrency(),
|
|
222
|
+
fiatType: normalizedQuote.getFiatType(),
|
|
223
|
+
})
|
|
224
|
+
)
|
|
225
|
+
.put(submitFiatAccountCompleted())
|
|
226
|
+
.run()
|
|
227
|
+
expect(AppAnalytics.track).toHaveBeenCalledTimes(1)
|
|
228
|
+
expect(AppAnalytics.track).toHaveBeenCalledWith(
|
|
229
|
+
FiatExchangeEvents.cico_fiat_details_success,
|
|
230
|
+
{
|
|
231
|
+
flow: normalizedQuote.flow,
|
|
232
|
+
provider: normalizedQuote.getProviderId(),
|
|
233
|
+
fiatAccountSchema: normalizedQuote.getFiatAccountSchema(),
|
|
234
|
+
}
|
|
235
|
+
)
|
|
236
|
+
expect(navigate).toBeCalledTimes(1)
|
|
237
|
+
expect(navigate).toHaveBeenCalledWith(Screens.FiatConnectReview, {
|
|
238
|
+
normalizedQuote: normalizedQuote,
|
|
239
|
+
flow: normalizedQuote.flow,
|
|
240
|
+
fiatAccount: mockObfuscatedAccount,
|
|
241
|
+
})
|
|
242
|
+
})
|
|
243
|
+
it('does not navigate to review when account already exists (no KYC)', async () => {
|
|
244
|
+
mockAddFiatAccount.mockResolvedValueOnce(
|
|
245
|
+
Result.err(
|
|
246
|
+
new ResponseError('FiatConnect API Error', { error: FiatConnectError.ResourceExists })
|
|
247
|
+
)
|
|
248
|
+
)
|
|
249
|
+
await expectSaga(
|
|
250
|
+
handleSubmitFiatAccount,
|
|
251
|
+
submitFiatAccount({
|
|
252
|
+
flow: normalizedQuote.flow,
|
|
253
|
+
quote: normalizedQuote,
|
|
254
|
+
fiatAccountData: { random: 'data' },
|
|
255
|
+
})
|
|
256
|
+
)
|
|
257
|
+
.provide([[matches.call.fn(getFiatConnectClient), mockFcClient]])
|
|
258
|
+
.put(submitFiatAccountCompleted())
|
|
259
|
+
.put(
|
|
260
|
+
showError(ErrorMessages.FIATCONNECT_ADD_ACCOUNT_EXISTS, undefined, {
|
|
261
|
+
provider: normalizedQuote.getProviderName(),
|
|
262
|
+
})
|
|
263
|
+
)
|
|
264
|
+
.run()
|
|
265
|
+
expect(AppAnalytics.track).toHaveBeenCalledWith(FiatExchangeEvents.cico_fiat_details_error, {
|
|
266
|
+
flow: normalizedQuote.flow,
|
|
267
|
+
provider: normalizedQuote.getProviderId(),
|
|
268
|
+
fiatAccountSchema: normalizedQuote.getFiatAccountSchema(),
|
|
269
|
+
fiatConnectError: FiatConnectError.ResourceExists,
|
|
270
|
+
error: 'FiatConnect API Error',
|
|
271
|
+
})
|
|
272
|
+
expect(navigate).not.toHaveBeenCalled()
|
|
273
|
+
})
|
|
274
|
+
it('does not navigate to review when experiencing a general error (no KYC)', async () => {
|
|
275
|
+
mockAddFiatAccount.mockResolvedValueOnce(Result.err(new ResponseError('some error')))
|
|
276
|
+
await expectSaga(
|
|
277
|
+
handleSubmitFiatAccount,
|
|
278
|
+
submitFiatAccount({
|
|
279
|
+
flow: normalizedQuote.flow,
|
|
280
|
+
quote: normalizedQuote,
|
|
281
|
+
fiatAccountData: { random: 'data' },
|
|
282
|
+
})
|
|
283
|
+
)
|
|
284
|
+
.provide([[matches.call.fn(getFiatConnectClient), mockFcClient]])
|
|
285
|
+
.put(submitFiatAccountCompleted())
|
|
286
|
+
.put(
|
|
287
|
+
showError(ErrorMessages.FIATCONNECT_ADD_ACCOUNT_FAILED, undefined, {
|
|
288
|
+
provider: normalizedQuote.getProviderName(),
|
|
289
|
+
})
|
|
290
|
+
)
|
|
291
|
+
.run()
|
|
292
|
+
expect(AppAnalytics.track).toHaveBeenCalledWith(FiatExchangeEvents.cico_fiat_details_error, {
|
|
293
|
+
flow: normalizedQuote.flow,
|
|
294
|
+
provider: normalizedQuote.getProviderId(),
|
|
295
|
+
fiatAccountSchema: normalizedQuote.getFiatAccountSchema(),
|
|
296
|
+
fiatConnectError: undefined,
|
|
297
|
+
error: 'some error',
|
|
298
|
+
})
|
|
299
|
+
expect(navigate).not.toHaveBeenCalled()
|
|
300
|
+
})
|
|
301
|
+
it('successfully submits account and navigates to review when KYC is required and approved', async () => {
|
|
302
|
+
mockAddFiatAccount.mockResolvedValueOnce(Result.ok(mockObfuscatedAccount))
|
|
303
|
+
await expectSaga(
|
|
304
|
+
handleSubmitFiatAccount,
|
|
305
|
+
submitFiatAccount({
|
|
306
|
+
flow: normalizedQuoteKyc.flow,
|
|
307
|
+
quote: normalizedQuoteKyc,
|
|
308
|
+
fiatAccountData: { random: 'data' },
|
|
309
|
+
})
|
|
310
|
+
)
|
|
311
|
+
.provide([
|
|
312
|
+
[matches.call.fn(getFiatConnectClient), mockFcClient],
|
|
313
|
+
{ call: provideDelay },
|
|
314
|
+
[
|
|
315
|
+
matches.call.fn(getKycStatus),
|
|
316
|
+
{
|
|
317
|
+
providerId: normalizedQuoteKyc.quote.provider.id,
|
|
318
|
+
kycStatus: {
|
|
319
|
+
[KycSchema.PersonalDataAndDocuments]: FiatConnectKycStatus.KycApproved,
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
],
|
|
323
|
+
{ call: provideDelay },
|
|
324
|
+
{ call: provideDelay },
|
|
325
|
+
])
|
|
326
|
+
.put(
|
|
327
|
+
showMessage(
|
|
328
|
+
i18n.t('fiatDetailsScreen.addFiatAccountSuccess', {
|
|
329
|
+
provider: normalizedQuoteKyc.getProviderName(),
|
|
330
|
+
})
|
|
331
|
+
)
|
|
332
|
+
)
|
|
333
|
+
.put(
|
|
334
|
+
fiatAccountUsed({
|
|
335
|
+
providerId: normalizedQuoteKyc.getProviderId(),
|
|
336
|
+
fiatAccountId: mockObfuscatedAccount.fiatAccountId,
|
|
337
|
+
fiatAccountType: mockObfuscatedAccount.fiatAccountType,
|
|
338
|
+
fiatAccountSchema: mockObfuscatedAccount.fiatAccountSchema,
|
|
339
|
+
flow: normalizedQuoteKyc.flow,
|
|
340
|
+
cryptoType: normalizedQuoteKyc.getCryptoCurrency(),
|
|
341
|
+
fiatType: normalizedQuoteKyc.getFiatType(),
|
|
342
|
+
})
|
|
343
|
+
)
|
|
344
|
+
.put(submitFiatAccountKycApproved())
|
|
345
|
+
.put(submitFiatAccountCompleted())
|
|
346
|
+
.run()
|
|
347
|
+
expect(AppAnalytics.track).toHaveBeenCalledTimes(1)
|
|
348
|
+
expect(AppAnalytics.track).toHaveBeenCalledWith(
|
|
349
|
+
FiatExchangeEvents.cico_fiat_details_success,
|
|
350
|
+
{
|
|
351
|
+
flow: normalizedQuoteKyc.flow,
|
|
352
|
+
provider: normalizedQuoteKyc.getProviderId(),
|
|
353
|
+
fiatAccountSchema: normalizedQuoteKyc.getFiatAccountSchema(),
|
|
354
|
+
}
|
|
355
|
+
)
|
|
356
|
+
expect(navigate).toBeCalledTimes(1)
|
|
357
|
+
expect(navigate).toHaveBeenCalledWith(Screens.FiatConnectReview, {
|
|
358
|
+
normalizedQuote: normalizedQuoteKyc,
|
|
359
|
+
flow: normalizedQuoteKyc.flow,
|
|
360
|
+
fiatAccount: mockObfuscatedAccount,
|
|
361
|
+
})
|
|
362
|
+
})
|
|
363
|
+
it('successfully submits account and navigates to denied screen when KYC is required and denied', async () => {
|
|
364
|
+
mockAddFiatAccount.mockResolvedValueOnce(Result.ok(mockObfuscatedAccount))
|
|
365
|
+
await expectSaga(
|
|
366
|
+
handleSubmitFiatAccount,
|
|
367
|
+
submitFiatAccount({
|
|
368
|
+
flow: normalizedQuoteKyc.flow,
|
|
369
|
+
quote: normalizedQuoteKyc,
|
|
370
|
+
fiatAccountData: { random: 'data' },
|
|
371
|
+
})
|
|
372
|
+
)
|
|
373
|
+
.provide([
|
|
374
|
+
[matches.call.fn(getFiatConnectClient), mockFcClient],
|
|
375
|
+
{ call: provideDelay },
|
|
376
|
+
[
|
|
377
|
+
matches.call.fn(getKycStatus),
|
|
378
|
+
{
|
|
379
|
+
providerId: normalizedQuoteKyc.quote.provider.id,
|
|
380
|
+
kycStatus: {
|
|
381
|
+
[KycSchema.PersonalDataAndDocuments]: FiatConnectKycStatus.KycDenied,
|
|
382
|
+
},
|
|
383
|
+
},
|
|
384
|
+
],
|
|
385
|
+
{ call: provideDelay },
|
|
386
|
+
])
|
|
387
|
+
.put(
|
|
388
|
+
showMessage(
|
|
389
|
+
i18n.t('fiatDetailsScreen.addFiatAccountSuccess', {
|
|
390
|
+
provider: normalizedQuoteKyc.getProviderName(),
|
|
391
|
+
})
|
|
392
|
+
)
|
|
393
|
+
)
|
|
394
|
+
.put(
|
|
395
|
+
fiatAccountUsed({
|
|
396
|
+
providerId: normalizedQuoteKyc.getProviderId(),
|
|
397
|
+
fiatAccountId: mockObfuscatedAccount.fiatAccountId,
|
|
398
|
+
fiatAccountType: mockObfuscatedAccount.fiatAccountType,
|
|
399
|
+
fiatAccountSchema: mockObfuscatedAccount.fiatAccountSchema,
|
|
400
|
+
flow: normalizedQuoteKyc.flow,
|
|
401
|
+
cryptoType: normalizedQuoteKyc.getCryptoCurrency(),
|
|
402
|
+
fiatType: normalizedQuoteKyc.getFiatType(),
|
|
403
|
+
})
|
|
404
|
+
)
|
|
405
|
+
.put(submitFiatAccountCompleted())
|
|
406
|
+
.run()
|
|
407
|
+
expect(AppAnalytics.track).toHaveBeenCalledTimes(1)
|
|
408
|
+
expect(AppAnalytics.track).toHaveBeenCalledWith(
|
|
409
|
+
FiatExchangeEvents.cico_fiat_details_success,
|
|
410
|
+
{
|
|
411
|
+
flow: normalizedQuoteKyc.flow,
|
|
412
|
+
provider: normalizedQuoteKyc.getProviderId(),
|
|
413
|
+
fiatAccountSchema: normalizedQuoteKyc.getFiatAccountSchema(),
|
|
414
|
+
}
|
|
415
|
+
)
|
|
416
|
+
expect(navigate).toBeCalledTimes(1)
|
|
417
|
+
expect(navigate).toHaveBeenCalledWith(Screens.KycDenied, {
|
|
418
|
+
quote: normalizedQuoteKyc,
|
|
419
|
+
flow: normalizedQuoteKyc.flow,
|
|
420
|
+
retryable: true,
|
|
421
|
+
})
|
|
422
|
+
})
|
|
423
|
+
it('successfully submits account and navigates to expired screen when KYC is required and expired', async () => {
|
|
424
|
+
mockAddFiatAccount.mockResolvedValueOnce(Result.ok(mockObfuscatedAccount))
|
|
425
|
+
await expectSaga(
|
|
426
|
+
handleSubmitFiatAccount,
|
|
427
|
+
submitFiatAccount({
|
|
428
|
+
flow: normalizedQuoteKyc.flow,
|
|
429
|
+
quote: normalizedQuoteKyc,
|
|
430
|
+
fiatAccountData: { random: 'data' },
|
|
431
|
+
})
|
|
432
|
+
)
|
|
433
|
+
.provide([
|
|
434
|
+
[matches.call.fn(getFiatConnectClient), mockFcClient],
|
|
435
|
+
{ call: provideDelay },
|
|
436
|
+
[
|
|
437
|
+
matches.call.fn(getKycStatus),
|
|
438
|
+
{
|
|
439
|
+
providerId: normalizedQuoteKyc.quote.provider.id,
|
|
440
|
+
kycStatus: {
|
|
441
|
+
[KycSchema.PersonalDataAndDocuments]: FiatConnectKycStatus.KycExpired,
|
|
442
|
+
},
|
|
443
|
+
},
|
|
444
|
+
],
|
|
445
|
+
{ call: provideDelay },
|
|
446
|
+
])
|
|
447
|
+
.put(
|
|
448
|
+
showMessage(
|
|
449
|
+
i18n.t('fiatDetailsScreen.addFiatAccountSuccess', {
|
|
450
|
+
provider: normalizedQuoteKyc.getProviderName(),
|
|
451
|
+
})
|
|
452
|
+
)
|
|
453
|
+
)
|
|
454
|
+
.put(
|
|
455
|
+
fiatAccountUsed({
|
|
456
|
+
providerId: normalizedQuoteKyc.getProviderId(),
|
|
457
|
+
fiatAccountId: mockObfuscatedAccount.fiatAccountId,
|
|
458
|
+
fiatAccountType: mockObfuscatedAccount.fiatAccountType,
|
|
459
|
+
fiatAccountSchema: mockObfuscatedAccount.fiatAccountSchema,
|
|
460
|
+
flow: normalizedQuoteKyc.flow,
|
|
461
|
+
cryptoType: normalizedQuoteKyc.getCryptoCurrency(),
|
|
462
|
+
fiatType: normalizedQuoteKyc.getFiatType(),
|
|
463
|
+
})
|
|
464
|
+
)
|
|
465
|
+
.put(submitFiatAccountCompleted())
|
|
466
|
+
.run()
|
|
467
|
+
expect(AppAnalytics.track).toHaveBeenCalledTimes(1)
|
|
468
|
+
expect(AppAnalytics.track).toHaveBeenCalledWith(
|
|
469
|
+
FiatExchangeEvents.cico_fiat_details_success,
|
|
470
|
+
{
|
|
471
|
+
flow: normalizedQuoteKyc.flow,
|
|
472
|
+
provider: normalizedQuoteKyc.getProviderId(),
|
|
473
|
+
fiatAccountSchema: normalizedQuoteKyc.getFiatAccountSchema(),
|
|
474
|
+
}
|
|
475
|
+
)
|
|
476
|
+
expect(navigate).toBeCalledTimes(1)
|
|
477
|
+
expect(navigate).toHaveBeenCalledWith(Screens.KycExpired, {
|
|
478
|
+
quote: normalizedQuoteKyc,
|
|
479
|
+
flow: normalizedQuoteKyc.flow,
|
|
480
|
+
})
|
|
481
|
+
})
|
|
482
|
+
it('successfully submits account and navigates to pending screen when KYC is required and pending', async () => {
|
|
483
|
+
mockAddFiatAccount.mockResolvedValueOnce(Result.ok(mockObfuscatedAccount))
|
|
484
|
+
await expectSaga(
|
|
485
|
+
handleSubmitFiatAccount,
|
|
486
|
+
submitFiatAccount({
|
|
487
|
+
flow: normalizedQuoteKyc.flow,
|
|
488
|
+
quote: normalizedQuoteKyc,
|
|
489
|
+
fiatAccountData: { random: 'data' },
|
|
490
|
+
})
|
|
491
|
+
)
|
|
492
|
+
.provide([
|
|
493
|
+
[matches.call.fn(getFiatConnectClient), mockFcClient],
|
|
494
|
+
{ call: provideDelay },
|
|
495
|
+
[
|
|
496
|
+
matches.call.fn(getKycStatus),
|
|
497
|
+
{
|
|
498
|
+
providerId: normalizedQuoteKyc.quote.provider.id,
|
|
499
|
+
kycStatus: {
|
|
500
|
+
[KycSchema.PersonalDataAndDocuments]: FiatConnectKycStatus.KycPending,
|
|
501
|
+
},
|
|
502
|
+
},
|
|
503
|
+
],
|
|
504
|
+
{ call: provideDelay },
|
|
505
|
+
])
|
|
506
|
+
.put(
|
|
507
|
+
showMessage(
|
|
508
|
+
i18n.t('fiatDetailsScreen.addFiatAccountSuccess', {
|
|
509
|
+
provider: normalizedQuoteKyc.getProviderName(),
|
|
510
|
+
})
|
|
511
|
+
)
|
|
512
|
+
)
|
|
513
|
+
.put(
|
|
514
|
+
fiatAccountUsed({
|
|
515
|
+
providerId: normalizedQuoteKyc.getProviderId(),
|
|
516
|
+
fiatAccountId: mockObfuscatedAccount.fiatAccountId,
|
|
517
|
+
fiatAccountType: mockObfuscatedAccount.fiatAccountType,
|
|
518
|
+
fiatAccountSchema: mockObfuscatedAccount.fiatAccountSchema,
|
|
519
|
+
flow: normalizedQuoteKyc.flow,
|
|
520
|
+
cryptoType: normalizedQuoteKyc.getCryptoCurrency(),
|
|
521
|
+
fiatType: normalizedQuoteKyc.getFiatType(),
|
|
522
|
+
})
|
|
523
|
+
)
|
|
524
|
+
.put(submitFiatAccountCompleted())
|
|
525
|
+
.run()
|
|
526
|
+
expect(AppAnalytics.track).toHaveBeenCalledTimes(1)
|
|
527
|
+
expect(AppAnalytics.track).toHaveBeenCalledWith(
|
|
528
|
+
FiatExchangeEvents.cico_fiat_details_success,
|
|
529
|
+
{
|
|
530
|
+
flow: normalizedQuoteKyc.flow,
|
|
531
|
+
provider: normalizedQuoteKyc.getProviderId(),
|
|
532
|
+
fiatAccountSchema: normalizedQuoteKyc.getFiatAccountSchema(),
|
|
533
|
+
}
|
|
534
|
+
)
|
|
535
|
+
expect(navigate).toBeCalledTimes(1)
|
|
536
|
+
expect(navigate).toHaveBeenCalledWith(Screens.KycPending, {
|
|
537
|
+
quote: normalizedQuoteKyc,
|
|
538
|
+
flow: normalizedQuoteKyc.flow,
|
|
539
|
+
})
|
|
540
|
+
})
|
|
541
|
+
it('successfully submits account and navigates to pending screen when KYC is required and throws while fetching', async () => {
|
|
542
|
+
mockAddFiatAccount.mockResolvedValueOnce(Result.ok(mockObfuscatedAccount))
|
|
543
|
+
await expectSaga(
|
|
544
|
+
handleSubmitFiatAccount,
|
|
545
|
+
submitFiatAccount({
|
|
546
|
+
flow: normalizedQuoteKyc.flow,
|
|
547
|
+
quote: normalizedQuoteKyc,
|
|
548
|
+
fiatAccountData: { random: 'data' },
|
|
549
|
+
})
|
|
550
|
+
)
|
|
551
|
+
.provide([
|
|
552
|
+
[matches.call.fn(getFiatConnectClient), mockFcClient],
|
|
553
|
+
{ call: provideDelay },
|
|
554
|
+
[matches.call.fn(getKycStatus), new Error('uh oh!')],
|
|
555
|
+
{ call: provideDelay },
|
|
556
|
+
])
|
|
557
|
+
.put(
|
|
558
|
+
showMessage(
|
|
559
|
+
i18n.t('fiatDetailsScreen.addFiatAccountSuccess', {
|
|
560
|
+
provider: normalizedQuoteKyc.getProviderName(),
|
|
561
|
+
})
|
|
562
|
+
)
|
|
563
|
+
)
|
|
564
|
+
.put(
|
|
565
|
+
fiatAccountUsed({
|
|
566
|
+
providerId: normalizedQuoteKyc.getProviderId(),
|
|
567
|
+
fiatAccountId: mockObfuscatedAccount.fiatAccountId,
|
|
568
|
+
fiatAccountType: mockObfuscatedAccount.fiatAccountType,
|
|
569
|
+
fiatAccountSchema: mockObfuscatedAccount.fiatAccountSchema,
|
|
570
|
+
flow: normalizedQuoteKyc.flow,
|
|
571
|
+
cryptoType: normalizedQuoteKyc.getCryptoCurrency(),
|
|
572
|
+
fiatType: normalizedQuoteKyc.getFiatType(),
|
|
573
|
+
})
|
|
574
|
+
)
|
|
575
|
+
.put(submitFiatAccountCompleted())
|
|
576
|
+
.run()
|
|
577
|
+
expect(AppAnalytics.track).toHaveBeenCalledTimes(1)
|
|
578
|
+
expect(AppAnalytics.track).toHaveBeenCalledWith(
|
|
579
|
+
FiatExchangeEvents.cico_fiat_details_success,
|
|
580
|
+
{
|
|
581
|
+
flow: normalizedQuoteKyc.flow,
|
|
582
|
+
provider: normalizedQuoteKyc.getProviderId(),
|
|
583
|
+
fiatAccountSchema: normalizedQuoteKyc.getFiatAccountSchema(),
|
|
584
|
+
}
|
|
585
|
+
)
|
|
586
|
+
expect(navigate).toBeCalledTimes(1)
|
|
587
|
+
expect(navigate).toHaveBeenCalledWith(Screens.KycPending, {
|
|
588
|
+
quote: normalizedQuoteKyc,
|
|
589
|
+
flow: normalizedQuoteKyc.flow,
|
|
590
|
+
})
|
|
591
|
+
})
|
|
592
|
+
it('successfully submits account and navigates to pending screen when KYC is required but unexpected status is returned', async () => {
|
|
593
|
+
mockAddFiatAccount.mockResolvedValueOnce(Result.ok(mockObfuscatedAccount))
|
|
594
|
+
await expectSaga(
|
|
595
|
+
handleSubmitFiatAccount,
|
|
596
|
+
submitFiatAccount({
|
|
597
|
+
flow: normalizedQuoteKyc.flow,
|
|
598
|
+
quote: normalizedQuoteKyc,
|
|
599
|
+
fiatAccountData: { random: 'data' },
|
|
600
|
+
})
|
|
601
|
+
)
|
|
602
|
+
.provide([
|
|
603
|
+
[matches.call.fn(getFiatConnectClient), mockFcClient],
|
|
604
|
+
{ call: provideDelay },
|
|
605
|
+
[
|
|
606
|
+
matches.call.fn(getKycStatus),
|
|
607
|
+
{
|
|
608
|
+
providerId: normalizedQuoteKyc.quote.provider.id,
|
|
609
|
+
kycStatus: {
|
|
610
|
+
[KycSchema.PersonalDataAndDocuments]: 'bad-status!',
|
|
611
|
+
},
|
|
612
|
+
},
|
|
613
|
+
],
|
|
614
|
+
{ call: provideDelay },
|
|
615
|
+
])
|
|
616
|
+
.put(
|
|
617
|
+
showMessage(
|
|
618
|
+
i18n.t('fiatDetailsScreen.addFiatAccountSuccess', {
|
|
619
|
+
provider: normalizedQuoteKyc.getProviderName(),
|
|
620
|
+
})
|
|
621
|
+
)
|
|
622
|
+
)
|
|
623
|
+
.put(
|
|
624
|
+
fiatAccountUsed({
|
|
625
|
+
providerId: normalizedQuoteKyc.getProviderId(),
|
|
626
|
+
fiatAccountId: mockObfuscatedAccount.fiatAccountId,
|
|
627
|
+
fiatAccountType: mockObfuscatedAccount.fiatAccountType,
|
|
628
|
+
fiatAccountSchema: mockObfuscatedAccount.fiatAccountSchema,
|
|
629
|
+
flow: normalizedQuoteKyc.flow,
|
|
630
|
+
cryptoType: normalizedQuoteKyc.getCryptoCurrency(),
|
|
631
|
+
fiatType: normalizedQuoteKyc.getFiatType(),
|
|
632
|
+
})
|
|
633
|
+
)
|
|
634
|
+
.put(submitFiatAccountCompleted())
|
|
635
|
+
.run()
|
|
636
|
+
expect(AppAnalytics.track).toHaveBeenCalledTimes(1)
|
|
637
|
+
expect(AppAnalytics.track).toHaveBeenCalledWith(
|
|
638
|
+
FiatExchangeEvents.cico_fiat_details_success,
|
|
639
|
+
{
|
|
640
|
+
flow: normalizedQuoteKyc.flow,
|
|
641
|
+
provider: normalizedQuoteKyc.getProviderId(),
|
|
642
|
+
fiatAccountSchema: normalizedQuoteKyc.getFiatAccountSchema(),
|
|
643
|
+
}
|
|
644
|
+
)
|
|
645
|
+
expect(navigate).toBeCalledTimes(1)
|
|
646
|
+
expect(navigate).toHaveBeenCalledWith(Screens.KycPending, {
|
|
647
|
+
quote: normalizedQuoteKyc,
|
|
648
|
+
flow: normalizedQuoteKyc.flow,
|
|
649
|
+
})
|
|
650
|
+
})
|
|
651
|
+
})
|
|
652
|
+
describe('handleFetchFiatConnectQuotes', () => {
|
|
653
|
+
it('saves quotes when fetch is successful', async () => {
|
|
654
|
+
jest.mocked(fetchQuotes).mockImplementation(() => Promise.resolve(mockFiatConnectQuotes))
|
|
655
|
+
await expectSaga(
|
|
656
|
+
handleFetchFiatConnectQuotes,
|
|
657
|
+
fetchFiatConnectQuotes({
|
|
658
|
+
flow: CICOFlow.CashIn,
|
|
659
|
+
digitalAsset: CiCoCurrency.CELO,
|
|
660
|
+
cryptoAmount: 3,
|
|
661
|
+
fiatAmount: 2,
|
|
662
|
+
providerIds: ['provider-one'],
|
|
663
|
+
})
|
|
664
|
+
)
|
|
665
|
+
.provide([
|
|
666
|
+
[select(userLocationDataSelector), { countryCodeAlpha2: 'MX' }],
|
|
667
|
+
[select(getLocalCurrencyCode), 'USD'],
|
|
668
|
+
[select(fiatConnectProvidersSelector), mockFiatConnectProviderInfo],
|
|
669
|
+
[select(walletAddressSelector), '0xabc'],
|
|
670
|
+
])
|
|
671
|
+
.put(fetchFiatConnectQuotesCompleted({ quotes: mockFiatConnectQuotes }))
|
|
672
|
+
.run()
|
|
673
|
+
|
|
674
|
+
expect(fetchQuotes).toHaveBeenCalledWith({
|
|
675
|
+
country: 'MX',
|
|
676
|
+
cryptoAmount: 3,
|
|
677
|
+
fiatAmount: 2,
|
|
678
|
+
digitalAsset: 'CELO',
|
|
679
|
+
flow: CICOFlow.CashIn,
|
|
680
|
+
localCurrency: 'USD',
|
|
681
|
+
fiatConnectProviders: [mockFiatConnectProviderInfo[1]],
|
|
682
|
+
address: '0xabc',
|
|
683
|
+
})
|
|
684
|
+
})
|
|
685
|
+
|
|
686
|
+
it('fetches providers if null initially', async () => {
|
|
687
|
+
jest.mocked(fetchQuotes).mockImplementation(() => Promise.resolve(mockFiatConnectQuotes))
|
|
688
|
+
const providers = (
|
|
689
|
+
firstValue: FiatConnectProviderInfo[] | null,
|
|
690
|
+
restValue: FiatConnectProviderInfo[] | null
|
|
691
|
+
) => {
|
|
692
|
+
let callCount = 0
|
|
693
|
+
return () => (++callCount == 1 ? firstValue : restValue)
|
|
694
|
+
}
|
|
695
|
+
await expectSaga(
|
|
696
|
+
handleFetchFiatConnectQuotes,
|
|
697
|
+
fetchFiatConnectQuotes({
|
|
698
|
+
flow: CICOFlow.CashIn,
|
|
699
|
+
digitalAsset: CiCoCurrency.CELO,
|
|
700
|
+
cryptoAmount: 3,
|
|
701
|
+
fiatAmount: 2,
|
|
702
|
+
providerIds: ['provider-one'],
|
|
703
|
+
})
|
|
704
|
+
)
|
|
705
|
+
.provide([
|
|
706
|
+
[select(userLocationDataSelector), { countryCodeAlpha2: 'MX' }],
|
|
707
|
+
[select(getLocalCurrencyCode), 'USD'],
|
|
708
|
+
[
|
|
709
|
+
select(fiatConnectProvidersSelector),
|
|
710
|
+
dynamic(providers(null, mockFiatConnectProviderInfo)),
|
|
711
|
+
],
|
|
712
|
+
[select(walletAddressSelector), '0xabc'],
|
|
713
|
+
])
|
|
714
|
+
.put(fetchFiatConnectProviders())
|
|
715
|
+
.dispatch(fetchFiatConnectProvidersCompleted({ providers: mockFiatConnectProviderInfo }))
|
|
716
|
+
.put(fetchFiatConnectQuotesCompleted({ quotes: mockFiatConnectQuotes }))
|
|
717
|
+
.run()
|
|
718
|
+
|
|
719
|
+
expect(fetchQuotes).toHaveBeenCalledWith({
|
|
720
|
+
country: 'MX',
|
|
721
|
+
cryptoAmount: 3,
|
|
722
|
+
fiatAmount: 2,
|
|
723
|
+
digitalAsset: 'CELO',
|
|
724
|
+
flow: CICOFlow.CashIn,
|
|
725
|
+
localCurrency: 'USD',
|
|
726
|
+
fiatConnectProviders: [mockFiatConnectProviderInfo[1]],
|
|
727
|
+
address: '0xabc',
|
|
728
|
+
})
|
|
729
|
+
})
|
|
730
|
+
|
|
731
|
+
it('saves an error', async () => {
|
|
732
|
+
jest.mocked(fetchQuotes).mockRejectedValue({})
|
|
733
|
+
await expectSaga(
|
|
734
|
+
handleFetchFiatConnectQuotes,
|
|
735
|
+
fetchFiatConnectQuotes({
|
|
736
|
+
flow: CICOFlow.CashIn,
|
|
737
|
+
digitalAsset: CiCoCurrency.CELO,
|
|
738
|
+
cryptoAmount: 3,
|
|
739
|
+
fiatAmount: 2,
|
|
740
|
+
})
|
|
741
|
+
)
|
|
742
|
+
.provide([
|
|
743
|
+
[select(userLocationDataSelector), { countryCodeAlpha2: 'MX' }],
|
|
744
|
+
[select(getLocalCurrencyCode), 'USD'],
|
|
745
|
+
[select(fiatConnectProvidersSelector), mockFiatConnectProviderInfo],
|
|
746
|
+
[select(walletAddressSelector), '0xabc'],
|
|
747
|
+
])
|
|
748
|
+
.put(fetchFiatConnectQuotesFailed({ error: 'Could not fetch fiatconnect quotes' }))
|
|
749
|
+
.run()
|
|
750
|
+
|
|
751
|
+
expect(fetchQuotes).toHaveBeenCalledWith({
|
|
752
|
+
country: 'MX',
|
|
753
|
+
cryptoAmount: 3,
|
|
754
|
+
fiatAmount: 2,
|
|
755
|
+
digitalAsset: 'CELO',
|
|
756
|
+
flow: CICOFlow.CashIn,
|
|
757
|
+
localCurrency: 'USD',
|
|
758
|
+
fiatConnectProviders: mockFiatConnectProviderInfo,
|
|
759
|
+
address: '0xabc',
|
|
760
|
+
})
|
|
761
|
+
})
|
|
762
|
+
it('saves an error when providers is null and fetching them fails', async () => {
|
|
763
|
+
jest.mocked(fetchQuotes).mockResolvedValue(mockFiatConnectQuotes)
|
|
764
|
+
await expectSaga(
|
|
765
|
+
handleFetchFiatConnectQuotes,
|
|
766
|
+
fetchFiatConnectQuotes({
|
|
767
|
+
flow: CICOFlow.CashIn,
|
|
768
|
+
digitalAsset: CiCoCurrency.CELO,
|
|
769
|
+
cryptoAmount: 3,
|
|
770
|
+
fiatAmount: 2,
|
|
771
|
+
})
|
|
772
|
+
)
|
|
773
|
+
.provide([
|
|
774
|
+
[select(userLocationDataSelector), { countryCodeAlpha2: 'MX' }],
|
|
775
|
+
[select(getLocalCurrencyCode), 'USD'],
|
|
776
|
+
[select(fiatConnectProvidersSelector), null],
|
|
777
|
+
[select(walletAddressSelector), '0xabc'],
|
|
778
|
+
])
|
|
779
|
+
.put(fetchFiatConnectProviders())
|
|
780
|
+
.dispatch(fetchFiatConnectProvidersFailed())
|
|
781
|
+
.put(fetchFiatConnectQuotesFailed({ error: 'Could not fetch fiatconnect quotes' }))
|
|
782
|
+
.run()
|
|
783
|
+
|
|
784
|
+
expect(fetchQuotes).not.toHaveBeenCalled()
|
|
785
|
+
})
|
|
786
|
+
})
|
|
787
|
+
|
|
788
|
+
describe('handleSelectFiatConnectQuote', () => {
|
|
789
|
+
it.each([FiatConnectKycStatus.KycApproved, FiatConnectKycStatus.KycPending])(
|
|
790
|
+
'navigates to KycInactive if KYC is required and KYC status is %s',
|
|
791
|
+
async (fcKycStatus) => {
|
|
792
|
+
await expectSaga(
|
|
793
|
+
handleSelectFiatConnectQuote,
|
|
794
|
+
selectFiatConnectQuote({ quote: normalizedQuoteKyc })
|
|
795
|
+
)
|
|
796
|
+
.provide([
|
|
797
|
+
[
|
|
798
|
+
matches.call.fn(getKycStatus),
|
|
799
|
+
{
|
|
800
|
+
providerId: normalizedQuoteKyc.quote.provider.id,
|
|
801
|
+
kycStatus: {
|
|
802
|
+
[KycSchema.PersonalDataAndDocuments]: fcKycStatus,
|
|
803
|
+
},
|
|
804
|
+
},
|
|
805
|
+
],
|
|
806
|
+
{ call: provideDelay },
|
|
807
|
+
])
|
|
808
|
+
.put(selectFiatConnectQuoteCompleted())
|
|
809
|
+
.run()
|
|
810
|
+
|
|
811
|
+
expect(navigate).toHaveBeenCalledWith(Screens.KycInactive, {
|
|
812
|
+
flow: normalizedQuoteKyc.flow,
|
|
813
|
+
quote: normalizedQuoteKyc,
|
|
814
|
+
})
|
|
815
|
+
}
|
|
816
|
+
)
|
|
817
|
+
it('navigates to KycExpired screen early if KYC is required and is expired', async () => {
|
|
818
|
+
await expectSaga(
|
|
819
|
+
handleSelectFiatConnectQuote,
|
|
820
|
+
selectFiatConnectQuote({ quote: normalizedQuoteKyc })
|
|
821
|
+
)
|
|
822
|
+
.provide([
|
|
823
|
+
[
|
|
824
|
+
matches.call.fn(getKycStatus),
|
|
825
|
+
{
|
|
826
|
+
providerId: normalizedQuoteKyc.quote.provider.id,
|
|
827
|
+
kycStatus: {
|
|
828
|
+
[KycSchema.PersonalDataAndDocuments]: FiatConnectKycStatus.KycExpired,
|
|
829
|
+
},
|
|
830
|
+
},
|
|
831
|
+
],
|
|
832
|
+
{ call: provideDelay },
|
|
833
|
+
])
|
|
834
|
+
.put(selectFiatConnectQuoteCompleted())
|
|
835
|
+
.run()
|
|
836
|
+
expect(navigate).toHaveBeenCalledWith(Screens.KycExpired, {
|
|
837
|
+
flow: normalizedQuoteKyc.flow,
|
|
838
|
+
quote: normalizedQuoteKyc,
|
|
839
|
+
})
|
|
840
|
+
})
|
|
841
|
+
it('navigates to KycDenied screen early if KYC is required and is denied', async () => {
|
|
842
|
+
await expectSaga(
|
|
843
|
+
handleSelectFiatConnectQuote,
|
|
844
|
+
selectFiatConnectQuote({ quote: normalizedQuoteKyc })
|
|
845
|
+
)
|
|
846
|
+
.provide([
|
|
847
|
+
[
|
|
848
|
+
matches.call.fn(getKycStatus),
|
|
849
|
+
{
|
|
850
|
+
providerId: normalizedQuoteKyc.quote.provider.id,
|
|
851
|
+
kycStatus: {
|
|
852
|
+
[KycSchema.PersonalDataAndDocuments]: FiatConnectKycStatus.KycDenied,
|
|
853
|
+
},
|
|
854
|
+
},
|
|
855
|
+
],
|
|
856
|
+
{ call: provideDelay },
|
|
857
|
+
])
|
|
858
|
+
.put(selectFiatConnectQuoteCompleted())
|
|
859
|
+
.run()
|
|
860
|
+
expect(navigate).toHaveBeenCalledWith(Screens.KycDenied, {
|
|
861
|
+
flow: normalizedQuoteKyc.flow,
|
|
862
|
+
quote: normalizedQuoteKyc,
|
|
863
|
+
retryable: true,
|
|
864
|
+
})
|
|
865
|
+
})
|
|
866
|
+
it('navigates to KYC inactive screen early if KYC is required', async () => {
|
|
867
|
+
await expectSaga(
|
|
868
|
+
handleSelectFiatConnectQuote,
|
|
869
|
+
selectFiatConnectQuote({ quote: normalizedQuoteKyc })
|
|
870
|
+
)
|
|
871
|
+
.provide([
|
|
872
|
+
[
|
|
873
|
+
matches.call.fn(getKycStatus),
|
|
874
|
+
{
|
|
875
|
+
providerId: normalizedQuoteKyc.quote.provider.id,
|
|
876
|
+
kycStatus: {
|
|
877
|
+
[KycSchema.PersonalDataAndDocuments]: FiatConnectKycStatus.KycNotCreated,
|
|
878
|
+
},
|
|
879
|
+
},
|
|
880
|
+
],
|
|
881
|
+
{ call: provideDelay },
|
|
882
|
+
])
|
|
883
|
+
.put(selectFiatConnectQuoteCompleted())
|
|
884
|
+
.run()
|
|
885
|
+
expect(navigate).toHaveBeenCalledWith(Screens.KycInactive, {
|
|
886
|
+
flow: normalizedQuoteKyc.flow,
|
|
887
|
+
quote: normalizedQuoteKyc,
|
|
888
|
+
})
|
|
889
|
+
})
|
|
890
|
+
|
|
891
|
+
it('goes back to SelectProvider if FC KYC status is not recognized', async () => {
|
|
892
|
+
await expectSaga(
|
|
893
|
+
handleSelectFiatConnectQuote,
|
|
894
|
+
selectFiatConnectQuote({ quote: normalizedQuoteKyc })
|
|
895
|
+
)
|
|
896
|
+
.provide([
|
|
897
|
+
[
|
|
898
|
+
matches.call.fn(getKycStatus),
|
|
899
|
+
{
|
|
900
|
+
providerId: normalizedQuoteKyc.quote.provider.id,
|
|
901
|
+
kycStatus: {
|
|
902
|
+
[KycSchema.PersonalDataAndDocuments]: 'badKyc',
|
|
903
|
+
},
|
|
904
|
+
},
|
|
905
|
+
],
|
|
906
|
+
{ call: provideDelay },
|
|
907
|
+
])
|
|
908
|
+
.put(selectFiatConnectQuoteCompleted())
|
|
909
|
+
.put(showError(ErrorMessages.PROVIDER_FETCH_FAILED))
|
|
910
|
+
.run()
|
|
911
|
+
expect(navigate).toHaveBeenCalledWith(Screens.SelectProvider, {
|
|
912
|
+
flow: normalizedQuoteKyc.flow,
|
|
913
|
+
amount: {
|
|
914
|
+
crypto: parseFloat(normalizedQuoteKyc.getCryptoAmount()),
|
|
915
|
+
fiat: parseFloat(normalizedQuoteKyc.getFiatAmount()),
|
|
916
|
+
},
|
|
917
|
+
tokenId: mockCusdTokenId,
|
|
918
|
+
})
|
|
919
|
+
})
|
|
920
|
+
it('invokes _checkFiatAccountAndNavigate directly if KYC is not required', async () => {
|
|
921
|
+
await expectSaga(
|
|
922
|
+
handleSelectFiatConnectQuote,
|
|
923
|
+
selectFiatConnectQuote({ quote: normalizedQuote })
|
|
924
|
+
)
|
|
925
|
+
.provide([
|
|
926
|
+
[matches.call.fn(_checkFiatAccountAndNavigate), undefined],
|
|
927
|
+
{ call: provideDelay },
|
|
928
|
+
])
|
|
929
|
+
.put(selectFiatConnectQuoteCompleted())
|
|
930
|
+
.call(_checkFiatAccountAndNavigate, {
|
|
931
|
+
quote: normalizedQuote,
|
|
932
|
+
isKycRequired: false,
|
|
933
|
+
isKycApproved: false,
|
|
934
|
+
})
|
|
935
|
+
.run()
|
|
936
|
+
})
|
|
937
|
+
it('shows an error and goes back to SelectProvider if _checkFiatAccountAndNavigate throws', async () => {
|
|
938
|
+
await expectSaga(
|
|
939
|
+
handleSelectFiatConnectQuote,
|
|
940
|
+
selectFiatConnectQuote({ quote: normalizedQuote })
|
|
941
|
+
)
|
|
942
|
+
.provide([
|
|
943
|
+
[
|
|
944
|
+
matches.call.fn(_checkFiatAccountAndNavigate),
|
|
945
|
+
throwError(new Error('failed to fetch fiat account')),
|
|
946
|
+
],
|
|
947
|
+
])
|
|
948
|
+
.put(selectFiatConnectQuoteCompleted())
|
|
949
|
+
.put(showError(ErrorMessages.PROVIDER_FETCH_FAILED))
|
|
950
|
+
.run()
|
|
951
|
+
expect(navigate).toHaveBeenCalledWith(Screens.SelectProvider, {
|
|
952
|
+
flow: normalizedQuote.flow,
|
|
953
|
+
amount: {
|
|
954
|
+
crypto: parseFloat(normalizedQuote.getCryptoAmount()),
|
|
955
|
+
fiat: parseFloat(normalizedQuote.getFiatAmount()),
|
|
956
|
+
},
|
|
957
|
+
tokenId: mockCusdTokenId,
|
|
958
|
+
})
|
|
959
|
+
})
|
|
960
|
+
})
|
|
961
|
+
|
|
962
|
+
describe('handlePostKyc', () => {
|
|
963
|
+
it('posts kyc, caches quote params and invokes _checkFiatAccountAndNavigate', async () => {
|
|
964
|
+
await expectSaga(handlePostKyc, postKycAction({ quote: normalizedQuoteKyc }))
|
|
965
|
+
.provide([
|
|
966
|
+
[matches.call.fn(postKyc), undefined],
|
|
967
|
+
[matches.call.fn(_checkFiatAccountAndNavigate), undefined],
|
|
968
|
+
])
|
|
969
|
+
.call(postKyc, {
|
|
970
|
+
providerInfo: normalizedQuoteKyc.getProviderInfo(),
|
|
971
|
+
kycSchema: normalizedQuoteKyc.getKycSchema(),
|
|
972
|
+
})
|
|
973
|
+
.call(_checkFiatAccountAndNavigate, {
|
|
974
|
+
quote: normalizedQuoteKyc,
|
|
975
|
+
isKycRequired: true,
|
|
976
|
+
isKycApproved: false,
|
|
977
|
+
})
|
|
978
|
+
.put(cacheQuoteParams(expectedCacheQuoteParams))
|
|
979
|
+
.run()
|
|
980
|
+
})
|
|
981
|
+
it('navigates to SelectProvider if post kyc fails', async () => {
|
|
982
|
+
await expectSaga(handlePostKyc, postKycAction({ quote: normalizedQuoteKyc }))
|
|
983
|
+
.provide([
|
|
984
|
+
[matches.call.fn(postKyc), throwError(new Error('post kyc failed'))],
|
|
985
|
+
{ call: provideDelay },
|
|
986
|
+
])
|
|
987
|
+
.call(postKyc, {
|
|
988
|
+
providerInfo: normalizedQuoteKyc.getProviderInfo(),
|
|
989
|
+
kycSchema: normalizedQuoteKyc.getKycSchema(),
|
|
990
|
+
})
|
|
991
|
+
.put(showError(ErrorMessages.PROVIDER_FETCH_FAILED))
|
|
992
|
+
.run()
|
|
993
|
+
expect(navigate).toHaveBeenCalledWith(Screens.SelectProvider, {
|
|
994
|
+
flow: normalizedQuoteKyc.flow,
|
|
995
|
+
amount: {
|
|
996
|
+
crypto: parseFloat(normalizedQuoteKyc.getCryptoAmount()),
|
|
997
|
+
fiat: parseFloat(normalizedQuoteKyc.getFiatAmount()),
|
|
998
|
+
},
|
|
999
|
+
tokenId: mockCusdTokenId,
|
|
1000
|
+
})
|
|
1001
|
+
})
|
|
1002
|
+
it('navigates to SelectProvider if _checkFiatAccountAndNavigate throws', async () => {
|
|
1003
|
+
await expectSaga(handlePostKyc, postKycAction({ quote: normalizedQuoteKyc }))
|
|
1004
|
+
.provide([
|
|
1005
|
+
[matches.call.fn(postKyc), undefined],
|
|
1006
|
+
[matches.call.fn(_checkFiatAccountAndNavigate), throwError(new Error('failed'))],
|
|
1007
|
+
{ call: provideDelay },
|
|
1008
|
+
])
|
|
1009
|
+
.call(postKyc, {
|
|
1010
|
+
providerInfo: normalizedQuoteKyc.getProviderInfo(),
|
|
1011
|
+
kycSchema: normalizedQuoteKyc.getKycSchema(),
|
|
1012
|
+
})
|
|
1013
|
+
.call(_checkFiatAccountAndNavigate, {
|
|
1014
|
+
quote: normalizedQuoteKyc,
|
|
1015
|
+
isKycRequired: true,
|
|
1016
|
+
isKycApproved: false,
|
|
1017
|
+
})
|
|
1018
|
+
.put(cacheQuoteParams(expectedCacheQuoteParams))
|
|
1019
|
+
.put(showError(ErrorMessages.PROVIDER_FETCH_FAILED))
|
|
1020
|
+
.run()
|
|
1021
|
+
expect(navigate).toHaveBeenCalledWith(Screens.SelectProvider, {
|
|
1022
|
+
flow: normalizedQuoteKyc.flow,
|
|
1023
|
+
amount: {
|
|
1024
|
+
crypto: parseFloat(normalizedQuoteKyc.getCryptoAmount()),
|
|
1025
|
+
fiat: parseFloat(normalizedQuoteKyc.getFiatAmount()),
|
|
1026
|
+
},
|
|
1027
|
+
tokenId: mockCusdTokenId,
|
|
1028
|
+
})
|
|
1029
|
+
})
|
|
1030
|
+
})
|
|
1031
|
+
|
|
1032
|
+
describe('_checkFiatAccountAndNavigate', () => {
|
|
1033
|
+
const fiatAccount = {
|
|
1034
|
+
fiatAccountId: '123',
|
|
1035
|
+
providerId: 'provider-two',
|
|
1036
|
+
accountName: 'provider two',
|
|
1037
|
+
institutionName: 'The fun bank',
|
|
1038
|
+
fiatAccountType: FiatAccountType.BankAccount, // matching fiatAccount type
|
|
1039
|
+
fiatAccountSchema: FiatAccountSchema.AccountNumber,
|
|
1040
|
+
}
|
|
1041
|
+
const expectedGetFiatAccountArgs = (quote: FiatConnectQuote) => ({
|
|
1042
|
+
fiatConnectProviders: [quote.getProviderInfo()],
|
|
1043
|
+
providerId: quote.getProviderId(),
|
|
1044
|
+
fiatAccountType: quote.getFiatAccountType(),
|
|
1045
|
+
fiatAccountSchema: quote.getFiatAccountSchema(),
|
|
1046
|
+
})
|
|
1047
|
+
const expectedFiatConnectUsedArgs = (quote: FiatConnectQuote) => ({
|
|
1048
|
+
providerId: quote.getProviderId(),
|
|
1049
|
+
fiatAccountId: fiatAccount.fiatAccountId,
|
|
1050
|
+
fiatAccountType: quote.getFiatAccountType(),
|
|
1051
|
+
fiatAccountSchema: quote.getFiatAccountSchema(),
|
|
1052
|
+
flow: quote.flow,
|
|
1053
|
+
cryptoType: quote.getCryptoCurrency(),
|
|
1054
|
+
fiatType: quote.getFiatType(),
|
|
1055
|
+
})
|
|
1056
|
+
it('navigates to step two of kyc landing if kyc is required and fiat account is not found', async () => {
|
|
1057
|
+
await expectSaga(_checkFiatAccountAndNavigate, {
|
|
1058
|
+
quote: normalizedQuoteKyc,
|
|
1059
|
+
isKycRequired: true,
|
|
1060
|
+
isKycApproved: false,
|
|
1061
|
+
})
|
|
1062
|
+
.provide([[matches.call.fn(_getFiatAccount), null]])
|
|
1063
|
+
.call(_getFiatAccount, expectedGetFiatAccountArgs(normalizedQuoteKyc))
|
|
1064
|
+
.run()
|
|
1065
|
+
expect(navigate).toHaveBeenCalledWith(Screens.KycInactive, {
|
|
1066
|
+
flow: normalizedQuoteKyc.flow,
|
|
1067
|
+
quote: normalizedQuoteKyc,
|
|
1068
|
+
})
|
|
1069
|
+
})
|
|
1070
|
+
it('navigates to link account if kyc is not required and fiat account is not found', async () => {
|
|
1071
|
+
await expectSaga(_checkFiatAccountAndNavigate, {
|
|
1072
|
+
quote: normalizedQuote,
|
|
1073
|
+
isKycRequired: false,
|
|
1074
|
+
isKycApproved: false,
|
|
1075
|
+
})
|
|
1076
|
+
.provide([[matches.call.fn(_getFiatAccount), null], { call: provideDelay }])
|
|
1077
|
+
.call(_getFiatAccount, expectedGetFiatAccountArgs(normalizedQuote))
|
|
1078
|
+
.run()
|
|
1079
|
+
expect(navigate).toHaveBeenCalledWith(Screens.FiatConnectLinkAccount, {
|
|
1080
|
+
flow: normalizedQuote.flow,
|
|
1081
|
+
quote: normalizedQuote,
|
|
1082
|
+
})
|
|
1083
|
+
})
|
|
1084
|
+
it('saves fiat account and navigates to review screen if kyc is not required and fiat account is found', async () => {
|
|
1085
|
+
await expectSaga(_checkFiatAccountAndNavigate, {
|
|
1086
|
+
quote: normalizedQuote,
|
|
1087
|
+
isKycRequired: false,
|
|
1088
|
+
isKycApproved: false,
|
|
1089
|
+
})
|
|
1090
|
+
.provide([[matches.call.fn(_getFiatAccount), fiatAccount], { call: provideDelay }])
|
|
1091
|
+
.call(_getFiatAccount, expectedGetFiatAccountArgs(normalizedQuote))
|
|
1092
|
+
.put(fiatAccountUsed(expectedFiatConnectUsedArgs(normalizedQuote)))
|
|
1093
|
+
.run()
|
|
1094
|
+
expect(navigate).toHaveBeenCalledWith(Screens.FiatConnectReview, {
|
|
1095
|
+
normalizedQuote,
|
|
1096
|
+
flow: normalizedQuote.flow,
|
|
1097
|
+
fiatAccount,
|
|
1098
|
+
})
|
|
1099
|
+
})
|
|
1100
|
+
it('saves fiat account and navigates to review screen if kyc is required and approved and fiat account is found', async () => {
|
|
1101
|
+
await expectSaga(_checkFiatAccountAndNavigate, {
|
|
1102
|
+
quote: normalizedQuoteKyc,
|
|
1103
|
+
isKycRequired: true,
|
|
1104
|
+
isKycApproved: true,
|
|
1105
|
+
})
|
|
1106
|
+
.provide([[matches.call.fn(_getFiatAccount), fiatAccount], { call: provideDelay }])
|
|
1107
|
+
.call(_getFiatAccount, expectedGetFiatAccountArgs(normalizedQuoteKyc))
|
|
1108
|
+
.put(fiatAccountUsed(expectedFiatConnectUsedArgs(normalizedQuoteKyc)))
|
|
1109
|
+
.run()
|
|
1110
|
+
expect(navigate).toHaveBeenCalledWith(Screens.FiatConnectReview, {
|
|
1111
|
+
normalizedQuote: normalizedQuoteKyc,
|
|
1112
|
+
flow: normalizedQuoteKyc.flow,
|
|
1113
|
+
fiatAccount,
|
|
1114
|
+
})
|
|
1115
|
+
})
|
|
1116
|
+
it('saves fiat account and navigates to pending screen if kyc is required and pending and fiat account is found', async () => {
|
|
1117
|
+
await expectSaga(_checkFiatAccountAndNavigate, {
|
|
1118
|
+
quote: normalizedQuoteKyc,
|
|
1119
|
+
isKycRequired: true,
|
|
1120
|
+
isKycApproved: false,
|
|
1121
|
+
})
|
|
1122
|
+
.provide([[matches.call.fn(_getFiatAccount), fiatAccount], { call: provideDelay }])
|
|
1123
|
+
.call(_getFiatAccount, expectedGetFiatAccountArgs(normalizedQuoteKyc))
|
|
1124
|
+
.put(fiatAccountUsed(expectedFiatConnectUsedArgs(normalizedQuoteKyc)))
|
|
1125
|
+
.run()
|
|
1126
|
+
expect(navigate).toHaveBeenCalledWith(Screens.KycPending, {
|
|
1127
|
+
flow: normalizedQuoteKyc.flow,
|
|
1128
|
+
quote: normalizedQuoteKyc,
|
|
1129
|
+
})
|
|
1130
|
+
})
|
|
1131
|
+
})
|
|
1132
|
+
|
|
1133
|
+
describe('handleFetchFiatConnectProviders', () => {
|
|
1134
|
+
it('saves on success', async () => {
|
|
1135
|
+
jest.mocked(getFiatConnectProviders).mockResolvedValue(mockFiatConnectProviderInfo)
|
|
1136
|
+
await expectSaga(handleFetchFiatConnectProviders)
|
|
1137
|
+
.provide([[select(walletAddressSelector), '0xabc']])
|
|
1138
|
+
.put(fetchFiatConnectProvidersCompleted({ providers: mockFiatConnectProviderInfo }))
|
|
1139
|
+
.run()
|
|
1140
|
+
expect(getFiatConnectProviders).toHaveBeenCalledWith('0xabc')
|
|
1141
|
+
})
|
|
1142
|
+
it('fails when account is null', async () => {
|
|
1143
|
+
jest.mocked(getFiatConnectProviders).mockResolvedValue(mockFiatConnectProviderInfo)
|
|
1144
|
+
await expectSaga(handleFetchFiatConnectProviders)
|
|
1145
|
+
.provide([[select(walletAddressSelector), null]])
|
|
1146
|
+
.put(fetchFiatConnectProvidersFailed())
|
|
1147
|
+
.run()
|
|
1148
|
+
expect(getFiatConnectProviders).not.toHaveBeenCalled()
|
|
1149
|
+
expect(Logger.error).toHaveBeenCalled()
|
|
1150
|
+
})
|
|
1151
|
+
it('fails when getProviders fails', async () => {
|
|
1152
|
+
jest.mocked(getFiatConnectProviders).mockRejectedValue(new Error('error'))
|
|
1153
|
+
await expectSaga(handleFetchFiatConnectProviders)
|
|
1154
|
+
.provide([[select(walletAddressSelector), '0xabc']])
|
|
1155
|
+
.put(fetchFiatConnectProvidersFailed())
|
|
1156
|
+
.run()
|
|
1157
|
+
expect(getFiatConnectProviders).toHaveBeenCalledWith('0xabc')
|
|
1158
|
+
expect(Logger.error).toHaveBeenCalled()
|
|
1159
|
+
})
|
|
1160
|
+
})
|
|
1161
|
+
|
|
1162
|
+
describe('handleRefetchQuote', () => {
|
|
1163
|
+
const fiatAccount = {
|
|
1164
|
+
fiatAccountId: '123',
|
|
1165
|
+
providerId: 'provider-two',
|
|
1166
|
+
accountName: 'provider two',
|
|
1167
|
+
institutionName: 'The fun bank',
|
|
1168
|
+
fiatAccountType: FiatAccountType.BankAccount,
|
|
1169
|
+
fiatAccountSchema: FiatAccountSchema.AccountNumber,
|
|
1170
|
+
}
|
|
1171
|
+
const quote = new FiatConnectQuote({
|
|
1172
|
+
flow: CICOFlow.CashOut,
|
|
1173
|
+
fiatAccountType: FiatAccountType.BankAccount,
|
|
1174
|
+
quote: mockFiatConnectQuotes[1] as FiatConnectQuoteSuccess,
|
|
1175
|
+
tokenId: mockCusdTokenId,
|
|
1176
|
+
})
|
|
1177
|
+
const params = refetchQuote({
|
|
1178
|
+
flow: CICOFlow.CashOut,
|
|
1179
|
+
cryptoType: quote.getCryptoType(),
|
|
1180
|
+
cryptoAmount: quote.getCryptoAmount(),
|
|
1181
|
+
fiatAmount: quote.getFiatAmount(),
|
|
1182
|
+
providerId: quote.getProviderId(),
|
|
1183
|
+
fiatAccount,
|
|
1184
|
+
tokenId: quote.getTokenId(),
|
|
1185
|
+
})
|
|
1186
|
+
it('selects a cached fiat account from _getSpecificQuote if none is provided', async () => {
|
|
1187
|
+
const paramsWithoutFiatAccount = refetchQuote({
|
|
1188
|
+
flow: CICOFlow.CashOut,
|
|
1189
|
+
cryptoType: quote.getCryptoType(),
|
|
1190
|
+
cryptoAmount: quote.getCryptoAmount(),
|
|
1191
|
+
fiatAmount: quote.getFiatAmount(),
|
|
1192
|
+
providerId: quote.getProviderId(),
|
|
1193
|
+
tokenId: quote.getTokenId(),
|
|
1194
|
+
})
|
|
1195
|
+
await expectSaga(handleRefetchQuote, paramsWithoutFiatAccount)
|
|
1196
|
+
.provide([
|
|
1197
|
+
[
|
|
1198
|
+
call(_getSpecificQuote, {
|
|
1199
|
+
flow: params.payload.flow,
|
|
1200
|
+
digitalAsset: CiCoCurrency.cUSD,
|
|
1201
|
+
cryptoAmount: 100,
|
|
1202
|
+
fiatAmount: 100,
|
|
1203
|
+
providerId: params.payload.providerId,
|
|
1204
|
+
fiatAccount: undefined,
|
|
1205
|
+
tokenId: mockCusdTokenId,
|
|
1206
|
+
}),
|
|
1207
|
+
{
|
|
1208
|
+
normalizedQuote: quote,
|
|
1209
|
+
selectedFiatAccount: fiatAccount,
|
|
1210
|
+
},
|
|
1211
|
+
],
|
|
1212
|
+
])
|
|
1213
|
+
.put(refetchQuoteCompleted())
|
|
1214
|
+
.run()
|
|
1215
|
+
expect(navigate).toHaveBeenCalledWith(Screens.FiatConnectReview, {
|
|
1216
|
+
flow: params.payload.flow,
|
|
1217
|
+
normalizedQuote: quote,
|
|
1218
|
+
shouldRefetchQuote: false,
|
|
1219
|
+
fiatAccount,
|
|
1220
|
+
})
|
|
1221
|
+
})
|
|
1222
|
+
it('calls refetchQuoteFailed if the _getSpecificQuote throws an error', async () => {
|
|
1223
|
+
await expectSaga(handleRefetchQuote, params)
|
|
1224
|
+
.provide([
|
|
1225
|
+
[
|
|
1226
|
+
call(_getSpecificQuote, {
|
|
1227
|
+
digitalAsset: CiCoCurrency.cUSD,
|
|
1228
|
+
cryptoAmount: 100,
|
|
1229
|
+
fiatAmount: 100,
|
|
1230
|
+
flow: params.payload.flow,
|
|
1231
|
+
providerId: params.payload.providerId,
|
|
1232
|
+
fiatAccount,
|
|
1233
|
+
tokenId: mockCusdTokenId,
|
|
1234
|
+
}),
|
|
1235
|
+
throwError(new Error('Could not find quote')),
|
|
1236
|
+
],
|
|
1237
|
+
])
|
|
1238
|
+
.put(refetchQuoteFailed({ error: 'could not refetch quote' }))
|
|
1239
|
+
.run()
|
|
1240
|
+
})
|
|
1241
|
+
it('navigates to FiatConnectReview when _getSpecificQuote returns the quote', async () => {
|
|
1242
|
+
await expectSaga(handleRefetchQuote, params)
|
|
1243
|
+
.provide([
|
|
1244
|
+
[
|
|
1245
|
+
call(_getSpecificQuote, {
|
|
1246
|
+
flow: params.payload.flow,
|
|
1247
|
+
digitalAsset: CiCoCurrency.cUSD,
|
|
1248
|
+
cryptoAmount: 100,
|
|
1249
|
+
fiatAmount: 100,
|
|
1250
|
+
providerId: params.payload.providerId,
|
|
1251
|
+
fiatAccount,
|
|
1252
|
+
tokenId: mockCusdTokenId,
|
|
1253
|
+
}),
|
|
1254
|
+
{
|
|
1255
|
+
normalizedQuote: quote,
|
|
1256
|
+
selectedFiatAccount: fiatAccount,
|
|
1257
|
+
},
|
|
1258
|
+
],
|
|
1259
|
+
])
|
|
1260
|
+
.put(refetchQuoteCompleted())
|
|
1261
|
+
.run()
|
|
1262
|
+
expect(navigate).toHaveBeenCalledWith(Screens.FiatConnectReview, {
|
|
1263
|
+
flow: params.payload.flow,
|
|
1264
|
+
normalizedQuote: quote,
|
|
1265
|
+
shouldRefetchQuote: false,
|
|
1266
|
+
fiatAccount,
|
|
1267
|
+
})
|
|
1268
|
+
})
|
|
1269
|
+
})
|
|
1270
|
+
|
|
1271
|
+
describe('handleAttemptReturnUserFlow', () => {
|
|
1272
|
+
const selectProviderParams = {
|
|
1273
|
+
amount: {
|
|
1274
|
+
crypto: 2,
|
|
1275
|
+
fiat: 2,
|
|
1276
|
+
},
|
|
1277
|
+
flow: CICOFlow.CashOut,
|
|
1278
|
+
tokenId: mockCusdTokenId,
|
|
1279
|
+
}
|
|
1280
|
+
const params = attemptReturnUserFlow({
|
|
1281
|
+
...selectProviderParams,
|
|
1282
|
+
providerId: 'provider-two',
|
|
1283
|
+
fiatAccountId: '123',
|
|
1284
|
+
fiatAccountType: FiatAccountType.BankAccount,
|
|
1285
|
+
fiatAccountSchema: FiatAccountSchema.AccountNumber,
|
|
1286
|
+
selectedCrypto: CiCoCurrency.cUSD,
|
|
1287
|
+
})
|
|
1288
|
+
const paramsKyc = attemptReturnUserFlow({
|
|
1289
|
+
...selectProviderParams,
|
|
1290
|
+
providerId: 'provider-three',
|
|
1291
|
+
fiatAccountId: '123',
|
|
1292
|
+
fiatAccountType: FiatAccountType.BankAccount,
|
|
1293
|
+
fiatAccountSchema: FiatAccountSchema.AccountNumber,
|
|
1294
|
+
selectedCrypto: CiCoCurrency.cUSD,
|
|
1295
|
+
})
|
|
1296
|
+
const fiatAccount = {
|
|
1297
|
+
fiatAccountId: '123',
|
|
1298
|
+
accountName: 'My account',
|
|
1299
|
+
institutionName: 'The fun bank',
|
|
1300
|
+
providerId: 'provider-two',
|
|
1301
|
+
fiatAccountType: FiatAccountType.BankAccount,
|
|
1302
|
+
fiatAccountSchema: FiatAccountSchema.AccountNumber,
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
const fiatAccountKyc = {
|
|
1306
|
+
...fiatAccount,
|
|
1307
|
+
providerId: 'provider-three',
|
|
1308
|
+
}
|
|
1309
|
+
it('navigates to SelectProvider when there is no quote', async () => {
|
|
1310
|
+
await expectSaga(handleAttemptReturnUserFlow, params)
|
|
1311
|
+
.provide([
|
|
1312
|
+
[select(fiatConnectProvidersSelector), mockFiatConnectProviderInfo],
|
|
1313
|
+
[
|
|
1314
|
+
call(fetchFiatAccountsSaga, 'provider-two', 'fakewebsite.example.com', 'fake-api-key'),
|
|
1315
|
+
[fiatAccount],
|
|
1316
|
+
],
|
|
1317
|
+
[
|
|
1318
|
+
call(_getSpecificQuote, {
|
|
1319
|
+
digitalAsset: CiCoCurrency.cUSD,
|
|
1320
|
+
cryptoAmount: 2,
|
|
1321
|
+
fiatAmount: 2,
|
|
1322
|
+
flow: params.payload.flow,
|
|
1323
|
+
providerId: params.payload.providerId,
|
|
1324
|
+
fiatAccount,
|
|
1325
|
+
tokenId: mockCusdTokenId,
|
|
1326
|
+
}),
|
|
1327
|
+
throwError(new Error('Could not find quote')),
|
|
1328
|
+
],
|
|
1329
|
+
])
|
|
1330
|
+
.put(attemptReturnUserFlowCompleted())
|
|
1331
|
+
.run()
|
|
1332
|
+
expect(navigate).toHaveBeenCalledWith(Screens.SelectProvider, selectProviderParams)
|
|
1333
|
+
expect(Logger.debug).toHaveBeenCalledWith(
|
|
1334
|
+
'FiatConnectSaga',
|
|
1335
|
+
'Failed to use previous fiatAccount to take user directly to Review Screen',
|
|
1336
|
+
new Error('Could not find quote')
|
|
1337
|
+
)
|
|
1338
|
+
})
|
|
1339
|
+
it('navigates to SelectProvider when the fiatAccount cannot be found', async () => {
|
|
1340
|
+
await expectSaga(handleAttemptReturnUserFlow, params)
|
|
1341
|
+
.provide([
|
|
1342
|
+
[select(fiatConnectProvidersSelector), mockFiatConnectProviderInfo],
|
|
1343
|
+
[
|
|
1344
|
+
call(_getSpecificQuote, {
|
|
1345
|
+
digitalAsset: CiCoCurrency.cUSD,
|
|
1346
|
+
cryptoAmount: 2,
|
|
1347
|
+
fiatAmount: 2,
|
|
1348
|
+
flow: params.payload.flow,
|
|
1349
|
+
providerId: params.payload.providerId,
|
|
1350
|
+
fiatAccount,
|
|
1351
|
+
tokenId: mockCusdTokenId,
|
|
1352
|
+
}),
|
|
1353
|
+
{
|
|
1354
|
+
normalizedQuote,
|
|
1355
|
+
selectedFiatAccount: fiatAccount,
|
|
1356
|
+
},
|
|
1357
|
+
],
|
|
1358
|
+
[
|
|
1359
|
+
call(fetchFiatAccountsSaga, 'provider-two', 'fakewebsite.example.com', 'fake-api-key'),
|
|
1360
|
+
[],
|
|
1361
|
+
],
|
|
1362
|
+
])
|
|
1363
|
+
.put(attemptReturnUserFlowCompleted())
|
|
1364
|
+
.run()
|
|
1365
|
+
expect(navigate).toHaveBeenCalledWith(Screens.SelectProvider, selectProviderParams)
|
|
1366
|
+
expect(Logger.debug).toHaveBeenCalledWith(
|
|
1367
|
+
'FiatConnectSaga',
|
|
1368
|
+
'Failed to use previous fiatAccount to take user directly to Review Screen',
|
|
1369
|
+
new Error('Could not find fiat account')
|
|
1370
|
+
)
|
|
1371
|
+
})
|
|
1372
|
+
it('navigates to FiatConnectReview when everything is found and matches for non KYC quote', async () => {
|
|
1373
|
+
await expectSaga(handleAttemptReturnUserFlow, params)
|
|
1374
|
+
.provide([
|
|
1375
|
+
[select(fiatConnectProvidersSelector), mockFiatConnectProviderInfo],
|
|
1376
|
+
[
|
|
1377
|
+
call(_getSpecificQuote, {
|
|
1378
|
+
digitalAsset: CiCoCurrency.cUSD,
|
|
1379
|
+
cryptoAmount: 2,
|
|
1380
|
+
fiatAmount: 2,
|
|
1381
|
+
flow: params.payload.flow,
|
|
1382
|
+
providerId: params.payload.providerId,
|
|
1383
|
+
fiatAccount,
|
|
1384
|
+
tokenId: mockCusdTokenId,
|
|
1385
|
+
}),
|
|
1386
|
+
{
|
|
1387
|
+
normalizedQuote,
|
|
1388
|
+
selectedFiatAccount: fiatAccount,
|
|
1389
|
+
},
|
|
1390
|
+
],
|
|
1391
|
+
[
|
|
1392
|
+
call(fetchFiatAccountsSaga, 'provider-two', 'fakewebsite.example.com', 'fake-api-key'),
|
|
1393
|
+
[fiatAccount],
|
|
1394
|
+
],
|
|
1395
|
+
])
|
|
1396
|
+
.put(attemptReturnUserFlowCompleted())
|
|
1397
|
+
.run()
|
|
1398
|
+
expect(navigate).toHaveBeenCalledWith(Screens.FiatConnectReview, {
|
|
1399
|
+
flow: CICOFlow.CashOut,
|
|
1400
|
+
normalizedQuote,
|
|
1401
|
+
fiatAccount,
|
|
1402
|
+
})
|
|
1403
|
+
})
|
|
1404
|
+
it('navigates to SelectProvider if quote requires KYC but KYC is not created with provider', async () => {
|
|
1405
|
+
await expectSaga(handleAttemptReturnUserFlow, paramsKyc)
|
|
1406
|
+
.provide([
|
|
1407
|
+
[select(fiatConnectProvidersSelector), mockFiatConnectProviderInfo],
|
|
1408
|
+
[
|
|
1409
|
+
call(_getSpecificQuote, {
|
|
1410
|
+
digitalAsset: CiCoCurrency.cUSD,
|
|
1411
|
+
cryptoAmount: 2,
|
|
1412
|
+
fiatAmount: 2,
|
|
1413
|
+
flow: paramsKyc.payload.flow,
|
|
1414
|
+
providerId: paramsKyc.payload.providerId,
|
|
1415
|
+
fiatAccount: fiatAccountKyc,
|
|
1416
|
+
tokenId: mockCusdTokenId,
|
|
1417
|
+
}),
|
|
1418
|
+
{
|
|
1419
|
+
normalizedQuote: normalizedQuoteKyc,
|
|
1420
|
+
selectedFiatAccount: fiatAccountKyc,
|
|
1421
|
+
},
|
|
1422
|
+
],
|
|
1423
|
+
[
|
|
1424
|
+
call(fetchFiatAccountsSaga, 'provider-three', 'fakewebsite.example.com', undefined),
|
|
1425
|
+
[fiatAccountKyc],
|
|
1426
|
+
],
|
|
1427
|
+
[
|
|
1428
|
+
call(getKycStatus, {
|
|
1429
|
+
providerInfo: normalizedQuoteKyc.getProviderInfo(),
|
|
1430
|
+
kycSchemas: [KycSchema.PersonalDataAndDocuments],
|
|
1431
|
+
}),
|
|
1432
|
+
{
|
|
1433
|
+
providerId: normalizedQuoteKyc.getProviderId(),
|
|
1434
|
+
kycStatus: {
|
|
1435
|
+
[KycSchema.PersonalDataAndDocuments]: FiatConnectKycStatus.KycNotCreated,
|
|
1436
|
+
},
|
|
1437
|
+
},
|
|
1438
|
+
],
|
|
1439
|
+
])
|
|
1440
|
+
.put(attemptReturnUserFlowCompleted())
|
|
1441
|
+
.run()
|
|
1442
|
+
expect(navigate).toHaveBeenCalledWith(Screens.SelectProvider, selectProviderParams)
|
|
1443
|
+
expect(Logger.debug).toHaveBeenCalledWith(
|
|
1444
|
+
'FiatConnectSaga',
|
|
1445
|
+
'Failed to use previous fiatAccount to take user directly to Review Screen',
|
|
1446
|
+
new Error('KYC not created')
|
|
1447
|
+
)
|
|
1448
|
+
})
|
|
1449
|
+
it('navigates to FiatConnectReview when everything is found and matches for KYC quote', async () => {
|
|
1450
|
+
await expectSaga(handleAttemptReturnUserFlow, paramsKyc)
|
|
1451
|
+
.provide([
|
|
1452
|
+
[select(fiatConnectProvidersSelector), mockFiatConnectProviderInfo],
|
|
1453
|
+
[
|
|
1454
|
+
call(_getSpecificQuote, {
|
|
1455
|
+
digitalAsset: CiCoCurrency.cUSD,
|
|
1456
|
+
cryptoAmount: 2,
|
|
1457
|
+
fiatAmount: 2,
|
|
1458
|
+
flow: paramsKyc.payload.flow,
|
|
1459
|
+
providerId: paramsKyc.payload.providerId,
|
|
1460
|
+
fiatAccount: fiatAccountKyc,
|
|
1461
|
+
tokenId: mockCusdTokenId,
|
|
1462
|
+
}),
|
|
1463
|
+
{
|
|
1464
|
+
normalizedQuote: normalizedQuoteKyc,
|
|
1465
|
+
selectedFiatAccount: fiatAccountKyc,
|
|
1466
|
+
},
|
|
1467
|
+
],
|
|
1468
|
+
[
|
|
1469
|
+
call(fetchFiatAccountsSaga, 'provider-three', 'fakewebsite.example.com', undefined),
|
|
1470
|
+
[fiatAccountKyc],
|
|
1471
|
+
],
|
|
1472
|
+
[
|
|
1473
|
+
call(getKycStatus, {
|
|
1474
|
+
providerInfo: normalizedQuoteKyc.getProviderInfo(),
|
|
1475
|
+
kycSchemas: [KycSchema.PersonalDataAndDocuments],
|
|
1476
|
+
}),
|
|
1477
|
+
{
|
|
1478
|
+
providerId: normalizedQuoteKyc.getProviderId(),
|
|
1479
|
+
kycStatus: {
|
|
1480
|
+
[KycSchema.PersonalDataAndDocuments]: FiatConnectKycStatus.KycApproved,
|
|
1481
|
+
},
|
|
1482
|
+
},
|
|
1483
|
+
],
|
|
1484
|
+
])
|
|
1485
|
+
.put(attemptReturnUserFlowCompleted())
|
|
1486
|
+
.run()
|
|
1487
|
+
expect(navigate).toHaveBeenCalledWith(Screens.FiatConnectReview, {
|
|
1488
|
+
flow: CICOFlow.CashOut,
|
|
1489
|
+
normalizedQuote: normalizedQuoteKyc,
|
|
1490
|
+
fiatAccount: fiatAccountKyc,
|
|
1491
|
+
})
|
|
1492
|
+
})
|
|
1493
|
+
it('navigates to KycPending if KYC is pending', async () => {
|
|
1494
|
+
await expectSaga(handleAttemptReturnUserFlow, paramsKyc)
|
|
1495
|
+
.provide([
|
|
1496
|
+
[select(fiatConnectProvidersSelector), mockFiatConnectProviderInfo],
|
|
1497
|
+
[
|
|
1498
|
+
call(_getSpecificQuote, {
|
|
1499
|
+
digitalAsset: CiCoCurrency.cUSD,
|
|
1500
|
+
cryptoAmount: 2,
|
|
1501
|
+
fiatAmount: 2,
|
|
1502
|
+
flow: paramsKyc.payload.flow,
|
|
1503
|
+
providerId: paramsKyc.payload.providerId,
|
|
1504
|
+
fiatAccount: fiatAccountKyc,
|
|
1505
|
+
tokenId: mockCusdTokenId,
|
|
1506
|
+
}),
|
|
1507
|
+
{
|
|
1508
|
+
normalizedQuote: normalizedQuoteKyc,
|
|
1509
|
+
selectedFiatAccount: fiatAccountKyc,
|
|
1510
|
+
},
|
|
1511
|
+
],
|
|
1512
|
+
[
|
|
1513
|
+
call(fetchFiatAccountsSaga, 'provider-three', 'fakewebsite.example.com', undefined),
|
|
1514
|
+
[fiatAccountKyc],
|
|
1515
|
+
],
|
|
1516
|
+
[
|
|
1517
|
+
call(getKycStatus, {
|
|
1518
|
+
providerInfo: normalizedQuoteKyc.getProviderInfo(),
|
|
1519
|
+
kycSchemas: [KycSchema.PersonalDataAndDocuments],
|
|
1520
|
+
}),
|
|
1521
|
+
{
|
|
1522
|
+
providerId: normalizedQuoteKyc.getProviderId(),
|
|
1523
|
+
kycStatus: {
|
|
1524
|
+
[KycSchema.PersonalDataAndDocuments]: FiatConnectKycStatus.KycPending,
|
|
1525
|
+
},
|
|
1526
|
+
},
|
|
1527
|
+
],
|
|
1528
|
+
])
|
|
1529
|
+
.put(attemptReturnUserFlowCompleted())
|
|
1530
|
+
.run()
|
|
1531
|
+
expect(navigate).toHaveBeenCalledWith(Screens.KycPending, {
|
|
1532
|
+
flow: paramsKyc.payload.flow,
|
|
1533
|
+
quote: normalizedQuoteKyc,
|
|
1534
|
+
})
|
|
1535
|
+
})
|
|
1536
|
+
it('navigates to KycExpired if KYC is expired', async () => {
|
|
1537
|
+
await expectSaga(handleAttemptReturnUserFlow, paramsKyc)
|
|
1538
|
+
.provide([
|
|
1539
|
+
[select(fiatConnectProvidersSelector), mockFiatConnectProviderInfo],
|
|
1540
|
+
[
|
|
1541
|
+
call(_getSpecificQuote, {
|
|
1542
|
+
digitalAsset: CiCoCurrency.cUSD,
|
|
1543
|
+
cryptoAmount: 2,
|
|
1544
|
+
fiatAmount: 2,
|
|
1545
|
+
flow: paramsKyc.payload.flow,
|
|
1546
|
+
providerId: paramsKyc.payload.providerId,
|
|
1547
|
+
fiatAccount: fiatAccountKyc,
|
|
1548
|
+
tokenId: mockCusdTokenId,
|
|
1549
|
+
}),
|
|
1550
|
+
{
|
|
1551
|
+
normalizedQuote: normalizedQuoteKyc,
|
|
1552
|
+
selectedFiatAccount: fiatAccountKyc,
|
|
1553
|
+
},
|
|
1554
|
+
],
|
|
1555
|
+
[
|
|
1556
|
+
call(fetchFiatAccountsSaga, 'provider-three', 'fakewebsite.example.com', undefined),
|
|
1557
|
+
[fiatAccountKyc],
|
|
1558
|
+
],
|
|
1559
|
+
[
|
|
1560
|
+
call(getKycStatus, {
|
|
1561
|
+
providerInfo: normalizedQuoteKyc.getProviderInfo(),
|
|
1562
|
+
kycSchemas: [KycSchema.PersonalDataAndDocuments],
|
|
1563
|
+
}),
|
|
1564
|
+
{
|
|
1565
|
+
providerId: normalizedQuoteKyc.getProviderId(),
|
|
1566
|
+
kycStatus: {
|
|
1567
|
+
[KycSchema.PersonalDataAndDocuments]: FiatConnectKycStatus.KycExpired,
|
|
1568
|
+
},
|
|
1569
|
+
},
|
|
1570
|
+
],
|
|
1571
|
+
])
|
|
1572
|
+
.put(attemptReturnUserFlowCompleted())
|
|
1573
|
+
.run()
|
|
1574
|
+
expect(navigate).toHaveBeenCalledWith(Screens.KycExpired, {
|
|
1575
|
+
flow: paramsKyc.payload.flow,
|
|
1576
|
+
quote: normalizedQuoteKyc,
|
|
1577
|
+
})
|
|
1578
|
+
})
|
|
1579
|
+
it('navigates to KycDenied if KYC is denied', async () => {
|
|
1580
|
+
await expectSaga(handleAttemptReturnUserFlow, paramsKyc)
|
|
1581
|
+
.provide([
|
|
1582
|
+
[select(fiatConnectProvidersSelector), mockFiatConnectProviderInfo],
|
|
1583
|
+
[
|
|
1584
|
+
call(_getSpecificQuote, {
|
|
1585
|
+
digitalAsset: CiCoCurrency.cUSD,
|
|
1586
|
+
cryptoAmount: 2,
|
|
1587
|
+
fiatAmount: 2,
|
|
1588
|
+
flow: paramsKyc.payload.flow,
|
|
1589
|
+
providerId: paramsKyc.payload.providerId,
|
|
1590
|
+
fiatAccount: fiatAccountKyc,
|
|
1591
|
+
tokenId: mockCusdTokenId,
|
|
1592
|
+
}),
|
|
1593
|
+
{
|
|
1594
|
+
normalizedQuote: normalizedQuoteKyc,
|
|
1595
|
+
selectedFiatAccount: fiatAccountKyc,
|
|
1596
|
+
},
|
|
1597
|
+
],
|
|
1598
|
+
[
|
|
1599
|
+
call(fetchFiatAccountsSaga, 'provider-three', 'fakewebsite.example.com', undefined),
|
|
1600
|
+
[fiatAccountKyc],
|
|
1601
|
+
],
|
|
1602
|
+
[
|
|
1603
|
+
call(getKycStatus, {
|
|
1604
|
+
providerInfo: normalizedQuoteKyc.getProviderInfo(),
|
|
1605
|
+
kycSchemas: [KycSchema.PersonalDataAndDocuments],
|
|
1606
|
+
}),
|
|
1607
|
+
{
|
|
1608
|
+
providerId: normalizedQuoteKyc.getProviderId(),
|
|
1609
|
+
kycStatus: {
|
|
1610
|
+
[KycSchema.PersonalDataAndDocuments]: FiatConnectKycStatus.KycDenied,
|
|
1611
|
+
},
|
|
1612
|
+
},
|
|
1613
|
+
],
|
|
1614
|
+
])
|
|
1615
|
+
.put(attemptReturnUserFlowCompleted())
|
|
1616
|
+
.run()
|
|
1617
|
+
expect(navigate).toHaveBeenCalledWith(Screens.KycDenied, {
|
|
1618
|
+
flow: paramsKyc.payload.flow,
|
|
1619
|
+
quote: normalizedQuoteKyc,
|
|
1620
|
+
retryable: true,
|
|
1621
|
+
})
|
|
1622
|
+
})
|
|
1623
|
+
})
|
|
1624
|
+
|
|
1625
|
+
describe('fetchFiatAccountsSaga', () => {
|
|
1626
|
+
const mockGetFiatAccounts = jest.fn()
|
|
1627
|
+
const mockFcClient = {
|
|
1628
|
+
getFiatAccounts: mockGetFiatAccounts,
|
|
1629
|
+
}
|
|
1630
|
+
it('throws when fetching the client errors', async () => {
|
|
1631
|
+
mockGetFiatAccounts.mockResolvedValueOnce(Result.err(new Error('error')))
|
|
1632
|
+
await expect(
|
|
1633
|
+
async () =>
|
|
1634
|
+
await expectSaga(
|
|
1635
|
+
fetchFiatAccountsSaga,
|
|
1636
|
+
'test-provider',
|
|
1637
|
+
'www.hello.example.com',
|
|
1638
|
+
undefined
|
|
1639
|
+
)
|
|
1640
|
+
.provide([
|
|
1641
|
+
[
|
|
1642
|
+
call(getFiatConnectClient, 'test-provider', 'www.hello.example.com', undefined),
|
|
1643
|
+
mockFcClient,
|
|
1644
|
+
],
|
|
1645
|
+
])
|
|
1646
|
+
.run()
|
|
1647
|
+
).rejects.toThrow()
|
|
1648
|
+
})
|
|
1649
|
+
it('returns the fiatAccounts when the call is successful', async () => {
|
|
1650
|
+
mockGetFiatAccounts.mockResolvedValue(
|
|
1651
|
+
Result.ok({
|
|
1652
|
+
BankAccount: [
|
|
1653
|
+
{
|
|
1654
|
+
fiatAccountId: '123',
|
|
1655
|
+
fiatAccountType: 'BankAccount',
|
|
1656
|
+
accountName: '(...1234)',
|
|
1657
|
+
institutionName: 'My Bank',
|
|
1658
|
+
},
|
|
1659
|
+
],
|
|
1660
|
+
})
|
|
1661
|
+
)
|
|
1662
|
+
await expectSaga(fetchFiatAccountsSaga, 'test-provider', 'www.hello.example.com', undefined)
|
|
1663
|
+
.provide([
|
|
1664
|
+
[
|
|
1665
|
+
call(getFiatConnectClient, 'test-provider', 'www.hello.example.com', undefined),
|
|
1666
|
+
mockFcClient,
|
|
1667
|
+
],
|
|
1668
|
+
])
|
|
1669
|
+
.returns([
|
|
1670
|
+
{
|
|
1671
|
+
fiatAccountId: '123',
|
|
1672
|
+
fiatAccountType: 'BankAccount',
|
|
1673
|
+
accountName: '(...1234)',
|
|
1674
|
+
institutionName: 'My Bank',
|
|
1675
|
+
providerId: 'test-provider',
|
|
1676
|
+
},
|
|
1677
|
+
])
|
|
1678
|
+
.run()
|
|
1679
|
+
})
|
|
1680
|
+
})
|
|
1681
|
+
|
|
1682
|
+
describe('_initiateTransferWithProvider', () => {
|
|
1683
|
+
const transferOutFcQuote = new FiatConnectQuote({
|
|
1684
|
+
flow: CICOFlow.CashOut,
|
|
1685
|
+
quote: mockFiatConnectQuotes[1] as FiatConnectQuoteSuccess,
|
|
1686
|
+
fiatAccountType: FiatAccountType.BankAccount,
|
|
1687
|
+
tokenId: mockCusdTokenId,
|
|
1688
|
+
})
|
|
1689
|
+
|
|
1690
|
+
const quoteId = transferOutFcQuote.getQuoteId()
|
|
1691
|
+
const providerId = transferOutFcQuote.getProviderId()
|
|
1692
|
+
const providerBaseUrl = transferOutFcQuote.getProviderBaseUrl()
|
|
1693
|
+
const providerApiKey = transferOutFcQuote.getProviderApiKey()
|
|
1694
|
+
|
|
1695
|
+
const mockTransferOut = jest.fn()
|
|
1696
|
+
const mockFcClient = {
|
|
1697
|
+
transferOut: mockTransferOut,
|
|
1698
|
+
}
|
|
1699
|
+
jest.mocked(uuidv4).mockReturnValue('mock-uuidv4')
|
|
1700
|
+
it('calls the fiatconnect transfer function and returns the transfer results', async () => {
|
|
1701
|
+
mockTransferOut.mockResolvedValueOnce(
|
|
1702
|
+
Result.ok({
|
|
1703
|
+
transferId: 'transfer1',
|
|
1704
|
+
transferStatus: TransferStatus.TransferReadyForUserToSendCryptoFunds,
|
|
1705
|
+
transferAddress: '0xabc',
|
|
1706
|
+
})
|
|
1707
|
+
)
|
|
1708
|
+
await expectSaga(
|
|
1709
|
+
_initiateTransferWithProvider,
|
|
1710
|
+
createFiatConnectTransfer({
|
|
1711
|
+
flow: CICOFlow.CashOut,
|
|
1712
|
+
fiatConnectQuote: transferOutFcQuote,
|
|
1713
|
+
fiatAccountId: 'account1',
|
|
1714
|
+
})
|
|
1715
|
+
)
|
|
1716
|
+
.provide([
|
|
1717
|
+
[call(getFiatConnectClient, providerId, providerBaseUrl, providerApiKey), mockFcClient],
|
|
1718
|
+
])
|
|
1719
|
+
.returns({
|
|
1720
|
+
transferId: 'transfer1',
|
|
1721
|
+
transferStatus: TransferStatus.TransferReadyForUserToSendCryptoFunds,
|
|
1722
|
+
transferAddress: '0xabc',
|
|
1723
|
+
})
|
|
1724
|
+
.run()
|
|
1725
|
+
|
|
1726
|
+
expect(mockTransferOut).toHaveBeenCalledWith({
|
|
1727
|
+
data: { fiatAccountId: 'account1', quoteId },
|
|
1728
|
+
idempotencyKey: 'mock-uuidv4',
|
|
1729
|
+
})
|
|
1730
|
+
expect(AppAnalytics.track).toHaveBeenCalledTimes(0)
|
|
1731
|
+
})
|
|
1732
|
+
it('throws when there is an error with the transfer', async () => {
|
|
1733
|
+
mockTransferOut.mockResolvedValueOnce(
|
|
1734
|
+
Result.err(
|
|
1735
|
+
new ResponseError('FiatConnect API Error', { error: FiatConnectError.Unauthorized })
|
|
1736
|
+
)
|
|
1737
|
+
)
|
|
1738
|
+
await expect(() =>
|
|
1739
|
+
expectSaga(
|
|
1740
|
+
_initiateTransferWithProvider,
|
|
1741
|
+
createFiatConnectTransfer({
|
|
1742
|
+
flow: CICOFlow.CashOut,
|
|
1743
|
+
fiatConnectQuote: transferOutFcQuote,
|
|
1744
|
+
fiatAccountId: 'account1',
|
|
1745
|
+
})
|
|
1746
|
+
)
|
|
1747
|
+
.provide([
|
|
1748
|
+
[call(getFiatConnectClient, providerId, providerBaseUrl, providerApiKey), mockFcClient],
|
|
1749
|
+
])
|
|
1750
|
+
.run()
|
|
1751
|
+
).rejects.toThrow()
|
|
1752
|
+
|
|
1753
|
+
expect(mockTransferOut).toHaveBeenCalledWith({
|
|
1754
|
+
data: { fiatAccountId: 'account1', quoteId },
|
|
1755
|
+
idempotencyKey: 'mock-uuidv4',
|
|
1756
|
+
})
|
|
1757
|
+
expect(AppAnalytics.track).toHaveBeenCalledTimes(1)
|
|
1758
|
+
expect(AppAnalytics.track).toHaveBeenCalledWith(
|
|
1759
|
+
FiatExchangeEvents.cico_fc_transfer_api_error,
|
|
1760
|
+
{
|
|
1761
|
+
provider: providerId,
|
|
1762
|
+
flow: CICOFlow.CashOut,
|
|
1763
|
+
fiatConnectError: FiatConnectError.Unauthorized,
|
|
1764
|
+
error: 'FiatConnect API Error',
|
|
1765
|
+
}
|
|
1766
|
+
)
|
|
1767
|
+
})
|
|
1768
|
+
})
|
|
1769
|
+
|
|
1770
|
+
describe('_initiateSendTxToProvider', () => {
|
|
1771
|
+
beforeEach(() => {
|
|
1772
|
+
jest.clearAllMocks()
|
|
1773
|
+
mockedSendPreparedTransactions.mockResolvedValue(['0x12345'])
|
|
1774
|
+
})
|
|
1775
|
+
|
|
1776
|
+
const transferOutFcQuote = new FiatConnectQuote({
|
|
1777
|
+
flow: CICOFlow.CashOut,
|
|
1778
|
+
quote: mockFiatConnectQuotes[1] as FiatConnectQuoteSuccess,
|
|
1779
|
+
fiatAccountType: FiatAccountType.BankAccount,
|
|
1780
|
+
tokenId: mockCusdTokenId,
|
|
1781
|
+
})
|
|
1782
|
+
const transferAddress = mockAccount2
|
|
1783
|
+
const mockSerializablePreparedTransaction: SerializableTransactionRequest = {
|
|
1784
|
+
gas: '51613',
|
|
1785
|
+
_baseFeePerGas: '25000000000',
|
|
1786
|
+
to: mockCusdAddress as Address,
|
|
1787
|
+
data: encodeFunctionData({
|
|
1788
|
+
abi: erc20Abi,
|
|
1789
|
+
functionName: 'transfer',
|
|
1790
|
+
args: [transferAddress, BigInt(100e18)],
|
|
1791
|
+
}),
|
|
1792
|
+
maxFeePerGas: '52000000000',
|
|
1793
|
+
maxPriorityFeePerGas: '2000000000',
|
|
1794
|
+
from: mockAccount3,
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
const cryptoTypeToInfo: Record<CryptoType, TokenBalance> = {
|
|
1798
|
+
// if this fails to build due to a missing key, add fixture data for the new key! Do NOT just update the type,
|
|
1799
|
+
// coverage for every CryptoType is important.
|
|
1800
|
+
[CryptoType.CELO]: mockCeloTokenBalance,
|
|
1801
|
+
[CryptoType.cUSD]: mockCusdTokenBalance,
|
|
1802
|
+
[CryptoType.cEUR]: mockCeurTokenBalance,
|
|
1803
|
+
[CryptoType.cREAL]: mockCrealTokenBalance,
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
it.each(Object.keys(CryptoType) as CryptoType[])(
|
|
1807
|
+
'able to send tx and get tx hash for CryptoType %s',
|
|
1808
|
+
async (cryptoType) => {
|
|
1809
|
+
const quote = {
|
|
1810
|
+
...(_.cloneDeep(mockFiatConnectQuotes[1]) as FiatConnectQuoteSuccess),
|
|
1811
|
+
tokenId: mockCusdTokenId,
|
|
1812
|
+
}
|
|
1813
|
+
quote.quote.cryptoType = cryptoType
|
|
1814
|
+
const fiatConnectQuote = new FiatConnectQuote({
|
|
1815
|
+
flow: CICOFlow.CashOut,
|
|
1816
|
+
quote,
|
|
1817
|
+
fiatAccountType: FiatAccountType.BankAccount,
|
|
1818
|
+
tokenId: mockCusdTokenId,
|
|
1819
|
+
})
|
|
1820
|
+
const tokenInfo = cryptoTypeToInfo[cryptoType]
|
|
1821
|
+
const serializablePreparedTransaction = {
|
|
1822
|
+
...mockSerializablePreparedTransaction,
|
|
1823
|
+
to: tokenInfo.address as Address,
|
|
1824
|
+
}
|
|
1825
|
+
await expectSaga(_initiateSendTxToProvider, {
|
|
1826
|
+
transferAddress,
|
|
1827
|
+
fiatConnectQuote,
|
|
1828
|
+
tokenInfo,
|
|
1829
|
+
serializablePreparedTransaction,
|
|
1830
|
+
})
|
|
1831
|
+
.returns('0x12345')
|
|
1832
|
+
.run()
|
|
1833
|
+
|
|
1834
|
+
expect(mockedSendPreparedTransactions).toHaveBeenCalledTimes(1)
|
|
1835
|
+
expect(mockedSendPreparedTransactions).toHaveBeenCalledWith(
|
|
1836
|
+
[serializablePreparedTransaction],
|
|
1837
|
+
NetworkId['celo-alfajores'],
|
|
1838
|
+
expect.arrayContaining([expect.any(Function)])
|
|
1839
|
+
)
|
|
1840
|
+
}
|
|
1841
|
+
)
|
|
1842
|
+
it('throws when there is an error (safe to retry) with the transaction', async () => {
|
|
1843
|
+
jest.mocked(isTxPossiblyPending).mockReturnValue(false)
|
|
1844
|
+
mockedSendPreparedTransactions.mockRejectedValue(new Error('error is safe to retry'))
|
|
1845
|
+
|
|
1846
|
+
await expect(() =>
|
|
1847
|
+
expectSaga(_initiateSendTxToProvider, {
|
|
1848
|
+
transferAddress: '0xabc',
|
|
1849
|
+
fiatConnectQuote: transferOutFcQuote,
|
|
1850
|
+
serializablePreparedTransaction: mockSerializablePreparedTransaction,
|
|
1851
|
+
tokenInfo: mockCusdTokenBalance,
|
|
1852
|
+
}).run()
|
|
1853
|
+
).rejects.toThrow(
|
|
1854
|
+
new FiatConnectTxError(
|
|
1855
|
+
'Error while attempting to send funds for FiatConnect transfer out',
|
|
1856
|
+
false,
|
|
1857
|
+
new Error('error is safe to retry')
|
|
1858
|
+
)
|
|
1859
|
+
)
|
|
1860
|
+
expect(AppAnalytics.track).toHaveBeenCalledTimes(1)
|
|
1861
|
+
expect(AppAnalytics.track).toHaveBeenCalledWith(
|
|
1862
|
+
FiatExchangeEvents.cico_fc_transfer_tx_error,
|
|
1863
|
+
{
|
|
1864
|
+
provider: transferOutFcQuote.getProviderId(),
|
|
1865
|
+
flow: CICOFlow.CashOut,
|
|
1866
|
+
transferAddress: '0xabc',
|
|
1867
|
+
error: 'error is safe to retry',
|
|
1868
|
+
}
|
|
1869
|
+
)
|
|
1870
|
+
})
|
|
1871
|
+
it('throws when there is a miscellanious error (not safe to retry) with the transaction', async () => {
|
|
1872
|
+
jest.mocked(isTxPossiblyPending).mockReturnValue(true)
|
|
1873
|
+
mockedSendPreparedTransactions.mockRejectedValue(new Error('unsafe error'))
|
|
1874
|
+
|
|
1875
|
+
await expect(() =>
|
|
1876
|
+
expectSaga(_initiateSendTxToProvider, {
|
|
1877
|
+
transferAddress: '0xabc',
|
|
1878
|
+
fiatConnectQuote: transferOutFcQuote,
|
|
1879
|
+
serializablePreparedTransaction: mockSerializablePreparedTransaction,
|
|
1880
|
+
tokenInfo: mockCusdTokenBalance,
|
|
1881
|
+
}).run()
|
|
1882
|
+
).rejects.toThrow(
|
|
1883
|
+
new FiatConnectTxError(
|
|
1884
|
+
'Error while attempting to send funds for FiatConnect transfer out',
|
|
1885
|
+
true,
|
|
1886
|
+
new Error('unsafe error')
|
|
1887
|
+
)
|
|
1888
|
+
)
|
|
1889
|
+
expect(AppAnalytics.track).toHaveBeenCalledTimes(1)
|
|
1890
|
+
expect(AppAnalytics.track).toHaveBeenCalledWith(
|
|
1891
|
+
FiatExchangeEvents.cico_fc_transfer_tx_error,
|
|
1892
|
+
{
|
|
1893
|
+
provider: transferOutFcQuote.getProviderId(),
|
|
1894
|
+
flow: CICOFlow.CashOut,
|
|
1895
|
+
transferAddress: '0xabc',
|
|
1896
|
+
error: 'unsafe error',
|
|
1897
|
+
}
|
|
1898
|
+
)
|
|
1899
|
+
})
|
|
1900
|
+
})
|
|
1901
|
+
|
|
1902
|
+
describe('handleCreateFiatConnectTransfer', () => {
|
|
1903
|
+
describe('TransferIn', () => {
|
|
1904
|
+
const transferInFcQuote = new FiatConnectQuote({
|
|
1905
|
+
flow: CICOFlow.CashIn,
|
|
1906
|
+
quote: mockFiatConnectQuotes[1] as FiatConnectQuoteSuccess,
|
|
1907
|
+
fiatAccountType: FiatAccountType.BankAccount,
|
|
1908
|
+
tokenId: mockCusdTokenId,
|
|
1909
|
+
})
|
|
1910
|
+
const transferAddress = '0x12345'
|
|
1911
|
+
it('calls transfer in', async () => {
|
|
1912
|
+
const action = createFiatConnectTransfer({
|
|
1913
|
+
flow: CICOFlow.CashIn,
|
|
1914
|
+
fiatConnectQuote: transferInFcQuote,
|
|
1915
|
+
fiatAccountId: 'account1',
|
|
1916
|
+
})
|
|
1917
|
+
await expectSaga(handleCreateFiatConnectTransfer, action)
|
|
1918
|
+
.provide([[call(_initiateTransferWithProvider, action), { transferAddress }]])
|
|
1919
|
+
.put(
|
|
1920
|
+
createFiatConnectTransferCompleted({
|
|
1921
|
+
flow: CICOFlow.CashIn,
|
|
1922
|
+
quoteId: transferInFcQuote.getQuoteId(),
|
|
1923
|
+
txHash: null,
|
|
1924
|
+
})
|
|
1925
|
+
)
|
|
1926
|
+
.run()
|
|
1927
|
+
expect(AppAnalytics.track).toHaveBeenCalledTimes(1)
|
|
1928
|
+
expect(AppAnalytics.track).toHaveBeenCalledWith(
|
|
1929
|
+
FiatExchangeEvents.cico_fc_transfer_success,
|
|
1930
|
+
{
|
|
1931
|
+
provider: transferInFcQuote.getProviderId(),
|
|
1932
|
+
flow: CICOFlow.CashIn,
|
|
1933
|
+
transferAddress,
|
|
1934
|
+
txHash: null,
|
|
1935
|
+
}
|
|
1936
|
+
)
|
|
1937
|
+
})
|
|
1938
|
+
})
|
|
1939
|
+
describe('TransferOut', () => {
|
|
1940
|
+
const transferOutFcQuote = new FiatConnectQuote({
|
|
1941
|
+
flow: CICOFlow.CashOut,
|
|
1942
|
+
quote: mockFiatConnectQuotes[1] as FiatConnectQuoteSuccess,
|
|
1943
|
+
fiatAccountType: FiatAccountType.BankAccount,
|
|
1944
|
+
tokenId: mockCusdTokenId,
|
|
1945
|
+
})
|
|
1946
|
+
const transferAddress = mockAccount2
|
|
1947
|
+
const transactionHash = '0xabc'
|
|
1948
|
+
const transferId = 'transferId12345'
|
|
1949
|
+
const fiatAccountId = 'account1'
|
|
1950
|
+
const networkId = NetworkId['celo-alfajores']
|
|
1951
|
+
const mockBaseSerializablePreparedTransaction: SerializableTransactionRequest = {
|
|
1952
|
+
gas: '51613',
|
|
1953
|
+
_baseFeePerGas: '25000000000',
|
|
1954
|
+
to: mockCusdAddress as Address,
|
|
1955
|
+
data: encodeFunctionData({
|
|
1956
|
+
abi: erc20Abi,
|
|
1957
|
+
functionName: 'transfer',
|
|
1958
|
+
args: [mockAccount3, BigInt(100e18)], // own account, 100 cUSD
|
|
1959
|
+
}),
|
|
1960
|
+
maxFeePerGas: '52000000000',
|
|
1961
|
+
maxPriorityFeePerGas: '2000000000',
|
|
1962
|
+
from: mockAccount3,
|
|
1963
|
+
}
|
|
1964
|
+
const mockFinalSerializablePreparedTransaction: SerializableTransactionRequest = {
|
|
1965
|
+
...mockBaseSerializablePreparedTransaction,
|
|
1966
|
+
data: encodeFunctionData({
|
|
1967
|
+
abi: erc20Abi,
|
|
1968
|
+
functionName: 'transfer',
|
|
1969
|
+
args: [transferAddress, BigInt(100e18)], // provider account, 100 cUSD
|
|
1970
|
+
}),
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
it('calls transfer out and initiates a transaction', async () => {
|
|
1974
|
+
const action = createFiatConnectTransfer({
|
|
1975
|
+
flow: CICOFlow.CashOut,
|
|
1976
|
+
fiatConnectQuote: transferOutFcQuote,
|
|
1977
|
+
fiatAccountId,
|
|
1978
|
+
serializablePreparedTransaction: mockBaseSerializablePreparedTransaction,
|
|
1979
|
+
networkId,
|
|
1980
|
+
})
|
|
1981
|
+
await expectSaga(handleCreateFiatConnectTransfer, action)
|
|
1982
|
+
.provide([
|
|
1983
|
+
[call(_initiateTransferWithProvider, action), { transferAddress, transferId }],
|
|
1984
|
+
[select(tokensByIdSelector), { [mockCusdTokenId]: mockCusdTokenBalance }],
|
|
1985
|
+
[
|
|
1986
|
+
call(_initiateSendTxToProvider, {
|
|
1987
|
+
transferAddress,
|
|
1988
|
+
fiatConnectQuote: transferOutFcQuote,
|
|
1989
|
+
tokenInfo: mockCusdTokenBalance,
|
|
1990
|
+
serializablePreparedTransaction: mockFinalSerializablePreparedTransaction,
|
|
1991
|
+
}),
|
|
1992
|
+
transactionHash,
|
|
1993
|
+
],
|
|
1994
|
+
])
|
|
1995
|
+
.put(
|
|
1996
|
+
cacheFiatConnectTransfer({
|
|
1997
|
+
txHash: transactionHash,
|
|
1998
|
+
transferId,
|
|
1999
|
+
fiatAccountId,
|
|
2000
|
+
providerId: transferOutFcQuote.getProviderId(),
|
|
2001
|
+
quote: transferOutFcQuote.quote.quote,
|
|
2002
|
+
})
|
|
2003
|
+
)
|
|
2004
|
+
.put(
|
|
2005
|
+
createFiatConnectTransferCompleted({
|
|
2006
|
+
flow: CICOFlow.CashOut,
|
|
2007
|
+
quoteId: transferOutFcQuote.getQuoteId(),
|
|
2008
|
+
txHash: transactionHash,
|
|
2009
|
+
})
|
|
2010
|
+
)
|
|
2011
|
+
.run()
|
|
2012
|
+
expect(AppAnalytics.track).toHaveBeenCalledTimes(1)
|
|
2013
|
+
expect(AppAnalytics.track).toHaveBeenCalledWith(
|
|
2014
|
+
FiatExchangeEvents.cico_fc_transfer_success,
|
|
2015
|
+
{
|
|
2016
|
+
provider: transferOutFcQuote.getProviderId(),
|
|
2017
|
+
flow: CICOFlow.CashOut,
|
|
2018
|
+
transferAddress,
|
|
2019
|
+
txHash: transactionHash,
|
|
2020
|
+
}
|
|
2021
|
+
)
|
|
2022
|
+
})
|
|
2023
|
+
it('sets transaction as pending when an unsafe error occurs', async () => {
|
|
2024
|
+
const action = createFiatConnectTransfer({
|
|
2025
|
+
flow: CICOFlow.CashOut,
|
|
2026
|
+
fiatConnectQuote: transferOutFcQuote,
|
|
2027
|
+
fiatAccountId: 'account1',
|
|
2028
|
+
serializablePreparedTransaction: mockBaseSerializablePreparedTransaction,
|
|
2029
|
+
networkId,
|
|
2030
|
+
})
|
|
2031
|
+
await expectSaga(handleCreateFiatConnectTransfer, action)
|
|
2032
|
+
.provide([
|
|
2033
|
+
[call(_initiateTransferWithProvider, action), { transferAddress }],
|
|
2034
|
+
[select(tokensByIdSelector), { [mockCusdTokenId]: mockCusdTokenBalance }],
|
|
2035
|
+
[
|
|
2036
|
+
call(_initiateSendTxToProvider, {
|
|
2037
|
+
transferAddress,
|
|
2038
|
+
fiatConnectQuote: transferOutFcQuote,
|
|
2039
|
+
tokenInfo: mockCusdTokenBalance,
|
|
2040
|
+
serializablePreparedTransaction: mockFinalSerializablePreparedTransaction,
|
|
2041
|
+
}),
|
|
2042
|
+
throwError(
|
|
2043
|
+
new FiatConnectTxError('some error', true, new Error('some internal error'))
|
|
2044
|
+
),
|
|
2045
|
+
],
|
|
2046
|
+
])
|
|
2047
|
+
.put(
|
|
2048
|
+
createFiatConnectTransferTxProcessing({
|
|
2049
|
+
flow: CICOFlow.CashOut,
|
|
2050
|
+
quoteId: transferOutFcQuote.getQuoteId(),
|
|
2051
|
+
})
|
|
2052
|
+
)
|
|
2053
|
+
.run()
|
|
2054
|
+
expect(AppAnalytics.track).toHaveBeenCalledTimes(1)
|
|
2055
|
+
expect(AppAnalytics.track).toHaveBeenCalledWith(FiatExchangeEvents.cico_fc_transfer_error, {
|
|
2056
|
+
provider: transferOutFcQuote.getProviderId(),
|
|
2057
|
+
flow: CICOFlow.CashOut,
|
|
2058
|
+
error: 'some error',
|
|
2059
|
+
})
|
|
2060
|
+
})
|
|
2061
|
+
it('sets transaction as failed when an "safe" error occurs', async () => {
|
|
2062
|
+
const action = createFiatConnectTransfer({
|
|
2063
|
+
flow: CICOFlow.CashOut,
|
|
2064
|
+
fiatConnectQuote: transferOutFcQuote,
|
|
2065
|
+
fiatAccountId: 'account1',
|
|
2066
|
+
serializablePreparedTransaction: mockBaseSerializablePreparedTransaction,
|
|
2067
|
+
networkId,
|
|
2068
|
+
})
|
|
2069
|
+
await expectSaga(handleCreateFiatConnectTransfer, action)
|
|
2070
|
+
.provide([
|
|
2071
|
+
[call(_initiateTransferWithProvider, action), { transferAddress }],
|
|
2072
|
+
[select(tokensByIdSelector), { [mockCusdTokenId]: mockCusdTokenBalance }],
|
|
2073
|
+
[
|
|
2074
|
+
call(_initiateSendTxToProvider, {
|
|
2075
|
+
transferAddress,
|
|
2076
|
+
fiatConnectQuote: transferOutFcQuote,
|
|
2077
|
+
tokenInfo: mockCusdTokenBalance,
|
|
2078
|
+
serializablePreparedTransaction: mockFinalSerializablePreparedTransaction,
|
|
2079
|
+
}),
|
|
2080
|
+
throwError(
|
|
2081
|
+
new FiatConnectTxError('some error', false, new Error('some internal error'))
|
|
2082
|
+
),
|
|
2083
|
+
],
|
|
2084
|
+
])
|
|
2085
|
+
.put(
|
|
2086
|
+
createFiatConnectTransferFailed({
|
|
2087
|
+
flow: CICOFlow.CashOut,
|
|
2088
|
+
quoteId: transferOutFcQuote.getQuoteId(),
|
|
2089
|
+
})
|
|
2090
|
+
)
|
|
2091
|
+
.run()
|
|
2092
|
+
expect(AppAnalytics.track).toHaveBeenCalledTimes(1)
|
|
2093
|
+
expect(AppAnalytics.track).toHaveBeenCalledWith(FiatExchangeEvents.cico_fc_transfer_error, {
|
|
2094
|
+
provider: transferOutFcQuote.getProviderId(),
|
|
2095
|
+
flow: CICOFlow.CashOut,
|
|
2096
|
+
error: 'some error',
|
|
2097
|
+
})
|
|
2098
|
+
})
|
|
2099
|
+
})
|
|
2100
|
+
describe('Errors', () => {
|
|
2101
|
+
const transferInFcQuote = new FiatConnectQuote({
|
|
2102
|
+
flow: CICOFlow.CashIn,
|
|
2103
|
+
quote: mockFiatConnectQuotes[1] as FiatConnectQuoteSuccess,
|
|
2104
|
+
fiatAccountType: FiatAccountType.BankAccount,
|
|
2105
|
+
tokenId: mockCusdTokenId,
|
|
2106
|
+
})
|
|
2107
|
+
it('Handles thrown errors and logs them', async () => {
|
|
2108
|
+
const action = createFiatConnectTransfer({
|
|
2109
|
+
flow: CICOFlow.CashIn,
|
|
2110
|
+
fiatConnectQuote: transferInFcQuote,
|
|
2111
|
+
fiatAccountId: 'account1',
|
|
2112
|
+
})
|
|
2113
|
+
await expectSaga(handleCreateFiatConnectTransfer, action)
|
|
2114
|
+
.provide([[call(_initiateTransferWithProvider, action), throwError(new Error('ERROR'))]])
|
|
2115
|
+
.put(
|
|
2116
|
+
createFiatConnectTransferFailed({
|
|
2117
|
+
flow: CICOFlow.CashIn,
|
|
2118
|
+
quoteId: transferInFcQuote.getQuoteId(),
|
|
2119
|
+
})
|
|
2120
|
+
)
|
|
2121
|
+
.run()
|
|
2122
|
+
expect(Logger.error).toHaveBeenCalledTimes(1)
|
|
2123
|
+
expect(Logger.error).toHaveBeenCalledWith(
|
|
2124
|
+
`FiatConnectSaga`,
|
|
2125
|
+
`Transfer for CashIn failed..`,
|
|
2126
|
+
new Error('ERROR')
|
|
2127
|
+
)
|
|
2128
|
+
expect(AppAnalytics.track).toHaveBeenCalledTimes(1)
|
|
2129
|
+
expect(AppAnalytics.track).toHaveBeenCalledWith(FiatExchangeEvents.cico_fc_transfer_error, {
|
|
2130
|
+
provider: transferInFcQuote.getProviderId(),
|
|
2131
|
+
flow: CICOFlow.CashOut,
|
|
2132
|
+
error: 'ERROR',
|
|
2133
|
+
})
|
|
2134
|
+
})
|
|
2135
|
+
})
|
|
2136
|
+
})
|
|
2137
|
+
|
|
2138
|
+
describe('_getFiatAccount', () => {
|
|
2139
|
+
const mockFiatAccounts = [
|
|
2140
|
+
{
|
|
2141
|
+
fiatAccountId: '123',
|
|
2142
|
+
accountName: 'some account name',
|
|
2143
|
+
institutionName: 'some institution',
|
|
2144
|
+
fiatAccountType: FiatAccountType.BankAccount,
|
|
2145
|
+
fiatAccountSchema: FiatAccountSchema.AccountNumber,
|
|
2146
|
+
},
|
|
2147
|
+
{
|
|
2148
|
+
fiatAccountId: '456',
|
|
2149
|
+
accountName: 'some account name',
|
|
2150
|
+
institutionName: 'some institution',
|
|
2151
|
+
fiatAccountType: FiatAccountType.BankAccount,
|
|
2152
|
+
fiatAccountSchema: FiatAccountSchema.DuniaWallet,
|
|
2153
|
+
},
|
|
2154
|
+
{
|
|
2155
|
+
fiatAccountId: '789',
|
|
2156
|
+
accountName: 'some account name',
|
|
2157
|
+
institutionName: 'some institution',
|
|
2158
|
+
fiatAccountType: FiatAccountType.MobileMoney,
|
|
2159
|
+
fiatAccountSchema: FiatAccountSchema.MobileMoney,
|
|
2160
|
+
},
|
|
2161
|
+
]
|
|
2162
|
+
|
|
2163
|
+
it('throws an error when no matching provider is given', async () => {
|
|
2164
|
+
await expect(
|
|
2165
|
+
async () =>
|
|
2166
|
+
await expectSaga(_getFiatAccount, {
|
|
2167
|
+
fiatConnectProviders: mockFiatConnectProviderInfo,
|
|
2168
|
+
providerId: 'fake-provider',
|
|
2169
|
+
}).run()
|
|
2170
|
+
).rejects.toThrow('Could not find provider')
|
|
2171
|
+
})
|
|
2172
|
+
it('returns account with matching ID', async () => {
|
|
2173
|
+
await expectSaga(_getFiatAccount, {
|
|
2174
|
+
fiatConnectProviders: mockFiatConnectProviderInfo,
|
|
2175
|
+
providerId: 'provider-two',
|
|
2176
|
+
fiatAccountId: '789',
|
|
2177
|
+
})
|
|
2178
|
+
.provide([
|
|
2179
|
+
[
|
|
2180
|
+
call(fetchFiatAccountsSaga, 'provider-two', 'fakewebsite.example.com', 'fake-api-key'),
|
|
2181
|
+
mockFiatAccounts,
|
|
2182
|
+
],
|
|
2183
|
+
])
|
|
2184
|
+
.returns(mockFiatAccounts[2])
|
|
2185
|
+
.run()
|
|
2186
|
+
})
|
|
2187
|
+
it('returns account with matching type', async () => {
|
|
2188
|
+
await expectSaga(_getFiatAccount, {
|
|
2189
|
+
fiatConnectProviders: mockFiatConnectProviderInfo,
|
|
2190
|
+
providerId: 'provider-two',
|
|
2191
|
+
fiatAccountType: FiatAccountType.BankAccount,
|
|
2192
|
+
})
|
|
2193
|
+
.provide([
|
|
2194
|
+
[
|
|
2195
|
+
call(fetchFiatAccountsSaga, 'provider-two', 'fakewebsite.example.com', 'fake-api-key'),
|
|
2196
|
+
mockFiatAccounts,
|
|
2197
|
+
],
|
|
2198
|
+
])
|
|
2199
|
+
.returns(mockFiatAccounts[0])
|
|
2200
|
+
.run()
|
|
2201
|
+
})
|
|
2202
|
+
it('returns account with matching schema', async () => {
|
|
2203
|
+
await expectSaga(_getFiatAccount, {
|
|
2204
|
+
fiatConnectProviders: mockFiatConnectProviderInfo,
|
|
2205
|
+
providerId: 'provider-two',
|
|
2206
|
+
fiatAccountSchema: FiatAccountSchema.DuniaWallet,
|
|
2207
|
+
})
|
|
2208
|
+
.provide([
|
|
2209
|
+
[
|
|
2210
|
+
call(fetchFiatAccountsSaga, 'provider-two', 'fakewebsite.example.com', 'fake-api-key'),
|
|
2211
|
+
mockFiatAccounts,
|
|
2212
|
+
],
|
|
2213
|
+
])
|
|
2214
|
+
.returns(mockFiatAccounts[1])
|
|
2215
|
+
.run()
|
|
2216
|
+
})
|
|
2217
|
+
it('returns account when all filters defined', async () => {
|
|
2218
|
+
await expectSaga(_getFiatAccount, {
|
|
2219
|
+
fiatConnectProviders: mockFiatConnectProviderInfo,
|
|
2220
|
+
providerId: 'provider-two',
|
|
2221
|
+
fiatAccountType: FiatAccountType.BankAccount,
|
|
2222
|
+
fiatAccountSchema: FiatAccountSchema.DuniaWallet,
|
|
2223
|
+
fiatAccountId: '456',
|
|
2224
|
+
})
|
|
2225
|
+
.provide([
|
|
2226
|
+
[
|
|
2227
|
+
call(fetchFiatAccountsSaga, 'provider-two', 'fakewebsite.example.com', 'fake-api-key'),
|
|
2228
|
+
mockFiatAccounts,
|
|
2229
|
+
],
|
|
2230
|
+
])
|
|
2231
|
+
.returns(mockFiatAccounts[1])
|
|
2232
|
+
.run()
|
|
2233
|
+
})
|
|
2234
|
+
it('returns null when no accounts match', async () => {
|
|
2235
|
+
await expectSaga(_getFiatAccount, {
|
|
2236
|
+
fiatConnectProviders: mockFiatConnectProviderInfo,
|
|
2237
|
+
providerId: 'provider-two',
|
|
2238
|
+
fiatAccountSchema: FiatAccountSchema.IBANNumber,
|
|
2239
|
+
})
|
|
2240
|
+
.provide([
|
|
2241
|
+
[
|
|
2242
|
+
call(fetchFiatAccountsSaga, 'provider-two', 'fakewebsite.example.com', 'fake-api-key'),
|
|
2243
|
+
mockFiatAccounts,
|
|
2244
|
+
],
|
|
2245
|
+
])
|
|
2246
|
+
.returns(null)
|
|
2247
|
+
.run()
|
|
2248
|
+
})
|
|
2249
|
+
})
|
|
2250
|
+
|
|
2251
|
+
describe('_selectQuoteFromFiatAccount', () => {
|
|
2252
|
+
const normalizedQuotes = normalizeFiatConnectQuotes(
|
|
2253
|
+
CICOFlow.CashOut,
|
|
2254
|
+
[mockFiatConnectQuotes[1]],
|
|
2255
|
+
mockCusdTokenId
|
|
2256
|
+
)
|
|
2257
|
+
|
|
2258
|
+
it('selects a matching quote when one exists', () => {
|
|
2259
|
+
const fiatAccount = {
|
|
2260
|
+
fiatAccountId: '456',
|
|
2261
|
+
accountName: 'account 1',
|
|
2262
|
+
institutionName: 'some institution',
|
|
2263
|
+
fiatAccountType: FiatAccountType.BankAccount,
|
|
2264
|
+
fiatAccountSchema: FiatAccountSchema.AccountNumber,
|
|
2265
|
+
providerId: 'provider-one',
|
|
2266
|
+
}
|
|
2267
|
+
const selectedQuote = _selectQuoteMatchingFiatAccount({
|
|
2268
|
+
normalizedQuotes,
|
|
2269
|
+
fiatAccount,
|
|
2270
|
+
})
|
|
2271
|
+
expect(selectedQuote).toEqual(normalizedQuotes[0])
|
|
2272
|
+
})
|
|
2273
|
+
|
|
2274
|
+
it('returns null when no matching quote exists', () => {
|
|
2275
|
+
const fiatAccount = {
|
|
2276
|
+
fiatAccountId: '456',
|
|
2277
|
+
accountName: 'account 1',
|
|
2278
|
+
institutionName: 'some institution',
|
|
2279
|
+
fiatAccountType: FiatAccountType.BankAccount,
|
|
2280
|
+
fiatAccountSchema: FiatAccountSchema.DuniaWallet,
|
|
2281
|
+
providerId: 'provider-one',
|
|
2282
|
+
}
|
|
2283
|
+
const selectedQuote = _selectQuoteMatchingFiatAccount({
|
|
2284
|
+
normalizedQuotes,
|
|
2285
|
+
fiatAccount,
|
|
2286
|
+
})
|
|
2287
|
+
expect(selectedQuote).not.toBeDefined()
|
|
2288
|
+
})
|
|
2289
|
+
})
|
|
2290
|
+
|
|
2291
|
+
describe('_selectQuoteAndFiatAccount', () => {
|
|
2292
|
+
const normalizedQuotes = normalizeFiatConnectQuotes(
|
|
2293
|
+
CICOFlow.CashOut,
|
|
2294
|
+
mockFiatConnectQuotes,
|
|
2295
|
+
mockCusdTokenId
|
|
2296
|
+
)
|
|
2297
|
+
|
|
2298
|
+
const fiatAccounts = [
|
|
2299
|
+
{
|
|
2300
|
+
fiatAccountId: '123',
|
|
2301
|
+
accountName: 'account one',
|
|
2302
|
+
institutionName: 'some institution',
|
|
2303
|
+
fiatAccountType: FiatAccountType.DuniaWallet,
|
|
2304
|
+
fiatAccountSchema: FiatAccountSchema.DuniaWallet,
|
|
2305
|
+
providerId: 'provider-one',
|
|
2306
|
+
},
|
|
2307
|
+
{
|
|
2308
|
+
fiatAccountId: '456',
|
|
2309
|
+
accountName: 'account two',
|
|
2310
|
+
institutionName: 'some institution',
|
|
2311
|
+
fiatAccountType: FiatAccountType.BankAccount,
|
|
2312
|
+
fiatAccountSchema: FiatAccountSchema.AccountNumber,
|
|
2313
|
+
providerId: 'provider-one',
|
|
2314
|
+
},
|
|
2315
|
+
{
|
|
2316
|
+
fiatAccountId: '789',
|
|
2317
|
+
accountName: 'account three',
|
|
2318
|
+
institutionName: 'some institution',
|
|
2319
|
+
fiatAccountType: FiatAccountType.BankAccount,
|
|
2320
|
+
fiatAccountSchema: FiatAccountSchema.AccountNumber,
|
|
2321
|
+
providerId: 'provider-one',
|
|
2322
|
+
},
|
|
2323
|
+
]
|
|
2324
|
+
|
|
2325
|
+
it('throws when provider not found', async () => {
|
|
2326
|
+
await expect(
|
|
2327
|
+
async () =>
|
|
2328
|
+
await expectSaga(_selectQuoteAndFiatAccount, {
|
|
2329
|
+
normalizedQuotes,
|
|
2330
|
+
providerId: 'fake-provider',
|
|
2331
|
+
})
|
|
2332
|
+
.provide([[select(fiatConnectProvidersSelector), mockFiatConnectProviderInfo]])
|
|
2333
|
+
.run()
|
|
2334
|
+
).rejects.toThrow('Could not find provider')
|
|
2335
|
+
})
|
|
2336
|
+
|
|
2337
|
+
it('throws when no account-quote pair found', async () => {
|
|
2338
|
+
await expect(
|
|
2339
|
+
async () =>
|
|
2340
|
+
await expectSaga(_selectQuoteAndFiatAccount, {
|
|
2341
|
+
normalizedQuotes,
|
|
2342
|
+
providerId: 'provider-one',
|
|
2343
|
+
})
|
|
2344
|
+
.provide([
|
|
2345
|
+
[select(fiatConnectProvidersSelector), mockFiatConnectProviderInfo],
|
|
2346
|
+
[
|
|
2347
|
+
call(
|
|
2348
|
+
fetchFiatAccountsSaga,
|
|
2349
|
+
'provider-one',
|
|
2350
|
+
mockFiatConnectProviderInfo[1].baseUrl,
|
|
2351
|
+
mockFiatConnectProviderInfo[1].apiKey
|
|
2352
|
+
),
|
|
2353
|
+
fiatAccounts.slice(0, 1),
|
|
2354
|
+
],
|
|
2355
|
+
])
|
|
2356
|
+
.run()
|
|
2357
|
+
).rejects.toThrow('Could not find a fiat account matching any provided quote')
|
|
2358
|
+
})
|
|
2359
|
+
|
|
2360
|
+
it('returns an accout-quote pair when one is found', async () => {
|
|
2361
|
+
await expectSaga(_selectQuoteAndFiatAccount, {
|
|
2362
|
+
normalizedQuotes,
|
|
2363
|
+
providerId: 'provider-one',
|
|
2364
|
+
})
|
|
2365
|
+
.provide([
|
|
2366
|
+
[select(fiatConnectProvidersSelector), mockFiatConnectProviderInfo],
|
|
2367
|
+
[
|
|
2368
|
+
call(
|
|
2369
|
+
fetchFiatAccountsSaga,
|
|
2370
|
+
'provider-one',
|
|
2371
|
+
mockFiatConnectProviderInfo[1].baseUrl,
|
|
2372
|
+
mockFiatConnectProviderInfo[1].apiKey
|
|
2373
|
+
),
|
|
2374
|
+
fiatAccounts,
|
|
2375
|
+
],
|
|
2376
|
+
])
|
|
2377
|
+
.returns({
|
|
2378
|
+
normalizedQuote: normalizedQuotes[0],
|
|
2379
|
+
selectedFiatAccount: fiatAccounts[1],
|
|
2380
|
+
})
|
|
2381
|
+
.run()
|
|
2382
|
+
})
|
|
2383
|
+
})
|
|
2384
|
+
|
|
2385
|
+
describe('_getSpecificQuote', () => {
|
|
2386
|
+
const fiatAccount = {
|
|
2387
|
+
fiatAccountId: '789',
|
|
2388
|
+
accountName: 'some account name',
|
|
2389
|
+
institutionName: 'some institution',
|
|
2390
|
+
fiatAccountType: FiatAccountType.BankAccount,
|
|
2391
|
+
fiatAccountSchema: FiatAccountSchema.AccountNumber,
|
|
2392
|
+
providerId: 'provider-c',
|
|
2393
|
+
}
|
|
2394
|
+
|
|
2395
|
+
const normalizedQuote = normalizeFiatConnectQuotes(
|
|
2396
|
+
CICOFlow.CashOut,
|
|
2397
|
+
[mockFiatConnectQuotes[1]],
|
|
2398
|
+
mockCusdTokenId
|
|
2399
|
+
)[0]
|
|
2400
|
+
|
|
2401
|
+
it('finds a suitable fiat account from on-file accounts if none is provided', async () => {
|
|
2402
|
+
await expectSaga(_getSpecificQuote, {
|
|
2403
|
+
digitalAsset: CiCoCurrency.cUSD,
|
|
2404
|
+
cryptoAmount: 2,
|
|
2405
|
+
fiatAmount: 2,
|
|
2406
|
+
flow: CICOFlow.CashOut,
|
|
2407
|
+
providerId: 'provider-two',
|
|
2408
|
+
tokenId: mockCusdTokenId,
|
|
2409
|
+
})
|
|
2410
|
+
.provide([
|
|
2411
|
+
[
|
|
2412
|
+
call(_getQuotes, {
|
|
2413
|
+
flow: CICOFlow.CashOut,
|
|
2414
|
+
digitalAsset: CiCoCurrency.cUSD,
|
|
2415
|
+
cryptoAmount: 2,
|
|
2416
|
+
fiatAmount: 2,
|
|
2417
|
+
providerIds: ['provider-two'],
|
|
2418
|
+
}),
|
|
2419
|
+
[mockFiatConnectQuotes[1]],
|
|
2420
|
+
],
|
|
2421
|
+
[
|
|
2422
|
+
call(_selectQuoteAndFiatAccount, {
|
|
2423
|
+
normalizedQuotes: [normalizedQuote],
|
|
2424
|
+
providerId: 'provider-two',
|
|
2425
|
+
}),
|
|
2426
|
+
{
|
|
2427
|
+
normalizedQuote,
|
|
2428
|
+
selectedFiatAccount: fiatAccount,
|
|
2429
|
+
},
|
|
2430
|
+
],
|
|
2431
|
+
])
|
|
2432
|
+
.returns({
|
|
2433
|
+
normalizedQuote,
|
|
2434
|
+
selectedFiatAccount: fiatAccount,
|
|
2435
|
+
})
|
|
2436
|
+
.run()
|
|
2437
|
+
})
|
|
2438
|
+
it('throws an error if no fiat account is provided and no suitable on-file account is found', async () => {
|
|
2439
|
+
await expect(
|
|
2440
|
+
async () =>
|
|
2441
|
+
await expectSaga(_getSpecificQuote, {
|
|
2442
|
+
digitalAsset: CiCoCurrency.cUSD,
|
|
2443
|
+
cryptoAmount: 2,
|
|
2444
|
+
fiatAmount: 2,
|
|
2445
|
+
flow: CICOFlow.CashOut,
|
|
2446
|
+
providerId: 'provider-two',
|
|
2447
|
+
tokenId: mockCusdTokenId,
|
|
2448
|
+
})
|
|
2449
|
+
.provide([
|
|
2450
|
+
[
|
|
2451
|
+
call(_getQuotes, {
|
|
2452
|
+
flow: CICOFlow.CashOut,
|
|
2453
|
+
digitalAsset: CiCoCurrency.cUSD,
|
|
2454
|
+
cryptoAmount: 2,
|
|
2455
|
+
fiatAmount: 2,
|
|
2456
|
+
providerIds: ['provider-two'],
|
|
2457
|
+
}),
|
|
2458
|
+
[mockFiatConnectQuotes[1]],
|
|
2459
|
+
],
|
|
2460
|
+
[
|
|
2461
|
+
call(_selectQuoteAndFiatAccount, {
|
|
2462
|
+
normalizedQuotes: [normalizedQuote],
|
|
2463
|
+
providerId: 'provider-two',
|
|
2464
|
+
}),
|
|
2465
|
+
throwError(new Error('some error')),
|
|
2466
|
+
],
|
|
2467
|
+
])
|
|
2468
|
+
.run()
|
|
2469
|
+
).rejects.toThrow('some error')
|
|
2470
|
+
})
|
|
2471
|
+
it('fetches and returns a quote if fiat account type and schema match', async () => {
|
|
2472
|
+
await expectSaga(_getSpecificQuote, {
|
|
2473
|
+
digitalAsset: CiCoCurrency.cUSD,
|
|
2474
|
+
cryptoAmount: 2,
|
|
2475
|
+
fiatAmount: 2,
|
|
2476
|
+
flow: CICOFlow.CashOut,
|
|
2477
|
+
providerId: 'provider-two',
|
|
2478
|
+
fiatAccount,
|
|
2479
|
+
tokenId: mockCusdTokenId,
|
|
2480
|
+
})
|
|
2481
|
+
.provide([
|
|
2482
|
+
[
|
|
2483
|
+
call(_getQuotes, {
|
|
2484
|
+
flow: CICOFlow.CashOut,
|
|
2485
|
+
digitalAsset: CiCoCurrency.cUSD,
|
|
2486
|
+
cryptoAmount: 2,
|
|
2487
|
+
fiatAmount: 2,
|
|
2488
|
+
providerIds: ['provider-two'],
|
|
2489
|
+
}),
|
|
2490
|
+
[mockFiatConnectQuotes[1]],
|
|
2491
|
+
],
|
|
2492
|
+
])
|
|
2493
|
+
.returns({
|
|
2494
|
+
normalizedQuote: normalizedQuote,
|
|
2495
|
+
selectedFiatAccount: fiatAccount,
|
|
2496
|
+
})
|
|
2497
|
+
.run()
|
|
2498
|
+
})
|
|
2499
|
+
it('throws if no quote with matching fiatAccountType is found', async () => {
|
|
2500
|
+
const duniaFiatAccount = Object.assign(fiatAccount, {
|
|
2501
|
+
fiatAccountType: FiatAccountType.DuniaWallet,
|
|
2502
|
+
})
|
|
2503
|
+
await expect(
|
|
2504
|
+
async () =>
|
|
2505
|
+
await expectSaga(_getSpecificQuote, {
|
|
2506
|
+
digitalAsset: CiCoCurrency.cUSD,
|
|
2507
|
+
cryptoAmount: 2,
|
|
2508
|
+
fiatAmount: 2,
|
|
2509
|
+
flow: CICOFlow.CashOut,
|
|
2510
|
+
providerId: 'provider-two',
|
|
2511
|
+
fiatAccount: duniaFiatAccount,
|
|
2512
|
+
tokenId: mockCusdTokenId,
|
|
2513
|
+
})
|
|
2514
|
+
.provide([
|
|
2515
|
+
[
|
|
2516
|
+
call(_getQuotes, {
|
|
2517
|
+
flow: CICOFlow.CashOut,
|
|
2518
|
+
digitalAsset: CiCoCurrency.cUSD,
|
|
2519
|
+
cryptoAmount: 2,
|
|
2520
|
+
fiatAmount: 2,
|
|
2521
|
+
providerIds: ['provider-two'],
|
|
2522
|
+
}),
|
|
2523
|
+
[mockFiatConnectQuotes[1]],
|
|
2524
|
+
],
|
|
2525
|
+
])
|
|
2526
|
+
.run()
|
|
2527
|
+
).rejects.toThrow('Could not find quote')
|
|
2528
|
+
})
|
|
2529
|
+
})
|
|
2530
|
+
|
|
2531
|
+
describe('handleKycTryAgain', () => {
|
|
2532
|
+
const quote = new FiatConnectQuote({
|
|
2533
|
+
quote: mockFiatConnectQuotes[3] as FiatConnectQuoteSuccess,
|
|
2534
|
+
fiatAccountType: FiatAccountType.BankAccount,
|
|
2535
|
+
flow: CICOFlow.CashOut,
|
|
2536
|
+
tokenId: mockCusdTokenId,
|
|
2537
|
+
})
|
|
2538
|
+
const flow = CICOFlow.CashOut
|
|
2539
|
+
|
|
2540
|
+
it('deletes kyc status and navigates to kyc landing screen', async () => {
|
|
2541
|
+
jest.mocked(deleteKyc).mockResolvedValueOnce()
|
|
2542
|
+
await expectSaga(handleKycTryAgain, kycTryAgain({ flow, quote }))
|
|
2543
|
+
.put(kycTryAgainCompleted())
|
|
2544
|
+
.run()
|
|
2545
|
+
expect(deleteKyc).toHaveBeenCalledTimes(1)
|
|
2546
|
+
expect(deleteKyc).toHaveBeenCalledWith({
|
|
2547
|
+
providerInfo: quote.getProviderInfo(),
|
|
2548
|
+
kycSchema: quote.getKycSchema(),
|
|
2549
|
+
})
|
|
2550
|
+
expect(navigate).toHaveBeenCalledTimes(1)
|
|
2551
|
+
expect(navigate).toHaveBeenCalledWith(Screens.KycInactive, {
|
|
2552
|
+
flow,
|
|
2553
|
+
quote,
|
|
2554
|
+
})
|
|
2555
|
+
})
|
|
2556
|
+
|
|
2557
|
+
it('shows error message on delete kyc failure', async () => {
|
|
2558
|
+
jest.mocked(deleteKyc).mockRejectedValueOnce(new Error('delete failed'))
|
|
2559
|
+
await expectSaga(handleKycTryAgain, kycTryAgain({ flow, quote }))
|
|
2560
|
+
.put(kycTryAgainCompleted())
|
|
2561
|
+
.run()
|
|
2562
|
+
expect(navigate).not.toHaveBeenCalled()
|
|
2563
|
+
expect(Logger.error).toHaveBeenCalledWith(
|
|
2564
|
+
'FiatConnectSaga',
|
|
2565
|
+
'Kyc try again failed',
|
|
2566
|
+
new Error('delete failed')
|
|
2567
|
+
)
|
|
2568
|
+
})
|
|
2569
|
+
|
|
2570
|
+
it('shows error message if quote is missing kyc schema', async () => {
|
|
2571
|
+
await expectSaga(
|
|
2572
|
+
handleKycTryAgain,
|
|
2573
|
+
kycTryAgain({
|
|
2574
|
+
flow,
|
|
2575
|
+
quote: new FiatConnectQuote({
|
|
2576
|
+
quote: mockFiatConnectQuotes[1] as FiatConnectQuoteSuccess,
|
|
2577
|
+
fiatAccountType: FiatAccountType.BankAccount,
|
|
2578
|
+
flow,
|
|
2579
|
+
tokenId: mockCusdTokenId,
|
|
2580
|
+
}),
|
|
2581
|
+
})
|
|
2582
|
+
)
|
|
2583
|
+
.put(kycTryAgainCompleted())
|
|
2584
|
+
.run()
|
|
2585
|
+
expect(deleteKyc).not.toHaveBeenCalled()
|
|
2586
|
+
expect(navigate).not.toHaveBeenCalled()
|
|
2587
|
+
expect(Logger.error).toHaveBeenCalledWith(
|
|
2588
|
+
'FiatConnectSaga',
|
|
2589
|
+
'Kyc try again failed',
|
|
2590
|
+
new Error('No KYC Schema found in quote')
|
|
2591
|
+
)
|
|
2592
|
+
})
|
|
2593
|
+
})
|
|
2594
|
+
})
|