Ejemplo n.º 1
0
def handle_channel_update_transfer(raiden: 'RaidenService', event: Event):
    token_network_identifier = event.originating_contract
    data = event.event_data
    args = data['args']
    channel_identifier = args['channel_identifier']
    transaction_hash = data['transaction_hash']
    block_number = data['block_number']
    block_hash = data['block_hash']

    channel_state = views.get_channelstate_by_token_network_identifier(
        views.state_from_raiden(raiden),
        token_network_identifier,
        channel_identifier,
    )

    if channel_state:
        channel_transfer_updated = ContractReceiveUpdateTransfer(
            transaction_hash=transaction_hash,
            token_network_identifier=token_network_identifier,
            channel_identifier=channel_identifier,
            nonce=args['nonce'],
            block_number=block_number,
            block_hash=block_hash,
        )
        raiden.handle_and_track_state_change(channel_transfer_updated)
Ejemplo n.º 2
0
def handle_channel_update_transfer(raiden: "RaidenService", event: Event):
    token_network_identifier = event.originating_contract
    data = event.event_data
    args = data["args"]
    channel_identifier = args["channel_identifier"]
    transaction_hash = data["transaction_hash"]
    block_number = data["block_number"]
    block_hash = data["block_hash"]

    chain_state = views.state_from_raiden(raiden)
    channel_state = views.get_channelstate_by_canonical_identifier_and_address(
        chain_state=chain_state,
        canonical_identifier=CanonicalIdentifier(
            chain_identifier=chain_state.chain_id,
            token_network_address=token_network_identifier,
            channel_identifier=channel_identifier,
        ),
        address=args['closing_participant'],
    )

    if channel_state:
        channel_transfer_updated = ContractReceiveUpdateTransfer(
            transaction_hash=transaction_hash,
            canonical_identifier=channel_state.canonical_identifier,
            nonce=args["nonce"],
            block_number=block_number,
            block_hash=block_hash,
        )
        raiden.handle_and_track_state_change(channel_transfer_updated)
Ejemplo n.º 3
0
def contractreceiveupdatetransfer_from_event(
        channel_state: NettingChannelState,
        event: DecodedEvent) -> ContractReceiveUpdateTransfer:
    data = event.event_data
    args = data["args"]

    return ContractReceiveUpdateTransfer(
        canonical_identifier=channel_state.canonical_identifier,
        nonce=args["nonce"],
        transaction_hash=event.transaction_hash,
        block_number=event.block_number,
        block_hash=event.block_hash,
    )
Ejemplo n.º 4
0
def handle_channel_update_transfer(raiden, event):
    token_network_identifier = event.originating_contract
    data = event.event_data
    channel_identifier = data['channel_identifier']
    transaction_hash = data['transactionHash']
    assert transaction_hash, 'A mined transaction must have the hash field'

    channel_state = views.get_channelstate_by_token_network_identifier(
        views.state_from_raiden(raiden),
        token_network_identifier,
        channel_identifier,
    )

    if channel_state:
        channel_transfer_updated = ContractReceiveUpdateTransfer(
            transaction_hash=transaction_hash,
            token_network_identifier=token_network_identifier,
            channel_identifier=channel_identifier,
            nonce=data['args']['nonce'],
        )
        raiden.handle_state_change(channel_transfer_updated)