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

Conversation

@satello
Copy link
Contributor

@satello satello commented Mar 29, 2018

  • Another restructuring of the API. Now the 3 base level directories in src/ are contractWrappers, abstractWrappers and resourceWrappers. Moved to a directory based structure (i.e. abstractWrappers/arbitrator/index.js instead of abstractWrappers/arbitrator.js).

  • Arbitrator api now stores the contract instance so that arbitratorAddress never has to be passed. Because of this the functionality is slightly different. Need to pass an arbitrator address when initializing the Kleros api. Or else call kleros.arbitrator.setArbitrator before use of the arbitrator api. We cannot load the contract in the constructor so the address just gets set and then when the first call is made it will check to see if it is loaded and load contractInstance. (There might be an easier way, open to suggestions)

  • expose contract api's via kleros.contracts... instead of having pinakion and blockhashrng be initialized root level api's. Only initialized api's are arbitrator and arbitrableContracts

  • arbitrableContract -> arbitrableContracts throughout the codebase

@satello satello requested review from epiqueras and n1c01a5 March 29, 2018 00:55
@coveralls
Copy link

coveralls commented Mar 29, 2018

Pull Request Test Coverage Report for Build 574

  • 93 of 113 (82.3%) changed or added relevant lines in 14 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+2.6%) to 56.806%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/contractWrappers/arbitrator/StatefulContractWrapper.js 16 17 94.12%
src/contractWrappers/arbitrator/KlerosPOC/index.js 29 33 87.88%
src/resourceWrappers/Notifications/index.js 12 17 70.59%
src/resourceWrappers/Disputes/index.js 8 18 44.44%
Totals Coverage Status
Change from base Build 566: 2.6%
Covered Lines: 554
Relevant Lines: 905

💛 - Coveralls

* @returns {object} contractInstance object
*/
setArbitrator = async (contractAddress, artifact) => {
this.contractAddress = contractAddress || this.contractAddress
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use default params?

return this._load()
}

getContractInstance = () => this.contractInstance
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need getters for public properties.

Copy link
Contributor Author

@satello satello Mar 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed because at least at the moment abstractWrapper/arbitrator is only inheriting/delegating the functions from KlerosPOC. So there is no way to access variables via the api without a getter

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could keep a reference like before, this.contractWrapper.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one but its private at the moment this._contractWrapper. It kind of defeats the purpose of the delegation if its public, as then all those methods can just be called via arbitrator.contactWrapper...., which maybe isn't a bad alternative to trying to be tricky with the delegation, but does require the consumer to have a deeper knowledge of where their calls live

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to leave it as is for now

import ContractWrapper from '../ContractWrapper'
import * as errorConstants from '../../constants/error'

class ArbitratorContract extends ContractWrapper {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StatefulContractWrapper?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -0,0 +1,5 @@
import BlockHashRNG from './BlockHashRNG'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use named exports instead so we can tree-shake.

# [0.2.0](https://github.com/kleros/kleros-api/compare/v0.0.70...v0.2.0) (2018-03-29)

### Bug Fixes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Next time, don't create releases on a branch. It can cause issues with semver tags when merging after a hotfix or another merge.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I am not a huge fan of pushing directly to develop. We can do release branches though

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea.

@epiqueras
Copy link
Contributor

epiqueras commented Mar 29, 2018 via email

@satello satello merged commit e76ed6e into develop Mar 29, 2018
@satello satello deleted the feat/stateful_arbitrator branch May 18, 2018 19:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants