diff --git a/package.json b/package.json index 07569df..cb1495c 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,10 @@ "@next/next/no-html-link-for-pages": [ "warn", "site/pages" + ], + "complexity": [ + "warn", + 20 ] } } diff --git a/site/components/DPAuctionsLayout.js b/site/components/DPAuctionsLayout.js index 88ff81f..e66b723 100644 --- a/site/components/DPAuctionsLayout.js +++ b/site/components/DPAuctionsLayout.js @@ -5,7 +5,7 @@ import DPAuctionsContextProvider from './DPAuctionsContext' import Layout from './Layout' import Transactions from './Transactions' -function PaymentStreamsLayout({ children }) { +function DPAuctionsLayout({ children }) { const t = useTranslations() return ( @@ -19,4 +19,4 @@ function PaymentStreamsLayout({ children }) { ) } -export default PaymentStreamsLayout +export default DPAuctionsLayout diff --git a/site/components/UtilitiesTabs.js b/site/components/UtilitiesTabs.js index 68aa51e..9940b6e 100644 --- a/site/components/UtilitiesTabs.js +++ b/site/components/UtilitiesTabs.js @@ -43,7 +43,7 @@ function UtilitiesTabs() { // positions constant. // // Add Descending Price Auctions if Uniswap v2 is supported. - if (utilsConfig[chainId].dpAuctions.uniswapV2) { + if (chainId && utilsConfig[chainId]?.dpAuctions.uniswapV2) { items.splice(5, 0, { href: '/dp-auctions', label: t('dp-auctions'), @@ -51,7 +51,7 @@ function UtilitiesTabs() { }) } // Add Payment Streams if ChainLink is supported. - if (utilsConfig[chainId]?.paymentStreams?.chainLink) { + if (chainId && utilsConfig[chainId]?.paymentStreams?.chainLink) { items.splice(3, 0, { href: '/payment-streams', label: t('payment-streams'), diff --git a/site/components/payment-streams/CreateStream.js b/site/components/payment-streams/CreateStream.js index a86935f..0b5b540 100644 --- a/site/components/payment-streams/CreateStream.js +++ b/site/components/payment-streams/CreateStream.js @@ -21,6 +21,7 @@ import { PaymentStreamsLibContext } from './PaymentStreamsLib' const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000' +// To create a payment stream, the payment token has to have a ChainLink feed! const useSupportedTokens = function () { const { data, error } = useSWR('supported-tokens', () => fetchJson('https://cl-docs-addresses.web.app/addresses.json').then( @@ -57,9 +58,9 @@ const CreateStream = function () { // tokens are in the list in the form of " / [USD|ETH]"" pairs. For example: "UNI / USD" // addresses are not available - const isTokenSupported = function (value) { + const isTokenSupported = function (address) { // vesper is registered as "Vesper Finance TVL" - see https://docs.chain.link/docs/ethereum-addresses/#Ethereum%20Mainnet - const symbol = findToken(value, 1)?.symbol.toLowerCase() + const symbol = findToken(address, 1)?.symbol.toLowerCase() if (!symbol) { return false } diff --git a/site/pages/[locale]/merkle-claims.js b/site/pages/[locale]/merkle-claims.js index 5e9c795..5d6c8d4 100644 --- a/site/pages/[locale]/merkle-claims.js +++ b/site/pages/[locale]/merkle-claims.js @@ -35,7 +35,7 @@ function MerkleClaims() { merkle.getHolding && merkle .getHolding(cID) - .then(h => { + .then(function (h) { if (h.isClaimable) { clearFeedback() } else { @@ -50,16 +50,19 @@ function MerkleClaims() { [merkle] ) - const handleClaimIDChange = function (e) { - const re = /^[0-9\b]+$/ - if (e.target.value === '' || re.test(e.target.value)) { - clearFeedback() - setClaimID(e.target.value) - delayedClaimID(e.target.value) - } - } + const handleClaimIDChange = useCallback( + function (e) { + const re = /^[0-9\b]+$/ + if (e.target.value === '' || re.test(e.target.value)) { + clearFeedback() + setClaimID(e.target.value) + delayedClaimID(e.target.value) + } + }, + [delayedClaimID] + ) - const handleClaimSubmit = () => { + const handleClaimSubmit = function () { setClaimInProgress(true) setInfoMessage(t('claim-in-progress')) return merkle @@ -73,10 +76,13 @@ function MerkleClaims() { .then(() => watchAsset({ account, token: holding.token })) } - useEffect(() => { - clearFeedback() - setClaimID('') - }, [active, account]) + useEffect( + function () { + clearFeedback() + setClaimID('') + }, + [active, account] + ) useEffect(() => setHolding({ amount: '', isClaimable: false }), [claimID]) @@ -84,7 +90,7 @@ function MerkleClaims() { function setClaimIdFromQueryOnLoad() { handleClaimIDChange({ target: { value: query.id } }) }, - [merkle, query] + [handleClaimIDChange, merkle, query] ) return ( @@ -108,6 +114,7 @@ function MerkleClaims() { toFixed(fromUnit(holding.amount, holding.token.decimals), 6) } /> + {/* TODO disable the button if not claimable! */} diff --git a/site/pages/[locale]/token-revokes.js b/site/pages/[locale]/token-revokes.js index 53e6dcb..b3d9e01 100644 --- a/site/pages/[locale]/token-revokes.js +++ b/site/pages/[locale]/token-revokes.js @@ -64,7 +64,7 @@ const getNewestApprovals = function ({ logs, tokenApprovals, library }) { const newestOperation = allOperations[0] if (library.utils.hexToNumberString(newestOperation.allowance) === '0') { - return + return null } return newestOperation }) @@ -221,7 +221,7 @@ function useTokenApprovals() { useEffect( function () { if (!active || !account) { - return + return undefined } const subscription = library.eth.subscribe('logs', { diff --git a/site/pages/[locale]/wrap-eth.js b/site/pages/[locale]/wrap-eth.js index 9a5c187..c355c33 100644 --- a/site/pages/[locale]/wrap-eth.js +++ b/site/pages/[locale]/wrap-eth.js @@ -70,7 +70,7 @@ const WrapUnwrapEth = function () { const handleSubmit = function (e) { e.preventDefault() if (!active || !isValidNumber) { - return + return null } const erc20Service = erc20(account)