fix something about contracts
This commit is contained in:
parent
7051eafe36
commit
c7a26f1a7e
@ -65,7 +65,7 @@ contract Bank {
|
|||||||
order_info[id] = Order(false, amount, shop);
|
order_info[id] = Order(false, amount, shop);
|
||||||
client_orders[msg.sender].push(id);
|
client_orders[msg.sender].push(id);
|
||||||
payable(shop).transfer(amount);
|
payable(shop).transfer(amount);
|
||||||
sbt.logBorrowing(msg.sender, id, amount);
|
sbt.logBorrowing(msg.sender, shop, id, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
function repay() public payable onlyClient returns (uint, uint) {
|
function repay() public payable onlyClient returns (uint, uint) {
|
||||||
@ -110,7 +110,7 @@ contract Bank {
|
|||||||
return credits[client];
|
return credits[client];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArrear(address client) public view onlySelfOrBank(client) return (uint) {
|
function getArrear(address client) public view onlySelfOrBank(client) returns (uint) {
|
||||||
return arrears[client];
|
return arrears[client];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -19,13 +19,13 @@ contract SoulboundToken is ERC721, Ownable {
|
|||||||
mapping(address => Certificate[]) private certificates;
|
mapping(address => Certificate[]) private certificates;
|
||||||
mapping(address => uint) private address_to_number;
|
mapping(address => uint) private address_to_number;
|
||||||
|
|
||||||
event Borrow(address client, address bank, uint id, uint amount);
|
event Borrow(address client, address shop, address bank, uint id, uint amount);
|
||||||
event Repay(address client, address bank, uint id, uint amount);
|
event Repay(address client, address bank, uint id, uint amount);
|
||||||
event Warning(address client, address bank);
|
event Warning(address client, address bank);
|
||||||
|
|
||||||
constructor() ERC721("Credit System Soulbound Token", "CS_SBT") {}
|
constructor() ERC721("Credit System Soulbound Token", "CS_SBT") {}
|
||||||
|
|
||||||
function mint(address player) public onlyOwner returns (uint256) {
|
function mint(address player) public returns (uint256) {
|
||||||
_tokenIds.increment();
|
_tokenIds.increment();
|
||||||
uint256 newItemId = _tokenIds.current();
|
uint256 newItemId = _tokenIds.current();
|
||||||
_mint(player, newItemId);
|
_mint(player, newItemId);
|
||||||
@ -72,11 +72,9 @@ contract SoulboundToken is ERC721, Ownable {
|
|||||||
require(isReliableBank[msg.sender] == true, "Only bank can access this function");
|
require(isReliableBank[msg.sender] == true, "Only bank can access this function");
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
event HERE(address);
|
|
||||||
|
|
||||||
modifier onlySelfOrBank(address addr) {
|
modifier onlySelfOrBank(address addr) {
|
||||||
emit HERE(addr);
|
require(isReliableBank[msg.sender] == true || (msg.sender == addr), "Only the owner can access this function.");
|
||||||
require((msg.sender == owner()) || (msg.sender == addr), "Only the owner can access this function.");
|
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,8 +91,8 @@ contract SoulboundToken is ERC721, Ownable {
|
|||||||
isReliableBank[bank] = false;
|
isReliableBank[bank] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function logBorrowing(address client, uint id, uint amount) public onlyBank {
|
function logBorrowing(address client, address shop, uint id, uint amount) public onlyBank {
|
||||||
emit Borrow(client, msg.sender, id, amount);
|
emit Borrow(client, shop, msg.sender, id, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
function logRepaying(address client, uint id, uint amount) public onlyBank {
|
function logRepaying(address client, uint id, uint amount) public onlyBank {
|
||||||
@ -113,8 +111,7 @@ contract SoulboundToken is ERC721, Ownable {
|
|||||||
return certificates[client];
|
return certificates[client];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAccountNumber(address client) public onlySelfOrBank(client) returns (uint) {
|
function getAccountNumber(address client) public view onlySelfOrBank(client) returns (uint) {
|
||||||
|
|
||||||
return address_to_number[client];
|
return address_to_number[client];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user