Skip to content

Commit

Permalink
fix: get nonce without override pending txs
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyHD committed Jan 24, 2024
1 parent 4ce820b commit 20a253a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/BatchScript.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
}
Expand Down

0 comments on commit 20a253a

Please sign in to comment.