def deploy_service_contracts( self, token_address: HexAddress, user_deposit_whole_balance_limit: int, service_registry_controller: HexAddress, initial_service_deposit_price: int, service_deposit_bump_numerator: int, service_deposit_bump_denominator: int, decay_constant: int, min_price: int, registration_duration: int, token_network_registry_address: HexAddress, ) -> DeployedContracts: """Deploy 3rd party service contracts""" if not contracts_version_has_initial_service_deposit( self.contract_manager.contracts_version): raise RuntimeError( "Deployment of older service contracts is not suppported.") chain_id = int(self.web3.version.network) deployed_contracts: DeployedContracts = { "contracts_version": self.contract_manager.contracts_version, "chain_id": chain_id, "contracts": {}, } service_registry = self._deploy_and_remember( CONTRACT_SERVICE_REGISTRY, [ token_address, service_registry_controller, initial_service_deposit_price, service_deposit_bump_numerator, service_deposit_bump_denominator, decay_constant, min_price, registration_duration, ], deployed_contracts, ) user_deposit = self._deploy_and_remember( contract_name=CONTRACT_USER_DEPOSIT, arguments=[token_address, user_deposit_whole_balance_limit], deployed_contracts=deployed_contracts, ) monitoring_service_constructor_args = [ token_address, deployed_contracts["contracts"][CONTRACT_SERVICE_REGISTRY] ["address"], deployed_contracts["contracts"][CONTRACT_USER_DEPOSIT]["address"], token_network_registry_address, ] msc = self._deploy_and_remember( contract_name=CONTRACT_MONITORING_SERVICE, arguments=monitoring_service_constructor_args, deployed_contracts=deployed_contracts, ) one_to_n = self._deploy_and_remember( contract_name=CONTRACT_ONE_TO_N, arguments=[ user_deposit.address, chain_id, service_registry.address ], deployed_contracts=deployed_contracts, ) # Tell the UserDeposit instance about other contracts. LOG.debug("Calling UserDeposit.init() with " f"msc_address={msc.address} " f"one_to_n_address={one_to_n.address}") self.transact( user_deposit.functions.init(_msc_address=msc.address, _one_to_n_address=one_to_n.address)) return deployed_contracts
def test_contracts_version_has_initial_service_deposit() -> None: assert contracts_version_has_initial_service_deposit(ALDERAAN_VERSION) assert contracts_version_has_initial_service_deposit(None) with pytest.raises(ValueError): contracts_version_has_initial_service_deposit("not a semver string")