Skip to content

Commit

Permalink
Allow 0x as a numeric value for 0 in Provider formatter (#1104).
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Oct 23, 2020
1 parent d8cdd0e commit fe17a29
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/providers/src.ts/etherscan-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,19 +349,19 @@ export class EtherscanProvider extends BaseProvider{
const logs: Array<any> = await get(url, null, getResult);

// Cache txHash => blockHash
let txs: { [hash: string]: string } = {};
let blocks: { [tag: string]: string } = {};

// Add any missing blockHash to the logs
for (let i = 0; i < logs.length; i++) {
const log = logs[i];
if (log.blockHash != null) { continue; }
if (txs[log.transactionHash] == null) {
const tx = await this.getTransaction(log.transactionHash);
if (tx) {
txs[log.transactionHash] = tx.blockHash
if (blocks[log.blockNumber] == null) {
const block = await this.getBlock(log.blockNumber);
if (block) {
blocks[log.blockNumber] = block.hash;
}
}
log.blockHash = txs[log.transactionHash];
log.blockHash = blocks[log.blockNumber];
}

return logs;
Expand Down
1 change: 1 addition & 0 deletions packages/providers/src.ts/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export class Formatter {
// Requires a BigNumberish that is within the IEEE754 safe integer range; returns a number
// Strict! Used on input.
number(number: any): number {
if (number === "0x") { return 0; }
return BigNumber.from(number).toNumber();
}

Expand Down

0 comments on commit fe17a29

Please sign in to comment.