Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docall for builder session #89

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/protocols/Builder/Session.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ contract Session is Test {
bytes memory root = HexStrings.fromHexString(HexStrings.stripQuotesAndPrefix(output.at('"root"').value()));
}

function doCall(address target, bytes memory data) public returns (bytes memory) {
bytes memory encodedRequest = abi.encodePacked(
'{"to":"', LibString.toHexStringChecksummed(target), '","data":"', LibString.toHexString(data), '"}'
);
return doCall(encodedRequest);
}

function doCall(bytes memory encodedRequest) public returns (bytes memory) {
bytes memory input = abi.encodePacked(session, ",", encodedRequest);
JSONParserLib.Item memory item = callImpl("call", input);

bytes memory result = HexStrings.fromHexString(HexStrings.stripQuotesAndPrefix(item.value()));
return result;
}

function callImpl(string memory method, bytes memory args) internal returns (JSONParserLib.Item memory) {
Suave.HttpRequest memory request;
request.method = "POST";
Expand Down
Loading