How to use the cryptoconditions.exceptions.UnsupportedTypeError function in cryptoconditions

To help you get started, we’ve selected a few cryptoconditions examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bigchaindb / bigchaindb / tests / validation / test_transaction_structure.py View on Github external
def test_unsupported_condition_type():
    from bigchaindb.common import transaction
    from cryptoconditions.exceptions import UnsupportedTypeError

    with pytest.raises(UnsupportedTypeError):
        transaction._fulfillment_from_details({'type': 'a'})

    with pytest.raises(UnsupportedTypeError):
        transaction._fulfillment_to_details(MagicMock(type_name='a'))
github bigchaindb / bigchaindb / tests / validation / test_transaction_structure.py View on Github external
def test_unsupported_condition_type():
    from bigchaindb.common import transaction
    from cryptoconditions.exceptions import UnsupportedTypeError

    with pytest.raises(UnsupportedTypeError):
        transaction._fulfillment_from_details({'type': 'a'})

    with pytest.raises(UnsupportedTypeError):
        transaction._fulfillment_to_details(MagicMock(type_name='a'))
github bigchaindb / bigchaindb / bigchaindb / common / transaction.py View on Github external
"""
    if _depth == 100:
        raise ThresholdTooDeep()

    if data['type'] == 'ed25519-sha-256':
        public_key = base58.b58decode(data['public_key'])
        return Ed25519Sha256(public_key=public_key)

    if data['type'] == 'threshold-sha-256':
        threshold = ThresholdSha256(data['threshold'])
        for cond in data['subconditions']:
            cond = _fulfillment_from_details(cond, _depth+1)
            threshold.add_subfulfillment(cond)
        return threshold

    raise UnsupportedTypeError(data.get('type'))
github bigchaindb / bigchaindb-driver / bigchaindb_driver / common / transaction.py View on Github external
'type': 'ed25519-sha-256',
            'public_key': base58.b58encode(fulfillment.public_key).decode(),
        }

    if fulfillment.type_name == 'threshold-sha-256':
        subconditions = [
            _fulfillment_to_details(cond['body'])
            for cond in fulfillment.subconditions
        ]
        return {
            'type': 'threshold-sha-256',
            'threshold': fulfillment.threshold,
            'subconditions': subconditions,
        }

    raise UnsupportedTypeError(fulfillment.type_name)
github bigchaindb / bigchaindb-driver / bigchaindb_driver / common / transaction.py View on Github external
"""
    if _depth == 100:
        raise ThresholdTooDeep()

    if data['type'] == 'ed25519-sha-256':
        public_key = base58.b58decode(data['public_key'])
        return Ed25519Sha256(public_key=public_key)

    if data['type'] == 'threshold-sha-256':
        threshold = ThresholdSha256(data['threshold'])
        for cond in data['subconditions']:
            cond = _fulfillment_from_details(cond, _depth+1)
            threshold.add_subfulfillment(cond)
        return threshold

    raise UnsupportedTypeError(data.get('type'))
github bigchaindb / bigchaindb / bigchaindb / common / transaction.py View on Github external
'type': 'ed25519-sha-256',
            'public_key': base58.b58encode(fulfillment.public_key).decode(),
        }

    if fulfillment.type_name == 'threshold-sha-256':
        subconditions = [
            _fulfillment_to_details(cond['body'])
            for cond in fulfillment.subconditions
        ]
        return {
            'type': 'threshold-sha-256',
            'threshold': fulfillment.threshold,
            'subconditions': subconditions,
        }

    raise UnsupportedTypeError(fulfillment.type_name)