Skip to content

Commit

Permalink
ERC20 cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
g-r-a-n-t committed Dec 8, 2020
1 parent 805bce1 commit cb1bdc7
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions compiler/tests/fixtures/erc20_token.fe
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ contract ERC20:
_balances: map<address, u256>
_allowances: map<address, map<address, u256>>

_totalSupply: u256
_total_supply: u256

_name: string100
_symbol: string100
Expand All @@ -18,9 +18,9 @@ contract ERC20:
idx to: address
value: u256

pub def __init__(_name: string100, _symbol: string100):
self._name = _name
self._symbol = _symbol
pub def __init__(name: string100, symbol: string100):
self._name = name
self._symbol = symbol
self._decimals = u8(18)
self._mint(msg.sender, 2600)

Expand All @@ -34,7 +34,7 @@ contract ERC20:
return self._decimals

pub def totalSupply() -> u256:
return self._totalSupply
return self._total_supply

pub def balanceOf(account: address) -> u256:
return self._balances[account]
Expand Down Expand Up @@ -69,7 +69,7 @@ contract ERC20:
assert sender != address(0)
assert recipient != address(0)

self._beforeTokenTransfer(sender, recipient, amount)
self._before_token_transfer(sender, recipient, amount)

self._balances[sender] = self._balances[sender] - amount
self._balances[recipient] = self._balances[recipient] + amount
Expand All @@ -78,19 +78,19 @@ contract ERC20:
def _mint(account: address, amount: u256):
assert account != address(0)

self._beforeTokenTransfer(address(0), account, amount)
self._before_token_transfer(address(0), account, amount)

self._totalSupply = self._totalSupply + amount
self._total_supply = self._total_supply + amount
self._balances[account] = self._balances[account] + amount
emit Transfer(address(0), account, amount)

def _burn(account: address, amount: u256):
assert account != address(0)

self._beforeTokenTransfer(account, address(0), amount)
self._before_token_transfer(account, address(0), amount)

self._balances[account] = self._balances[account] - amount
self._totalSupply = self._totalSupply - amount
self._total_supply = self._total_supply - amount
emit Transfer(account, address(0), amount)

def _approve(owner: address, spender: address, amount: u256):
Expand All @@ -100,8 +100,8 @@ contract ERC20:
self._allowances[owner][spender] = amount
emit Approval(owner, spender, amount)

def _setupDecimals(decimals_: u8):
def _setup_decimals(decimals_: u8):
self._decimals = decimals_

def _beforeTokenTransfer(from: address, to: address, amount: u256):
def _before_token_transfer(from: address, to: address, amount: u256):
pass

0 comments on commit cb1bdc7

Please sign in to comment.