@@ -19,8 +19,10 @@ contract MultipleArbitrableTransactionWithFee is IArbitrable {
1919 // **************************** //
2020
2121 uint8 constant AMOUNT_OF_CHOICES = 2 ;
22+ uint8 constant SENDER_WINS = 1 ;
23+ uint8 constant RECEIVER_WINS = 2 ;
2224
23- enum Party {None, Sender, Receiver}
25+ enum Party {Sender, Receiver}
2426 enum Status {NoDispute, WaitingSender, WaitingReceiver, DisputeCreated, Resolved}
2527
2628 struct Transaction {
@@ -98,7 +100,7 @@ contract MultipleArbitrableTransactionWithFee is IArbitrable {
98100 * @param _arbitrator The arbitrator of the contract.
99101 * @param _arbitratorExtraData Extra data for the arbitrator.
100102 * @param _feeRecipient Address which receives a % of receiver payment.
101- * @param _feeRecipientBasisPoint // The % of fee to be received by the feeRecipient, down to 2 decimal places as 550 = 5.5%.
103+ * @param _feeRecipientBasisPoint The % of fee to be received by the feeRecipient, down to 2 decimal places as 550 = 5.5%.
102104 * @param _feeTimeout Arbitration fee timeout for the parties.
103105 */
104106 constructor (
@@ -127,7 +129,6 @@ contract MultipleArbitrableTransactionWithFee is IArbitrable {
127129 address _receiver ,
128130 string _metaEvidence
129131 ) public payable returns (uint transactionID ) {
130- transactionID = transactions.length ;
131132 transactions.push (Transaction ({
132133 sender: msg .sender ,
133134 receiver: _receiver,
@@ -141,6 +142,8 @@ contract MultipleArbitrableTransactionWithFee is IArbitrable {
141142 }));
142143 emit MetaEvidence (transactions.length - 1 , _metaEvidence);
143144 emit TransactionCreated (transactions.length - 1 , msg .sender , _receiver, msg .value );
145+
146+ return transactions.length - 1 ;
144147 }
145148
146149 /** @dev Calculate the amount to be paid in wei according to feeRecipientBasisPoint for a particular amount.
@@ -193,10 +196,8 @@ contract MultipleArbitrableTransactionWithFee is IArbitrable {
193196 require (transaction.status == Status.NoDispute, "The transaction shouldn't be disputed. " );
194197 require (_amountReimbursed <= transaction.amount, "The amount reimbursed has to be less or equal than the transaction. " );
195198
196- transaction.amount -= _amountReimbursed;
197-
198199 transaction.sender.transfer (_amountReimbursed);
199-
200+ transaction.amount -= _amountReimbursed;
200201 emit Payment (_transactionID, _amountReimbursed, msg .sender );
201202 }
202203
@@ -210,13 +211,13 @@ contract MultipleArbitrableTransactionWithFee is IArbitrable {
210211
211212 uint amount = transaction.amount;
212213 transaction.amount = 0 ;
213-
214214 uint feeAmount = calculateFeeRecipientAmount (amount);
215215 feeRecipient.send (feeAmount);
216216 transaction.receiver.send (amount - feeAmount);
217217
218- transaction.status = Status.Resolved;
219218 emit FeePayment (_transactionID, feeAmount);
219+
220+ transaction.status = Status.Resolved;
220221 }
221222
222223 /** @dev Reimburse sender if receiver fails to pay the fee.
@@ -227,7 +228,11 @@ contract MultipleArbitrableTransactionWithFee is IArbitrable {
227228 require (transaction.status == Status.WaitingReceiver, "The transaction is not waiting on the receiver. " );
228229 require (now - transaction.lastInteraction >= feeTimeout, "Timeout time has not passed yet. " );
229230
230- executeRuling (_transactionID, uint (Party.Sender));
231+ if (transaction.receiverFee != 0 ) {
232+ transaction.receiver.send (transaction.receiverFee);
233+ transaction.receiverFee = 0 ;
234+ }
235+ executeRuling (_transactionID, SENDER_WINS);
231236 }
232237
233238 /** @dev Pay receiver if sender fails to pay the fee.
@@ -238,7 +243,11 @@ contract MultipleArbitrableTransactionWithFee is IArbitrable {
238243 require (transaction.status == Status.WaitingSender, "The transaction is not waiting on the sender. " );
239244 require (now - transaction.lastInteraction >= feeTimeout, "Timeout time has not passed yet. " );
240245
241- executeRuling (_transactionID, uint (Party.Receiver));
246+ if (transaction.senderFee != 0 ) {
247+ transaction.sender.send (transaction.senderFee);
248+ transaction.senderFee = 0 ;
249+ }
250+ executeRuling (_transactionID, RECEIVER_WINS);
242251 }
243252
244253 /** @dev Pay the arbitration fee to raise a dispute. To be called by the sender. UNTRUSTED.
@@ -384,9 +393,9 @@ contract MultipleArbitrableTransactionWithFee is IArbitrable {
384393
385394 // Give the arbitration fee back.
386395 // Note that we use send to prevent a party from blocking the execution.
387- if (_ruling == uint (Party.Sender) ) {
396+ if (_ruling == SENDER_WINS ) {
388397 transaction.sender.send (senderArbitrationFee + amount);
389- } else if (_ruling == uint (Party.Receiver) ) {
398+ } else if (_ruling == RECEIVER_WINS ) {
390399 feeAmount = calculateFeeRecipientAmount (amount);
391400
392401 feeRecipient.send (feeAmount);
0 commit comments