Closed athei closed 1 year ago
Hmm yes that could work. This whole solution seems a bit hacky. Even without the wrapper type. But I guess our only way to get this in without introducing a whole new way of just expressing types into the metadata.
Implemented your idea. Seems to be working. This is the output. I think we can work with that:
{
"id": 576,
"type": {
"path": [
"pallet_contracts",
"Environment"
],
"params": [
{
"name": "T",
"type": null
}
],
"def": {
"composite": {
"fields": [
{
"name": "account_id",
"type": 577,
"typeName": "EnvironmentType<AccountIdOf<T>>"
},
{
"name": "balance",
"type": 578,
"typeName": "EnvironmentType<BalanceOf<T>>"
},
{
"name": "hash",
"type": 579,
"typeName": "EnvironmentType<<T as frame_system::Config>::Hash>"
},
{
"name": "hasher",
"type": 580,
"typeName": "EnvironmentType<<T as frame_system::Config>::Hashing>"
},
{
"name": "timestamp",
"type": 582,
"typeName": "EnvironmentType<MomentOf<T>>"
},
{
"name": "block_number",
"type": 583,
"typeName": "EnvironmentType<BlockNumberFor<T>>"
}
]
}
}
}
},
{
"id": 577,
"type": {
"path": [
"pallet_contracts",
"EnvironmentType"
],
"params": [
{
"name": "T",
"type": 0
}
],
"def": {
"composite": {}
}
}
},
{
"id": 578,
"type": {
"path": [
"pallet_contracts",
"EnvironmentType"
],
"params": [
{
"name": "T",
"type": 6
}
],
"def": {
"composite": {}
}
}
},
{
"id": 579,
"type": {
"path": [
"pallet_contracts",
"EnvironmentType"
],
"params": [
{
"name": "T",
"type": 12
}
],
"def": {
"composite": {}
}
}
},
{
"id": 580,
"type": {
"path": [
"pallet_contracts",
"EnvironmentType"
],
"params": [
{
"name": "T",
"type": 581
}
],
"def": {
"composite": {}
}
}
},
Hmm yes that could work. This whole solution seems a bit hacky. Even without the wrapper type. But I guess our only way to get this in without introducing a whole new way of just expressing types into the metadata.
A little bit hacky, perhaps. But a very neat way of getting the information we need into the metadata without adding any additional configuration schema. Of course the downstream tooling will need to do some explicit name lookups to pull out the types, but I think it might be worth it to keep things simple on the node side.
bot rebase
Rebased
Please also approve the companion.
bot rebase
Rebased
bot merge
In order to implement https://github.com/paritytech/cargo-contract/issues/1167 we need to expose all types passed between
pallet-contracts
and the deployed contracts. The idea is to bundle all relevant types in anEnvironment
struct mirroring the ink!Environment
type. In order to expose it we add it to the config trait asGet<Environment>
. The types are obviously only mentioned asPhantomData
because we don't ever want to construct them. I did just this in this PR.I think this would be an elegant solution if it wouldn't be for https://github.com/paritytech/scale-info/pull/111. @ascjones Can we maybe add an attribute to
scale-info
that allows to opt-in toPhantomData
types?cc @SkymanOne
cumulus companion: https://github.com/paritytech/cumulus/pull/3036