@@ -307,8 +307,8 @@ contract IexecHub
307307 string _uri )
308308 public returns (bool )
309309 {
310+ require (m_woidRegistered[_woid]);
310311 WorkOrder workorder = WorkOrder (_woid);
311-
312312 require (workorder.m_workerpool () == msg .sender );
313313 require (workorder.m_status () == IexecLib.WorkOrderStatusEnum.REVEALING);
314314
@@ -338,9 +338,12 @@ contract IexecHub
338338 * reward = value: was locked at market making
339339 * emitcost: was locked at when emiting the workorder
340340 */
341- uint256 value = marketplace.getMarketOrderValue (workorder.m_marketorderIdx ()); // revert if not exist
342- address workerpoolOwner = marketplace.getMarketOrderWorkerpoolOwner (workorder.m_marketorderIdx ()); // revert if not exist
343- uint256 workerpoolStake = value.percentage (marketplace.ASK_STAKE_RATIO ());
341+ /* uint256 value = marketplace.getMarketOrderValue(workorder.m_marketorderIdx()); // revert if not exist */
342+ /* address workerpoolOwner = marketplace.getMarketOrderWorkerpoolOwner(workorder.m_marketorderIdx()); // revert if not exist */
343+ uint256 value;
344+ address workerpoolOwner;
345+ (,,,value,,,,workerpoolOwner) = marketplace.getMarketOrder (workorder.m_marketorderIdx ());
346+ uint256 workerpoolStake = value.percentage (marketplace.ASK_STAKE_RATIO ());
344347
345348 require (seize (workorder.m_requester (), value.add (workorder.m_emitcost ()))); // seize funds for payment (market value + emitcost)
346349 require (unlock (workerpoolOwner, workerpoolStake)); // unlock scheduler stake
@@ -350,13 +353,14 @@ contract IexecHub
350353
351354 // Rien ne se perd, rien ne se crée, tout se transfere
352355 // distribute bonus to scheduler. jackpot bonus come from scheduler stake loose on IexecHub contract
353- uint256 kitty;
354- (,kitty) = checkBalance (this ); // kitty is locked on `this` wallet
355- if (kitty > 0 )
356+ // we reuse the varaible value for the kitty / fraction of the kitty (stack too deep)
357+ /* (,value) = checkBalance(this); // kitty is locked on `this` wallet */
358+ value = m_accounts[this ].locked; // kitty is locked on `this` wallet
359+ if (value > 0 )
356360 {
357- uint256 kittyFraction = kitty .min (kitty .percentage (STAKE_BONUS_RATIO).max (STAKE_BONUS_MIN_THRESHOLD));
358- require (seize (this , kittyFraction ));
359- require (reward (workerpoolOwner, kittyFraction ));
361+ value = value .min (value .percentage (STAKE_BONUS_RATIO).max (STAKE_BONUS_MIN_THRESHOLD));
362+ require (seize (this , value ));
363+ require (reward (workerpoolOwner, value ));
360364 }
361365
362366 emit WorkOrderCompleted (_woid, workorder.m_workerpool ());
@@ -466,21 +470,23 @@ contract IexecHub
466470 /* Work */
467471 function lockForWork (address _woid , address _user , uint256 _amount ) public returns (bool )
468472 {
473+ require (m_woidRegistered[_woid]);
469474 require (WorkOrder (_woid).m_workerpool () == msg .sender );
470475 require (lock (_user, _amount));
471476 return true ;
472477 }
473478 function unlockForWork (address _woid , address _user , uint256 _amount ) public returns (bool )
474479 {
480+ require (m_woidRegistered[_woid]);
475481 require (WorkOrder (_woid).m_workerpool () == msg .sender );
476482 require (unlock (_user, _amount));
477483 return true ;
478484 }
479485 function rewardForWork (address _woid , address _worker , uint256 _amount , bool _reputation ) public returns (bool )
480486 {
487+ require (m_woidRegistered[_woid]);
481488 require (WorkOrder (_woid).m_workerpool () == msg .sender );
482489 require (reward (_worker, _amount));
483- // ------------------------------------------------------------------------
484490 if (_reputation)
485491 {
486492 m_contributionHistory.success = m_contributionHistory.success.add (1 );
@@ -491,9 +497,9 @@ contract IexecHub
491497 }
492498 function seizeForWork (address _woid , address _worker , uint256 _amount , bool _reputation ) public returns (bool )
493499 {
500+ require (m_woidRegistered[_woid]);
494501 require (WorkOrder (_woid).m_workerpool () == msg .sender );
495502 require (seize (_worker, _amount));
496- // ------------------------------------------------------------------------
497503 if (_reputation)
498504 {
499505 m_contributionHistory.failled = m_contributionHistory.failled.add (1 );
0 commit comments