def _deployment(
        contract_instance: str,
        contract_type: str,
        deployment_bytecode: Dict[str, Any],
        runtime_bytecode: Dict[str, Any],
        compiler: Dict[str, Any],
        block_uri: URI,
        address: HexStr,
        tx: HexStr,
        block: HexStr,
        manifest: Manifest,
) -> Manifest:
    validate_address(address)
    if not is_BIP122_block_uri(block_uri):
        raise ManifestBuildingError(f"{block_uri} is not a valid BIP122 URI.")

    if tx:
        if not is_string(tx) and not is_hex(tx):
            raise ManifestBuildingError(
                f"Transaction hash: {tx} is not a valid hexstring"
            )

    if block:
        if not is_string(block) and not is_hex(block):
            raise ManifestBuildingError(f"Block hash: {block} is not a valid hexstring")
    # todo: validate db, rb and compiler are properly formatted dicts
    deployment_data = _build_deployments_object(
        contract_type,
        deployment_bytecode,
        runtime_bytecode,
        compiler,
        address,
        tx,
        block,
        manifest,
    )
    return assoc_in(
        manifest, ["deployments", block_uri, contract_instance], deployment_data
    )
Пример #2
0
def test_is_BIP122_block_uri(value, expected):
    actual = is_BIP122_block_uri(value)
    assert actual is expected