Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release candidate v7.23.0 #11505

Merged
merged 76 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
5dcfcdc
feat(Hero): create multiple hero components for new DS
TylerAPfledderer Jul 20, 2023
0b4f4e9
Merge remote-tracking branch 'origin/dev' into feat/hero-new-ds
TylerAPfledderer Sep 12, 2023
feba0e4
fix(Hero/utils): set optional tuple element for buttons
TylerAPfledderer Sep 18, 2023
25c443b
feat(pages/learn): implement `HubHero`
TylerAPfledderer Sep 18, 2023
8e83d10
Merge remote-tracking branch 'origin/dev' into feat/hero-new-ds
TylerAPfledderer Sep 20, 2023
cbe229b
refactor(Hero): use custom globalized `GatsbyImage`
TylerAPfledderer Sep 20, 2023
53286dd
fix(ContentHero): return empty for undefined button in iterative
TylerAPfledderer Sep 20, 2023
1e92f6e
refactor(Hero): create central import entry
TylerAPfledderer Sep 20, 2023
5344f14
refactor(ContentHero): allow entire `Breadcrumbs` prop object to be p…
TylerAPfledderer Sep 23, 2023
3a14aaf
refactor(ContentHero): render heading as `h1`
TylerAPfledderer Sep 23, 2023
1357ecd
chore(MdxHero): change `heroTitle` prop to `title`
TylerAPfledderer Sep 23, 2023
256fffc
chore(CallToAction): remove double import
TylerAPfledderer Sep 23, 2023
d1ebcc5
chore(CallToAction): add `content` as an omitted prop from `ButtonProps`
TylerAPfledderer Sep 24, 2023
1cb49e6
refactor(Hero): add `title` to `CommonHeroProps`
TylerAPfledderer Sep 24, 2023
7d388ec
refactor(CallToAction): change type signature for `index` prop
TylerAPfledderer Sep 24, 2023
f250f3c
fix(Hero): update prop names used in stories
TylerAPfledderer Sep 24, 2023
07619e5
style(MdxHero): remove margin from breadcrumbs and add TODO reminder
TylerAPfledderer Sep 24, 2023
051f51e
Merge branch 'dev' into feat/hero-new-ds
pettinarip Sep 26, 2023
7e4793e
fix(Hero): update imports from `Buttons`
TylerAPfledderer Sep 27, 2023
116955b
French content buckets (Use cases, Staking, Learn pages, Learn hub & …
corwintines Sep 27, 2023
7225634
Kannada content buckets (Use cases)
corwintines Sep 27, 2023
f03ee75
add "kn" to languages
wackerow Oct 2, 2023
700bb5b
Merge remote-tracking branch 'origin/dev' into feat/hero-new-ds
TylerAPfledderer Oct 3, 2023
136ccde
style(Hero): remove unneeded spacing override for breadcrumbs
TylerAPfledderer Oct 3, 2023
d77680d
Remove unused SVGs
minimalsm Oct 3, 2023
0f0c35b
Update src/content/translations/fr/staking/dvt/index.md
minimalsm Oct 3, 2023
ae10a05
fix(theme/Heading): flip `lineHeight`'s rendered to match DS
TylerAPfledderer Oct 4, 2023
e076088
Merge pull request #1 from ethereum/dev
intrepidocabral Oct 11, 2023
fa30c68
Update the date of ETH Brazil into community-events.json
intrepidocabral Oct 11, 2023
e96e255
Update review-process.md
fvaysh Oct 13, 2023
7788213
Merge branch 'dev' into sept26French
corwintines Oct 16, 2023
e63edca
Dutch content buckets (Essentials, Exploring, Use Ethereum, Use cases)
corwintines Oct 16, 2023
379c440
Merge pull request #11363 from TylerAPfledderer/fix/heading-flip-line…
pettinarip Oct 18, 2023
879e611
Merge remote-tracking branch 'origin/dev' into feat/hero-new-ds
TylerAPfledderer Oct 18, 2023
e2556af
feat(pages/learn): use new image for learn hub hero
TylerAPfledderer Oct 18, 2023
888b973
fix(pages/learn): add spacing beneath the hero on mobile
TylerAPfledderer Oct 18, 2023
b4784b7
chore: account create text typo
byhow Oct 18, 2023
d0f431a
Update wallet listing policy link [Fixes #11470]
samajammin Oct 18, 2023
195e2d8
patch stray colon to fix header
wackerow Oct 18, 2023
36a722b
chore(learn-hub-hero): supply higher-quality image
TylerAPfledderer Oct 19, 2023
ecb9e50
Spelling mistake in index.md
Wilson-Wu1 Oct 20, 2023
60f1854
Update Crowdin contributors
actions-user Oct 22, 2023
63c37ff
remove netlify-lambda from build process
pettinarip Oct 17, 2023
9973986
Merge pull request #11490 from ethereum/remove-netlify-lambda
corwintines Oct 23, 2023
ef1fb19
Merge pull request #11469 from byhow/fix/wallet-creation-spelling
corwintines Oct 23, 2023
ecc6b33
Merge pull request #11446 from ethereum/october15Dutch
minimalsm Oct 23, 2023
b360635
Merge pull request #11288 from ethereum/sept27Kannada
minimalsm Oct 23, 2023
49ca1fa
Merge pull request #11282 from ethereum/sept26French
minimalsm Oct 23, 2023
75652c8
Merge pull request #11483 from ethereum/automated-update-20231022001113
minimalsm Oct 23, 2023
cd14eae
patch intl links for wallet policy
wackerow Oct 23, 2023
b3fc66e
Update src/content/developers/tutorials/uniswap-v2-annotated-code/ind…
minimalsm Oct 23, 2023
184f864
Merge pull request #11480 from Wilson-Wu1/patch-1
minimalsm Oct 23, 2023
ae64e7e
docs: update README.md [skip ci]
allcontributors[bot] Oct 23, 2023
6d81a27
docs: update .all-contributorsrc [skip ci]
allcontributors[bot] Oct 23, 2023
8093328
Merge pull request #11491 from ethereum/all-contributors/add-Wilson-Wu1
minimalsm Oct 23, 2023
11d83b9
docs: update README.md [skip ci]
allcontributors[bot] Oct 23, 2023
e301e88
docs: update .all-contributorsrc [skip ci]
allcontributors[bot] Oct 23, 2023
3dea06c
Merge pull request #11435 from fvaysh/patch-1
minimalsm Oct 23, 2023
b7a7d42
Merge pull request #11492 from ethereum/all-contributors/add-fvaysh
minimalsm Oct 23, 2023
947cafd
docs: update README.md [skip ci]
allcontributors[bot] Oct 23, 2023
623d5f8
docs: update .all-contributorsrc [skip ci]
allcontributors[bot] Oct 23, 2023
511fcc8
Merge pull request #11493 from ethereum/all-contributors/add-costgallo
minimalsm Oct 23, 2023
f50e92e
Merge pull request #11471 from ethereum/wallet-listing-policy-link
wackerow Oct 23, 2023
e327039
Merge pull request #11472 from ethereum/header-patch
corwintines Oct 23, 2023
cb4fb77
remove WritersCohortBanner
wackerow Oct 23, 2023
9b35261
style(Morpher): update color to `body.medium`
TylerAPfledderer Oct 24, 2023
21ca922
refactor(pages/index): apply new home hero
TylerAPfledderer Oct 24, 2023
546dffe
remove lambda functions
pettinarip Oct 24, 2023
d96b2db
style(theme): update font styling for mono text
TylerAPfledderer Oct 24, 2023
722f6a2
Merge pull request #11132 from TylerAPfledderer/feat/hero-new-ds
corwintines Oct 25, 2023
124bcf5
Merge pull request #11416 from intrepidocabral/dev
corwintines Oct 25, 2023
2d70f03
Merge branch 'dev' into remove-cohort-banner
corwintines Oct 25, 2023
ba7a5c3
Merge pull request #11494 from ethereum/remove-cohort-banner
corwintines Oct 25, 2023
d6a776b
Merge pull request #11495 from ethereum/remove-lambdas
corwintines Oct 25, 2023
66e1989
Merge branch 'staging' into dev
corwintines Oct 25, 2023
2d51226
Merge pull request #11502 from TylerAPfledderer/fix/code-font-size
pettinarip Oct 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -10649,6 +10649,33 @@
"contributions": [
"ideas"
]
},
{
"login": "Wilson-Wu1",
"name": "Wilson Wu",
"avatar_url": "https://avatars.githubusercontent.com/u/41039035?v=4",
"profile": "https://www.linkedin.com/in/wilson-wu-2021/",
"contributions": [
"doc"
]
},
{
"login": "fvaysh",
"name": "VAS",
"avatar_url": "https://avatars.githubusercontent.com/u/126754021?v=4",
"profile": "https://github.com/fvaysh",
"contributions": [
"doc"
]
},
{
"login": "costgallo",
"name": "Costanza",
"avatar_url": "https://avatars.githubusercontent.com/u/49433698?v=4",
"profile": "https://github.com/costgallo",
"contributions": [
"doc"
]
}
],
"contributorsPerLine": 7,
Expand Down
2 changes: 1 addition & 1 deletion .storybook/i18next.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import i18n, { Resource } from "i18next"
import { initReactI18next } from "gatsby-plugin-react-i18next"
import fs from "fs"

