Skip to content

Commit

Permalink
fix: JSON addr reads when empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSparksCode committed Oct 25, 2024
1 parent d1d614d commit f1d2f80
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion script/base/deploy-base.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit f1d2f80

Please sign in to comment.