Example #1
0
def handle_tokennetwork_new(raiden, event):
    data = event.event_data
    manager_address = data['channel_manager_address']

    registry = raiden.default_registry
    manager_proxy = registry.manager(manager_address)
    netting_channel_proxies = get_channel_proxies(raiden.chain, raiden.address,
                                                  manager_proxy)

    # Install the filters first to avoid missing changes, as a consequence
    # some events might be applied twice.
    raiden.blockchain_events.add_channel_manager_listener(manager_proxy)
    for channel_proxy in netting_channel_proxies:
        raiden.blockchain_events.add_netting_channel_listener(channel_proxy)

    token_network_state = get_token_network_state_from_proxies(
        raiden,
        manager_proxy,
        netting_channel_proxies,
    )

    new_payment_network = ContractReceiveNewTokenNetwork(
        event.originating_contract,
        token_network_state,
    )
    raiden.handle_state_change(new_payment_network)
Example #2
0
def handle_tokennetwork_new(raiden, event, current_block_number):
    data = event.event_data
    manager_address = data['channel_manager_address']

    registry_address = data['registry_address']
    registry = raiden.chain.registry(registry_address)

    manager_proxy = registry.manager(manager_address)
    netting_channel_proxies = get_channel_proxies(raiden.chain, raiden.address,
                                                  manager_proxy)

    # Install the filters first to avoid missing changes, as a consequence
    # some events might be applied twice.
    raiden.blockchain_events.add_channel_manager_listener(
        manager_proxy,
        from_block=data['blockNumber'],
    )
    for channel_proxy in netting_channel_proxies:
        raiden.blockchain_events.add_netting_channel_listener(
            channel_proxy,
            from_block=data['blockNumber'],
        )

    token_address = data_decoder(data['args']['token_address'])

    token_network_state = TokenNetworkState(
        manager_address,
        token_address,
    )

    new_payment_network = ContractReceiveNewTokenNetwork(
        event.originating_contract,
        token_network_state,
    )
    raiden.handle_state_change(new_payment_network, current_block_number)