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 return statement to HederaTokenService.redirectForToken() #299

Merged
merged 4 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,18 @@
}
],
"name": "redirectForToken",
"outputs": [],
"outputs": [
{
"internalType": "int256",
"name": "responseCode",
"type": "int256"
},
{
"internalType": "bytes",
"name": "response",
"type": "bytes"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2417,7 +2417,18 @@
}
],
"name": "redirectForToken",
"outputs": [],
"outputs": [
{
"internalType": "int64",
"name": "responseCode",
"type": "int64"
},
{
"internalType": "bytes",
"name": "response",
"type": "bytes"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
Expand Down
4 changes: 2 additions & 2 deletions artifacts/contracts/hts-precompile/KeyHelper.sol/Bits.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"contractName": "Bits",
"sourceName": "contracts/hts-precompile/KeyHelper.sol",
"abi": [],
"bytecode": "0x60556032600b8282823980515f1a607314602657634e487b7160e01b5f525f60045260245ffd5b305f52607381538281f3fe730000000000000000000000000000000000000000301460806040525f80fdfea264697066735822122082eae52db30a7b41b0b3c8ddf9afdfabfe4528d9d40fa9c108a5eec9bd3046b864736f6c63430008140033",
"deployedBytecode": "0x730000000000000000000000000000000000000000301460806040525f80fdfea264697066735822122082eae52db30a7b41b0b3c8ddf9afdfabfe4528d9d40fa9c108a5eec9bd3046b864736f6c63430008140033",
"bytecode": "0x60556032600b8282823980515f1a607314602657634e487b7160e01b5f525f60045260245ffd5b305f52607381538281f3fe730000000000000000000000000000000000000000301460806040525f80fdfea26469706673582212203b9261db8f6fe964dc39e79c21a48921fa332492f8065ed70f6d6b5ea0fb5cee64736f6c63430008140033",
"deployedBytecode": "0x730000000000000000000000000000000000000000301460806040525f80fdfea26469706673582212203b9261db8f6fe964dc39e79c21a48921fa332492f8065ed70f6d6b5ea0fb5cee64736f6c63430008140033",
"linkReferences": {},
"deployedLinkReferences": {}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions contracts/hts-precompile/HederaTokenService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -660,11 +660,14 @@ abstract contract HederaTokenService {
/// Redirect for token
/// @param token The token address
/// @param encodedFunctionSelector The function selector from the ERC20 interface + the bytes input for the function called
function redirectForToken(address token, bytes memory encodedFunctionSelector) external {
(bool success, bytes memory data) = precompileAddress.call(
/// @return responseCode The response code for the status of the request. SUCCESS is 22.
/// @return response The result of the call that had been encoded and sent for execution.
function redirectForToken(address token, bytes memory encodedFunctionSelector) external returns (int responseCode, bytes memory response) {
Nana-EC marked this conversation as resolved.
Show resolved Hide resolved
(bool success, bytes memory result) = precompileAddress.call(
abi.encodeWithSelector(IHederaTokenService.redirectForToken.selector, token, encodedFunctionSelector)
);

emit CallResponseEvent(success, data);
emit CallResponseEvent(success, result);
(responseCode, response) = success ? abi.decode(result, (int32, bytes)) : (HederaResponseCodes.UNKNOWN, bytes(""));
}
}
5 changes: 4 additions & 1 deletion contracts/hts-precompile/IHederaTokenService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,9 @@ interface IHederaTokenService {
(int64 responseCode, int32 tokenType);

/// Initiates a Redirect For Token
/// @param token The token address
/// @param encodedFunctionSelector The function selector from the ERC20 interface + the bytes input for the function called
function redirectForToken(address token, bytes memory encodedFunctionSelector) external;
/// @return responseCode The response code for the status of the request. SUCCESS is 22.
/// @return response The result of the call that had been encoded and sent for execution.
function redirectForToken(address token, bytes memory encodedFunctionSelector) external returns (int64 responseCode, bytes memory response);
Nana-EC marked this conversation as resolved.
Show resolved Hide resolved
Nana-EC marked this conversation as resolved.
Show resolved Hide resolved
}