ethpm / py-ethpm

This library is deprecated. ethPM python tooling is now located in web3.py
MIT License
24 stars 13 forks source link

ValueError: Package does not have valid web3 instance. #48

Closed fubuloubu closed 6 years ago

fubuloubu commented 6 years ago

What was wrong?

w3 = Web3(Web3.IPCProvider("/home/bryant/.ethereum/testnet/geth.ipc"))
from web3.pm import PM
PM.attach(web3, 'pmp')
owned_package = w3.pmp.get_package_from_manifest({
    ...:   "manifest_version": "2",
    ...:   "version": "1.0.0",
    ...:   "package_name": "owned",
    ...:   "meta": {
    ...:     "license": "MIT",
    ...:     "authors": [
    ...:       "Piper Merriam <pipermerriam@gmail.com>"
    ...:     ],
    ...:     "description": "Reusable contracts which implement a privileged 'owner' model for authorization.",
    ...:     "keywords": [
    ...:       "authorization"
    ...:     ],
    ...:     "links": {
    ...:       "documentation": "ipfs://QmUYcVzTfSwJoigggMxeo2g5STWAgJdisQsqcXHws7b1FW"
    ...:     }
    ...:   },
    ...:   "sources": {
    ...:     "./contracts/Owned.sol": "ipfs://Qme4otpS88NV8yQi8TfTP89EsQC5bko3F5N1yhRoi6cwGV"
    ...:   }
    ...: })
owned_package.get_contract_type('owned')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-55-a85b3dd83952> in <module>()
----> 1 owned_package.get_contract_type('owned')

~/.pyenv/versions/3.6.5/envs/pytest-ethereum/lib/python3.6/site-packages/ethpm/package.py in get_contract_type(self, name, w3)
     95 
     96         validate_contract_name(name)
---> 97         validate_w3_instance(current_w3)
     98 
     99         if name in self.package_data['contract_types']:

~/.pyenv/versions/3.6.5/envs/pytest-ethereum/lib/python3.6/site-packages/ethpm/utils/contract.py in validate_w3_instance(w3)
     46 def validate_w3_instance(w3: Web3) -> None:
     47     if w3 is None or not isinstance(w3, Web3):
---> 48         raise ValueError("Package does not have valid web3 instance.")
     49 
     50 

ValueError: Package does not have valid web3 instance.
fubuloubu commented 6 years ago

Woo!