-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from lidofinance/develop
from develop to main
- Loading branch information
Showing
15 changed files
with
230 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { FC } from 'react'; | ||
import { GetStaticPaths, GetStaticProps } from 'next'; | ||
import Head from 'next/head'; | ||
import { useWeb3 } from 'reef-knot/web3-react'; | ||
|
||
import { Layout } from 'shared/components'; | ||
import NoSSRWrapper from 'shared/components/no-ssr-wrapper'; | ||
|
||
import { WithdrawalsTabs } from 'features/withdrawals'; | ||
import { WithdrawalsProvider } from 'features/withdrawals/contexts/withdrawals-context'; | ||
|
||
const Withdrawals: FC<WithdrawalsModePageParams> = ({ mode }) => { | ||
const { account, chainId } = useWeb3(); | ||
|
||
return ( | ||
<Layout | ||
title="Withdrawals" | ||
subtitle="Request stETH/wstETH withdrawal and claim ETH" | ||
> | ||
<Head> | ||
<title>Withdrawals | Lido</title> | ||
</Head> | ||
<WithdrawalsProvider mode={mode}> | ||
<NoSSRWrapper> | ||
{/* In order to simplify side effects of switching wallets we remount the whole widget, resetting all internal state */} | ||
<WithdrawalsTabs key={`${account ?? '_'}${chainId ?? '1'}`} /> | ||
</NoSSRWrapper> | ||
</WithdrawalsProvider> | ||
</Layout> | ||
); | ||
}; | ||
|
||
export default Withdrawals; | ||
|
||
type WithdrawalsModePageParams = { | ||
mode: 'request' | 'claim'; | ||
}; | ||
|
||
export const getStaticPaths: GetStaticPaths< | ||
WithdrawalsModePageParams | ||
> = async () => { | ||
return { | ||
paths: [{ params: { mode: 'request' } }, { params: { mode: 'claim' } }], | ||
fallback: false, // return 404 on non match | ||
}; | ||
}; | ||
|
||
export const getStaticProps: GetStaticProps< | ||
WithdrawalsModePageParams, | ||
WithdrawalsModePageParams | ||
> = async ({ params }) => { | ||
if (!params?.mode) return { notFound: true }; | ||
return { props: { mode: params.mode } }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { createServer } from 'http'; | ||
import { parse } from 'url'; | ||
import next from 'next'; | ||
|
||
const dev = process.env.NODE_ENV !== 'production'; | ||
const hostname = 'localhost'; | ||
const port = Number(process.env.PORT) || 3000; | ||
// when using middleware `hostname` and `port` must be provided below | ||
const app = next({ dev, hostname, port }); | ||
const handle = app.getRequestHandler(); | ||
// cannot import from next.config.mjs because this will break env load | ||
const CACHE_CONTROL_HEADER = 'x-cache-control'; | ||
|
||
// allows us to override cache-control header | ||
const overrideSetHeader = (res) => { | ||
const setHeader = res.setHeader; | ||
let cacheControlOverwritten = false; | ||
res.setHeader = function (header, value) { | ||
if (header.toLowerCase() === CACHE_CONTROL_HEADER) { | ||
cacheControlOverwritten = true; | ||
return setHeader.call(this, 'Cache-Control', value); | ||
} | ||
|
||
if (header.toLowerCase() === 'cache-control' && cacheControlOverwritten) { | ||
return this; | ||
} | ||
|
||
return setHeader.call(this, header, value); | ||
}; | ||
}; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
app.prepare().then(() => { | ||
createServer(async (req, res) => { | ||
// Be sure to pass `true` as the second argument to `url.parse`. | ||
// This tells it to parse the query portion of the URL. | ||
const parsedUrl = parse(req.url, true); | ||
|
||
overrideSetHeader(res); | ||
|
||
await handle(req, res, parsedUrl); | ||
}) | ||
.once('error', (err) => { | ||
console.error(err); | ||
process.exit(1); | ||
}) | ||
.listen(port, () => { | ||
console.debug(`> Ready on http://${hostname}:${port}`); | ||
}); | ||
}); |
Oops, something went wrong.