Skip to content

Commit

Permalink
Merge pull request #117 from kleros/feat/getter-arbitrable-transactio…
Browse files Browse the repository at this point in the history
…ns-ids-by-address

[feat] add getter to get arbitration transaction ids by an address
  • Loading branch information
epiqueras authored Sep 7, 2018
2 parents 9e41358 + 2d3f384 commit 2e9b964
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions contracts/standard/arbitration/MultipleArbitrableTransaction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -331,4 +331,19 @@ contract MultipleArbitrableTransaction {
function getCountTransactions() public view returns (uint countTransactions) {
return transactions.length;
}

/** @dev Get IDs for transactions where the specified address is the buyer and/or the seller.
* @param _address The specified address.
* @return The transaction IDs.
*/
function getTransactionIDsByAddress(address _address) public view returns (uint[] transactionIDs) {
uint[] memory transactionIDsBigArr = new uint[](transactions.length);
uint count = 0;
for (uint i = 0; i < transactions.length; i++)
if (transactions[i].seller == _address || transactions[i].buyer == _address)
transactionIDsBigArr[count++] = i;

transactionIDs = new uint[](count);
for (uint j = 0; j < count; j++) transactionIDs[j] = transactionIDsBigArr[j];
}
}

0 comments on commit 2e9b964

Please sign in to comment.