Skip to content

Commit

Permalink
merge develop
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulnr7 committed Sep 23, 2024
2 parents 883463f + a5bd9c1 commit d6efe13
Show file tree
Hide file tree
Showing 72 changed files with 1,247 additions and 714 deletions.
Binary file not shown.
Binary file removed apps/wallet-mobile/src/assets/img/[email protected]
Binary file not shown.
Binary file removed apps/wallet-mobile/src/assets/img/[email protected]
Binary file not shown.
32 changes: 18 additions & 14 deletions apps/wallet-mobile/src/components/Icon/MinSwap.tsx

Large diffs are not rendered by default.

85 changes: 69 additions & 16 deletions apps/wallet-mobile/src/components/Icon/SundaeSwap.tsx

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const Price = ({amount, textStyle, ignorePrivacy, hidePrimaryPair}: Props) => {

if (isPrivacyActive && !ignorePrivacy) return `${privacyPlaceholder} ${currency}`

if (!isPrimaryToken(amount.info) && tokenPrice == null) return `— ${currency}`
if (!isPrimaryToken(amount.info) && tokenPrice == null) return `— ${currency}`

if (hidePrimaryPair && isPrimaryToken(amount.info) && isPrimaryTokenActive) return ''

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {Chain} from '@yoroi/types'
import _ from 'lodash'
import * as React from 'react'

import {useBalances} from '../../../../yoroi-wallets/hooks'
import {useBalances, useTransactionInfos} from '../../../../yoroi-wallets/hooks'
import {Amounts, Quantities} from '../../../../yoroi-wallets/utils/utils'
import {useSelectedWallet} from '../../../WalletManager/common/hooks/useSelectedWallet'
import {useWalletManager} from '../../../WalletManager/context/WalletManagerProvider'
Expand All @@ -14,19 +15,21 @@ import {SanchonetFaucetBanner} from './SanchonetFaucetBanner'

export const ShowBuyBanner = () => {
const {wallet} = useSelectedWallet()
const transactionInfos = useTransactionInfos({wallet})
const {
selected: {network},
} = useWalletManager()
const balances = useBalances(wallet)
const primaryAmount = Amounts.getAmount(balances, wallet.portfolioPrimaryTokenInfo.id)
const hasZeroPt = Quantities.isZero(primaryAmount.quantity)
const hasZeroTx = _.isEmpty(transactionInfos)

const showSmallBanner = useShowBuyBannerSmall()
const {resetShowBuyBannerSmall} = useResetShowBuyBannerSmall()

if (hasZeroPt && network === Chain.Network.Preprod) return <PreprodFaucetBanner />
if (hasZeroPt && network === Chain.Network.Sancho) return <SanchonetFaucetBanner />
if (hasZeroPt) return <BuyBannerBig />
if (hasZeroPt && hasZeroTx && network === Chain.Network.Preprod) return <PreprodFaucetBanner />
if (hasZeroPt && hasZeroTx && network === Chain.Network.Sancho) return <SanchonetFaucetBanner />
if (hasZeroPt && hasZeroTx) return <BuyBannerBig />
if (showSmallBanner) return <BuyBannerSmall onClose={resetShowBuyBannerSmall} />

return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {SearchProvider} from '../Search/SearchContext'
import {NetworkTag} from '../Settings/ChangeNetwork/NetworkTag'
import {TxDetails} from '../Transactions/useCases/TxDetails/TxDetails'
import {useStrings} from './common/hooks/useStrings'
import {PortfolioTokenDetailProvider} from './common/PortfolioTokenDetailContext'
import {PortfolioProvider} from './common/PortfolioProvider'
import {NftsNavigator} from './NftsNavigator'
import {PortfolioDashboardScreen} from './useCases/PortfolioDashboard/PortfolioDashboardScreen'
import ExportTokenTransactions from './useCases/PortfolioTokenDetails/ExportTokenTransactions'
Expand All @@ -22,7 +22,7 @@ export const PortfolioNavigator = () => {
const strings = useStrings()

return (
<PortfolioTokenDetailProvider>
<PortfolioProvider>
<Stack.Navigator
screenOptions={{
...defaultStackNavigationOptions(atoms, color),
Expand Down Expand Up @@ -65,6 +65,6 @@ export const PortfolioNavigator = () => {
)}
</Stack.Screen>
</Stack.Navigator>
</PortfolioTokenDetailProvider>
</PortfolioProvider>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,47 @@ import {invalid} from '@yoroi/common'
import {produce} from 'immer'
import * as React from 'react'

export const PortfolioDetailsTab = {
Performance: 'Performance',
Overview: 'Overview',
Transactions: 'Transactions',
} as const
export type PortfolioDetailsTab = (typeof PortfolioDetailsTab)[keyof typeof PortfolioDetailsTab]

export const PortfolioListTab = {
Wallet: 'Wallet',
Dapps: 'Dapps',
} as const
export type PortfolioListTab = (typeof PortfolioListTab)[keyof typeof PortfolioListTab]

export const PortfolioDappsTab = {
LiquidityPool: 'LiquidityPool',
OpenOrders: 'OpenOrders',
LendAndBorrow: 'LendAndBorrow',
} as const

export type PortfolioDappsTab = (typeof PortfolioDappsTab)[keyof typeof PortfolioDappsTab]

const defaultActions: PortfolioActions = {
setIsPrimaryTokenActive: () => invalid('missing init'),
setDetailsTab: () => invalid('missing init'),
setListTab: () => invalid('missing init'),
setDappsTab: () => invalid('missing init'),
resetTabs: () => invalid('missing init'),
} as const

const defaultState: PortfolioState = {
isPrimaryTokenActive: false,
detailsTab: PortfolioDetailsTab.Overview,
listTab: PortfolioListTab.Wallet,
dappsTab: PortfolioDappsTab.LiquidityPool,
} as const

type PortfolioState = {
isPrimaryTokenActive: boolean
detailsTab: PortfolioDetailsTab
listTab: PortfolioListTab
dappsTab: PortfolioDappsTab
}

const PortfolioContext = React.createContext<PortfolioState & PortfolioActions>({
Expand All @@ -32,6 +63,16 @@ export const PortfolioProvider = ({
setIsPrimaryTokenActive: (isActive) => {
dispatch({type: PortfolioActionType.SetIsPrimaryTokenActive, payload: {isActive}})
},
setDetailsTab: (tab) => {
dispatch({type: PortfolioActionType.SetDetailsTab, payload: {tab}})
},
setListTab: (tab) => {
dispatch({type: PortfolioActionType.SetListTab, payload: {tab}})
},
setDappsTab: (tab) => {
dispatch({type: PortfolioActionType.SetDappsTab, payload: {tab}})
},
resetTabs: () => dispatch({type: PortfolioActionType.ResetTabs}),
}).current

const context = React.useMemo<PortfolioState & PortfolioActions>(
Expand All @@ -45,17 +86,52 @@ export const PortfolioProvider = ({
export const usePortfolio = () =>
React.useContext(PortfolioContext) ?? {isPrimaryTokenActive: false, setIsPrimaryTokenActive: () => null}

enum PortfolioActionType {
SetIsPrimaryTokenActive = 'setIsPrimaryTokenActive',
}
const PortfolioActionType = {
SetIsPrimaryTokenActive: 'SetIsPrimaryTokenActive',
SetDetailsTab: 'SetDetailsTab',
SetListTab: 'SetListTab',
SetDappsTab: 'SetDappsTab',
ResetTabs: 'ResetTabs',
} as const
type PortfolioActionType = (typeof PortfolioActionType)[keyof typeof PortfolioActionType]

type PortfolioContextAction =
| SetIsPrimaryTokenActiveAction
| SetDetailsTabAction
| SetListTabAction
| SetDappsTabAction
| ResetTabsAction

type PortfolioContextAction = {
type: PortfolioActionType.SetIsPrimaryTokenActive
type SetIsPrimaryTokenActiveAction = {
type: typeof PortfolioActionType.SetIsPrimaryTokenActive
payload: {isActive: boolean}
}

type SetDetailsTabAction = {
type: typeof PortfolioActionType.SetDetailsTab
payload: {tab: PortfolioDetailsTab}
}

type SetListTabAction = {
type: typeof PortfolioActionType.SetListTab
payload: {tab: PortfolioListTab}
}

type SetDappsTabAction = {
type: typeof PortfolioActionType.SetDappsTab
payload: {tab: PortfolioDappsTab}
}

type ResetTabsAction = {
type: typeof PortfolioActionType.ResetTabs
}

type PortfolioActions = Readonly<{
setIsPrimaryTokenActive: (isActive: boolean) => void
setDetailsTab: (tab: PortfolioDetailsTab) => void
setListTab: (tab: PortfolioListTab) => void
setDappsTab: (tab: PortfolioDappsTab) => void
resetTabs: () => void
}>

const portfolioReducer = (state: PortfolioState, action: PortfolioContextAction): PortfolioState => {
Expand All @@ -64,6 +140,20 @@ const portfolioReducer = (state: PortfolioState, action: PortfolioContextAction)
case PortfolioActionType.SetIsPrimaryTokenActive:
draft.isPrimaryTokenActive = action.payload.isActive
break
case PortfolioActionType.SetDetailsTab:
draft.detailsTab = action.payload.tab
break
case PortfolioActionType.SetListTab:
draft.listTab = action.payload.tab
break
case PortfolioActionType.SetDappsTab:
draft.dappsTab = action.payload.tab
break
case PortfolioActionType.ResetTabs:
draft.detailsTab = defaultState.detailsTab
draft.listTab = defaultState.listTab
draft.dappsTab = defaultState.dappsTab
break
}
})
}

This file was deleted.

Loading

0 comments on commit d6efe13

Please sign in to comment.