Esempio n. 1
0
    def __init__(self, contract, name):
        FeeTokenInterface.__init__(self, contract, name)

        self.clearTokens = lambda sender, address: mine_tx(
            self.contract.functions.clearTokens(address).transact({"from": sender}), "clearTokens", self.contract_name)
        self.giveTokens = lambda sender, address, value: mine_tx(
            self.contract.functions.giveTokens(address, value).transact({"from": sender}), "giveTokens", self.contract_name)
    def __init__(self, contract, name):
        OwnedInterface.__init__(self, contract, name)
        self.contract = contract
        self.contract_name = name

        self.initiationTime = lambda: self.contract.functions.initiationTime(
        ).call()
        self.selfDestructBeneficiary = lambda: self.contract.functions.selfDestructBeneficiary(
        ).call()
        self.selfDestructInitiated = lambda: self.contract.functions.selfDestructInitiated(
        ).call()
        self.SELFDESTRUCT_DELAY = lambda: self.contract.functions.SELFDESTRUCT_DELAY(
        ).call()

        self.setSelfDestructBeneficiary = lambda sender, beneficiary: mine_tx(
            self.contract.functions.setSelfDestructBeneficiary(
                beneficiary).transact({'from': sender}),
            "setSelfDestructBeneficiary", self.contract_name)
        self.initiateSelfDestruct = lambda sender: mine_tx(
            self.contract.functions.initiateSelfDestruct().transact(
                {'from': sender}), "initiateSelfDestruct", self.contract_name)
        self.terminateSelfDestruct = lambda sender: mine_tx(
            self.contract.functions.terminateSelfDestruct().transact(
                {'from': sender}), "terminateSelfDestruct", self.contract_name)
        self.selfDestruct = lambda sender: mine_tx(
            self.contract.functions.selfDestruct().transact({'from': sender}),
            "selfDestruct", self.contract_name)
Esempio n. 3
0
    def __init__(self, contract, name):
        CourtInterface.__init__(self, contract, name)
        self.contract = contract
        self.contract_name = name

        self.getHavven = lambda: self.contract.functions._havven().call()
        self.getNomin = lambda: self.contract.functions._nomin().call()
        self.minStandingBalance = lambda: self.contract.functions.minStandingBalance().call()
        self.votingPeriod = lambda: self.contract.functions.votingPeriod().call()
        self.MIN_VOTING_PERIOD = lambda: self.contract.functions._MIN_VOTING_PERIOD().call()
        self.MAX_VOTING_PERIOD = lambda: self.contract.functions._MAX_VOTING_PERIOD().call()
        self.confirmationPeriod = lambda: self.contract.functions.confirmationPeriod().call()
        self.MIN_CONFIRMATION_PERIOD = lambda: self.contract.functions._MIN_CONFIRMATION_PERIOD().call()
        self.MAX_CONFIRMATION_PERIOD = lambda: self.contract.functions._MAX_CONFIRMATION_PERIOD().call()
        self.requiredParticipation = lambda: self.contract.functions.requiredParticipation().call()
        self.MIN_REQUIRED_PARTICIPATION = lambda: self.contract.functions._MIN_REQUIRED_PARTICIPATION().call()
        self.requiredMajority = lambda: self.contract.functions.requiredMajority().call()
        self.MIN_REQUIRED_MAJORITY = lambda: self.contract.functions._MIN_REQUIRED_MAJORITY().call()
        self.voteWeight = lambda account, motionID: self.contract.functions._voteWeight(account, motionID).call()
        self.nextMotionID = lambda: self.contract.functions._nextMotionID().call()

        # Internal
        self.setupVote = lambda sender, target: mine_tx(
            self.contract.functions.publicSetupVote(target).transact({'from': sender}), "setupVote", self.contract_name)

        self.setHavven = lambda sender, addr: mine_tx(
            self.contract.functions.setHavven(addr).transact({'from': sender}), "setHavven", self.contract_name)
        self.setNomin = lambda sender, addr: mine_tx(
            self.contract.functions.setNomin(addr).transact({'from': sender}), "setNomin", self.contract_name)
Esempio n. 4
0
    def setUpClass(cls):
        cls.assertReverts = assertReverts

        compiled = compile_contracts([ERC20Token_SOURCE])
        cls.erc20_abi = compiled['ERC20Token']['abi']
        cls.erc20_event_dict = generate_topic_event_map(cls.erc20_abi)
        cls.erc20token, cls.construction_txr = attempt_deploy(
            compiled, 'ERC20Token', MASTER,
            ["Test Token", "TEST", 1000 * UNIT, MASTER])

        cls.totalSupply = lambda self: cls.erc20token.functions.totalSupply(
        ).call()
        cls.name = lambda self: cls.erc20token.functions.name().call()
        cls.symbol = lambda self: cls.erc20token.functions.symbol().call()
        cls.balanceOf = lambda self, account: cls.erc20token.functions.balanceOf(
            account).call()
        cls.allowance = lambda self, account, spender: cls.erc20token.functions.allowance(
            account, spender).call()

        cls.transfer = lambda self, sender, to, value: mine_tx(
            cls.erc20token.functions.transfer(to, value).transact(
                {'from': sender}))
        cls.approve = lambda self, sender, spender, value: mine_tx(
            cls.erc20token.functions.approve(spender, value).transact(
                {'from': sender}))
        cls.transferFrom = lambda self, sender, fromAccount, to, value: mine_tx(
            cls.erc20token.functions.transferFrom(fromAccount, to, value).
            transact({'from': sender}))
Esempio n. 5
0
    def test_setOwner(self):
        pre_owner = self.nomin.owner()
        new_owner = DUMMY

        # Only the owner must be able to set the owner.
        self.assertReverts(self.nomin.nominateNewOwner, new_owner, new_owner)
        txr = mine_tx(
            self.nomin_contract.functions.nominateNewOwner(new_owner).transact(
                {'from': pre_owner}), 'nominateNewOwner', 'Nomin')
        self.assertEventEquals(self.nomin_event_dict,
                               txr.logs[0],
                               'OwnerNominated',
                               fields={'newOwner': new_owner},
                               location=self.nomin_contract.address)
        txr = mine_tx(
            self.nomin_contract.functions.acceptOwnership().transact(
                {'from': new_owner}), 'acceptOwnership', 'Nomin')
        self.assertEventEquals(self.nomin_event_dict,
                               txr.logs[0],
                               'OwnerChanged',
                               fields={
                                   'oldOwner': pre_owner,
                                   'newOwner': new_owner
                               },
                               location=self.nomin_contract.address)
        self.assertEqual(self.nomin_contract.functions.owner().call(),
                         new_owner)
Esempio n. 6
0
def deploy_public_havven():
    print("Deployment initiated.\n")

    compiled = attempt(compile_contracts, [SOLIDITY_SOURCES],
                       "Compiling contracts... ")

    # Deploy contracts
    havven_contract, hvn_txr = attempt_deploy(compiled, 'PublicHavven', MASTER,
                                              [ZERO_ADDRESS, MASTER])
    hvn_block = W3.eth.blockNumber
    nomin_contract, nom_txr = attempt_deploy(compiled, 'EtherNomin', MASTER, [
        havven_contract.address, MASTER, MASTER, 1000 * UNIT, MASTER,
        ZERO_ADDRESS
    ])
    court_contract, court_txr = attempt_deploy(
        compiled, 'Court', MASTER,
        [havven_contract.address, nomin_contract.address, MASTER])
    escrow_contract, escrow_txr = attempt_deploy(
        compiled, 'PublicHavvenEscrow', MASTER,
        [MASTER, havven_contract.address])

    # Install proxies
    havven_proxy, _ = attempt_deploy(compiled, 'Proxy', MASTER,
                                     [havven_contract.address, MASTER])
    mine_tx(
        havven_contract.functions.setProxy(havven_proxy.address).transact(
            {'from': MASTER}))
    proxy_havven = W3.eth.contract(address=havven_proxy.address,
                                   abi=compiled['PublicHavven']['abi'])

    nomin_proxy, _ = attempt_deploy(compiled, 'Proxy', MASTER,
                                    [nomin_contract.address, MASTER])
    mine_tx(
        nomin_contract.functions.setProxy(nomin_proxy.address).transact(
            {'from': MASTER}))
    proxy_nomin = W3.eth.contract(address=nomin_proxy.address,
                                  abi=compiled['EtherNomin']['abi'])

    # Hook up each of those contracts to each other
    txs = [
        proxy_havven.functions.setNomin(nomin_contract.address).transact(
            {'from': MASTER}),
        proxy_nomin.functions.setCourt(court_contract.address).transact(
            {'from': MASTER}),
        proxy_havven.functions.setEscrow(escrow_contract.address).transact(
            {'from': MASTER})
    ]
    attempt(mine_txs, [txs], "Linking contracts... ")

    escrow_event_dict = generate_topic_event_map(
        compiled['HavvenEscrow']['abi'])

    print("\nDeployment complete.\n")
    return proxy_havven, proxy_nomin, havven_proxy, nomin_proxy, havven_contract, nomin_contract, court_contract, escrow_contract, hvn_block, escrow_event_dict
