Skip to content

Commit

Permalink
Merge pull request #62 from PacificYield/fix-encryptedERC20
Browse files Browse the repository at this point in the history
fix: updates EncryptedERC20
  • Loading branch information
PacificYield authored Nov 18, 2024
2 parents 860761e + 42d53f8 commit 1aa4eb6
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions contracts/token/ERC20/EncryptedERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 1aa4eb6

Please sign in to comment.