From 3687a3d49df21f59f94cf0986398ac3a02e57b48 Mon Sep 17 00:00:00 2001 From: snsd0805 Date: Sun, 4 Jun 2023 23:16:07 +0800 Subject: [PATCH] feat: log borrowing & repaying & bank warning --- contracts/SoulboundToken.sol | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/contracts/SoulboundToken.sol b/contracts/SoulboundToken.sol index 445829f..730b8fe 100644 --- a/contracts/SoulboundToken.sol +++ b/contracts/SoulboundToken.sol @@ -10,6 +10,12 @@ contract SoulboundToken is ERC721, Ownable { using Counters for Counters.Counter; Counters.Counter private _tokenIds; + mapping(address => bool) isReliableBank; + + event Borrow(address client, address bank, uint id, uint amount); + event Repay(address client, address bank, uint id, uint amount, bool finish); + event Warning(address client, address bank); + constructor() ERC721("Credit System Soulbound Token", "CS_SBT") {} function mint(address player) public onlyOwner returns (uint256) { @@ -54,4 +60,28 @@ contract SoulboundToken is ERC721, Ownable { return string(abi.encodePacked(a, uid_str, b)); } + modifier onlyBank { + require(isReliableBank[msg.sender] == true, "Only bank can access this function"); + _; + } + + function addReliableBank(address bank) public onlyOwner { + isReliableBank[bank] = true; + } + + function removeReliableBank(address bank) public onlyOwner { + isReliableBank[bank] = false; + } + + function logBorrowing(address client, uint id, uint amount) public onlyBank { + emit Borrow(client, msg.sender, id, amount); + } + + function logRepaying(address client, uint id, uint amount, bool finish) public onlyBank { + emit Repay(client, msg.sender, id, amount, finish); + } + + function logWarning(address client) public onlyBank { + emit Warning(client, msg.sender); + } } \ No newline at end of file