Esempio n. 7
0
    def setUpClass(cls):
        cls.assertReverts = assertReverts

        compiled = compile_contracts([OWNED_SOURCE])
        cls.owned, txr = attempt_deploy(compiled, 'Owned', MASTER, [MASTER])

        cls.owner = lambda self: cls.owned.functions.owner().call()
        cls.nominateOwner = lambda self, sender, newOwner: mine_tx(
            cls.owned.functions.nominateOwner(newOwner).transact({'from': sender}))
        cls.acceptOwnership = lambda self, sender: mine_tx(
            cls.owned.functions.acceptOwnership().transact({'from': sender}))
Esempio n. 8
0
    def __init__(self, contract, name):
        self.contract = contract
        self.contract_name = name

        self.owner = lambda: self.contract.functions.owner().call()
        self.nominatedOwner = lambda: self.contract.functions.nominatedOwner().call()

        self.nominateNewOwner = lambda sender, addr: mine_tx(
            self.contract.functions.nominateNewOwner(addr).transact({'from': sender}), "nominateNewOwner", self.contract_name)
        self.acceptOwnership = lambda sender: mine_tx(
            self.contract.functions.acceptOwnership().transact({'from': sender}), "acceptOwnership", self.contract_name)
Esempio n. 9
0
    def __init__(self, contract, name):
        StateInterface.__init__(self, contract, name)
        self.contract = contract
        self.contract_name = name

        self.balanceOf = lambda acc: self.contract.functions.balanceOf(
            acc).call()
        self.allowance = lambda frm, to: self.contract.functions.allowance(
            frm, to).call()

        self.setAllowance = lambda sender, token_owner, spender, value: mine_tx(
            self.contract.functions.setAllowance(token_owner, spender, value).
            transact({'from': sender}), "setAllowance", self.contract_name)
        self.setBalanceOf = lambda sender, account, value: mine_tx(
            self.contract.functions.setBalanceOf(account, value).transact(
                {'from': sender}), "setBalanceOf", self.contract_name)
Esempio n. 10
0
def send_value(sender, recipient, value):
    return mine_tx(
        W3.eth.sendTransaction({
            'from': sender,
            'to': recipient,
            'value': value
        }))
Esempio n. 11
0
    def __init__(self, contract, name):
        self.contract = contract
        self.contract_name = name

        self.owner = lambda: self.contract.functions.owner().call()
        self.paused = lambda: self.contract.functions.paused().call()
        self.lastPauseTime = lambda: self.contract.functions.lastPauseTime(
        ).call()
        self.getSomeValue = lambda: self.contract.functions.someValue().call()

        self.setPaused = lambda sender, paused: mine_tx(
            self.contract.functions.setPaused(paused).transact(
                {'from': sender}), "setPaused", self.contract_name)
        self.setSomeValue = lambda sender, someValue: mine_tx(
            self.contract.functions.setSomeValue(someValue).transact(
                {'from': sender}), "setSomeValue", self.contract_name)
Esempio n. 12
0
    def __init__(self, contract, name):
        NominInterface.__init__(self, contract, name)
        self.contract = contract
        self.contract_name = name

        self.debugEmptyFeePool = lambda sender: mine_tx(
            self.contract.functions.debugEmptyFeePool().transact(
                {'from': sender}), "debugEmptyFeePool", self.contract_name)
        self.debugFreezeAccount = lambda sender, target: mine_tx(
            self.contract.functions.debugFreezeAccount(target).transact(
                {'from': sender}), "debugFreezeAccount", self.contract_name)

        self.giveNomins = lambda sender, target, amount: mine_tx(
            self.contract.functions.giveNomins(target, amount).transact(
                {'from': sender}), "giveNomins", self.contract_name)
        self.clearNomins = lambda sender, target: mine_tx(
            self.contract.functions.clearNomins(target).transact(
                {'from': sender}), "clearNomins", self.contract_name)

        self.generateFees = lambda sender, amt: mine_tx(
            self.contract.functions.generateFees(amt).transact(
                {'from': sender}), "generateFees", self.contract_name)

        self.publicBurn = lambda sender, target, amount: mine_tx(
            self.contract.functions.publicBurn(target, amount).transact(
                {'from': sender}), "publicBurn", self.contract_name)
        self.publicIssue = lambda sender, target, amount: mine_tx(
            self.contract.functions.publicIssue(target, amount).transact(
                {'from': sender}), "publicIssue", self.contract_name)
    def setUpClass(cls):
        cls.assertReverts = assertReverts

        cls.the_owner = DUMMY

        cls.compiled = compile_contracts(
            [ExternStateProxyToken_SOURCE, TokenState_SOURCE, Proxy_SOURCE],
            remappings=['""=contracts'])
        cls.token_abi = cls.compiled['PublicExternStateProxyToken']['abi']
        cls.token_event_dict = generate_topic_event_map(cls.token_abi)
        cls.token_real, cls.construction_txr = attempt_deploy(
            cls.compiled, 'PublicExternStateProxyToken', MASTER, [
                "Test Token", "TEST", 1000 * UNIT, cls.the_owner, ZERO_ADDRESS,
                cls.the_owner
            ])

        cls.tokenstate = W3.eth.contract(
            address=cls.token_real.functions.state().call(),
            abi=cls.compiled['TokenState']['abi'])

        mine_tx(
            cls.token_real.functions.setState(cls.tokenstate.address).transact(
                {'from': cls.the_owner}))

        cls.tokenproxy, _ = attempt_deploy(
            cls.compiled, 'Proxy', MASTER,
            [cls.token_real.address, cls.the_owner])
        mine_tx(
            cls.token_real.functions.setProxy(cls.tokenproxy.address).transact(
                {'from': cls.the_owner}))
        cls.token = W3.eth.contract(
            address=cls.tokenproxy.address,
            abi=cls.compiled['PublicExternStateProxyToken']['abi'])

        cls.owner = lambda self: cls.token.functions.owner().call()
        cls.totalSupply = lambda self: cls.token.functions.totalSupply().call()
        cls.state = lambda self: cls.token.functions.state().call()
        cls.name = lambda self: cls.token.functions.name().call()
        cls.symbol = lambda self: cls.token.functions.symbol().call()
        cls.balanceOf = lambda self, account: cls.token.functions.balanceOf(
            account).call()
        cls.allowance = lambda self, account, spender: cls.token.functions.allowance(
            account, spender).call()

        cls.setState = lambda self, sender, new_state: mine_tx(
            cls.token.functions.setState(new_state).transact({'from': sender}))
        cls.transfer_byProxy = lambda self, sender, to, value: mine_tx(
            cls.token.functions.transfer_byProxy(to, value).transact(
                {'from': sender}))
        cls.approve = lambda self, sender, spender, value: mine_tx(
            cls.token.functions.approve(spender, value).transact(
                {'from': sender}))
        cls.transferFrom_byProxy = lambda self, sender, fromAccount, to, value: mine_tx(
            cls.token.functions.transferFrom_byProxy(fromAccount, to, value).
            transact({'from': sender}))
Esempio n. 14
0
    def __init__(self, contract, name):
        self.contract = contract
        self.contract_name = name

        self.setNomin = lambda sender, new_nomin: mine_tx(
            self.contract.functions.setNomin(new_nomin).transact({'from': sender}), "setNomin", "FakeCourt")
        self.setConfirming = lambda sender, target, status: mine_tx(
            self.contract.functions.setConfirming(target, status).transact({'from': sender}), "setConfirming",
            "FakeCourt")
        self.setVotePasses = lambda sender, target, status: mine_tx(
            self.contract.functions.setVotePasses(target, status).transact({'from': sender}), "setVotePasses",
            "FakeCourt")
        self.setTargetMotionID = lambda sender, target, motionID: mine_tx(
            self.contract.functions.setTargetMotionID(target, motionID).transact({'from': sender}), "setTargetMotionID",
            "FakeCourt")
        self.freezeAndConfiscate = lambda sender, target: mine_tx(
            self.contract.functions.freezeAndConfiscate(target).transact({'from': sender}), "freezeAndConfiscate",
            "FakeCourt")
    def __init__(self, contract, name):
        FeeTokenInterface.__init__(self, contract, name)
        self.contract = contract
        self.contract_name = name

        self.havven = lambda: self.contract.functions.havven().call()
        self.frozen = lambda address: self.contract.functions.frozen(address
                                                                     ).call()

        self.setHavven = lambda sender, address: mine_tx(
            self.contract.functions.setHavven(address).transact(
                {'from': sender}), "setHavven", self.contract_name)

        self.transferPlusFee = lambda value: self.contract.functions.transferPlusFee(
            value).call()
        self.transferFeeIncurred = lambda value: self.contract.functions.transferFeeIncurred(
            value).call()
        self.transfer = lambda sender, recipient, value: mine_tx(
            self.contract.functions.transfer(recipient, value).transact(
                {'from': sender}), "transfer", self.contract_name)
        self.transferFrom = lambda sender, frm, to, value: mine_tx(
            self.contract.functions.transferFrom(frm, to, value).transact(
                {'from': sender}), "transferFrom", self.contract_name)
        self.transferSenderPaysFee = lambda sender, recipient, value: mine_tx(
            self.contract.functions.transferSenderPaysFee(
                recipient, value).transact({'from': sender}),
            "transferSenderPaysFee", self.contract_name)
        self.transferFromSenderPaysFee = lambda sender, frm, to, value: mine_tx(
            self.contract.functions.transferFromSenderPaysFee(
                frm, to, value).transact({'from': sender}),
            "transferFromSenderPaysFee", self.contract_name)

        self.approve = lambda sender, spender, value: mine_tx(
            self.contract.functions.approve(spender, value).transact(
                {'from': sender}), "approve", self.contract_name)

        # onlyOwner
        self.unfreezeAccount = lambda sender, target: mine_tx(
            self.contract.functions.unfreezeAccount(target).transact(
                {'from': sender}), "unfreezeAccount", self.contract_name)

        # onlyHavven
        self.burn = lambda sender, target, amount: mine_tx(
            self.contract.functions.burn(target, amount).transact(
                {'from': sender}), "burn", self.contract_name)
        self.issue = lambda sender, target, amount: mine_tx(
            self.contract.functions.issue(target, amount).transact(
                {'from': sender}), "issue", self.contract_name)
