Skip to content
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
14 changes: 14 additions & 0 deletions contracts/standard/arbitration/Linguo.sol
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,20 @@ contract Linguo is Arbitrable {
}
}

/** @dev Gets the deposit required for challenging the translation.
* @param _taskID The ID of the task.
* @return deposit The challengers's deposit.
*/
function getChallengeValue(uint _taskID) public view returns (uint deposit) {
Task storage task = tasks[_taskID];
if (now - task.lastInteraction > reviewTimeout || task.status != Status.AwaitingReview) {
deposit = NOT_PAYABLE_VALUE;
} else {
uint arbitrationCost = arbitrator.arbitrationCost(arbitratorExtraData);
deposit = arbitrationCost.addCap((challengeMultiplier.mulCap(task.requesterDeposit)) / MULTIPLIER_DIVISOR);
}
}

/** @dev Gets the current price of a specified task.
* @param _taskID The ID of the task.
* @return price The price of the task.
Expand Down
49 changes: 17 additions & 32 deletions test/linguo.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,9 @@ contract('Linguo', function(accounts) {
await linguo.submitTranslation(0, 'ipfs:/X', { from: translator })
await expectThrow(linguo.acceptTranslation(0))

const task = await linguo.tasks(0)
const price = task[6].toNumber()
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
const challengerDeposit =
arbitrationFee + (challengeMultiplier * price) / MULTIPLIER_DIVISOR + 1000
(await linguo.getChallengeValue(0)).toNumber() + 1000
await linguo.challengeTranslation(0, {
from: challenger,
value: challengerDeposit
Expand All @@ -436,10 +434,9 @@ contract('Linguo', function(accounts) {
await linguo.submitTranslation(0, 'ipfs:/X', { from: translator })

task = await linguo.tasks(0)
const price = task[6].toNumber()
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
const challengerDeposit =
arbitrationFee + (challengeMultiplier * price) / MULTIPLIER_DIVISOR + 1000
(await linguo.getChallengeValue(0)).toNumber() + 1000
const challengeTx = await linguo.challengeTranslation(0, {
from: challenger,
value: challengerDeposit
Expand Down Expand Up @@ -516,10 +513,9 @@ contract('Linguo', function(accounts) {
await linguo.submitTranslation(0, 'ipfs:/X', { from: translator })

task = await linguo.tasks(0)
const price = task[6].toNumber()
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
const challengerDeposit =
arbitrationFee + (challengeMultiplier * price) / MULTIPLIER_DIVISOR + 1000
(await linguo.getChallengeValue(0)).toNumber() + 1000
await linguo.challengeTranslation(0, {
from: challenger,
value: challengerDeposit
Expand Down Expand Up @@ -574,11 +570,9 @@ contract('Linguo', function(accounts) {
})
await linguo.submitTranslation(0, 'ipfs:/X', { from: translator })

task = await linguo.tasks(0)
const price = task[6].toNumber()
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
const challengerDeposit =
arbitrationFee + (challengeMultiplier * price) / MULTIPLIER_DIVISOR + 1000
(await linguo.getChallengeValue(0)).toNumber() + 1000
await linguo.challengeTranslation(0, {
from: challenger,
value: challengerDeposit
Expand Down Expand Up @@ -633,10 +627,9 @@ contract('Linguo', function(accounts) {
await linguo.submitTranslation(0, 'ipfs:/X', { from: translator })

task = await linguo.tasks(0)
const price = task[6].toNumber()
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
const challengerDeposit =
arbitrationFee + (challengeMultiplier * price) / MULTIPLIER_DIVISOR + 1000
(await linguo.getChallengeValue(0)).toNumber() + 1000
await linguo.challengeTranslation(0, {
from: challenger,
value: challengerDeposit
Expand Down Expand Up @@ -687,11 +680,9 @@ contract('Linguo', function(accounts) {
})
await linguo.submitTranslation(0, 'ipfs:/X', { from: translator })

const task = await linguo.tasks(0)
const price = task[6].toNumber()
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
const challengerDeposit =
arbitrationFee + (challengeMultiplier * price) / MULTIPLIER_DIVISOR + 1000
(await linguo.getChallengeValue(0)).toNumber() + 1000
await linguo.challengeTranslation(0, {
from: challenger,
value: challengerDeposit
Expand Down Expand Up @@ -805,11 +796,10 @@ contract('Linguo', function(accounts) {
})
await linguo.submitTranslation(0, 'ipfs:/X', { from: translator })

const task = await linguo.tasks(0)
const price = task[6].toNumber()
// DEL: const task = await linguo.tasks(0)
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
const challengerDeposit =
arbitrationFee + (challengeMultiplier * price) / MULTIPLIER_DIVISOR + 1000
(await linguo.getChallengeValue(0)).toNumber() + 1000
await linguo.challengeTranslation(0, {
from: challenger,
value: challengerDeposit
Expand All @@ -832,11 +822,10 @@ contract('Linguo', function(accounts) {
})
await linguo.submitTranslation(0, 'ipfs:/X', { from: translator })

const task = await linguo.tasks(0)
const price = task[6].toNumber()
// DEL: const task = await linguo.tasks(0)
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
const challengerDeposit =
arbitrationFee + (challengeMultiplier * price) / MULTIPLIER_DIVISOR + 1000
(await linguo.getChallengeValue(0)).toNumber() + 1000
await linguo.challengeTranslation(0, {
from: challenger,
value: challengerDeposit
Expand All @@ -862,10 +851,9 @@ contract('Linguo', function(accounts) {
await linguo.submitTranslation(0, 'ipfs:/X', { from: translator })

task = await linguo.tasks(0)
const price = task[6].toNumber()
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
const challengerDeposit =
arbitrationFee + (challengeMultiplier * price) / MULTIPLIER_DIVISOR + 1000
(await linguo.getChallengeValue(0)).toNumber() + 1000
await linguo.challengeTranslation(0, {
from: challenger,
value: challengerDeposit
Expand Down Expand Up @@ -926,12 +914,11 @@ contract('Linguo', function(accounts) {
})
await linguo.submitTranslation(0, 'ipfs:/X', { from: translator })

const task = await linguo.tasks(0)
const price = task[6].toNumber()
// DEL: const task = await linguo.tasks(0)

// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
const challengerDeposit =
arbitrationFee + (challengeMultiplier * price) / MULTIPLIER_DIVISOR + 1000
(await linguo.getChallengeValue(0)).toNumber() + 1000
await linguo.challengeTranslation(0, {
from: challenger,
value: challengerDeposit
Expand Down Expand Up @@ -1029,11 +1016,10 @@ contract('Linguo', function(accounts) {
})
await linguo.submitTranslation(0, 'ipfs:/X', { from: translator })

const task = await linguo.tasks(0)
const price = task[6].toNumber()
// DEL: const task = await linguo.tasks(0)
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
const challengerDeposit =
arbitrationFee + (challengeMultiplier * price) / MULTIPLIER_DIVISOR + 1000
(await linguo.getChallengeValue(0)).toNumber() + 1000
await linguo.challengeTranslation(0, {
from: challenger,
value: challengerDeposit
Expand Down Expand Up @@ -1113,11 +1099,10 @@ contract('Linguo', function(accounts) {
})
await linguo.submitTranslation(0, 'ipfs:/X', { from: translator })

const task = await linguo.tasks(0)
const price = task[6].toNumber()
// DEL: const task = await linguo.tasks(0)
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
const challengerDeposit =
arbitrationFee + (challengeMultiplier * price) / MULTIPLIER_DIVISOR + 1000
(await linguo.getChallengeValue(0)).toNumber() + 1000
await linguo.challengeTranslation(0, {
from: challenger,
value: challengerDeposit
Expand Down