# Path: hydrachain/nc_utils.py
# def isaddress(x):
#     return len(x) == 20 and x != '\0' * 20
# 
# STATUS = 'uint16'
# 
# FORBIDDEN = 403
# 
# OK = 200
# 
# INSUFFICIENTFUNDS = PAYMENTREQUIRED = 402


import ethereum.utils as utils
import ethereum.slogging as slogging
import hydrachain.native_contracts as nc
from hydrachain.nc_utils import isaddress, STATUS, FORBIDDEN, OK, INSUFFICIENTFUNDS

class Token(Fungible):
    address = utils.int_to_addr(5001)


class Coin(Fungible):
    address = utils.int_to_addr(5002)


class Currency(Fungible):
    address = utils.int_to_addr(5003)


class Issuance(nc.ABIEvent):

    "Triggered when IOU.issue is called."
    args = [dict(name='issuer', type='address', indexed=True),
            dict(name='rtgs_hash', type='bytes32', indexed=True),
            dict(name='amount', type='uint256', indexed=True)]


class IOU(Fungible):
    """
    IOU fungible, can Issue its supply
    """

    address = utils.int_to_addr(5004)
    events = [Transfer, Approval, Issuance]
    issued_amounts = nc.IterableDict('uint256')


# Path: hydrachain/nc_utils.py
# def isaddress(x):
#     return len(x) == 20 and x != '\0' * 20
# 
# STATUS = 'uint16'
# 
# FORBIDDEN = 403
# 
# OK = 200
# 
# INSUFFICIENTFUNDS = PAYMENTREQUIRED = 402


# Path: hydrachain/examples/native/fungible/fungible_contract.py
import ethereum.utils as utils
import ethereum.slogging as slogging
import hydrachain.native_contracts as nc
from hydrachain.nc_utils import isaddress, STATUS, FORBIDDEN, OK, INSUFFICIENTFUNDS


class Token(Fungible):
    address = utils.int_to_addr(5001)


class Coin(Fungible):
    address = utils.int_to_addr(5002)


class Currency(Fungible):
    address = utils.int_to_addr(5003)


class Issuance(nc.ABIEvent):

    "Triggered when IOU.issue is called."
    args = [dict(name='issuer', type='address', indexed=True),
            dict(name='rtgs_hash', type='bytes32', indexed=True),
            dict(name='amount', type='uint256', indexed=True)]


class IOU(Fungible):
    """
    IOU fungible, can Issue its supply
    """

    address = utils.int_to_addr(5004)
    events = [Transfer, Approval, Issuance]
    issued_amounts = nc.IterableDict('uint256')


    def init(ctx, returns=STATUS):