diff --git a/package-lock.json b/package-lock.json index 2f87633da..0efa8781e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1764,6 +1764,12 @@ "integrity": "sha512-BIdRNjRaoRj4bMsZLKbIZPMNKqmwnzNiyxqBYDSs6dFOCs9w8OHPuUE8e1bH60i1IhOzT0NjLtCD+lKEWB1KTQ==", "dev": true }, + "chai-bn": { + "version": "0.1.0-beta.0", + "resolved": "https://registry.npmjs.org/chai-bn/-/chai-bn-0.1.0-beta.0.tgz", + "integrity": "sha512-H88f0+5eMTQLhP8CxwgDB0y6QM1Do3HmihvwhlGkYOXu9H+2TuOT2WAsbjV6e0Tf63CFmQBIG39xZ/j/g+4vKw==", + "dev": true + }, "chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", @@ -5789,6 +5795,34 @@ "mimic-fn": "^1.0.0" } }, + "openzeppelin-test-helpers": { + "version": "0.1.0-beta.1", + "resolved": "https://registry.npmjs.org/openzeppelin-test-helpers/-/openzeppelin-test-helpers-0.1.0-beta.1.tgz", + "integrity": "sha512-Vsvo78bsfkA5ju06spPpMKNV9e3KHUJjORSMWYnHLp33Kl96mrWfWSGfKsTH/1x0AbNI0LgRqFHMupV4ohTflg==", + "dev": true, + "requires": { + "chai": "^4.2.0", + "chai-bn": "0.1.0-beta.0", + "ethjs-abi": "^0.2.1", + "truffle": "^5.0.0" + }, + "dependencies": { + "chai": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", + "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", + "dev": true, + "requires": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^3.0.1", + "get-func-name": "^2.0.0", + "pathval": "^1.1.0", + "type-detect": "^4.0.5" + } + } + } + }, "optimist": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", diff --git a/package.json b/package.json index 9d59a2787..e884cb9e6 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "ethereumjs-util": "^6.0.0", "ethjs-abi": "^0.2.1", "ganache-cli": "6.1.8", + "openzeppelin-test-helpers": "0.1.0-beta.1", "pify": "^4.0.1", "solhint": "^1.5.0", "solidity-coverage": "^0.5.4", diff --git a/test/access/Roles.test.js b/test/access/Roles.test.js index 15fffec34..bd56f1a6e 100644 --- a/test/access/Roles.test.js +++ b/test/access/Roles.test.js @@ -1,17 +1,14 @@ -const shouldFail = require('../helpers/shouldFail'); -const { ZERO_ADDRESS } = require('../helpers/constants'); +const { shouldFail, constants } = require('openzeppelin-test-helpers'); const RolesMock = artifacts.require('RolesMock'); -require('./../helpers/setup'); - contract('Roles', function ([_, authorized, otherAuthorized, anyone]) { beforeEach(async function () { this.roles = await RolesMock.new(); }); it('reverts when querying roles for the null account', async function () { - await shouldFail.reverting(this.roles.has(ZERO_ADDRESS)); + await shouldFail.reverting(this.roles.has(constants.ZERO_ADDRESS)); }); context('initially', function () { @@ -34,7 +31,7 @@ contract('Roles', function ([_, authorized, otherAuthorized, anyone]) { }); it('reverts when adding roles to the null account', async function () { - await shouldFail.reverting(this.roles.add(ZERO_ADDRESS)); + await shouldFail.reverting(this.roles.add(constants.ZERO_ADDRESS)); }); }); }); @@ -57,7 +54,7 @@ contract('Roles', function ([_, authorized, otherAuthorized, anyone]) { }); it('reverts when removing roles from the null account', async function () { - await shouldFail.reverting(this.roles.remove(ZERO_ADDRESS)); + await shouldFail.reverting(this.roles.remove(constants.ZERO_ADDRESS)); }); }); }); diff --git a/test/access/roles/PublicRole.behavior.js b/test/access/roles/PublicRole.behavior.js index d558c1300..508ff9b20 100644 --- a/test/access/roles/PublicRole.behavior.js +++ b/test/access/roles/PublicRole.behavior.js @@ -1,8 +1,4 @@ -const shouldFail = require('../../helpers/shouldFail'); -const { ZERO_ADDRESS } = require('../../helpers/constants'); -const expectEvent = require('../../helpers/expectEvent'); - -require('../../helpers/setup'); +const { shouldFail, constants, expectEvent } = require('openzeppelin-test-helpers'); function capitalize (str) { return str.replace(/\b\w/g, l => l.toUpperCase()); @@ -27,7 +23,7 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [anyone], role } it('reverts when querying roles for the null account', async function () { - await shouldFail.reverting(this.contract[`is${rolename}`](ZERO_ADDRESS)); + await shouldFail.reverting(this.contract[`is${rolename}`](constants.ZERO_ADDRESS)); }); describe('access control', function () { @@ -67,7 +63,7 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [anyone], role }); it('reverts when adding role to the null account', async function () { - await shouldFail.reverting(this.contract[`add${rolename}`](ZERO_ADDRESS, { from })); + await shouldFail.reverting(this.contract[`add${rolename}`](constants.ZERO_ADDRESS, { from })); }); }); }); @@ -93,7 +89,7 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [anyone], role }); it('reverts when removing role from the null account', async function () { - await shouldFail.reverting(this.contract[`remove${rolename}`](ZERO_ADDRESS), { from }); + await shouldFail.reverting(this.contract[`remove${rolename}`](constants.ZERO_ADDRESS), { from }); }); }); }); diff --git a/test/crowdsale/AllowanceCrowdsale.test.js b/test/crowdsale/AllowanceCrowdsale.test.js index 4a53c5f97..887a4c69a 100644 --- a/test/crowdsale/AllowanceCrowdsale.test.js +++ b/test/crowdsale/AllowanceCrowdsale.test.js @@ -1,19 +1,13 @@ -const expectEvent = require('../helpers/expectEvent'); -const { ether } = require('../helpers/ether'); -const shouldFail = require('../helpers/shouldFail'); -const { balanceDifference } = require('../helpers/balanceDifference'); -const { ZERO_ADDRESS } = require('../helpers/constants'); - -const { BigNumber } = require('../helpers/setup'); +const { balance, BN, constants, ether, expectEvent, shouldFail } = require('openzeppelin-test-helpers'); const AllowanceCrowdsaleImpl = artifacts.require('AllowanceCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenWallet]) { - const rate = new BigNumber(1); - const value = ether(0.42); + const rate = new BN('1'); + const value = ether('0.42'); const expectedTokenAmount = rate.mul(value); - const tokenAllowance = new BigNumber('1e22'); + const tokenAllowance = new BN('1e22'); beforeEach(async function () { this.token = await SimpleToken.new({ from: tokenWallet }); @@ -52,7 +46,7 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW }); it('should forward funds to wallet', async function () { - (await balanceDifference(wallet, () => + (await balance.difference(wallet, () => this.crowdsale.sendTransaction({ value, from: investor })) ).should.be.bignumber.equal(value); }); @@ -68,7 +62,7 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW context('when the allowance is larger than the token amount', function () { beforeEach(async function () { const amount = await this.token.balanceOf(tokenWallet); - await this.token.approve(this.crowdsale.address, amount.plus(1), { from: tokenWallet }); + await this.token.approve(this.crowdsale.address, amount.add(new BN(1)), { from: tokenWallet }); }); it('should report the amount instead of the allowance', async function () { @@ -80,7 +74,7 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW describe('when token wallet is different from token address', function () { it('creation reverts', async function () { this.token = await SimpleToken.new({ from: tokenWallet }); - await shouldFail.reverting(AllowanceCrowdsaleImpl.new(rate, wallet, this.token.address, ZERO_ADDRESS)); + await shouldFail.reverting(AllowanceCrowdsaleImpl.new(rate, wallet, this.token.address, constants.ZERO_ADDRESS)); }); }); }); diff --git a/test/crowdsale/CappedCrowdsale.test.js b/test/crowdsale/CappedCrowdsale.test.js index 8199ec32e..f829f3033 100644 --- a/test/crowdsale/CappedCrowdsale.test.js +++ b/test/crowdsale/CappedCrowdsale.test.js @@ -1,16 +1,13 @@ -const { ether } = require('../helpers/ether'); -const shouldFail = require('../helpers/shouldFail'); - -const { BigNumber } = require('../helpers/setup'); +const { BN, ether, shouldFail } = require('openzeppelin-test-helpers'); const CappedCrowdsaleImpl = artifacts.require('CappedCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); contract('CappedCrowdsale', function ([_, wallet]) { - const rate = new BigNumber(1); - const cap = ether(100); - const lessThanCap = ether(60); - const tokenSupply = new BigNumber('1e22'); + const rate = new BN('1'); + const cap = ether('100'); + const lessThanCap = ether('60'); + const tokenSupply = new BN('1e22'); beforeEach(async function () { this.token = await SimpleToken.new(); @@ -28,7 +25,7 @@ contract('CappedCrowdsale', function ([_, wallet]) { describe('accepting payments', function () { it('should accept payments within cap', async function () { - await this.crowdsale.send(cap.minus(lessThanCap)); + await this.crowdsale.send(cap.sub(lessThanCap)); await this.crowdsale.send(lessThanCap); }); @@ -38,7 +35,7 @@ contract('CappedCrowdsale', function ([_, wallet]) { }); it('should reject payments that exceed cap', async function () { - await shouldFail.reverting(this.crowdsale.send(cap.plus(1))); + await shouldFail.reverting(this.crowdsale.send(cap.add(new BN(1)))); }); }); @@ -49,7 +46,7 @@ contract('CappedCrowdsale', function ([_, wallet]) { }); it('should not reach cap if sent just under cap', async function () { - await this.crowdsale.send(cap.minus(1)); + await this.crowdsale.send(cap.sub(1)); (await this.crowdsale.capReached()).should.equal(false); }); diff --git a/test/cryptography/ECDSA.test.js b/test/cryptography/ECDSA.test.js index 1909b848d..c37f405bd 100644 --- a/test/cryptography/ECDSA.test.js +++ b/test/cryptography/ECDSA.test.js @@ -1,12 +1,10 @@ +const { shouldFail } = require('openzeppelin-test-helpers'); const { signMessage, toEthSignedMessageHash } = require('../helpers/sign'); -const shouldFail = require('../helpers/shouldFail'); const ECDSAMock = artifacts.require('ECDSAMock'); -require('../helpers/setup'); - -const TEST_MESSAGE = web3.sha3('OpenZeppelin'); -const WRONG_MESSAGE = web3.sha3('Nope'); +const TEST_MESSAGE = web3.utils.sha3('OpenZeppelin'); +const WRONG_MESSAGE = web3.utils.sha3('Nope'); contract('ECDSA', function ([_, anyone]) { beforeEach(async function () { @@ -16,7 +14,7 @@ contract('ECDSA', function ([_, anyone]) { context('recover with valid signature', function () { context('with v0 signature', function () { // Signature generated outside ganache with method web3.eth.sign(signer, message) - const signer = '0x2cc1166f6212628a0deef2b33befb2187d35b86c'; + const signer = '0x2cc1166f6212628A0deEf2B33BEFB2187D35b86c'; // eslint-disable-next-line max-len const signatureWithoutVersion = '0x5d99b6f7f6d1f73d1a26497f2b1c89b24c0993913f86e9a2d02cd69887d9c94f3c880358579d811b21dd1b7fd9bb01c1d81d10e69f0384e675c32b39643be892'; @@ -49,7 +47,7 @@ contract('ECDSA', function ([_, anyone]) { }); context('with v1 signature', function () { - const signer = '0x1e318623ab09fe6de3c9b8672098464aeda9100e'; + const signer = '0x1E318623aB09Fe6de3C9b8672098464Aeda9100E'; // eslint-disable-next-line max-len const signatureWithoutVersion = '0x331fe75a821c982f9127538858900d87d3ec1f9f737338ad67cad133fa48feff48e6fa0c18abc62e42820f05943e47af3e9fbe306ce74d64094bdf1691ee53e0'; @@ -85,7 +83,7 @@ contract('ECDSA', function ([_, anyone]) { context('with correct signature', function () { it('returns signer address', async function () { // Create the signature - const signature = signMessage(anyone, TEST_MESSAGE); + const signature = await signMessage(anyone, TEST_MESSAGE); // Recover the signer address from the generated message and signature. (await this.ecdsa.recover( @@ -98,7 +96,7 @@ contract('ECDSA', function ([_, anyone]) { context('with wrong signature', function () { it('does not return signer address', async function () { // Create the signature - const signature = signMessage(anyone, TEST_MESSAGE); + const signature = await signMessage(anyone, TEST_MESSAGE); // Recover the signer address from the generated message and wrong signature. (await this.ecdsa.recover(WRONG_MESSAGE, signature)).should.not.equal(anyone); @@ -111,7 +109,7 @@ contract('ECDSA', function ([_, anyone]) { // @TODO - remove `skip` once we upgrade to solc^0.5 it.skip('reverts', async function () { // Create the signature - const signature = signMessage(anyone, TEST_MESSAGE); + const signature = await signMessage(anyone, TEST_MESSAGE); await shouldFail.reverting( this.ecdsa.recover(TEST_MESSAGE.substring(2), signature) ); diff --git a/test/cryptography/MerkleProof.test.js b/test/cryptography/MerkleProof.test.js index 869423048..b3b14d89b 100644 --- a/test/cryptography/MerkleProof.test.js +++ b/test/cryptography/MerkleProof.test.js @@ -1,10 +1,10 @@ +require('openzeppelin-test-helpers'); + const { MerkleTree } = require('../helpers/merkleTree.js'); const { keccak256, bufferToHex } = require('ethereumjs-util'); const MerkleProofWrapper = artifacts.require('MerkleProofWrapper'); -require('../helpers/setup'); - contract('MerkleProof', function () { beforeEach(async function () { this.merkleProof = await MerkleProofWrapper.new(); diff --git a/test/drafts/Counter.test.js b/test/drafts/Counter.test.js index 008e76778..e486ed1e8 100644 --- a/test/drafts/Counter.test.js +++ b/test/drafts/Counter.test.js @@ -1,11 +1,10 @@ +const { BN } = require('openzeppelin-test-helpers'); const CounterImpl = artifacts.require('CounterImpl'); -require('../helpers/setup'); - -const EXPECTED = [1, 2, 3, 4]; -const KEY1 = web3.sha3('key1'); -const KEY2 = web3.sha3('key2'); +const EXPECTED = [new BN(1), new BN(2), new BN(3), new BN(4)]; +const KEY1 = web3.utils.sha3('key1'); +const KEY2 = web3.utils.sha3('key2'); contract('Counter', function ([_, owner]) { beforeEach(async function () { diff --git a/test/drafts/ERC1046/TokenMetadata.test.js b/test/drafts/ERC1046/TokenMetadata.test.js index 58aaa3a33..83eca7038 100644 --- a/test/drafts/ERC1046/TokenMetadata.test.js +++ b/test/drafts/ERC1046/TokenMetadata.test.js @@ -1,6 +1,6 @@ -const ERC20WithMetadataMock = artifacts.require('ERC20WithMetadataMock'); +require('openzeppelin-test-helpers'); -require('../../helpers/setup'); +const ERC20WithMetadataMock = artifacts.require('ERC20WithMetadataMock'); const metadataURI = 'https://example.com'; diff --git a/test/drafts/ERC20Migrator.test.js b/test/drafts/ERC20Migrator.test.js index 05c8f5f03..dd291dc3e 100644 --- a/test/drafts/ERC20Migrator.test.js +++ b/test/drafts/ERC20Migrator.test.js @@ -1,17 +1,14 @@ -const shouldFail = require('../helpers/shouldFail'); -const { ZERO_ADDRESS } = require('../helpers/constants'); +const { BN, constants, shouldFail } = require('openzeppelin-test-helpers'); const ERC20Mock = artifacts.require('ERC20Mock'); const ERC20Mintable = artifacts.require('ERC20Mintable'); const ERC20Migrator = artifacts.require('ERC20Migrator'); -require('../helpers/setup'); - contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) { - const totalSupply = 200; + const totalSupply = new BN('200'); it('reverts with a null legacy token address', async function () { - await shouldFail.reverting(ERC20Migrator.new(ZERO_ADDRESS)); + await shouldFail.reverting(ERC20Migrator.new(constants.ZERO_ADDRESS)); }); describe('with tokens and migrator', function () { @@ -27,7 +24,7 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) { describe('beginMigration', function () { it('reverts with a null new token address', async function () { - await shouldFail.reverting(this.migrator.beginMigration(ZERO_ADDRESS)); + await shouldFail.reverting(this.migrator.beginMigration(constants.ZERO_ADDRESS)); }); it('reverts if not a minter of the token', async function () { @@ -81,7 +78,7 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) { currentBurnedBalance.should.be.bignumber.equal(amount); const currentLegacyTokenBalance = await this.legacyToken.balanceOf(owner); - currentLegacyTokenBalance.should.be.bignumber.equal(0); + currentLegacyTokenBalance.should.be.bignumber.equal('0'); }); it('updates the total supply', async function () { @@ -91,7 +88,7 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) { }); describe('when the approved balance is lower than the owned balance', function () { - const amount = baseAmount - 1; + const amount = baseAmount.subn(1); beforeEach('approving part of the balance to the new contract', async function () { await this.legacyToken.approve(this.migrator.address, amount, { from: owner }); @@ -106,7 +103,7 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) { }); describe('migrate', function () { - const baseAmount = 50; + const baseAmount = new BN(50); beforeEach('approving tokens to the new contract', async function () { await this.legacyToken.approve(this.migrator.address, baseAmount, { from: owner }); @@ -129,7 +126,7 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) { currentBurnedBalance.should.be.bignumber.equal(amount); const currentLegacyTokenBalance = await this.legacyToken.balanceOf(owner); - currentLegacyTokenBalance.should.be.bignumber.equal(totalSupply - amount); + currentLegacyTokenBalance.should.be.bignumber.equal(totalSupply.sub(amount)); }); it('updates the total supply', async function () { @@ -139,7 +136,7 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) { }); describe('when the given amount is higher than the one approved', function () { - const amount = baseAmount + 1; + const amount = baseAmount.addn(1); it('reverts', async function () { await shouldFail.reverting(this.migrator.migrate(owner, amount)); diff --git a/test/drafts/SignatureBouncer.test.js b/test/drafts/SignatureBouncer.test.js index 4e204011a..3b9c22b4f 100644 --- a/test/drafts/SignatureBouncer.test.js +++ b/test/drafts/SignatureBouncer.test.js @@ -1,13 +1,11 @@ -const shouldFail = require('../helpers/shouldFail'); +const { shouldFail } = require('openzeppelin-test-helpers'); const { getSignFor } = require('../helpers/sign'); const { shouldBehaveLikePublicRole } = require('../access/roles/PublicRole.behavior'); const SignatureBouncerMock = artifacts.require('SignatureBouncerMock'); -require('../helpers/setup'); - const UINT_VALUE = 23; -const BYTES_VALUE = web3.toHex('test'); +const BYTES_VALUE = web3.utils.toHex('test'); const INVALID_SIGNATURE = '0xabcd'; contract('SignatureBouncer', function ([_, signer, otherSigner, anyone, authorizedUser, ...otherAccounts]) { diff --git a/test/drafts/TokenVesting.test.js b/test/drafts/TokenVesting.test.js index cb8fc18b5..9950f780d 100644 --- a/test/drafts/TokenVesting.test.js +++ b/test/drafts/TokenVesting.test.js @@ -1,16 +1,10 @@ -const shouldFail = require('../helpers/shouldFail'); -const expectEvent = require('../helpers/expectEvent'); -const time = require('../helpers/time'); -const { ethGetBlock } = require('../helpers/web3'); -const { ZERO_ADDRESS } = require('../helpers/constants'); - -const { BigNumber } = require('../helpers/setup'); +const { BN, constants, expectEvent, shouldFail, time } = require('openzeppelin-test-helpers'); const ERC20Mintable = artifacts.require('ERC20Mintable'); const TokenVesting = artifacts.require('TokenVesting'); contract('TokenVesting', function ([_, owner, beneficiary]) { - const amount = new BigNumber(1000); + const amount = new BN('1000'); beforeEach(async function () { // +1 minute so it starts after contract instantiation @@ -32,7 +26,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) { it('reverts with a null beneficiary', async function () { await shouldFail.reverting( - TokenVesting.new(ZERO_ADDRESS, this.start, this.cliffDuration, this.duration, true, { from: owner }) + TokenVesting.new(constants.ZERO_ADDRESS, this.start, this.cliffDuration, this.duration, true, { from: owner }) ); }); @@ -86,7 +80,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) { await time.increaseTo(this.start + this.cliffDuration); const { receipt } = await this.vesting.release(this.token.address); - const block = await ethGetBlock(receipt.blockNumber); + const block = await web3.eth.getBlock(receipt.blockNumber); const releaseTime = block.timestamp; const releasedAmount = amount.mul(releaseTime - this.start).div(this.duration).floor(); diff --git a/test/helpers/sign.js b/test/helpers/sign.js index 9164a9cd1..10326a6bf 100644 --- a/test/helpers/sign.js +++ b/test/helpers/sign.js @@ -1,21 +1,19 @@ -const { sha3, soliditySha3 } = require('web3-utils'); - const REAL_SIGNATURE_SIZE = 2 * 65; // 65 bytes in hexadecimal string legnth const PADDED_SIGNATURE_SIZE = 2 * 96; // 96 bytes in hexadecimal string length -const DUMMY_SIGNATURE = `0x${web3.padLeft('', REAL_SIGNATURE_SIZE)}`; +const DUMMY_SIGNATURE = `0x${web3.utils.padLeft('', REAL_SIGNATURE_SIZE)}`; // messageHex = '0xdeadbeef' function toEthSignedMessageHash (messageHex) { const messageBuffer = Buffer.from(messageHex.substring(2), 'hex'); const prefix = Buffer.from(`\u0019Ethereum Signed Message:\n${messageBuffer.length}`); - return sha3(Buffer.concat([prefix, messageBuffer])); + return web3.utils.sha3(Buffer.concat([prefix, messageBuffer])); } // signs message in node (ganache auto-applies "Ethereum Signed Message" prefix) // messageHex = '0xdeadbeef' const signMessage = (signer, messageHex = '0x') => { - return web3.eth.sign(signer, messageHex); // actually personal_sign + return web3.eth.sign(messageHex, signer); // actually personal_sign }; // @TODO - remove this when we migrate to web3-1.0.0 @@ -57,13 +55,13 @@ const getSignFor = (contract, signer) => (redeemer, methodName, methodArgs = []) } else { const abi = contract.abi.find(abi => abi.name === methodName); const name = transformToFullName(abi); - const signature = sha3(name).slice(0, 10); + const signature = web3.utils.sha3(name).slice(0, 10); parts.push(signature); } } // return the signature of the "Ethereum Signed Message" hash of the hash of `parts` - const messageHex = soliditySha3(...parts); + const messageHex = web3.utils.soliditySha3(...parts); return signMessage(signer, messageHex); };