Esempio n. 16
0
    def __init__(self, contract, name):
        OwnedInterface.__init__(self, contract, name)
        self.contract = contract
        self.contract_name = name

        self.target = lambda: self.contract.functions.target().call()
        self.useDELEGATECALL = lambda: self.contract.functions.useDELEGATECALL().call()

        self.setTarget = lambda sender, addr: mine_tx(
            self.contract.functions.setTarget(addr).transact({'from': sender}), "setTarget", self.contract_name)
Esempio n. 17
0
    def setUpClass(cls):
        cls.assertReverts = assertReverts

        cls.compiled = compile_contracts([TokenState_SOURCE],
                                         remappings=['""=contracts'])
        cls.owner = MASTER
        cls.associate = DUMMY

        cls.tokenstate, _ = attempt_deploy(cls.compiled, 'TokenState', MASTER, [cls.owner, cls.associate])

        cls.state_owner = lambda self: cls.tokenstate.functions.owner().call()
        cls.associatedContract = lambda self: cls.tokenstate.functions.associatedContract().call()
        cls.balanceOf = lambda self, acc: cls.tokenstate.functions.balanceOf(acc).call()
        cls.allowance = lambda self, frm, to: cls.tokenstate.functions.allowance(frm, to).call()

        cls.setAssociatedContract = lambda self, sender, addr: mine_tx(
            cls.tokenstate.functions.setAssociatedContract(addr).transact({'from': sender}))
        cls.setAllowance = lambda self, sender, tokenOwner, spender, value: mine_tx(
            cls.tokenstate.functions.setAllowance(tokenOwner, spender, value).transact({'from': sender}))
        cls.setBalanceOf = lambda self, sender, account, value: mine_tx(
            cls.tokenstate.functions.setBalanceOf(account, value).transact({'from': sender}))
    def __init__(self, contract, name):
        SafeDecimalMathInterface.__init__(self, contract, name)
        SelfDestructibleInterface.__init__(self, contract, name)
        self.contract = contract
        self.contract_name = name

        self.totalSupply = lambda: self.contract.functions.totalSupply().call()
        self.tokenState = lambda: self.contract.functions.tokenState().call()
        self.name = lambda: self.contract.functions.name().call()
        self.symbol = lambda: self.contract.functions.symbol().call()
        self.balanceOf = lambda account: self.contract.functions.balanceOf(account).call()
        self.allowance = lambda account, spender: self.contract.functions.allowance(account, spender).call()

        self.setTokenState = lambda sender, new_state: mine_tx(
            self.contract.functions.setTokenState(new_state).transact({'from': sender}), "setTokenState", self.contract_name)
        self.transfer = lambda sender, to, value: mine_tx(
            self.contract.functions.transfer(to, value).transact({'from': sender}), "transfer", self.contract_name)
        self.approve = lambda sender, spender, value: mine_tx(
            self.contract.functions.approve(spender, value).transact({'from': sender}), "approve", self.contract_name)
        self.transferFrom = lambda sender, frm, to, value: mine_tx(
            self.contract.functions.transferFrom(frm, to, value).transact({'from': sender}), "transferFrom", self.contract_name)
Esempio n. 19
0
    def __init__(self, contract, name):
        ExternStateTokenInterface.__init__(self, contract, name)
        
        self.contract = contract
        self.contract_name = name

        self.feePool = lambda: self.contract.functions.feePool().call()
        self.feeAuthority = lambda: self.contract.functions.feeAuthority().call()
        self.transferFeeRate = lambda: self.contract.functions.transferFeeRate().call()

        self.transferFeeIncurred = lambda value: self.contract.functions.transferFeeIncurred(value).call()
        self.transferPlusFee = lambda value: self.contract.functions.transferPlusFee(value).call()
        self.amountReceived = lambda value: self.contract.functions.amountReceived(value).call()

        self.setTransferFeeRate = lambda sender, new_fee_rate: mine_tx(
            self.contract.functions.setTransferFeeRate(new_fee_rate).transact({'from': sender}), "setTransferFeeRate", self.contract_name)
        self.setFeeAuthority = lambda sender, new_fee_authority: mine_tx(
            self.contract.functions.setFeeAuthority(new_fee_authority).transact({'from': sender}), "setFeeAuthority", self.contract_name)
        self.transferSenderPaysFee = lambda sender, to, value: mine_tx(
            self.contract.functions.transferSenderPaysFee(to, value).transact({'from': sender}), "transferSenderPaysFee", self.contract_name)
        self.transferFromSenderPaysFee = lambda sender, frm, to, value: mine_tx(
            self.contract.functions.transferFromSenderPaysFee(frm, to, value).transact({'from': sender}), "transferFromSenderPaysFee", self.contract_name)
        self.withdrawFees = lambda sender, account, value: mine_tx(
            self.contract.functions.withdrawFees(account, value).transact({'from': sender}), "withdrawFees", self.contract_name)
        self.donateToFeePool = lambda sender, value: mine_tx(
            self.contract.functions.donateToFeePool(value).transact({'from': sender}), "donateToFeePool", self.contract_name)
    def setUpClass(cls):
        cls.assertReverts = assertReverts
        cls.assertClose = assertClose

        compiled = compile_contracts([SD_SOURCE], remappings=['""=contracts'])

        cls.sd, txr = attempt_deploy(compiled, 'PayableSD', MASTER,
                                     [MASTER, DUMMY])

        cls.owner = lambda self: cls.sd.functions.owner().call()
        cls.nominateOwner = lambda self, sender, newOwner: mine_tx(
            cls.sd.functions.nominateOwner(newOwner).transact({'from': sender})
        )
        cls.acceptOwnership = lambda self, sender: mine_tx(
            cls.sd.functions.acceptOwnership().transact({'from': sender}))

        cls.initiationTime = lambda self: cls.sd.functions.initiationTime(
        ).call()
        cls.beneficiary = lambda self: cls.sd.functions.beneficiary().call()

        cls.setBeneficiary = lambda self, sender, beneficiary: mine_tx(
            cls.sd.functions.setBeneficiary(beneficiary).transact(
                {'from': sender}))
        cls.initiateSelfDestruct = lambda self, sender: mine_tx(
            cls.sd.functions.initiateSelfDestruct().transact({'from': sender}))
        cls.terminateSelfDestruct = lambda self, sender: mine_tx(
            cls.sd.functions.terminateSelfDestruct().transact({'from': sender}
                                                              ))
        cls.selfDestruct = lambda self, sender: mine_tx(
            cls.sd.functions.selfDestruct().transact({'from': sender}))

        send_value(MASTER, cls.sd.address, 10 * UNIT)
