-
Notifications
You must be signed in to change notification settings - Fork 157
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
fix: Use correct registry when creating calls; Remove usage of derive.chain.getBlock #391
Conversation
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.
However, for some reason none of the Codec objects returned from the derive call have a type registry dated to the call
Should we open an issue here (or on pd.js?) to dig into this further?
const authorId = sessionValidators | ||
? this.extractAuthor(sessionValidators, digest) | ||
: undefined; |
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.
What does extractAuthor
return? If it returns undefined
this ternary isn't needed.
const authorId = sessionValidators | |
? this.extractAuthor(sessionValidators, digest) | |
: undefined; | |
const authorId = this.extractAuthor(sessionValidators, digest); |
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.
We just need something so TS does not complain since it knows sessionValidators may be undefined.
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.
eew, so you're saying we must do like const authorId = this.extractAuthor(sessionValidators, digest) || undefined;
just to appease the compiler? :/
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.
Yeah, but we need to check before we call extractAuthor
, because extractAuthor
requires that the type of the sessionValidators
param be Array<AccountId>
. I agree with the compiler here because sending down undefined
where only an array is expected could lead to issues at runtime.
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 see what you mean. But is it not an error if sessionValidators
is undefined
(or an empty array)? Like, shouldn't we bail before we get here if that's the case?
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.
LGTM!
Closes #384
In #351, I removed the querys
api.query.session.validators
&api.rpc.getBlock
. Additionally I removedBlocksService. extractAuthor
. I replaced all of them withapi.derive.chain.getBlock
, which neatly gave us theauthorId
in addition to theblock
. (Opposed to having to use the validators and digest logs to extract the authorId)However, for some reason none of the
Codec
objects returned from the derive call have a type registry dated to the call, instead they have what seems to be the most recent type registry. The effect of this is that when we try to createCall
s that are not in the most recent metadata we get a call not found error. To solver this issue I have brought back the aforementioned code that I removed and use the type registry attached to the blockI experimented with other options like using the type registry on the block hash passed down from the controller, but that had the same issue. We also can't use the events because we do not guarantee that those will be retrieved (e.g. a non-archive node)