Skip to main content

Python abstraction for ERC190 packages.

Project description

  • parse and validate packages.

  • given a web3 instance provide access to contract factory classes

  • given a web3 instance provide access to all of the deployed contract instances for the chain that web3 is connected to.

  • validate package bytecode matches compilation output.

  • validate deployed bytecode matches compilation output

  • access to packages dependencies

  • construct new packages

Web3

The Package object will function much like the Contract class provided by web3. Rather than instantiating the base class provided by ethpm, you will instead use a classmethod which generates a new Package class for a given package.

OwnedPackage = BasePackage.factory('/path/to/owned-v1.0.0.json')

Then, the OwnedPackage can be instantiated with any web3 intance.

owned_package = OwnedPackage(web3)

A Package class can only be directly constructed from the parsed package JSON. It can also be initialized with the package’s URI or the local filesystem path to a package by using Package.from_file(path).

Contract Factories

Contract factories should be accessible from the package class but you must also provide a web3 instance.

Owned = OwnedPackage.get_contract_factory(web3, 'owned')

From a package instance, they are also available as properties.

Owned = owned_package.contract_factories.owned

In cases where a contract uses a library, the contract factory will have unlinked bytecode. The ethpm package ships with its own subclass of web3.contract.Contract with a few extra methods and properties related to bytecode linking

>>> math = owned_package.contract_factories.math
>>> math.has_linkable_bytecode
True
>>> math.is_bytecode_linked
False
>>> linked_math = math.link_bytecode({'MathLib': '0x1234...'})
>>> linked_math.is_bytecode_linked
True

Note: the actual format of the link data is not clear since library names aren’t a one-size-fits all solution. We need the ability to specify specific link references in the code.

Deployed Contracts

Deployed contracts are only available from package instances. The package instance will filter the deployments based on the chain that web3 is connected to.

Accessing deployments is done with property access

package.deployed_contracts.Greeter

IPFS

We’ll need a pluggable backend system for IPFS access. A built-in default one that defaults to using infura should be enough to get off the ground.

Lower priority but important will be ensuring that a user can configure connecting to their own IPFS node.

Verifying Things

The Package class should verify all of the following things.

  • Package json matches EthPM V2 Manifest Specification

  • Included bytecode matches compilation output

  • Deployed bytecode matches compilation output

Dependencies

The Package class should provide access to the full dependency tree.

>>> owned_package.build_dependencies['zeppelin']
<ZeppelinPackage>

Testing Strategy

  • Load and validate packages from disk.

  • Access package data.

  • Access contract factories.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ethpm-0.1.0.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

ethpm-0.1.0-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file ethpm-0.1.0.tar.gz.

File metadata

  • Download URL: ethpm-0.1.0.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ethpm-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8bd23f30e0b38ddcc7fffb8a7b81fb537cb7f30573c31651fe616ab6c981c31f
MD5 e1d0b8cd6e113d19f37c35ae2c5e762b
BLAKE2b-256 040549be8a2ffadf675db4853e6c6319328aaaeeb7b118d44d8eb972fc19e8a1

See more details on using hashes here.

File details

Details for the file ethpm-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ethpm-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bdb0aa4fd36273bf65f8b0bc6ff4ad3f7de9cba0150b22003fb8d10a21aa2031
MD5 0df2886e16560785aa7703e7add8e88b
BLAKE2b-256 6a93b640a3547508b75091536fc1c64ab2d71089f34d205c3ca661099ccf96ba

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page