def deploy_contracts(cls): sources = [ 'tests/contracts/PublicEST.sol', 'contracts/ExternStateToken.sol', 'contracts/TokenState.sol', 'contracts/Proxy.sol', 'tests/contracts/TokenRecipient.sol', 'tests/contracts/EmptyTokenRecipient.sol', 'tests/contracts/ReEntrantTokenRecipient.sol' ] compiled, cls.event_maps = cls.compileAndMapEvents(sources) proxy_contract, _ = attempt_deploy(compiled, "Proxy", MASTER, [MASTER]) tokenstate, _ = attempt_deploy(compiled, 'TokenState', MASTER, [MASTER, MASTER]) token_contract, construction_txr = attempt_deploy( compiled, 'PublicEST', MASTER, [ proxy_contract.address, tokenstate.address, "Test Token", "TEST", 1000 * UNIT, MASTER ]) token_recipient_contract, _ = attempt_deploy(compiled, 'TokenRecipient', MASTER, []) token_recipient_abi = compiled['TokenRecipient']['abi'] token_recipient = W3.eth.contract( address=token_recipient_contract.address, abi=token_recipient_abi) token_recipient_event_dict = generate_topic_event_map( token_recipient_abi) empty_token_recipient, _ = attempt_deploy(compiled, 'EmptyTokenRecipient', MASTER, []) re_entrant_token_recipient, _ = attempt_deploy( compiled, 'ReEntrantTokenRecipient', MASTER, []) token_abi = compiled['PublicEST']['abi'] token_event_dict = generate_topic_event_map(token_abi) proxied_token = W3.eth.contract(address=proxy_contract.address, abi=token_abi) mine_txs([ tokenstate.functions.setBalanceOf(MASTER, 1000 * UNIT).transact( {'from': MASTER}), tokenstate.functions.setAssociatedContract( token_contract.address).transact({'from': MASTER}), proxy_contract.functions.setTarget( token_contract.address).transact({'from': MASTER}) ]) return proxy_contract, proxied_token, compiled, token_contract, token_abi, token_event_dict, tokenstate, token_recipient, token_recipient_event_dict, empty_token_recipient, re_entrant_token_recipient
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, [MASTER]) hvn_block = W3.eth.blockNumber nomin_contract, nom_txr = attempt_deploy( compiled, 'EtherNomin', MASTER, [havven_contract.address, MASTER, MASTER, 1000 * UNIT, MASTER]) court_contract, court_txr = attempt_deploy( compiled, 'Court', MASTER, [havven_contract.address, nomin_contract.address, MASTER]) escrow_contract, escrow_txr = attempt_deploy( compiled, 'HavvenEscrow', MASTER, [MASTER, havven_contract.address, nomin_contract.address]) # Hook up each of those contracts to each other txs = [ havven_contract.functions.setNomin(nomin_contract.address).transact( {'from': MASTER}), nomin_contract.functions.setCourt(court_contract.address).transact( {'from': MASTER}) ] attempt(mine_txs, [txs], "Linking contracts... ") havven_event_dict = generate_topic_event_map( compiled['PublicHavven']['abi']) print("\nDeployment complete.\n") return havven_contract, nomin_contract, court_contract, escrow_contract, hvn_block, havven_event_dict
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}))
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}))
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
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.nominatedOwner = lambda self: cls.owned.functions.nominatedOwner().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})) cls.owned_event_map = generate_topic_event_map(compiled['Owned']['abi'])
def deployContracts(): sources = [ "tests/contracts/PublicFeeToken.sol", "contracts/FeeToken.sol", "contracts/TokenState.sol" ] compiled = compile_contracts(sources, remappings=['""=contracts']) feetoken_abi = compiled['PublicFeeToken']['abi'] proxy, _ = attempt_deploy(compiled, "Proxy", MASTER, [MASTER]) proxied_feetoken = W3.eth.contract(address=proxy.address, abi=feetoken_abi) feetoken_event_dict = generate_topic_event_map(feetoken_abi) feestate, txr = attempt_deploy(compiled, "TokenState", MASTER, [MASTER, MASTER]) feetoken_contract_1, construction_txr_1 = attempt_deploy( compiled, "PublicFeeToken", MASTER, [ proxy.address, feestate.address, "Test Fee Token", "FEE", 1000 * UNIT, UNIT // 20, MASTER, MASTER ]) feetoken_contract_2, construction_txr_2 = attempt_deploy( compiled, "PublicFeeToken", MASTER, [ proxy.address, feestate.address, "Test Fee Token 2", "FEE", 1000 * UNIT, UNIT // 20, MASTER, MASTER ]) mine_txs([ proxy.functions.setTarget(feetoken_contract_1.address).transact( {'from': MASTER}), feestate.functions.setBalanceOf(DUMMY, 1000 * UNIT).transact( {'from': MASTER}), feestate.functions.setAssociatedContract( feetoken_contract_1.address).transact({'from': MASTER}), feetoken_contract_1.functions.setTokenState( feestate.address).transact({'from': MASTER}) ]) return compiled, proxy, proxied_feetoken, feetoken_contract_1, feetoken_contract_2, feetoken_event_dict, feestate
def deployContracts(cls): print("Deployment initiated.\n") sources = [ "tests/contracts/PublicHavven.sol", "contracts/Nomin.sol", "contracts/HavvenEscrow.sol" ] compiled, cls.event_maps = cls.compileAndMapEvents(sources) # Deploy contracts havven_proxy, _ = attempt_deploy(compiled, 'Proxy', MASTER, [MASTER]) nomin_proxy, _ = attempt_deploy(compiled, 'Proxy', MASTER, [MASTER]) proxied_havven = W3.eth.contract(address=havven_proxy.address, abi=compiled['PublicHavven']['abi']) proxied_nomin = W3.eth.contract(address=nomin_proxy.address, abi=compiled['Nomin']['abi']) havven_tokenstate, _ = attempt_deploy(compiled, 'TokenState', MASTER, [MASTER, MASTER]) nomin_tokenstate, _ = attempt_deploy(compiled, 'TokenState', MASTER, [MASTER, MASTER]) havven_contract, hvn_txr = attempt_deploy( compiled, 'PublicHavven', MASTER, [ havven_proxy.address, havven_tokenstate.address, MASTER, MASTER, cls.initial_price, [], ZERO_ADDRESS ]) hvn_block = W3.eth.blockNumber nomin_contract, nom_txr = attempt_deploy(compiled, 'Nomin', MASTER, [ nomin_proxy.address, nomin_tokenstate.address, havven_contract.address, 0, MASTER ]) escrow_contract, escrow_txr = attempt_deploy( compiled, 'HavvenEscrow', MASTER, [MASTER, havven_contract.address]) # Hook up each of those contracts to each other mine_txs([ havven_tokenstate.functions.setBalanceOf( havven_contract.address, 100000000 * UNIT).transact({'from': MASTER}), havven_tokenstate.functions.setAssociatedContract( havven_contract.address).transact({'from': MASTER}), nomin_tokenstate.functions.setAssociatedContract( nomin_contract.address).transact({'from': MASTER}), havven_proxy.functions.setTarget(havven_contract.address).transact( {'from': MASTER}), nomin_proxy.functions.setTarget(nomin_contract.address).transact( {'from': MASTER}), havven_contract.functions.setNomin( nomin_contract.address).transact({'from': MASTER}), nomin_contract.functions.setHavven( havven_contract.address).transact({'from': MASTER}), havven_contract.functions.setEscrow( escrow_contract.address).transact({'from': MASTER}) ]) havven_event_dict = generate_topic_event_map( compiled['PublicHavven']['abi']) print("\nDeployment complete.\n") return havven_proxy, proxied_havven, nomin_proxy, proxied_nomin, havven_contract, nomin_contract, escrow_contract, hvn_block, havven_event_dict
def test_constructor_migration(self): # Ensure issuers list updates issued balances properly... update deploycontracts above. sources = [ "tests/contracts/PublicHavven.sol", "contracts/Nomin.sol", "contracts/HavvenEscrow.sol" ] print() compiled, event_maps = self.compileAndMapEvents(sources) # Initial issued nomin balances #issuer_addresses = [f"0x{'0'*39}{i+1}" for i in range(10)] issuers_all = fresh_accounts(54) issuers = issuers_all[:2] issuer_balances = [77 * UNIT * i for i in range(10)] total_nomins = sum(issuer_balances) # Deploy contracts havven_proxy, _ = attempt_deploy(compiled, 'Proxy', MASTER, [MASTER]) nomin_proxy, _ = attempt_deploy(compiled, 'Proxy', MASTER, [MASTER]) proxied_havven = W3.eth.contract(address=havven_proxy.address, abi=compiled['PublicHavven']['abi']) proxied_nomin = W3.eth.contract(address=nomin_proxy.address, abi=compiled['Nomin']['abi']) havven_tokenstate, _ = attempt_deploy(compiled, 'TokenState', MASTER, [MASTER, MASTER]) nomin_tokenstate, _ = attempt_deploy(compiled, 'TokenState', MASTER, [MASTER, MASTER]) havven_contract, hvn_txr = attempt_deploy( compiled, 'PublicHavven', MASTER, [ havven_proxy.address, havven_tokenstate.address, MASTER, MASTER, UNIT, [], ZERO_ADDRESS ]) hvn_block = W3.eth.blockNumber nomin_contract, nom_txr = attempt_deploy(compiled, 'Nomin', MASTER, [ nomin_proxy.address, nomin_tokenstate.address, havven_contract.address, 0, MASTER ]) escrow_contract, escrow_txr = attempt_deploy( compiled, 'HavvenEscrow', MASTER, [MASTER, havven_contract.address]) mine_txs([ havven_tokenstate.functions.setBalanceOf( havven_contract.address, 100000000 * UNIT).transact({'from': MASTER}), havven_tokenstate.functions.setAssociatedContract( havven_contract.address).transact({'from': MASTER}), nomin_tokenstate.functions.setAssociatedContract( nomin_contract.address).transact({'from': MASTER}), havven_proxy.functions.setTarget(havven_contract.address).transact( {'from': MASTER}), nomin_proxy.functions.setTarget(nomin_contract.address).transact( {'from': MASTER}), havven_contract.functions.setNomin( nomin_contract.address).transact({'from': MASTER}), nomin_contract.functions.setHavven( havven_contract.address).transact({'from': MASTER}), havven_contract.functions.setEscrow( escrow_contract.address).transact({'from': MASTER}) ]) havven_event_dict = generate_topic_event_map( compiled['PublicHavven']['abi']) havven = PublicHavvenInterface(proxied_havven, "Havven") nomin = PublicNominInterface(proxied_nomin, "Nomin") for i in range(len(issuers)): issuer = issuers[i] havven.endow(MASTER, issuer, 1000 * UNIT) havven.setIssuer(MASTER, issuer, True) mine_txs([ havven_contract.functions.updatePrice( UNIT, block_time() + 1).transact({'from': MASTER}) ]) havven.issueNomins(issuer, i * 10 * UNIT) fast_forward(havven.feePeriodDuration() // 20) for i in range(len(issuers)): issuer = issuers[i] havven.endow(MASTER, issuer, 1000 * UNIT) havven.setIssuer(MASTER, issuer, True) mine_txs([ havven_contract.functions.updatePrice( UNIT, block_time() + 1).transact({'from': MASTER}) ]) havven.issueNomins(issuer, (len(issuers) - 1 - i) * 5 * UNIT) fast_forward(havven.feePeriodDuration() // 15) new_havven_contract, txr = attempt_deploy( compiled, 'PublicHavven', MASTER, [ havven_proxy.address, havven_tokenstate.address, MASTER, MASTER, UNIT, issuers_all, havven_contract.address ]) new_havven = PublicHavvenInterface(new_havven_contract, "Havven") self.assertEqual(havven.totalIssuanceData(), new_havven.totalIssuanceData()) self.assertEqual(havven.feePeriodStartTime(), new_havven.feePeriodStartTime()) self.assertEqual(havven.lastFeePeriodStartTime(), new_havven.lastFeePeriodStartTime()) for issuer in issuers: self.assertEqual(havven.isIssuer(issuer), new_havven.isIssuer(issuer)) self.assertEqual(havven.issuanceData(issuer), new_havven.issuanceData(issuer)) self.assertEqual(havven.nominsIssued(issuer), new_havven.nominsIssued(issuer))
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}))
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}))
def setUpClass(cls): cls.assertReverts = assertReverts cls.havven, cls.nomin, cls.court, cls.court_abi = deploy_public_court() # Event stuff cls.court_event_dict = generate_topic_event_map(cls.court_abi) # Inherited cls.owner = lambda self: self.court.functions.owner().call() # Non-public variables cls.getHavven = lambda self: self.court.functions._havven().call() cls.getNomin = lambda self: self.court.functions._nomin().call() cls.minStandingBalance = lambda self: self.court.functions.minStandingBalance( ).call() cls.votingPeriod = lambda self: self.court.functions.votingPeriod( ).call() cls.minVotingPeriod = lambda self: self.court.functions._minVotingPeriod( ).call() cls.maxVotingPeriod = lambda self: self.court.functions._maxVotingPeriod( ).call() cls.confirmationPeriod = lambda self: self.court.functions.confirmationPeriod( ).call() cls.minConfirmationPeriod = lambda self: self.court.functions._minConfirmationPeriod( ).call() cls.maxConfirmationPeriod = lambda self: self.court.functions._maxConfirmationPeriod( ).call() cls.requiredParticipation = lambda self: self.court.functions.requiredParticipation( ).call() cls.minRequiredParticipation = lambda self: self.court.functions._minRequiredParticipation( ).call() cls.requiredMajority = lambda self: self.court.functions.requiredMajority( ).call() cls.minRequiredMajority = lambda self: self.court.functions._minRequiredMajority( ).call() cls.voteWeight = lambda self: self.court.functions.voteWeight().call() # Public variables cls.voteStartTimes = lambda self, account: self.court.functions.voteStartTimes( account).call() cls.votesFor = lambda self, account: self.court.functions.votesFor( account).call() cls.votesAgainst = lambda self, account: self.court.functions.votesAgainst( account).call() cls.userVote = lambda self, account: self.court.functions.userVote( account).call() cls.voteTarget = lambda self, account: self.court.functions.voteTarget( account).call() # Inherited setter cls.setOwner = lambda self, sender, address: mine_tx( self.court.functions.setOwner(address).transact({'from': sender})) # Setters cls.setMinStandingBalance = lambda self, sender, balance: mine_tx( self.court.functions.setMinStandingBalance(balance).transact( {'from': sender})) cls.setVotingPeriod = lambda self, sender, duration: mine_tx( self.court.functions.setVotingPeriod(duration).transact( {'from': sender})) cls.setConfirmationPeriod = lambda self, sender, duration: mine_tx( self.court.functions.setConfirmationPeriod(duration).transact( {'from': sender})) cls.setRequiredParticipation = lambda self, sender, fraction: mine_tx( self.court.functions.setRequiredParticipation(fraction).transact( {'from': sender})) cls.setRequiredMajority = lambda self, sender, fraction: mine_tx( self.court.functions.setRequiredMajority(fraction).transact( {'from': sender})) # Views cls.hasVoted = lambda self, sender: self.court.functions.hasVoted( sender).call() cls.voting = lambda self, target: self.court.functions.voting(target ).call() cls.confirming = lambda self, target: self.court.functions.confirming( target).call() cls.waiting = lambda self, target: self.court.functions.waiting( target).call() cls.votePasses = lambda self, target: self.court.functions.votePasses( target).call() # Mutators cls.beginConfiscationMotion = lambda self, sender, target: mine_tx( self.court.functions.beginConfiscationMotion(target).transact( {'from': sender})) cls.voteFor = lambda self, sender, target: mine_tx( self.court.functions.voteFor(target).transact({'from': sender})) cls.voteAgainst = lambda self, sender, target: mine_tx( self.court.functions.voteAgainst(target).transact({'from': sender}) ) cls.cancelVote = lambda self, sender, target: mine_tx( self.court.functions.cancelVote(target).transact({'from': sender})) cls.closeVote = lambda self, sender, target: mine_tx( self.court.functions.closeVote(target).transact({'from': sender})) # Owner only cls.approve = lambda self, sender, target: mine_tx( self.court.functions.approve(target).transact({'from': sender})) cls.veto = lambda self, sender, target: mine_tx( self.court.functions.veto(target).transact({'from': sender})) # Internal cls.setVotedYea = lambda self, sender, account, target: self.court.functions.publicSetVotedYea( account, target).transact({'from': sender}) cls.setVotedNay = lambda self, sender, account, target: self.court.functions.publicSetVotedNay( account, target).transact({'from': sender}) # Havven getters cls.havvenSupply = lambda self: self.havven.functions.totalSupply( ).call() cls.havvenBalance = lambda self, account: self.havven.functions.balanceOf( account).call() cls.havvenHasVoted = lambda self, account: self.havven.functions.hasVoted( account).call() cls.havvenTargetFeePeriodDurationSeconds = lambda self: self.havven.functions.targetFeePeriodDurationSeconds( ).call() cls.havvenPenultimateAverageBalance = lambda self, addr: self.havven.functions.penultimateAverageBalance( addr).call() cls.havvenLastAverageBalance = lambda self, addr: self.havven.functions.lastAverageBalance( addr).call() # Havven mutators cls.havvenEndow = lambda self, sender, account, value: mine_tx( self.havven.functions.endow(account, value).transact( {'from': sender})) cls.havvenTransfer = lambda self, sender, to, value: mine_tx( self.havven.functions.transfer(to, value).transact( {'from': sender})) cls.havvenCheckFeePeriodRollover = lambda self, sender: mine_tx( self.havven.functions._checkFeePeriodRollover().transact( {'from': sender})) cls.havvenAdjustFeeEntitlement = lambda self, sender, acc, p_bal: mine_tx( self.havven.functions._adjustFeeEntitlement(acc, p_bal).transact( {'from': sender})) cls.havvenSetTargetFeePeriodDuration = lambda self, sender, duration: mine_tx( self.havven.functions.setTargetFeePeriodDuration(duration). transact({'from': sender})) # Nomin getter cls.nominIsFrozen = lambda self, account: self.nomin.functions.isFrozen( account).call() # Solidity convenience cls.days = 86400 cls.weeks = 604800 cls.months = 2628000