Skip to content

Commit

Permalink
Fix event param in erc20 and erc721 (#226)
Browse files Browse the repository at this point in the history
* fix _from param

* replace _from with from_

* update _from in docs
  • Loading branch information
andrew-fleming authored Mar 22, 2022
1 parent 437383a commit fd6630e
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 67 deletions.
6 changes: 3 additions & 3 deletions docs/ERC20.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ success: felt
### Events

```jsx
func Transfer(_from: felt, to: felt, value: Uint256):
func Transfer(from_: felt, to: felt, value: Uint256):
end

func Approval(owner: felt, spender: felt, value: Uint256):
Expand All @@ -322,14 +322,14 @@ end

#### `Transfer (event)`

Emitted when `value` tokens are moved from one account (`_from`) to another (`to`).
Emitted when `value` tokens are moved from one account (`from_`) to another (`to`).

Note that `value` may be zero.

Parameters:

```jsx
_from: felt
from_: felt
to: felt
value: Uint256
```
Expand Down
28 changes: 14 additions & 14 deletions docs/ERC721.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ namespace IERC721:
end

func safeTransferFrom(
_from: felt,
from_: felt,
to: felt,
tokenId: Uint256,
data_len: felt,
data: felt*
):

func transferFrom(_from: felt, to: felt, tokenId: Uint256):
func transferFrom(from_: felt, to: felt, tokenId: Uint256):
end

func approve(approved: felt, tokenId: Uint256):
Expand Down Expand Up @@ -219,7 +219,7 @@ Interface for any contract that wants to support safeTransfers from ERC721 asset
namespace IERC721_Receiver:
func onERC721Received(
operator: felt,
_from: felt,
from_: felt,
tokenId: Uint256,
data_len: felt
data: felt*
Expand Down Expand Up @@ -354,15 +354,15 @@ func ownerOf(tokenId: Uint256) -> (owner: felt):
end

func safeTransferFrom(
_from: felt,
from_: felt,
to: felt,
tokenId: Uint256,
data_len: felt,
data: felt*
):
end

func transferFrom(_from: felt, to: felt, tokenId: Uint256):
func transferFrom(from_: felt, to: felt, tokenId: Uint256):
end

func approve(approved: felt, tokenId: Uint256):
Expand Down Expand Up @@ -413,14 +413,14 @@ owner: felt

#### `safeTransferFrom`

Safely transfers `tokenId` token from `_from` to `to`, checking first that contract recipients are aware of the ERC721 protocol to prevent tokens from being forever locked. For information regarding how contracts communicate their awareness of the ERC721 protocol, see [ERC721Received](#erc721received).
Safely transfers `tokenId` token from `from_` to `to`, checking first that contract recipients are aware of the ERC721 protocol to prevent tokens from being forever locked. For information regarding how contracts communicate their awareness of the ERC721 protocol, see [ERC721Received](#erc721received).

Emits a [Transfer](#-Transfer-(event)-) event.

Parameters:

```jsx
_from: felt
from_: felt
to: felt
tokenId: Uint256
data_len: felt
Expand All @@ -433,7 +433,7 @@ None.

#### `transferFrom`

Transfers `tokenId` token from `_from` to `to`.
Transfers `tokenId` token from `from_` to `to`.

> Note that this function should be used instead of `safeTransferFrom` to transfer tokens. Exercise caution as tokens sent to a contract that does not support ERC721 can be lost forever.
Expand All @@ -442,7 +442,7 @@ Emits a [Transfer](#-Transfer-(event)-) event.
Parameters:

```jsx
_from: felt
from_: felt
to: felt
tokenId: Uint256
```
Expand Down Expand Up @@ -545,12 +545,12 @@ approved: felt

#### `Transfer (Event)`

Emitted when `tokenId` token is transferred from `_from` to `to`.
Emitted when `tokenId` token is transferred from `from_` to `to`.

Parameters:

```jsx
_from: felt
from_: felt
to: felt
tokenId: Uint256
```
Expand Down Expand Up @@ -679,7 +679,7 @@ tokenId: Uint256
```jsx
func onERC721Received(
operator: felt,
_from: felt,
from_: felt,
tokenId: Uint256,
data_len: felt
data: felt*
Expand All @@ -689,14 +689,14 @@ end

#### `onERC721Received`

Whenever an IERC721 `tokenId` token is transferred to this non-account contract via `safeTransferFrom` by `operator` from `_from`, this function is called.
Whenever an IERC721 `tokenId` token is transferred to this non-account contract via `safeTransferFrom` by `operator` from `from_`, this function is called.


Parameters:

```jsx
operator: felt
_from: felt
from_: felt
tokenId: Uint256
data_len: felt
data: felt*
Expand Down
2 changes: 1 addition & 1 deletion src/openzeppelin/token/erc20/library.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ from openzeppelin.utils.constants import TRUE, FALSE, UINT8_MAX
#

@event
func Transfer(_from: felt, to: felt, value: Uint256):
func Transfer(from_: felt, to: felt, value: Uint256):
end

@event
Expand Down
8 changes: 4 additions & 4 deletions src/openzeppelin/token/erc721/ERC721_Mintable_Burnable.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ func transferFrom{
syscall_ptr: felt*,
range_check_ptr
}(
_from: felt,
from_: felt,
to: felt,
tokenId: Uint256
):
ERC721_transferFrom(_from, to, tokenId)
ERC721_transferFrom(from_, to, tokenId)
return ()
end

Expand All @@ -181,13 +181,13 @@ func safeTransferFrom{
syscall_ptr: felt*,
range_check_ptr
}(
_from: felt,
from_: felt,
to: felt,
tokenId: Uint256,
data_len: felt,
data: felt*
):
ERC721_safeTransferFrom(_from, to, tokenId, data_len, data)
ERC721_safeTransferFrom(from_, to, tokenId, data_len, data)
return ()
end

Expand Down
8 changes: 4 additions & 4 deletions src/openzeppelin/token/erc721/ERC721_Mintable_Pausable.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@ func transferFrom{
syscall_ptr: felt*,
range_check_ptr
}(
_from: felt,
from_: felt,
to: felt,
tokenId: Uint256
):
Pausable_when_not_paused()
ERC721_transferFrom(_from, to, tokenId)
ERC721_transferFrom(from_, to, tokenId)
return ()
end

Expand All @@ -199,14 +199,14 @@ func safeTransferFrom{
syscall_ptr: felt*,
range_check_ptr
}(
_from: felt,
from_: felt,
to: felt,
tokenId: Uint256,
data_len: felt,
data: felt*
):
Pausable_when_not_paused()
ERC721_safeTransferFrom(_from, to, tokenId, data_len, data)
ERC721_safeTransferFrom(from_, to, tokenId, data_len, data)
return ()
end

Expand Down
4 changes: 2 additions & 2 deletions src/openzeppelin/token/erc721/interfaces/IERC721.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ namespace IERC721:
end

func safeTransferFrom(
_from: felt,
from_: felt,
to: felt,
tokenId: Uint256,
data_len: felt,
data: felt*
):
end

func transferFrom(_from: felt, to: felt, tokenId: Uint256):
func transferFrom(from_: felt, to: felt, tokenId: Uint256):
end

func approve(approved: felt, tokenId: Uint256):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ from starkware.cairo.common.uint256 import Uint256
namespace IERC721_Receiver:
func onERC721Received(
operator: felt,
_from: felt,
from_: felt,
tokenId: Uint256,
data_len: felt,
data: felt*
Expand Down
32 changes: 16 additions & 16 deletions src/openzeppelin/token/erc721/library.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ from openzeppelin.utils.constants import TRUE, FALSE
#

@event
func Transfer(_from: felt, to: felt, tokenId: Uint256):
func Transfer(from_: felt, to: felt, tokenId: Uint256):
end

@event
Expand Down Expand Up @@ -255,7 +255,7 @@ func ERC721_transferFrom{
pedersen_ptr: HashBuiltin*,
syscall_ptr: felt*,
range_check_ptr
}(_from: felt, to: felt, token_id: Uint256):
}(from_: felt, to: felt, token_id: Uint256):
alloc_locals
with_attr error_message("ERC721: token_id is not a valid Uint256"):
uint256_check(token_id)
Expand All @@ -271,7 +271,7 @@ func ERC721_transferFrom{
# meaning that a*0==0 for all a in the field,
# therefore a*b==0 implies that at least one of a,b is zero in the field

_transfer(_from, to, token_id)
_transfer(from_, to, token_id)
return ()
end

Expand All @@ -280,7 +280,7 @@ func ERC721_safeTransferFrom{
syscall_ptr: felt*,
range_check_ptr
}(
_from: felt,
from_: felt,
to: felt,
token_id: Uint256,
data_len: felt,
Expand All @@ -301,7 +301,7 @@ func ERC721_safeTransferFrom{
# meaning that a*0==0 for all a in the field,
# therefore a*b==0 implies that at least one of a,b is zero in the field

_safe_transfer(_from, to, token_id, data_len, data)
_safe_transfer(from_, to, token_id, data_len, data)
return ()
end

Expand Down Expand Up @@ -477,11 +477,11 @@ func _transfer{
syscall_ptr: felt*,
pedersen_ptr: HashBuiltin*,
range_check_ptr
}(_from: felt, to: felt, token_id: Uint256):
# ownerOf ensures '_from' is not the zero address
}(from_: felt, to: felt, token_id: Uint256):
# ownerOf ensures 'from_' is not the zero address
let (_ownerOf) = ERC721_ownerOf(token_id)
with_attr error_message("ERC721: transfer from incorrect owner"):
assert _ownerOf = _from
assert _ownerOf = from_
end

with_attr error_message("ERC721: cannot transfer to the zero address"):
Expand All @@ -492,9 +492,9 @@ func _transfer{
_approve(0, token_id)

# Decrease owner balance
let (owner_bal) = ERC721_balances.read(_from)
let (owner_bal) = ERC721_balances.read(from_)
let (new_balance: Uint256) = uint256_checked_sub_le(owner_bal, Uint256(1, 0))
ERC721_balances.write(_from, new_balance)
ERC721_balances.write(from_, new_balance)

# Increase receiver balance
let (receiver_bal) = ERC721_balances.read(to)
Expand All @@ -503,7 +503,7 @@ func _transfer{

# Update token_id owner
ERC721_owners.write(token_id, to)
Transfer.emit(_from, to, token_id)
Transfer.emit(from_, to, token_id)
return ()
end

Expand All @@ -512,15 +512,15 @@ func _safe_transfer{
pedersen_ptr: HashBuiltin*,
range_check_ptr
}(
_from: felt,
from_: felt,
to: felt,
token_id: Uint256,
data_len: felt,
data: felt*
):
_transfer(_from, to, token_id)
_transfer(from_, to, token_id)

let (success) = _check_onERC721Received(_from, to, token_id, data_len, data)
let (success) = _check_onERC721Received(from_, to, token_id, data_len, data)
with_attr error_message("ERC721: transfer to non ERC721Receiver implementer"):
assert_not_zero(success)
end
Expand All @@ -532,7 +532,7 @@ func _check_onERC721Received{
pedersen_ptr: HashBuiltin*,
range_check_ptr
}(
_from: felt,
from_: felt,
to: felt,
token_id: Uint256,
data_len: felt,
Expand All @@ -545,7 +545,7 @@ func _check_onERC721Received{
let (selector) = IERC721_Receiver.onERC721Received(
to,
caller,
_from,
from_,
token_id,
data_len,
data
Expand Down
2 changes: 1 addition & 1 deletion src/openzeppelin/token/erc721/utils/ERC721_Holder.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ from openzeppelin.introspection.ERC165 import (
@view
func onERC721Received(
operator: felt,
_from: felt,
from_: felt,
tokenId: Uint256,
data_len: felt,
data: felt*
Expand Down
Loading

0 comments on commit fd6630e

Please sign in to comment.