Skip to content

Commit

Permalink
linters
Browse files Browse the repository at this point in the history
  • Loading branch information
DZariusz committed Mar 7, 2019
1 parent 5ba1d41 commit b5959c2
Show file tree
Hide file tree
Showing 9 changed files with 218 additions and 254 deletions.
6 changes: 2 additions & 4 deletions migrations/1_initial_migration.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
var Migrations = artifacts.require("./Migrations.sol");
const Migrations = artifacts.require('./Migrations.sol');

module.exports = function(deployer) {
deployer.deploy(Migrations);
};
module.exports = deployer => deployer.deploy(Migrations);
53 changes: 27 additions & 26 deletions migrations/2_sales_migration.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
const abi = require('ethereumjs-abi');
const getConfig = require('./inc/getConfig');

const Sales = artifacts.require('Sales');
const abi = require('ethereumjs-abi');

module.exports = function(deployer, network, accounts) {
module.exports = (deployer, network, accounts) => {
const { config, wallet } = getConfig(network, accounts);

// assert.ok(wallet);

var args = [
const args = [
wallet,
config['total'],
config['name'],
config['decimals'],
config['symbol'],
config['price'],
config['startBlock'],
config['freezeBlock'],
config['cap'],
config['locked']
config.total,
config.name,
config.decimals,
config.symbol,
config.price,
config.startBlock,
config.freezeBlock,
config.cap,
config.locked,
];

console.log('args: ' + args.join(','));
console.log(`args: ${args.join(',')}`);

var encoded = abi.rawEncode(
const encoded = abi.rawEncode(
[
'address',
'uint256',
Expand All @@ -33,24 +34,24 @@ module.exports = function(deployer, network, accounts) {
'uint256',
'uint256',
'uint256',
'uint256'
'uint256',
],
args
args,
);

console.log('encoded argument for Sales contract: ' + encoded.toString('hex'));
console.log(`encoded argument for Sales contract: ${encoded.toString('hex')}`);

return deployer.deploy(
Sales,
wallet,
config['total'],
config['name'],
config['decimals'],
config['symbol'],
config['price'],
config['startBlock'],
config['freezeBlock'],
config['cap'],
config['locked']
config.total,
config.name,
config.decimals,
config.symbol,
config.price,
config.startBlock,
config.freezeBlock,
config.cap,
config.locked,
);
};
5 changes: 4 additions & 1 deletion migrations/3_salable_migration.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const SalableDeployer = require('./deployers/Salable');

const Salable = artifacts.require('Salable');

module.exports = (deployer, network, accounts) => SalableDeployer(deployer, network, accounts, Salable);
module.exports = (deployer, network, accounts) => SalableDeployer(
deployer, network, accounts, Salable,
);
109 changes: 53 additions & 56 deletions migrations/deployers/Salable.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,55 @@
const getConfig = require('../inc/getConfig');
const abi = require('ethereumjs-abi');
const getConfig = require('../inc/getConfig');

module.exports = (deployer, network, accounts, SalableArtifact) => {
return deployer.then(async () => {
const { config, wallet } = getConfig(network, accounts);

// assert.ok(wallet);

var args = [
wallet,
config['total'],
config['name'],
config['decimals'],
config['symbol'],
config['price'],
config['startBlock'],
config['freezeBlock'],
config['cap'],
config['locked']
];

console.log('args: ' + args.join(','));

var encoded = abi.rawEncode(
[
'address',
'uint256',
'string',
'uint8',
'string',
'uint256',
'uint256',
'uint256',
'uint256',
'uint256'
],
args
);

console.log('encoded argument for Salable contract: ' + encoded.toString('hex'));

return deployer.deploy(
SalableArtifact,
wallet,
config['total'],
config['name'],
config['decimals'],
config['symbol'],
config['price'],
config['startBlock'],
config['freezeBlock'],
config['cap'],
config['locked']
);
});
};

module.exports = (deployer, network, accounts, SalableArtifact) => deployer.then(async () => {
const { config, wallet } = getConfig(network, accounts);

// assert.ok(wallet);

const args = [
wallet,
config.total,
config.name,
config.decimals,
config.symbol,
config.price,
config.startBlock,
config.freezeBlock,
config.cap,
config.locked,
];

console.log(`args: ${args.join(',')}`);

const encoded = abi.rawEncode(
[
'address',
'uint256',
'string',
'uint8',
'string',
'uint256',
'uint256',
'uint256',
'uint256',
'uint256',
],
args,
);

console.log(`encoded argument for Salable contract: ${encoded.toString('hex')}`);

return deployer.deploy(
SalableArtifact,
wallet,
config.total,
config.name,
config.decimals,
config.symbol,
config.price,
config.startBlock,
config.freezeBlock,
config.cap,
config.locked,
);
});
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
"version": "0.1.0",
"description": "Typical Ethereum based Sale Contracts",
"scripts": {
"lint:solium": "solium --dir . --fix",
"lint:js": "./node_modules/.bin/eslint ./test --no-ignore --ext .js --fix",
"lint:js-migrations": "./node_modules/.bin/eslint ./migrations --no-ignore --ext .js --fix",
"lint": "npm run lint:js && npm run lint:js-migrations && npm run lint:solium",
"lint": "npm run lint:js && npm run lint:js-migrations",
"test": "scripts/test.sh"
},
"author": "Miguel Morales <[email protected]>",
Expand All @@ -18,6 +17,7 @@
"dependencies": {
"bip39": "2.5.0",
"bn.js": "4.11.8",
"bignumber.js": "8.1.1",
"ethereumjs-abi": "0.6.6",
"ethjs-provider-http": "0.1.6",
"ethjs-query": "0.3.8",
Expand Down
14 changes: 9 additions & 5 deletions test/SalableTest.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// const {assert} = require('chai');

const BN = require('bn.js');
const BigNumber = require('bignumber.js');

Expand Down Expand Up @@ -36,15 +34,21 @@ contract('Salable', (accounts) => {
});

it('should set the expected total supply', async () => {
assert(BigNumber(conf.total).times(100 - TWENTY).div(100).eq(await ministroSalable.totalSupply()));
assert(
BigNumber(conf.total).times(100 - TWENTY).div(100).eq(await ministroSalable.totalSupply()),
);
});

it('should set the expected number of tokens for the contract as owner', async () => {
assert(BigNumber(conf.total).times(SALE_PERCENT).div(100).eq(await ministroSalable.balanceOf(ministroSalable.instance.address)));
assert(BigNumber(conf.total).times(SALE_PERCENT).div(100).eq(
await ministroSalable.balanceOf(ministroSalable.instance.address),
));
});

it('should set the expected number of tokens for the owner', async () => {
assert(BigNumber(conf.total).times(TWENTY).div(100).eq(await ministroSalable.balanceOf(ownerAccount)));
assert(BigNumber(conf.total).times(TWENTY).div(100).eq(
await ministroSalable.balanceOf(ownerAccount),
));
});
});

Expand Down
Loading

0 comments on commit b5959c2

Please sign in to comment.