-
Notifications
You must be signed in to change notification settings - Fork 3
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
Including optional time for isValid in server #780
Conversation
Pull Request ReportHey there! I've generated a report for your pull request. Let's dive in! Changes
Suggestions
Bugs
Improvements
public async isVerified(payload: ProcaptchaOutput, maxVerifiedTime?: number): Promise<boolean> {
const { user, dapp, providerUrl, commitmentId, blockNumber } = payload;
if (maxVerifiedTime !== undefined && blockNumber !== undefined) {
const currentBlockNumber = (await this.getApi().rpc.chain.getBlock()).block.header.number.toNumber();
const blockLength = this.getApi().consts.babe.expectedBlockTime.toNumber();
if ((currentBlockNumber - blockNumber) * blockLength > maxVerifiedTime) {
return false;
}
}
const contractApi = await this.getContractApi();
const block = (await this.getApi().rpc.chain.getBlockHash(blockNumber)) as BlockHash;
const getRandomProviderResponse = await this.getContract().queryAtBlock<RandomProvider>(block, contractApi.query.getRandomProvider);
// Rest of the code...
} RatingI would rate the code a 7 out of 10. The code has good readability and the added optional That's it for the report! Let me know if you need any further assistance. Happy coding! |
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.
Looks good, could you stick the time stuff in a separate function?
…g in contract check
No description provided.