Skip to content

Commit

Permalink
fix(limit-order-protocol-facade): improve parseSimulateTransferError(…
Browse files Browse the repository at this point in the history
…) for any errors type
  • Loading branch information
shoom3301 committed May 15, 2021
1 parent 7848be7 commit 3c40dac
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This is the package of utilities for working with the `1inch limit orders protoc

| Statements | Branches | Functions | Lines |
| ----------------------------------------------------------------------------- | --------------------------------------------------------------------------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| ![Statements](https://img.shields.io/badge/Coverage-98.96%25-brightgreen.svg) | ![Branches](https://img.shields.io/badge/Coverage-96.88%25-brightgreen.svg) | ![Functions](https://img.shields.io/badge/Coverage-100%25-brightgreen.svg) | ![Lines](https://img.shields.io/badge/Coverage-98.96%25-brightgreen.svg) |
| ![Statements](https://img.shields.io/badge/Coverage-98.97%25-brightgreen.svg) | ![Branches](https://img.shields.io/badge/Coverage-96.88%25-brightgreen.svg) | ![Functions](https://img.shields.io/badge/Coverage-100%25-brightgreen.svg) | ![Lines](https://img.shields.io/badge/Coverage-98.97%25-brightgreen.svg) |

## Installation

Expand Down
4 changes: 2 additions & 2 deletions src/limit-order-protocol.facade.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ describe('LimitOrderProtocolFacade - facade for Limit order protocol contract',
it('When order is partially filled, then must return remaining amount', async () => {
// Order 1BUSD > 1 DAI, filled for 20%
const orderHash =
'0x5e887e6f651029455ce72384b0c02d8eb612db728c09617fd23d3fb834f705e6';
'0xa5b11acf64bd0ff47fc2b71b060a0e1e63bb8e82bd3e6aa3470b00ad7746933a';

const remaining = await facade.remaining(orderHash);

expect(remaining.toString()).toBe('800000000000000000');
expect(remaining.toString()).toBe('8000000000000000000');
});

it('When order is canceled, then must return zero', async () => {
Expand Down
3 changes: 2 additions & 1 deletion src/limit-order-protocol.facade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ export class LimitOrderProtocolFacade {
}

parseSimulateTransferError(error: Error | string): boolean | null {
const message = typeof error === 'string' ? error : error.message;
const message =
typeof error === 'string' ? error : JSON.stringify(error);
const regex = new RegExp('(' + SIMULATE_TRANSFER_PREFIX + '\\d+)');
const match = message.match(regex);

Expand Down

0 comments on commit 3c40dac

Please sign in to comment.