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

feat: Migrate web lib to 3.0 #121

Merged
merged 10 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ module.exports = {
'comma-spacing': 'off',
'@typescript-eslint/comma-spacing': ['error'],
'dot-notation': 'off',
'@typescript-eslint/dot-notation': ['error']
'@typescript-eslint/dot-notation': ['error'],
'@typescript-eslint/no-explicit-any': 'off'
}
};
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ jobs:
run: yarn --prefer-offline

- name: Build project
run: yarn build
run: yarn build
env:
WALLETCONNECT_PROJECT_ID: ${{ secrets.WALLETCONNECT_PROJECT_ID }}
4 changes: 2 additions & 2 deletions components/ImageTester.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import React, {ReactElement} from 'react';
import {useYearn} from 'contexts/useYearn';
import {TTokenData, TTokensData} from 'types/entities';
import {useWeb3} from '@yearn-finance/web-lib/contexts';
import {toAddress} from '@yearn-finance/web-lib/utils';
import {useWeb3} from '@yearn-finance/web-lib/contexts/useWeb3';
import {toAddress} from '@yearn-finance/web-lib/utils/address';

function VaultImageTester({vaults}: {vaults: any[]}): ReactElement {
const {onUpdateIconStatus, onUpdateTokenIconStatus} = useYearn();
Expand Down
6 changes: 3 additions & 3 deletions components/PartnerEntity.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, {ReactElement} from 'react';
import {Card} from '@yearn-finance/web-lib/components';
import type {TPartner, TSettings} from 'types/types';
import StatusLine from './StatusLine';
import {useWeb3} from '@yearn-finance/web-lib';
import {Card} from 'components/common/Card';
import {useWeb3} from '@yearn-finance/web-lib/contexts/useWeb3';

type TPartnerEntityProps = {partner: string; status: TPartner[] ;settings: TSettings};

const getSuffix = (src: string, chainID: string, hasAnomalies: boolean, partner: string): ReactElement | string => {
const getSuffix = (src: string, chainID: number, hasAnomalies: boolean, partner: string): ReactElement | string => {
if (hasAnomalies && src === 'yDaemon') {
return (<span>
{'yDaemon (file '}
Expand Down
4 changes: 2 additions & 2 deletions components/StatusLine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function StatusLine({
{suffix}
{onClick ? <IconFix
onClick={onClick}
className={'mt-[2px] ml-2 inline h-4 min-h-[16px] w-4 min-w-[16px] cursor-pointer text-neutral-500/40 transition-colors hover:text-neutral-500'} /> : null}
className={'ml-2 mt-[2px] inline h-4 min-h-[16px] w-4 min-w-[16px] cursor-pointer text-neutral-500/40 transition-colors hover:text-neutral-500'} /> : null}
</p>
</div>
);
Expand All @@ -64,7 +64,7 @@ function StatusLine({
{suffix}
{onClick ? <IconFix
onClick={onClick}
className={'mt-[2px] ml-2 inline h-4 min-h-[16px] w-4 min-w-[16px] cursor-pointer text-neutral-500/40 transition-colors hover:text-neutral-500'} /> : null}
className={'ml-2 mt-[2px] inline h-4 min-h-[16px] w-4 min-w-[16px] cursor-pointer text-neutral-500/40 transition-colors hover:text-neutral-500'} /> : null}
</p>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion components/StrategyEntity.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, {ReactElement} from 'react';
import {AddressWithActions} from '@yearn-finance/web-lib/components';
import type {TFile, TSettings} from 'types/types';
import {TStrategy} from 'types/entities';
import StatusLine from './StatusLine';
import {AddressWithActions} from 'components/common/AddressWithActions';

type TProtocolStatus = {
name: string;
Expand Down
23 changes: 12 additions & 11 deletions components/TokenEntity.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import React, {ReactElement} from 'react';
import Image from 'next/image';
import {useSettings, useWeb3} from '@yearn-finance/web-lib/contexts';
import {copyToClipboard} from '@yearn-finance/web-lib/utils';
import {Copy, LinkOut} from '@yearn-finance/web-lib/icons';
import {AddressWithActions} from '@yearn-finance/web-lib/components';
import type {TSettings} from 'types/types';
import TranslationStatusLine from 'components/TranslationStatusLine';
import AnomaliesSection from 'components/VaultEntity.AnomaliesSection';
import {TTokenData} from 'types/entities';
import {AddressWithActions} from 'components/common/AddressWithActions';
import {getNetwork} from '@yearn-finance/web-lib/utils/wagmi/utils';
import {copyToClipboard} from '@yearn-finance/web-lib/utils/helpers';
import {IconCopy} from '@yearn-finance/web-lib/icons/IconCopy';
import {IconLinkOut} from '@yearn-finance/web-lib/icons/IconLinkOut';
import {useWeb3} from '@yearn-finance/web-lib/contexts/useWeb3';

function TokenEntity({
tokenData,
settings: statusSettings
}: {tokenData: TTokenData, settings: TSettings}): ReactElement | null {
const {chainID} = useWeb3();
const {networks} = useSettings();

if (!tokenData) {
return null;
Expand Down Expand Up @@ -76,14 +77,14 @@ function TokenEntity({
suffix: (
<span className={'inline'}>
{'for underlying token '}
<a href={`${networks[chainID].explorerBaseURI}/address/${tokenData.address}`} target={'_blank'} className={`underline ${tokenData?.hasValidTokenIcon ? 'tabular-nums' : 'tabular-nums text-red-900'}`} rel={'noreferrer'}>
<a href={`${getNetwork(chainID).defaultBlockExplorer}/address/${tokenData.address}`} target={'_blank'} className={`underline ${tokenData?.hasValidTokenIcon ? 'tabular-nums' : 'tabular-nums text-red-900'}`} rel={'noreferrer'}>
{tokenData.symbol || 'not_set'}
</a>
<button onClick={(): void => copyToClipboard(`${networks[chainID].explorerBaseURI}/address/${tokenData.address}`)}>
<Copy className={'ml-2 inline h-4 w-4 text-neutral-500/40 transition-colors hover:text-neutral-500'} />
<button onClick={(): void => copyToClipboard(`${getNetwork(chainID).defaultBlockExplorer}/address/${tokenData.address}`)}>
<IconCopy className={'ml-2 inline h-4 w-4 text-neutral-500/40 transition-colors hover:text-neutral-500'} />
</button>
<a href={`${networks[chainID].explorerBaseURI}/address/${tokenData.address}`} target={'_blank'} rel={'noreferrer'}>
<LinkOut className={'ml-2 inline h-4 w-4 text-neutral-500/40 transition-colors hover:text-neutral-500'} />
<a href={`${getNetwork(chainID).defaultBlockExplorer}/address/${tokenData.address}`} target={'_blank'} rel={'noreferrer'}>
<IconLinkOut className={'ml-2 inline h-4 w-4 text-neutral-500/40 transition-colors hover:text-neutral-500'} />
</a>
</span>
)
Expand All @@ -101,7 +102,7 @@ function TokenEntity({
suffix: (
<span>
{'for token '}
<a href={`${networks[chainID].explorerBaseURI}/address/${tokenData.address}`} target={'_blank'} className={`underline ${tokenData.hasValidPrice ? '' : 'text-red-900'}`} rel={'noreferrer'}>
<a href={`${getNetwork(chainID).defaultBlockExplorer}/address/${tokenData.address}`} target={'_blank'} className={`underline ${tokenData.hasValidPrice ? '' : 'text-red-900'}`} rel={'noreferrer'}>
{tokenData.name}
</a>
{tokenData?.hasValidPrice ? ` (${tokenData.price}$)` : ''}
Expand Down
2 changes: 1 addition & 1 deletion components/VaultEntity.AnomaliesSection.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {ReactElement, ReactNode, useEffect, useState} from 'react';
import {performBatchedUpdates} from '@yearn-finance/web-lib/utils';
import StatusLine from 'components/StatusLine';
import type {TAnomalies, TAnomaliesSection} from 'types/types';
import {performBatchedUpdates} from '@yearn-finance/web-lib/utils/performBatchedUpdates';

function AnomaliesSection({
label,
Expand Down
Loading
Loading