From 7051eafe368e9599cb4e53792416842c4429b6f0 Mon Sep 17 00:00:00 2001 From: Ting-Jun Wang Date: Thu, 8 Jun 2023 19:29:09 +0800 Subject: [PATCH] fix: add the modifier 'onlySelfOrBank' for SBT --- contracts/SoulboundToken.sol | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/contracts/SoulboundToken.sol b/contracts/SoulboundToken.sol index 1b37883..80a4a89 100644 --- a/contracts/SoulboundToken.sol +++ b/contracts/SoulboundToken.sol @@ -72,6 +72,13 @@ contract SoulboundToken is ERC721, Ownable { require(isReliableBank[msg.sender] == true, "Only bank can access this function"); _; } + event HERE(address); + + modifier onlySelfOrBank(address addr) { + emit HERE(addr); + require((msg.sender == owner()) || (msg.sender == addr), "Only the owner can access this function."); + _; + } modifier onlyRegister { require(balanceOf(msg.sender)!=0, "Only Register can access this function"); @@ -106,7 +113,8 @@ contract SoulboundToken is ERC721, Ownable { return certificates[client]; } - function getAccountNumber(address client) public view onlyBank returns (uint) { + function getAccountNumber(address client) public onlySelfOrBank(client) returns (uint) { + return address_to_number[client]; } } \ No newline at end of file