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

feature: portfolio api integration and updates #3616

Open
wants to merge 41 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
9ed8f53
refactor current selected wallet prop
SorinC6 Aug 29, 2024
a70e730
WIP - add header integration
SorinC6 Sep 3, 2024
717410f
add initial price api integration
SorinC6 Sep 3, 2024
ffdc431
add wallet manager context
SorinC6 Sep 5, 2024
c1bd370
add portfolio activity provider to handle all price change data in on…
SorinC6 Sep 6, 2024
769d89e
Merge branch 'develop' into sorin/YOEXT-1199/portfolio
SorinC6 Sep 9, 2024
77aa626
add token total and single price based on current fiat pair
SorinC6 Sep 10, 2024
6c62b08
add primary tokens prices
SorinC6 Sep 10, 2024
4078f87
wip
SorinC6 Sep 11, 2024
64bbb1c
update UI, hide elements
SorinC6 Sep 11, 2024
90f0def
add procentage hook
SorinC6 Sep 12, 2024
017d6e8
add first iteration of primary token chart with real data for 24 h
SorinC6 Sep 12, 2024
2a256c7
add interval for all time periods
SorinC6 Sep 12, 2024
3cf4b23
refactor garaph to use real data, update styles
SorinC6 Sep 13, 2024
3743b83
types fixes
SorinC6 Sep 13, 2024
63af9ab
fix chart, add token overview
SorinC6 Sep 18, 2024
970a665
add token id
SorinC6 Sep 18, 2024
cf1abae
add portfolio swap token functionality
SorinC6 Sep 18, 2024
8385a75
fix types
SorinC6 Sep 18, 2024
1974f20
fix types
SorinC6 Sep 18, 2024
13ce05e
Merge branch 'develop' into sorin/YOEXT-1199/portfolio
SorinC6 Sep 18, 2024
ff1ff69
add missing stakingAddress
SorinC6 Sep 18, 2024
e920c54
fix eslint
SorinC6 Sep 18, 2024
4036f66
add skeleton loading
SorinC6 Sep 18, 2024
04376a5
Merge branch 'develop' into sorin/YOEXT-1199/portfolio
SorinC6 Sep 19, 2024
8a38707
wip
SorinC6 Sep 19, 2024
457ad3a
refactor prices api usage
SorinC6 Sep 24, 2024
5267dc0
Merge branch 'develop' into sorin/YOEXT-1199/portfolio
SorinC6 Sep 24, 2024
edcb130
Merge branch 'develop' into sorin/YOEXT-1199/portfolio
SorinC6 Sep 25, 2024
c5ae1d1
fix styles
SorinC6 Sep 25, 2024
e5d83b9
fix data display
SorinC6 Sep 25, 2024
81daa27
fix y axis color
SorinC6 Sep 25, 2024
3313eec
add interval requests
SorinC6 Sep 25, 2024
0be14f2
add ada token interval prices
SorinC6 Sep 25, 2024
c96a9b3
restructure portfolio folder, fix search
SorinC6 Sep 25, 2024
6bbd812
fix graph UI
SorinC6 Sep 25, 2024
c2ee266
add token price in token details
SorinC6 Sep 26, 2024
617c5a4
add total amount on non ada tokens
SorinC6 Sep 26, 2024
d6db64b
updates - wip
SorinC6 Sep 27, 2024
5e3bae3
Merge branch 'develop' into sorin/YOEXT-1199/portfolio
SorinC6 Oct 2, 2024
08e3ba5
fix ts
SorinC6 Oct 2, 2024
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
15 changes: 13 additions & 2 deletions packages/yoroi-extension/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ module.exports = {
legacyDecorators: true,
},
},
extends: ['airbnb', 'prettier'],
extends: [
'airbnb',
'prettier',
],
env: {
browser: true,
mocha: true,
Expand Down Expand Up @@ -125,7 +128,15 @@ module.exports = {
camelcase: 0,
'react/jsx-curly-brace-presence': 0,
},
plugins: ['import', 'promise', 'react', 'flowtype', 'no-floating-promise', 'prettier', 'eslint-plugin-simple-import-sort'],
plugins: [
'import',
'promise',
'react',
'flowtype',
'no-floating-promise',
'prettier',
'eslint-plugin-simple-import-sort',
],
globals: {
chrome: true,
API: true,
Expand Down
271 changes: 145 additions & 126 deletions packages/yoroi-extension/app/Routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ import NFTsWrapper from './containers/wallet/NFTsWrapper';
import Wallet from './containers/wallet/Wallet';
import RestoreWalletPage, { RestoreWalletPagePromise } from './containers/wallet/restore/RestoreWalletPage';

// GOLABL Context
// $FlowIgnore: suppressing this error
import { CurrencyProvider } from './UI/context/CurrencyContext';

// New UI pages
// $FlowIgnore: suppressing this error
import { createCurrrentWalletInfo } from './UI/features/governace/common/helpers';
import { createCurrrentWalletInfo } from './UI/utils/createCurrentWalletInfo';
// $FlowIgnore: suppressing this error
import { GovernanceContextProvider } from './UI/features/governace/module/GovernanceContextProvider';
// $FlowIgnore: suppressing this error
Expand Down Expand Up @@ -196,132 +200,139 @@ declare var CONFIG: ConfigType;

export const Routes = (stores: StoresMap, actions: ActionsMap): Node => {
const queryClient = new QueryClient();

return (
<QueryClientProvider client={queryClient}>
<Suspense fallback={null}>
<Switch>
<Route exact path={ROUTES.ROOT} component={props => <LoadingPage {...props} stores={stores} actions={actions} />} />
<Route
exact
path={ROUTES.NIGHTLY_INFO}
component={props => <NightlyPage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.PROFILE.LANGUAGE_SELECTION}
component={props => <LanguageSelectionPage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.PROFILE.COMPLEXITY_LEVEL}
component={props => <ComplexityLevelPage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.PROFILE.TERMS_OF_USE}
component={props => <TermsOfUsePage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.PROFILE.URI_PROMPT}
component={props => <UriPromptPage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.PROFILE.OPT_FOR_ANALYTICS}
component={props => <OptForAnalyticsPage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.MY_WALLETS}
component={props => <MyWalletsPage {...props} stores={stores} actions={actions} />}
/>
<Route exact path={ROUTES.STAKING} component={props => <StakingPage {...props} stores={stores} actions={actions} />} />
<Route
path={ROUTES.ASSETS.ROOT}
component={props => wrapAssets({ ...props, stores, actions }, AssetsSubpages(stores, actions))}
/>
<Route
path={ROUTES.NFTS.ROOT}
component={props => wrapNFTs({ ...props, stores, actions }, NFTsSubPages(stores, actions))}
/>
<Route
exact
path={ROUTES.WALLETS.ADD}
component={props => <AddWalletPage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.WALLETS.RESTORE_WALLET}
component={props => <RestoreWalletPage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.WALLETS.CREATE_NEW_WALLET}
component={props => <CreateWalletPage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.DAPP_CONNECTOR.CONNECTED_WEBSITES}
component={props => <ConnectedWebsitesPage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.EXPERIMENTAL.YOROI_PALETTE}
component={props => <YoroiPalettePage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.EXPERIMENTAL.THEMES}
component={props => <YoroiThemesPage {...props} stores={stores} actions={actions} />}
/>
<Route
path={ROUTES.WALLETS.ROOT}
component={props => wrapWallet({ ...props, stores, actions }, WalletsSubpages(stores, actions))}
/>
<Route
path={ROUTES.SETTINGS.ROOT}
component={props => wrapSettings({ ...props, stores, actions }, SettingsSubpages(stores, actions))}
/>
<Route
path={ROUTES.SWAP.ROOT}
component={props => wrapSwap({ ...props, stores, actions }, SwapSubpages(stores, actions))}
/>
<Route path={ROUTES.TRANSFER.ROOT} component={props => <Transfer {...props} stores={stores} actions={actions} />} />
<Route
exact
path={ROUTES.SEND_FROM_URI.ROOT}
component={props => <URILandingPage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.OAUTH_FROM_EXTERNAL.DROPBOX}
component={props => <OAuthDropboxPage {...props} stores={stores} actions={actions} />}
/>
<Route exact path={ROUTES.SWITCH} component={props => <WalletSwitch {...props} stores={stores} actions={actions} />} />
<Route
exact
path={ROUTES.REVAMP.CATALYST_VOTING}
component={props => <VotingPage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.EXCHANGE_END}
component={props => <ExchangeEndPage {...props} stores={stores} actions={actions} />}
/>

{/* NEW UI Routes */}
<Route
path={ROUTES.Governance.ROOT}
component={props => wrapGovernance({ ...props, stores, actions }, GovernanceSubpages(stores, actions))}
/>
<Route
path={ROUTES.PORTFOLIO.ROOT}
component={props => wrapPortfolio({ ...props, stores, actions }, PortfolioSubpages(stores, actions))}
/>

<Redirect to={ROUTES.MY_WALLETS} />
<Route exact path={ROUTES.ROOT} component={props => <LoadingPage {...props} stores={stores} actions={actions} />} />
<Route
exact
path={ROUTES.NIGHTLY_INFO}
component={props => <NightlyPage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.PROFILE.LANGUAGE_SELECTION}
component={props => <LanguageSelectionPage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.PROFILE.COMPLEXITY_LEVEL}
component={props => <ComplexityLevelPage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.PROFILE.TERMS_OF_USE}
component={props => <TermsOfUsePage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.PROFILE.URI_PROMPT}
component={props => <UriPromptPage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.PROFILE.OPT_FOR_ANALYTICS}
component={props => <OptForAnalyticsPage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.MY_WALLETS}
component={props => <MyWalletsPage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.STAKING}
component={props => <StakingPage {...props} stores={stores} actions={actions} />}
/>
<Route
path={ROUTES.ASSETS.ROOT}
component={props => wrapAssets({ ...props, stores, actions }, AssetsSubpages(stores, actions))}
/>
<Route
path={ROUTES.NFTS.ROOT}
component={props => wrapNFTs({ ...props, stores, actions }, NFTsSubPages(stores, actions))}
/>
<Route
exact
path={ROUTES.WALLETS.ADD}
component={props => <AddWalletPage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.WALLETS.RESTORE_WALLET}
component={props => <RestoreWalletPage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.WALLETS.CREATE_NEW_WALLET}
component={props => <CreateWalletPage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.DAPP_CONNECTOR.CONNECTED_WEBSITES}
component={props => <ConnectedWebsitesPage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.EXPERIMENTAL.YOROI_PALETTE}
component={props => <YoroiPalettePage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.EXPERIMENTAL.THEMES}
component={props => <YoroiThemesPage {...props} stores={stores} actions={actions} />}
/>
<Route
path={ROUTES.WALLETS.ROOT}
component={props => wrapWallet({ ...props, stores, actions }, WalletsSubpages(stores, actions))}
/>
<Route
path={ROUTES.SETTINGS.ROOT}
component={props => wrapSettings({ ...props, stores, actions }, SettingsSubpages(stores, actions))}
/>
<Route
path={ROUTES.SWAP.ROOT}
component={props => wrapSwap({ ...props, stores, actions }, SwapSubpages(stores, actions))}
/>
<Route path={ROUTES.TRANSFER.ROOT} component={props => <Transfer {...props} stores={stores} actions={actions} />} />
<Route
exact
path={ROUTES.SEND_FROM_URI.ROOT}
component={props => <URILandingPage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.OAUTH_FROM_EXTERNAL.DROPBOX}
component={props => <OAuthDropboxPage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.SWITCH}
component={props => <WalletSwitch {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.REVAMP.CATALYST_VOTING}
component={props => <VotingPage {...props} stores={stores} actions={actions} />}
/>
<Route
exact
path={ROUTES.EXCHANGE_END}
component={props => <ExchangeEndPage {...props} stores={stores} actions={actions} />}
/>

{/* NEW UI Routes */}
<Route
path={ROUTES.Governance.ROOT}
component={props => wrapGovernance({ ...props, stores, actions }, GovernanceSubpages(stores, actions))}
/>
<Route
path={ROUTES.PORTFOLIO.ROOT}
component={props => wrapPortfolio({ ...props, stores, actions }, PortfolioSubpages(stores, actions))}
/>

<Redirect to={ROUTES.MY_WALLETS} />
</Switch>
</Suspense>
</QueryClientProvider>
Expand Down Expand Up @@ -499,6 +510,8 @@ const GovernanceSubpages = (stores, actions) => (

export function wrapSwap(swapProps: StoresAndActionsProps, children: Node): Node {
// const queryClient = new QueryClient();


const loader = (
<FullscreenLayout bottomPadding={0}>
<Stack alignItems="center" justifyContent="center" height="50vh">
Expand Down Expand Up @@ -576,9 +589,15 @@ export function wrapGovernance(governanceProps: StoresAndActionsProps, children:
);
}
export function wrapPortfolio(portfolioProps: StoresAndActionsProps, children: Node): Node {
const currentWalletInfo = createCurrrentWalletInfo(portfolioProps.stores);

return (
<PortfolioContextProvider settingFiatPairUnit={portfolioProps.stores.profile.unitOfAccount}>
<Suspense fallback={null}>{children}</Suspense>
</PortfolioContextProvider>
<CurrencyProvider currency={portfolioProps.stores.profile.unitOfAccount.currency || 'USD'}>
<PortfolioContextProvider settingFiatPairUnit={portfolioProps.stores.profile.unitOfAccount} currentWallet={currentWalletInfo}>
<Suspense fallback={null} settingFiatPairUnit={portfolioProps.stores.profile.unitOfAccount}>
{children}
</Suspense>
</PortfolioContextProvider>
</CurrencyProvider>
);
}
32 changes: 32 additions & 0 deletions packages/yoroi-extension/app/UI/context/CurrencyContext.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';

import { configCurrencies } from '../types/other';
import { supportedCurrencies } from '../utils/constants';
import { usePrimaryTokenActivity } from '../utils/usePrimaryTokenActivity';

const CurrencyContext = React.createContext<undefined | any>(undefined);
export const CurrencyProvider = ({ currency, children }: { currency: any; children: React.ReactNode }) => {
const { ptActivity, isLoading } = usePrimaryTokenActivity({ to: currency });

const value = React.useMemo(
() => ({
currency,
supportedCurrencies,
configCurrencies,
config: configCurrencies[currency],
ptActivity,
isLoading,
}),
[currency, ptActivity, isLoading]
);

return <CurrencyContext.Provider value={value}>{children}</CurrencyContext.Provider>;
};

export const useCurrencyPairing = () => React.useContext(CurrencyContext) || missingProvider();

const missingProvider = () => {
throw new Error('CurrencyProvider is missing');
};


Loading
Loading