diff --git a/src/BatchScript.sol b/src/BatchScript.sol index feb7fe7..303fb47 100644 --- a/src/BatchScript.sol +++ b/src/BatchScript.sol @@ -433,14 +433,16 @@ abstract contract BatchScript is Script, DelegatePrank { function _getNonce(address safe_) internal returns (uint256) { string memory endpoint = string.concat( - SAFE_API_BASE_URL, - vm.toString(safe_), - "/" + _getSafeAPIEndpoint(safe_), + "?limit=1" ); (uint256 status, bytes memory data) = endpoint.get(); if (status == 200) { - string memory result = string(data); - return result.readUint(".nonce"); + string memory resp = string(data); + string[] memory results; + results = resp.readStringArray(".results"); + if (results.length == 0) return 0; + return resp.readUint(".results[0].nonce") + 1; } else { revert("Get nonce failed!"); }