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

chore: add errors to abis #10697

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Changes from all commits
Commits
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
16 changes: 15 additions & 1 deletion yarn-project/l1-artifacts/scripts/generate-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ CONTRACTS=(
"l1-contracts:ExtRollupLib"
)

# Read the error ABI's once and store it in COMBINED_ERRORS variable
COMBINED_ERRORS=$(jq -s '
.[0].abi + .[1].abi |
unique_by({type: .type, name: .name})
' \
../../l1-contracts/out/Errors.sol/Errors.json \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe combine these while we are here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The split is currently with core and governance the paths just end up looking a bit funky in the foundry out dir.

Think we should keep the split for now.

../../l1-contracts/out/libraries/Errors.sol/Errors.json)

# create target dir if it doesn't exist
mkdir -p "$target_dir";
Expand All @@ -44,7 +51,14 @@ for E in "${CONTRACTS[@]}"; do
CONTRACT_NAME="${ARR[1]}";

echo -ne "/**\n * $CONTRACT_NAME ABI.\n */\nexport const ${CONTRACT_NAME}Abi = " > "$target_dir/${CONTRACT_NAME}Abi.ts";
jq -j '.abi' ../../$ROOT/out/$CONTRACT_NAME.sol/$CONTRACT_NAME.json >> "$target_dir/${CONTRACT_NAME}Abi.ts";

# Merge contract abi and errors abi while removing duplicates based on both type and name
# Just merging it into all, it is not the cleanest, but it does the job.
jq -j --argjson errors "$COMBINED_ERRORS" '
.abi + $errors |
unique_by({type: .type, name: .name})
' ../../$ROOT/out/$CONTRACT_NAME.sol/$CONTRACT_NAME.json >> "$target_dir/${CONTRACT_NAME}Abi.ts";

echo " as const;" >> "$target_dir/${CONTRACT_NAME}Abi.ts";

echo -ne "/**\n * $CONTRACT_NAME bytecode.\n */\nexport const ${CONTRACT_NAME}Bytecode = \"" > "$target_dir/${CONTRACT_NAME}Bytecode.ts";
Expand Down
Loading