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

Document Ether.js for asset hub smart contracts #295

Open
wants to merge 24 commits into
base: staging-ah-smart-contracts
Choose a base branch
from

Conversation

nhussein11
Copy link
Collaborator

@nhussein11 nhussein11 commented Jan 6, 2025

This PR aims to add a basic documentation of ether.js to showcase the interaction with asset hub smart contracts

Note: The IA used is preliminary. We can circle back on this later on and define where all this content should be located

@nhussein11 nhussein11 requested a review from a team as a code owner January 6, 2025 17:17
@nhussein11 nhussein11 linked an issue Jan 6, 2025 that may be closed by this pull request
develop/toolkit/api-libraries/smart-contracts/ether-js.md Outdated Show resolved Hide resolved
develop/toolkit/api-libraries/smart-contracts/ether-js.md Outdated Show resolved Hide resolved

Ensure you replace the `INSERT_MNEMONIC`, `INSERT_CONTRACT_ADDRESS` and `INSERT_ADDRESS_TO_CHECK` placeholders with actual values. Also, the contract ABI file (`Storage.json`) should be correctly referenced.

## Conclusion
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we can add a follow up to the REMIX IDE as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, we can add REMIX IDE as a follow-up, but I see Remix more as a development environment. Ideally, we should link to some ethers.js tutorial that demonstrates how to implement a project using ethers.js. What do you think @CrackTheCode016 ?

In any case, those two options would be tasks to add later on.

develop/toolkit/api-libraries/smart-contracts/ether-js.md Outdated Show resolved Hide resolved
develop/toolkit/api-libraries/smart-contracts/ether-js.md Outdated Show resolved Hide resolved
@nhussein11 nhussein11 changed the base branch from master to staging-ah-smart-contracts January 7, 2025 15:29
Copy link
Contributor

@kianenigma kianenigma left a comment

Choose a reason for hiding this comment

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

The code snippets in this chapter are good examples to already be included in our strategy to be test-able right of the bat. We don't need to do it now, but cc-ing @UtkarshBhardwaj007 for discussion.

Note that my push to make things test-able will also force us all to use these tools e2e, which is good.

Similar to the rust setup, we can bundle such codes into a single NPM project for each chapter. npm run run or similar should run a test script that would execute the flow e2e, and check the output.

Some notes about how to achieve this:

  • We would need to rely on the console logs, capture them, and assert on them. For example, in this example, we should expect "Retrieved stored number: 42" to be in the logs
  • We would need one seed account's private key to be stored in our gh as a secret with a lot of WND. This account can be used both for our manual testing, and in a CI to run this flow
  • We should destroy the contract post test every time

Having written the above, it seems to me that this is non-trivial but achievable, so I won't necessarily suggest it now, but we should start thinking about it.

@UtkarshBhardwaj007
Copy link
Collaborator

The code snippets in this chapter are good examples to already be included in our strategy to be test-able right of the bat. We don't need to do it now, but cc-ing @UtkarshBhardwaj007 for discussion.

Note that my push to make things test-able will also force us all to use these tools e2e, which is good.

Similar to the rust setup, we can bundle such codes into a single NPM project for each chapter. npm run run or similar should run a test script that would execute the flow e2e, and check the output.

Some notes about how to achieve this:

  • We would need to rely on the console logs, capture them, and assert on them. For example, in this example, we should expect "Retrieved stored number: 42" to be in the logs
  • We would need one seed account's private key to be stored in our gh as a secret with a lot of WND. This account can be used both for our manual testing, and in a CI to run this flow
  • We should destroy the contract post test every time

Having written the above, it seems to me that this is non-trivial but achievable, so I won't necessarily suggest it now, but we should start thinking about it.

Agreed. I don't want to block this PR but a suggestion would be to write code that builds. Since we are creating tutorials, we could follow them to write code that actually builds and later on, as part of this issue we can add tests to ensure that the code remains valid as testing (like you pointed out @kianenigma ) might be non-trivial. I am working on the rust code in the tutorials atm. I will pickup the node based code after that.

@nhussein11 nhussein11 requested a review from 0xLucca January 8, 2025 17:41
nhussein11 and others added 8 commits January 9, 2025 08:53
Co-authored-by: 0xLucca <95830307+0xLucca@users.noreply.github.com>
Co-authored-by: 0xLucca <95830307+0xLucca@users.noreply.github.com>
Co-authored-by: 0xLucca <95830307+0xLucca@users.noreply.github.com>
@nhussein11 nhussein11 requested a review from 0xLucca January 9, 2025 14:43
@nhussein11 nhussein11 added the B0 - Needs Review Pull request is ready for review label Jan 9, 2025
Copy link
Collaborator

@0xLucca 0xLucca left a comment

Choose a reason for hiding this comment

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

LGTM!

