-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathUser.sol
79 lines (54 loc) · 2 KB
/
User.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
//"SPDX-License-Identifier: UNLICENSED"
pragma solidity >= 0.4.0 < 0.7.0;
import './Driver.sol';
import 'Ownable.sol';
contract User is Ownable{
// Main variables
string private _city;
address payable owneradd;
Driver d;
// Set Driver Contract address
function setDriverContractAddress(address contract_add) public onlyOwner{
d = Driver(contract_add);
}
//Test Function to check if we can access variables of other contract
// function getDriverList() public{
// nddriverList=d.giveArray();
// }
//Set Owner to get Payed
function setPayableOwner() public onlyOwner{
address ownerr = owner();
owneradd = payable(ownerr);
// emit nu(ownerr);
}
//Find drivers in your city (To give input in Driver Contract)
function findDriverbyCity(string calldata city) external{
_city=city;
}
//Get the count of all Drivers
function totalDrivers() public view returns(uint256){
return d.getDriverCount();
}
//Give city as input to driverLoop in Driver contract and get Drivers in Logs
function getDriverinLogs() public {
return d.driverLoop(_city);
}
//Call Selected driver
function callDriver(address driver_add) public payable{
owneradd.transfer(1000000000000000000);
return d.EngageDriver(driver_add,msg.sender);
}
// Pay money to driver as per his kilometer charge
function payMoney(address payable driver_add) public payable returns(address,uint256){
driver_add.transfer(address(this).balance);
return d.EndJourney(driver_add);
}
//To Cancel a ride
function cancelYourRide(address driver_add,address cust) public{
return d.cancelRide(driver_add,cust);
}
//Self Destruct
function kill() public onlyOwner{
selfdestruct(msg.sender);
}
}