Last active
March 15, 2020 18:02
-
-
Save thrilok209/53c29d24115ac74f0860d2005b88a7a6 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.6.0; | |
/** | |
* Interface of the Central Event Contract. | |
*/ | |
interface EventInterface { | |
function emitEvent(uint _connectorType, uint _connectorID, bytes32 _eventCode, bytes calldata _eventData) external; | |
} | |
contract Memory { | |
/** | |
* @dev Return Central Event Contract Address. | |
*/ | |
function getEventAddr() public pure returns (address) { | |
return 0x0000000000000000000000000000000000000000; | |
} | |
/** | |
* @dev Return Connector ID and Type. | |
* @return `_type`: Returns Type of the connector. | |
* eg: For Static Connector => 2 and Normal Connector => 1 | |
* @return `_id`: Returns ID of the connector. | |
* eg: You get Connector's ID from the Connector.sol, which will be the | |
* `connectorArray.lenght + 1`. | |
*/ | |
function connectorID() public pure returns(uint _type, uint _id) { | |
(_type, _id) = (<Connector Type>, <connectorArray.lenght + 1>); | |
} | |
} | |
contract BasicResolver is Memory { | |
/** | |
* @dev Event. | |
*/ | |
event LogExampleEvent(address ethAddr, uint256 number); | |
/** | |
* @dev Ether Address. | |
*/ | |
function getEthAddr() public pure returns (address) { | |
return 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; | |
} | |
/** | |
* @dev Emitting event using central event contract. | |
*/ | |
function func() public { | |
// Function Logic goes here..... | |
// `_eventCode` helps the central event contract to decode the event name. | |
bytes32 _eventCode = keccak256("LogExampleEvent(address,uint256)"); | |
// `_eventParam` helps the central event contract to decode the event params. | |
// This contains the parameters of the above event. | |
bytes memory _eventParam = abi.encode(getEthAddr(), 10**18); | |
// `_id` helps the central event contract to identity the event emitted from this connector. | |
// `_type` helps the central event contract to identity type of the connector. | |
(uint _type, uint _id) = connectorID(); | |
// Central Event Contract emits the event. | |
EventInterface(getEventAddr()).emitEvent(_type, _id, _eventCode, _eventParam); | |
} | |
} | |
contract ConnectBasic is BasicResolver { | |
/** | |
* @dev Connector Name. | |
*/ | |
string public constant name = "<Connector Name>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment