def ms_database() -> Database: return Database( filename=":memory:", chain_id=ChainID(61), msc_address=TEST_MSC_ADDRESS, registry_address=Address(bytes([3] * 20)), receiver=Address(bytes([4] * 20)), )
def ms_database(): return Database( filename=':memory:', chain_id=1, msc_address='0x' + '2' * 40, registry_address='0x' + '3' * 40, receiver='0x' + '4' * 40, )
def ms_database(): return Database( filename=":memory:", chain_id=ChainID(1), msc_address=Address(bytes([2] * 20)), registry_address=Address(bytes([3] * 20)), receiver=Address(bytes([4] * 20)), )
def ms_database(): return Database( filename=":memory:", chain_id=1, msc_address=Address("0x" + "2" * 40), registry_address=Address("0x" + "3" * 40), receiver=Address("0x" + "4" * 40), )
def __init__( # pylint: disable=too-many-arguments self, web3: Web3, private_key: PrivateKey, db_filename: str, contracts: Dict[str, Contract], sync_start_block: BlockNumber, required_confirmations: BlockTimeout, poll_interval: float, min_reward: int = 0, get_timestamp_now: Callable = get_posix_utc_time_now, ): self.web3 = web3 self.chain_id = ChainID(web3.eth.chain_id) self.private_key = private_key self.address = private_key_to_address(private_key) self.poll_interval = poll_interval self.service_registry = contracts[CONTRACT_SERVICE_REGISTRY] self.token_network_registry = contracts[ CONTRACT_TOKEN_NETWORK_REGISTRY] self.get_timestamp_now = get_timestamp_now self.try_scheduled_events_after = get_timestamp_now() web3.middleware_onion.add( construct_sign_and_send_raw_middleware(private_key)) monitoring_contract = contracts[CONTRACT_MONITORING_SERVICE] user_deposit_contract = contracts[CONTRACT_USER_DEPOSIT] self.database = Database( filename=db_filename, chain_id=self.chain_id, registry_address=to_canonical_address( self.token_network_registry.address), receiver=self.address, msc_address=MonitoringServiceAddress( to_canonical_address(monitoring_contract.address)), sync_start_block=sync_start_block, ) ms_state = self.database.load_state() self.context = Context( ms_state=ms_state, database=self.database, web3=self.web3, monitoring_service_contract=monitoring_contract, user_deposit_contract=user_deposit_contract, min_reward=min_reward, required_confirmations=required_confirmations, )
def __init__( # pylint: disable=too-many-arguments self, web3: Web3, private_key: str, db_filename: str, contracts: Dict[str, Contract], sync_start_block: BlockNumber = BlockNumber(0), required_confirmations: int = DEFAULT_NUMBER_OF_BLOCK_CONFIRMATIONS, poll_interval: float = 1, min_reward: int = 0, ): self.web3 = web3 self.private_key = private_key self.address = private_key_to_address(private_key) self.required_confirmations = required_confirmations self.poll_interval = poll_interval self.service_registry = contracts[CONTRACT_SERVICE_REGISTRY] web3.middleware_stack.add( construct_sign_and_send_raw_middleware(private_key)) monitoring_contract = contracts[CONTRACT_MONITORING_SERVICE] user_deposit_contract = contracts[CONTRACT_USER_DEPOSIT] chain_id = ChainID(int(web3.net.version)) self.database = Database( filename=db_filename, chain_id=chain_id, registry_address=contracts[CONTRACT_TOKEN_NETWORK_REGISTRY]. address, receiver=self.address, msc_address=monitoring_contract.address, sync_start_block=sync_start_block, ) ms_state = self.database.load_state() self.context = Context( ms_state=ms_state, db=self.database, web3=self.web3, monitoring_service_contract=monitoring_contract, user_deposit_contract=user_deposit_contract, min_reward=min_reward, required_confirmations=required_confirmations, )
def __init__( self, web3: Web3, private_key: str, db_filename: str, contracts: Dict[str, Contract], sync_start_block: BlockNumber = BlockNumber(0), required_confirmations: int = DEFAULT_REQUIRED_CONFIRMATIONS, poll_interval: float = 1, min_reward: int = 0, ): self.web3 = web3 self.private_key = private_key self.address = private_key_to_address(private_key) self.required_confirmations = required_confirmations self.poll_interval = poll_interval self.last_gas_check_block = 0 web3.middleware_stack.add(construct_sign_and_send_raw_middleware(private_key)) monitoring_contract = contracts[CONTRACT_MONITORING_SERVICE] user_deposit_contract = contracts[CONTRACT_USER_DEPOSIT] chain_id = int(web3.net.version) self.database = Database( filename=db_filename, chain_id=chain_id, registry_address=contracts[CONTRACT_TOKEN_NETWORK_REGISTRY].address, receiver=self.address, msc_address=monitoring_contract.address, sync_start_block=sync_start_block, ) ms_state = self.database.load_state() self.context = Context( ms_state=ms_state, db=self.database, w3=self.web3, contract_manager=CONTRACT_MANAGER, last_known_block=0, monitoring_service_contract=monitoring_contract, user_deposit_contract=user_deposit_contract, min_reward=min_reward, )
def __init__( self, web3: Web3, contract_manager: ContractManager, private_key: str, registry_address: Address, monitor_contract_address: Address, user_deposit_contract_address: Address, db_filename: str, sync_start_block: BlockNumber = 0, required_confirmations: int = DEFAULT_REQUIRED_CONFIRMATIONS, poll_interval: float = 1, min_reward: int = 0, ): self.web3 = web3 self.contract_manager = contract_manager self.private_key = private_key self.address = private_key_to_address(private_key) self.required_confirmations = required_confirmations self.poll_interval = poll_interval self.last_gas_check_block = 0 web3.middleware_stack.add( construct_sign_and_send_raw_middleware(private_key), ) monitoring_contract = self.web3.eth.contract( abi=self.contract_manager.get_contract_abi( CONTRACT_MONITORING_SERVICE, ), address=monitor_contract_address, ) user_deposit_contract = self.web3.eth.contract( abi=self.contract_manager.get_contract_abi( CONTRACT_USER_DEPOSIT, ), address=user_deposit_contract_address, ) chain_id = int(web3.net.version) self.database = Database( filename=db_filename, chain_id=chain_id, registry_address=registry_address, receiver=self.address, msc_address=monitor_contract_address, ) ms_state = self.database.load_state() self.bcl = BlockchainListener( web3=self.web3, contract_manager=contract_manager, ) self.context = Context( ms_state=ms_state, db=self.database, w3=self.web3, contract_manager=contract_manager, last_known_block=0, monitoring_service_contract=monitoring_contract, user_deposit_contract=user_deposit_contract, min_reward=min_reward, )