From 61dcd7bb5a31fae11d9d7e1d1ea3eda0fa11f673 Mon Sep 17 00:00:00 2001 From: Major <90963895+Majorfi@users.noreply.github.com> Date: Fri, 20 Oct 2023 10:07:31 +0200 Subject: [PATCH] Preapy (#389) * feat: adjust prettier * chore: Deps * refactor: Hide network selector * chore: Bump @yearn-finance/web-lib * feat: Add new column * feat(MultiSelectDropdown): Start implementing the multi select dropdown * fix: Combobox logic to handle unselecting an option * feat: Add Select All option * feat: Add chain icons * fix: Options container style * feat: Set width of chain icon * Ofix: Vite vulnerability * fix: JSX elements cannot have multiple attributes with the same name * refactor: Use chain icons from web-lib * refactor: Use chain icon * feat: Support yDaemon url without chain * feat: Get all vaults from multiple chains * refactor: Remove safeChainID * feat: Remove safeChainID, use selected chains * fix: dep * fix: dep * fix: dep * feat: add prettier * feat: add husky * feat: add husky * fix: line length * fix: single attribute per line * feat: push vscode config * fix: color * fix: color + hover effect * feat: refactor * fix: prices * fix: all selected * fix: issues with selectors * fix: animation and zod * fix: deposited includes all chains * fix: earned * wip: apy * fix: On Optimism it shows New on the list but 0 inside * WIP * fix: uri * fix: boost * rebase * feat: bump lib * feat: APR setup * fix: missing icon * fix: invalid name * fix: endpoint * fix: rebase * fix: dependencies * fix: zod retired * feat: working on APY * feat: rebase * fix: invalid schema * fix: ordering * fix: update dependencies * fix: minor UI adjustments * feat: by default all selected chains * fix: can unselect stuff * fix: can unselect stuff * fix: truncate * fix: maybe fix invalid balance display * fix: no zap possible & ui freeze * fix: responsiveness issue * fix: overflow * fix: filters * fix: blockchain order * fix: underline * fix: lint * fix: split all * fix: display historical when no forward * feat: remove safeChainID usage * fix: more chain fixes * fix: some elements * fix: add missing chains * fix: forknet balances * fix: forknet balances * fix: search all * fix: use forknet * wip: debt ratio checks * feat: some useAsyncEffect * fix: useless multiple re-render * fix: hide tooltip when 0 apr * fix: invalid hooks * feat: use search query for vault list * fix: missing arg and rename func * fix: use staking rewards too * fix: 0.00 tooltip * fix: remove chain check on boosted vaults * feat: use query args * fix: search * fix: remove log * fix: order * fix: order and APR display * fix: add condition to hide when staking rewards is 0 or boost is 0 * fix: hide balancer category * fix: upd yarnlock * fix: lint * fix: merge conflicts * fix: allowance * fix: enabling display of compact values * fix: set to 2 decimals * fix: replicate changes from main * fix: error message when searching no result * feat: use smol for chain image * fix: balance non-active * fix: rebase * fix: double return --------- Co-authored-by: Majorfi Co-authored-by: Karelian Pie --- .editorconfig | 1 + .eslintrc.js | 46 +- .github/ISSUE_TEMPLATE/bug_report.md | 6 +- .github/ISSUE_TEMPLATE/feature_request.md | 7 +- .gitignore | 1 - .husky/pre-commit | 4 + .lintstagedrc.json | 4 + .prettierrc | 12 + .vscode/settings.json | 37 + CHANGELOG.md | 243 +-- LICENSE.md | 328 ++-- README.md | 83 +- apps/common/components/AmountInput.tsx | 20 +- apps/common/components/AppHeader.tsx | 89 +- apps/common/components/Apps.tsx | 43 +- .../components/BalanceReminderPopover.tsx | 160 +- apps/common/components/Dropdown.tsx | 68 +- apps/common/components/GaugeDropdown.tsx | 93 +- apps/common/components/HeroTimer.tsx | 11 +- apps/common/components/ImageWithFallback.tsx | 3 +- apps/common/components/Input.tsx | 17 +- apps/common/components/ListHead.tsx | 108 +- apps/common/components/ListHero.tsx | 150 +- apps/common/components/Meta.tsx | 130 +- apps/common/components/MotionDiv.tsx | 6 +- .../common/components/MultiSelectDropdown.tsx | 229 +++ apps/common/components/PageProgressBar.tsx | 2 +- apps/common/components/Pagination.tsx | 38 +- apps/common/components/Popover.tsx | 79 +- apps/common/components/RenderAmount.tsx | 38 +- apps/common/components/SettingsOverwrite.tsx | 36 +- apps/common/components/SummaryData.tsx | 34 +- apps/common/components/Switch.tsx | 3 +- apps/common/components/Table.tsx | 227 +-- apps/common/components/Tabs.tsx | 127 +- apps/common/components/TokenDropdown.tsx | 127 +- apps/common/components/TokenIcon.tsx | 10 +- apps/common/components/ValueAnimation.tsx | 37 +- apps/common/contexts/useCurve.tsx | 35 +- apps/common/contexts/useMenu.tsx | 53 +- apps/common/contexts/useWallet.tsx | 421 +++-- apps/common/contexts/useYearn.tsx | 228 ++- apps/common/hooks/useAllowances.tsx | 48 - apps/common/hooks/useAsyncEffect.ts | 1 - apps/common/hooks/useBalance.ts | 26 +- apps/common/hooks/useCurrentApp.tsx | 26 +- apps/common/hooks/useFetch.ts | 8 +- apps/common/hooks/useMultichainBalances.ts | 482 ++++++ apps/common/hooks/usePagination.ts | 10 +- apps/common/hooks/usePrice.ts | 16 + apps/common/hooks/useTimer.ts | 2 +- apps/common/hooks/useToken.ts | 16 + apps/common/hooks/useTokenPrice.ts | 8 +- apps/common/hooks/useYDaemonStatus.ts | 5 +- apps/common/icons/ArrowDown.tsx | 8 +- apps/common/icons/IconArrow.tsx | 7 +- apps/common/icons/IconArrowRight.tsx | 7 +- apps/common/icons/IconChevron.tsx | 7 +- apps/common/icons/IconChevronPlain.tsx | 7 +- apps/common/icons/IconPaginationArrow.tsx | 8 +- apps/common/icons/IconQuestion.tsx | 45 + apps/common/icons/IconSpinner.tsx | 8 +- apps/common/icons/LogoYearn.tsx | 12 +- apps/common/icons/LogoYearnBlue.tsx | 12 +- apps/common/icons/MessageIcon.tsx | 9 +- apps/common/schemas/coinGeckoSchemas.ts | 1 - apps/common/schemas/curveSchemas.ts | 107 +- apps/common/schemas/yDaemonEarnedSchema.ts | 33 +- apps/common/schemas/yDaemonPricesSchema.ts | 10 + apps/common/schemas/yDaemonTokensSchema.ts | 3 +- apps/common/schemas/yDaemonVaultsSchemas.ts | 255 ++- apps/common/types/category.ts | 6 +- apps/common/types/types.ts | 69 +- apps/common/utils/actions.ts | 146 +- apps/common/utils/animations.ts | 1 - apps/common/utils/assert.ts | 1 - .../common/utils/externalZapOutTokenList.json | 48 +- apps/common/utils/fetch.ts | 4 +- apps/common/utils/getYDaemonBaseURI.ts | 12 +- apps/common/utils/index.tsx | 67 +- apps/common/utils/sort.ts | 15 +- apps/vaults/Wrapper.tsx | 14 +- apps/vaults/components/ImageWithOverlay.tsx | 10 +- apps/vaults/components/ListHero.tsx | 120 ++ apps/vaults/components/RewardsTab.tsx | 89 +- apps/vaults/components/SettingsPopover.tsx | 75 +- .../details/VaultActionsTabsWrapper.tsx | 200 ++- .../components/details/VaultDetailsHeader.tsx | 133 +- .../details/actions/QuickActionsButtons.tsx | 200 ++- .../details/actions/QuickActionsFrom.tsx | 87 +- .../details/actions/QuickActionsSwitch.tsx | 3 +- .../details/actions/QuickActionsTo.tsx | 59 +- .../details/tabs/VaultDetailsAbout.tsx | 126 +- .../details/tabs/VaultDetailsHistorical.tsx | 46 +- .../details/tabs/VaultDetailsStrategies.tsx | 120 +- .../details/tabs/VaultDetailsTabsWrapper.tsx | 162 +- .../graphs/GraphForStrategyReports.tsx | 80 +- .../graphs/GraphForVaultEarnings.tsx | 61 +- .../graphs/GraphForVaultPPSGrowth.tsx | 26 +- .../components/graphs/GraphForVaultTVL.tsx | 33 +- .../vaults/components/header/VaultsHeader.tsx | 6 +- .../components/list/VaultListFactory.tsx | 136 +- .../components/list/VaultListOptions.tsx | 21 +- .../components/list/VaultsListEmpty.tsx | 124 +- .../list/VaultsListInternalMigrationRow.tsx | 25 +- .../components/list/VaultsListRetired.tsx | 25 +- apps/vaults/components/list/VaultsListRow.tsx | 388 ++++- apps/vaults/constants/index.ts | 15 + apps/vaults/constants/optRewards.ts | 1 - apps/vaults/contexts/useActionFlow.tsx | 749 +++++---- apps/vaults/contexts/useAppSettings.tsx | 72 +- apps/vaults/contexts/useSolver.tsx | 339 ++-- apps/vaults/contexts/useStakingRewards.tsx | 182 +-- apps/vaults/contexts/useWalletForZaps.tsx | 143 +- .../helpers/isValidPortalsErrorObject.test.ts | 16 +- .../helpers/isValidPortalsErrorObject.ts | 4 +- apps/vaults/hooks/useAsync.ts | 4 +- apps/vaults/hooks/useFilteredVaults.ts | 146 +- apps/vaults/hooks/usePortalsApi.ts | 10 +- apps/vaults/hooks/useSolverChainCoin.ts | 229 +-- apps/vaults/hooks/useSolverCowswap.ts | 504 +++--- .../hooks/useSolverInternalMigration.ts | 238 +-- apps/vaults/hooks/useSolverOptimismBooster.ts | 182 ++- apps/vaults/hooks/useSolverPartnerContract.ts | 242 +-- apps/vaults/hooks/useSolverPortals.ts | 375 +++-- apps/vaults/hooks/useSolverVanilla.ts | 232 +-- apps/vaults/hooks/useSolverWido.ts | 383 +++-- apps/vaults/hooks/useSortVaults.ts | 136 +- apps/vaults/hooks/useVaultsQueryArgs.ts | 144 ++ apps/vaults/types/solvers.ts | 45 +- apps/vaults/types/solvers.wido.ts | 20 +- apps/vaults/utils/abi/stakingRewards.abi.ts | 531 +++++- .../utils/abi/stakingRewardsRegistry.abi.ts | 180 ++- .../vaults/utils/abi/stakingRewardsZap.abi.ts | 155 +- apps/vaults/utils/abi/vaultFactory.abi.ts | 628 +++++++- apps/vaults/utils/abi/vaultMigrator.abi.ts | 175 +- apps/vaults/utils/abi/zapOptEthToYvEth.ts | 48 +- apps/vaults/utils/abi/zapVeCRV.abi.ts | 155 +- apps/vaults/utils/actions.ts | 70 +- apps/vaults/utils/getVaultEstimateOut.ts | 18 +- apps/vaults/utils/index.ts | 15 +- apps/vaults/utils/zapOptions.tsx | 22 +- apps/veyfi/Wrapper.tsx | 2 +- apps/veyfi/components/RedeemTab.tsx | 74 +- apps/veyfi/components/RewardsTab.tsx | 33 +- apps/veyfi/components/ViewClaimVeYFI.tsx | 13 +- apps/veyfi/components/ViewEarlyExitVeYFI.tsx | 19 +- apps/veyfi/components/ViewExtendLockVeYFI.tsx | 32 +- apps/veyfi/components/ViewLockVeYFI.tsx | 74 +- .../components/ViewStakeUnstakeGauges.tsx | 180 ++- apps/veyfi/components/ViewVoteGauges.tsx | 10 +- apps/veyfi/components/VoteTab.unused.tsx | 22 +- apps/veyfi/components/header/VeYfiHeader.tsx | 2 +- apps/veyfi/constants/menu.ts | 6 +- apps/veyfi/contexts/useGauge.tsx | 78 +- apps/veyfi/contexts/useOption.tsx | 41 +- apps/veyfi/contexts/useVotingEscrow.tsx | 124 +- apps/veyfi/hooks/useVeYFIQueryArgs.ts | 1 - .../utils/abi/SnapshotDelegateRegistry.abi.ts | 50 +- apps/veyfi/utils/abi/veYFI.abi.ts | 232 ++- .../utils/abi/veYFIClaimRewardsZap.abi.ts | 4 +- apps/veyfi/utils/abi/veYFIGauge.abi.ts | 657 +++++++- apps/veyfi/utils/abi/veYFIOptions.abi.ts | 164 +- .../utils/abi/veYFIPositionHelper.abi.ts | 32 +- apps/veyfi/utils/abi/veYFIRegistry.abi.ts | 350 ++-- apps/veyfi/utils/abi/veYFIdYFI.abi.ts | 456 +++--- apps/veyfi/utils/abi/veYFIoYFI.abi.ts | 378 +++++ apps/veyfi/utils/actions.ts | 75 +- apps/veyfi/utils/actions/gauge.ts | 5 +- apps/veyfi/utils/actions/votingEscrow.ts | 28 +- apps/veyfi/utils/constants.ts | 1 + apps/veyfi/utils/index.ts | 8 +- apps/veyfi/utils/validations.ts | 21 +- apps/ybal/Wrapper.tsx | 2 +- .../ybal/components/CardTransactorWrapper.tsx | 190 ++- apps/ybal/components/CardZap.tsx | 162 +- apps/ybal/components/Harvests.tsx | 34 +- apps/ybal/components/HarvestsListHead.tsx | 34 +- apps/ybal/components/HarvestsListRow.tsx | 46 +- apps/ybal/components/header/YBalHeader.tsx | 2 +- apps/ybal/constants/index.ts | 1 + apps/ybal/constants/tokens.tsx | 33 +- apps/ybal/contexts/useAllowanceHook.tsx | 80 +- apps/ybal/contexts/useHoldingsHook.tsx | 39 +- apps/ybal/contexts/useYBal.tsx | 57 +- apps/ybal/utils/abi/styBal.abi.ts | 883 +++++++++- apps/ybal/utils/abi/veBAL.abi.ts | 311 +++- apps/ybal/utils/abi/veBalPegHelper.abi.ts | 202 ++- apps/ybal/utils/abi/yBalBalancerPool.abi.ts | 840 +++++++++- apps/ybal/utils/actions.test.ts | 2 - apps/ybal/utils/actions.ts | 102 +- apps/ybal/utils/zapOptions.tsx | 118 -- apps/ybribe/Wrapper.tsx | 2 +- .../components/bribe/GaugeBribeModal.tsx | 126 +- .../components/bribe/GaugeListEmpty.tsx | 5 +- apps/ybribe/components/bribe/GaugeListRow.tsx | 67 +- .../components/claim/GaugeListEmpty.tsx | 4 +- apps/ybribe/components/claim/GaugeListRow.tsx | 255 +-- .../ybribe/components/header/YBribeHeader.tsx | 2 +- .../components/rewardFeed/RewardFeedTable.tsx | 56 +- .../rewardFeed/RewardFeedTableRow.tsx | 30 +- apps/ybribe/constants/index.ts | 1 + apps/ybribe/contexts/useBribes.tsx | 322 ++-- apps/ybribe/utils/abi/curveBribeV2.abi.tsx | 102 +- apps/ybribe/utils/abi/curveBribeV3.abi.tsx | 496 +++++- .../utils/abi/curveBribeV3Helper.abi.tsx | 13 +- apps/ybribe/utils/actions.ts | 31 +- apps/ybribe/utils/index.ts | 8 +- apps/ycrv/Wrapper.tsx | 2 +- .../ycrv/components/CardTransactorWrapper.tsx | 215 +-- apps/ycrv/components/CardZap.tsx | 185 ++- apps/ycrv/components/Harvests.tsx | 28 +- apps/ycrv/components/HarvestsListHead.tsx | 36 +- apps/ycrv/components/HarvestsListRow.tsx | 33 +- apps/ycrv/components/QuickActions.tsx | 62 +- apps/ycrv/components/header/YCrvHeader.tsx | 2 +- .../components/illustrations/how-it-works.tsx | 139 +- apps/ycrv/constants/index.ts | 1 + apps/ycrv/constants/tokens.tsx | 67 +- apps/ycrv/contexts/useAllowanceHook.tsx | 164 +- apps/ycrv/contexts/useHoldingsHook.tsx | 54 +- apps/ycrv/contexts/useYCRV.tsx | 64 +- apps/ycrv/utils/abi/curveCrvYCrvLp.abi.ts | 465 +++++- apps/ycrv/utils/abi/styCRV.abi.ts | 808 +++++++++- apps/ycrv/utils/abi/yveCRV.abi.ts | 448 +++++- apps/ycrv/utils/abi/zapCRV.abi.ts | 121 +- apps/ycrv/utils/actions.ts | 31 +- next.config.js | 32 +- package.json | 189 ++- pages/_app.tsx | 178 +- pages/_document.tsx | 13 - pages/api/notify.ts | 27 +- pages/index.tsx | 101 +- pages/vaults/[chainID]/[address].tsx | 108 +- pages/vaults/about.tsx | 66 +- pages/vaults/factory.tsx | 223 +-- pages/vaults/index.tsx | 419 ++--- pages/veyfi/index.tsx | 7 +- pages/ybal/about.tsx | 96 +- pages/ybal/index.tsx | 123 +- pages/ybribe/about.tsx | 59 +- pages/ybribe/index.tsx | 204 ++- pages/ybribe/offer-bribe.tsx | 177 +- pages/ycrv/about.tsx | 122 +- pages/ycrv/index.tsx | 247 ++- postcss.config.js | 4 +- public/.well-known/did.json | 18 +- public/.well-known/wc-push-config.json | 23 +- public/apps/ybribe-manifest.json | 2 +- public/apps/ycrv-manifest.json | 2 +- public/favicons/manifest.json | 80 +- public/manifest.json | 2 +- style.css | 577 +++---- stylelint.config.js | 11 + tailwind.config.js | 35 +- tsconfig.json | 10 +- yarn.lock | 1433 +++++++++++++---- 257 files changed, 20999 insertions(+), 8071 deletions(-) create mode 100755 .husky/pre-commit create mode 100644 .lintstagedrc.json create mode 100644 .prettierrc create mode 100755 .vscode/settings.json create mode 100755 apps/common/components/MultiSelectDropdown.tsx delete mode 100644 apps/common/hooks/useAllowances.tsx create mode 100644 apps/common/hooks/useMultichainBalances.ts create mode 100644 apps/common/hooks/usePrice.ts create mode 100644 apps/common/hooks/useToken.ts create mode 100644 apps/common/icons/IconQuestion.tsx create mode 100644 apps/common/schemas/yDaemonPricesSchema.ts create mode 100644 apps/vaults/components/ListHero.tsx create mode 100644 apps/vaults/constants/index.ts create mode 100644 apps/vaults/hooks/useVaultsQueryArgs.ts create mode 100644 apps/veyfi/utils/abi/veYFIoYFI.abi.ts create mode 100644 apps/ybal/constants/index.ts delete mode 100755 apps/ybal/utils/zapOptions.tsx create mode 100644 apps/ybribe/constants/index.ts create mode 100644 apps/ycrv/constants/index.ts create mode 100644 stylelint.config.js diff --git a/.editorconfig b/.editorconfig index 0a5f29dbd..8cefed389 100755 --- a/.editorconfig +++ b/.editorconfig @@ -7,3 +7,4 @@ trim_trailing_whitespace = true insert_final_newline = true indent_style = tab indent_size = 4 +max_line_length = 180 diff --git a/.eslintrc.js b/.eslintrc.js index 82bb40d7c..ae4d9f8ef 100755 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,25 +1,39 @@ module.exports = { - 'extends': ['./node_modules/@yearn-finance/web-lib/.eslintrc.cjs', 'plugin:react-hooks/recommended'], - 'parser': '@typescript-eslint/parser', - 'parserOptions': { - 'ecmaFeatures': { - 'jsx': true + extends: [ + './node_modules/@yearn-finance/web-lib/.eslintrc.cjs', + 'plugin:@next/next/recommended', + 'prettier', + 'plugin:react-hooks/recommended' + ], + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaFeatures: { + jsx: true }, - 'tsconfigRootDir': __dirname, - 'ecmaVersion': 2022, - 'sourceType': 'module', - 'project': ['./tsconfig.json'] + tsconfigRootDir: __dirname, + ecmaVersion: 2022, + sourceType: 'module', + project: ['./tsconfig.json'] }, - 'rules': { + rules: { '@typescript-eslint/prefer-optional-chain': 'error', - 'indent': 'off', - '@typescript-eslint/indent': ['error', 'tab'], + indent: 'off', 'no-multi-spaces': ['error', {ignoreEOLComments: false}], - 'no-mixed-spaces-and-tabs': 'error', - 'react/jsx-max-props-per-line': 'off', + '@typescript-eslint/indent': 0, + 'no-mixed-spaces-and-tabs': ['warn', 'smart-tabs'], + 'object-curly-newline': [ + 'error', + { + ObjectExpression: {multiline: true, consistent: true}, + ObjectPattern: {multiline: true, consistent: true}, + ImportDeclaration: {multiline: true, consistent: true}, + ExportDeclaration: {multiline: true, minProperties: 3} + } + ], 'react-hooks/exhaustive-deps': [ - 'warn', { - 'additionalHooks': '(^useAsyncTrigger$|^useDeepCompareMemo$)' + 'warn', + { + additionalHooks: '(^useAsyncTrigger$|^useDeepCompareMemo$)' } ] } diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 4211fe370..0d695f753 100755 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -3,14 +3,16 @@ name: Bug report about: Create a report to help us improve the dapp title: 'Bug: ' labels: bug, blog - --- ### What happened 🆘 + **A clear and concise description of what the bug is.** ### To Reproduce 🔂 + Steps to reproduce the behavior: ### More 🔎 -- Browser : + +- Browser : diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index f5e883240..36d0c0388 100755 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,14 +1,17 @@ --- name: Feature Request Proposal about: Ask for a new feature for this website -title: 'FRP: ' +title: 'FRP: ' --- ### What is your proposal 🚀 + **A clear and concise description of what you are asking for.** ### What does this solve ? 🛠 + **A clear and concise description about why this is a nice to have.** ### More 🔎 -*N/A* + +_N/A_ diff --git a/.gitignore b/.gitignore index 271cfc6c1..3bb14ec82 100755 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,6 @@ pnpm-debug.log* # Editor directories and files .idea -.vscode *.suo *.ntvs* *.njsproj diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 000000000..d24fdfc60 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npx lint-staged diff --git a/.lintstagedrc.json b/.lintstagedrc.json new file mode 100644 index 000000000..913b73c8e --- /dev/null +++ b/.lintstagedrc.json @@ -0,0 +1,4 @@ +{ + "*.ts|*.tsx": ["yarn prettier-format", "eslint"], + "*.scss|*.css": "yarn prettier-format" +} diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 000000000..50715a45d --- /dev/null +++ b/.prettierrc @@ -0,0 +1,12 @@ +{ + "singleQuote": true, + "semi": true, + "useTabs": true, + "tabWidth": 4, + "trailingComma": "none", + "bracketSpacing": false, + "arrowParens": "avoid", + "bracketSameLine": true, + "singleAttributePerLine": true, + "printWidth": 120 +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100755 index 000000000..8b3e5908e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,37 @@ +{ + "eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"], + "files.trimTrailingWhitespace": true, + "search.exclude": { + "**/node_modules": true + }, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true, + "editor.wordWrap": "off", + "editor.autoIndent": "keep", + "editor.codeActionsOnSave": { + "source.fixAll": true + }, + "editor.quickSuggestions": { + "strings": true + }, + "css.validate": false, + "less.validate": false, + "scss.validate": false, + "[jsonc]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[typescript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[typescriptreact]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[postcss]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[json]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "typescript.tsdk": "node_modules/typescript/lib", + "typescript.enablePromptUseWorkspaceTsdk": true +} diff --git a/CHANGELOG.md b/CHANGELOG.md index ee90437e6..058e9ff72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,161 +1,186 @@ # 0.1.25 (28/08/2023) -- Gauge voting for veYFI under the `gauge-voting` feature flag + +- Gauge voting for veYFI under the `gauge-voting` feature flag # 0.1.24 (24/08/2023) -- Add `useFeatureFlag` hook to handle feature flags + +- Add `useFeatureFlag` hook to handle feature flags # 0.1.23 (14/02/2023) -- Add the vl-yCRV page by @karelianpie + +- Add the vl-yCRV page by @karelianpie # 0.1.22 (13/02/2023) -- Fix an issue with the deposit/approve button in the deposit/withdraw flow not being correctly updated -- Update the default slippage value from `0.1` to `0.5` -- Rename the `localStorage` variables to all use a specific format for Yearn -- Fix the balances from being wipped if two `updateSome` are triggered at the same time because of a race condition -- Update the `ActionFlow` and the tabs available in the vault details page to hide the `Deposit` tab for a deprecated vault -- Update the `ImageWithFallback` to trigger a custom error catcher when the initial image is errored. -- Update the `placeholder.png` with a better one -- Prepare a new component for the mixed Tokens Icons (ex: for pools) -- Update the `ValueAnimation` to use external better hooks for the flow -- Add the `MigratableTokens` in the `useWallet` context instead of an external group of context to avoid code duplicate -- Add a Migrate tab in the vault Details page to have a consistant flow for the migration, only available when a migration is possible for a given vault. -- Add a new custom Solver `INTERNAL_MIGRATION` to handle the vault-to-vault migration -- Fix an issue with the Frame Injector being triggered in loop +- Fix an issue with the deposit/approve button in the deposit/withdraw flow not being correctly updated +- Update the default slippage value from `0.1` to `0.5` +- Rename the `localStorage` variables to all use a specific format for Yearn +- Fix the balances from being wipped if two `updateSome` are triggered at the same time because of a race condition +- Update the `ActionFlow` and the tabs available in the vault details page to hide the `Deposit` tab for a deprecated vault +- Update the `ImageWithFallback` to trigger a custom error catcher when the initial image is errored. +- Update the `placeholder.png` with a better one +- Prepare a new component for the mixed Tokens Icons (ex: for pools) +- Update the `ValueAnimation` to use external better hooks for the flow +- Add the `MigratableTokens` in the `useWallet` context instead of an external group of context to avoid code duplicate +- Add a Migrate tab in the vault Details page to have a consistant flow for the migration, only available when a migration is possible for a given vault. +- Add a new custom Solver `INTERNAL_MIGRATION` to handle the vault-to-vault migration +- Fix an issue with the Frame Injector being triggered in loop # 0.1.21 (08/02/2023) -- Move the `useBalances` hook to use some Service Workers to prevent UI freeze and have better performances -- Replace the multiple `useBalances` hook usage over the context to use the same global logic and avoid multiple balance list (making it easier to play with prices) -- Rename unused components to `something.unused.tsx` -- Add some more checks in various place to avoid undefined values and crashed -- Fix the return value of the `useBalances` hook to only return the new balance fetched in `getBalances` function -- Some cleaning and refactor to make code easier. + +- Move the `useBalances` hook to use some Service Workers to prevent UI freeze and have better performances +- Replace the multiple `useBalances` hook usage over the context to use the same global logic and avoid multiple balance list (making it easier to play with prices) +- Rename unused components to `something.unused.tsx` +- Add some more checks in various place to avoid undefined values and crashed +- Fix the return value of the `useBalances` hook to only return the new balance fetched in `getBalances` function +- Some cleaning and refactor to make code easier. # 0.1.20 (06/02/2023) -- Replace the CowAppData to use a specific one for the UI -- Add a fallback for the `useBalances` hook to use the default provider if the wallet one is down/unavailable -- Add the Boost information on the vault page to display Curve's boost -- Replace APY > 500 to `APY ≧ 500%` and sort the gauges by APY in the GaugeDropdown for the Vault Factory page. + +- Replace the CowAppData to use a specific one for the UI +- Add a fallback for the `useBalances` hook to use the default provider if the wallet one is down/unavailable +- Add the Boost information on the vault page to display Curve's boost +- Replace APY > 500 to `APY ≧ 500%` and sort the gauges by APY in the GaugeDropdown for the Vault Factory page. # 0.1.19 (30/01/2023) -- Add redirections to twitter via `https://yearn.finance/twitter` -- Add redirections to github via `https://yearn.finance/github` -- Add redirections to telegram via `https://yearn.finance/telegram` -- Add redirections to medium via `https://yearn.finance/medium` -- Add redirections to governance via `https://yearn.finance/governance` -- Add redirections to snapshot via `https://yearn.finance/snapshot` -- Refactor the `useAsync` to use an external hook library with expected behaviors + +- Add redirections to twitter via `https://yearn.finance/twitter` +- Add redirections to github via `https://yearn.finance/github` +- Add redirections to telegram via `https://yearn.finance/telegram` +- Add redirections to medium via `https://yearn.finance/medium` +- Add redirections to governance via `https://yearn.finance/governance` +- Add redirections to snapshot via `https://yearn.finance/snapshot` +- Refactor the `useAsync` to use an external hook library with expected behaviors # 0.1.18 (24/01/2023) -- Fix the markdown not being parsed in the vault token description section -- Add a default check over nil/undef and a default fallback for the BigNumbers with `formatBN` and remove extra code -- Add an info about the contract used in the yCRV about page -- Add a fix on the signature of the coworder being triggered too early and breaking the logical flow -- Add a `isDisabled` solver info, to be able to enable/disable a specific solver. -- Replace the style of the `Connect Wallet` button to make it more visible -- Correctly reset values on the solvers on error/after a success + +- Fix the markdown not being parsed in the vault token description section +- Add a default check over nil/undef and a default fallback for the BigNumbers with `formatBN` and remove extra code +- Add an info about the contract used in the yCRV about page +- Add a fix on the signature of the coworder being triggered too early and breaking the logical flow +- Add a `isDisabled` solver info, to be able to enable/disable a specific solver. +- Replace the style of the `Connect Wallet` button to make it more visible +- Correctly reset values on the solvers on error/after a success # 0.1.17 (23/01/2023) -- Rework the `useBalances` hook to be lighter and more reliable -- Fix some CSS issues on mobile and some global lint style -- Fix the errored Vault logo when loading a vault page from the wrong network + +- Rework the `useBalances` hook to be lighter and more reliable +- Fix some CSS issues on mobile and some global lint style +- Fix the errored Vault logo when loading a vault page from the wrong network # 0.1.16 -- Add support for Solvers, aka external services used for zaps. Current zaps are Cowswap, Wido and Portals. Cowswap is implemented, Wido is waiting for a review from our security team, Portals is yet to be implemented. -- Add and fetch a tokenList with a supportedZap feature to determine which solver can be used for this IN token -- Add a separated tab for `Deposit` and `Withdraw` in the Vault Detail page -- Replace the `TokenDropdown` component to use Combobox instead of Listbox -- Draft a new version of `useBalances` hook to fetch the balances of the user -- Integrate `yearn.finance/zap-slippage` locale storage value to determine the slippage to use in the zaps -- Integrate `yearn.finance/zap-provider` locale storage value to determine the provider to use in the zaps -- Add some new custom hooks and context `apps/common/hooks/useAllowanceFetcher.tsx`, `apps/vaults/contexts/useSolver.tsx`, `apps/vaults/contexts/useWalletForZaps.tsx`, `apps/vaults/hooks/useSolverChainCoin.tsx`, `apps/vaults/hooks/useVaultEstimateOutFetcher.tsx`, `apps/vaults/contexts/useActionFlow.tsx` -- Add one solver hook per solver (`useVanilla`, `useChainChoin`, `usePartnerContract`, `useWido`, `useCowswap`) -- Fix some minor UI and UX issues -- Improve some typing and linting + +- Add support for Solvers, aka external services used for zaps. Current zaps are Cowswap, Wido and Portals. Cowswap is implemented, Wido is waiting for a review from our security team, Portals is yet to be implemented. +- Add and fetch a tokenList with a supportedZap feature to determine which solver can be used for this IN token +- Add a separated tab for `Deposit` and `Withdraw` in the Vault Detail page +- Replace the `TokenDropdown` component to use Combobox instead of Listbox +- Draft a new version of `useBalances` hook to fetch the balances of the user +- Integrate `yearn.finance/zap-slippage` locale storage value to determine the slippage to use in the zaps +- Integrate `yearn.finance/zap-provider` locale storage value to determine the provider to use in the zaps +- Add some new custom hooks and context `apps/common/hooks/useAllowanceFetcher.tsx`, `apps/vaults/contexts/useSolver.tsx`, `apps/vaults/contexts/useWalletForZaps.tsx`, `apps/vaults/hooks/useSolverChainCoin.tsx`, `apps/vaults/hooks/useVaultEstimateOutFetcher.tsx`, `apps/vaults/contexts/useActionFlow.tsx` +- Add one solver hook per solver (`useVanilla`, `useChainChoin`, `usePartnerContract`, `useWido`, `useCowswap`) +- Fix some minor UI and UX issues +- Improve some typing and linting # 0.1.15 -- Add the fetch to `https://api.yearn.finance/v1/chains/1/apy-previews/curve-factory` to get the APY for the gauges on the factory page -- Extract and reuse hooks and functions from the web-lib -- Improve Vault's search -- Remove the performance fee from Vault's strategies + +- Add the fetch to `https://api.yearn.finance/v1/chains/1/apy-previews/curve-factory` to get the APY for the gauges on the factory page +- Extract and reuse hooks and functions from the web-lib +- Improve Vault's search +- Remove the performance fee from Vault's strategies # 0.1.14 -- Remove the `isActive` from the gauge dropdown, as wallet connect is not required to get that list -- Add a `isClientLoaded` in `DesktopCategories` to avoid a SSR hydratation issue leading to multiple categories being selected -- Replace `getGauges` with `getAllGauges` for useCurve and adapt code to handle the changes -- Rename `useWalletNonce` to `balancesNonce` to match actual behavior and use the nonce from the useBalances hook -- Use some `toNormalizedBN` instead of raw declarations -- Add a specific code to refresh balance for a vault when you access that vault page. This will enable any old vault to get the balance even if it's not loaded in the app because of retired status. -- Bump the web-lib to `0.17.85` for the updated `useBalances` hook and -- Add an estimate code warning for the migration with an increase of `gasLimit` to avoid revert `outOfGas` issues -- Merge branch to add a `Balancer` wrap around text to make them nicer to read -- Add the `useCurrentApp` hook to make the app management easier to handle + +- Remove the `isActive` from the gauge dropdown, as wallet connect is not required to get that list +- Add a `isClientLoaded` in `DesktopCategories` to avoid a SSR hydratation issue leading to multiple categories being selected +- Replace `getGauges` with `getAllGauges` for useCurve and adapt code to handle the changes +- Rename `useWalletNonce` to `balancesNonce` to match actual behavior and use the nonce from the useBalances hook +- Use some `toNormalizedBN` instead of raw declarations +- Add a specific code to refresh balance for a vault when you access that vault page. This will enable any old vault to get the balance even if it's not loaded in the app because of retired status. +- Bump the web-lib to `0.17.85` for the updated `useBalances` hook and +- Add an estimate code warning for the migration with an increase of `gasLimit` to avoid revert `outOfGas` issues +- Merge branch to add a `Balancer` wrap around text to make them nicer to read +- Add the `useCurrentApp` hook to make the app management easier to handle # 0.1.13 -- Release the Vaults Factory page -- Fix issue with Messari Subgraph only returning 100 results + +- Release the Vaults Factory page +- Fix issue with Messari Subgraph only returning 100 results # 0.1.12 -- Add a `mutateVaultList` function to ask to refresh the vaultList in the `useYearn` context -- Add a `VoidPromiseFunction` type to mimic the `VoidFunction` type but for a function returning a `Promise`. TODO: Move to web-lib. -- Tweek the `useAsync` function to fix some issues with the dependencies and have an internal `isLoading` state. Add a mutate callback. -- Bump web-lib to `0.17.81` to get latest changes -- In the `Factory` page, add the `fetchGaugeDisplayData` to fetch the name and symbol of the gauges in order to be able to compute the actual final name and symbol for that vault. -- Enable the factory gauge in the dropdown + +- Add a `mutateVaultList` function to ask to refresh the vaultList in the `useYearn` context +- Add a `VoidPromiseFunction` type to mimic the `VoidFunction` type but for a function returning a `Promise`. TODO: Move to web-lib. +- Tweek the `useAsync` function to fix some issues with the dependencies and have an internal `isLoading` state. Add a mutate callback. +- Bump web-lib to `0.17.81` to get latest changes +- In the `Factory` page, add the `fetchGaugeDisplayData` to fetch the name and symbol of the gauges in order to be able to compute the actual final name and symbol for that vault. +- Enable the factory gauge in the dropdown # 0.1.11 -- Add a `GaugeDropdown` component using Combobox. To replicate to the default `TokenDropdown` component. -- Fix background color for the inputs in the `vaults/[chainID]/[address]` page from `neutral-100` to `neutral-0` -- Add the `Factory` nav item for the Vaults app -- Remove unused `apps/vaults/components/list/MigratableVaultListRow.tsx` -- Remove unused `apps/vaults/components/list/MigratableVaultsListEmpty.tsx` -- Merge `apps/vaults/components/list/VaultListExternalMigrationEmpty.tsx` in `apps/vaults/components/list/VaultListEmpty.tsx` -- Create an `useAsync` hook to be able to use it like we could use `useSWR` to get some values. It require a `callbackFunction` which will be triggered and a `defaultValue`, which will be returned until the desired value from the `callbackFunction` is loaded. -- Add the possibility to create a Vault from the Factory page with the `createVaultFromFactory` action and the Factory page -- Add the `VAULT_FACTORY_ADDRESS` to address [`0x21b1FC8A52f179757bf555346130bF27c0C2A17A`](https://etherscan.io/address/0x21b1FC8A52f179757bf555346130bF27c0C2A17A) + +- Add a `GaugeDropdown` component using Combobox. To replicate to the default `TokenDropdown` component. +- Fix background color for the inputs in the `vaults/[chainID]/[address]` page from `neutral-100` to `neutral-0` +- Add the `Factory` nav item for the Vaults app +- Remove unused `apps/vaults/components/list/MigratableVaultListRow.tsx` +- Remove unused `apps/vaults/components/list/MigratableVaultsListEmpty.tsx` +- Merge `apps/vaults/components/list/VaultListExternalMigrationEmpty.tsx` in `apps/vaults/components/list/VaultListEmpty.tsx` +- Create an `useAsync` hook to be able to use it like we could use `useSWR` to get some values. It require a `callbackFunction` which will be triggered and a `defaultValue`, which will be returned until the desired value from the `callbackFunction` is loaded. +- Add the possibility to create a Vault from the Factory page with the `createVaultFromFactory` action and the Factory page +- Add the `VAULT_FACTORY_ADDRESS` to address [`0x21b1FC8A52f179757bf555346130bF27c0C2A17A`](https://etherscan.io/address/0x21b1FC8A52f179757bf555346130bF27c0C2A17A) # 0.1.10 -- Add `.env` example and update `readme` from @patcito -- Fix typos from @engn33r + +- Add `.env` example and update `readme` from @patcito +- Fix typos from @engn33r # 0.1.9 -- Bump dependencies -- Set resolution for `json5` to `>= 2.2.2` to fix a low impact vulnerability: the parse method of the JSON5 library before and including version 2.2.1 does not restrict parsing of keys named __proto__, allowing specially crafted strings to pollute the prototype of the resulting object. + +- Bump dependencies +- Set resolution for `json5` to `>= 2.2.2` to fix a low impact vulnerability: the parse method of the JSON5 library before and including version 2.2.1 does not restrict parsing of keys named **proto**, allowing specially crafted strings to pollute the prototype of the resulting object. # 0.1.8 -- Fix vault access crash + +- Fix vault access crash # 0.1.7 -- Update the `AnimatePresence`/`motion.div`/`Wrapper` setup to keep the inner app contexts between the inner app pages -- Rename `VaultsListMigratableRow.tsx` to `VaultsListInternalMigrationRow.tsx` to match external pattern + +- Update the `AnimatePresence`/`motion.div`/`Wrapper` setup to keep the inner app contexts between the inner app pages +- Rename `VaultsListMigratableRow.tsx` to `VaultsListInternalMigrationRow.tsx` to match external pattern # 0.1.6 -- Update the web-lib to `0.17.79` to fix a crash with Gnosis Safe + +- Update the web-lib to `0.17.79` to fix a crash with Gnosis Safe # 0.1.5 -- Fix an hydratation warning in the vault page (dev only) -- Update the web-lib to `0.17.77` to use `onLoadStart` and `onLoadDone` from the `useUI` context, allowing to show a loading bar for multiple load actions -- Integrate `onLoadStart` and `onLoadDone` in `useWallet`, `useWalletForExternalMigrations`, `useWalletForInternalMigrations` and `useExtendedWallet`. -- Rename some variables -- Remove useless `useMigratableWallet.tsx` file (unused) + +- Fix an hydratation warning in the vault page (dev only) +- Update the web-lib to `0.17.77` to use `onLoadStart` and `onLoadDone` from the `useUI` context, allowing to show a loading bar for multiple load actions +- Integrate `onLoadStart` and `onLoadDone` in `useWallet`, `useWalletForExternalMigrations`, `useWalletForInternalMigrations` and `useExtendedWallet`. +- Rename some variables +- Remove useless `useMigratableWallet.tsx` file (unused) # 0.1.4 -- Write a redirection from `yearn.fi/*` to `yearn.finance/vaults/*` -- Write a redirection from `yearn.finance/*` to `yearn.finance/ycrv/*` -- Write a redirection from `ybribe.com/*` to `yearn.finance/ybribe/*` -- Fix the "Deposited" in the vault page to take into account the deposits from deprecated vaults + +- Write a redirection from `yearn.fi/*` to `yearn.finance/vaults/*` +- Write a redirection from `yearn.finance/*` to `yearn.finance/ycrv/*` +- Write a redirection from `ybribe.com/*` to `yearn.finance/ybribe/*` +- Fix the "Deposited" in the vault page to take into account the deposits from deprecated vaults # 0.1.3 -- Fix the open in explorer button not redirecting to the correct page + +- Fix the open in explorer button not redirecting to the correct page # 0.1.2 -- Update web-lib to `0.17.73` -- Fix lint issues related to `no-else-return` -- Fix lint issues related to `eol-last` + +- Update web-lib to `0.17.73` +- Fix lint issues related to `no-else-return` +- Fix lint issues related to `eol-last` # 0.1.1 -- Add bump package to bump package -- Add CHANGELOG.md + +- Add bump package to bump package +- Add CHANGELOG.md # 0.1.0 -- Initial release + +- Initial release diff --git a/LICENSE.md b/LICENSE.md index f288702d2..a5eae1527 100755 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,190 +1,190 @@ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. +Copyright (C) 2007 Free Software Foundation, Inc. +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. Preamble - The GNU General Public License is a free, copyleft license for +The GNU General Public License is a free, copyleft license for software and other kinds of works. - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, +The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the +software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to +any other work released this way by its authors. You can apply it to your programs, too. - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you +When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have +To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. - For example, if you distribute copies of such a program, whether +For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they know their rights. - Developers that use the GNU GPL protect your rights with two steps: +Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and +For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. - Some devices are designed to deny users access to install or run +Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we +use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we +products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. - Finally, every program is threatened constantly by software patents. +Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that +make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. - The precise terms and conditions for copying, distribution and +The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS - 0. Definitions. +0. Definitions. - "This License" refers to version 3 of the GNU General Public License. +"This License" refers to version 3 of the GNU General Public License. - "Copyright" also means copyright-like laws that apply to other kinds of +"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and +"The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. - To "modify" a work means to copy from or adapt all or part of the work +To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the +exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. - A "covered work" means either the unmodified Program or a work based +A "covered work" means either the unmodified Program or a work based on the Program. - To "propagate" a work means to do anything with it that, without +To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, +computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through +To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. - An interactive user interface displays "Appropriate Legal Notices" +An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If +work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. - 1. Source Code. +1. Source Code. - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source +The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source form of a work. - A "Standard Interface" means an interface that either is an official +A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. - The "System Libraries" of an executable work include anything, other +The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A +implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. - The "Corresponding Source" for a work in object code form means all +The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's +control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source +which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. - The Corresponding Source need not include anything that users +The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. - The Corresponding Source for a work in source code form is that +The Corresponding Source for a work in source code form is that same work. - 2. Basic Permissions. +2. Basic Permissions. - All rights granted under this License are granted for the term of +All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your +content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. - You may make, run and propagate covered works that you do not +You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose +in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works +not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 +Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. +3. Protecting Users' Legal Rights From Anti-Circumvention Law. - No covered work shall be deemed part of an effective technological +No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. - When you convey a covered work, you waive any legal power to forbid +When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or @@ -192,9 +192,9 @@ modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. - 4. Conveying Verbatim Copies. +4. Conveying Verbatim Copies. - You may convey verbatim copies of the Program's source code as you +You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any @@ -202,12 +202,12 @@ non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. - You may charge any price or no price for each copy that you convey, +You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. - 5. Conveying Modified Source Versions. +5. Conveying Modified Source Versions. - You may convey a work based on the Program, or the modifications to +You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: @@ -232,19 +232,19 @@ terms of section 4, provided that you also meet all of these conditions: interfaces that do not display Appropriate Legal Notices, your work need not make them do so. - A compilation of a covered work with other separate and independent +A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work +beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. - 6. Conveying Non-Source Forms. +6. Conveying Non-Source Forms. - You may convey a covered work in object code form under the terms +You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: @@ -290,75 +290,75 @@ in one of these ways: Source of the work are being offered to the general public at no charge under subsection 6d. - A separable portion of the object code, whose source code is excluded +A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. - A "User Product" is either (1) a "consumer product", which means any +A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product +actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. - "Installation Information" for a User Product means any methods, +"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must +a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. - If you convey an object code work under this section in, or with, or +If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply +by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). - The requirement to provide Installation Information does not include a +The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a +the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. - Corresponding Source conveyed, and Installation Information provided, +Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. - 7. Additional Terms. +7. Additional Terms. - "Additional permissions" are terms that supplement the terms of this +"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions +that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. - When you convey a copy of a covered work, you may at your option +When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. - Notwithstanding any other provision of this License, for material you +Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: @@ -385,74 +385,74 @@ that material) supplement the terms of this License with terms: any liability that these contractual assumptions directly impose on those licensors and authors. - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you +All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains +restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. - If you add terms to a covered work in accord with this section, you +If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. - Additional terms, permissive or non-permissive, may be stated in the +Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. - 8. Termination. +8. Termination. - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or +You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). - However, if you cease all violation of this License, then your +However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. - Moreover, your license from a particular copyright holder is +Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. - Termination of your rights under this section does not terminate the +Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently +this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. - 9. Acceptance Not Required for Having Copies. +9. Acceptance Not Required for Having Copies. - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work +You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, +to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. - 10. Automatic Licensing of Downstream Recipients. +10. Automatic Licensing of Downstream Recipients. - Each time you convey a covered work, the recipient automatically +Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible +propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. - An "entity transaction" is a transaction transferring control of an +An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered +organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could @@ -460,43 +460,43 @@ give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may +You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. - 11. Patents. +11. Patents. - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The +A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". - A contributor's "essential patent claims" are all patent claims +A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For +consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. - Each contributor grants you a non-exclusive, worldwide, royalty-free +Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. - In the following three paragraphs, a "patent license" is any express +In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a +sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. - If you convey a covered work, knowingly relying on a patent license, +If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, @@ -504,13 +504,13 @@ then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have +license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. - If, pursuant to or in connection with a single transaction or +If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify @@ -518,10 +518,10 @@ or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. - A patent license is "discriminatory" if it does not include within +A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered +specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying @@ -533,73 +533,73 @@ for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. - Nothing in this License shall be construed as excluding or limiting +Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. - 12. No Surrender of Others' Freedom. +12. No Surrender of Others' Freedom. - If conditions are imposed on you (whether by court order, agreement or +If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a +excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you +not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. - 13. Use with the GNU Affero General Public License. +13. Use with the GNU Affero General Public License. - Notwithstanding any other provision of this License, you have +Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this +combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. - 14. Revised Versions of this License. +14. Revised Versions of this License. - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will +The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. - Each version is given a distinguishing version number. If the +Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the +Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. - If the Program specifies that a proxy can decide which future +If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any +Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. - 15. Disclaimer of Warranty. +15. Disclaimer of Warranty. - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - 16. Limitation of Liability. +16. Limitation of Liability. - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE @@ -609,9 +609,9 @@ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - 17. Interpretation of Sections 15 and 16. +17. Interpretation of Sections 15 and 16. - If the disclaimer of warranty and limitation of liability provided +If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the @@ -622,11 +622,11 @@ copy of the Program in return for a fee. How to Apply These Terms to Your New Programs - If you develop a new program, and you want it to be of the greatest +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. - To do so, attach the following notices to the program. It is safest +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. @@ -649,7 +649,7 @@ the "copyright" line and a pointer to where the full notice is found. Also add information on how to contact you by electronic and paper mail. - If the program does terminal interaction, make it output a short +If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) @@ -658,17 +658,17 @@ notice like this when it starts in an interactive mode: under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands +parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". - You should also get your employer (if you work as a programmer) or school, +You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you +The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read . diff --git a/README.md b/README.md index 39eef598c..042652315 100755 --- a/README.md +++ b/README.md @@ -1,72 +1,77 @@ # yearn.fi + ![](./public/og.png) -Why? +Why? ### Initial Setup -- Fork the [original repo](https://github.com/yearn/yearn.fi) into your GitHub account -- Clone the forked repo from your GitHub account to your local machine +- Fork the [original repo](https://github.com/yearn/yearn.fi) into your GitHub account +- Clone the forked repo from your GitHub account to your local machine - ``` - git clone https://github.com//yearn.fi.git - ``` + ``` + git clone https://github.com//yearn.fi.git + ``` -- Set origin to your fork. This is where you push your changes to. This is done automatically by the step above. +- Set origin to your fork. This is where you push your changes to. This is done automatically by the step above. - ``` - git remote add origin https://github.com//yearn.fi - ``` + ``` + git remote add origin https://github.com//yearn.fi + ``` -- Set upstream to original repo. +- Set upstream to original repo. - ``` - git remote add upstream https://github.com/yearn/yearn.fi.git - ``` + ``` + git remote add upstream https://github.com/yearn/yearn.fi.git + ``` -- Optional: Create `.env` file in root directory of repo then copy contents of `.env.example` to `.env` and replace values with your own keys. If you do not do this the default values from `next.config.js` will be used. +- Optional: Create `.env` file in root directory of repo then copy contents of `.env.example` to `.env` and replace values with your own keys. If you do not do this the default values from `next.config.js` will be used. - ``` - cp .env.example .env + ``` + cp .env.example .env + ``` ### Install and run + 1. Run `yarn` 2. Run `yarn run dev` 3. Open the browser and navigate to `http://localhost:3000` ### Run with Docker + This project can be run with Docker. + 1. Build the image: `docker build -t [name-of-your-container] .` 2. Run the container: `docker run -p 3000:3000 [name-of-your-container]` 3. Open the browser and navigate to `http://localhost:3000` ### Making Changes -- Create a new local branch from upstream/main for each PR that you will submit - ``` - git fetch - git checkout -b upstream/main - ``` -- Commit your changes as you work - ``` - git add . - git commit -S -m "message" - ``` - - [info about verified commits](https://docs.github.com/en/github/authenticating-to-github/managing-commit-signature-verification) +- Create a new local branch from upstream/main for each PR that you will submit + ``` + git fetch + git checkout -b upstream/main + ``` +- Commit your changes as you work + ``` + git add . + git commit -S -m "message" + ``` + - [info about verified commits](https://docs.github.com/en/github/authenticating-to-github/managing-commit-signature-verification) ### Pushing Changes to your Repo -- Commits are squashed when PR is merged so rebasing is optional -- When ready to push - ``` - git fetch - git merge upstream/main - git push origin - ``` +- Commits are squashed when PR is merged so rebasing is optional +- When ready to push + ``` + git fetch + git merge upstream/main + git push origin + ``` ### Submitting Pull Request -- Go to your GitHub and navigate to your forked repo -- Click on `Pull requests` and then click on `New pull request` -- Click on `compare across forks` -- Click on `compare:` and select branch that you want to create a pull request for then click on `create pull request` +- Go to your GitHub and navigate to your forked repo +- Click on `Pull requests` and then click on `New pull request` +- Click on `compare across forks` +- Click on `compare:` and select branch that you want to create a pull request for then click on `create pull request` diff --git a/apps/common/components/AmountInput.tsx b/apps/common/components/AmountInput.tsx index 9c4127097..e5cf9def6 100644 --- a/apps/common/components/AmountInput.tsx +++ b/apps/common/components/AmountInput.tsx @@ -16,7 +16,7 @@ type TAmountInputProps = { onAmountChange?: (amount: string) => void; onLegendClick?: () => void; onMaxClick?: () => void; -} +}; export function AmountInput({ amount, @@ -33,15 +33,14 @@ export function AmountInput({ }: TAmountInputProps): ReactElement { return (
- {label && ( -

- {label} -

- )} + {label &&

{label}

}
@@ -70,4 +71,3 @@ export function AmountInput({
); } - diff --git a/apps/common/components/AppHeader.tsx b/apps/common/components/AppHeader.tsx index b8092ef0f..70b93c461 100644 --- a/apps/common/components/AppHeader.tsx +++ b/apps/common/components/AppHeader.tsx @@ -33,15 +33,17 @@ function Logo(): ReactElement { - + + front={'text-neutral-0'} + /> ); - } function LogoPopover(): ReactElement { @@ -51,14 +53,17 @@ function LogoPopover(): ReactElement { name: 'yETH', href: 'https://yeth.yearn.fi', isDisabled: false, - icon: + icon: ( + + ) }; return ( @@ -81,32 +86,32 @@ function LogoPopover(): ReactElement { leave={'transition ease-in duration-150'} leaveFrom={'opacity-100 translate-y-0'} leaveTo={'opacity-0 translate-y-1'}> - +
- { - [...Object.values(APPS), YETH] - .filter(({isDisabled}): boolean => !isDisabled) - .map(({name, href, icon}): ReactElement => { - return ( - set_isShowing(false)}> -
set_isShowing(false)} - className={'flex cursor-pointer flex-col items-center p-4 transition-colors hover:bg-neutral-200'}> -
- {cloneElement(icon)} -
-
- {name} -
+ {[...Object.values(APPS), YETH] + .filter(({isDisabled}): boolean => !isDisabled) + .map(({name, href, icon}): ReactElement => { + return ( + set_isShowing(false)}> +
set_isShowing(false)} + className={ + 'flex cursor-pointer flex-col items-center p-4 transition-colors hover:bg-neutral-200' + }> +
{cloneElement(icon)}
+
+ {name}
- - ); - })} +
+ + ); + })}
@@ -144,13 +149,16 @@ export function AppHeader(): ReactElement { } return [ HOME_MENU, - {path: 'https://gov.yearn.fi/', label: 'Governance', target: '_blank'}, + { + path: 'https://gov.yearn.fi/', + label: 'Governance', + target: '_blank' + }, {path: 'https://blog.yearn.fi/', label: 'Blog', target: '_blank'}, {path: 'https://docs.yearn.fi/', label: 'Docs', target: '_blank'} ]; }, [pathname]); - const supportedNetworks = useMemo((): number[] => { const ethereumOnlyPaths = ['/ycrv', '/ybal', '/veyfi', '/ybribe']; if (ethereumOnlyPaths.some((path): boolean => pathname.startsWith(path))) { @@ -162,23 +170,24 @@ export function AppHeader(): ReactElement { return (
} currentPathName={pathname} onOpenMenuMobile={onOpenMenu} nav={menu} supportedNetworks={supportedNetworks} - logo={( + logo={ - )} + } extra={
- } /> + } + /> ); } diff --git a/apps/common/components/Apps.tsx b/apps/common/components/Apps.tsx index 851118ce5..b26d4193e 100644 --- a/apps/common/components/Apps.tsx +++ b/apps/common/components/Apps.tsx @@ -31,18 +31,21 @@ type TApp = { manifest: TMetaFile; icon: ReactElement; isDisabled?: boolean; -} +}; -export const APPS: { [key in AppName]: TApp } = { +export const APPS: {[key in AppName]: TApp} = { Vaults: { name: AppName.VAULTS, href: '/vaults', menu: VAULTS_MENU, manifest: vaultsManifest, - icon: + icon: ( + + ) }, yCRV: { name: AppName.YCRV, @@ -56,7 +59,8 @@ export const APPS: { [key in AppName]: TApp } = { height={32} src={`${process.env.BASE_YEARN_ASSETS_URI}/1/${YCRV_TOKEN_ADDRESS}/logo-128.png`} loading={'eager'} - priority /> + priority + /> ) }, yBal: { @@ -72,7 +76,8 @@ export const APPS: { [key in AppName]: TApp } = { height={32} src={`${process.env.BASE_YEARN_ASSETS_URI}/1/${YBAL_TOKEN_ADDRESS}/logo-128.png`} loading={'eager'} - priority /> + priority + /> ) }, veYFI: { @@ -80,19 +85,25 @@ export const APPS: { [key in AppName]: TApp } = { menu: VEYFI_MENU, href: '/veyfi', manifest: veyfiManifest, - icon: + icon: ( + + ) }, yBribe: { name: AppName.YBRIBE, href: '/ybribe', menu: YBRIBE_MENU, manifest: ybribeManifest, - icon: + icon: ( + + ) } }; diff --git a/apps/common/components/BalanceReminderPopover.tsx b/apps/common/components/BalanceReminderPopover.tsx index 2e11a81c4..bfe2efe05 100755 --- a/apps/common/components/BalanceReminderPopover.tsx +++ b/apps/common/components/BalanceReminderPopover.tsx @@ -3,42 +3,50 @@ import {Popover, Transition} from '@headlessui/react'; import {captureException} from '@sentry/nextjs'; import {Renderable} from '@yearn-finance/web-lib/components/Renderable'; import {useWeb3} from '@yearn-finance/web-lib/contexts/useWeb3'; -import {useChainID} from '@yearn-finance/web-lib/hooks/useChainID'; import {IconAddToMetamask} from '@yearn-finance/web-lib/icons/IconAddToMetamask'; import {IconCross} from '@yearn-finance/web-lib/icons/IconCross'; import {IconWallet} from '@yearn-finance/web-lib/icons/IconWallet'; import {toAddress, truncateHex} from '@yearn-finance/web-lib/utils/address'; -import {toBigInt} from '@yearn-finance/web-lib/utils/format.bigNumber'; +import {cl} from '@yearn-finance/web-lib/utils/cl'; import {formatAmount} from '@yearn-finance/web-lib/utils/format.number'; import {ImageWithFallback} from '@common/components/ImageWithFallback'; import {useWallet} from '@common/contexts/useWallet'; import {useYearn} from '@common/contexts/useYearn'; import {useBalance} from '@common/hooks/useBalance'; +import {IconQuestion} from '@common/icons/IconQuestion'; import type {ReactElement} from 'react'; -import type {TAddress, TDict} from '@yearn-finance/web-lib/types'; -import type {TBalanceData} from '@yearn-finance/web-lib/types/hooks'; +import type {TAddress} from '@yearn-finance/web-lib/types'; +import type {TChainTokens} from '@common/types/types'; type TBalanceReminderElement = { - address: TAddress, - normalizedBalance: number, - decimals: number, - symbol: string, -} + address: TAddress; + chainID: number; + normalizedBalance: number; + decimals: number; + symbol: string; +}; function TokenItem({element}: {element: TBalanceReminderElement}): ReactElement { const {provider} = useWeb3(); - const {safeChainID} = useChainID(); - const balance = useBalance(element.address); + const balance = useBalance({address: element.address, chainID: element.chainID}); - async function addTokenToMetamask(address: TAddress, symbol: string, decimals: number, image: string): Promise { + async function addTokenToMetamask( + address: TAddress, + symbol: string, + decimals: number, + image: string + ): Promise { if (!provider) { return; } try { const walletClient = await provider.getWalletClient(); - await walletClient.watchAsset({type: 'ERC20', options: {address, decimals, symbol, image}}); + await walletClient.watchAsset({ + type: 'ERC20', + options: {address, decimals, symbol, image} + }); } catch (error) { captureException(error); console.warn(error); @@ -60,7 +68,10 @@ function TokenItem({element}: {element: TBalanceReminderElement}): ReactElement width={32} height={32} quality={90} - src={`${process.env.BASE_YEARN_ASSETS_URI}/${safeChainID}/${toAddress(element.address)}/logo-128.png`} /> + src={`${process.env.BASE_YEARN_ASSETS_URI}/${element.chainID}/${toAddress( + element.address + )}/logo-128.png`} + />
{element.symbol} @@ -74,10 +85,15 @@ function TokenItem({element}: {element: TBalanceReminderElement}): ReactElement element.address, element.symbol, element.decimals, - `${process.env.BASE_YEARN_ASSETS_URI}/${safeChainID}/${toAddress(element.address)}/logo-128.png` + `${process.env.BASE_YEARN_ASSETS_URI}/${element.chainID}/${toAddress( + element.address + )}/logo-128.png` ); }} - className={'ml-4 h-4 w-4 cursor-pointer text-neutral-400 transition-colors hover:text-neutral-900'} /> + className={ + 'ml-4 h-4 w-4 cursor-pointer text-neutral-400 transition-colors hover:text-neutral-900' + } + /> @@ -85,49 +101,52 @@ function TokenItem({element}: {element: TBalanceReminderElement}): ReactElement } export function BalanceReminderPopover(): ReactElement { - const {balances, isLoading} = useWallet(); + const {balances: tokens, isLoading, triggerForknetBalances, shouldUseForknetBalances} = useWallet(); const {address, ens, isActive, onDesactivate} = useWeb3(); const {vaults} = useYearn(); - const nonNullBalances = useMemo((): TDict => { - const nonNullBalances = Object.entries(balances).reduce((acc: TDict, [address, balance]): TDict => { - if (toBigInt(balance?.raw) > 0n) { - acc[toAddress(address)] = balance; + const nonNullBalances = useMemo((): TChainTokens => { + const nonNullBalances: TChainTokens = {}; + + for (const [chainIDStr, chainTokens] of Object.entries(tokens)) { + const chainID = Number(chainIDStr); + nonNullBalances[chainID] = {}; + for (const [, token] of Object.entries(chainTokens)) { + if (token.balance.raw > 0n) { + nonNullBalances[chainID][token.address] = token; + } } - return acc; - }, {}); + } return nonNullBalances; - }, [balances]); + }, [tokens]); const nonNullBalancesForVault = useMemo((): TBalanceReminderElement[] => { - const nonNullBalancesForVault = Object.entries(nonNullBalances).reduce((acc: TBalanceReminderElement[], [address, balance]): TBalanceReminderElement[] => { - const currentVault = vaults?.[toAddress(address)]; - if (currentVault) { - acc.push({ - address: toAddress(address), - normalizedBalance: balance.normalized, - decimals: balance.decimals, - symbol: currentVault.symbol - }); + const nonNullBalancesForVault: TBalanceReminderElement[] = []; + + for (const [, chainBalanceData] of Object.entries(nonNullBalances)) { + for (const [address, token] of Object.entries(chainBalanceData)) { + if (token.balance.raw > 0n) { + const currentVault = vaults?.[toAddress(address)]; + if (currentVault) { + nonNullBalancesForVault.push({ + address: toAddress(address), + chainID: currentVault.chainID, + normalizedBalance: Number(token.balance.normalized), + decimals: token.decimals, + symbol: currentVault.symbol + }); + } + } } - return acc; - }, []); + } return nonNullBalancesForVault; - }, [nonNullBalances, vaults]); + }, [nonNullBalances]); function renderNoTokenFallback(isLoading: boolean): ReactElement { if (isLoading) { - return ( -
- {'Retrieving your yvTokens ...'} -
- ); + return
{'Retrieving your yvTokens ...'}
; } - return ( -
- {'No position in Yearn found.'} -
- ); + return
{'No position in Yearn found.'}
; } return ( @@ -145,29 +164,60 @@ export function BalanceReminderPopover(): ReactElement { leave={'transition ease-in duration-150'} leaveFrom={'opacity-100 translate-y-0'} leaveTo={'opacity-0 translate-y-1'}> - +
-
+
+ +
+
- {isActive && address && ens ? ( - ens - ) : isActive && address ? ( - truncateHex(address, 5) - ) : 'Connect wallet'} + {isActive && address && ens + ? ens + : isActive && address + ? truncateHex(address, 5) + : 'Connect wallet'}
0} fallback={renderNoTokenFallback(isLoading)}> - {nonNullBalancesForVault.map((element): ReactElement => )} + {nonNullBalancesForVault.map( + (element): ReactElement => ( + + ) + )}
diff --git a/apps/common/components/Dropdown.tsx b/apps/common/components/Dropdown.tsx index 3415d43af..13ac146f6 100644 --- a/apps/common/components/Dropdown.tsx +++ b/apps/common/components/Dropdown.tsx @@ -14,7 +14,9 @@ const DropdownOption = (option: TDropdownOption): ReactElement => { return ( {({active}): ReactElement => ( -
+
{icon && (
{
)}
-

- {label} -

+

{label}

{description && (

{description} @@ -68,7 +68,7 @@ export type TDropdownOption = { label: string; description?: string; icon?: string; -} +}; export type TDropdownProps = { selected?: TDropdownOption; @@ -78,9 +78,17 @@ export type TDropdownProps = { legend?: string; isDisabled?: boolean; className?: string; -} +}; -export const Dropdown = ({selected, options, onChange, label, legend, isDisabled, className}: TDropdownProps): ReactElement => { +export const Dropdown = ({ + selected, + options, + onChange, + label, + legend, + isDisabled, + className +}: TDropdownProps): ReactElement => { const [isOpen, set_isOpen] = useThrottledState(false, 400); const [search, set_search] = useState(''); @@ -101,20 +109,20 @@ export const Dropdown = ({selected, options, onChange, label, legend, isDisabled e.stopPropagation(); e.preventDefault(); set_isOpen(false); - }} /> + }} + /> ) : null} { performBatchedUpdates((): void => { - if(onChange) { + if (onChange) { onChange(option); } set_isOpen(false); }); }} - disabled={isDisabled} - > + disabled={isDisabled}> <> set_isOpen((state: boolean): boolean => !state)} @@ -142,8 +150,10 @@ export const Dropdown = ({selected, options, onChange, label, legend, isDisabled isDisabled ? 'text-neutral-600' : 'text-neutral-900' )}> option?.label ?? '-' } + className={ + 'w-full cursor-default overflow-x-scroll border-none bg-transparent p-0 outline-none scrollbar-none' + } + displayValue={(option?: TDropdownOption): string => option?.label ?? '-'} spellCheck={false} onChange={(event): void => { performBatchedUpdates((): void => { @@ -157,7 +167,10 @@ export const Dropdown = ({selected, options, onChange, label, legend, isDisabled

+ className={`h-6 w-6 transition-transform ${ + isOpen ? '-rotate-180' : 'rotate-0' + }`} + />
) : ( - filteredOptions.map(({id, label, description, icon}): ReactElement => ( - - )) + filteredOptions.map( + ({id, label, description, icon}): ReactElement => ( + + ) + ) )}
- {legend && ( -

- {legend} -

- )} + {legend &&

{legend}

}
); }; - diff --git a/apps/common/components/GaugeDropdown.tsx b/apps/common/components/GaugeDropdown.tsx index c56f29aa9..ecbdbb64f 100755 --- a/apps/common/components/GaugeDropdown.tsx +++ b/apps/common/components/GaugeDropdown.tsx @@ -10,8 +10,10 @@ import type {TDropdownGaugeItemProps, TDropdownGaugeOption, TDropdownGaugeProps} function DropdownItem({option}: TDropdownGaugeItemProps): ReactElement { return ( - {({active}): ReactElement => -
+ {({active}): ReactElement => ( +
{option?.icon ? cloneElement(option.icon) : null}
@@ -24,7 +26,7 @@ function DropdownItem({option}: TDropdownGaugeItemProps): ReactElement {

- } + )}
); } @@ -48,30 +50,30 @@ function DropdownEmpty({query}: {query: string}): ReactElement { ); } -export function Dropdown({ - options, - selected, - onSelect, - placeholder = '' -}: TDropdownGaugeProps): ReactElement { +export function Dropdown({options, selected, onSelect, placeholder = ''}: TDropdownGaugeProps): ReactElement { const [isOpen, set_isOpen] = useState(false); const [query, set_query] = useState(''); - const orderedOptions = useMemo((): TDropdownGaugeOption[] => (options || []).sort((a, b): number => { - if (a.value.APY < b.value.APY) { - return 1; - } - if (a.value.APY > b.value.APY) { - return -1; - } - return 0; - }), [options]); + const orderedOptions = useMemo( + (): TDropdownGaugeOption[] => + (options || []).sort((a, b): number => { + if (a.value.APY < b.value.APY) { + return 1; + } + if (a.value.APY > b.value.APY) { + return -1; + } + return 0; + }), + [options] + ); - const filteredOptions = query === '' - ? orderedOptions - : orderedOptions.filter((option): boolean => { - return option.label.toLowerCase().includes(query.toLowerCase()); - }); + const filteredOptions = + query === '' + ? orderedOptions + : orderedOptions.filter((option): boolean => { + return option.label.toLowerCase().includes(query.toLowerCase()); + }); return (
@@ -82,7 +84,8 @@ export function Dropdown({ e.stopPropagation(); e.preventDefault(); set_isOpen(false); - }} /> + }} + /> set_isOpen(!isOpen)} - className={'flex h-10 w-full items-center justify-between bg-neutral-0 p-2 text-base text-neutral-900 md:px-3'}> + className={ + 'flex h-10 w-full items-center justify-between bg-neutral-0 p-2 text-base text-neutral-900 md:px-3' + }>
-
- {selected?.icon ? cloneElement(selected.icon) :
} +
+ {selected?.icon ? ( + cloneElement(selected.icon) + ) : ( +
+ )}
-

+

option.label} placeholder={placeholder} spellCheck={false} - onChange={(event): void => set_query(event.target.value)} /> + onChange={(event): void => set_query(event.target.value)} + />

+ className={`h-6 w-6 transition-transform ${isOpen ? '-rotate-180' : 'rotate-0'}`} + />
set_query('')}> - + 0} fallback={}> - {filteredOptions.map((option): ReactElement => )} + {filteredOptions.map( + (option): ReactElement => ( + + ) + )} diff --git a/apps/common/components/HeroTimer.tsx b/apps/common/components/HeroTimer.tsx index 894457846..e4d14f74d 100755 --- a/apps/common/components/HeroTimer.tsx +++ b/apps/common/components/HeroTimer.tsx @@ -9,7 +9,7 @@ extend(dayjsDuration); type TProps = { endTime?: TSeconds; -} +}; export function HeroTimer({endTime}: TProps): ReactElement { const time = useTimer({endTime}); @@ -18,8 +18,13 @@ export function HeroTimer({endTime}: TProps): ReactElement {
-
- +
+ {time}
diff --git a/apps/common/components/ImageWithFallback.tsx b/apps/common/components/ImageWithFallback.tsx index ba6b1b9e5..d97113679 100755 --- a/apps/common/components/ImageWithFallback.tsx +++ b/apps/common/components/ImageWithFallback.tsx @@ -27,6 +27,7 @@ export function ImageWithFallback(props: ImageProps): ReactElement { set_imageStyle({filter: 'opacity(0.2)'}); }); }} - {...rest} /> + {...rest} + /> ); } diff --git a/apps/common/components/Input.tsx b/apps/common/components/Input.tsx index 7e071293f..e1e919ad5 100644 --- a/apps/common/components/Input.tsx +++ b/apps/common/components/Input.tsx @@ -10,21 +10,18 @@ type TAmountInputProps = { isDisabled?: boolean; isLoading?: boolean; className?: string; -} +}; export function Input(props: TAmountInputProps): ReactElement { const {value, onChange, label, placeholder, legend, error, isDisabled, isLoading, className = ''} = props; return (
- {label && ( -

- {label} -

- )} + {label &&

{label}

}
{(error ?? legend) && ( - + {error ?? legend} )} diff --git a/apps/common/components/ListHead.tsx b/apps/common/components/ListHead.tsx index f4a2553d2..1ffff38bf 100644 --- a/apps/common/components/ListHead.tsx +++ b/apps/common/components/ListHead.tsx @@ -7,68 +7,86 @@ import type {TSortDirection} from '@common/types/types'; export type TListHead = { items: { - label: string, - value: string, - sortable?: boolean, - className?: string - }[], - dataClassName?: string, - wrapperClassName?: string, - tokenClassName?: string, - sortBy: string, - sortDirection: TSortDirection, - onSort: (sortBy: string, sortDirection: TSortDirection) => void -} + label: string | ReactElement; + value: string; + sortable?: boolean; + className?: string; + }[]; + dataClassName?: string; + wrapperClassName?: string; + tokenClassName?: string; + sortBy: string; + sortDirection: TSortDirection; + onSort: (sortBy: string, sortDirection: TSortDirection) => void; +}; -export function ListHead({items, dataClassName, wrapperClassName, tokenClassName, sortBy, sortDirection, onSort}: TListHead): ReactElement { +export function ListHead({ + items, + dataClassName, + wrapperClassName, + tokenClassName, + sortBy, + sortDirection, + onSort +}: TListHead): ReactElement { const toggleSortDirection = (newSortBy: string): TSortDirection => { - return sortBy === newSortBy ? ( - sortDirection === '' ? 'desc' : sortDirection === 'desc' ? 'asc' : 'desc' - ) : 'desc'; + return sortBy === newSortBy + ? sortDirection === '' + ? 'desc' + : sortDirection === 'desc' + ? 'asc' + : 'desc' + : 'desc'; }; - const renderChevron = useCallback((shouldSortBy: boolean): ReactElement => { - if (shouldSortBy && sortDirection === 'desc') { - return ; - } - if (shouldSortBy && sortDirection === 'asc') { - return ; - } - return ; - }, [sortDirection]); + const renderChevron = useCallback( + (shouldSortBy: boolean): ReactElement => { + if (shouldSortBy && sortDirection === 'desc') { + return ; + } + if (shouldSortBy && sortDirection === 'asc') { + return ; + } + return ( + + ); + }, + [sortDirection] + ); - const [first, ...rest] = items; + const [chain, token, ...rest] = items; return (
+

{chain.label}

+
- {rest.map((item, index): ReactElement => ( - - ))} + {rest.map( + (item, index): ReactElement => ( + + ) + )}
); } - diff --git a/apps/common/components/ListHero.tsx b/apps/common/components/ListHero.tsx index 6a43cb419..0b291b75d 100644 --- a/apps/common/components/ListHero.tsx +++ b/apps/common/components/ListHero.tsx @@ -2,6 +2,12 @@ import {useEffect, useState} from 'react'; import {Switch as HeadlessSwitch} from '@headlessui/react'; import {useIsMounted} from '@react-hookz/web'; import {Button} from '@yearn-finance/web-lib/components/Button'; +import {IconArbitrumChain} from '@yearn-finance/web-lib/icons/chains/IconArbitrumChain'; +import {IconBaseChain} from '@yearn-finance/web-lib/icons/chains/IconBaseChain'; +import {IconEtherumChain} from '@yearn-finance/web-lib/icons/chains/IconEtherumChain'; +import {IconFantomChain} from '@yearn-finance/web-lib/icons/chains/IconFantomChain'; +import {IconOptimismChain} from '@yearn-finance/web-lib/icons/chains/IconOptimismChain'; +import {MultiSelectDropdown} from '@common/components/MultiSelectDropdown'; import {SearchBar} from '@common/components/SearchBar'; import {isValidCategory} from '@common/types/category'; @@ -11,13 +17,13 @@ export type TListHeroCategory = { label: string; node?: ReactNode; value: T; - isSelected?: boolean, -} + isSelected?: boolean; +}; type TSwitchProps = { isEnabled: boolean; onSwitch?: (state: boolean) => void; -} +}; export type TListHero = { headLabel: string; @@ -25,14 +31,16 @@ export type TListHero = { searchPlaceholder: string; categories: TListHeroCategory[][]; onSelect: (category: T) => void; + selectedChains?: string; + set_selectedChains?: (chains: string) => void; searchValue: string; set_searchValue: (searchValue: string) => void; -} +}; export type TListHeroDesktopCategories = { categories: TListHeroCategory[][]; onSelect: (category: T) => void; -} +}; function DesktopCategories({categories, onSelect}: TListHeroDesktopCategories): ReactElement { const [isClientLoaded, set_isClientLoaded] = useState(false); @@ -46,24 +54,30 @@ function DesktopCategories({categories, onSelect}: TListHeroDesktopCategories return (
-
- {(categories || []).map((currentCategory, index: number): ReactElement => ( -
- {currentCategory.map((item): ReactElement => ( - - ))} -
- ))} +
+ {(categories || []).map( + (currentCategory, index: number): ReactElement => ( +
+ {currentCategory.map( + (item): ReactElement => ( + + ) + )} +
+ ) + )}
); @@ -86,12 +100,13 @@ function Switch(props: TSwitchProps): ReactElement { keyCode === 13 ? safeOnSwitch() : null} + onKeyDown={({keyCode}: {keyCode: number}): unknown => (keyCode === 13 ? safeOnSwitch() : null)} className={'yearn--next-switch'}> {'Use setting'}
+ className={(onSwitch ? isEnabled : isEnabledState) ? 'translate-x-[14px]' : 'translate-x-0'} + />
); @@ -103,9 +118,46 @@ export function ListHero({ categories, onSelect, searchValue, + selectedChains, set_searchValue, + set_selectedChains, switchProps }: TListHero): ReactElement { + const chains = JSON.parse(selectedChains || '[]') as number[]; + + const OPTIONS = [ + { + label: 'Ethereum', + value: 1, + isSelected: chains.includes(1), + icon: + }, + { + label: 'OP Mainnet', + value: 10, + isSelected: chains.includes(10), + icon: + }, + { + label: 'Fantom', + value: 250, + isSelected: chains.includes(250), + icon: + }, + { + label: 'Base', + value: 8453, + isSelected: chains.includes(8453), + icon: + }, + { + label: 'Arbitrum One', + value: 42161, + isSelected: chains.includes(42161), + icon: + } + ]; + const isMounted = useIsMounted(); return ( @@ -121,12 +173,25 @@ export function ListHero({
+ onSelect={onSelect} + /> + + { + const selectedChains = options + .filter((o): boolean => o.isSelected) + .map((option): number => Number(option.value)); + set_selectedChains?.(JSON.stringify(selectedChains)); + }} + /> + set_searchValue={set_searchValue} + /> {!!switchProps && (
@@ -145,25 +210,32 @@ export function ListHero({ onSelect(value); } }}> - {isMounted() && categories.map((currentCategory): ReactNode => ( - currentCategory.map((item): ReactElement => ( - - )) - ))} + {isMounted() && + categories.map( + (currentCategory): ReactNode => + currentCategory.map( + (item): ReactElement => ( + + ) + ) + )}
): void => set_searchValue(e.target.value)} /> + onChange={(e: ChangeEvent): void => set_searchValue(e.target.value)} + />
diff --git a/apps/common/components/Meta.tsx b/apps/common/components/Meta.tsx index eea36a276..76a1bd658 100755 --- a/apps/common/components/Meta.tsx +++ b/apps/common/components/Meta.tsx @@ -26,84 +26,151 @@ export type TMetaFile = { start_url: string; display: string; orientation: string; -} +}; function Meta({meta}: {meta: TMetaFile}): ReactElement { return ( <> {meta.name} - - - - - - + + + + + + - - - - - - - - + + + + + + + + - + + color={meta.theme_color} + /> + href={'/favicons/favicon.ico'} + /> + href={'/favicons/favicon-32x32.png'} + /> + href={'/favicons/favicon-16x16.png'} + /> + href={'/favicons/android-icon-512x512.png'} + /> + href={'/favicons/android-icon-192x192.png'} + /> - + href={'/favicons/android-icon-144x144.png'} + /> + + href={'/favicons/apple-icon-152x152.png'} + /> + href={'/favicons/apple-icon-180x180.png'} + /> + href={'/favicons/apple-icon-167x167.png'} + />