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

[feat] add multiple arbitrable transaction #163

Merged
merged 25 commits into from
Sep 13, 2018
Merged

Conversation

n1c01a5
Copy link
Contributor

@n1c01a5 n1c01a5 commented Aug 6, 2018

(WARNING) createTransaction transaction has a hardcoded gas limit

@n1c01a5 n1c01a5 requested a review from satello August 6, 2018 16:01
@coveralls
Copy link

coveralls commented Aug 6, 2018

Pull Request Test Coverage Report for Build 830

  • 35 of 79 (44.3%) changed or added relevant lines in 5 files are covered.
  • 168 unchanged lines in 7 files lost coverage.
  • Overall coverage decreased (-15.2%) to 36.417%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/contracts/implementations/arbitrable/Arbitrable.js 0 3 0.0%
src/contracts/abstractions/MultipleArbitrable.js 0 6 0.0%
src/contracts/implementations/arbitrable/MultipleArbitrableTransaction.js 31 66 46.97%
Files with Coverage Reduction New Missed Lines %
src/utils/StoreProviderWrapper.js 2 17.12%
src/utils/Web3Wrapper.js 4 12.0%
src/utils/EventListener.js 5 57.5%
src/contracts/implementations/arbitrable/ArbitrableTransaction.js 18 0.0%
src/contracts/implementations/arbitrable/Arbitrable.js 19 5.13%
src/resources/Notifications.js 36 4.35%
src/contracts/implementations/arbitrator/Kleros.js 84 24.11%
Totals Coverage Status
Change from base Build 814: -15.2%
Covered Lines: 448
Relevant Lines: 1087

💛 - Coveralls

@n1c01a5 n1c01a5 changed the title (WIP)[feat] add multiple arbitrable transaction [feat] add multiple arbitrable transaction Aug 15, 2018
Copy link
Contributor

@satello satello left a comment

Choose a reason for hiding this comment

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

Did you looks at src/contracts/abstractions/Arbitrable.js? That should be able to be abstracted on top of both ArbitrableTransaction and MultipleArbitrableTransaction. The interfaces interact with the abstract contract and if methods don't exist it delegates to the underlying implementation (what you created). Looks like deploy might need to be cleaned up in the arbitrable abstraction.

WAITING_PARTY_A: 1,
WAITING_PARTY_B: 2,
WAITING_BUYER: 2,
WAITING_SELLER: 1,
Copy link
Contributor

Choose a reason for hiding this comment

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

Swap the order of these

{
from: account,
value: this._Web3Wrapper.toWei(value, 'ether'),
gas: 800000 // FIXME gas hardcoded maybe use estimateGas before
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be good to add estimate gas to the Web3Wrapper class

* @param {number} arbitrationCost - Arbitration cost.
* @returns {object} - The result transaction object.
*/
payArbitrationFeeByBuyer = async (
Copy link
Contributor

Choose a reason for hiding this comment

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

Buyer/Seller seems a little use case specific. What about something like Sender/Recipient?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

buyer/seller sounds generic for me and it's this wording buyer/seller is used in the smart contract

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ok. To me it sounds like it has to be for a transaction of goods. But if its in the smart contract it is fine

* @param {number} transactionId - The index of the transaction.
* @returns {object} - The result transaction object.
*/
payArbitrationFeeBySeller = async (
Copy link
Contributor

Choose a reason for hiding this comment

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

Sender?

@@ -1,4 +1,4 @@
import arbitrableTransactionArtifact from 'kleros-interaction/build/contracts/ArbitrableTransaction'
import arbitrableTransactionArtifact from 'kleros-interaction/build/contracts/MultipleArbitrableTransaction'
Copy link
Contributor

Choose a reason for hiding this comment

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

why change this one? We should leave single arbitrable is the old artifact

@satello
Copy link
Contributor

satello commented Aug 20, 2018

And If it isn't possible to have an abstracted deploy it should be removed from the abstract contract @n1c01a5

* @param {number} transactionId - The index of the transaction.
* @returns {object} Object Data of the contract.
*/
getData = async transactionId => {
Copy link
Contributor

@satello satello Aug 20, 2018

Choose a reason for hiding this comment

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

This should be called contractId. transactionId is a commonly used term for the tx hash. Also you are referencing the contract at an index not a transaction unless I am misunderstanding what this is for

Copy link
Contributor Author

@n1c01a5 n1c01a5 Aug 21, 2018

Choose a reason for hiding this comment

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

I agree but basically I prefer used the wording from the smart contract. And the method is createTransaction so the keyword is transaction no contract (and contract can do reference to a smart contract :p)

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we still do something different than transactionId since that is used for tx hashes? Perhaps transactionIndex

Copy link
Contributor

Choose a reason for hiding this comment

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

Or arbitrableTransactionId would work too and is also more descriptive

Copy link
Contributor Author

@n1c01a5 n1c01a5 Aug 29, 2018

Choose a reason for hiding this comment

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

done 7bd98b8

satello
satello previously approved these changes Aug 29, 2018
the store must also updated to match with this api
_party: this._Web3Wrapper.getAccount(0),
_transactionId: this.arbitrableTransactionId
_evidence: evidenceJsonLink
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is going to work. _party and _evidence are not indexed. Also the only reason that we are looking up the event is to fetch the evidenceJsonLink. You shouldn't be able to pass it to getEvidence or else it isn't coming from the blockchain

return metaEvidenceResponse.body || metaEvidenceResponse
}

/**
* Get the evidence submitted in a dispute.
*/
getEvidence = async () => {
getEvidence = async evidenceJsonLink => {
Copy link
Contributor

Choose a reason for hiding this comment

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

How can we pass this? We need to get it form the chain

@@ -45,7 +25,7 @@ class MultipleArbitrable extends ContractImplementation {
* one meta-evidence that is submitted on contract creation. Look up meta-evidence event
* and make an http request to the resource.
*/
getMetaEvidence = async () => {
getMetaEvidence = async (arbitrableTransactionId, metaEvidenceJsonLink) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand why we need these

_transactionId: this.arbitrableTransactionId,
_evidence: this.metaEvidenceJsonLink
_transactionId: arbitrableTransactionId,
_evidence: metaEvidenceJsonLink
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't work. Not indexed

Copy link
Contributor

Choose a reason for hiding this comment

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

Also it looks like MetaEvidence is not following the standard in MultupleArbitrableTransaction (it calls _metaEvidenceID -> _transactionId in the event). This makes it so it is incompatible with the api. Can you change it to follow the standard? It needs to change in the Dispute event as well

@@ -1,6 +1,5 @@
import _ from 'lodash'
Copy link
Contributor

Choose a reason for hiding this comment

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

This file shouldn't exist. The contract should be made standard compliant and then just use Arbitrable.js to fetch evidence and MetaEvidence

@@ -28,12 +29,17 @@ class Arbitrable extends ContractImplementation {
if (this.metaEvidenceCache[this.contractAddress])
return this.metaEvidenceCache[this.contractAddress]

if (this.arbitrableTransactionId === null)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you name this metaEvidenceID (not all arbitrable contracts use transactionId as the metaEvidenceID)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also pass it as a param instead of using this.arbitrableTransactionID and have it default to 0

* @returns {object} truffle-contract Object | err The deployed contract or an error
*/
createArbitrableTransaction = async (
account = this._Web3Wrapper.getAccount(0),
Copy link
Contributor

Choose a reason for hiding this comment

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

I have been taking all these defaults for account out. I think its better if the caller passes the correct account. Especially if its the first param they will have to do it anyways since there are no kwargs

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 don't understand what you say. Can you write the parameters that you want?

satello
satello previously approved these changes Sep 11, 2018
partyB,
arbitrationCost.minus(partyBFeeContractInstance)
// seller pays fee
const raiseDisputeBySellerTxObj = await ArbitrableTransactionInstanceInstance.payArbitrationFeeBySeller(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this test fail. I have no idea why

@satello satello merged commit 49d1695 into develop Sep 13, 2018
@satello satello deleted the multiple_arbitrable_tx branch September 13, 2018 13:58
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.

3 participants