Esempio n. 21
0
    def __init__(self, contract, name):
        SafeDecimalMathInterface.__init__(self, contract, name)
        OwnedInterface.__init__(self, contract, name)
        LimitedSetupInterface.__init__(self, contract, name)

        self.contract = contract
        self.contract_name = name

        self.havven = lambda: self.contract.functions.havven().call()
        self.vestingSchedules = lambda account, index, i: self.contract.functions.vestingSchedules(
            account, index, i).call()
        self.numVestingEntries = lambda account: self.contract.functions.numVestingEntries(
            account).call()
        self.getVestingScheduleEntry = lambda account, index: self.contract.functions.getVestingScheduleEntry(
            account, index).call()
        self.getVestingTime = lambda account, index: self.contract.functions.getVestingTime(
            account, index).call()
        self.getVestingQuantity = lambda account, index: self.contract.functions.getVestingQuantity(
            account, index).call()
        self.totalVestedAccountBalance = lambda account: self.contract.functions.totalVestedAccountBalance(
            account).call()
        self.totalVestedBalance = lambda: self.contract.functions.totalVestedBalance(
        ).call()
        self.getNextVestingIndex = lambda account: self.contract.functions.getNextVestingIndex(
            account).call()
        self.getNextVestingEntry = lambda account: self.contract.functions.getNextVestingEntry(
            account).call()
        self.getNextVestingTime = lambda account: self.contract.functions.getNextVestingTime(
            account).call()
        self.getNextVestingQuantity = lambda account: self.contract.functions.getNextVestingQuantity(
            account).call()
        self.balanceOf = lambda account: self.contract.functions.balanceOf(
            account).call()

        self.setHavven = lambda sender, account: mine_tx(
            self.contract.functions.setHavven(account).transact(
                {'from': sender}), "setHavven", self.contract_name)
        self.purgeAccount = lambda sender, account: mine_tx(
            self.contract.functions.purgeAccount(account).transact(
                {'from': sender}), "purgeAccount", self.contract_name)
        self.withdrawHavvens = lambda sender, quantity: mine_tx(
            self.contract.functions.withdrawHavvens(quantity).transact(
                {'from': sender}), "withdrawHavvens", self.contract_name)
        self.appendVestingEntry = lambda sender, account, time, quantity: mine_tx(
            self.contract.functions.appendVestingEntry(
                account, time, quantity).transact({'from': sender}),
            "appendVestingEntry", self.contract_name)
        self.addVestingSchedule = lambda sender, account, times, quantities: mine_tx(
            self.contract.functions.addVestingSchedule(
                account, times, quantities).transact({'from': sender}),
            "addVestingSchedule", self.contract_name)
        self.vest = lambda sender: mine_tx(
            self.contract.functions.vest().transact({'from': sender}), "vest",
            self.contract_name)
Esempio n. 22
0
    def setUpClass(cls):
        cls.havven, cls.nomin, cls.havven_proxy, cls.nomin_proxy, cls.havven_real, cls.nomin_real, cls.fake_court = deploy_public_contracts(
        )

        cls.assertClose = assertClose
        cls.assertReverts = assertReverts
        fast_forward(weeks=102)

        # INHERITED
        # OWNED
        cls.h_owner = lambda self: self.havven.functions.owner().call()
        cls.h_nominateOwner = lambda self, sender, addr: mine_tx(
            self.havven.functions.nominateOwner(addr).transact(
                {'from': sender}))
        cls.h_acceptOwnership = lambda self, sender: mine_tx(
            self.havven.functions.acceptOwnership().transact({'from': sender}))

        # ExternStateProxyToken (transfer/transferFrom are overwritten)
        # totalSupply
        cls.h_totalSupply = lambda self: self.havven.functions.totalSupply(
        ).call()
        cls.h_name = lambda self: self.havven.functions.name().call()
        cls.h_symbol = lambda self: self.havven.functions.symbol().call()
        cls.h_balanceOf = lambda self, a: self.havven.functions.balanceOf(
            a).call()
        cls.h_allowance = lambda self, owner, spender: self.havven.functions.allowance(
            owner, spender).call()
        cls.h_approve = lambda self, sender, spender, val: mine_tx(
            self.havven.functions.approve(spender, val).transact(
                {"from": sender}))

        # HAVVEN
        # GETTERS
        cls.h_currentBalanceSum = lambda self, addr: self.havven.functions._currentBalanceSum(
            addr).call()
        cls.h_lastAverageBalance = lambda self, addr: self.havven.functions.lastAverageBalance(
            addr).call()
        cls.h_penultimateAverageBalance = lambda self, addr: self.havven.functions.penultimateAverageBalance(
            addr).call()
        cls.h_lastTransferTimestamp = lambda self, addr: self.havven.functions._lastTransferTimestamp(
            addr).call()
        cls.h_hasWithdrawnLastPeriodFees = lambda self, addr: self.havven.functions._hasWithdrawnLastPeriodFees(
            addr).call()
        cls.h_lastAverageBalanceNeedsRecomputation = lambda self, addr: \
            self.havven.functions.lastAverageBalanceNeedsRecomputation(addr).call()

        cls.h_feePeriodStartTime = lambda self: self.havven.functions.feePeriodStartTime(
        ).call()
        cls.h_lastFeePeriodStartTime = lambda self: self.havven.functions._lastFeePeriodStartTime(
        ).call()
        cls.h_penultimateFeePeriodStartTime = lambda self: self.havven.functions._penultimateFeePeriodStartTime(
        ).call()
        cls.h_targetFeePeriodDurationSeconds = lambda \
            self: self.havven.functions.targetFeePeriodDurationSeconds().call()
        cls.h_minFeePeriodDurationSeconds = lambda self: self.havven.functions._minFeePeriodDurationSeconds(
        ).call()
        cls.h_maxFeePeriodDurationSeconds = lambda self: self.havven.functions._maxFeePeriodDurationSeconds(
        ).call()
        cls.h_lastFeesCollected = lambda self: self.havven.functions.lastFeesCollected(
        ).call()

        cls.h_get_nomin = lambda self: self.havven.functions.nomin().call()

        #
        # SETTERS
        cls.h_setNomin = lambda self, sender, addr: mine_tx(
            self.havven.functions.setNomin(addr).transact({'from': sender}))
        cls.h_setTargetFeePeriodDuration = lambda self, sender, dur: mine_tx(
            self.havven.functions.setTargetFeePeriodDuration(dur).transact(
                {'from': sender}))

        #
        # FUNCTIONS
        cls.h_endow = lambda self, sender, addr, amt: mine_tx(
            self.havven.functions.endow(addr, amt).transact({'from': sender}))
        cls.h_transfer = lambda self, sender, addr, amt: mine_tx(
            self.havven.functions.transfer(addr, amt).transact(
                {'from': sender}))
        cls.h_transferFrom = lambda self, sender, frm, to, amt: mine_tx(
            self.havven.functions.transferFrom(frm, to, amt).transact(
                {'from': sender}))
        cls.h_recomputeLastAverageBalance = lambda self, sender: mine_tx(
            self.havven.functions.recomputeLastAverageBalance().transact(
                {'from': sender}))
        cls.h_rolloverFeePeriod = lambda self, sender: mine_tx(
            self.havven.functions.rolloverFeePeriod().transact(
                {'from': sender}))

        #
        # INTERNAL
        cls.h_adjustFeeEntitlement = lambda self, sender, acc, p_bal: mine_tx(
            self.havven.functions._adjustFeeEntitlement(acc, p_bal).transact(
                {'from': sender}))
        # rolloverFee (ltt->last_transfer_time)
        cls.h_rolloverFee = lambda self, sender, acc, ltt, p_bal: mine_tx(
            self.havven.functions._rolloverFee(acc, ltt, p_bal).transact(
                {'from': sender}))

        # withdrawFeeEntitlement
        cls.h_withdrawFeeEntitlement = lambda self, sender: mine_tx(
            self.havven.functions.withdrawFeeEntitlement().transact(
                {'from': sender}))

        #
        # MODIFIERS
        # postCheckFeePeriodRollover
        cls.h_checkFeePeriodRollover = lambda self, sender: mine_tx(
            self.havven.functions._checkFeePeriodRollover().transact(
                {'from': sender}))

        cls.fake_court_setNomin = lambda sender, new_nomin: mine_tx(
            cls.fake_court.functions.setNomin(new_nomin).transact(
                {'from': sender}))
        cls.fake_court_setConfirming = lambda sender, target, status: mine_tx(
            cls.fake_court.functions.setConfirming(target, status).transact(
                {'from': sender}))
        cls.fake_court_setVotePasses = lambda sender, target, status: mine_tx(
            cls.fake_court.functions.setVotePasses(target, status).transact(
                {'from': sender}))
        cls.fake_court_confiscateBalance = lambda sender, target: mine_tx(
            cls.fake_court.functions.confiscateBalance(target).transact(
                {'from': sender}))
        cls.fake_court_setNomin(W3.eth.accounts[0], cls.nomin.address)

        cls.n_owner = lambda self: cls.nomin.functions.owner().call()
        cls.n_oracle = lambda self: cls.nomin.functions.oracle().call()
        cls.n_court = lambda self: cls.nomin.functions.court().call()
        cls.n_beneficiary = lambda self: cls.nomin.functions.beneficiary(
        ).call()
        cls.n_nominPool = lambda self: cls.nomin.functions.nominPool().call()
        cls.n_poolFeeRate = lambda self: cls.nomin.functions.poolFeeRate(
        ).call()
        cls.n_liquidationPeriod = lambda self: cls.nomin.functions.liquidationPeriod(
        ).call()
        cls.n_liquidationTimestamp = lambda self: cls.nomin.functions.liquidationTimestamp(
        ).call()
        cls.n_etherPrice = lambda self: cls.nomin.functions.etherPrice().call()
        cls.n_frozen = lambda self, address: cls.nomin.functions.frozen(
            address).call()
        cls.n_lastPriceUpdate = lambda self: cls.nomin.functions.lastPriceUpdate(
        ).call()
        cls.n_stalePeriod = lambda self: cls.nomin.functions.stalePeriod(
        ).call()

        cls.n_nominateOwner = lambda self, sender, address: mine_tx(
            cls.nomin.functions.nominateOwner(address).transact(
                {'from': sender}))
        cls.n_acceptOwnership = lambda self, sender: mine_tx(
            cls.nomin.functions.acceptOwnership().transact({'from': sender}))
        cls.n_setOracle = lambda self, sender, address: mine_tx(
            cls.nomin.functions.setOracle(address).transact({'from': sender}))
        cls.n_setCourt = lambda self, sender, address: mine_tx(
            cls.nomin.functions.setCourt(address).transact({'from': sender}))
        cls.n_setBeneficiary = lambda self, sender, address: mine_tx(
            cls.nomin.functions.setBeneficiary(address).transact(
                {'from': sender}))
        cls.n_setPoolFeeRate = lambda self, sender, rate: mine_tx(
            cls.nomin.functions.setPoolFeeRate(rate).transact({'from': sender})
        )
        cls.n_updatePrice = lambda self, sender, price, timeSent: mine_tx(
            cls.nomin_real.functions.updatePrice(price, timeSent).transact(
                {'from': sender}))
        cls.n_setStalePeriod = lambda self, sender, period: mine_tx(
            cls.nomin.functions.setStalePeriod(period).transact(
                {'from': sender}))

        cls.n_fiatValue = lambda self, eth: cls.nomin.functions.fiatValue(
            eth).call()
        cls.n_fiatBalance = lambda self: cls.nomin.functions.fiatBalance(
        ).call()
        cls.n_collateralisationRatio = lambda self: cls.nomin.functions.collateralisationRatio(
        ).call()
        cls.n_etherValue = lambda self, fiat: cls.nomin.functions.etherValue(
            fiat).call()
        cls.n_etherValueAllowStale = lambda self, fiat: cls.nomin.functions.publicEtherValueAllowStale(
            fiat).call()
        cls.n_poolFeeIncurred = lambda self, n: cls.nomin.functions.poolFeeIncurred(
            n).call()
        cls.n_purchaseCostFiat = lambda self, n: cls.nomin.functions.purchaseCostFiat(
            n).call()
        cls.n_purchaseCostEther = lambda self, n: cls.nomin.functions.purchaseCostEther(
            n).call()
        cls.n_saleProceedsFiat = lambda self, n: cls.nomin.functions.saleProceedsFiat(
            n).call()
        cls.n_saleProceedsEther = lambda self, n: cls.nomin.functions.saleProceedsEther(
            n).call()
        cls.n_saleProceedsEtherAllowStale = lambda self, n: cls.nomin.functions.publicSaleProceedsEtherAllowStale(
            n).call()
        cls.n_priceIsStale = lambda self: cls.nomin.functions.priceIsStale(
        ).call()
        cls.n_isLiquidating = lambda self: cls.nomin.functions.isLiquidating(
        ).call()
        cls.n_canSelfDestruct = lambda self: cls.nomin.functions.canSelfDestruct(
        ).call()

        cls.n_transferPlusFee = lambda self, value: cls.nomin.functions.transferPlusFee(
            value).call()
        cls.n_transfer = lambda self, sender, recipient, value: mine_tx(
            cls.nomin.functions.transfer(recipient, value).transact(
                {'from': sender}))
        cls.n_transferFrom = lambda self, sender, fromAccount, to, value: mine_tx(
            cls.nomin.functions.transferFrom(fromAccount, to, value).transact(
                {'from': sender}))
        cls.n_approve = lambda self, sender, spender, value: mine_tx(
            cls.nomin.functions.approve(spender, value).transact(
                {'from': sender}))
        cls.n_replenishPool = lambda self, sender, n, value: mine_tx(
            cls.nomin.functions.replenishPool(n).transact({
                'from': sender,
                'value': value
            }))
        cls.n_diminishPool = lambda self, sender, n: mine_tx(
            cls.nomin.functions.diminishPool(n).transact({'from': sender}))
        cls.n_buy = lambda self, sender, n, value: mine_tx(
            cls.nomin.functions.buy(n).transact({
                'from': sender,
                'value': value
            }))
        cls.n_sell = lambda self, sender, n: mine_tx(
            cls.nomin.functions.sell(n).transact({
                'from': sender,
                'gasPrice': 10
            }))

        cls.n_forceLiquidation = lambda self, sender: mine_tx(
            cls.nomin.functions.forceLiquidation().transact({'from': sender}))
        cls.n_liquidate = lambda self, sender: mine_tx(
            cls.nomin.functions.liquidate().transact({'from': sender}))
        cls.n_extendLiquidationPeriod = lambda self, sender, extension: mine_tx(
            cls.nomin.functions.extendLiquidationPeriod(extension).transact(
                {'from': sender}))
        cls.n_terminateLiquidation = lambda self, sender: mine_tx(
            cls.nomin.functions.terminateLiquidation().transact(
                {'from': sender}))
        cls.n_selfDestruct = lambda self, sender: mine_tx(
            cls.nomin.functions.selfDestruct().transact({'from': sender}))

        cls.n_confiscateBalance = lambda self, sender, target: mine_tx(
            cls.nomin.functions.confiscateBalance(target).transact(
                {'from': sender}))
        cls.n_unfreezeAccount = lambda self, sender, target: mine_tx(
            cls.nomin.functions.unfreezeAccount(target).transact(
                {'from': sender}))

        cls.n_name = lambda self: cls.nomin.functions.name().call()
        cls.n_symbol = lambda self: cls.nomin.functions.symbol().call()
        cls.n_totalSupply = lambda self: cls.nomin.functions.totalSupply(
        ).call()
        cls.n_balanceOf = lambda self, account: cls.nomin.functions.balanceOf(
            account).call()
        cls.n_transferFeeRate = lambda self: cls.nomin.functions.transferFeeRate(
        ).call()
        cls.n_feePool = lambda self: cls.nomin.functions.feePool().call()
        cls.n_feeAuthority = lambda self: cls.nomin.functions.feeAuthority(
        ).call()

        cls.n_debugWithdrawAllEther = lambda self, sender, recipient: mine_tx(
            cls.nomin.functions.debugWithdrawAllEther(recipient).transact(
                {'from': sender}))
        cls.n_debugEmptyFeePool = lambda self, sender: mine_tx(
            cls.nomin.functions.debugEmptyFeePool().transact({'from': sender}))
        cls.n_debugFreezeAccount = lambda self, sender, target: mine_tx(
            cls.nomin.functions.debugFreezeAccount(target).transact(
                {'from': sender}))
