Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
@0x/utils: Add docstring for raw constructor parameter in `Revert…
Browse files Browse the repository at this point in the history
…Error`.

`@0x/utils`: Use `...is.instanceof()` pattern in `RevertError` tests.
  • Loading branch information
merklejerk committed Sep 4, 2019
1 parent dcb1d72 commit 387b233
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/utils/CHANGELOG.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
"note": "Add `LibFixedMath` `RevertError` types.",
"pr": 2109
},
{
"note": "Add `RawRevertError` `RevertError` type.",
"pr": 2109
},
{
"note": "Make `RevertError.decode()` optionally return a `RawRevertError` if the selector is unknown.",
"pr": 2109
Expand Down
3 changes: 3 additions & 0 deletions packages/utils/src/revert_error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ export abstract class RevertError extends Error {
* Parameters that are left undefined will not be tested in equality checks.
* @param declaration Function-style declaration of the revert (e.g., Error(string message))
* @param values Optional mapping of parameters to values.
* @param raw Optional encoded form of the revert error. If supplied, this
* instance will be treated as a `RawRevertError`, meaning it can only
* match other `RawRevertError` types with the same encoded payload.
*/
protected constructor(name: string, declaration?: string, values?: ValueMap, raw?: string) {
super(createErrorMessage(name, values));
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/test/revert_error_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ describe('RevertError', () => {
it('should decode an unknown selector as a `RawRevertError`', () => {
const _encoded = encoded.substr(0, 2) + '00' + encoded.substr(4);
const decoded = RevertError.decode(_encoded, true);
expect(decoded instanceof RawRevertError).to.be.true();
expect(decoded).is.instanceof(RawRevertError);
});
it('should fail to decode a malformed ABI encoded revert error', () => {
const _encoded = encoded.substr(0, encoded.length - 1);
Expand Down

0 comments on commit 387b233

Please sign in to comment.