-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d301a9
commit 50a85f5
Showing
5 changed files
with
144 additions
and
160 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
pragma solidity ^0.5.16; | ||
|
||
contract KYC { | ||
address kycadmin; | ||
|
||
constructor() public { | ||
kycadmin = msg.sender; | ||
} | ||
|
||
modifier onlyadmin() { | ||
require(msg.sender == kycadmin); | ||
_; | ||
} | ||
|
||
struct Bank { | ||
string name; | ||
uint256 kycCount; | ||
address Address; | ||
bool isAllowedToAddCustomer; | ||
bool kycPrivilege; | ||
} | ||
|
||
struct Customer { | ||
string name; | ||
string data; | ||
address validatedBank; | ||
bool kycStatus; | ||
} | ||
|
||
mapping(address => Bank) banks; // Mapping a bank's address to the Bank | ||
mapping(string => Customer) customersInfo; // Mapping a customer's username to the Customer | ||
|
||
function addNewBank(string memory bankName, address add) public onlyadmin { | ||
require( | ||
!areBothStringSame(banks[add].name, bankName), | ||
"A Bank already exists with same name" | ||
); | ||
banks[add] = Bank(bankName, 0, add, true, true); | ||
} | ||
|
||
function blockBankFromKYC(address add) public onlyadmin returns (int) { | ||
require(banks[add].Address != address(0), "Bank not found"); | ||
banks[add].kycPrivilege = false; | ||
return 1; | ||
} | ||
|
||
function allowBankFromKYC(address add) public onlyadmin returns (int) { | ||
require(banks[add].Address != address(0), "Bank not found"); | ||
banks[add].kycPrivilege = true; | ||
return 1; | ||
} | ||
|
||
function blockBankFromAddingNewCustomers( | ||
address add | ||
) public onlyadmin returns (int) { | ||
require(banks[add].Address != address(0), "Bank not found"); | ||
require( | ||
banks[add].isAllowedToAddCustomer, | ||
"Requested Bank is already blocked to add new customers" | ||
); | ||
banks[add].isAllowedToAddCustomer = false; | ||
return 1; | ||
} | ||
|
||
function allowBankFromAddingNewCustomers( | ||
address add | ||
) public onlyadmin returns (int) { | ||
require(banks[add].Address != address(0), "Bank not found"); | ||
require( | ||
!banks[add].isAllowedToAddCustomer, | ||
"Requested Bank is already allowed to add new customers" | ||
); | ||
banks[add].isAllowedToAddCustomer = true; | ||
return 1; | ||
} | ||
|
||
function addNewCustomerToBank( | ||
string memory custName, | ||
string memory custData | ||
) public { | ||
require( | ||
banks[msg.sender].isAllowedToAddCustomer, | ||
"Requested Bank is blocked to add new customers" | ||
); | ||
require( | ||
customersInfo[custName].validatedBank == address(0), | ||
"Requested Customer already exists" | ||
); | ||
|
||
customersInfo[custName] = Customer( | ||
custName, | ||
custData, | ||
msg.sender, | ||
false | ||
); | ||
} | ||
|
||
function viewCustomerData( | ||
string memory custName | ||
) public view returns (string memory, bool) { | ||
require( | ||
customersInfo[custName].validatedBank != address(0), | ||
"Requested Customer not found" | ||
); | ||
return ( | ||
customersInfo[custName].data, | ||
customersInfo[custName].kycStatus | ||
); | ||
} | ||
|
||
function addNewCustomerRequestForKYC( | ||
string memory custName | ||
) public returns (int) { | ||
require( | ||
banks[msg.sender].kycPrivilege, | ||
"Requested Bank does'nt have KYC Privilege" | ||
); | ||
customersInfo[custName].kycStatus = true; | ||
banks[msg.sender].kycCount++; | ||
|
||
return 1; | ||
} | ||
|
||
function getCustomerKycStatus( | ||
string memory custName | ||
) public view returns (bool) { | ||
require( | ||
customersInfo[custName].validatedBank != address(0), | ||
"Requested Customer not found" | ||
); | ||
return (customersInfo[custName].kycStatus); | ||
} | ||
|
||
function areBothStringSame( | ||
string memory a, | ||
string memory b | ||
) private pure returns (bool) { | ||
if (bytes(a).length != bytes(b).length) { | ||
return false; | ||
} else { | ||
return keccak256(bytes(a)) == keccak256(bytes(b)); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.