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

Commit

Permalink
refactor(resources): event listener is a util. Make Disputes and Noti…
Browse files Browse the repository at this point in the history
…fications standalone classes.
  • Loading branch information
satello committed Apr 4, 2018
1 parent 190d5c4 commit 257ba80
Show file tree
Hide file tree
Showing 12 changed files with 708 additions and 733 deletions.
11 changes: 11 additions & 0 deletions src/constants/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export const CONTRACT_NOT_DEPLOYED =
'Unable to load contract. Are you sure the contract is deployed and you are on the right network?'
export const UNABLE_TO_LOAD_CONTRACT =
'Unable to load contract. Are you sure the contract artifact is correct?'
export const MISSING_CONTRACT_PARAMETERS =
'Unable to load contract. Missing contractAddress or Artifact. Please call setContractInstance'

// Implementation
export const CONTRACT_INSTANCE_NOT_SET =
Expand Down Expand Up @@ -67,3 +69,12 @@ export const NO_STORE_PROVIDER_SPECIFIED =
// Disputes
export const NO_STORE_DATA_FOR_DISPUTE = account =>
`Account ${account} does not have store data for dispute`

// Notifications
export const MISSING_STORE_PROVIDER =
'This method requires the use of an off chain store. Please call setStoreProviderInstance.'

// Event Listener
export const MISSING_CONTRACT_INSTANCE = contractAddress =>
`No contract instance stored for ${contractAddress}. Please call addContractInstance.`
export const ERROR_FETCHING_EVENTS = error => `Unable to fetch events: ${error}`
2 changes: 2 additions & 0 deletions src/contracts/ContractImplementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ class ContractImplementation {
this._contractLoadedRejecter = reject
})

// we have getters so that abstract classes can provide public access to implementations variables
getContractInstance = () => this.contractInstance
getContractAddress = () => this.contractAddress
}

Expand Down
15 changes: 7 additions & 8 deletions src/kleros.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import isRequired from './utils/isRequired'
import Web3Wrapper from './utils/Web3Wrapper'
import StoreProviderWrapper from './utils/StoreProviderWrapper'
import * as contracts from './contracts'
import * as resources from './resourceWrappers'
// import EventListener from './eventListener'
import * as resources from './resources'
import EventListener from './utils/EventListener'

class Kleros {
web3Wrapper = {}
Expand Down Expand Up @@ -53,16 +53,15 @@ class Kleros {
this.storeWrapper
)
// ARBITRABLE CONTRACTS
this.arbitrableContracts = new contracts.abstractions.ArbitrableContracts(
this.arbitrable = new contracts.abstractions.Arbitrable(
_arbitrableTransaction,
this.storeWrapper
)
// EVENT LISTENER
this.eventListener = new resources.EventListeners(
this.arbitrator,
this.arbitrableContracts,
this.storeWrapper
)
this.eventListener = new EventListener([
this.arbitrator._contractImplementation.contractInstance,
this.arbitrable._contractImplementation.contractInstance
])
// DISPUTES
this.disputes = new resources.Disputes(
this.arbitrator,
Expand Down
Loading

0 comments on commit 257ba80

Please sign in to comment.