Skip to content

Commit

Permalink
feat(limit-order-protocol-facade): improve parsing result of simulate…
Browse files Browse the repository at this point in the history
…TransferFroms for ethereum mainnet
  • Loading branch information
shoom3301 committed Apr 30, 2021
1 parent 4dc1301 commit 69b41ac
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/limit-order-protocol.facade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,16 @@ export class LimitOrderProtocolFacade {
.then((result) => {
const parsed = this.parseSimulateTransferResponse(result);

if (parsed !== null) {
return parsed;
}
if (parsed !== null) return parsed;

return Promise.reject(result);
})
.catch((error) => {
const parsed = this.parseSimulateTransferError(error);

if (parsed !== null) return parsed;

return Promise.reject(error);
});
}

Expand All @@ -159,6 +164,16 @@ export class LimitOrderProtocolFacade {
return null;
}

parseSimulateTransferError(error: Error | string): boolean | null {
const message = typeof error === 'string' ? error : error.message;

if (message.includes(SIMULATE_TRANSFER_PREFIX)) {
return !message.includes('0');
}

return null;
}

parseContractResponse(response: string): string {
return this.providerConnector.decodeABIParameter<string>(
'string',
Expand Down

0 comments on commit 69b41ac

Please sign in to comment.