Skip to content

Commit

Permalink
[bug](initialBalances)
Browse files Browse the repository at this point in the history
  • Loading branch information
amazingandyyy committed Apr 7, 2018
1 parent e17ef04 commit 3e8f1b1
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 58 deletions.
7 changes: 2 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,10 @@
"no-param-reassign": 0,
"func-names": 0,
"no-plusplus": 0,
"class-methods-use-this": 0,
"async-await/space-after-async": 2,
"async-await/space-after-await": 2
"class-methods-use-this": 0
},
"plugins": [
"node",
"jest",
"async-await"
"jest"
]
}
6 changes: 0 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-stage-3": "^6.24.1",
"babel-preset-env": "^1.6.1",
"babel-preset-es2017": "^6.24.1",
"babel-preset-stage-3": "^6.24.1",
"babel-watch": "^2.0.7",
"eslint": "^4.14.0",
"eslint-config-standard": "^10.2.1",
"eslint-plugin-async-await": "0.0.0",
"eslint-plugin-es5": "^1.1.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jest": "^21.5.0",
Expand Down
9 changes: 8 additions & 1 deletion src/config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import path from 'path';
require('dotenv').config({path: path.resolve(__dirname, '.env')})
export default {
APP_GCI: process.env.APP_GCI
APP_GCI: process.env.APP_GCI,
INITIAL_WALLETS: {
'6ZbRYV2f1NNuNQ9FDYyUMC2d1cjG2goWa': 0,
'94sjtY7LtC3P886FTepA5Q42VGqotbQfa': 100,
'6VD36a9t4DJRbY7WzjPuRRqDfEo8CpTHk': 200,
'LQbFPTBca2c55WWRH1cVdq8qcLhgbBSTV': 300,
'AYiagTrfG3nE9aFJALVTX6Pkn3CH28pTw': 400
}
}
11 changes: 4 additions & 7 deletions src/node.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
import lotion from 'lotion';
import coins from 'coins';

// import config from './config';

const PORT = process.argv[2] || 3000;
const app = lotion({ initialState: {} });

app.use(coins({
name: 'basecoin',
initialBalances: {
// ...config.INITIAL_WALLETS
andy: 100000
}
}
}));
// console.log(Object.keys(app));

// AYiagTrfG3nE9aFJALVTX6Pkn3CH28pTw: 400,
// 6VD36a9t4DJRbY7WzjPuRRqDfEo8CpTHk: 200,
// 6ZbRYV2f1NNuNQ9FDYyUMC2d1cjG2goWa: 0,
// 94sjtY7LtC3P886FTepA5Q42VGqotbQfa: 100,
// LQbFPTBca2c55WWRH1cVdq8qcLhgbBSTV: 300
app.listen(PORT).then(() => {
console.log(`\x1b[33m[chain]\t Coin availabled on PORT ${PORT}\x1b[0m`);
});
29 changes: 0 additions & 29 deletions src/wallet.js

This file was deleted.

7 changes: 2 additions & 5 deletions src/wallets/factory.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import lotion from 'lotion';
import coins from 'coins';
import GetPrivateKey from './getPrivateKey';

import config from '../config';
const { APP_GCI } = config;

class WalletFactory {
constructor(_index){
this.priv = Buffer.alloc(32);
this.priv = GetPrivateKey(_index);
this.walletObj = {};
this.walletObj.index = _index;

for(let i = 0; i < this.priv.length; i++){
this.priv[i] = i + _index;
}
let wallet;
lotion.connect(APP_GCI)
.then((client)=>{
Expand Down
9 changes: 9 additions & 0 deletions src/wallets/getPrivateKey.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function GetPrivateKey(_index) {
let priv = Buffer.alloc(32);
for(let i = 0; i < priv.length; i++){
priv[i] = i + _index;
}
return priv;
}

export default GetPrivateKey;
7 changes: 4 additions & 3 deletions src/wallets/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import WalletFactory from './factory';

let wallets = [];
const walletNumber = 5;
const walletNumber = process.argv[2] || 5;
for (let i = 0; i < walletNumber; i++) {
var wallet = new WalletFactory(i);
wallets.push(wallet);
}

export default wallets;
console.log(wallets)
console.log(`\x1b[33m[wallets]\t${wallets.length} wallets created\x1b[0m`);

export default wallets;

0 comments on commit 3e8f1b1

Please sign in to comment.