Created
December 17, 2016 14:19
-
-
Save ferni/413e56354b34731793ed0ecd2f6cfb70 to your computer and use it in GitHub Desktop.
Fixes web3.sha3 leading '0x' compatibility issue between <= 0.15 and >= 0.16 versions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Web3 = require('web3'); | |
var web3 = new Web3(); | |
function fixSha3(web3) { | |
var original = web3.sha3; | |
web3.sha3 = function() { | |
var result = original.apply(this, arguments); | |
if (result[1] !== 'x') { | |
return '0x' + result; | |
} | |
return result; | |
} | |
return web3; | |
} | |
console.log(web3.sha3('asdf')); | |
fixSha3(web3); | |
console.log(web3.sha3('asdf')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment