Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Migrate to Web3.py v5 #2038

Merged
merged 15 commits into from
Aug 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,13 @@ jobs:
docker:
- image: circleci/python
- image: 0xorg/ganache-cli:2.2.2
- image: 0xorg/launch-kit-ci
- image: 0xorg/launch-kit-backend:74bcc39
environment:
RPC_URL: http://localhost:8545
NETWORK_ID: 50
WHITELIST_ALL_TOKENS: True
command: bash -c "until curl -sfd'{\"method\":\"net_listening\"}' http://localhost:8545 | grep true; do continue; done; forever ts/lib/index.js"
command: |
sh -c "until printf 'POST /\r\nContent-Length: 26\r\n\r\n{\"method\":\"net_listening\"}' | nc localhost 8545 | grep true; do continue; done; node_modules/.bin/forever ts/lib/index.js"
steps:
- checkout
- run: sudo chown -R circleci:circleci /usr/local/bin
Expand All @@ -210,7 +211,7 @@ jobs:
- run:
command: |
cd python-packages
./parallel coverage run setup.py test
./parallel_without_sra_client coverage run setup.py test
./build_docs
- save_cache:
key: coverage-python-contract-addresses-{{ .Environment.CIRCLE_SHA1 }}
Expand Down
4 changes: 4 additions & 0 deletions packages/abi-gen-templates/Python/contract.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ class {{contractName}}:
"""Wrapper class for {{contractName}} Solidity contract.{{docBytesIfNecessary ABIString}}"""
{{#each methods}}
{{toPythonIdentifier this.languageSpecificName}}: {{toPythonClassname this.languageSpecificName}}Method
"""Constructor-initialized instance of
:class:`{{toPythonClassname this.languageSpecificName}}Method`.
"""

{{/each}}

def __init__(
Expand Down
9 changes: 7 additions & 2 deletions packages/abi-gen/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,18 @@ function registerPythonHelpers(): void {
Handlebars.registerHelper('toPythonIdentifier', utils.toPythonIdentifier.bind(utils));
Handlebars.registerHelper('sanitizeDevdocDetails', (_methodName: string, devdocDetails: string, indent: number) => {
// wrap to 80 columns, assuming given indent, so that generated
// docstrings can pass pycodestyle checks.
// docstrings can pass pycodestyle checks. also, replace repeated
// spaces, likely caused by leading indents in the Solidity, because
// they cause repeated spaces in the output, and in particular they may
// cause repeated spaces at the beginning of a line in the docstring,
// which leads to "unexpected indent" errors when generating
// documentation.
if (devdocDetails === undefined || devdocDetails.length === 0) {
return '';
}
const columnsPerRow = 80;
return new Handlebars.SafeString(
`\n${cliFormat.wrap(devdocDetails || '', {
`\n${cliFormat.wrap(devdocDetails.replace(/ +/g, ' ') || '', {
paddingLeft: ' '.repeat(indent),
width: columnsPerRow,
ansi: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def validate_and_normalize_inputs(self, _hash: bytes, v: int, r: bytes, s: bytes
def call(self, _hash: bytes, v: int, r: bytes, s: bytes, tx_params: Optional[TxParams] = None) -> str:
"""Execute underlying contract method via eth_call.

test that devdocs will be generated and that multiline devdocs will
test that devdocs will be generated and that multiline devdocs will
look okay

:param hash: description of some hash. Let's make this line super long
Expand All @@ -465,7 +465,7 @@ def call(self, _hash: bytes, v: int, r: bytes, s: bytes, tx_params: Optional[TxP
def send_transaction(self, _hash: bytes, v: int, r: bytes, s: bytes, tx_params: Optional[TxParams] = None) -> Union[HexBytes, bytes]:
"""Execute underlying contract method via eth_sendTransaction.

test that devdocs will be generated and that multiline devdocs will
test that devdocs will be generated and that multiline devdocs will
look okay

:param hash: description of some hash. Let's make this line super long
Expand Down Expand Up @@ -1367,34 +1367,150 @@ class AbiGenDummy:
which can be accomplished via `str.encode("utf_8")`:code:.
"""
simple_require: SimpleRequireMethod
"""Constructor-initialized instance of
:class:`SimpleRequireMethod`.
"""

accepts_an_array_of_bytes: AcceptsAnArrayOfBytesMethod
"""Constructor-initialized instance of
:class:`AcceptsAnArrayOfBytesMethod`.
"""

simple_input_simple_output: SimpleInputSimpleOutputMethod
"""Constructor-initialized instance of
:class:`SimpleInputSimpleOutputMethod`.
"""

withdraw: WithdrawMethod
"""Constructor-initialized instance of
:class:`WithdrawMethod`.
"""

multi_input_multi_output: MultiInputMultiOutputMethod
"""Constructor-initialized instance of
:class:`MultiInputMultiOutputMethod`.
"""

ecrecover_fn: EcrecoverFnMethod
"""Constructor-initialized instance of
:class:`EcrecoverFnMethod`.
"""

accepts_bytes: AcceptsBytesMethod
"""Constructor-initialized instance of
:class:`AcceptsBytesMethod`.
"""

no_input_simple_output: NoInputSimpleOutputMethod
"""Constructor-initialized instance of
:class:`NoInputSimpleOutputMethod`.
"""

revert_with_constant: RevertWithConstantMethod
"""Constructor-initialized instance of
:class:`RevertWithConstantMethod`.
"""

simple_revert: SimpleRevertMethod
"""Constructor-initialized instance of
:class:`SimpleRevertMethod`.
"""

method_using_nested_struct_with_inner_struct_not_used_elsewhere: MethodUsingNestedStructWithInnerStructNotUsedElsewhereMethod
"""Constructor-initialized instance of
:class:`MethodUsingNestedStructWithInnerStructNotUsedElsewhereMethod`.
"""

nested_struct_output: NestedStructOutputMethod
"""Constructor-initialized instance of
:class:`NestedStructOutputMethod`.
"""

require_with_constant: RequireWithConstantMethod
"""Constructor-initialized instance of
:class:`RequireWithConstantMethod`.
"""

with_address_input: WithAddressInputMethod
"""Constructor-initialized instance of
:class:`WithAddressInputMethod`.
"""

struct_input: StructInputMethod
"""Constructor-initialized instance of
:class:`StructInputMethod`.
"""

non_pure_method: NonPureMethodMethod
"""Constructor-initialized instance of
:class:`NonPureMethodMethod`.
"""

complex_input_complex_output: ComplexInputComplexOutputMethod
"""Constructor-initialized instance of
:class:`ComplexInputComplexOutputMethod`.
"""

no_input_no_output: NoInputNoOutputMethod
"""Constructor-initialized instance of
:class:`NoInputNoOutputMethod`.
"""

simple_pure_function_with_input: SimplePureFunctionWithInputMethod
"""Constructor-initialized instance of
:class:`SimplePureFunctionWithInputMethod`.
"""

non_pure_method_that_returns_nothing: NonPureMethodThatReturnsNothingMethod
"""Constructor-initialized instance of
:class:`NonPureMethodThatReturnsNothingMethod`.
"""

simple_pure_function: SimplePureFunctionMethod
"""Constructor-initialized instance of
:class:`SimplePureFunctionMethod`.
"""

nested_struct_input: NestedStructInputMethod
"""Constructor-initialized instance of
:class:`NestedStructInputMethod`.
"""

method_returning_multiple_values: MethodReturningMultipleValuesMethod
"""Constructor-initialized instance of
:class:`MethodReturningMultipleValuesMethod`.
"""

method_returning_array_of_structs: MethodReturningArrayOfStructsMethod
"""Constructor-initialized instance of
:class:`MethodReturningArrayOfStructsMethod`.
"""

struct_output: StructOutputMethod
"""Constructor-initialized instance of
:class:`StructOutputMethod`.
"""

pure_function_with_constant: PureFunctionWithConstantMethod
"""Constructor-initialized instance of
:class:`PureFunctionWithConstantMethod`.
"""

simple_input_no_output: SimpleInputNoOutputMethod
"""Constructor-initialized instance of
:class:`SimpleInputNoOutputMethod`.
"""

overloaded_method2: OverloadedMethod2Method
"""Constructor-initialized instance of
:class:`OverloadedMethod2Method`.
"""

overloaded_method1: OverloadedMethod1Method
"""Constructor-initialized instance of
:class:`OverloadedMethod1Method`.
"""


def __init__(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,15 @@ def estimate_gas(self, x: int, tx_params: Optional[TxParams] = None) -> int:
class TestLibDummy:
"""Wrapper class for TestLibDummy Solidity contract."""
public_add_constant: PublicAddConstantMethod
"""Constructor-initialized instance of
:class:`PublicAddConstantMethod`.
"""

public_add_one: PublicAddOneMethod
"""Constructor-initialized instance of
:class:`PublicAddOneMethod`.
"""


def __init__(
self,
Expand Down
4 changes: 2 additions & 2 deletions python-packages/cmd_pkgs_in_dep_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
# independent first) in order for them to resolve properly.
"contract_addresses",
"contract_artifacts",
"contract_wrappers",
"json_schemas",
"sra_client",
"order_utils",
"sra_client",
"middlewares",
"contract_wrappers",
]

for package in PACKAGE_DEPENDENCY_LIST:
Expand Down
9 changes: 2 additions & 7 deletions python-packages/contract_wrappers/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# Changelog

## 2.0.0 - TBD
## 1.0.0 - TBD

- Completely new implementation of the Exchange wrapper, virtually all auto-generated from the Solidity contract. Breaking changes include method parameter name changes and accepting of signatures as bytes.
- Introduction of wrappers for all 0x contracts.

## 1.0.0 - 2019-04-30

- Initial release.
- Initial release
4 changes: 1 addition & 3 deletions python-packages/contract_wrappers/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,9 @@ def run(self):
"0x-contract-artifacts",
"0x-json-schemas",
"0x-order-utils",
"0x-web3",
"web3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

"attrs",
"eth_utils",
"hypothesis>=3.31.2", # HACK! this is web3's dependency!
# above works around https://github.com/ethereum/web3.py/issues/1179
"mypy_extensions",
],
extras_require={
Expand Down
Loading