Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency cleanup #557

Merged
merged 7 commits into from
Feb 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 16 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polymath-core",
"version": "2.0.0",
"version": "3.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer the bump of the version during the release.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have already bumped 2.1 version. It helps the dApp guys. I am fine with any though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok then leave as it is

"description": "Polymath Network Core Smart Contracts",
"main": "truffle.js",
"directories": {
Expand Down Expand Up @@ -57,30 +57,18 @@
},
"homepage": "https://github.com/PolymathNetwork/polymath-core#readme",
"dependencies": {
"truffle": "^5.0.4",
"truffle-hdwallet-provider": "^1.0.4",
"web3-provider-engine": "^14.1.0"
},
"devDependencies": {
"babel-polyfill": "6.26.0",
"babel-preset-es2015": "6.24.1",
"babel-preset-stage-2": "6.24.1",
"babel-preset-stage-3": "6.24.1",
"babel-register": "6.26.0",
"bignumber.js": "5.0.0",
"chalk": "^2.4.2",
"coveralls": "^3.0.1",
"ethereumjs-testrpc": "^6.0.3",
"ethers": "^4.0.7",
"fs": "0.0.2",
"openzeppelin-solidity": "^2.1.0-rc.2",
"pify": "^4.0.1",
"prompt": "^1.0.0",
"readline-sync": "^1.4.9",
"request": "^2.88.0",
"request-promise": "^4.2.2",
"solc": "^0.5.2",
"truffle-contract": "^3.0.4",
"truffle-hdwallet-provider-privkey": "0.2.0",
"web3": "1.0.0-beta.35"
},
"devDependencies": {
"@soldoc/soldoc": "^0.4.3",
"eslint": "^5.8.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.10.0",
Expand All @@ -90,23 +78,27 @@
"eth-gas-reporter": "^0.1.12",
"ethereum-bridge": "^0.6.1",
"ethereumjs-abi": "^0.6.5",
"ganache-cli": "^6.2.4",
"fs": "0.0.2",
"ganache-cli": "6.1.8",
"mocha-junit-reporter": "^1.18.0",
"openzeppelin-solidity": "2.1.2",
"prettier": "^1.15.3",
"table": "^5.2.3",
"prompt": "^1.0.0",
"request": "^2.88.0",
"request-promise": "^4.2.2",
"sol-merger": "^0.1.2",
"solidity-coverage": "^0.5.11",
"solidity-docgen": "^0.1.0",
"solium": "^1.1.6",
"truffle": "^5.0.4",
"truffle-wallet-provider": "0.0.5"
"table": "^5.2.3",
"web3": "1.0.0-beta.35"
},
"greenkeeper": {
"ignore": [
"openzeppelin-solidity",
"web3",
"bignumber.js",
"truffle-hdwallet-provider-privkey"
"truffle-hdwallet-provider",
"ganache-cli"
]
}
}
1 change: 0 additions & 1 deletion test/g_general_permission_manager.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import latestTime from "./helpers/latestTime";
import { signData } from "./helpers/signData";
import { pk } from "./helpers/testprivateKey";
import { duration, promisifyLogWatch, latestBlock } from "./helpers/utils";
import { takeSnapshot, increaseTime, revertToSnapshot } from "./helpers/time";
Expand Down
20 changes: 0 additions & 20 deletions test/helpers/signData.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
const ethers = require("ethers");
const utils = ethers.utils;
const ethUtil = require("ethereumjs-util");
const Web3 = require("web3");
let BN = Web3.utils.BN;

//this, _investor, _fromTime, _toTime, _validTo
function signData(tmAddress, investorAddress, fromTime, toTime, expiryTime, validFrom, validTo, nonce, pk) {
let packedData = utils
.solidityKeccak256(
["address", "address", "uint256", "uint256", "uint256", "uint256", "uint256", "uint256"],
[tmAddress, investorAddress, fromTime, toTime, expiryTime, validFrom, validTo, nonce]
)
.slice(2);
packedData = new Buffer(packedData, "hex");
console.log("PackedData 1: " + packedData);
packedData = Buffer.concat([new Buffer(`\x19Ethereum Signed Message:\n${packedData.length.toString()}`), packedData]);
packedData = web3.utils.sha3(`0x${packedData.toString("hex")}`, { encoding: "hex" });
console.log("PackedData 2: " + packedData);
return ethUtil.ecsign(new Buffer(packedData.slice(2), "hex"), new Buffer(pk, "hex"));
}

