Created
June 26, 2018 07:02
-
-
Save yhuag/e191f22677823dd5df18d95ff2648996 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.21; | |
// @title MAR mode: Module-Agnostic Rendering Mode (Core) | |
// @author Jeff Hu | |
// @dev This smart contract is modularized via a module agnostic execution scheme | |
contract C { | |
address public M_addr; // The deployed address of the module M | |
string public M_func; // The target function signature of module M | |
// Address Storage (stores module addresses) | |
mapping(string => address) AddressStorage; | |
function getAddressValue(string record) constant public returns (address) { | |
return AddressStorage[record]; | |
} | |
function setAddressValue(string record, address value) public { | |
AddressStorage[record] = value; | |
} | |
// String Storage (stores function signatures) | |
mapping(string => string) StringStorage; | |
function getStringValue(string record) constant public returns (string) { | |
return StringStorage[record]; | |
} | |
function setStringValue(string record, string value) public { | |
StringStorage[record] = value; | |
} | |
// Render target that is to-be-called | |
function renderModule(string _addrByte, string _funcByte) public { | |
M_addr = getAddressValue(_addrByte); | |
M_func = getStringValue(_funcByte); | |
} | |
// Execute the target modules's function | |
function exec() public returns (bool) { | |
return M_addr.call(bytes4(keccak256(M_func))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment