You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/web3.pm.rst
+39-13
Original file line number
Diff line number
Diff line change
@@ -4,19 +4,34 @@ Package Manager API
4
4
5
5
The ``web3.pm`` object exposes methods to interact with Packages as defined by `ERC 1123 <https://github.com/ethereum/EIPs/issues/1123>`_.
6
6
7
-
To learn more about the EthPM spec, visit the `documentation <http://ethpm.github.io/ethpm-spec/>`__.
8
-
To learn more about the Py-EthPM library used in this module, visit the `documentation <https://py-ethpm.readthedocs.io/en/latest/>`__.
7
+
- To learn more about the EthPM spec, visit the `documentation <http://ethpm.github.io/ethpm-spec/>`__.
8
+
- To learn more about the Py-EthPM library used in this module, visit the `documentation <https://py-ethpm.readthedocs.io/en/latest/>`__.
9
9
10
10
11
-
Attaching
12
-
---------
13
-
To use ``web3.pm``, attach it to your ``web3`` instance.
14
-
15
-
.. code-block:: python
16
-
17
-
from web3.pm importPM
18
-
PM.attach(web3, 'pm')
19
-
11
+
.. WARNING::
12
+
13
+
The ``web3.pm`` API is still under development and likely to change quickly.
14
+
15
+
Now is a great time to get familiar with the API, and test out writing
16
+
code that uses some of the great upcoming features.
17
+
18
+
By default, access to this module has been turned off in the stable version of Web3.py:
19
+
20
+
.. code-block:: python
21
+
22
+
>>>from web3.auto import w3
23
+
>>> w3.pm
24
+
...
25
+
AttributeError: The Package Management feature is disabled by default ...
26
+
27
+
In order to access these features, you can turn it on with...
28
+
29
+
.. code-block:: python
30
+
31
+
>>> web3.enable_unstable_package_management_api()
32
+
>>> w3.pm
33
+
<web3.pm.PM at 0x....>
34
+
20
35
21
36
Methods
22
37
-------
@@ -25,8 +40,6 @@ The following methods are available on the ``web3.pm`` namespace.
25
40
.. autoclass:: web3.pm.PM
26
41
:members:
27
42
28
-
.. note:: If you want to implement your own registry and use it with ``web3.pm``, you must create a subclass that inherits from ``ERCRegistry``, implements all the methods defined in ``ERCRegistry``, and manually set it as the ```registry`` attribute on ``web3.pm``.
@@ -36,3 +49,16 @@ The following methods are available on the ``web3.pm`` namespace.
36
49
.. autoclass:: web3.pm.SolidityReferenceRegistry
37
50
:members:
38
51
52
+
53
+
Creating your own Registry class
54
+
--------------------------------
55
+
If you want to implement your own registry and use it with ``web3.pm``, you must create a subclass that inherits from ``ERCRegistry``, and implements all the `ERC 1319 standard methods <https://github.com/ethereum/EIPs/issues/1319>`_ prefixed with an underscore in ``ERCRegistry``. Then, you have to manually set it as the ``registry`` attribute on ``web3.pm``.
One reason a user might want to create their own Registry class is if they build a custom Package Registry smart contract that has features beyond those specified in `ERC 1319 <https://github.com/ethereum/EIPs/issues/1319>`_. For example, the ability to delete a release or some micropayment feature. Rather than accessing those functions directly on the contract instance, they can create a custom ``ERCRegistry`` subclass to easily call both the standard & custom methods.
63
+
64
+
The ``VyperReferenceRegistry`` class is an example of this, as it contains all of the ``ERC 1319`` defined functions (prefixed with an underscore, eg ``_get_package_name``) but also contains functions that are unique to the Vyper Registry reference implementation (eg ``transfer_owner``).
0 commit comments