function getSignSTMData(tmAddress, nonce, expiry, fromAddress, toAddress, amount, pk) {
let hash = web3.utils.soliditySha3({t: 'address', v: tmAddress}, {t: 'uint256', v: new BN(nonce)}, {t: 'uint256', v: new BN(expiry)}, {t: 'address', v: fromAddress}, {t: 'address', v: toAddress}, {t: 'uint256', v: new BN(amount)});
let signature = (web3.eth.accounts.sign(hash, pk)).signature;
Expand All @@ -34,7 +15,6 @@ function getSignGTMData(tmAddress, investorAddress, fromTime, toTime, expiryTime
}

module.exports = {
signData,
getSignSTMData,
getSignGTMData
};
75 changes: 24 additions & 51 deletions test/helpers/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,39 @@
// aren’t included within the original RPC specification.
// See https://github.com/ethereumjs/testrpc#implemented-methods

// async function increaseTime(duration) {
// //let currentTime = (await web3.eth.getBlock('latest')).timestamp
// await sendIncreaseTime(duration);
// return advanceBlock();
// }

// async function sendIncreaseTime(duration) {
// return new Promise(() =>
// web3.currentProvider.send({
// jsonrpc: '2.0',
// method: 'evm_increaseTime',
// params: [duration],
// })
// );
// }

// async function advanceBlock() {
// return new Promise(() =>
// web3.currentProvider.send({
// jsonrpc: '2.0',
// method: 'evm_mine',
// })
// );
// }

const pify = require('pify');

function advanceBlock() {
return pify(web3.currentProvider.send)({
jsonrpc: '2.0',
method: 'evm_mine',
async function advanceBlock() {
return new Promise((resolve, reject) => {
web3.currentProvider.send({
jsonrpc: '2.0',
method: 'evm_mine',
},
(err, result) => {
if (err) {
return reject(err);
}
resolve(result.result);
}
);
});
}

// Increases ganache time by the passed duration in seconds
async function increaseTime(duration) {
await pify(web3.currentProvider.send)({
jsonrpc: '2.0',
method: 'evm_increaseTime',
params: [duration],
});
await advanceBlock();
}

async function jumpToTime(timestamp) {
const id = Date.now();

return new Promise((resolve, reject) => {
web3.currentProvider.send(
{
jsonrpc: "2.0",
method: "evm_mine",
params: [timestamp],
id: id
await new Promise((resolve, reject) => {
web3.currentProvider.send({
jsonrpc: '2.0',
method: 'evm_increaseTime',
params: [duration],
},
(err, res) => {
return err ? reject(err) : resolve(res);
(err, result) => {
if (err) {
return reject(err);
}
resolve(result.result);
}
);
});
await advanceBlock();
}

export default function takeSnapshot() {
Expand Down
12 changes: 8 additions & 4 deletions test/o_security_token.js
Original file line number Diff line number Diff line change
Expand Up @@ -1330,10 +1330,14 @@ contract("SecurityToken", async (accounts) => {
Controller address from the contract: ${await stGetter.controller.call()}
Controller address from the storage: ${await readStorage(I_SecurityToken.address, 7)}
`)

assert.equal(
(await stGetter.controller.call()).substring(0, 3),
await readStorage(I_SecurityToken.address, 7)
// Different versions of web3 behave differently :/
assert.oneOf(
await readStorage(I_SecurityToken.address, 7),
[
(await stGetter.controller.call()).substring(0, 4),
(await stGetter.controller.call()).substring(0, 3),
await stGetter.controller.call()
]
);

console.log(`
Expand Down
2 changes: 1 addition & 1 deletion truffle-config-gas.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require('babel-polyfill');
const fs = require('fs');
const NonceTrackerSubprovider = require("web3-provider-engine/subproviders/nonce-tracker")

const HDWalletProvider = require("truffle-hdwallet-provider-privkey");
const HDWalletProvider = require("truffle-hdwallet-provider");

module.exports = {
networks: {
Expand Down
2 changes: 1 addition & 1 deletion truffle-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require('babel-polyfill');
const fs = require('fs');
const NonceTrackerSubprovider = require("web3-provider-engine/subproviders/nonce-tracker")

const HDWalletProvider = require("truffle-hdwallet-provider-privkey");
const HDWalletProvider = require("truffle-hdwallet-provider");

module.exports = {
networks: {
Expand Down
Loading