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

Reading/Writing Features #123

Merged
merged 47 commits into from
Nov 10, 2023
Merged

Reading/Writing Features #123

merged 47 commits into from
Nov 10, 2023

Conversation

DOBEN
Copy link
Member

@DOBEN DOBEN commented Oct 12, 2023

Purpose

closes #127

  • Add a feature to read from smart contract
  • Add a feature to write to smart contract

Changes

  • Add a box to read from the smart contract (either the user can manually fill in all input fields of that box or the user can only input the smart contract index and derive most of the values by checking the "Derive From Smart Contract Index" checkbox)
  • Add a box to write to the smart contract (either the user can manually fill in all input fields of that box or the user can only input the smart contract index and derive most of the values by checking the "Derive From Smart Contract Index" checkbox)

Copy link
Contributor

@soerenbf soerenbf left a comment

Choose a reason for hiding this comment

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

Here are some things to consider.

  • No wallet connect support? Is this intentional or something we plan to introduce (since we use @concordium/react-components)?
  • As users can now do more stuff than deploy/init contracts, it would make sense to think about user flows (in my opinion)
    • I would also introduce a router (react-router), as it lets you be more declarative about individual sections of the application, with the added benefit of persisting the location in the url along with associated state. This will allow users to use browser navigation (back/forward) to navigate the app + link to selected parts of the application, which might be useful.

Possible application routes (marked with bold)

  • / (root = Deploy/declare module)
    • /module/:module-reference
      • Instantiate contract
  • /instance
    • Declare contract details (can we just always derive contract name and possible entrypoints if possible?)
    • /instance/:index/read (do we need subindex?)
    • /instance/:index/write (do we need subindex?)

I realize these changes are quite substantial, but will improve usability a lot.

front-end-tools/src/index.css Outdated Show resolved Hide resolved
front-end-tools/src/Main.tsx Show resolved Hide resolved
front-end-tools/src/writing_to_blockchain.ts Show resolved Hide resolved
@DOBEN
Copy link
Member Author

DOBEN commented Nov 1, 2023

Makes sense. With regards to the 2-step flow, it's possible to use browser location state, which can also be restored on back/forward browser navigation.

Anyway it would be nice if you could add an issue for this refactoring 🙂

#130

@DOBEN DOBEN requested a review from soerenbf November 3, 2023 11:39
Copy link
Contributor

@abizjak abizjak left a comment

Choose a reason for hiding this comment

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

Looks pretty good overall.

I have some relatively minor comments.

There is one general thing about the UI, but also some details of the flows could be revised a bit.

But we don't have time to spend on fiddling with that at the moment. This can be part of the next iteration.

front-end-tools/src/components/Box.tsx Show resolved Hide resolved
front-end-tools/src/components/CCDScanLinks.tsx Outdated Show resolved Hide resolved
front-end-tools/src/components/DeployComponent.tsx Outdated Show resolved Hide resolved
front-end-tools/src/components/DeployComponent.tsx Outdated Show resolved Hide resolved
front-end-tools/src/constants.ts Show resolved Hide resolved
front-end-tools/src/reading_from_blockchain.ts Outdated Show resolved Hide resolved
front-end-tools/src/reading_from_blockchain.ts Outdated Show resolved Hide resolved
front-end-tools/src/writing_to_blockchain.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@soerenbf soerenbf left a comment

Choose a reason for hiding this comment

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

I still think it's worthwhile to look into the structure of these inputs that trigger other changes (effects or derived values), which is my main issue with the code as it is right now.

I would prefer if we stuck with the recommendations from the documentation of the forms library, which revolve around

  • spread form.register onto input
  • use Controller to integrate with controlled field components
  • use validation rules and associated error messages registered
  • use useWatch to handle complicated derived values or effects

front-end-tools/src/Main.tsx Show resolved Hide resolved
front-end-tools/src/Main.tsx Show resolved Hide resolved
front-end-tools/src/components/DeployComponent.tsx Outdated Show resolved Hide resolved
front-end-tools/src/components/WriteComponent.tsx Outdated Show resolved Hide resolved
front-end-tools/src/components/WriteComponent.tsx Outdated Show resolved Hide resolved
front-end-tools/src/components/WriteComponent.tsx Outdated Show resolved Hide resolved
front-end-tools/src/components/WriteComponent.tsx Outdated Show resolved Hide resolved
front-end-tools/src/components/WriteComponent.tsx Outdated Show resolved Hide resolved
@DOBEN DOBEN requested review from abizjak and soerenbf November 8, 2023 17:03
Copy link
Contributor

@soerenbf soerenbf left a comment

Choose a reason for hiding this comment

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

Tested the different parts of the app again, and experienced this discrepancy:

Screenshot 2023-11-09 at 09 40 38

If you want the concrete module deployed, I can send it to you.

Other than that, I don't have any more comments if all the optimizations with regards to using the forms library are pushed to sometime in the future.

Copy link
Contributor

@abizjak abizjak left a comment

Choose a reason for hiding this comment

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

There are still some issues (see video shared in slack).

But if those are resolved I think we should merge this.

While I understand @soerenbf 's concerns, we also have to get this done.

We'll have to prioritize handling the backlog later, since we have other things we need to be working on as well. It's good there is an issue with all the concerns listed.

front-end-tools/src/components/DeployComponent.tsx Outdated Show resolved Hide resolved
front-end-tools/src/components/InitComponent.tsx Outdated Show resolved Hide resolved
@DOBEN DOBEN force-pushed the reading-writing-features branch from 5be5c38 to a17f5fb Compare November 9, 2023 12:38
@DOBEN DOBEN requested a review from soerenbf November 9, 2023 12:47
@DOBEN DOBEN force-pushed the reading-writing-features branch from 2975400 to 4ef17b4 Compare November 10, 2023 08:12
@DOBEN DOBEN merged commit 0d601b2 into main Nov 10, 2023
@DOBEN DOBEN deleted the reading-writing-features branch November 10, 2023 08:15
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.

Add read from (and write to) smart contract feature to hosted deploy/initialize front end
3 participants