-
Notifications
You must be signed in to change notification settings - Fork 419
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
Implement signRaw #196
Implement signRaw #196
Conversation
Thanks for doing this, this is a great addition. I will take a look in the next couple of hours. |
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.
Generally looks good, thank you very much for this. I only have some really small nitpick-y comments.
Code updated. Thanks for reviewing |
@jacogr I tested the implementation manually and fixed some issues |
Thanks for that, it is the only thing I was still missing to merge - I have it top of the list for the morning. (I am truly sorry for the long delay between the PR and merge here, not quite cool seeing thing stuck, so my humble apologies) |
Via this one, polkadot-js/apps#1936, the signature comes back as bytes instead of hex - It should be hex. (Just need to pass the response through u8aToHex) |
Updated |
Thank you. Will do the final play-through this morning, really excited to get this in. |
A couple of issues -
|
I have merged support for this on the apps UI, so this feature should be easier to test and explore now. |
WTF! So much problems. Sorry for the noise. |
This one is tough to test properly without having some way of well, testing :) So no reason to apologize, I also looked at the code and well, that looks good - however, you were playing in the depths of midnight, so those excursions are never easy. |
Indeed! These are good examples of a programmer's life |
|
||
sign (pair: KeyringPair): { signature: string } { | ||
const inner = this.inner as SignerPayloadRaw; | ||
const signedBytes = pair.sign(hexToU8a(inner.data)); |
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.
According to the SignerPayloadRawBase
contract,
export interface SignerPayloadRawBase {
/**
* @description The hex-encoded data for this request
*/
data: string;
/**
* @description The type of the contained data
*/
type?: 'bytes' | 'payload';
}
data
will always be hex, so it is up to the caller to pass valid data.
Also, type?: 'bytes' | 'payload';
doesn't make sense. One can simply const bytes = extrinsic.toU8a(true)
and signRaw(bytes)
. Can we remove it?
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.
The payload
was added specifically for other extensions, such as the centrality one - where they don't care about de-serliazing the payload, but rather just want to sign it as a raw blob. From an implementation perspective, both can just be treated as bytes
here, it does not need to be treated separately for the case where signRaw
is called.
The reason behind it - in case of transactions, the API will first try to use the normal payload sign, if that is not available will fallback to signRaw
. Since the normal sign path is catered for, we should not receive a payload in normal circumstances.
Either way, it it ever does receive a type: payload
it actually cannot quite decode it, since it is in a signable form, not a decodable form, so it should be treated it as a "piece of data". (There is a small trick here which came in with v4 where the signature needs to have type information attached in the case of a payload
, but we don't need to cater for it here in signRaw
)
TL;DR Ignore the type specifier on signRaw
, we can just treat all data
as bytes.
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.
Very interesting, thank you for writing this in an explanatory way
I'll need to take a peek again at the code here, since something is going wrong, either in the extension or somewhere along the way, i.e. possibly the UI doing something weird now that it has When submitting a transaction (verified against current, it doesn't happen), the transactions come through as "immortal", not "mortal with era", while the API def submits mortals. ... Update, after checking some more - the decoding is def. completely wrong, since here we have chain with version 195 and 194 displayed on the extension (in addition to the mortal being diaplyed as immortal being wrong) Not sure, will take a peek though both sides again. Additionally, the hex signing works, but I mucked-up the apps UI side for signing, i.e. when non-hex data inputted there, it doesn't send hex through. That needs a fix on that side, fix incoming. |
So the issue with transactions is twofold -
(Both these are verified on an older version as working on the same chain) I believe is is due to how inner is constructed. So rather,
With the above change reverted, at least the signing portion should still work, I'm trying to figure . out wht the |
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.
signRaw portion seems 100% now, however some small issues with transaction signing snuck in.
07a7240
to
1293466
Compare
Thank you ! Hope you are doing ok. |
Sorry, I'm very aware I need a play-through and review here ASAP. Just "a bit" snowed under after the Kusama CC3 launch. So need to, want to, I just have not had a gap. My humble apologies for dragging my feet, not out of choice. |
Don't worry about it, we all have stuff to do. Personally, you are one of the most attentive reviewers I have ever met |
I will take a play through today, thanks for the patience on this :( |
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.
Absolutely brilliant! Thanks a million for this, it does exactly what it says on the tin. Tested against CC3 with transfers, signing (bytes & strings), all 100% ok.
This is awesome! Thanks! |
@jacogr Do you know when will be next marketplace deployment? |
I will do it soon - I am just stuck with a nasty flu atm, so don’t quite trust a release process. So just need an update to latest Kusama CC3 and a full test through. I am hoping in the next couple of days (hopefully latest on Monday), I just need a clear head. ;) |
Flu catches us all. Hope you get better |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Fixes #115
With the following interface:
extension
package abstracts the signing procedure using thesign
method and becauseextension-ui
needs to be aware if it is dealing with an extrinsic or a bunch of bytes,inner
returns the inner payload content of its implementations.