Skip to content

Commit

Permalink
refactor: artifacts script
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed May 3, 2023
1 parent 8c435f3 commit 9704296
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions yarn-project/l1-artifacts/scripts/generate-artifacts.sh
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
set -euo pipefail;

# create generated dir if it doesn't exist
mkdir -p generated;
target_dir=./generated

echo -ne "/**\n * DecoderHelper ABI.\n */\nexport const DecoderHelperAbi = " > ./generated/DecoderHelperAbi.ts;
jq -j '.abi' ../../l1-contracts/out/DecoderHelper.sol/DecoderHelper.json >> ./generated/DecoderHelperAbi.ts;
echo " as const;" >> ./generated/DecoderHelperAbi.ts;
echo -ne "/**\n * DecoderHelper bytecode.\n */\nexport const DecoderHelperBytecode = \"" > ./generated/DecoderHelperBytecode.ts;
jq -j '.bytecode.object' ../../l1-contracts/out/DecoderHelper.sol/DecoderHelper.json >> ./generated/DecoderHelperBytecode.ts;
echo "\";" >> ./generated/DecoderHelperBytecode.ts;
# create target dir if it doesn't exist
mkdir -p "$target_dir";

echo -ne "/**\n * Rollup ABI.\n */\nexport const RollupAbi = " > ./generated/RollupAbi.ts;
jq -j '.abi' ../../l1-contracts/out/Rollup.sol/Rollup.json >> ./generated/RollupAbi.ts;
echo " as const;" >> ./generated/RollupAbi.ts;
echo -ne "/**\n * DecoderHelper ABI.\n */\nexport const DecoderHelperAbi = " > "$target_dir/DecoderHelperAbi.ts";
jq -j '.abi' ../../l1-contracts/out/DecoderHelper.sol/DecoderHelper.json >> "$target_dir/DecoderHelperAbi.ts";
echo " as const;" >> "$target_dir/DecoderHelperAbi.ts";
echo -ne "/**\n * DecoderHelper bytecode.\n */\nexport const DecoderHelperBytecode = \"" > "$target_dir/DecoderHelperBytecode.ts";
jq -j '.bytecode.object' ../../l1-contracts/out/DecoderHelper.sol/DecoderHelper.json >> "$target_dir/DecoderHelperBytecode.ts";
echo "\";" >> "$target_dir/DecoderHelperBytecode.ts";

echo -ne "/**\n * Rollup bytecode.\n */\nexport const RollupBytecode = '" > ./generated/RollupBytecode.ts;
jq -j '.bytecode.object' ../../l1-contracts/out/Rollup.sol/Rollup.json >> ./generated/RollupBytecode.ts;
echo "' as const;" >> ./generated/RollupBytecode.ts;
echo -ne "/**\n * Rollup ABI.\n */\nexport const RollupAbi = " > "$target_dir/RollupAbi.ts";
jq -j '.abi' ../../l1-contracts/out/Rollup.sol/Rollup.json >> "$target_dir/RollupAbi.ts";
echo " as const;" >> "$target_dir/RollupAbi.ts";

echo -ne "/**\n * UnverifiedDataEmitter ABI.\n */\nexport const UnverifiedDataEmitterAbi = " > ./generated/UnverifiedDataEmitterAbi.ts;
jq -j '.abi' ../../l1-contracts/out/UnverifiedDataEmitter.sol/UnverifiedDataEmitter.json >> ./generated/UnverifiedDataEmitterAbi.ts;
echo " as const;" >> ./generated/UnverifiedDataEmitterAbi.ts;
echo -ne "/**\n * Rollup bytecode.\n */\nexport const RollupBytecode = '" > "$target_dir/RollupBytecode.ts";
jq -j '.bytecode.object' ../../l1-contracts/out/Rollup.sol/Rollup.json >> "$target_dir/RollupBytecode.ts";
echo "' as const;" >> "$target_dir/RollupBytecode.ts";

echo -ne "/**\n * UnverifiedDataEmitter bytecode.\n */\nexport const UnverifiedDataEmitterBytecode = '" > ./generated/UnverifiedDataEmitterBytecode.ts;
jq -j '.bytecode.object' ../../l1-contracts/out/UnverifiedDataEmitter.sol/UnverifiedDataEmitter.json >> ./generated/UnverifiedDataEmitterBytecode.ts;
echo "' as const;" >> ./generated/UnverifiedDataEmitterBytecode.ts;
echo -ne "/**\n * UnverifiedDataEmitter ABI.\n */\nexport const UnverifiedDataEmitterAbi = " > "$target_dir/UnverifiedDataEmitterAbi.ts";
jq -j '.abi' ../../l1-contracts/out/UnverifiedDataEmitter.sol/UnverifiedDataEmitter.json >> "$target_dir/UnverifiedDataEmitterAbi.ts";
echo " as const;" >> "$target_dir/UnverifiedDataEmitterAbi.ts";

echo -ne "export * from './DecoderHelperAbi.js';\nexport * from './DecoderHelperBytecode.js';\n" > ./generated/index.ts;
echo -ne "export * from './RollupAbi.js';\nexport * from './RollupBytecode.js';\n" >> ./generated/index.ts;
echo -ne "export * from './UnverifiedDataEmitterAbi.js';\nexport * from './UnverifiedDataEmitterBytecode.js';" >> ./generated/index.ts;
echo -ne "/**\n * UnverifiedDataEmitter bytecode.\n */\nexport const UnverifiedDataEmitterBytecode = '" > "$target_dir/UnverifiedDataEmitterBytecode.ts";
jq -j '.bytecode.object' ../../l1-contracts/out/UnverifiedDataEmitter.sol/UnverifiedDataEmitter.json >> "$target_dir/UnverifiedDataEmitterBytecode.ts";
echo "' as const;" >> "$target_dir/UnverifiedDataEmitterBytecode.ts";

echo "Successfully generated TS artifacts!";
echo -ne "export * from './DecoderHelperAbi.js';\nexport * from './DecoderHelperBytecode.js';\n" > "$target_dir/index.ts";
echo -ne "export * from './RollupAbi.js';\nexport * from './RollupBytecode.js';\n" >> "$target_dir/index.ts";
echo -ne "export * from './UnverifiedDataEmitterAbi.js';\nexport * from './UnverifiedDataEmitterBytecode.js';" >> "$target_dir/index.ts";

echo "Successfully generated TS artifacts!";

0 comments on commit 9704296

Please sign in to comment.