Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async getBlockNumber(): Promise {
try {
const res: RPCResponse = await this.provider.send(
RPCMethod.GetLatestTxBlock,
);
if (res.error === undefined && res.result.header.BlockNum) {
// if blockNumber is too high, we use BN to be safer
return new BN(res.result.header.BlockNum);
} else {
throw new Error('Can not get latest BlockNumber');
}
} catch (error) {
throw error;
}
}
getLatestTxBlock(): Promise> {
return this.provider.send(RPCMethod.GetLatestTxBlock);
}