def test_builder_deployment_type_complex(escrow_package):
    escrow, w3 = escrow_package
    escrow_dep_type = deployment_type(
        contract_instance="Escrow",
        contract_type="Escrow",
        deployment_bytecode={
            "bytecode":
            "0x608060405234801561001057600080fd5b5060405160208061045383398101604081815291516002819055336000818152602081815285822084905583855294519294919390927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a3506103d2806100816000396000f3006080604052600436106100775763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663095ea7b3811461007c57806318160ddd146100b457806323b872dd146100db57806370a0823114610105578063a9059cbb14610126578063dd62ed3e1461014a575b600080fd5b34801561008857600080fd5b506100a0600160a060020a0360043516602435610171565b604080519115158252519081900360200190f35b3480156100c057600080fd5b506100c96101d8565b60408051918252519081900360200190f35b3480156100e757600080fd5b506100a0600160a060020a03600435811690602435166044356101de565b34801561011157600080fd5b506100c9600160a060020a03600435166102c9565b34801561013257600080fd5b506100a0600160a060020a03600435166024356102e4565b34801561015657600080fd5b506100c9600160a060020a036004358116906024351661037b565b336000818152600160209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a35060015b92915050565b60025481565b600160a060020a03831660009081526020819052604081205482118015906102295750600160a060020a03841660009081526001602090815260408083203384529091529020548211155b80156102355750600082115b156102be57600160a060020a0380841660008181526020818152604080832080548801905593881680835284832080548890039055600182528483203384528252918490208054879003905583518681529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35060016102c2565b5060005b9392505050565b600160a060020a031660009081526020819052604090205490565b3360009081526020819052604081205482118015906103035750600082115b15610373573360008181526020818152604080832080548790039055600160a060020a03871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a35060016101d2565b5060006101d2565b600160a060020a039182166000908152600160209081526040808320939094168252919091522054905600a165627a7a72305820cf9d6a3f751ca1e6b9bc2324e42633a4cde513d64c3e6cc32d6359629249e90200290000000000000000000000000000000000000000000000000000000000000001"  # noqa: E501
        },
        runtime_bytecode={
            "bytecode":
            "0x6080604052600436106100775763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663095ea7b3811461007c57806318160ddd146100b457806323b872dd146100db57806370a0823114610105578063a9059cbb14610126578063dd62ed3e1461014a575b600080fd5b34801561008857600080fd5b506100a0600160a060020a0360043516602435610171565b604080519115158252519081900360200190f35b3480156100c057600080fd5b506100c96101d8565b60408051918252519081900360200190f35b3480156100e757600080fd5b506100a0600160a060020a03600435811690602435166044356101de565b34801561011157600080fd5b506100c9600160a060020a03600435166102c9565b34801561013257600080fd5b506100a0600160a060020a03600435166024356102e4565b34801561015657600080fd5b506100c9600160a060020a036004358116906024351661037b565b336000818152600160209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a35060015b92915050565b60025481565b600160a060020a03831660009081526020819052604081205482118015906102295750600160a060020a03841660009081526001602090815260408083203384529091529020548211155b80156102355750600082115b156102be57600160a060020a0380841660008181526020818152604080832080548801905593881680835284832080548890039055600182528483203384528252918490208054879003905583518681529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35060016102c2565b5060005b9392505050565b600160a060020a031660009081526020819052604090205490565b3360009081526020819052604081205482118015906103035750600082115b15610373573360008181526020818152604080832080548790039055600160a060020a03871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a35060016101d2565b5060006101d2565b600160a060020a039182166000908152600160209081526040808320939094168252919091522054905600a165627a7a72305820cf9d6a3f751ca1e6b9bc2324e42633a4cde513d64c3e6cc32d6359629249e9020029"  # noqa: E501
        },
        compiler={
            "name": "solc",
            "version": "0.4.24+commit.e67f0147.Emscripten.clang",
            "settings": {
                "optimize": True
            },
        },
    )
    safesendlib_dep_type = deployment_type(contract_instance="SafeSendLib",
                                           contract_type="SafeSendLib")
    manifest = build(
        {},
        package_name("escrow"),
        version("1.0.0"),
        manifest_version("ethpm/3"),
        escrow_dep_type(
            block_uri=
            "blockchain://1111111111111111111111111111111111111111111111111111111111111111/block/1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",  # noqa: E501
            address=escrow.deployments.get_instance("Escrow").address,
        ),
        # dep_type with block uri
        safesendlib_dep_type(
            block_uri=
            "blockchain://1111111111111111111111111111111111111111111111111111111111111111/block/1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",  # noqa: E501
            address=escrow.deployments.get_instance("SafeSendLib").address,
        ),
        # simple deployment
        deployment(
            block_uri=
            "blockchain://1234567890123456789012345678901234567890123456789012345678901234/block/1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",  # noqa: E501
            contract_instance="Escrow",
            contract_type="Escrow",
            address=escrow.deployments.get_instance("Escrow").address,
        ),
        # simple deployment
        deployment(
            block_uri=
            "blockchain://1234567890123456789012345678901234567890123456789012345678901234/block/1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",  # noqa: E501
            contract_instance="SafeSendLib",
            contract_type="SafeSendLib",
            address=escrow.deployments.get_instance("SafeSendLib").address,
        ),
        validate(),
    )
    assert len(manifest["deployments"].keys()) == 2
    assert len(list(manifest["deployments"].values())[0]) == 2
    assert len(list(manifest["deployments"].values())[1]) == 2
Example #2
0
def test_builder_deployment_simple(w3):
    expected = json.dumps({
        "package_name": "package",
        "version": "1.0.0",
        "manifest_version": "2",
        "deployments": {
            "blockchain://1234567890123456789012345678901234567890123456789012345678901234/block/1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef":
            {  # noqa: E501
                "Owned": {
                    "contract_type": "Owned",
                    "address": "0xd3CdA913deB6f67967B99D67aCDFa1712C293601",
                }
            }
        },
    })
    manifest = build(
        BASE_MANIFEST,
        deployment(
            block_uri=
            "blockchain://1234567890123456789012345678901234567890123456789012345678901234/block/1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",  # noqa: E501
            contract_instance="Owned",
            contract_type="Owned",
            address=to_canonical_address(
                "0xd3cda913deb6f67967b99d67acdfa1712c293601"),
        ),
    )
    assert manifest == json.loads(expected)
Example #3
0
def amend_deployments(manifest: Manifest) -> Iterable[Callable[..., Manifest]]:
    try:
        manifest["deployments"]
    except KeyError:
        flag = parse_bool_flag("No deployments found, would you like to add one?")
    else:
        # todo: support amending existing deployments, and refactor deployment strategy
        # to support multiple deployments on the same chain
        cli_logger.info(
            "Deployments found, amending existing deployments is not currently supported."
        )
        return tuple()

    if flag:
        deployment_data = amend_single_deployment(manifest)
        return (b.deployment(**dep) for dep in deployment_data)
    return tuple()
Example #4
0
def build_deployments(
        solc_output: Dict[str, Any]) -> Iterable[Callable[..., Manifest]]:
    deployments_data = gen_all_deployments(solc_output)
    return (b.deployment(**dep) for dep in deployments_data)