I have the following data type defined in my runtime module
#[derive(Encode, Decode, Clone, PartialEq, Debug)]
pub enum AuctionStatus {
Ongoing,
Cancelled,
ToBeClaimed,
Closed
}
// This is necessary so that other structs depend on this enum can be encode/decode with default value.
impl Default for AuctionStatus {
fn default() -> Self { AuctionStatus::Ongoing }
}
#[derive(Encode, Decode, Default, Clone, PartialEq, Debug)]
pub struct Auction<Hash, Balance, Moment, AuctionTx> {
id: Hash,
kitty_id: Hash,
base_price: Balance,
start_time: Moment,
end_time: Moment,
status: AuctionStatus,
tx: Option<AuctionTx>,
}
#[derive(Encode, Decode, Default, Clone, PartialEq, Debug)]
pub struct AuctionTx<Hash, AccountId, Balance, Moment> {
auction_id: Hash,
tx_time: Moment,
buyer: AccountId,
tx_price: Balance,
}
Now in polkadot UI, what should be the correct JSON type definition to be imported?
I tried the following but polkadotUI is still saying unknown type.
{
"AuctionStatus": "u32",
"AuctionTx": {
"auction_id": "Hash",
"tx_time": "Moment",
"buyer": "AccountId",
"tx_price": "Balance"
},
"Auction": {
"id": "Hash",
"kitty_id": "Hash",
"base_price": "Balance",
"start_time": "Moment",
"end_time": "Moment",
"status": "AuctionStatus",
"tx": "Option<AuctionTx>"
}
}
Update-01:
The following are the browser console error messages:
1st message:
Unable to decode storage catAuction.auctions: createType(Auction):: Encoding for input doesn't match output, created 0xa9531feb7f4eb8a888e1eedf72e812e26e32a53a2e379ef79bb2e8f7d883f2462e1cd9ea24d53ce565292a9e56458943554c7c13b6aef70c00079076650bdd8f983a0000000000000000000000000000f6491c5d0000000060ce1e5d00000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 from 0xa9531feb7f4eb8a888e1eedf72e812e26e32a53a2e379ef79bb2e8f7d883f2462e1cd9ea24d53ce565292a9e56458943554c7c13b6aef70c00079076650bdd8f983a0000000000000000000000000000f6491c5d0000000060ce1e5d000000000000
2nd message:
2019-07-03 14:24:40 RPC-CORE: subscribeStorage (keys: Vec<StorageKey>): StorageChangeSet:: createType(Auction):: Encoding for input doesn't match output, created 0xa9531feb7f4eb8a888e1eedf72e812e26e32a53a2e379ef79bb2e8f7d883f2462e1cd9ea24d53ce565292a9e56458943554c7c13b6aef70c00079076650bdd8f983a0000000000000000000000000000f6491c5d0000000060ce1e5d00000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 from 0xa9531feb7f4eb8a888e1eedf72e812e26e32a53a2e379ef79bb2e8f7d883f2462e1cd9ea24d53ce565292a9e56458943554c7c13b6aef70c00079076650bdd8f983a0000000000000000000000000000f6491c5d0000000060ce1e5d000000000000
not sure if this give any help...
I think the problem here is you have defined your enum as a u32
and it is messing up parsing the encoded data.
From the Polkadot UI help text:
Be aware that the types are registered in the order they appear here. Since Transaction above requires both TransactionInput and TransactionOutput it is defined after the definitions for those are available. (Circular deps are not supported here). For a slightly more complex example, using both types and enums, the following would be used -
{ "SimpleEnum": { "_enum": ["One", "Two", "Three"] }, "TypeEnum": { "_enum": { "One": "u32", "Two": "u64", "Three": null } }. "MyNumber": "u32", "Thing": { "count_enum": "SimpleEnum", "type_enum": "TypeEnum", "counter": "MyNumber", "ids": "Vec<AccountId>" }, "ArrayThing": "Vec<Thing>" }
So try defining your enum correctly and see if that resolves your issue. Let me know if this helps.