def standard_token_package(ethpm_spec_dir):
    standard_token_dir = ethpm_spec_dir / "examples" / "standard-token"
    manifest = get_ethpm_spec_manifest("standard-token", "v3.json")
    compiler = get_ethpm_local_manifest("standard-token",
                                        "output_v3.json")["contracts"]
    contracts_dir = standard_token_dir / "contracts"
    return contracts_dir, manifest, compiler
Beispiel #2
0
def sol_registry(w3):
    manifest = get_ethpm_local_manifest("simple-registry", "v3.json")
    registry_package = Package(manifest, w3)
    registry_deployer = Deployer(registry_package)
    deployed_registry_package = registry_deployer.deploy("PackageRegistry")
    assert isinstance(registry_package, Package)
    registry = deployed_registry_package.deployments.get_instance("PackageRegistry")
    return SimpleRegistry(registry.address, w3)
def test_get_contract_factory_with_valid_owned_manifest(w3):
    owned_manifest = get_ethpm_local_manifest('owned', 'with_contract_type_v3.json')
    owned_package = w3.pm.get_package_from_manifest(owned_manifest)
    owned_factory = owned_package.get_contract_factory('Owned')
    tx_hash = owned_factory.constructor().transact()
    tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
    owned_address = tx_receipt.contractAddress
    owned_instance = owned_package.get_contract_instance("Owned", owned_address)
    assert owned_instance.abi == owned_factory.abi
def owned_package(ethpm_spec_dir):
    manifest = get_ethpm_spec_manifest("owned", "v3.json")
    # source_id missing `./` prefix in ethpm-spec ("Owned.sol"/"./Owned.sol" though both are valid)
    source_obj = manifest['sources'].pop('Owned.sol')
    updated_manifest = assoc_in(manifest, ['sources', './Owned.sol'],
                                source_obj)

    compiler = get_ethpm_local_manifest("owned", "output_v3.json")["contracts"]
    contracts_dir = ethpm_spec_dir / "examples" / "owned" / "contracts"
    return contracts_dir, updated_manifest, compiler
def test_deploy_a_standalone_package_integration(w3):
    standard_token_manifest = get_ethpm_local_manifest("standard-token", "with_bytecode_v3.json")
    token_package = w3.pm.get_package_from_manifest(standard_token_manifest)
    # Added deployment bytecode to manifest to be able to generate factory
    ERC20 = token_package.get_contract_factory('StandardToken')
    # totalSupply = 100
    tx_hash = ERC20.constructor(100).transact()
    tx_receipt = w3.eth.get_transaction_receipt(tx_hash)
    address = tx_receipt["contractAddress"]
    erc20 = w3.eth.contract(address=address, abi=ERC20.abi)
    total_supply = erc20.functions.totalSupply().call()
    assert total_supply == 100