Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: swap refactor (#3731) #3799

Open
wants to merge 95 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
197b35c
chore: swap refactor (#3731)
jorbuedo Jan 27, 2025
e3d7ab2
chore: CR updates
stackchain Jan 28, 2025
1eee3cc
launch swap from portfolio
jorbuedo Jan 29, 2025
c9079ac
remove old files
jorbuedo Jan 29, 2025
e02bbbf
Rename providersplits
jorbuedo Jan 29, 2025
6c02c5f
replace .unknown
jorbuedo Jan 29, 2025
b874397
adds warn limit price
jorbuedo Jan 29, 2025
2ab8b19
rename dispatch
jorbuedo Jan 29, 2025
ec93ed7
fix actions to swap
jorbuedo Jan 29, 2025
311d4f7
remove log
jorbuedo Jan 29, 2025
1277848
pr fixes
jorbuedo Jan 29, 2025
dc3e84a
revert internal address
jorbuedo Jan 29, 2025
453eba8
failed tx
jorbuedo Jan 29, 2025
7d4afd3
Merge branch 'develop' into refactor/swap-module
jorbuedo Jan 29, 2025
9faf8cb
Merge branch 'develop' into refactor/swap-module
jorbuedo Jan 30, 2025
db0dbe4
Merge branch 'develop' into refactor/swap-module
jorbuedo Jan 30, 2025
dfed15e
Merge branch 'develop' into refactor/swap-module
jorbuedo Jan 31, 2025
b0f0b20
more undefinedToken
jorbuedo Jan 31, 2025
2999601
wip
jorbuedo Jan 31, 2025
8a6466c
chore(swap): upd storage to consume parser from common pkg
stackchain Jan 30, 2025
370a520
refactor(swap): types
stackchain Feb 3, 2025
e9a007f
chore(swap): README.md update for glossary
stackchain Feb 3, 2025
484e88c
Merge branch 'develop' into refactor/swap-module
jorbuedo Feb 4, 2025
86167a9
fix wrong imports
jorbuedo Feb 4, 2025
5e77287
Use ascii names for unkown tokens
jorbuedo Feb 4, 2025
8272f79
fix token info transformer
jorbuedo Feb 5, 2025
3a937f6
fix tests
jorbuedo Feb 5, 2025
9056d63
CR: update
banklesss Feb 5, 2025
ccf3b50
chore(swap): added tests to tokens transformers
stackchain Feb 7, 2025
5fbd6d8
chore(swap): covered token id transformations
stackchain Feb 7, 2025
f9989f4
chore(swap): covered protocol transformations
stackchain Feb 7, 2025
6a1c6ab
chore(swap): covered protocols transformations
stackchain Feb 7, 2025
96f6938
fix(wallet-mobile): pass isPrimaryToken as dep to swap factory
stackchain Feb 7, 2025
dd7eb64
Merge branch 'develop' into refactor/swap-module
stackchain Feb 7, 2025
4117265
refactor(swap): agg -> protocols only
stackchain Feb 10, 2025
de53a64
chore(swap): covered orders dexhunter hp
stackchain Feb 10, 2025
f30e267
chore(swap): covered orders muesli
stackchain Feb 11, 2025
dc3def4
chore(swap): covered cancel request
stackchain Feb 11, 2025
abf752c
chore(swap): covered cancel response
stackchain Feb 11, 2025
30fa7a8
chore(swap): covered estimate dexhunter
stackchain Feb 12, 2025
2f3f444
chore(swap): covered quote muesli
stackchain Feb 12, 2025
5cfaeb1
merge develop
banklesss Feb 12, 2025
8a48ac6
chore(swap): updated protocols
stackchain Feb 12, 2025
ca99105
Feature/swap cancellation details (#3827)
banklesss Feb 13, 2025
13e4f91
pass test and warnAllLeft
jorbuedo Feb 13, 2025
2a9628d
add explorer lnks for swap in dev
jorbuedo Feb 13, 2025
64bbfa9
fix
jorbuedo Feb 13, 2025
5d6b38a
Merge branch 'develop' into refactor/swap-module
jorbuedo Feb 13, 2025
f11cccb
jsn
jorbuedo Feb 13, 2025
c6696f8
do not call estimate or create for aggregator that did not return the…
jorbuedo Feb 13, 2025
b26be4d
Merge branch 'develop' into refactor/swap-module
jorbuedo Feb 13, 2025
492253a
TokenDetails
jorbuedo Feb 13, 2025
895ed79
Fix supply layout shift
jorbuedo Feb 13, 2025
3f4f2d2
fix
jorbuedo Feb 13, 2025
a0abb66
chore(swap): cover reverse estimate DH
stackchain Feb 13, 2025
1e8cdf1
restore proper use of image loading so it does not fail
jorbuedo Feb 14, 2025
2ae14ec
log invalidations
jorbuedo Feb 14, 2025
1dc3369
refactor(swap): collocating transf
stackchain Feb 14, 2025
b73cff1
fix
jorbuedo Feb 14, 2025
d3da183
refactor(swap): ts infer parser
stackchain Feb 14, 2025
9d7d39a
chore(swap): cover create muesli
stackchain Feb 14, 2025
e92e9fc
Merge branch 'develop' into refactor/swap-module
stackchain Feb 14, 2025
7721aae
chore(swap): cover branches
stackchain Feb 17, 2025
05a349f
chore(swap): cover limit
stackchain Feb 17, 2025
3f1d5cb
chore(swap): cover create
stackchain Feb 17, 2025
3d9c860
Merge branch 'develop' into refactor/swap-module
jorbuedo Feb 17, 2025
2c0822d
chore(swap): cover limit quote
stackchain Feb 17, 2025
41c765a
chore(swap): get best swap tests
stackchain Feb 17, 2025
b0cca66
chore(swap): cover create limit
stackchain Feb 17, 2025
be833ad
chore(swap): quote cover
stackchain Feb 17, 2025
702a90f
chore(swap): cover muesli factory
stackchain Feb 17, 2025
286f38e
chore(swap): cover factories
stackchain Feb 18, 2025
46d51c0
Merge branch 'develop' into refactor/swap-module
jorbuedo Feb 19, 2025
86e92f0
Merge branch 'develop' into refactor/swap-module
jorbuedo Feb 19, 2025
760b930
chore(swap): cover limit estimate dh
stackchain Feb 19, 2025
5b0dff6
chore(swap): cover limit estimate response dh
stackchain Feb 19, 2025
9aa2cb6
chore(swap): start covering manager
stackchain Feb 19, 2025
8667255
Merge branch 'develop' into refactor/swap-module
jorbuedo Feb 24, 2025
832644f
fix merge
jorbuedo Feb 24, 2025
c18f8da
Merge branch 'develop' into refactor/swap-module
jorbuedo Feb 24, 2025
ac170ce
Merge branch 'develop' into refactor/swap-module
stackchain Feb 24, 2025
617984b
fix
jorbuedo Feb 24, 2025
4bfe635
fix
jorbuedo Feb 24, 2025
24582bd
Merge branch 'develop' into refactor/swap-module
jorbuedo Feb 26, 2025
929fb80
Merge branch 'develop' into refactor/swap-module
jorbuedo Mar 3, 2025
ed7966c
Merge branch 'develop' into refactor/swap-module
jorbuedo Mar 4, 2025
faac7b8
Merge branch 'develop' into refactor/swap-module
jorbuedo Mar 5, 2025
b4b5013
new swap navigation
jorbuedo Mar 5, 2025
181f594
refactor AmountCard
jorbuedo Mar 6, 2025
6b8e61e
adjust tokens and orders calls
jorbuedo Mar 6, 2025
5dab742
make selected aggregators an array
jorbuedo Mar 7, 2025
d8dad94
swap settings changes
jorbuedo Mar 7, 2025
733413d
jsons
jorbuedo Mar 7, 2025
8528045
do not let no aggregator
jorbuedo Mar 7, 2025
58de9b1
fix
jorbuedo Mar 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions apps/wallet-mobile/.storybook/storybook.requires.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

232 changes: 100 additions & 132 deletions apps/wallet-mobile/src/WalletNavigator.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
import {BottomTabBar, BottomTabBarProps, createBottomTabNavigator} from '@react-navigation/bottom-tabs'
import {useFocusEffect} from '@react-navigation/native'
import {createStackNavigator} from '@react-navigation/stack'
import {
milkTokenId,
supportedProviders,
swapApiMaker,
swapManagerMaker,
SwapProvider,
swapStorageMaker,
} from '@yoroi/swap'
import {useTheme} from '@yoroi/theme'
import {Swap} from '@yoroi/types'
import React from 'react'
import {defineMessages, useIntl} from 'react-intl'
import {Keyboard, Platform, StyleSheet, View} from 'react-native'
Expand All @@ -30,10 +21,9 @@ import {SettingsScreenNavigator} from './features/Settings/SettingsScreenNavigat
import {NetworkTag} from './features/Settings/useCases/changeAppSettings/ChangeNetwork/NetworkTag'
import {SetupWalletNavigator} from './features/SetupWallet/SetupWalletNavigator'
import {GovernanceNavigator} from './features/Staking/Governance/GovernanceNavigator'
import {SwapFormProvider} from './features/Swap/common/SwapFormProvider'
import {SwapProvider} from './features/Swap/common/SwapProvider'
import {ToggleAnalyticsSettingsNavigator} from './features/ToggleAnalyticsSettings'
import {TxHistoryNavigator} from './features/Transactions/TxHistoryNavigator'
import {useSelectedWallet} from './features/WalletManager/common/hooks/useSelectedWallet'
import {SelectWalletFromList} from './features/WalletManager/useCases/SelectWalletFromListScreen/SelectWalletFromListScreen'
import {useMetrics} from './kernel/metrics/metricsManager'
import {
Expand All @@ -43,7 +33,6 @@ import {
WalletTabRoutes,
} from './kernel/navigation'
import {DashboardNavigator} from './legacy/Dashboard/DashboardNavigator'
import {useFrontendFees, useStakingKey} from './yoroi-wallets/hooks'

const Tab = createBottomTabNavigator<WalletTabRoutes>()

Expand All @@ -52,8 +41,6 @@ const TabBarWithHiddenContent = (props: BottomTabBarProps) => {
return shouldShow ? <BottomTabBar {...props} /> : null
}

const aggregator: Swap.Aggregator = 'muesliswap'

const WalletTabNavigator = () => {
const strings = useStrings()
const {colors, styles} = useStyles()
Expand Down Expand Up @@ -83,127 +70,108 @@ const WalletTabNavigator = () => {
}, [track]),
)

// swap
const {wallet} = useSelectedWallet()
const {frontendFees} = useFrontendFees(wallet)
const stakingKey = useStakingKey(wallet)
const swapManager = React.useMemo(() => {
const aggregatorTokenId = wallet.isMainnet ? milkTokenId.mainnet : milkTokenId.preprod
const swapStorage = swapStorageMaker()
const swapApi = swapApiMaker({
isMainnet: wallet.isMainnet,
stakingKey,
primaryTokenInfo: wallet.portfolioPrimaryTokenInfo,
supportedProviders,
})
const frontendFeeTiers = frontendFees?.[aggregator] ?? ([] as const)
return swapManagerMaker({swapStorage, swapApi, frontendFeeTiers, aggregator, aggregatorTokenId})
}, [wallet.isMainnet, wallet.portfolioPrimaryTokenInfo, stakingKey, frontendFees])

return (
<SwapProvider swapManager={swapManager}>
<SwapFormProvider>
<OfflineBanner />

<Tab.Navigator
sceneContainerStyle={{backgroundColor: colors.background}}
screenOptions={{
headerShown: false,
tabBarLabelStyle: styles.labelStyle,
tabBarActiveTintColor: colors.active,
tabBarInactiveTintColor: colors.inactive,
tabBarBackground: () => (
<View style={{...StyleSheet.absoluteFillObject, backgroundColor: colors.background}} />
),
tabBarStyle: {
borderTopColor: colors.divider,
borderTopWidth: 2 * StyleSheet.hairlineWidth,

// keyboardWillShow keyboardWillHiden dont work on android
display: isKeyboardOpen ? 'none' : undefined,
},
tabBarHideOnKeyboard: true,
<SwapProvider>
<OfflineBanner />

<Tab.Navigator
sceneContainerStyle={{backgroundColor: colors.background}}
screenOptions={{
headerShown: false,
tabBarLabelStyle: styles.labelStyle,
tabBarActiveTintColor: colors.active,
tabBarInactiveTintColor: colors.inactive,
tabBarBackground: () => (
<View style={{...StyleSheet.absoluteFillObject, backgroundColor: colors.background}} />
),
tabBarStyle: {
borderTopColor: colors.divider,
borderTopWidth: 2 * StyleSheet.hairlineWidth,

// keyboardWillShow keyboardWillHiden dont work on android
display: isKeyboardOpen ? 'none' : undefined,
},
tabBarHideOnKeyboard: true,
}}
tabBar={(props) => <TabBarWithHiddenContent {...props} />}
backBehavior="initialRoute"
>
<Tab.Screen
name="history"
options={{
tabBarIcon: ({focused}) =>
focused ? (
<Icon.TabWalletActive size={24} color={colors.active} />
) : (
<Icon.TabWallet size={24} color={colors.inactive} />
),
tabBarLabel: strings.walletTabBarLabel,
tabBarTestID: 'walletTabBarButton',
}}
tabBar={(props) => <TabBarWithHiddenContent {...props} />}
backBehavior="initialRoute"
>
<Tab.Screen
name="history"
options={{
tabBarIcon: ({focused}) =>
focused ? (
<Icon.TabWalletActive size={24} color={colors.active} />
) : (
<Icon.TabWallet size={24} color={colors.inactive} />
),
tabBarLabel: strings.walletTabBarLabel,
tabBarTestID: 'walletTabBarButton',
}}
>
{() => (
<SearchProvider>
<TxHistoryNavigator />
</SearchProvider>
)}
</Tab.Screen>

<Tab.Screen
name="portfolio"
initialParams={{screen: 'dashboard-portfolio'}}
options={{
tabBarIcon: ({focused}) =>
focused ? (
<Icon.TabPortfolioActive size={24} color={colors.active} />
) : (
<Icon.TabPortfolio size={24} color={colors.inactive} />
),
tabBarLabel: strings.portfolioButton,
tabBarTestID: 'portfolioTabBarButton',
}}
>
{() => (
<SearchProvider>
<PortfolioNavigator />
</SearchProvider>
)}
</Tab.Screen>

<Tab.Screen
name="discover"
options={{
tabBarIcon: ({focused}) =>
focused ? (
<Icon.TabDiscoverActive size={28} color={colors.active} />
) : (
<Icon.TabDiscover size={28} color={colors.inactive} />
),
tabBarLabel: strings.discoverTabBarLabel,
tabBarTestID: 'discoverTabBarButton',
}}
>
{() => (
<SearchProvider>
<DiscoverNavigator />
</SearchProvider>
)}
</Tab.Screen>

<Tab.Screen
name="menu"
component={MenuNavigator}
options={{
tabBarIcon: ({focused}) =>
focused ? (
<Icon.TabMenuActive size={28} color={colors.active} />
) : (
<Icon.TabMenu size={28} color={colors.inactive} />
),
tabBarLabel: strings.menuTabBarLabel,
tabBarTestID: 'menuTabBarButton',
}}
/>
</Tab.Navigator>
</SwapFormProvider>
{() => (
<SearchProvider>
<TxHistoryNavigator />
</SearchProvider>
)}
</Tab.Screen>

<Tab.Screen
name="portfolio"
initialParams={{screen: 'dashboard-portfolio'}}
options={{
tabBarIcon: ({focused}) =>
focused ? (
<Icon.TabPortfolioActive size={24} color={colors.active} />
) : (
<Icon.TabPortfolio size={24} color={colors.inactive} />
),
tabBarLabel: strings.portfolioButton,
tabBarTestID: 'portfolioTabBarButton',
}}
>
{() => (
<SearchProvider>
<PortfolioNavigator />
</SearchProvider>
)}
</Tab.Screen>

<Tab.Screen
name="discover"
options={{
tabBarIcon: ({focused}) =>
focused ? (
<Icon.TabDiscoverActive size={28} color={colors.active} />
) : (
<Icon.TabDiscover size={28} color={colors.inactive} />
),
tabBarLabel: strings.discoverTabBarLabel,
tabBarTestID: 'discoverTabBarButton',
}}
>
{() => (
<SearchProvider>
<DiscoverNavigator />
</SearchProvider>
)}
</Tab.Screen>

<Tab.Screen
name="menu"
component={MenuNavigator}
options={{
tabBarIcon: ({focused}) =>
focused ? (
<Icon.TabMenuActive size={28} color={colors.active} />
) : (
<Icon.TabMenu size={28} color={colors.inactive} />
),
tabBarLabel: strings.menuTabBarLabel,
tabBarTestID: 'menuTabBarButton',
}}
/>
</Tab.Navigator>
</SwapProvider>
)
}
Expand Down
Loading
Loading