Skip to content

Commit

Permalink
add accompanying comments to fixed logic
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-fleming committed Jan 21, 2022
1 parent b69efc4 commit 6dca176
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions contracts/token/ERC721_base.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ func ERC721_transferFrom{
let (caller) = get_caller_address()
let (is_approved) = _is_approved_or_owner(caller, token_id)
assert_not_zero(caller * is_approved)
# Note that if either `is_approved` or `caller` equals `0`,
# this tx should revert.
# The `caller` address and `is_approved` boolean are both field elements
# 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)
return ()
Expand All @@ -209,6 +214,11 @@ func ERC721_safeTransferFrom{
let (caller) = get_caller_address()
let (is_approved) = _is_approved_or_owner(caller, token_id)
assert_not_zero(caller * is_approved)
# Note that if either `is_approved` or `caller` equals `0`,
# this tx should revert.
# The `caller` address and `is_approved` boolean are both field elements
# 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)
return ()
Expand Down

0 comments on commit 6dca176

Please sign in to comment.