def build_default_from_config(cls, keyfile=None, pw_file=None, privkey_seed=None, cs_address=None, cs_fee_rate=0.01, base_token_addr=None, quote_token_addr=None, message_broker_host='127.0.0.1', message_broker_port=5000, trader_host='127.0.0.1', trader_port=5001, offer_lifetime=None): if keyfile is not None and pw_file is not None: pw = pw_file.read() pw = pw.splitlines()[0] acc = Account.load(file=keyfile, password=pw) signer = Signer.from_account(acc) elif privkey_seed is None: signer = Signer.random() else: signer = Signer.from_seed(privkey_seed) token_pair = TokenPair(base_token=binary_address(base_token_addr), base_decimal=3, quote_token=binary_address(quote_token_addr), quote_decimal=18) trader_client = TraderClient(signer.checksum_address, host=trader_host, port=trader_port, market=token_pair) message_broker = MessageBrokerClient(host=message_broker_host, port=message_broker_port, address=signer.checksum_address) transport = Transport(message_broker, signer) commitment_service_client = CommitmentServiceClient( signer, token_pair, message_broker, cs_address, fee_rate=cs_fee_rate) raidex_node = RaidexNode(signer.address, token_pair, message_broker, trader_client) # if mock_trading_activity is True: # raise NotImplementedError('Trading Mocking disabled a the moment') if offer_lifetime is not None: raidex_node.default_offer_lifetime = offer_lifetime app = App(trader_client, commitment_service_client, transport, token_pair, raidex_node) return app
def __init__(self, signer, market, message_broker, commitment_service_address, fee_rate): super(CommitmentServiceClient, self).__init__(CommitmentServiceEvent) self.node_address = signer.checksum_address self.commitment_service_address = binary_address( commitment_service_address) self.fee_rate = fee_rate self.message_broker = message_broker self.commitment_amount = 1 self.market = market CommitmentProofTask( CommitmentProofListener(self.message_broker, topic=self.node_address)).start()
def encode(event, type_): if type_ == 'EventPaymentReceivedSuccess': return PaymentReceivedEvent(binary_address(event['initiator']), event['amount'], event['identifier']) # raise Exception('encoding error: unknown-event-type') return None
def __init__(self, initiator, amount, identifier, received_timestamp): self.initiator = binary_address(initiator) self.amount = amount self.identifier = identifier self.timestamp = received_timestamp