/
Events.sol
93 lines (76 loc) · 4.37 KB
/
Events.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
pragma solidity ^0.4.24;
import '../interfaces/DBInterface.sol';
contract Events {
DBInterface public database;
constructor(address _database) public{
database = DBInterface(_database);
}
function message(string _message)
external
onlyApprovedContract {
emit LogEvent(_message, keccak256(abi.encodePacked(_message)), tx.origin);
}
function transaction(string _message, address _from, address _to, uint _amount, address _token)
external
onlyApprovedContract {
emit LogTransaction(_message, keccak256(abi.encodePacked(_message)), _from, _to, _amount, _token, tx.origin);
}
function registration(string _message, address _account)
external
onlyApprovedContract {
emit LogAddress(_message, keccak256(abi.encodePacked(_message)), _account, tx.origin);
}
function contractChange(string _message, address _account, string _name)
external
onlyApprovedContract {
emit LogContractChange(_message, keccak256(abi.encodePacked(_message)), _account, _name, tx.origin);
}
function asset(string _message, string _uri, address _assetAddress, address _manager)
external
onlyApprovedContract {
emit LogAsset(_message, keccak256(abi.encodePacked(_message)), _uri, keccak256(abi.encodePacked(_uri)), _assetAddress, _manager, tx.origin);
}
function escrow(string _message, address _assetAddress, bytes32 _escrowID, address _manager, uint _amount)
external
onlyApprovedContract {
emit LogEscrow(_message, keccak256(abi.encodePacked(_message)), _assetAddress, _escrowID, _manager, _amount, tx.origin);
}
function order(string _message, bytes32 _orderID, uint _amount, uint _price)
external
onlyApprovedContract {
emit LogOrder(_message, keccak256(abi.encodePacked(_message)), _orderID, _amount, _price, tx.origin);
}
function exchange(string _message, bytes32 _orderID, address _assetAddress, address _account)
external
onlyApprovedContract {
emit LogExchange(_message, keccak256(abi.encodePacked(_message)), _orderID, _assetAddress, _account, tx.origin);
}
function operator(string _message, bytes32 _id, string _name, string _ipfs, address _account)
external
onlyApprovedContract {
emit LogOperator(_message, keccak256(abi.encodePacked(_message)), _id, _name, _ipfs, _account, tx.origin);
}
function consensus(string _message, bytes32 _executionID, bytes32 _votesID, uint _votes, uint _tokens, uint _quorum)
external
onlyApprovedContract {
emit LogConsensus(_message, keccak256(abi.encodePacked(_message)), _executionID, _votesID, _votes, _tokens, _quorum, tx.origin);
}
//Generalized events
event LogEvent(string message, bytes32 indexed messageID, address indexed origin);
event LogTransaction(string message, bytes32 indexed messageID, address indexed from, address indexed to, uint amount, address token, address origin); //amount and token will be empty on some events
event LogAddress(string message, bytes32 indexed messageID, address indexed account, address indexed origin);
event LogContractChange(string message, bytes32 indexed messageID, address indexed account, string name, address indexed origin);
event LogAsset(string message, bytes32 indexed messageID, string uri, bytes32 indexed assetID, address asset, address manager, address indexed origin);
event LogEscrow(string message, bytes32 indexed messageID, address asset, bytes32 escrowID, address indexed manager, uint amount, address indexed origin);
event LogOrder(string message, bytes32 indexed messageID, bytes32 indexed orderID, uint amount, uint price, address indexed origin);
event LogExchange(string message, bytes32 indexed messageID, bytes32 orderID, address indexed asset, address account, address indexed origin);
event LogOperator(string message, bytes32 indexed messageID, bytes32 id, string name, string ipfs, address indexed account, address indexed origin);
event LogConsensus(string message, bytes32 indexed messageID, bytes32 executionID, bytes32 votesID, uint votes, uint tokens, uint quorum, address indexed origin);
// --------------------------------------------------------------------------------------
// Caller must be registered as a contract through ContractManager.sol
// --------------------------------------------------------------------------------------
modifier onlyApprovedContract() {
require(database.boolStorage(keccak256(abi.encodePacked("contract", msg.sender))));
_;
}
}