Skip to content
Merged
Show file tree
Hide file tree
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
41 changes: 41 additions & 0 deletions generate-artifact.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ fi
source_name=$(basename $absolute_path)
# Remove .json or .sol extension
source_name=${source_name%.*}
#
echo "source_name: $source_name"

# Generate the artifact
abi=$(forge inspect $source_name abi --json)
Expand All @@ -78,6 +80,45 @@ storage_layout=$(forge inspect $source_name storageLayout --json)
bytecode=$(forge inspect $source_name bytecode)
deployed_bytecode=$(forge inspect $source_name deployedBytecode)

sanitize_json_field() {
local name="$1"
local value="$2"

if [[ -z "$value" || "$value" == "null" ]]; then
echo "field $name is null" >&2
echo "null"
return
fi

# Ensure the value is valid JSON; fallback to null if not
if echo "$value" | jq -c . >/dev/null 2>&1; then
echo "$value" | jq -c .
else
echo "field $name is invalid JSON; defaulting to null" >&2
echo "null"
fi
}

sanitize_string_field() {
local name="$1"
local value="$2"

if [[ -z "$value" || "$value" == "null" ]]; then
echo "field $name is null" >&2
echo ""
else
echo "$value"
fi
}

abi=$(sanitize_json_field "abi" "$abi")
devdoc=$(sanitize_json_field "devdoc" "$devdoc")
userdoc=$(sanitize_json_field "userdoc" "$userdoc")
metadata=$(sanitize_json_field "metadata" "$metadata")
storage_layout=$(sanitize_json_field "storage_layout" "$storage_layout")
bytecode=$(sanitize_string_field "bytecode" "$bytecode")
deployed_bytecode=$(sanitize_string_field "deployed_bytecode" "$deployed_bytecode")

# Create the JSON object
json_content=$(
jq -n \
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,6 @@ done

export_address

echo "\033[33mTrying to compile contracts ...\033[0m"
forge build --offline # Ensure the contracts are compiled before running the script

should_verify=$([[ $should_verify == true && $is_broadcast == true ]] && echo true || echo false)

if [[ $force_generate_artifact == true ]]; then
Expand Down Expand Up @@ -199,7 +196,7 @@ fi

start_time=$(date +%s)

${op_command} forge script --offline ${verify_arg} ${@} -g 200 --sig 'run(bytes,string)' $(cast calldata 'run()') "${extra_argument}"
${op_command} forge script --offline ${verify_arg} ${@} -g 200 --color always --sig 'run(bytes,string)' $(cast calldata 'run()') "${extra_argument}"

if [ $? -ne 0 ]; then
exit 1
Expand Down
4 changes: 0 additions & 4 deletions script/libraries/LibArtifact.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,11 @@ library LibArtifact {

console.log(string.concat("By: ", vm.getLabel(info.deployer), ", nonce: ", vm.toString(info.nonce), "\n"));

vm.pauseTracing();

string memory dirPath = vme.getDeploymentDirectory(vme.getCurrentNetwork());

_tryCreateDir(dirPath);

_serializeArtifact(dirPath, info);

vm.resumeTracing();
}

function _serializeArtifact(string memory dirPath, ArtifactInfo memory info) internal {
Expand Down
2 changes: 0 additions & 2 deletions script/libraries/LibDeploy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ library LibDeploy {
function deployFromArtifact(
DeployInfo memory info
) internal returns (address payable deployed) {
vm.pauseTracing();
deployed = deployFromBytecode(
info.absolutePath,
info.contractName,
Expand All @@ -239,7 +238,6 @@ library LibDeploy {
info.callValue,
info.by
);
vm.resumeTracing();
}

function deployFromBytecode(
Expand Down
2 changes: 1 addition & 1 deletion script/libraries/LibInitializeGuard.sol
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ library LibInitializeGuard {
inputs[0] = "forge";
inputs[1] = "inspect";
inputs[2] = _getContractAbsolutePath($cache._chainInfo[proxy].forkId, proxy);
inputs[3] = "storage";
inputs[3] = "storageLayout";
inputs[4] = "--json";

string memory ret = string(vm.ffi(inputs));
Expand Down
4 changes: 2 additions & 2 deletions soldeer.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ name = "openzeppelin-v4"
version = "4.9.5"
url = "https://github.com/OpenZeppelin/openzeppelin-contracts/archive/refs/tags/v4.9.5.zip"
checksum = "fe249a9cb37b7a6664f8bfe61a9633873fbbb895e5d4c3fac78db50fd9af3a73"
integrity = "590ed70cbd82f6a8ea6512d136626c3aa02a22433a4bf84664faaa463c397574"
integrity = "b4b46e19320d23ccd8708b45bf3a1b996fdd3734fd6ec46cd1d24713af6d44f9"

[[dependencies]]
name = "openzeppelin-v5"
version = "5.1.0"
url = "https://github.com/OpenZeppelin/openzeppelin-contracts/archive/refs/tags/v5.1.0.zip"
checksum = "30600e9dc4dd7d9089c5f2ae78aedfdb764349ae15647190c792afd07123e2c2"
integrity = "cb412b382c03069b2eb43beda83d3be86c9efcf3724368cb884d527357341366"
integrity = "5c896fe66026522d814bf97d4331d408283f549123254575c8a0f67c1fefecc1"

[[dependencies]]
name = "solady"
Expand Down