From 2044e94491675b3a2bb04d27e3146b0e89904ce2 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Mon, 18 Nov 2024 09:18:08 +0100 Subject: [PATCH] update some examples --- examples/tokens/ERC20.vy | 12 ++++++------ examples/tokens/ERC4626.vy | 14 +++++++------- examples/tokens/ERC721.vy | 10 +++++----- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/examples/tokens/ERC20.vy b/examples/tokens/ERC20.vy index 2d70fd670a..86a9c42880 100644 --- a/examples/tokens/ERC20.vy +++ b/examples/tokens/ERC20.vy @@ -39,7 +39,7 @@ def __init__(_name: String[32], _symbol: String[32], _decimals: uint8, _supply: self.balanceOf[msg.sender] = init_supply self.totalSupply = init_supply self.minter = msg.sender - log IERC20.Transfer(empty(address), msg.sender, init_supply) + log IERC20.Transfer(sender=empty(address), receiver=msg.sender, value=init_supply) @@ -54,7 +54,7 @@ def transfer(_to : address, _value : uint256) -> bool: # so the following subtraction would revert on insufficient balance self.balanceOf[msg.sender] -= _value self.balanceOf[_to] += _value - log IERC20.Transfer(msg.sender, _to, _value) + log IERC20.Transfer(sender=msg.sender, receiver=_to, value=_value) return True @@ -73,7 +73,7 @@ def transferFrom(_from : address, _to : address, _value : uint256) -> bool: # NOTE: vyper does not allow underflows # so the following subtraction would revert on insufficient allowance self.allowance[_from][msg.sender] -= _value - log IERC20.Transfer(_from, _to, _value) + log IERC20.Transfer(sender=_from, receiver=_to, value=_value) return True @@ -89,7 +89,7 @@ def approve(_spender : address, _value : uint256) -> bool: @param _value The amount of tokens to be spent. """ self.allowance[msg.sender][_spender] = _value - log IERC20.Approval(msg.sender, _spender, _value) + log IERC20.Approval(owner=msg.sender, spender=_spender, value=_value) return True @@ -106,7 +106,7 @@ def mint(_to: address, _value: uint256): assert _to != empty(address) self.totalSupply += _value self.balanceOf[_to] += _value - log IERC20.Transfer(empty(address), _to, _value) + log IERC20.Transfer(sender=empty(address), receiver=_to, value=_value) @internal @@ -120,7 +120,7 @@ def _burn(_to: address, _value: uint256): assert _to != empty(address) self.totalSupply -= _value self.balanceOf[_to] -= _value - log IERC20.Transfer(_to, empty(address), _value) + log IERC20.Transfer(sender=_to, receiver=empty(address), value=_value) @external diff --git a/examples/tokens/ERC4626.vy b/examples/tokens/ERC4626.vy index 2dc4656746..313d99ed4c 100644 --- a/examples/tokens/ERC4626.vy +++ b/examples/tokens/ERC4626.vy @@ -56,14 +56,14 @@ def decimals() -> uint8: def transfer(receiver: address, amount: uint256) -> bool: self.balanceOf[msg.sender] -= amount self.balanceOf[receiver] += amount - log IERC20.Transfer(msg.sender, receiver, amount) + log IERC20.Transfer(sender=msg.sender, receiver=receiver, value=amount) return True @external def approve(spender: address, amount: uint256) -> bool: self.allowance[msg.sender][spender] = amount - log IERC20.Approval(msg.sender, spender, amount) + log IERC20.Approval(owner=msg.sender, spender=spender, value=amount) return True @@ -72,7 +72,7 @@ def transferFrom(sender: address, receiver: address, amount: uint256) -> bool: self.allowance[sender][msg.sender] -= amount self.balanceOf[sender] -= amount self.balanceOf[receiver] += amount - log IERC20.Transfer(sender, receiver, amount) + log IERC20.Transfer(sender=sender, receiver=receiver, value=amount) return True @@ -137,7 +137,7 @@ def deposit(assets: uint256, receiver: address=msg.sender) -> uint256: self.totalSupply += shares self.balanceOf[receiver] += shares - log IERC4626.Deposit(msg.sender, receiver, assets, shares) + log IERC4626.Deposit(sender=msg.sender, owner=receiver, assets=assets, shares=shares) return shares @@ -170,7 +170,7 @@ def mint(shares: uint256, receiver: address=msg.sender) -> uint256: self.totalSupply += shares self.balanceOf[receiver] += shares - log IERC4626.Deposit(msg.sender, receiver, assets, shares) + log IERC4626.Deposit(sender=msg.sender, owner=receiver, assets=assets, shares=shares) return assets @@ -207,7 +207,7 @@ def withdraw(assets: uint256, receiver: address=msg.sender, owner: address=msg.s self.balanceOf[owner] -= shares extcall self.asset.transfer(receiver, assets) - log IERC4626.Withdraw(msg.sender, receiver, owner, assets, shares) + log IERC4626.Withdraw(sender=msg.sender, receiver=receiver, owner=owner, assets=assets, shares=shares) return shares @@ -233,7 +233,7 @@ def redeem(shares: uint256, receiver: address=msg.sender, owner: address=msg.sen self.balanceOf[owner] -= shares extcall self.asset.transfer(receiver, assets) - log IERC4626.Withdraw(msg.sender, receiver, owner, assets, shares) + log IERC4626.Withdraw(sender=msg.sender, receiver=receiver, owner=owner, assets=assets, shares=shares) return assets diff --git a/examples/tokens/ERC721.vy b/examples/tokens/ERC721.vy index d57088b5aa..acb445bd57 100644 --- a/examples/tokens/ERC721.vy +++ b/examples/tokens/ERC721.vy @@ -201,7 +201,7 @@ def _transferFrom(_from: address, _to: address, _tokenId: uint256, _sender: addr # Add NFT self._addTokenTo(_to, _tokenId) # Log the transfer - log IERC721.Transfer(_from, _to, _tokenId) + log IERC721.Transfer(sender=_from, receiver=_to, token_id=_tokenId) ### TRANSFER FUNCTIONS ### @@ -275,7 +275,7 @@ def approve(_approved: address, _tokenId: uint256): assert (senderIsOwner or senderIsApprovedForAll) # Set the approval self.idToApprovals[_tokenId] = _approved - log IERC721.Approval(owner, _approved, _tokenId) + log IERC721.Approval(owner=owner, approved=_approved, token_id=_tokenId) @external @@ -291,7 +291,7 @@ def setApprovalForAll(_operator: address, _approved: bool): # Throws if `_operator` is the `msg.sender` assert _operator != msg.sender self.ownerToOperators[msg.sender][_operator] = _approved - log IERC721.ApprovalForAll(msg.sender, _operator, _approved) + log IERC721.ApprovalForAll(owner=msg.sender, operator=_operator, approved=_approved) ### MINT & BURN FUNCTIONS ### @@ -313,7 +313,7 @@ def mint(_to: address, _tokenId: uint256) -> bool: assert _to != empty(address) # Add NFT. Throws if `_tokenId` is owned by someone self._addTokenTo(_to, _tokenId) - log IERC721.Transfer(empty(address), _to, _tokenId) + log IERC721.Transfer(sender=empty(address), receiver=_to, token_id=_tokenId) return True @@ -333,7 +333,7 @@ def burn(_tokenId: uint256): assert owner != empty(address) self._clearApproval(owner, _tokenId) self._removeTokenFrom(owner, _tokenId) - log IERC721.Transfer(owner, empty(address), _tokenId) + log IERC721.Transfer(sender=owner, receiver=empty(address), token_id=_tokenId) @view