From 5efd0c1f8ab9544f94f80a4f12f83e7809ce53ac Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Mon, 27 Aug 2018 14:51:03 +0200 Subject: [PATCH] Backport fix for EIP-848 status codes from v4; only an error is generated in v3, the error string is ignored. (#262). --- contracts/contract.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/contracts/contract.js b/contracts/contract.js index 65a219401..c06c83c34 100644 --- a/contracts/contract.js +++ b/contracts/contract.js @@ -3,6 +3,7 @@ var Interface = require('./interface.js'); var utils = (function() { + var convert = require('../utils/convert.js'); return { defineProperty: require('../utils/properties.js').defineProperty, @@ -10,7 +11,8 @@ var utils = (function() { bigNumberify: require('../utils/bignumber.js').bigNumberify, - hexlify: require('../utils/convert.js').hexlify, + arrayify: convert.arrayify, + hexlify: convert.hexlify, }; })(); @@ -124,9 +126,12 @@ function Contract(addressOrName, contractInterface, signerOrProvider) { }).then(function(value) { try { + if ((utils.arrayify(value).length % 32) !== 0) { + throw new Error('call exception'); + } var result = call.parse(value); } catch (error) { - if (value === '0x' && method.outputs.types.length > 0) { + if ((value === '0x' && method.outputs.types.length > 0) || error.message === 'call exception') { errors.throwError('call exception', errors.CALL_EXCEPTION, { address: addressOrName, method: call.signature,