@eshaben eshaben added the C1 - Medium Medium priority task label Jan 13, 2025
@eshaben eshaben added the A0 - New Content Pull request contains new content pages label Jan 13, 2025
@eshaben eshaben requested a review from dawnkelly09 January 17, 2025 07:53
Copy link
Collaborator

@dawnkelly09 dawnkelly09 left a comment

Choose a reason for hiding this comment

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

Needs a little love to give a more polished feel. Thank you!

develop/toolkit/api-libraries/smart-contracts/ethers-js.md Outdated Show resolved Hide resolved
develop/toolkit/api-libraries/smart-contracts/ethers-js.md Outdated Show resolved Hide resolved
develop/toolkit/api-libraries/smart-contracts/ethers-js.md Outdated Show resolved Hide resolved
develop/toolkit/api-libraries/smart-contracts/ethers-js.md Outdated Show resolved Hide resolved
develop/toolkit/api-libraries/smart-contracts/ethers-js.md Outdated Show resolved Hide resolved
develop/toolkit/api-libraries/smart-contracts/ethers-js.md Outdated Show resolved Hide resolved
develop/toolkit/api-libraries/smart-contracts/ethers-js.md Outdated Show resolved Hide resolved
develop/toolkit/api-libraries/smart-contracts/ethers-js.md Outdated Show resolved Hide resolved
develop/toolkit/api-libraries/smart-contracts/ethers-js.md Outdated Show resolved Hide resolved
develop/toolkit/api-libraries/smart-contracts/ethers-js.md Outdated Show resolved Hide resolved
@nhussein11
Copy link
Collaborator Author

@dawnkelly09 I've addressed your comments and I also aligned this branch with the (temporal) architecture present in https://github.com/polkadot-developers/polkadot-docs/tree/staging-ah-smart-contracts. This should be ready for final review now

@dawnkelly09
Copy link
Collaborator

@dawnkelly09 I've addressed your comments and I also aligned this branch with the (temporal) architecture present in https://github.com/polkadot-developers/polkadot-docs/tree/staging-ah-smart-contracts. This should be ready for final review now

When I spun this up locally, the ethers.js page only renders the title and the feedback stuff. It's weird.
ethers1

@nhussein11
Copy link
Collaborator Author

@dawnkelly09 I've addressed your comments and I also aligned this branch with the (temporal) architecture present in https://github.com/polkadot-developers/polkadot-docs/tree/staging-ah-smart-contracts. This should be ready for final review now

When I spun this up locally, the ethers.js page only renders the title and the feedback stuff. It's weird. ethers1

Should be fixed in 103fa77

Copy link
Collaborator

@dawnkelly09 dawnkelly09 left a comment

Choose a reason for hiding this comment

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

A few formatting nits plus one broken link. Thanks!

TODO: complete this index page
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sooo....we fixing this index page or nah? Obviously I don't want to merge it like this ;-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Mmm idk, to be honest. Since we are merging this into a branch that has a temporary Information Architecture (see this comment #300 (comment)), many things will probably change, particularly regarding indexes and so on.

I was considering making a separate PR when we have the final IA to update not only the website structure but also the index pages. WDYT, @dawnkelly09?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, if this is going to staging first that's probably ok. We just have to make sure there is a final check on TODOs before we move out of staging and deploy.

develop/smart-contracts/evm-toolkit/libraries/ethers-js.md Outdated Show resolved Hide resolved
develop/smart-contracts/evm-toolkit/libraries/ethers-js.md Outdated Show resolved Hide resolved
develop/smart-contracts/evm-toolkit/libraries/ethers-js.md Outdated Show resolved Hide resolved
develop/smart-contracts/evm-toolkit/libraries/ethers-js.md Outdated Show resolved Hide resolved
nhussein11 and others added 2 commits January 20, 2025 17:02
Co-authored-by: Dawn Kelly <83190195+dawnkelly09@users.noreply.github.com>
Copy link
Collaborator

@dawnkelly09 dawnkelly09 left a comment

Choose a reason for hiding this comment

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

Approved for staging but needs work on index page(s) before it can be deployed publicly.

@nhussein11 nhussein11 added B1 - Ready to be Merged Pull request is ready to be merged and removed B0 - Needs Review Pull request is ready for review labels Jan 22, 2025
Copy link
Collaborator

@eshaben eshaben left a comment

Choose a reason for hiding this comment

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

One thing to consider is putting the variables at the top of the files, so users when they first look at the code snippets, they instantly see that they need to update those

develop/smart-contracts/evm-toolkit/libraries/ethers-js.md Outdated Show resolved Hide resolved
develop/smart-contracts/.pages Outdated Show resolved Hide resolved
Co-authored-by: Erin Shaben <eshaben@icloud.com>
@nhussein11 nhussein11 requested a review from eshaben January 23, 2025 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A0 - New Content Pull request contains new content pages B1 - Ready to be Merged Pull request is ready to be merged C1 - Medium Medium priority task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Explore and document Ethers.js
7 participants