Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Commit

Permalink
Merge bcfcbb0 into d08db7a
Browse files Browse the repository at this point in the history
  • Loading branch information
n1c01a5 committed Sep 11, 2018
2 parents d08db7a + bcfcbb0 commit 89bb804
Show file tree
Hide file tree
Showing 11 changed files with 597 additions and 114 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"ethereumjs-util": "^5.2.0",
"ethjs": "^0.4.0",
"kleros": "^0.0.6",
"kleros-interaction": "^0.0.22",
"kleros-interaction": "^0.0.24",
"lodash": "^4.17.4",
"minimetoken": "^0.2.0",
"truffle-contract": "^2.0.5",
Expand Down
4 changes: 2 additions & 2 deletions src/constants/contract.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const STATUS = {
NO_DISPUTE: 0,
WAITING_PARTY_A: 1,
WAITING_PARTY_B: 2,
WAITING_SELLER: 1,
WAITING_BUYER: 2,
DISPUTE_CREATED: 3,
RESOLVED: 4
}
3 changes: 3 additions & 0 deletions src/constants/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,15 @@ export const DISPUTE_DOES_NOT_EXIST = disputeID =>
`Dispute ${disputeID} does not exist`

// ArbitrableTransaction
export const UNABLE_TO_CREATE_TRANSACTION =
'Unable to create a new transaction.'
export const UNABLE_TO_PAY_ARBITRATION_FEE =
'Unable to pay fee, are you sure you have enough PNK?'
export const UNABLE_TO_RAISE_AN_APPEAL =
'Unable to raise appeal, are you sure you are in the appeal period?'
export const UNABLE_TO_PAY_SELLER =
'Unable to pay the seller, are you sure you have enough ETH?'
export const UNABLE_TO_REIMBURSE_BUYER = 'Unable to reimburse the buyer.'
export const UNABLE_TO_CALL_TIMEOUT = 'Unable to call timeout.'
export const CONTRACT_IS_NOT_WAITING_ON_OTHER_PARTY =
'Unable to call timeout, because the contract is not waiting on the other party.'
Expand Down
59 changes: 59 additions & 0 deletions src/contracts/abstractions/MultipleArbitrable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import AbstractContract from '../AbstractContract'

/**
* Arbitrable Abstract Contarct API. This wraps an arbitrable contract. It provides
* interaction with both the off chain store as well as the arbitrable instance. All
* arbitrable methods from the supplied contract implementation can be called from this
* object.
*/
class ArbitrableContract extends AbstractContract {
/**
* Submit evidence. FIXME should we determine the hash for the user?
* @param {string} account - ETH address of user.
* @param {string} arbitrableTransactionId - Id of the arbitrable transaction.
* @param {string} name - Name of evidence.
* @param {string} description - Description of evidence.
* @param {string} url - A link to an evidence using its URI.
* @param {string} hash - A hash of the evidence at the URI. No hash if content is dynamic
* @returns {string} - txHash Hash transaction.
*/
submitEvidence = async (
account,
arbitrableTransactionId,
name,
description,
url,
hash
) => {
const contractAddress = this._contractImplementation.contractAddress

// get the index of the new evidence
const evidenceIndex = await this._StoreProvider.addEvidenceContract(
contractAddress,
arbitrableTransactionId,
account,
name,
description,
url,
hash
)

// construct the unique URI
const evidenceUri = this._StoreProvider.getEvidenceUri(
account,
contractAddress,
arbitrableTransactionId,
evidenceIndex
)

const txHash = await this._contractImplementation.submitEvidence(
account,
arbitrableTransactionId,
evidenceUri
)

return txHash
}
}

export default ArbitrableContract
17 changes: 15 additions & 2 deletions src/contracts/implementations/arbitrable/Arbitrable.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Arbitrable extends ContractImplementation {
* and make an http request to the resource.
* @returns {object} The metaEvidence object
*/
getMetaEvidence = async () => {
getMetaEvidence = async (metaEvidenceID = 0) => {
if (this.metaEvidenceCache[this.contractAddress])
return this.metaEvidenceCache[this.contractAddress]

Expand All @@ -35,7 +35,7 @@ class Arbitrable extends ContractImplementation {
'MetaEvidence',
0,
'latest',
{ _metaEvidenceID: 0 }
{ _metaEvidenceID: metaEvidenceID }
)

if (!metaEvidenceLog[0]) return {} // NOTE better to throw errors for missing meta-evidence?
Expand Down Expand Up @@ -88,6 +88,19 @@ class Arbitrable extends ContractImplementation {
})
)
}

/**
* Fetch all standard contract data.
*/
getContractData = async () => {
await this.loadContract()

const [metaEvidence] = await Promise.all([this.getMetaEvidence()])

return {
metaEvidence
}
}
}

export default Arbitrable

0 comments on commit 89bb804

Please sign in to comment.