Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
major changes. demo on site index. ropsten network. etc.
- Loading branch information
Showing
94 changed files
with
7,940 additions
and
2,136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"constant":true,"inputs":[],"name":"MULTIPLIER","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"crowdsaleAgent","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"FROZEN_TOKENS","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_crowdsaleAgent","type":"address"}],"name":"setCrowdsaleAgent","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"receiver","type":"address"},{"name":"amount","type":"uint256"}],"name":"mint","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"crowdSaleOverTimestamp","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"releaseTokenTransfer","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"FREEZE_PERIOD","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"released","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"amount","type":"uint256"}],"name":"convertToDecimal","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"type":"function"},{"inputs":[],"payable":false,"type":"constructor"},{"payable":true,"type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
const Deal = require('../db/models/Deal.js'); | ||
const User = require('../db/models/User.js'); | ||
|
||
const settings = require('../config/settings')('bcg-escrows'); | ||
|
||
function findAndChangeEscrows(deal) { | ||
let used_ids = deal.escrows.map(function (escrow) { | ||
return escrow.escrow; | ||
}); | ||
return new Promise(function(resolve, reject){ | ||
User.find({ | ||
$and: [ | ||
{type: 'escrow'}, | ||
{_id: {$nin: used_ids}} | ||
] | ||
}).then(function(escrows){ | ||
if (escrows && escrows.length > 0) { | ||
let random = Math.floor(Math.random() * escrows.length); | ||
deal.escrows.push({escrow: escrows[random]._id}); | ||
} | ||
return deal.save(); | ||
}).then(function (deal){ | ||
resolve(deal); | ||
}).catch(function(err){ | ||
reject(err); | ||
}); | ||
}) | ||
} | ||
|
||
module.exports = function(io){ | ||
setInterval(function(){ | ||
Deal.find({ | ||
status: 'dispute' | ||
}).then(function (deals){ | ||
let _deals = []; | ||
deals.forEach(function(deal, index){ | ||
if (deal.escrows.length){ | ||
let lastEscrow = deal.escrows[deal.escrows.length - 1]; | ||
let created_at = new Date(lastEscrow.created_at); | ||
let join_at = new Date(lastEscrow.join_at); | ||
let now = new Date(); | ||
|
||
if ((join_at.getTime() == 0 && Math.floor(now - created_at) > settings.time_from_add * 1000) || | ||
(join_at.getTime() != 0 && Math.floor(now - join_at) > settings.time_from_join * 1000)){ | ||
deal.escrows.id(lastEscrow._id).set({decision: 'rejected'}); | ||
findAndChangeEscrows(deal).then(function(deal){ | ||
io.in(deal._id.toString()).emit('disputeChanged'); | ||
}).catch(function (err){ | ||
console.log(err); | ||
}); | ||
} | ||
} | ||
}); | ||
}).catch(function (err){ | ||
console.log(err); | ||
}); | ||
}, 1000 * settings.time_to_check); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Generate wallets for users which didnt have them | ||
*/ | ||
const config = require('../config/database'); | ||
const mongoose = require('mongoose'); | ||
mongoose.Promise = global.Promise; | ||
mongoose.connect(config.database, { | ||
useMongoClient: true | ||
}); | ||
|
||
const User = require('../db/models/User.js'); | ||
const Account = require('../db/models/crypto/Account.js'); | ||
const Deal = require('../db/models/Deal.js'); | ||
|
||
const Web3 = require('web3'); | ||
const web3 = new Web3( | ||
new Web3.providers.HttpProvider('https://ropsten.infura.io/') | ||
); | ||
|
||
function createAccount (data) { | ||
return new Account(data).save(); | ||
} | ||
|
||
Deal.find({coin: {$exists: false}}).then(async function (deals) { | ||
await Promise.all(deals.map(async function (deal) { | ||
deal.coin = 'ETH'; | ||
await deal.save(); | ||
}) | ||
); | ||
console.log("done\n"); | ||
process.exit(); | ||
}).catch(function(err) { | ||
console.log(err); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Generate wallets for users which didnt have them | ||
*/ | ||
const config = require('../config/database'); | ||
const mongoose = require('mongoose'); | ||
mongoose.Promise = global.Promise; | ||
mongoose.connect(config.database, { | ||
useMongoClient: true | ||
}); | ||
|
||
const User = require('../db/models/User.js'); | ||
const Account = require('../db/models/crypto/Account.js'); | ||
|
||
const Web3 = require('web3'); | ||
const web3 = new Web3( | ||
new Web3.providers.HttpProvider('https://ropsten.infura.io/') | ||
); | ||
|
||
function createAccount (data) { | ||
return new Account(data).save(); | ||
} | ||
|
||
User.find({holds: {$exists: false}}).then(async function (users) { | ||
await Promise.all(users.map(async function (user) { | ||
user.holds = {eth: 0, pfr: 0}; | ||
user.markModified('holds'); | ||
await user.save(); | ||
}) | ||
); | ||
console.log("done\n"); | ||
process.exit(); | ||
}).catch(function(err) { | ||
console.log(err); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Generate wallets for users which didnt have them | ||
*/ | ||
const config = require('../config/database'); | ||
const mongoose = require('mongoose'); | ||
mongoose.Promise = global.Promise; | ||
mongoose.connect(config.database, { | ||
useMongoClient: true | ||
}); | ||
|
||
const User = require('../db/models/User.js'); | ||
const Account = require('../db/models/crypto/Account.js'); | ||
|
||
const Web3 = require('web3'); | ||
const web3 = new Web3( | ||
new Web3.providers.HttpProvider('https://ropsten.infura.io/') | ||
); | ||
|
||
function createAccount (data) { | ||
return new Account(data).save(); | ||
} | ||
|
||
User.find({wallet: {$exists: false}, status: 'active'}).then(async function (users) { | ||
await Promise.all(users.map(async function (user) { | ||
let newAccount = web3.eth.accounts.create(); | ||
let account = await createAccount({ | ||
address: newAccount.address, | ||
privateKey: newAccount.privateKey, | ||
coin: 'eth', | ||
owner: user._id | ||
}); | ||
user.wallet = account._id; | ||
await user.save(); | ||
})); | ||
console.log("done\n"); | ||
process.exit(); | ||
}).catch(function(err) { | ||
console.log(err); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
|
||
module.exports = { | ||
pfr_address: '0x4a39e8bae23eff8dbd9ac2ad9fcb59218a731d3d', // ropsten address | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* Get values of settings by name of category | ||
* @param {String} setting_name Category of settings | ||
* @returns {array} Return values of settings by name of category | ||
*/ | ||
module.exports = function(setting_name){ | ||
var s = { | ||
'bcg-escrows': { | ||
time_from_add: 60 * 5, // sec | ||
time_from_join: 60 * 90, // sec | ||
time_to_check: 60 * 5 // sec | ||
} | ||
} | ||
return s[setting_name]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const mongoose = require('mongoose'); | ||
const Schema = mongoose.Schema; | ||
|
||
const Review = new Schema({ | ||
_id: { | ||
type: Schema.Types.ObjectId | ||
}, | ||
user: { | ||
type: Schema.Types.ObjectId, | ||
ref: 'User' | ||
}, | ||
author: { | ||
type: Schema.Types.ObjectId, | ||
ref: 'User' | ||
}, | ||
comment: { | ||
type: String | ||
}, | ||
rating: { | ||
type: Number, | ||
default: 5 | ||
}, | ||
created_at: { | ||
type: Date, | ||
default: Date.now | ||
}, | ||
deal: { | ||
type: Schema.Types.ObjectId, | ||
ref: 'Deal' | ||
} | ||
}); | ||
|
||
module.exports = mongoose.model('Review', Review); |
Oops, something went wrong.