Esempio n. 23
0
 def havven_updatePrice(self, sender, price, time):
     return mine_tx(
         self.havven_contract.functions.updatePrice(price, time).transact(
             {'from': sender}), 'updatePrice', 'Havven')
    def setUpClass(cls):
        cls.assertReverts = assertReverts
        cls.initial_beneficiary, cls.fee_authority, cls.token_owner = fresh_accounts(
            3)

        cls.compiled = compile_contracts(
            [ExternStateProxyFeeToken_SOURCE, Proxy_SOURCE, TokenState_SOURCE],
            remappings=['""=contracts'])
        cls.feetoken_abi = cls.compiled['PublicExternStateProxyFeeToken'][
            'abi']
        cls.feetoken_event_dict = generate_topic_event_map(cls.feetoken_abi)
        cls.feetoken_real, cls.construction_txr = attempt_deploy(
            cls.compiled, "PublicExternStateProxyFeeToken", MASTER, [
                "Test Fee Token", "FEE", UNIT // 20, cls.fee_authority,
                ZERO_ADDRESS, cls.token_owner
            ])

        cls.feestate, txr = attempt_deploy(cls.compiled, "TokenState", MASTER,
                                           [cls.token_owner, cls.token_owner])
        mine_tx(
            cls.feestate.functions.setBalanceOf(cls.initial_beneficiary,
                                                1000 * UNIT).transact(
                                                    {'from': cls.token_owner}))
        mine_tx(
            cls.feestate.functions.setAssociatedContract(
                cls.feetoken_real.address).transact({'from': cls.token_owner}))

        cls.feetoken_proxy, _ = attempt_deploy(
            cls.compiled, 'Proxy', MASTER,
            [cls.feetoken_real.address, cls.token_owner])
        mine_tx(
            cls.feetoken_real.functions.setProxy(
                cls.feetoken_proxy.address).transact({'from':
                                                      cls.token_owner}))
        cls.feetoken = W3.eth.contract(
            address=cls.feetoken_proxy.address,
            abi=cls.compiled['PublicExternStateProxyFeeToken']['abi'])

        mine_tx(
            cls.feetoken_real.functions.setState(
                cls.feestate.address).transact({'from': cls.token_owner}))

        cls.owner = lambda self: cls.feetoken.functions.owner().call()
        cls.totalSupply = lambda self: cls.feetoken.functions.totalSupply(
        ).call()
        cls.state = lambda self: cls.feetoken.functions.state().call()
        cls.name = lambda self: cls.feetoken.functions.name().call()
        cls.symbol = lambda self: cls.feetoken.functions.symbol().call()
        cls.balanceOf = lambda self, account: self.feetoken.functions.balanceOf(
            account).call()
        cls.allowance = lambda self, account, spender: self.feetoken.functions.allowance(
            account, spender).call()
        cls.transferFeeRate = lambda self: cls.feetoken.functions.transferFeeRate(
        ).call()
        cls.maxTransferFeeRate = lambda self: cls.feetoken.functions.maxTransferFeeRate(
        ).call()
        cls.feePool = lambda self: cls.feetoken.functions.feePool().call()
        cls.feeAuthority = lambda self: cls.feetoken.functions.feeAuthority(
        ).call()

        cls.transferFeeIncurred = lambda self, value: cls.feetoken.functions.transferFeeIncurred(
            value).call()
        cls.transferPlusFee = lambda self, value: cls.feetoken.functions.transferPlusFee(
            value).call()
        cls.priceToSpend = lambda self, value: cls.feetoken.functions.priceToSpend(
            value).call()

        cls.nominateOwner = lambda self, sender, address: mine_tx(
            cls.feetoken.functions.nominateOwner(address).transact(
                {'from': sender}))
        cls.acceptOwnership = lambda self, sender: mine_tx(
            cls.feetoken.functions.acceptOwnership().transact({'from': sender}
                                                              ))
        cls.setTransferFeeRate = lambda self, sender, new_fee_rate: mine_tx(
            cls.feetoken.functions.setTransferFeeRate(new_fee_rate).transact(
                {'from': sender}))
        cls.setFeeAuthority = lambda self, sender, new_fee_authority: mine_tx(
            cls.feetoken.functions.setFeeAuthority(new_fee_authority).transact(
                {'from': sender}))
        cls.setState = lambda self, sender, new_state: mine_tx(
            cls.feetoken.functions.setState(new_state).transact(
                {'from': sender}))
        cls.transfer_byProxy = lambda self, sender, to, value: mine_tx(
            cls.feetoken.functions.transfer_byProxy(to, value).transact(
                {'from': sender}))
        cls.approve = lambda self, sender, spender, value: mine_tx(
            cls.feetoken.functions.approve(spender, value).transact(
                {'from': sender}))
        cls.transferFrom_byProxy = lambda self, sender, fromAccount, to, value: mine_tx(
            cls.feetoken.functions.transferFrom_byProxy(
                fromAccount, to, value).transact({'from': sender}))

        cls.withdrawFee = lambda self, sender, account, value: mine_tx(
            cls.feetoken_real.functions.withdrawFee(account, value).transact(
                {'from': sender}))
        cls.donateToFeePool = lambda self, sender, value: mine_tx(
            cls.feetoken.functions.donateToFeePool(value).transact(
                {'from': sender}))

        cls.debug_messageSender = lambda self: cls.feetoken_real.functions._messageSender(
        ).call()
        cls.debug_optionalProxy = lambda self, sender: mine_tx(
            cls.feetoken.functions._optionalProxy_tester().transact(
                {'from': sender}))
        cls.debug_optionalProxy_direct = lambda self, sender: mine_tx(
            cls.feetoken_real.functions._optionalProxy_tester().transact(
                {'from': sender}))
