Skip to content

Commit

Permalink
bytes32
Browse files Browse the repository at this point in the history
  • Loading branch information
rkdud007 committed Jul 17, 2024
1 parent a2a0042 commit f6ac693
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/datatypes/module/ModuleCodecs.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ import {TaskCode} from "../Task.sol";
/// @param classHash The class hash of the module.
/// @param inputs The inputs to the module.
struct Module {
uint256 classHash;
uint256[] inputs;
bytes32 classHash;
bytes32[] inputs;
}

/// @notice Codecs for Module.
/// @dev Represent a computation perform by a module.
library ModuleCodecs {
/// @dev Encodes a Module.
/// @param module The Module to encode.
function encode_task(Module memory module) internal pure returns (bytes memory) {
function encode_task(
Module memory module
) internal pure returns (bytes memory) {
return abi.encode(TaskCode.Module, module.classHash, module.inputs);
}

Expand All @@ -29,7 +31,10 @@ library ModuleCodecs {
/// @dev Decodes a Module.
/// @param data The encoded Module.
function decode(bytes memory data) internal pure returns (Module memory) {
(, uint256 classHash, uint256[] memory inputs) = abi.decode(data, (TaskCode, uint256, uint256[]));
(, bytes32 classHash, bytes32[] memory inputs) = abi.decode(
data,
(TaskCode, bytes32, bytes32[])
);
return Module(classHash, inputs);
}
}

0 comments on commit f6ac693

Please sign in to comment.