Skip to content

Commit

Permalink
Include 'removed' field in logs (#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
thebrianchen authored Sep 11, 2023
1 parent 2ad5254 commit b4279cc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@

### Minor Changes

- Fixed a bug in the `Log` object where the `removed` field was not included in the response.

## 2.10.0

### Major Changes

- Add support for Base
- Add support for Base

### Minor Changes

Expand Down
21 changes: 21 additions & 0 deletions src/api/alchemy-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ export class AlchemyProvider
return fetchJson(batcherConnection, JSON.stringify(requests));
};
this.batcher = new RequestBatcher(sendBatchFn);

this.modifyFormatter();
}

/**
Expand Down Expand Up @@ -316,6 +318,25 @@ export class AlchemyProvider

return result;
}

/**
* Overrides the base `Formatter` class inherited from ethers to support
* returning custom fields in Ethers response types.
*
* For context, ethers has a `Formatter` class that is used to format the
* response from a JSON-RPC request. Any fields that are not defined in the
* `Formatter` class are removed from the returned response. By modifying the
* `Formatter` class in this method, we can add support for fields that are
* not defined in ethers.
*/
private modifyFormatter(): void {
this.formatter.formats['receiptLog']['removed'] = val => {
if (typeof val === 'boolean') {
return val;
}
return undefined;
};
}
}

/**
Expand Down

0 comments on commit b4279cc

Please sign in to comment.