mirror of https://github.com/dap-ps/discover.git
Fix on downvote and status 1.6 preparation
This commit is contained in:
parent
cc034da10e
commit
b3a3022b74
|
@ -74,9 +74,9 @@ module.exports = {
|
|||
SafeMath: { deploy: false },
|
||||
TestBancorFormula: { deploy: false },
|
||||
MiniMeToken: {
|
||||
address: '0x2764b5da3696E3613Ef9864E9B4613f9fA478E75'
|
||||
address: '0x25B1bD06fBfC2CbDbFc174e10f1B78b1c91cc77B'
|
||||
},
|
||||
Discover: { address: '0x3c70c61b974c807a5fbbccb87353bd29bd6e3a20' },
|
||||
Discover: { address: '0x17e7a7330d23fc6a2ab8578a627408f815396662' },
|
||||
// MiniMeToken: {
|
||||
// args: [
|
||||
// '$MiniMeTokenFactory',
|
||||
|
|
|
@ -114,6 +114,8 @@ class DiscoverService extends BlockchainService {
|
|||
async createDApp(amount, metadata) {
|
||||
const tokenAmount = this.decimalMultiplier.mul(new BN(amount, 10))
|
||||
|
||||
console.log(tokenAmount)
|
||||
|
||||
const ConnectedDiscoverContract = await super.__unlockServiceAccount(
|
||||
DiscoverContract,
|
||||
)
|
||||
|
@ -160,18 +162,16 @@ class DiscoverService extends BlockchainService {
|
|||
const dapp = await this.getDAppById(id)
|
||||
const amount = (await this.downVoteCost(dapp.id)).c
|
||||
|
||||
console.log('Cost gotten from the contract', amount)
|
||||
const amountBN = new BN(amount, 10)
|
||||
|
||||
const tokenAmount = this.decimalMultiplier.mul(new BN(amount, 10))
|
||||
|
||||
console.log('Cost after adjustment', tokenAmount.toString())
|
||||
const tokenAmount = this.decimalMultiplier.mul(amountBN)
|
||||
|
||||
const callData = DiscoverContract.methods
|
||||
.downvote(dapp.id, tokenAmount)
|
||||
.encodeABI()
|
||||
return this.sharedContext.SNTService.approveAndCall(
|
||||
this.contract,
|
||||
amount,
|
||||
tokenAmount,
|
||||
callData,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
const BN = require('bn.js')
|
||||
|
||||
class SNTValidator {
|
||||
constructor(service) {
|
||||
this.service = service
|
||||
|
@ -8,7 +10,9 @@ class SNTValidator {
|
|||
this.service.sharedContext.account,
|
||||
)
|
||||
|
||||
if (toBalance < amount) {
|
||||
const toBalanceBN = new BN(toBalance, 10)
|
||||
|
||||
if (amount.gt(toBalanceBN)) {
|
||||
throw new Error('Not enough SNT balance')
|
||||
}
|
||||
}
|
||||
|
@ -20,15 +24,6 @@ class SNTValidator {
|
|||
}
|
||||
|
||||
await this.validateSNTTransferFrom(amount)
|
||||
|
||||
const allowance = await this.service.allowance(
|
||||
this.service.sharedContext.account,
|
||||
spender,
|
||||
)
|
||||
|
||||
if (amount != 0 && allowance != 0) {
|
||||
throw new Error('You have allowance already')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,14 +1,13 @@
|
|||
module.exports = {
|
||||
BancorFormula: require('./BancorFormula').default,
|
||||
SafeMath: require('./SafeMath').default,
|
||||
BancorFormula: require('./BancorFormula').default,
|
||||
Controlled: require('./Controlled').default,
|
||||
MiniMeToken: require('./MiniMeToken').default,
|
||||
ERC20Token: require('./ERC20Token').default,
|
||||
TestBancorFormula: require('./TestBancorFormula').default,
|
||||
ApproveAndCallFallBack: require('./ApproveAndCallFallBack').default,
|
||||
TokenFactory: require('./TokenFactory').default,
|
||||
ERC20Token: require('./ERC20Token').default,
|
||||
MiniMeTokenInterface: require('./MiniMeTokenInterface').default,
|
||||
TokenController: require('./TokenController').default,
|
||||
MiniMeTokenFactory: require('./MiniMeTokenFactory').default,
|
||||
TokenController: require('./TokenController').default,
|
||||
TokenFactory: require('./TokenFactory').default,
|
||||
Discover: require('./Discover').default,
|
||||
}
|
||||
|
|
|
@ -129,8 +129,8 @@ export const fetchVoteRatingAction = (dapp, isUpvote, sntValue) => {
|
|||
dapp.id,
|
||||
)
|
||||
// balanceDownBy, votesRequired, cost
|
||||
rating = parseInt(downVoteEffect.b, 10)
|
||||
downVoteSntValue = downVoteEffect.b
|
||||
rating = parseInt(downVoteEffect.c, 10)
|
||||
downVoteSntValue = downVoteEffect.c
|
||||
} catch (e) {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue