-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddress
428 lines (385 loc) · 14.3 KB
/
address
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
0x8dc3Fae25a89AD3af0b8F5c99069d8263c64f449
SSV_Contract address: 0xfbD6099696F6f2E76F8CA2014143a8Cf9c224D8E
latest 0x992Ac7062c0db547D0F76fdfaEA8fe5a356D5a4a
latest1: 0xcb04a10eEc1c8778a024E773DcA97B60110b8B1E
<ContributeForm address={this.props.address}/>
<Form onSubmit={this.onSubmit}>
<Button primary loading={this.state.loading1}>View msg</Button>
</Form>
**********************************
*/index.js
<Link route="/contracts/new">
<a>
<Button floated="right"
content="Create Contract"
icon="add circle"
primary
/>
</a>
</Link>
Header.js
<Link route="/">
<a className="item" basic color="teal">
<Icon name='globe'/>
Global Contracts
</a>
</Link>
return {
header: info_string,
description:(
<Link route={`/contracts/${address}`} color="green" >
<Button basic color="green" floated="right">
View Contract
</Button>
</Link>
),
fluid:true,
meta:"ACCEPTED \nManager: "+manager+'\nReceiver: '+receiver
}
<Button basic color="green" floated="right">
View Contract
</Button>
<Card>
<Card.Content header='About Amy' />
<Card.Content description='description' />
<Card.Content extra>
</Card.Content>
</Card>
return Card
***************************************************************************************************************************
pragma solidity ^0.4.17;
pragma experimental ABIEncoderV2;
contract ContractDeployer {
mapping(address=>bool) public map;
address[] public deployedContracts;
function createContract(address _reciever, string info_string,string filehash,string ManagerName,string ReceiverName) public {
if(_reciever!=msg.sender){
address newContract = new MyContract( _reciever , info_string,msg.sender,filehash,ManagerName,ReceiverName);
deployedContracts.push(newContract);
}
}
function summaryOfInfo(address a,string s)public view returns (string []){
string[] array;
for(uint i=0;i<deployedContracts.length;i++)
{
MyContract my=MyContract(deployedContracts[i]);
if(keccak256(abi.encodePacked(s)) == keccak256(abi.encodePacked("Manager"))&&my.getManagerAddress()==a){
array.push(my.getInfo());
}
else if(keccak256(abi.encodePacked(s)) == keccak256(abi.encodePacked("Receiver"))&&my.getReceiverAddress()==a){
array.push(my.getInfo());
}
else if(keccak256(abi.encodePacked(s)) == keccak256(abi.encodePacked("Both"))&&((my.getReceiverAddress()==a)||(my.getManagerAddress()==a))){
array.push(my.getInfo());
}
}
return (array);
}
function summaryOfStatus(address a,string s)public view returns (bool []){
bool[] array;
for(uint i=0;i<deployedContracts.length;i++)
{
MyContract my=MyContract(deployedContracts[i]);
if(keccak256(abi.encodePacked(s)) == keccak256(abi.encodePacked("Manager"))&&my.getManagerAddress()==a){
array.push(my.checkAccepted());
}
else if(keccak256(abi.encodePacked(s)) == keccak256(abi.encodePacked("Receiver"))&&my.getReceiverAddress()==a){
array.push(my.checkAccepted());
}
else if(keccak256(abi.encodePacked(s)) == keccak256(abi.encodePacked("Both"))&&((my.getReceiverAddress()==a)||(my.getManagerAddress()==a))){
array.push(my.checkAccepted());
}
}
return (array);
}
function arrayGetAddress(address a,string s)public view returns (address []){
address[] array;
for(uint i=0;i<deployedContracts.length;i++)
{
MyContract my=MyContract(deployedContracts[i]);
if(keccak256(abi.encodePacked(s)) == keccak256(abi.encodePacked("Manager"))&&my.getManagerAddress()==a){
array.push(deployedContracts[i]);
}
else if(keccak256(abi.encodePacked(s)) == keccak256(abi.encodePacked("Receiver"))&&my.getReceiverAddress()==a){
array.push(deployedContracts[i]);
}
else if(keccak256(abi.encodePacked(s)) == keccak256(abi.encodePacked("Both"))&&((my.getReceiverAddress()==a)||(my.getManagerAddress()==a))){
array.push(deployedContracts[i]);
}
}
return array;
}
function getDeployedContracts() public view returns (address[]){
return deployedContracts;
}
function getNumberofContracts() public view returns (uint) {
return deployedContracts.length;
}
function getStatus() public view returns(bool[]){
bool[] status;
for(uint i=0;i<deployedContracts.length;i++)
{
MyContract my=MyContract(deployedContracts[i]);
status.push(my.checkAccepted());
}
return status;
}
function getInfo() public view returns (string[]){
string[] str;
for(uint i=0;i<deployedContracts.length;i++)
{
MyContract my=MyContract(deployedContracts[i]);
str.push(my.getInfo());
}
return str;
}
function getReceiver(address add) public view returns(address){
MyContract my=MyContract(add);
address t=my.getReceiverAddress();
return t;
}
function getManager(address add) public view returns(address){
MyContract my=MyContract(add);
address t=my.getManagerAddress();
return t;
}
function getReceiverAndManager(address add) public view returns(address,address){
MyContract my=MyContract(add);
address r=my.getReceiverAddress();
address m=my.getManagerAddress();
return (r,m);
}
function getManagerName() public view returns(string[]){
string[] str;
for(uint i=0;i<deployedContracts.length;i++)
{
MyContract my=MyContract(deployedContracts[i]);
str.push(my.getManagerName());
}
return str;
}
function getReceiverName()public view returns(string[]){
string[] str;
for(uint i=0;i<deployedContracts.length;i++)
{
MyContract my=MyContract(deployedContracts[i]);
str.push(my.getReceiverName());
}
return str;
}
}
contract MyContract {
address public manager;
address reciever;
string manager_Name;
string reciever_Name;
bool public isAccepted;
string public contract_info;
string[] public msgFromReceiver;
string[] public msgFromManager;
string public filehash;
constructor(address _reciever, string info_string,address Contract_manager,string _filehash,string ManagerName,string ReceiverName) public {
manager = Contract_manager;
reciever = _reciever;
contract_info=info_string;
filehash = _filehash;
isAccepted = false;
manager_Name=ManagerName;
reciever_Name=ReceiverName;
}
function getManagerAddress() public view returns(address){
return manager;
}
function getInfo() public view returns(string)
{
return contract_info;
}
function getReceiverAddress() public view returns(address)
{
return reciever;
}
function getfilehash() public view returns(string){
return filehash;
}
function setfilehash(string hash) public {
filehash=hash;
}
function acceptRequest() public{
require(msg.sender == reciever);
isAccepted = true;
}
function checkAccepted() public view returns(bool){
return isAccepted;
}
function setMsgfromReceiver(string msgReceiver) public {
require(msg.sender==reciever&&!isAccepted);
msgFromReceiver.push(msgReceiver);
}
function getmsgFromReceiver() public view returns(string[]){
return msgFromReceiver;
}
function setMsgfromManager(string msgManager) public {
require(msg.sender==manager&&!isAccepted);
msgFromManager.push(msgManager);
}
function getmsgFromManager() public view returns(string[]){
return msgFromManager;
}
function setContract_Info(string s) public{
require(msg.sender==manager&&!isAccepted);
contract_info=s;
}
function getSummary() public view returns(address,string,address,string,string,string
){
return(
reciever,contract_info,manager,filehash,manager_Name,reciever_Name
);
}
function setManagerName(string ManagerName) public{
require(msg.sender==manager);
manager_Name=ManagerName;
}
function getManagerName() public view returns(string){
//require(msg.sender==manager||msg.sender==reciever);
return manager_Name;
}
function setReceiverName(string ReceiverName) public{
require(msg.sender==manager);
reciever_Name=ReceiverName;
}
function getReceiverName() public view returns(string){
//require(msg.sender==manager||msg.sender==reciever);
return reciever_Name;
}
}
contract DeployMyProfile{
address[] public deployedContracts;
function createContract(string Name,uint Mbno,string Email,string ResidentialAddress,string Profession) public{
uint i=0;
address newContract;
for(i=0;i<deployedContracts.length;i++)
{
MyProfile my=MyProfile(deployedContracts[i]);
if(msg.sender==my.getAddress())
break;
}
if(deployedContracts.length==0){
newContract=new MyProfile(msg.sender,Name,Mbno,Email,ResidentialAddress,Profession);
deployedContracts.push(newContract);
}else
if(i==deployedContracts.length)
{
newContract=new MyProfile(msg.sender,Name,Mbno,Email,ResidentialAddress,Profession);
deployedContracts.push(newContract);
}
}
function getDeployedContracts() public view returns (address[]){
return deployedContracts;
}
function getNumberofContracts() public view returns (uint) {
return deployedContracts.length;
}
function getUsersInfo(address a) public view returns (string,uint,string,string,string){
string memory name;
uint mbno;
string memory email;
string memory residentialAddress;
string memory profession;
for(uint i=0;i<deployedContracts.length;i++)
{
MyProfile my=MyProfile(deployedContracts[i]);
if(my.getAddress()==a){
name=my.getName();
mbno=(my.getMbno());
email=(my.getEmail());
residentialAddress=(my.getResdentialAddress());
profession=(my.getProfession());
}
}
return (name,mbno,email,residentialAddress,profession);
}
function getUsersAddress(string a) public view returns (address){
address add;
for(uint i=0;i<deployedContracts.length;i++)
{
MyProfile my=MyProfile(deployedContracts[i]);
if(keccak256(abi.encodePacked(a)) == keccak256(abi.encodePacked(my.getName()))){
add=my.getAddress();
}
}
return (add);
}
function getAllUsers() public view returns (address[],string[] ,uint[],string[],string[],string[]){
address[] memory add=new address[](deployedContracts.length);
string[] memory name= new string[](deployedContracts.length);
uint[] memory mbno=new uint[](deployedContracts.length);
string[] memory email=new string[](deployedContracts.length);
string[] memory residentialAddress=new string[](deployedContracts.length);
string[] memory profession=new string[](deployedContracts.length);
for(uint i=0;i<deployedContracts.length;i++)
{
MyProfile my=MyProfile(deployedContracts[i]);
add[i]=my.getAddress();
name[i]=my.getName();
mbno[i]=my.getMbno();
email[i]=my.getEmail();
residentialAddress[i]=my.getResdentialAddress();
profession[i]=my.getProfession();
}
return (add,name,mbno,email,residentialAddress,profession);
}
}
contract MyProfile{
address public addressOfUser;
string public name;
uint public mbno;
string public email;
string public residentialAddress;
string public profession;
constructor(address Address,string Name,uint Mbno,string Email,string ResidentialAddress,string Profession) public
{
addressOfUser=Address;
name=Name;
mbno=Mbno;
email=Email;
residentialAddress=ResidentialAddress;
profession=Profession;
}
function getAddress() public view returns(address){
return addressOfUser;
}
function getName() public view returns(string){
return name;
}
function getMbno() public view returns(uint){
return mbno;
}
function getEmail() public view returns(string){
return email;
}
function getResdentialAddress() public view returns(string){
return residentialAddress;
}
function getProfession() public view returns(string){
return profession;
}
function setAddress(address a) public{
addressOfUser=a;
}
function setName(string a) public{
name=a;
}
function setMbno(uint a) public{
mbno=a;
}
function setEmail(string a) public{
email=a;
}
function setResdentialAddress(string a) public{
residentialAddress=a;
}
function setProfession(string a) public{
profession=a;
}
}
*******************************************************************************************************************************