Remove Babel (#1074)
* Test helpers no longer rely on Babel. * Behaviours are no longer imported. * Removed Babel dependency. * Fixed linter errors.pull/1023/head
parent
99e4b081dc
commit
cea2a85a42
@ -1 +1,5 @@ |
||||
export default 'revert'; |
||||
const EVMRevert = 'revert'; |
||||
|
||||
module.exports = { |
||||
EVMRevert, |
||||
}; |
||||
|
@ -1 +1,5 @@ |
||||
export default 'invalid opcode'; |
||||
const EVMThrow = 'invalid opcode'; |
||||
|
||||
module.exports = { |
||||
EVMThrow, |
||||
}; |
||||
|
@ -1,8 +1,12 @@ |
||||
const SolidityEvent = require('web3/lib/web3/event.js'); |
||||
|
||||
export default function decodeLogs (logs, contract, address) { |
||||
function decodeLogs (logs, contract, address) { |
||||
return logs.map(log => { |
||||
const event = new SolidityEvent(null, contract.events[log.topics[0]], address); |
||||
return event.decode(log); |
||||
}); |
||||
} |
||||
|
||||
module.exports = { |
||||
decodeLogs, |
||||
}; |
||||
|
@ -1,3 +1,7 @@ |
||||
export default function ether (n) { |
||||
function ether (n) { |
||||
return new web3.BigNumber(web3.toWei(n, 'ether')); |
||||
} |
||||
|
||||
module.exports = { |
||||
ether, |
||||
}; |
||||
|
@ -1,7 +1,11 @@ |
||||
import { ethGetBlock } from './web3'; |
||||
const { ethGetBlock } = require('./web3'); |
||||
|
||||
// Returns the time of the last mined block in seconds
|
||||
export default async function latestTime () { |
||||
async function latestTime () { |
||||
const block = await ethGetBlock('latest'); |
||||
return block.timestamp; |
||||
} |
||||
|
||||
module.exports = { |
||||
latestTime, |
||||
}; |
||||
|
@ -1,22 +1,28 @@ |
||||
import utils from 'ethereumjs-util'; |
||||
const utils = require('ethereumjs-util'); |
||||
|
||||
/** |
||||
* Hash and add same prefix to the hash that ganache use. |
||||
* @param {string} message the plaintext/ascii/original message |
||||
* @return {string} the hash of the message, prefixed, and then hashed again |
||||
*/ |
||||
export const hashMessage = (message) => { |
||||
function hashMessage (message) { |
||||
const messageHex = Buffer.from(utils.sha3(message).toString('hex'), 'hex'); |
||||
const prefix = utils.toBuffer('\u0019Ethereum Signed Message:\n' + messageHex.length.toString()); |
||||
return utils.bufferToHex(utils.sha3(Buffer.concat([prefix, messageHex]))); |
||||
}; |
||||
} |
||||
|
||||
// signs message using web3 (auto-applies prefix)
|
||||
export const signMessage = (signer, message = '', options = {}) => { |
||||
function signMessage (signer, message = '', options = {}) { |
||||
return web3.eth.sign(signer, web3.sha3(message, options)); |
||||
}; |
||||
} |
||||
|
||||
// signs hex string using web3 (auto-applies prefix)
|
||||
export const signHex = (signer, message = '') => { |
||||
function signHex (signer, message = '') { |
||||
return signMessage(signer, message, { encoding: 'hex' }); |
||||
} |
||||
|
||||
module.exports = { |
||||
hashMessage, |
||||
signMessage, |
||||
signHex, |
||||
}; |
||||
|
Loading…
Reference in new issue