Skip to content

Commit

Permalink
Checks input type string to avoid confusing error (web3#1254)
Browse files Browse the repository at this point in the history
* Checks input type string to avoid confusing error

* remove quotes
  • Loading branch information
samsonradu authored and nachomazzara committed Jun 4, 2020
1 parent 2c33b7c commit 0261dc6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/web3-eth-abi/src/formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ var formatInputDynamicBytes = function (value) {
* @returns {SolidityParam}
*/
var formatInputString = function (value) {
if(!_.isString(value)) {
throw new Error('Given parameter is not a valid string: ' + value);
}

var result = utils.utf8ToHex(value).replace(/^0x/i,'');
var length = result.length / 2;
var l = Math.floor((result.length + 63) / 64);
Expand Down

0 comments on commit 0261dc6

Please sign in to comment.