Esempio n. 25
0
    def setUpClass(cls):
        cls.assertReverts = assertReverts
        cls.initial_beneficiary, cls.fee_authority, cls.token_owner = fresh_accounts(
            3)

        compiled = compile_contracts([ERC20FeeToken_SOURCE])
        cls.erc20fee_abi = compiled['ERC20FeeToken']['abi']
        cls.erc20fee_event_dict = generate_topic_event_map(cls.erc20fee_abi)
        cls.erc20feetoken, cls.construction_txr = attempt_deploy(
            compiled, "ERC20FeeToken", MASTER, [
                "Test Fee Token", "FEE", 1000 * UNIT, cls.initial_beneficiary,
                UNIT // 20, cls.fee_authority, cls.token_owner
            ])

        cls.owner = lambda self: cls.erc20feetoken.functions.owner().call()
        cls.totalSupply = lambda self: cls.erc20feetoken.functions.totalSupply(
        ).call()
        cls.name = lambda self: cls.erc20feetoken.functions.name().call()
        cls.symbol = lambda self: cls.erc20feetoken.functions.symbol().call()
        cls.balanceOf = lambda self, account: self.erc20feetoken.functions.balanceOf(
            account).call()
        cls.allowance = lambda self, account, spender: self.erc20feetoken.functions.allowance(
            account, spender).call()
        cls.transferFeeRate = lambda self: cls.erc20feetoken.functions.transferFeeRate(
        ).call()
        cls.maxTransferFeeRate = lambda self: cls.erc20feetoken.functions.maxTransferFeeRate(
        ).call()
        cls.feePool = lambda self: cls.erc20feetoken.functions.feePool().call()
        cls.feeAuthority = lambda self: cls.erc20feetoken.functions.feeAuthority(
        ).call()

        cls.transferFeeIncurred = lambda self, value: cls.erc20feetoken.functions.transferFeeIncurred(
            value).call()
        cls.transferPlusFee = lambda self, value: cls.erc20feetoken.functions.transferPlusFee(
            value).call()

        cls.setOwner = lambda self, sender, address: mine_tx(
            cls.erc20feetoken.functions.setOwner(address).transact(
                {'from': sender}))
        cls.setTransferFeeRate = lambda self, sender, new_fee_rate: mine_tx(
            cls.erc20feetoken.functions.setTransferFeeRate(new_fee_rate).
            transact({'from': sender}))
        cls.setFeeAuthority = lambda self, sender, new_fee_authority: mine_tx(
            cls.erc20feetoken.functions.setFeeAuthority(new_fee_authority).
            transact({'from': sender}))
        cls.transfer = lambda self, sender, to, value: mine_tx(
            cls.erc20feetoken.functions.transfer(to, value).transact(
                {'from': sender}))
        cls.approve = lambda self, sender, spender, value: mine_tx(
            cls.erc20feetoken.functions.approve(spender, value).transact(
                {'from': sender}))
        cls.transferFrom = lambda self, sender, fromAccount, to, value: mine_tx(
            cls.erc20feetoken.functions.transferFrom(fromAccount, to, value).
            transact({'from': sender}))

        cls.withdrawFee = lambda self, sender, account, value: mine_tx(
            cls.erc20feetoken.functions.withdrawFee(account, value).transact(
                {'from': sender}))
        cls.donateToFeePool = lambda self, sender, value: mine_tx(
            cls.erc20feetoken.functions.donateToFeePool(value).transact(
                {'from': sender}))
Esempio n. 26
0
    def __init__(self, contract, name):
        SafeDecimalMathInterface.__init__(self, contract, name)
        OwnedInterface.__init__(self, contract, name)

        self.contract = contract
        self.contract_name = name

        # Public variables
        self.motionTarget = lambda index: self.contract.functions.motionTarget(index).call()
        self.targetMotionID = lambda address: self.contract.functions.targetMotionID(address).call()
        self.motionStartTime = lambda account: self.contract.functions.motionStartTime(account).call()
        self.votesFor = lambda account: self.contract.functions.votesFor(account).call()
        self.votesAgainst = lambda account: self.contract.functions.votesAgainst(account).call()
        self.vote = lambda account, motionID: self.contract.functions.vote(account, motionID).call()

         # Setters
        self.setMinStandingBalance = lambda sender, balance: mine_tx(
            self.contract.functions.setMinStandingBalance(balance).transact({'from': sender}), "setMinStandingBalance", self.contract_name)
        self.setVotingPeriod = lambda sender, duration: mine_tx(
            self.contract.functions.setVotingPeriod(duration).transact({'from': sender}), "setVotingPeriod", self.contract_name)
        self.setConfirmationPeriod = lambda sender, duration: mine_tx(
            self.contract.functions.setConfirmationPeriod(duration).transact({'from': sender}), "setConfirmationPeriod", self.contract_name)
        self.setRequiredParticipation = lambda sender, fraction: mine_tx(
            self.contract.functions.setRequiredParticipation(fraction).transact({'from': sender}), "setRequiredParticipation", self.contract_name)
        self.setRequiredMajority = lambda sender, fraction: mine_tx(
            self.contract.functions.setRequiredMajority(fraction).transact({'from': sender}), "setRequiredMajority", self.contract_name)

        # Views
        self.hasVoted = lambda sender, motionID: self.contract.functions.hasVoted(sender, motionID).call()
        self.motionVoting = lambda target: self.contract.functions.motionVoting(target).call()
        self.motionConfirming = lambda target: self.contract.functions.motionConfirming(target).call()
        self.motionWaiting = lambda target: self.contract.functions.motionWaiting(target).call()
        self.motionPasses = lambda target: self.contract.functions.motionPasses(target).call()

        # Mutators
        self.beginMotion = lambda sender, target: mine_tx(
            self.contract.functions.beginMotion(target).transact({'from': sender}), "beginMotion", self.contract_name)
        self.voteFor = lambda sender, target: mine_tx(
            self.contract.functions.voteFor(target).transact({'from': sender}), "voteFor", self.contract_name)
        self.voteAgainst = lambda sender, target: mine_tx(
            self.contract.functions.voteAgainst(target).transact({'from': sender}), "voteAgainst", self.contract_name)
        self.cancelVote = lambda sender, target: mine_tx(
            self.contract.functions.cancelVote(target).transact({'from': sender}), "cancelVote", self.contract_name)
        self.closeMotion = lambda sender, target: mine_tx(
            self.contract.functions.closeMotion(target).transact({'from': sender}), "closeMotion", self.contract_name)

        # Owner only
        self.approveMotion = lambda sender, target: mine_tx(
            self.contract.functions.approveMotion(target).transact({'from': sender}), "approveMotion", self.contract_name)
        self.vetoMotion = lambda sender, target: mine_tx(
            self.contract.functions.vetoMotion(target).transact({'from': sender}), "vetoMotion", self.contract_name)
