Skip to content
Permalink
Browse files

feat: implement appealCreatedAt

  • Loading branch information...
satello committed Jun 5, 2018
1 parent 11f77b4 commit 2517bf46ef08b57b786fa7d4ae15c00a936b27d9
@@ -605,6 +605,32 @@ class KlerosPOC extends ContractImplementation {
return eventLogTimestamps
}

/**
* Get the event log for the dispute creation.
* @param {Number} disputeId - The block number that the dispute was created.
* @returns {Promise}
*/
getAppealCreationTimestamps = async (startBlock, numberOfAppeals) => {
const eventLogs = await this._getNewPeriodEventLogs(
blockNumber,
arbitratorConstants.PERIOD.VOTE,
numberOfAppeals + 1
)

const eventLogTimestamps = [startBlock]

// skip first execute phase as this is the original ruling
for (let i=1; i<eventLogs.length; i++) {
const eventLog = eventLogs[i]

const timestamp = await this._getTimestampForBlock(eventLog.blockNumber)

eventLogTimestamps.push(timestamp * 1000)
}

return eventLogTimestamps
}

/**
* Get the event log for the dispute creation.
* @param {Number} disputeId - The block number that the dispute was created.
@@ -166,10 +166,9 @@ class Disputes {

// Get dispute data from the store
let appealDraws = []
let appealCreatedAt = null
let appealCreatedAt = []
let appealDeadlines = []
let appealRuledAt = []
let netPNK = 0
let startBlock
try {
const userData = await this._StoreProviderInstance.getDispute(
@@ -198,6 +197,10 @@ class Disputes {
startBlock,
dispute.numberOfAppeals
)
appealCreatedAt = await this._ArbitratorInstance.getAppealCreationTimestamps(
startBlock,
dispute.numberOfAppeals
)
}

const netPNK = await this._ArbitratorInstance.getNetTokensForDispute(
@@ -241,6 +244,7 @@ class Disputes {
;[ruling, canRule] = await Promise.all(rulingPromises)

appealJuror[appeal] = {
createdAt: appealCreatedAt[appeal],
fee: dispute.arbitrationFeePerJuror * draws.length,
draws,
canRule
@@ -272,8 +276,8 @@ class Disputes {
disputeStatus: dispute.status,
appealJuror,
appealRulings,
appealCreatedAt, // there is only one timestamp for when dispute was first created
netPNK
netPNK,
disputeCreatedAt,

// Store Data
title: contractStoreData ? contractStoreData.title : undefined,
@@ -314,6 +314,7 @@ class Notifications {
const notification = await this._newNotification(
account,
event.transactionHash,
event.blockNumber,
openDispute.disputeId, // use disputeId instead of logIndex since it doens't have its own event
notificationConstants.TYPE.APPEAL_POSSIBLE,
'A ruling has been made. Appeal is possible',
@@ -354,6 +355,7 @@ class Notifications {
const notification = await this._newNotification(
account,
txHash,
event.blockNumber,
event.logIndex,
notificationConstants.TYPE.DISPUTE_CREATED,
'New Dispute Created',
@@ -392,6 +394,7 @@ class Notifications {
const notification = await this._newNotification(
account,
event.transactionHash,
event.blockNumber,
event.logIndex,
notificationConstants.TYPE.APPEAL_POSSIBLE,
'A ruling has been made. Appeal is possible',
@@ -429,6 +432,7 @@ class Notifications {
const notification = await this._newNotification(
account,
event.transactionHash,
event.blockNumber,
event.logIndex,
notificationConstants.TYPE.RULING_APPEALED,
'A ruling been appealed',
@@ -460,6 +464,7 @@ class Notifications {
const notification = await this._newNotification(
account,
event.transactionHash,
event.blockNumber,
event.logIndex,
notificationConstants.TYPE.TOKEN_SHIFT,
'Tokens have been redistributed',
@@ -492,6 +497,7 @@ class Notifications {
const notification = await this._newNotification(
account,
event.transactionHash,
event.blockNumber,
event.logIndex,
notificationConstants.TYPE.ARBITRATION_REWARD,
'Juror awarded arbitration fee',
@@ -558,13 +564,17 @@ class Notifications {
_newNotification = async (
account,
txHash,
blockNumber,
logIndex,
notificationType,
message = '',
data = {},
read = false
) => {
if (this._StoreProviderInstance) {
// update last block we have processed an event for
await this._StoreProviderInstance.updateLastBlock(account, blockNumber)

const response = await this._StoreProviderInstance.newNotification(
account,
txHash,
@@ -172,7 +172,7 @@ class StoreProviderWrapper {
`${this._storeUri}/${userAddress}`
)
if (response.status !== 201)
throw new Error(errorConstants.REQUEST_FAILED(response.responseText))
throw new Error(errorConstants.REQUEST_FAILED(response))
userProfile = response.body
}

@@ -229,10 +229,6 @@ class StoreProviderWrapper {
`${this._storeUri}/${userAddress}/contracts/${contractAddress}`
)

if (httpResponse.status !== 201) {
throw new Error(errorConstants.REQUEST_FAILED(httpResponse.error))
}

return _.filter(
httpResponse.body[0].contracts,
contract => contract.address === contractAddress

0 comments on commit 2517bf4

Please sign in to comment.
You can’t perform that action at this time.