Comments (13)
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.
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.
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.
@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.
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.
This is a great template. I think the following improvements could be made:
- 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.
- 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.
- Add a link from this repo to https://substrate.dev/docs/en/tutorials/substrate-front-end/
- 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.
@ltfschoen See if the latest readme have addressed your four points.
And thanks for adding the Custom Type link :).
from substrate-front-end-template.
@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.
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.
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.
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.
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.
@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)
- README : polkadot.js.org url's are outdated
- Styling forced from substratecontextprovider HOT 4
- Having problems encoding the address chain format HOT 1
- start fail
- Cannot find module 'worker_threads' HOT 1
- Investigate why numerous websocket connections are open HOT 1
- StorageDoubleMap Pallet Interactor second key input not present HOT 1
- BUG: Build is not happening with latest node and yarn version HOT 11
- Error of PoE: Failed to compile: ./src/TemplateModule.js: Attempted import error: 'useSubstrateState' is not exported from './substrate-lib'.
- Start the front-end template : error:0308010C:digital envelope routines::unsupported HOT 2
- Cryptokitties api arguments type mismatch Expected at least 32 bytes (256 bits), found 16 byte HOT 2
- Hosted endpoint wss://dev-node.substrate.dev mentioned in docs not working
- Update react hook in proof of existence solution branch.
- NEXT.JS Front end template HOT 1
- Full Support for Typescript HOT 1
- yarn start not working HOT 7
- Unable to have optional params in Query calls HOT 2
- Should This Repository Be Archived? HOT 2
- Transfer of tokens don't work HOT 6
- Trouble Registering Events in Substrate Tutorial's Frontend Transaction: Need Assistance HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from substrate-front-end-template.