Esempio n. 27
0
    def setUpClass(cls):
        cls.assertReverts = assertReverts
        cls.assertClose = assertClose

        compiled = compile_contracts(
            [ESCROW_SOURCE, HAVVEN_SOURCE, NOMIN_SOURCE])
        cls.havven, txr = attempt_deploy(compiled, 'Havven', MASTER, [MASTER])
        cls.nomin, txr = attempt_deploy(
            compiled, 'EtherNomin', MASTER,
            [cls.havven.address, MASTER, MASTER, 1000 * 10**18, MASTER])
        cls.escrow, txr = attempt_deploy(
            compiled, 'HavvenEscrow', MASTER,
            [MASTER, cls.havven.address, cls.nomin.address])
        mine_tx(
            cls.havven.functions.setNomin(cls.nomin.address).transact(
                {'from': MASTER}))
        mine_tx(
            cls.havven.functions.setEscrow(cls.escrow.address).transact(
                {'from': MASTER}))

        cls.h_totalSupply = lambda self: cls.havven.functions.totalSupply(
        ).call()
        cls.h_targetFeePeriodDurationSeconds = lambda self: cls.havven.functions.targetFeePeriodDurationSeconds(
        ).call()
        cls.h_feePeriodStartTime = lambda self: cls.havven.functions.feePeriodStartTime(
        ).call()
        cls.h_endow = lambda self, sender, receiver, amt: mine_tx(
            cls.havven.functions.endow(receiver, amt).transact(
                {'from': sender}))
        cls.h_balanceOf = lambda self, account: cls.havven.functions.balanceOf(
            account).call()
        cls.h_transfer = lambda self, sender, receiver, amt: mine_tx(
            cls.havven.functions.transfer(receiver, amt).transact(
                {'from': sender}))
        cls.h_recomputeLastAverageBalance = lambda self, sender: mine_tx(
            cls.havven.functions.recomputeLastAverageBalance().transact(
                {'from': sender}))

        cls.n_updatePrice = lambda self, sender, price: mine_tx(
            cls.nomin.functions.updatePrice(price).transact({'from': sender}))
        cls.n_setTransferFeeRate = lambda self, sender, rate: mine_tx(
            cls.nomin.functions.setTransferFeeRate(rate).transact(
                {'from': sender}))
        cls.n_issue = lambda self, sender, quantity, value: mine_tx(
            cls.nomin.functions.issue(quantity).transact({
                'from': sender,
                'value': value
            }))
        cls.n_burn = lambda self, sender, quantity: mine_tx(
            cls.nomin.functions.burn(quantity).transact({'from': sender}))
        cls.n_buy = lambda self, sender, quantity, value: mine_tx(
            cls.nomin.functions.buy(quantity).transact({
                'from': sender,
                'value': value
            }))
        cls.n_sell = lambda self, sender, quantity: mine_tx(
            cls.nomin.functions.sell(quantity).transact({'from': sender}))
        cls.n_purchaseCostEther = lambda self, quantity: cls.nomin.functions.purchaseCostEther(
            quantity).call()
        cls.n_balanceOf = lambda self, account: cls.nomin.functions.balanceOf(
            account).call()
        cls.n_transfer = lambda self, sender, recipient, quantity: mine_tx(
            cls.nomin.functions.transfer(recipient, quantity).transact(
                {'from': sender}))
        cls.n_feePool = lambda self: cls.nomin.functions.feePool().call()
        cls.n_nominPool = lambda self: cls.nomin.functions.nominPool().call()
        cls.n_priceToSpend = lambda self, v: cls.nomin.functions.priceToSpend(
            v).call()

        cls.owner = lambda self: cls.escrow.functions.owner().call()
        cls.setOwner = lambda self, sender, newOwner: mine_tx(
            cls.escrow.functions.setOwner(newOwner).transact({'from': sender}))

        cls.e_havven = lambda self: cls.escrow.functions.havven().call()
        cls.e_nomin = lambda self: cls.escrow.functions.nomin().call()
        cls.vestingSchedules = lambda self, account, index, i: cls.escrow.functions.vestingSchedules(
            account, index, i).call()
        cls.numVestingEntries = lambda self, account: cls.escrow.functions.numVestingEntries(
            account).call()
        cls.getVestingScheduleEntry = lambda self, account, index: cls.escrow.functions.getVestingScheduleEntry(
            account, index).call()
        cls.getVestingTime = lambda self, account, index: cls.escrow.functions.getVestingTime(
            account, index).call()
        cls.getVestingQuantity = lambda self, account, index: cls.escrow.functions.getVestingQuantity(
            account, index).call()
        cls.totalVestedAccountBalance = lambda self, account: cls.escrow.functions.totalVestedAccountBalance(
            account).call()
        cls.totalVestedBalance = lambda self: cls.escrow.functions.totalVestedBalance(
        ).call()
        cls.getNextVestingIndex = lambda self, account: cls.escrow.functions.getNextVestingIndex(
            account).call()
        cls.getNextVestingEntry = lambda self, account: cls.escrow.functions.getNextVestingEntry(
            account).call()
        cls.getNextVestingTime = lambda self, account: cls.escrow.functions.getNextVestingTime(
            account).call()
        cls.getNextVestingQuantity = lambda self, account: cls.escrow.functions.getNextVestingQuantity(
            account).call()

        cls.feePool = lambda self: cls.escrow.functions.feePool().call()
        cls.setHavven = lambda self, sender, account: mine_tx(
            cls.escrow.functions.setHavven(account).transact({'from': sender}))
        cls.setNomin = lambda self, sender, account: mine_tx(
            cls.escrow.functions.setNomin(account).transact({'from': sender}))
        cls.withdrawFees = lambda self, sender: mine_tx(
            cls.escrow.functions.withdrawFees().transact({'from': sender}))
        cls.withdrawFeePool = lambda self, sender: mine_tx(
            cls.escrow.functions.withdrawFeePool().transact({'from': sender}))
        cls.purgeAccount = lambda self, sender, account: mine_tx(
            cls.escrow.functions.purgeAccount(account).transact(
                {'from': sender}))
        cls.withdrawHavvens = lambda self, sender, quantity: mine_tx(
            cls.escrow.functions.withdrawHavvens(quantity).transact(
                {'from': sender}))
        cls.appendVestingEntry = lambda self, sender, account, time, quantity: mine_tx(
            cls.escrow.functions.appendVestingEntry(account, time, quantity).
            transact({'from': sender}))
        cls.addRegularVestingSchedule = lambda self, sender, account, time, quantity, periods: mine_tx(
            cls.escrow.functions.addRegularVestingSchedule(
                account, time, quantity, periods).transact({'from': sender}))
        cls.vest = lambda self, sender: mine_tx(cls.escrow.functions.vest().
                                                transact({'from': sender}))
