コード例 #1
0
ファイル: state.py プロジェクト: roninjin10/raiden
    def from_dict(cls, data: typing.Dict[str, typing.Any]) -> 'InitiatorTransferState':
        restored = cls(
            transfer_description=data['transfer_description'],
            channel_identifier=typing.ChannelID(int(data['channel_identifier'])),
            transfer=data['transfer'],
            revealsecret=data['revealsecret'],
            received_secret_request=data['received_secret_request'],
        )

        return restored
コード例 #2
0
ファイル: events.py プロジェクト: roninjin10/raiden
    def from_dict(cls, data: typing.Dict[str,
                                         typing.Any]) -> 'SendRefundTransfer':
        restored = cls(
            recipient=to_canonical_address(data['recipient']),
            channel_identifier=typing.ChannelID(int(
                data['channel_identifier'])),
            message_identifier=int(data['message_identifier']),
            transfer=data['transfer'],
        )

        return restored
コード例 #3
0
ファイル: events.py プロジェクト: roninjin10/raiden
    def from_dict(cls, data: typing.Dict[str,
                                         typing.Any]) -> 'SendSecretReveal':
        restored = cls(
            recipient=to_canonical_address(data['recipient']),
            channel_identifier=typing.ChannelID(int(
                data['channel_identifier'])),
            message_identifier=int(data['message_identifier']),
            secret=serialization.deserialize_bytes(data['secret']),
        )

        return restored
コード例 #4
0
 def from_dict(
         cls,
         data: typing.Dict[str,
                           typing.Any]) -> 'ContractReceiveChannelSettled':
     return cls(
         transaction_hash=deserialize_bytes(data['transaction_hash']),
         token_network_identifier=to_canonical_address(
             data['token_network_identifier']),
         channel_identifier=typing.ChannelID(int(
             data['channel_identifier'])),
         block_number=typing.BlockNumber(int(data['block_number'])),
     )
コード例 #5
0
ファイル: events.py プロジェクト: roninjin10/raiden
    def from_dict(cls, data: typing.Dict[str,
                                         typing.Any]) -> 'SendSecretRequest':
        restored = cls(
            recipient=to_canonical_address(data['recipient']),
            channel_identifier=typing.ChannelID(int(
                data['channel_identifier'])),
            message_identifier=int(data['message_identifier']),
            payment_identifier=int(data['payment_identifier']),
            amount=int(data['amount']),
            expiration=int(data['expiration']),
            secrethash=serialization.deserialize_bytes(data['secrethash']),
        )

        return restored
コード例 #6
0
ファイル: events.py プロジェクト: roninjin10/raiden
    def from_dict(cls, data: typing.Dict[str,
                                         typing.Any]) -> 'SendBalanceProof':
        restored = cls(
            recipient=to_canonical_address(data['recipient']),
            channel_identifier=typing.ChannelID(int(
                data['channel_identifier'])),
            message_identifier=int(data['message_identifier']),
            payment_identifier=int(data['payment_identifier']),
            token_address=to_canonical_address(data['token_address']),
            secret=serialization.deserialize_bytes(data['secret']),
            balance_proof=data['balance_proof'],
        )

        return restored
コード例 #7
0
def make_channel_identifier() -> typing.ChannelID:
    return typing.ChannelID(make_uint256())
コード例 #8
0
ファイル: events.py プロジェクト: roninjin10/raiden
# pylint: disable=too-many-arguments,too-few-public-methods
from eth_utils import to_canonical_address, to_checksum_address

from raiden.transfer.architecture import Event, SendMessageEvent
from raiden.transfer.mediated_transfer.state import LockedTransferUnsignedState
from raiden.transfer.state import BalanceProofUnsignedState
from raiden.utils import pex, serialization, sha3, typing

# According to the smart contracts as of 07/08:
# https://github.com/raiden-network/raiden-contracts/blob/fff8646ebcf2c812f40891c2825e12ed03cc7628/raiden_contracts/contracts/TokenNetwork.sol#L213
# channel_identifier can never be 0. We make this a requirement in the client and use this fact
# to signify that a channel_identifier of `0` passed to the messages adds them to the
# global queue
CHANNEL_IDENTIFIER_GLOBAL_QUEUE = typing.ChannelID(0)


def refund_from_sendmediated(send_lockedtransfer_event):
    return SendRefundTransfer(
        recipient=send_lockedtransfer_event.recipient,
        channel_identifier=send_lockedtransfer_event.queue_identifier.
        channel_identifier,
        message_identifier=send_lockedtransfer_event.message_identifier,
        transfer=send_lockedtransfer_event.transfer,
    )


class SendLockExpired(SendMessageEvent):
    def __init__(
        self,
        recipient: typing.Address,
        message_identifier: typing.MessageID,
コード例 #9
0
 def from_dict(cls, data) -> 'ActionCancelRoute':
     return cls(
         registry_address=to_canonical_address(data['registry_address']),
         channel_identifier=typing.ChannelID(int(data['identifier'])),
         routes=data['routes'],
     )