export const baseLocales = {
en: { title: "English", left: "En" },
Expand All @@ -15,6 +14,7 @@ const ns = [
"glossary",
"page-about",
"page-index",
"page-learn",
"page-upgrades",
"page-developers-index",
]
Expand Down
2 changes: 1 addition & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const config: StorybookConfig = {
"@chakra-ui/storybook-addon",
"storybook-react-i18next",
],
staticDirs: ["../static"],
staticDirs: ["../static", "../src/assets"],
babel: async () => ({
...babelConfig,
}),
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1666,6 +1666,11 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center" valign="top" width="14.28%"><a href="https://github.com/robertkodra"><img src="https://avatars.githubusercontent.com/u/36516516?v=4?s=100" width="100px;" alt="Robert"/><br /><sub><b>Robert</b></sub></a><br /><a href="#content-robertkodra" title="Content">🖋</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/0xObsidian"><img src="https://avatars.githubusercontent.com/u/131651958?v=4?s=100" width="100px;" alt="obsidian"/><br /><sub><b>obsidian</b></sub></a><br /><a href="#content-0xObsidian" title="Content">🖋</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://www.scienft.com"><img src="https://avatars.githubusercontent.com/u/36033065?v=4?s=100" width="100px;" alt="Fekry Aiad"/><br /><sub><b>Fekry Aiad</b></sub></a><br /><a href="#ideas-MohamedFekryyy" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://www.linkedin.com/in/wilson-wu-2021/"><img src="https://avatars.githubusercontent.com/u/41039035?v=4?s=100" width="100px;" alt="Wilson Wu"/><br /><sub><b>Wilson Wu</b></sub></a><br /><a href="https://github.com/ethereum/ethereum-org-website/commits?author=Wilson-Wu1" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/fvaysh"><img src="https://avatars.githubusercontent.com/u/126754021?v=4?s=100" width="100px;" alt="VAS"/><br /><sub><b>VAS</b></sub></a><br /><a href="https://github.com/ethereum/ethereum-org-website/commits?author=fvaysh" title="Documentation">📖</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/costgallo"><img src="https://avatars.githubusercontent.com/u/49433698?v=4?s=100" width="100px;" alt="Costanza"/><br /><sub><b>Costanza</b></sub></a><br /><a href="https://github.com/ethereum/ethereum-org-website/commits?author=costgallo" title="Documentation">📖</a></td>
</tr>
</tbody>
</table>
Expand Down
6 changes: 3 additions & 3 deletions docs/review-process.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ This documentation outlines our current processes for how we prioritize items in

### General review process

We use a first-in, first-out system for reviewing pull requests. The longer a pull request has been open, the higher priority it is for our team to review. In some cases—for example, fixing a high-priority issue or merging low-hanging fruit for a deploy—we will stray from this process and use our best judgement to get higher-impact changes deployed more quickly.
We use a first-in, first-out system for reviewing pull requests. The longer a pull request has been open, the higher the priority it is for our team to review. In some cases—for example, fixing a high-priority issue or merging low-hanging fruit for a deploy—we will stray from this process and use our best judgement to get higher-impact changes deployed more quickly.

We aim to have every new PR reviewed with change requests, merged, or closed within 30 days of opening. As outlined in the following sections, different types of pull requests do have different levels of priority, and this may influence how promptly a pull request is acted on.

### Translations

Translation pull requests are considered high priority. These are when the translated and reviewed files from our translation management platform are submitted as a pull request. They are important to our core value of bringing Ethereum education to as many languages as possible. They also are the accumulation of months of work by translators and reviewers, and any delay to this already long process is undesirable.
Translation pull requests are considered high-priority. These are when the translated and reviewed files from our translation management platform are submitted as a pull request. They are important to our core value of bringing Ethereum education to as many languages as possible. They also are the accumulation of months of work by translators and reviewers, and any delay to this already long process is undesirable.

**Timeline:** PRs should be merged within 4 days of opening (by the next release).

Expand All @@ -24,7 +24,7 @@ Bug pull requests can vary from low-priority to high-priority depending on the s

### Features

Any new feature correlated to an approved issue is medium-priority. Similar to translators, code contributors dedicate a large amount of their time to improving [ethereum.org](http://ethereum.org) as a resource and addressing their efforts quickly is desirable. New features that were not discussed, requested or approved do not fall under this timeline.
Any new feature correlated with an approved issue is of medium priority. Similar to translators, code contributors dedicate a large amount of their time to improving [ethereum.org](http://ethereum.org) as a resource and addressing their efforts quickly is desirable. New features that were not discussed, requested or approved do not fall under this timeline.

**Timeline:** Major features should be merged within 30 days of opening. Minor features should be merged within 14 days of opening.

Expand Down
15 changes: 0 additions & 15 deletions gatsby-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,18 +495,3 @@ export const onPreBootstrap: GatsbyNode["onPreBootstrap"] = async ({
copyContributors()
reporter.info(`Contributors copied`)
}

// Build lambda functions when the build is complete and the `/public` folder exists
export const onPostBuild: GatsbyNode["onPostBuild"] = async (
gatsbyNodeHelpers
) => {
const { reporter } = gatsbyNodeHelpers

const reportOut = (report: { stderr: string; stdout: string }) => {
const { stderr, stdout } = report
if (stderr) reporter.error(stderr)
if (stdout) reporter.info(stdout)
}

reportOut(await exec("npm run build:lambda && cp netlify.toml public"))
}
8 changes: 5 additions & 3 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
# Default build command.
# command = "yarn build" # debug with: "yarn build --verbose"

# Directory with the serverless Lambda functions to deploy to AWS.
# netlify-lambda needs this netlify.toml file in order to build
# Directory with the serverless Lambda functions to deploy to AWS
functions = "public/functions"

[[headers]]
for = "/*"
[headers.values]
Access-Control-Allow-Origin = "https://esp.ethereum.foundation"
Access-Control-Allow-Origin = "https://esp.ethereum.foundation"

[[plugins]]
package = "@netlify/plugin-gatsby"
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"is-relative-url": "^3.0.0",
"lodash": "^4.17.21",
"luxon": "^1.28.1",
"netlify-lambda": "^2.0.3",
"polished": "^4.1.4",
"prism-react-renderer": "^1.1.1",
"prismjs": "^1.27.0",
Expand All @@ -83,6 +82,7 @@
"@chakra-ui/cli": "^2.4.1",
"@chakra-ui/storybook-addon": "^5.0.1",
"@netlify/functions": "^1.2.0",
"@netlify/plugin-gatsby": "^3.7.2",
"@storybook/addon-a11y": "^7.0.23",
"@storybook/addon-actions": "^7.0.23",
"@storybook/addon-essentials": "^7.0.23",
Expand Down Expand Up @@ -121,7 +121,6 @@
"scripts": {
"postinstall": "yarn theme",
"build": "gatsby build",
"build:lambda": "cross-env NODE_OPTIONS=--openssl-legacy-provider netlify-lambda build src/lambda --config=./webpack.lambda.js",
"build:10gb": "cross-env NODE_OPTIONS=--max-old-space-size=10240 gatsby build",
"clean": "gatsby clean",
"crowdin-clean": "rm -rf .crowdin && mkdir .crowdin",
Expand All @@ -134,7 +133,6 @@
"optimize-images": "ts-node -O '{ \"module\": \"commonjs\" }' src/scripts/optimizeImages.ts",
"crowdin-contributors": "ts-node -O '{ \"module\": \"commonjs\" }' src/scripts/crowdin/getCrowdinContributors.ts",
"start": "gatsby develop",
"start:lambda": "netlify-lambda serve src/lambda",
"start:static": "gatsby build && gatsby serve",
"serve": "gatsby serve",
"type-check": "tsc --noEmit",
Expand Down
8 changes: 4 additions & 4 deletions src/@chakra-ui/gatsby-plugin/components/Heading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ const { sizes: defaultSizes } = headingDefaultTheme

const lineHeightScale = {
"4xl": "6xs",
"3xl": ["5xs", null, "6xs"],
"2xl": ["5xs", null, "4xs"],
xl: ["3xs", null, "2xs"],
lg: ["3xs", null, "2xs"],
"3xl": ["6xs", null, "5xs"],
"2xl": ["4xs", null, "5xs"],
xl: ["2xs", null, "4xs"],
lg: ["2xs", null, "3xs"],
md: "xs",
sm: "base",
xs: "base",
Expand Down
6 changes: 3 additions & 3 deletions src/@chakra-ui/gatsby-plugin/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ const styles = {
visibility: "visible",
},
"pre, code, kbd, samp": {
fontSize: "0.8em",
lineHeight: "1.1rem",
fontFamily: "SFMono-Regular,Menlo,Monaco,Consolas,monospace",
fontSize: "md",
lineHeight: "base",
fontFamily: "monospace",
},
}),
}
Expand Down
53 changes: 45 additions & 8 deletions src/api/calendarEvents.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,54 @@
import axios from "axios"
import type { GatsbyFunctionRequest, GatsbyFunctionResponse } from "gatsby"
import { lambda } from "../lambda/calendarEvents"

async function handler(
__req: GatsbyFunctionRequest,
res: GatsbyFunctionResponse
): Promise<void> {
// passing env vars as arguments due to a bug on GC functions where env vars
// can not be accessed by imported functions
const { statusCode, body } = await lambda(
process.env.GOOGLE_API_KEY!,
process.env.GOOGLE_CALENDAR_ID!
)
res.status(statusCode).send(body)
const apiKey = process.env.GOOGLE_API_KEY
const calendarId = process.env.GOOGLE_CALENDAR_ID

try {
const futureEventsReq = await axios.get(
`https://content.googleapis.com/calendar/v3/calendars/${calendarId}/events`,
{
params: {
key: apiKey,
timeMin: new Date().toISOString(),
maxResults: 3,
singleEvents: true,
orderBy: "startTime",
},
}
)

const pastEventsReq = await axios.get(
`https://content.googleapis.com/calendar/v3/calendars/${calendarId}/events`,
{
params: {
key: apiKey,
timeMax: new Date().toISOString(),
maxResults: 4,
singleEvents: true,
orderBy: "startTime",
},
}
)

const response = {
pastEvents: pastEventsReq.data.items,
futureEvents: futureEventsReq.data.items,
}

res.status(200).send(JSON.stringify(response))
} catch (error) {
console.error(error)
res.status(500).send(
JSON.stringify({
msg: "Something went wrong with requesting the calendar events data.",
})
)
}
}

export default handler
34 changes: 28 additions & 6 deletions src/api/defipulse.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,37 @@
import axios from "axios"
import takeRightWhile from "lodash/takeRightWhile"
import type { GatsbyFunctionRequest, GatsbyFunctionResponse } from "gatsby"

import { lambda } from "../lambda/defipulse"

async function handler(
__req: GatsbyFunctionRequest,
res: GatsbyFunctionResponse
): Promise<void> {
// passing env vars as arguments due to a bug on GC functions where env vars
// can not be accessed by imported functions
const { statusCode, body } = await lambda()
res.status(statusCode).send(body)
try {
const response = await axios.get(`https://api.llama.fi/charts/Ethereum`)
if (response.status < 200 || response.status >= 300) {
return res
.status(response.status)
.send(JSON.stringify(response.statusText))
}

const { data } = response

// get only the last 90 days
const daysToFetch = 90
const now = new Date()
const startDate = new Date(now.setDate(now.getDate() - daysToFetch))
const startTimestamp = Math.round(startDate.getTime() / 1000)

const trimmedData = takeRightWhile(
data,
({ date }) => Number(date) > startTimestamp
)

res.status(200).send(JSON.stringify(trimmedData))
} catch (error) {
console.error(error)
res.status(500).send(JSON.stringify({ msg: (error as Error)?.message }))
}
}

export default handler
30 changes: 24 additions & 6 deletions src/api/etherscan.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
import axios from "axios"
import { GatsbyFunctionRequest, GatsbyFunctionResponse } from "gatsby"

import { lambda } from "../lambda/etherscan"

async function handler(
__req: GatsbyFunctionRequest,
res: GatsbyFunctionResponse
) {
// passing env vars as arguments due to a bug on GC functions where env vars
// can not be accessed by imported functions
const { statusCode, body } = await lambda(process.env.ETHERSCAN_API_KEY)
res.status(statusCode).send(body)
const apiKey = process.env.ETHERSCAN_API_KEY

const daysToFetch = 90
const now = new Date()
const endDate = now.toISOString().split("T")[0] // YYYY-MM-DD
const startDate = new Date(now.setDate(now.getDate() - daysToFetch))
.toISOString()
.split("T")[0] // {daysToFetch} days ago
try {
const response = await axios.get(
`https://api.etherscan.io/api?module=stats&action=nodecounthistory&startdate=${startDate}&enddate=${endDate}&sort=desc&apikey=${apiKey}`
)
if (response.status < 200 || response.status >= 300) {
return res
.status(response.status)
.send(JSON.stringify(response.statusText))
}
const { data } = response
res.status(200).send(JSON.stringify(data))
} catch (error) {
console.error(error)
res.status(500).send(JSON.stringify({ msg: (error as Error).message }))
}
}

export default handler
23 changes: 17 additions & 6 deletions src/api/etherscanBlock.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
import axios from "axios"
import { GatsbyFunctionRequest, GatsbyFunctionResponse } from "gatsby"

import { lambda } from "../lambda/etherscanBlock"

async function handler(
__req: GatsbyFunctionRequest,
res: GatsbyFunctionResponse
) {
// passing env vars as arguments due to a bug on GC functions where env vars
// can not be accessed by imported functions
const { statusCode, body } = await lambda(process.env.ETHERSCAN_API_KEY)
res.status(statusCode).send(body)
const apiKey = process.env.ETHERSCAN_API_KEY

try {
const response = await axios.get(
`https://api.etherscan.io/api?module=block&action=getblockcountdown&blockno=12965000&apikey=${apiKey}`
)
if (response.status < 200 || response.status >= 300) {
return res.status(response.status).send(response.statusText)
}

const { data } = response
res.status(200).send(JSON.stringify(data.result.EstimateTimeInSec || 0))
} catch (error) {
console.error(error)
res.status(500).send(JSON.stringify({ msg: (error as Error).message }))
}
}

export default handler
Loading
Loading