コード例 #1
0
ファイル: contracts.py プロジェクト: ninjai2018/raiden
def secret_registry_proxy(deploy_client, secret_registry_contract,
                          contract_manager):
    return SecretRegistry(
        jsonrpc_client=deploy_client,
        secret_registry_address=to_canonical_address(
            secret_registry_contract.contract.address),
        contract_manager=contract_manager,
    )
コード例 #2
0
def secret_registry_proxy_patched(secret_registry_proxy):
    secret_registry_patched = SecretRegistry(
        secret_registry_proxy.client,
        secret_registry_proxy.address,
    )
    _register_secret = secret_registry_patched._register_secret

    def register_secret_patched(self, secret):
        """Make sure the transaction is sent only once per secret"""
        assert secret not in self.trigger
        self.trigger[secret] = True
        return _register_secret(secret)

    secret_registry_patched._register_secret = types.MethodType(
        register_secret_patched,
        secret_registry_patched,
    )
    secret_registry_patched.trigger = dict()
    return secret_registry_patched
コード例 #3
0
    def secret_registry(self, address: Address) -> SecretRegistry:
        if not is_binary_address(address):
            raise ValueError('address must be a valid address')

        if address not in self.address_to_secret_registry:
            self.address_to_secret_registry[address] = SecretRegistry(
                self.client,
                address,
            )

        return self.address_to_secret_registry[address]
コード例 #4
0
def secret_registry_proxy_patched(secret_registry_proxy):
    secret_registry_patched = SecretRegistry(
        secret_registry_proxy.client,
        secret_registry_proxy.address,
    )
    _register_secret_batch = secret_registry_patched._register_secret_batch

    def register_secret_batch_patched(self, secrets):
        """Make sure the transaction is sent only once per secret"""
        for secret in secrets:
            assert secret not in self.trigger
            self.trigger[secret] = True
        return _register_secret_batch(secrets)

    secret_registry_patched._register_secret_batch = types.MethodType(
        register_secret_batch_patched,
        secret_registry_patched,
    )
    secret_registry_patched.trigger = dict()
    return secret_registry_patched
コード例 #5
0
def secret_registry_proxy_patched(secret_registry_proxy, contract_manager):
    secret_registry_patched = SecretRegistry(
        jsonrpc_client=secret_registry_proxy.client,
        secret_registry_address=secret_registry_proxy.address,
        contract_manager=contract_manager,
    )
    register_secret_batch = secret_registry_patched.register_secret_batch

    def register_secret_batch_patched(self, secrets):
        """Make sure the transaction is sent only once per secret"""
        for secret in secrets:
            assert secret not in self.trigger
            self.trigger[secret] = True
        return register_secret_batch(secrets=secrets, given_block_identifier='latest')

    secret_registry_patched._register_secret_batch = types.MethodType(
        register_secret_batch_patched,
        secret_registry_patched,
    )
    secret_registry_patched.trigger = dict()
    return secret_registry_patched
コード例 #6
0
 def add_secret_registry_listener(
     self,
     secret_registry_proxy: SecretRegistry,
     from_block: typing.BlockSpecification = 'latest',
 ):
     secret_registry_filter = secret_registry_proxy.secret_registered_filter(
         from_block=from_block, )
     secret_registry_address = secret_registry_proxy.address
     self.add_event_listener(
         'SecretRegistry {}'.format(pex(secret_registry_address)),
         secret_registry_filter,
         CONTRACT_MANAGER.get_contract_abi(CONTRACT_SECRET_REGISTRY),
     )
コード例 #7
0
    def secret_registry(self, address: Address) -> SecretRegistry:
        if not is_binary_address(address):
            raise ValueError('address must be a valid address')

        with self._secret_registry_creation_lock:
            if address not in self.address_to_secret_registry:
                self.address_to_secret_registry[address] = SecretRegistry(
                    jsonrpc_client=self.client,
                    secret_registry_address=address,
                    contract_manager=self.contract_manager,
                )

        return self.address_to_secret_registry[address]
コード例 #8
0
ファイル: events.py プロジェクト: AlphaX-IBS/raiden
 def add_secret_registry_listener(
         self,
         secret_registry_proxy: SecretRegistry,
         from_block: typing.BlockSpecification = 'latest',
 ):
     secret_registry_filter = secret_registry_proxy.secret_registered_filter(
         from_block=from_block,
     )
     secret_registry_address = secret_registry_proxy.address
     self.add_event_listener(
         'SecretRegistry {}'.format(pex(secret_registry_address)),
         secret_registry_filter,
         CONTRACT_MANAGER.get_contract_abi(CONTRACT_SECRET_REGISTRY),
     )
コード例 #9
0
ファイル: contracts.py プロジェクト: tokenbase/raiden
def secret_registry_proxy(deploy_client, secret_registry_contract):
    return SecretRegistry(
        deploy_client,
        to_canonical_address(secret_registry_contract.contract.address),
    )