Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update contract docs to use compile_standard #1263

Merged
merged 1 commit into from
May 2, 2019

Conversation

ammarqureshi
Copy link
Contributor

What was wrong?

The contract deployment example is using compile_source which is no longer fully supported as mentioned in this issue

How was it fixed?

By replacing compile_source with compile_standard as mentioned by @kclowes #1245

Cute Animal Picture

30260317720_91d483dfe7_z

Copy link
Collaborator

@kclowes kclowes left a comment

Choose a reason for hiding this comment

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

This is looking great, @ammarqureshi! Thank you. If possible, I think it would be a good idea to doctest this so that we know if it's not working like it should. There is an example of a doctest in docs/web3.eth.account.rst around line 84. Let me know if you have questions!

"sources": {
"Greeter.sol": {
"content": '''
pragma solidity ^0.5.0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we move this content so that it is indented 4 spaces under content please?

@@ -68,13 +91,13 @@ To run this example, you will need to install a few extra features:

# Create the contract instance with the newly-deployed address
greeter = w3.eth.contract(
address=tx_receipt.contractAddress,
abi=contract_interface['abi'],
address=tx_receipt.contractAddress,
Copy link
Collaborator

Choose a reason for hiding this comment

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

this needs to be indented too please

)

# Display the default greeting from the contract
print('Default contract greeting: {}'.format(
greeter.functions.greet().call()
greeter.functions.greet().call()
Copy link
Collaborator

Choose a reason for hiding this comment

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

whitespace :)

@@ -85,9 +108,13 @@ To run this example, you will need to install a few extra features:

# Display the new greeting value
print('Updated contract greeting: {}'.format(
greeter.functions.greet().call()
greeter.functions.greet().call()
Copy link
Collaborator

Choose a reason for hiding this comment

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

whitespace :)

))

# When issuing a lot of reads, try this more concise reader:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Lines 114-116 should be removed. We are no longer encouraging the use of ConciseContract in v5

Copy link
Collaborator

@kclowes kclowes left a comment

Choose a reason for hiding this comment

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

Thanks for addressing my comments, @ammarqureshi! It looks like you branched off of an old version of master. It would be a good idea to pull in the most recent master. Anything that references ConciseContract should be removed. Let me know if you need help determining what should stay.

You can see the docs and run the tests from the command line by running:
make docs.

Let me know if you need more direction!

docs/contracts.rst Show resolved Hide resolved

# get abi
abi = json.loads(compiled_sol['contracts']['Greeter.sol']['Greeter']['metadata'])['output']['abi']

Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like you're missing a few lines here:

    Greeter = w3.eth.contract(abi=abi, bytecode=bytecode)
    # Submit the transaction that deploys the contract
    tx_hash = Greeter.constructor().transact()
    # Wait for the transaction to be mined, and get the transaction receipt
    tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash)

reader = ConciseContract(greeter)
assert reader.greet() == "Nihao"

.. testsetup::
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be .. doctest:: so that users will be able to see it. .. testsetup:: blocks are not shown in the docs. There should be no whitespace in front of the dots.

@kclowes
Copy link
Collaborator

kclowes commented Apr 4, 2019

@ammarqureshi are you still interested in completing this?

@kclowes
Copy link
Collaborator

kclowes commented May 2, 2019

I ran into problems installing the solidity compiler on CircleCI, so I am going to leave doctesting out for this particular example.

@kclowes kclowes merged commit 27851ce into ethereum:master May 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants