-
Notifications
You must be signed in to change notification settings - Fork 14
Feat/stateful arbitrator #114
Conversation
Pull Request Test Coverage Report for Build 574
💛 - Coveralls |
| * @returns {object} contractInstance object | ||
| */ | ||
| setArbitrator = async (contractAddress, artifact) => { | ||
| this.contractAddress = contractAddress || this.contractAddress |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StatefulContractWrapper?
There was a problem hiding this comment.
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' | |||
|
|
|||
There was a problem hiding this comment.
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 | ||
|
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea.
|
I don’t think it’s wrong to use it internally, It’s “private usage”.
…On Thu, Mar 29, 2018 at 3:40 PM Sam Vitello ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/contractWrappers/arbitrator/Arbitrator.js
<#114 (comment)>:
> + }
+ }
+
+ /**
+ * Set a new arbitrator
+ * @param {string} contractAddress - The address of the contract
+ * @param {object} artifact - Contract artifact to use to load contract
+ * @returns {object} contractInstance object
+ */
+ setArbitrator = async (contractAddress, artifact) => {
+ this.contractAddress = contractAddress || this.contractAddress
+ this.artifact = artifact || this.artifact
+ return this._load()
+ }
+
+ getContractInstance = () => this.contractInstance
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
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#114 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ASRQaLyykeWsUegGVrgiCsgkbwWM-HMpks5tjWLXgaJpZM4S_leA>
.
|
Another restructuring of the API. Now the 3 base level directories in
src/arecontractWrappers,abstractWrappersandresourceWrappers. 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.setArbitratorbefore 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 havingpinakionandblockhashrngbe initialized root level api's. Only initialized api's arearbitratorandarbitrableContractsarbitrableContract->arbitrableContractsthroughout the codebase