From 42d53f8b0ca911ea92e730c25da86bd8095c5653 Mon Sep 17 00:00:00 2001 From: PacificYield <173040337+PacificYield@users.noreply.github.com> Date: Mon, 18 Nov 2024 16:42:44 +0100 Subject: [PATCH] fix: updates EncryptedERC20 --- contracts/token/ERC20/EncryptedERC20.sol | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/contracts/token/ERC20/EncryptedERC20.sol b/contracts/token/ERC20/EncryptedERC20.sol index cf6689b..3a1570a 100644 --- a/contracts/token/ERC20/EncryptedERC20.sol +++ b/contracts/token/ERC20/EncryptedERC20.sol @@ -154,14 +154,27 @@ abstract contract EncryptedERC20 is IEncryptedERC20 { TFHE.allow(amount, spender); } + /** + * @dev It does not incorporate any underflow check. It must be implemented + * by the function calling it. + */ + function _unsafeBurn(address account, euint64 amount) internal virtual { + euint64 newBalanceAccount = TFHE.sub(_balances[account], amount); + _balances[account] = newBalanceAccount; + TFHE.allowThis(newBalanceAccount); + TFHE.allow(newBalanceAccount, account); + emit Transfer(account, address(0)); + } + /** * @dev It does not incorporate any overflow check. It must be implemented * by the function calling it. */ function _unsafeMint(address account, euint64 amount) internal virtual { - _balances[msg.sender] = TFHE.add(_balances[account], amount); - TFHE.allowThis(_balances[account]); - TFHE.allow(_balances[account], account); + euint64 newBalanceAccount = TFHE.add(_balances[account], amount); + _balances[account] = newBalanceAccount; + TFHE.allowThis(newBalanceAccount); + TFHE.allow(newBalanceAccount, account); emit Transfer(address(0), account); }