Esempio n. 28
0
    def setUpClass(cls):
        cls.assertReverts = assertReverts
        cls.assertClose = assertClose

        cls.havven, cls.nomin, cls.havven_proxy, cls.nomin_proxy, cls.havven_real, cls.nomin_real, cls.court, cls.escrow, cls.construction_block, cls.escrow_event_dict = deploy_public_havven(
        )

        cls.initial_time = cls.nomin.functions.lastPriceUpdate().call()

        cls.h_totalSupply = lambda self: cls.havven.functions.totalSupply(
        ).call()
        cls.h_targetFeePeriodDurationSeconds = lambda self: cls.havven.functions.targetFeePeriodDurationSeconds(
        ).call()
        cls.h_feePeriodStartTime = lambda self: cls.havven.functions.feePeriodStartTime(
        ).call()
        cls.h_endow = lambda self, sender, receiver, amt: mine_tx(
            cls.havven.functions.endow(receiver, amt).transact(
                {'from': sender}))
        cls.h_balanceOf = lambda self, account: cls.havven.functions.balanceOf(
            account).call()
        cls.h_transfer = lambda self, sender, receiver, amt: mine_tx(
            cls.havven.functions.transfer(receiver, amt).transact(
                {'from': sender}))
        cls.h_recomputeLastAverageBalance = lambda self, sender: mine_tx(
            cls.havven.functions.recomputeLastAverageBalance().transact(
                {'from': sender}))
        cls.h_withdrawFeeEntitlement = lambda self, sender: mine_tx(
            cls.havven.functions.withdrawFeeEntitlement().transact(
                {'from': sender}))

        cls.n_updatePrice = lambda self, sender, price, timeSent: mine_tx(
            cls.nomin_real.functions.updatePrice(price, timeSent).transact(
                {'from': sender}))
        cls.n_setTransferFeeRate = lambda self, sender, rate: mine_tx(
            cls.nomin.functions.setTransferFeeRate(rate).transact(
                {'from': sender}))
        cls.n_replenishPool = lambda self, sender, quantity, value: mine_tx(
            cls.nomin.functions.replenishPool(quantity).transact({
                'from': sender,
                'value': value
            }))
        cls.n_diminishPool = lambda self, sender, quantity: mine_tx(
            cls.nomin.functions.diminishPool(quantity).transact(
                {'from': sender}))
        cls.n_buy = lambda self, sender, quantity, value: mine_tx(
            cls.nomin.functions.buy(quantity).transact({
                'from': sender,
                'value': value
            }))
        cls.n_sell = lambda self, sender, quantity: mine_tx(
            cls.nomin.functions.sell(quantity).transact({'from': sender}))
        cls.n_purchaseCostEther = lambda self, quantity: cls.nomin.functions.purchaseCostEther(
            quantity).call()
        cls.n_balanceOf = lambda self, account: cls.nomin.functions.balanceOf(
            account).call()
        cls.n_transfer = lambda self, sender, recipient, quantity: mine_tx(
            cls.nomin.functions.transfer(recipient, quantity).transact(
                {'from': sender}))
        cls.n_feePool = lambda self: cls.nomin.functions.feePool().call()
        cls.n_nominPool = lambda self: cls.nomin.functions.nominPool().call()
        cls.n_priceToSpend = lambda self, v: cls.nomin.functions.priceToSpend(
            v).call()

        cls.owner = lambda self: cls.escrow.functions.owner().call()
        cls.nominateOwner = lambda self, sender, newOwner: mine_tx(
            cls.escrow.functions.nominateOwner(newOwner).transact(
                {'from': sender}))
        cls.acceptOwnership = lambda self, sender: mine_tx(
            cls.escrow.functions.acceptOwnership().transact({'from': sender}))

        cls.e_havven = lambda self: cls.escrow.functions.havven().call()
        cls.vestingSchedules = lambda self, account, index, i: cls.escrow.functions.vestingSchedules(
            account, index, i).call()
        cls.numVestingEntries = lambda self, account: cls.escrow.functions.numVestingEntries(
            account).call()
        cls.getVestingScheduleEntry = lambda self, account, index: cls.escrow.functions.getVestingScheduleEntry(
            account, index).call()
        cls.getVestingTime = lambda self, account, index: cls.escrow.functions.getVestingTime(
            account, index).call()
        cls.getVestingQuantity = lambda self, account, index: cls.escrow.functions.getVestingQuantity(
            account, index).call()
        cls.totalVestedAccountBalance = lambda self, account: cls.escrow.functions.totalVestedAccountBalance(
            account).call()
        cls.totalVestedBalance = lambda self: cls.escrow.functions.totalVestedBalance(
        ).call()
        cls.getNextVestingIndex = lambda self, account: cls.escrow.functions.getNextVestingIndex(
            account).call()
        cls.getNextVestingEntry = lambda self, account: cls.escrow.functions.getNextVestingEntry(
            account).call()
        cls.getNextVestingTime = lambda self, account: cls.escrow.functions.getNextVestingTime(
            account).call()
        cls.getNextVestingQuantity = lambda self, account: cls.escrow.functions.getNextVestingQuantity(
            account).call()

        cls.setHavven = lambda self, sender, account: mine_tx(
            cls.escrow.functions.setHavven(account).transact({'from': sender}))
        cls.purgeAccount = lambda self, sender, account: mine_tx(
            cls.escrow.functions.purgeAccount(account).transact(
                {'from': sender}))
        cls.withdrawHavvens = lambda self, sender, quantity: mine_tx(
            cls.escrow.functions.withdrawHavvens(quantity).transact(
                {'from': sender}))
        cls.appendVestingEntry = lambda self, sender, account, time, quantity: mine_tx(
            cls.escrow.functions.appendVestingEntry(account, time, quantity).
            transact({'from': sender}))
        cls.addRegularVestingSchedule = lambda self, sender, account, time, quantity, periods: mine_tx(
            cls.escrow.functions.addRegularVestingSchedule(
                account, time, quantity, periods).transact({'from': sender}))
        cls.vest = lambda self, sender: mine_tx(cls.escrow.functions.vest().
                                                transact({'from': sender}))
    def __init__(self, contract, name):
        self.contract = contract
        self.contract_name = name

        self.priceStalePeriod = lambda: self.contract.functions.priceStalePeriod(
        ).call()
        self.fundsWallet = lambda: self.contract.functions.fundsWallet().call()
        self.havven = lambda: self.contract.functions.havven().call()
        self.nomin = lambda: self.contract.functions.nomin().call()
        self.oracle = lambda: self.contract.functions.oracle().call()
        self.owner = lambda: self.contract.functions.owner().call()
        self.usdToEthPrice = lambda: self.contract.functions.usdToEthPrice(
        ).call()
        self.usdToHavPrice = lambda: self.contract.functions.usdToHavPrice(
        ).call()
        self.lastPriceUpdateTime = lambda: self.contract.functions.lastPriceUpdateTime(
        ).call()
        self.selfDestructDelay = lambda: self.contract.functions.selfDestructDelay(
        ).call()
        self.selfDestructBeneficiary = lambda: self.contract.functions.selfDestructBeneficiary(
        ).call()
        self.priceStalePeriod = lambda: self.contract.functions.priceStalePeriod(
        ).call()
        self.havvensReceivedForNomins = lambda amount: self.contract.functions.havvensReceivedForNomins(
            amount).call()
        self.nominsReceivedForEther = lambda amount: self.contract.functions.nominsReceivedForEther(
            amount).call()

        self.setOracle = lambda sender, newAddress: mine_tx(
            self.contract.functions.setOracle(newAddress).transact(
                {'from': sender}), "setOracle", self.contract_name)
        self.setHavven = lambda sender, newAddress: mine_tx(
            self.contract.functions.setHavven(newAddress).transact(
                {'from': sender}), "setHavven", self.contract_name)
        self.setNomin = lambda sender, newAddress: mine_tx(
            self.contract.functions.setNomin(newAddress).transact(
                {'from': sender}), "setNomin", self.contract_name)
        self.setFundsWallet = lambda sender, newAddress: mine_tx(
            self.contract.functions.setFundsWallet(newAddress).transact(
                {'from': sender}), "setFundsWallet", self.contract_name)
        self.setPriceStalePeriod = lambda sender, newPriceStalePeriod: mine_tx(
            self.contract.functions.setPriceStalePeriod(
                newPriceStalePeriod).transact({'from': sender}),
            "setPriceStalePeriod", self.contract_name)
        self.updatePrices = lambda sender, newEthPrice, newHavPrice, timeSent: mine_tx(
            self.contract.functions.updatePrices(
                newEthPrice, newHavPrice, timeSent).transact({'from': sender}),
            "updatePrices", self.contract_name)
        self.exchangeEtherForNomins = lambda sender, value: mine_tx(
            self.contract.functions.exchangeEtherForNomins().transact(
                {
                    'from': sender,
                    'value': value
                }), "exchangeEtherForNomins", self.contract_name)
        self.exchangeNominsForHavvens = lambda sender, value: mine_tx(
            self.contract.functions.exchangeNominsForHavvens(value).transact(
                {'from': sender}), "exchangeNominsForHavvens", self.
            contract_name)
        self.withdrawHavvens = lambda sender, value: mine_tx(
            self.contract.functions.withdrawHavvens(value).transact(
                {'from': sender}), "withdrawHavvens", self.contract_name)
        self.withdrawNomins = lambda sender, value: mine_tx(
            self.contract.functions.withdrawNomins(value).transact(
                {'from': sender}), "withdrawNomins", self.contract_name)
        # TODO: Add inherited interface here instead
        self.setPaused = lambda sender, paused: mine_tx(
            self.contract.functions.setPaused(paused).transact(
                {'from': sender}), "setPaused", self.contract_name)
Esempio n. 30
0
 def feetoken_withdrawFees(self, sender, beneficiary, quantity):
     return mine_tx(
         self.feetoken_contract.functions.withdrawFees(
             beneficiary, quantity).transact({'from': sender}),
         "withdrawFees", self.feetoken.contract_name)