Skip to content

Instantly share code, notes, and snippets.

@yhuag
Created June 26, 2018 07:02
Show Gist options
  • Save yhuag/e191f22677823dd5df18d95ff2648996 to your computer and use it in GitHub Desktop.
Save yhuag/e191f22677823dd5df18d95ff2648996 to your computer and use it in GitHub Desktop.
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