-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Metadata V15: Enrich extrinsic type info for decoding #14123
Changes from 13 commits
da550a7
a51ea7b
888ce4a
49995b4
0babb53
768c515
ab66814
52f1480
6610ac2
25617e0
10bbe10
b823f5c
a94cd09
1f17361
86e39c1
903ebd7
37f6a09
16b81b6
cd5c0a3
60db7bc
6e4f749
0ad90f3
7d55ba1
03383be
0e87313
2c307b8
e183783
1747586
9fd69cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,13 +106,20 @@ impl<Address, Call, Signature, Extra: SignedExtension> Extrinsic | |
{ | ||
type Call = Call; | ||
|
||
type SignaturePayload = (Address, Signature, Extra); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ahh, it is being done already 🙈 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case, a |
||
type SignatureAddress = Address; | ||
|
||
type Signature = Signature; | ||
|
||
type SignatureExtra = Extra; | ||
|
||
fn is_signed(&self) -> Option<bool> { | ||
Some(self.signature.is_some()) | ||
} | ||
|
||
fn new(function: Call, signed_data: Option<Self::SignaturePayload>) -> Option<Self> { | ||
fn new( | ||
function: Call, | ||
signed_data: Option<(Self::SignatureAddress, Self::Signature, Self::SignatureExtra)>, | ||
) -> Option<Self> { | ||
Some(if let Some((address, signature, extra)) = signed_data { | ||
Self::new_signed(function, address, signature, extra) | ||
} else { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -961,12 +961,20 @@ pub trait Extrinsic: Sized { | |
/// The function call. | ||
type Call; | ||
|
||
/// The payload we carry for signed extrinsics. | ||
/// The type of the address that signed the extrinsic. | ||
/// | ||
/// Usually it will contain a `Signature` and | ||
/// may include some additional data that are specific to signed | ||
/// extrinsics. | ||
type SignaturePayload; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of breaking most of the code we could just do
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, I like this approach more! Thanks for the feedback! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bkchr What's your opinion on having the We should have enough type info by relying on:
The That is unless we'll break other things There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no idea if someone is using this. However, frankly speaking by only having the types you listed you don't know the encoding of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea! I'll add the The type only contained the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. iirc the extrinsic type was quite useless anyway before; it mostly just said "hey we want to encode the extrinsic to some vec of bytes". It doesn't provide any useful information on how those bytes need to be formed etc. There are already a bunch of things we must just assume already about encoding extrinsics, ie the order of the signature stuff, how the not-really-scale Option for the signature is encoded (ie it has a version number The metadata, in my mind, only needs to provide the information that might vary from chain to chain (eg the actual additional params etc). This tx version can encode the actual format that this stuff is turned into an extrinsic. All of this to say, what would adding a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Good point.
Just because every body is currently using our |
||
/// Particular to a signed extrinsic. | ||
type SignatureAddress; | ||
|
||
/// The signature type of the extrinsic. | ||
/// | ||
/// Particular to a signed extrinsic. | ||
type Signature; | ||
|
||
/// The additional data that is specific to the signed extrinsic. | ||
/// | ||
/// Particular to a signed extrinsic. | ||
type SignatureExtra; | ||
|
||
/// Is this `Extrinsic` signed? | ||
/// If no information are available about signed/unsigned, `None` should be returned. | ||
|
@@ -980,7 +988,10 @@ pub trait Extrinsic: Sized { | |
/// 1. Inherents (no signature; created by validators during block production) | ||
/// 2. Unsigned Transactions (no signature; represent "system calls" or other special kinds of | ||
/// calls) 3. Signed Transactions (with signature; a regular transactions with known origin) | ||
fn new(_call: Self::Call, _signed_data: Option<Self::SignaturePayload>) -> Option<Self> { | ||
fn new( | ||
_call: Self::Call, | ||
_signed_data: Option<(Self::SignatureAddress, Self::Signature, Self::SignatureExtra)>, | ||
) -> Option<Self> { | ||
None | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get why we have to break down
SignaturePayload
? can't this haveTypeInfo
itself?And if it is being broken down and not used, I rather actually delete
SignaturePayload
if it is not being used anymore.