-
Notifications
You must be signed in to change notification settings - Fork 443
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
Rework the Environment
trait
#1303
Comments
I really don't like this approach. Part of the point of using Substrate is that things are generic and they can be swapped out easily. Having people fork a crate only to swap some types around seems like unnecessary overhead |
It is that I'm suggesting!=) Only maintainers of the network should fork crate and specify new types. The developers only should add two lines in Right now, if you have contracts that use But what approach adds more overhead? The approach where 10k developers should propagate I like the idea of using generics in the Substrate. And I like generics in Rust=) But smart contracts are about easy development and faster deployment. You don't need to be a guru of Rust to write a smart contract otherwise, I can use Substrate=D |
In other words, they are global types for the whole parachain's smart contract ecosystem. But in that way, they still are generic because you can replace them to work with specific parachain. With substrate, one relay chain contains many parachain, and each parachain has its |
Personally I'd prefer to just fix AccountId to AccountId32 and Balance to u128. Substrate is already built to allow customization. What we need more is an unified ecosystem that can interoperate. |
Added an example to show how it could work and how it is easy to do on the developer side=) |
It is possible to customize
AccountId
,Timestamp
,Balance
,Hash
,Gas
,BlockNumber
types on thecontract-pallet
side. So different parachain can use different types inside.To support it and be agnostic to the parachain/blockchain ink! provides
Environment
trait that is automatically implemented by the contract withDefaultEnvironment
or can be customized with its own environment via#[ink::contract(env = CustomEnvironment)]
.The problem with that approach is:
Env
generic via the whole stack.ParachainAEnvironment
and another -ParachainBEnvironment
.We are proposing another approach:
Create a separate crate like
ink_types
that will contain definitions of all customizable items(better put it in a separate repository). It can be, for example, that file.ink_env
crate usesink_types
to get all requires types:And use a default configuration.
If some parachain/blockchain want to use custom types, they fork the repository and use
[patch.crates-io]
to override default types.or
So the destination contract decides that types use across all dependencies. It solves all problems described above. If someone wants to deploy the contract to parachain/blockchain with the custom environment he only needs to add 2 lines in his
Cargo.toml
.The text was updated successfully, but these errors were encountered: