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 69 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
69 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
e9b0e72
fix price calculation
SorinC6 Oct 3, 2024
c314f41
refactor request
SorinC6 Oct 7, 2024
01ed961
refactor
SorinC6 Oct 7, 2024
e961810
types updates
SorinC6 Oct 7, 2024
02de79c
Merge branch 'develop' into sorin/YOEXT-1199/portfolio
SorinC6 Oct 7, 2024
154d86b
add extra check when parse
SorinC6 Oct 8, 2024
f9e890c
fix table loading, reset piar pair on select new wallet
SorinC6 Oct 8, 2024
315d5dd
fix dialog opener
SorinC6 Oct 8, 2024
3dc8d63
rename reset to unset
SorinC6 Oct 8, 2024
e410266
Merge remote-tracking branch 'origin/develop' into sorin/YOEXT-1199/p…
vsubhuman Oct 10, 2024
8c6bb13
post-merge fixes
vsubhuman Oct 10, 2024
30da91d
Merge branch 'develop' into sorin/YOEXT-1199/portfolio
SorinC6 Oct 11, 2024
835ee08
update cards styles
SorinC6 Oct 10, 2024
330d950
Merge branch 'develop' into sorin/YOEXT-1199/portfolio
SorinC6 Oct 21, 2024
f9c9ef2
wip
SorinC6 Oct 10, 2024
3992129
Merge branch 'develop' into sorin/YOEXT-1199/portfolio
SorinC6 Oct 21, 2024
f73d730
fix ui for portfolio
SorinC6 Oct 22, 2024
14add6d
handle fiar paring switch
SorinC6 Oct 22, 2024
ea5b5e7
fix import
SorinC6 Oct 22, 2024
14e579e
fix chart drag
SorinC6 Oct 22, 2024
4fb24c5
fix overview
SorinC6 Oct 22, 2024
e33a513
fix local storage
SorinC6 Oct 23, 2024
cd515b7
refactor header
SorinC6 Oct 23, 2024
e8816c2
fix color
SorinC6 Oct 23, 2024
d541aa9
fix color
SorinC6 Oct 23, 2024
771a8b1
unset local storage when add new wallet
SorinC6 Oct 23, 2024
56c4063
remove console.log
SorinC6 Oct 23, 2024
73af332
floor the value
SorinC6 Oct 23, 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
17 changes: 15 additions & 2 deletions packages/yoroi-extension/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ module.exports = {
legacyDecorators: true,
},
},
extends: ['airbnb', 'prettier'],
extends: [
'airbnb',
'prettier',
'plugin:@typescript-eslint/recommended', // Enable recommended rules from the TypeScript plugin
],
env: {
browser: true,
mocha: true,
Expand Down Expand Up @@ -125,7 +129,16 @@ 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',
'@typescript-eslint', // Add TypeScript plugin
],
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