From f1d2f80fcb9d24db4f249b30052cab17291c291e Mon Sep 17 00:00:00 2001 From: Ben Sparks <52714090+BenSparksCode@users.noreply.github.com> Date: Fri, 25 Oct 2024 09:07:12 +0200 Subject: [PATCH] fix: JSON addr reads when empty string --- script/base/deploy-base.s.sol | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/script/base/deploy-base.s.sol b/script/base/deploy-base.s.sol index ba15ab1ac..6836b2954 100644 --- a/script/base/deploy-base.s.sol +++ b/script/base/deploy-base.s.sol @@ -85,7 +85,14 @@ contract DeployBaseScript is Script { // console.log("Getting", fullKey, "from deployments.json"); - // NOTE: Use fullKey method above for safety + // Revert if key doesn't exist in JSON. + if (!json.keyExists(fullKey)) revert(string.concat(fullKey, " not found in deployments.json")); + + // If key exists but is empty, return address(0) + address decodedAddr = abi.decode(json.parseRaw(fullKey), (address)); + if (decodedAddr == address(0x20) || decodedAddr == address(0)) return address(0); + + // Otherwise, return the address return json.readAddress(fullKey); }