Ejemplo n.º 1
0
def revoke(address: str, amount: int) -> int:
    """Removes specified amount (at max) of tokens from provided address.

    Tokens go back to the authority.

    :return: The final balance of the address.
    """
    _assert_is_authority(context.sender)
    amount = min(amount, get_balance(address))
    base.Balances(balance_of).transfer(context.sender, address, amount)
    revoked(user=address, amount=amount)

    return base.Balances(balance_of).get(address)
Ejemplo n.º 2
0
def use_token() -> bool:
    """Grants or deny access to the sender, depending on the tokens owned."""
    global total_supply

    try:
        # First check base permission requirements
        _assert_is_not_frozen()
        base.Balances(balance_of).require(context.sender, 1)
    except ValueError as e:
        access_denied(user=context.sender, why=str(e))
        return False

    # then handle consequences regarding token type.
    success = True
    if permission_type == _PERM_TYPE_RETURNED:
        success = transfer(authority, 1)
    elif permission_type == _PERM_TYPE_CONSUMED:
        total_supply = burn(1)

    # Finally, raise appropriate event
    if success:
        access_granted(user=context.sender)
    else:
        access_denied(user=context.sender, why="Unknown error")

    return success
Ejemplo n.º 3
0
def get_organic_shares(address: str = None) -> int:
    """Gives the number of shares of the specified shareholder. This does not
    include delegation.

    :param address: The address of the shareholder to get delegation. If none
        provided, uses the sender's delegate address.
    """
    _assert_is_shareholder(address)
    return base.Balances(balance_of).get(address)
Ejemplo n.º 4
0
def get_balance(address: str) -> int:
    """Gives the current balance of the specified account."""
    return base.Balances(balance_of).get(address)
Ejemplo n.º 5
0
def get_total_spent() -> int:
    """Gives the total number of points spent by all customers."""
    return base.Balances(balance_of).get(bank_account)