-
-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f77b774
commit 2b88f25
Showing
5 changed files
with
41 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* eslint-disable no-console */ | ||
import fs from "node:fs"; | ||
import path from "node:path"; | ||
import url from "node:url"; | ||
|
||
import {version} from "./src/schema/version.js"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
const __dirname = path.dirname(url.fileURLToPath(import.meta.url)); | ||
|
||
async function downloadBeaconApiSchema(): Promise<void> { | ||
const url = `https://github.com/ethereum/beacon-APIs/releases/download/${version}/beacon-node-oapi.json`; | ||
const filepath = path.join(__dirname, "./src/schema/beacon-node-oapi.json"); | ||
console.log(`Downloading oapi file from ${url}`); | ||
let openApiStr = await fetch(url).then((res) => res.text()); | ||
|
||
// Parse before writting to ensure it's proper JSON | ||
try { | ||
openApiStr = JSON.stringify(JSON.parse(openApiStr)); | ||
} catch (e) { | ||
console.log(openApiStr); | ||
throw e; | ||
} | ||
|
||
fs.writeFileSync(filepath, openApiStr); | ||
} | ||
|
||
await downloadBeaconApiSchema(); |
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
Large diffs are not rendered by default.
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,5 @@ | ||
import schemaJson from "./beacon-node-oapi.json" assert {type: "json"}; | ||
import {version} from "./version.js"; | ||
|
||
export const schema = schemaJson; | ||
export const version = version; |
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,6 @@ | ||
/** | ||
* This is the currently-targeted version of the Beacon-API | ||
* | ||
* https://github.com/ethereum/beacon-apis | ||
*/ | ||
export const version = "v2.3.0"; |