-
Notifications
You must be signed in to change notification settings - Fork 0
/
out.sol
144 lines (121 loc) · 3.63 KB
/
out.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
pragma solidity ^0.4.26;
pragma experimental ABIEncoderV2;
contract Media {
uint256 timestamp;
string url;
address sender;
string media_type;
function Media(string _url, string _media_type) {
sender = msg.sender;
timestamp = block.timestamp;
url = _url;
media_type = _media_type;
}
function get_url() returns (string) {
return url;
}
function get_timestamp() returns (uint256) {
return timestamp;
}
function get_sender() returns (address) {
return sender;
}
function get_media_type() returns (string) {
return media_type;
}
}
contract Tweets {
uint256 timestamp;
string text;
address sender;
string location;
function Tweets(string _text, string _location) {
sender = msg.sender;
timestamp = block.timestamp;
text = _text;
location = _location;
}
function get_text() returns (string) {
return text;
}
function get_timestamp() returns (uint256) {
return timestamp;
}
function get_sender() returns (address) {
return sender;
}
function get_location() returns (string) {
return location;
}
}
contract App {
address[] Media_list;
uint256 Media_list_length;
//event NewJobs(address creater); //todo loop and fill out fields
address[] Tweets_list;
uint256 Tweets_list_length;
//event NewJobs(address creater); //todo loop and fill out fields
struct UserInfo {
address owner;
bool exists;
address[] Media_list;
uint256 Media_list_length;
address[] Tweets_list;
uint256 Tweets_list_length;
}
mapping(address => UserInfo) public user_map;
address[] UserInfoList;
uint256 UserInfoListLength;
function new_Media(string url, string media_type) returns (address) {
address mynew =
address(new Media({_url: url, _media_type: media_type}));
if (!user_map[msg.sender].exists) {
user_map[msg.sender] = create_user_on_new_Media(mynew);
}
user_map[msg.sender].Media_list.push(mynew);
Media_list.push(mynew);
Media_list_length += 1;
// emit NewPublicMessage(message, message_text,msg.sender);
return mynew;
}
function create_user_on_new_Media(address addr) private returns (UserInfo) {
address[] storage Media_list;
UserInfoList.push(addr);
return
UserInfo({
exists: true,
owner: addr,
Media_list: Media_list,
Media_list_length: 0,
Tweets_list: Tweets_list,
Tweets_list_length: 0
});
}
function new_Tweets(string text, string location) returns (address) {
address mynew = address(new Tweets({_text: text, _location: location}));
if (!user_map[msg.sender].exists) {
user_map[msg.sender] = create_user_on_new_Tweets(mynew);
}
user_map[msg.sender].Tweets_list.push(mynew);
Tweets_list.push(mynew);
Tweets_list_length += 1;
// emit NewPublicMessage(message, message_text,msg.sender);
return mynew;
}
function create_user_on_new_Tweets(address addr)
private
returns (UserInfo)
{
address[] storage Tweets_list;
UserInfoList.push(addr);
return
UserInfo({
exists: true,
owner: addr,
Media_list: Media_list,
Media_list_length: 0,
Tweets_list: Tweets_list,
Tweets_list_length: 0
});
}
}