Closed AurevoirXavier closed 2 years ago
That is the UI rendering component - it doesn't render aye + conviction, it only renders the "aye". (It is a limited override only)
That is the UI rendering component - it doesn't render aye + conviction, it only renders the "aye". (It is a limited override only)
I can't vote on my chain. But it was worked a few days ago. https://polkadot.js.org/apps/?rpc=wss://pangolin-rpc.darwinia.network#/democracy
react.01.387c2759.js:2 Uncaught Error: createType(Call):: Call: failed decoding democracy.vote:: Struct: failed on args: {"ref_index":"Compact<u32>","vote":"{\"_enum\":{\"Standard\":\"{\\\"vote\\\":\\\"u8\\\",\\\"balance\\\":\\\"u128\\\"}\",\"Split\":\"{\\\"aye\\\":\\\"u128\\\",\\\"nay\\\":\\\"u128\\\"}\"}}"}:: Struct: failed on vote: {"_enum":{"Standard":"{\"vote\":\"u8\",\"balance\":\"u128\"}","Split":"{\"aye\":\"u128\",\"nay\":\"u128\"}"}}:: Enum(Standard):: Struct: failed on vote: u8:: Assertion failed
I can vote from extrinsic.
I check the democracy pallet, I didn't find any new updates. Why Polkadot's component is different from ours?
In the case of the Substrate-standard AccountVote
metadata type path the vote
value is aliased to a type that can do the aye
+ conviction
encoding into a single u8
instead of every user having to encode that manually.
It implements the specialized encoding as found in Rust -
/// A number of lock periods, plus a vote, one way or the other.
#[derive(Copy, Clone, Eq, PartialEq, Default, RuntimeDebug, MaxEncodedLen)]
pub struct Vote {
pub aye: bool,
pub conviction: Conviction,
}
impl Encode for Vote {
fn encode_to<T: Output + ?Sized>(&self, output: &mut T) {
output.push_byte(u8::from(self.conviction) | if self.aye { 0b1000_0000 } else { 0 });
}
}
Applied wildcard matching on metadata type names in https://github.com/polkadot-js/api/pull/4741 - however this is a dangerous path, so would need to see the impact. (So it may be reverted if it "breaks the world" due to over-zealous matching)
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.
Why the standard vote's first param is a bool?
It looks like you are usingVote
instead ofAccountVote
.https://github.com/paritytech/substrate/blame/master/frame/democracy/src/vote.rs#L70-L76https://github.com/paritytech/substrate/blame/master/frame/democracy/src/vote.rs#L29-L34And the call needsAccountVote
.https://github.com/paritytech/substrate/blob/master/frame/democracy/src/lib.rs#L700