Coder Social home page Coder Social logo

Comments (13)

JoshOrndorff avatar JoshOrndorff commented on August 28, 2024

This seems like a step toward re-inventing apps. Isn't the purpose of this template to be an example and starting point for writing dapp-specific UIs? If so the types for the dApp should be hard-coded, not exposed to the end user.

from substrate-front-end-template.

shawntabrizi avatar shawntabrizi commented on August 28, 2024

Could you explain the downside of including such a component?

I imagine it would be something that shows up on the "blockchain loading" screen, and where a UI might fail to load, instead it just works.

I imagine a use case for this to be when we might have a tutorial telling a user to go directly to: https://substrate.dev/substrate-ui-template/, since it is pre-hosted, and of course, we can't hard code every possible runtime in it

It also makes sense for when we add a selector to connect to different endpoints.

from substrate-front-end-template.

JoshOrndorff avatar JoshOrndorff commented on August 28, 2024

My concern is that it adds extra complexity, and may take away from the simple nature that the template has so far. When a developer forks the template UI to build their dapp-specific UI they will have to strip this feature out (or leave it in despite making the project larger).

Your last two points are good, but I it feels like using Apps (which already has both features) would be better.

from substrate-front-end-template.

shawntabrizi avatar shawntabrizi commented on August 28, 2024

@JoshOrndorff I think we should look at the implementation before we say if it is too complex. Statically defined types and dynamically defined types, to my understanding, can both be allowed.

Adding this component should not affect anything related to defining static types right now.

Further, a user who removes this component would have no behavioral changes around static types.

If you know something I don't about why this wouldnt be the case, please call that out explicitly.

from substrate-front-end-template.

shawntabrizi avatar shawntabrizi commented on August 28, 2024

I also think you need see that having a user "go to apps" is not always the right solution here.

Any tutorial where we need to introduce Apps, we also need to introduce how a user uses and interacts with Apps.

For example in the Kitties tutorial, we tell users to use apps for the first half of the tutorial, and then all of the sudden for UI development, they use an entirely different piece of software.

I am not saying that this is not a pattern which we will end up doing, certainly the UI Template will not be able to do everything the Apps can do, but if this enables us to avoid showing a user two UIs, and thus simplify the developer learning curve, then it is totally worth it.

from substrate-front-end-template.

ltfschoen avatar ltfschoen commented on August 28, 2024

This is a great template. I think the following improvements could be made:

  1. Update the Tutorial https://substrate.dev/docs/en/tutorials/substrate-front-end/ so it mentions that it's already setup for DApp devs to define their Custom Types in src/config/common.json or otherwise Chain State queries will return an error.
  2. Update this repo's README.md https://github.com/substrate-developer-hub/substrate-front-end-template/blob/master/README.md so there's an additional configuration step (i.e. configure Custom Types). So the steps would be Configure, Install, Start.
  3. Add a link from this repo to https://substrate.dev/docs/en/tutorials/substrate-front-end/
  4. Mention where it describes how to define Custom Types i.e. https://polkadot.js.org/api/start/types.extend.html

The reasoning for suggesting the above is summarised below based on my developer experience trying to integrate this front-end into my Substrate Kitties-like custom runtime.

I found out about this repo from the Riot chatrooms.
I just followed this README.md's instructions and started up the front-end (i.e. yarn; yarn start).
I then tried to create a kittie by creating an Extrinsic createKitty, which is where I encountered an error and raised this issue #46
But I modified the code to resolve the issue so I could create the kittie.
Then I wanted to view the kittie so I used the Chain State section of the UI to query kitties, but it didn't work.
So I knew I needed to add the Custom Types.
I then looked for where the Polkadot.js API connection was in the code and I found it in useSubstrate.js let _api = await ApiPromise.create({ provider, types });, so I just added my custom types there and it worked (even though I later found out that this wasn't necessary)
So I started creating a PR, thinking this should be a configuration option for DApp devs.
But then I found it already existed in the codebase within src/config/common.json, and all I had to do was add my Custom Types under "CUSTOM_TYPES", so the PR wasn't necessary

from substrate-front-end-template.

jimmychu0807 avatar jimmychu0807 commented on August 28, 2024

@ltfschoen See if the latest readme have addressed your four points.

And thanks for adding the Custom Type link :).

from substrate-front-end-template.

shawntabrizi avatar shawntabrizi commented on August 28, 2024

@jimmychu0807 do you think it would be possible for each component to have its own "type" configuration right in the file, which then feeds to the API?

from substrate-front-end-template.

jimmychu0807 avatar jimmychu0807 commented on August 28, 2024

Currently the ApiPromise is being called once only when the app is loaded. So without changing the logic, the "type" is going to be an aggregated whole of all possible "types" that are used by all components.

from substrate-front-end-template.

shawntabrizi avatar shawntabrizi commented on August 28, 2024

And when the app is loaded, we can't call into other components? I am of course inventing a feature, but it would be cool if each module template kept their types in their code/component file. Then the UI would just pull the type information from each file and combine it together.

from substrate-front-end-template.

jimmychu0807 avatar jimmychu0807 commented on August 28, 2024

I see. I think we can do it. So a component file also export out a customType, in addition to its component. And then in config/index.js to specify where these customType are defined, and then load and aggregate them together.

from substrate-front-end-template.

shawntabrizi avatar shawntabrizi commented on August 28, 2024

If it makes sense, it might be a cool idea to play around with, otherwise, we don't want to over engineer the substrate-front-end-template.

The ultimately goal is to keep things simple for the user to build on top of (and to understand to some extent). I am mostly talking aloud some ideas :)

from substrate-front-end-template.

jimmychu0807 avatar jimmychu0807 commented on August 28, 2024

@shawntabrizi Take a look at commit a599517. Is this what you mean by putting CUSTOM_TYPES inside the component?

But there is no good custom types in the template. So this code cannot be merged into master. I am just illustrating a pattern.

from substrate-front-end-template.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.