Skip to content

Commit

Permalink
Merge pull request #12 from MEV-Protocol/nonce
Browse files Browse the repository at this point in the history
fix: get nonce without override pending txs
  • Loading branch information
ind-igo authored Sep 4, 2024
2 parents a0170c3 + 20a253a commit 33ef967
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 @@ -438,14 +438,16 @@ abstract contract BatchScript is Script {

function _getNonce(address safe_) private 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 33ef967

Please sign in to comment.