Skip to content

Commit

Permalink
Merge pull request #109 from axieinfinity/implement-feature/runtime-c…
Browse files Browse the repository at this point in the history
…onfig/rename-flags

feat(runtime-config): implement `rename-flags`
  • Loading branch information
TuDo1403 committed Mar 1, 2024
2 parents 2384765 + 061d901 commit 514aaca
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
12 changes: 10 additions & 2 deletions broadcast.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ else
echo "Error: .broadcast.env file not found."
fi

verify_arg=""
extra_argument=""

for arg in "$@"; do
Expand All @@ -20,6 +19,15 @@ done
# Remove the @ character from the end of extra_argument
extra_argument="${extra_argument%%@}"

op_command=""
## Check if the private key is stored in the .env file
if [[ ! $extra_argument == *"sender"* ]] && [[ ! $extra_argument == *"trezor"* ]]; then
source .env
if [[ $MAINNET_PK == op* ]] || [[ $TESTNET_PK == op* ]] || [[ $LOCAL_PK == op* ]]; then
op_command="op run --env-file="./.env" --"
fi
fi

echo Broadcast Tx...
echo From: ${FROM}
echo To: ${TO}
Expand All @@ -28,4 +36,4 @@ echo GasAmount: ${GAS}
echo Calldata:
cast pretty-calldata ${CALLDATA}
calldata=$(cast calldata 'broadcast(address,address,uint256,uint256,bytes)' ${FROM} ${TO} ${GAS} ${VALUE} ${CALLDATA})
forge script ${verify_arg} ${@} -g 200 OnchainExecutor --sig 'run(bytes,string)' ${calldata} "${extra_argument}"
${op_command} forge script ${verify_arg} ${@} -g 200 OnchainExecutor --sig 'run(bytes,string)' ${calldata} "${extra_argument}"
1 change: 0 additions & 1 deletion debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ else
echo "Error: .debug.env file not found."
fi

verify_arg=""
extra_argument=""

for arg in "$@"; do
Expand Down
25 changes: 21 additions & 4 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ for arg in "$@"; do
--trezor)
extra_argument+=trezor@
;;
--log)
set -- "${@/#--log/}"
extra_argument+=log@
--disable-postcheck)
set -- "${@/#--disable-postcheck/}"
extra_argument+=no-postcheck@
;;
--generate-artifacts)
set -- "${@/#--generate-artifacts/}"
extra_argument+=generate-artifact@
;;
-atf)
set -- "${@/#-atf/}"
extra_argument+=generate-artifact@
;;
*) ;;
esac
Expand All @@ -17,5 +25,14 @@ done
# Remove the @ character from the end of extra_argument
extra_argument="${extra_argument%%@}"

op_command=""
## Check if the private key is stored in the .env file
if [[ ! $extra_argument == *"sender"* ]] && [[ ! $extra_argument == *"trezor"* ]]; then
source .env
if [[ $MAINNET_PK == op* ]] || [[ $TESTNET_PK == op* ]] || [[ $LOCAL_PK == op* ]]; then
op_command="op run --env-file="./.env" --"
fi
fi

calldata=$(cast calldata 'run()')
forge script ${verify_arg} ${@} -g 200 --sig 'run(bytes,string)' ${calldata} "${extra_argument}"
${op_command} forge script ${verify_arg} ${@} -g 200 --sig 'run(bytes,string)' ${calldata} "${extra_argument}"
3 changes: 2 additions & 1 deletion script/configs/RuntimeConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ abstract contract RuntimeConfig is IRuntimeConfig {
uint256 length = args.length;

for (uint256 i; i < length;) {
if (args[i].eq("log")) _option.log = true;
if (args[i].eq("generate-artifact")) _option.generateArtifact = true;
else if (args[i].eq("trezor")) _option.trezor = true;
else if (args[i].eq("no-postcheck")) _option.disablePostcheck = true;
else console.log(StdStyle.yellow("Unsupported command: "), args[i]);

unchecked {
Expand Down
3 changes: 2 additions & 1 deletion script/interfaces/configs/IRuntimeConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ pragma solidity ^0.8.19;

interface IRuntimeConfig {
struct Option {
bool log;
bool generateArtifact;
bool trezor;
bool disablePostcheck;
}

function isPostChecking() external view returns (bool);
Expand Down

0 comments on commit 514aaca

Please sign in to comment.