Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make proper use of the term spender... #18

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ jobs:
node-version: "14"
cache: "yarn"

- uses: actions/setup-python@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.8.5
python-version: 3.11

- name: Install Solidity
env:
Expand All @@ -66,7 +67,7 @@ jobs:
solc-select use $SOLC_VERSION
- name: Install Slither
env:
SLITHER_VERSION: 0.8.0
SLITHER_VERSION: 0.9.6
run: pip3 install slither-analyzer==$SLITHER_VERSION

- name: Install dependencies
Expand Down
30 changes: 15 additions & 15 deletions contracts/token/ERC20WithPermit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,29 +73,29 @@ contract ERC20WithPermit is IERC20WithPermit, Ownable {
return true;
}

/// @notice Moves `amount` tokens from `spender` to `recipient` using the
/// @notice Moves `amount` tokens from `owner` to `recipient` using the
/// allowance mechanism. `amount` is then deducted from the caller's
/// allowance unless the allowance was made for `type(uint256).max`.
/// @return True if the operation succeeded, reverts otherwise.
/// @dev Requirements:
/// - `spender` and `recipient` cannot be the zero address,
/// - `spender` must have a balance of at least `amount`,
/// - the caller must have allowance for `spender`'s tokens of at least
/// - `owner` and `recipient` cannot be the zero address,
/// - `owner` must have a balance of at least `amount`,
/// - the caller must have allowance for `owner`'s tokens of at least
/// `amount`.
function transferFrom(
address spender,
address owner,
address recipient,
uint256 amount
) external override returns (bool) {
uint256 currentAllowance = allowance[spender][msg.sender];
uint256 currentAllowance = allowance[owner][msg.sender];
if (currentAllowance != type(uint256).max) {
require(
currentAllowance >= amount,
"Transfer amount exceeds allowance"
);
_approve(spender, msg.sender, currentAllowance - amount);
_approve(owner, msg.sender, currentAllowance - amount);
}
_transfer(spender, recipient, amount);
_transfer(owner, recipient, amount);
return true;
}

Expand Down Expand Up @@ -289,21 +289,21 @@ contract ERC20WithPermit is IERC20WithPermit, Ownable {
}

function _transfer(
address spender,
address owner,
address recipient,
uint256 amount
) private {
require(spender != address(0), "Transfer from the zero address");
require(owner != address(0), "Transfer from the zero address");
require(recipient != address(0), "Transfer to the zero address");
require(recipient != address(this), "Transfer to the token address");

beforeTokenTransfer(spender, recipient, amount);
beforeTokenTransfer(owner, recipient, amount);

uint256 spenderBalance = balanceOf[spender];
require(spenderBalance >= amount, "Transfer amount exceeds balance");
balanceOf[spender] = spenderBalance - amount;
uint256 ownerBalance = balanceOf[owner];
require(ownerBalance >= amount, "Transfer amount exceeds balance");
balanceOf[owner] = ownerBalance - amount;
balanceOf[recipient] += amount;
emit Transfer(spender, recipient, amount);
emit Transfer(owner, recipient, amount);
}

function _approve(
Expand Down
Loading