-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
6 changed files
with
5,686 additions
and
82 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 |
---|---|---|
@@ -1,2 +1 @@ | ||
execution-apis_temp.* | ||
openrpc.json | ||
execution-apis_temp |
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,72 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Clones the ethereum/execution-apis repo and generates types from the open-rpc schema. | ||
# | ||
# Usage: $0 [branch] [repo_url] | ||
# | ||
# branch: The branch to clone. | ||
# repo_url: The url of the git repository to clone. | ||
|
||
# SETTINGS | ||
repo_url=${2:-"[email protected]:ethereum/execution-apis.git"} | ||
branch=${1:-"main"} | ||
schema_doc="refs-openrpc.json" | ||
out_dir="src/ethereum" | ||
out_schema_doc="$out_dir/openrpc.json" | ||
out_types_name="ethereum" | ||
out_types="$out_dir/$out_types_name".ts | ||
|
||
if [ ! -d "$out_dir" ]; then | ||
mkdir -p "$out_dir" | ||
fi | ||
|
||
if [ ! -f "$out_schema_doc" ]; then | ||
temp_dir="execution-apis_temp" | ||
|
||
if [ ! -d "$temp_dir" ]; then | ||
echo "Cloning $branch from $repo_url" | ||
git clone --depth 1 "$repo_url" --branch "$branch" "$temp_dir" | ||
fi | ||
|
||
echo "Installing dependencies and generating OpenRPC schema..." | ||
( | ||
cd "$temp_dir" | ||
npm i ci | ||
npm run build | ||
) | ||
cp "$temp_dir/$schema_doc" "$out_schema_doc" | ||
|
||
echo "Deleting temp clone..." | ||
rm -rf "$temp_dir" | ||
fi | ||
|
||
echo "Generating types..." | ||
npx open-rpc-typings -d "$out_schema_doc" --output-ts "$out_dir" --name-ts "$out_types_name" | ||
|
||
# Convert source name to PascalCase | ||
out_types_name=$(echo "$out_types_name" | | ||
sed 's/-/ /g' | | ||
awk '{ | ||
for (i=1; i<=NF; i++) { | ||
$i = toupper(substr($i,1,1)) substr($i,2) | ||
} | ||
}' | | ||
sed 's/ //g') | ||
|
||
{ | ||
echo "/* eslint-disable */" | ||
echo "/* @ts-nocheck */" | ||
echo "" | ||
echo "// This file was generated using the OpenRPC schema from the ethereum/execution-apis repo." | ||
echo "// See https://github.com/ethereum/execution-apis for more information." | ||
echo "//" | ||
echo "// Changes to this file will be lost when the code is regenerated." | ||
echo "// Generated by: $0" | ||
echo "" | ||
echo "export namespace $out_types_name {" | ||
cat "$out_types" | ||
echo "}" | ||
} >"$out_types.tmp" | ||
mv "$out_types.tmp" "$out_types" |
This file was deleted.
Oops, something went wrong.
9 changes: 4 additions & 5 deletions
9
packages/drift/src/execution-apis.ts → packages/drift/src/ethereum/ethereum.ts
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.