Skip to content

Commit

Permalink
add iExecpoco address to _debitVoucherAndTransfer input
Browse files Browse the repository at this point in the history
  • Loading branch information
gfournieriExec committed Apr 29, 2024
1 parent bba6389 commit 7932b61
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions contracts/beacon/Voucher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,17 @@ contract Voucher is OwnableUpgradeable, IVoucher {
// TODO check expiration
VoucherStorage storage $ = _getVoucherStorage();
IVoucherHub voucherHub = IVoucherHub($._voucherHub);
address iexecPoco = voucherHub.getIexecPoco();
uint256 sponsoredAmount = _debitVoucherAndTransfer(
$._type,
$._voucherHub,
iexecPoco,
appOrder,
datasetOrder,
workerpoolOrder,
requestOrder
);
dealId = IexecPoco1(voucherHub.getIexecPoco()).sponsorMatchOrders(
dealId = IexecPoco1(iexecPoco).sponsorMatchOrders(
appOrder,
datasetOrder,
workerpoolOrder,
Expand Down Expand Up @@ -146,15 +148,17 @@ contract Voucher is OwnableUpgradeable, IVoucher {
) external onlyAuthorized onlyNotExpired returns (bytes32 dealId) {
VoucherStorage storage $ = _getVoucherStorage();
IVoucherHub voucherHub = IVoucherHub($._voucherHub);
address iexecPoco = voucherHub.getIexecPoco();
uint256 sponsoredAmount = _debitVoucherAndTransfer(
$._type,
$._voucherHub,
iexecPoco,
appOrder,
datasetOrder,
workerpoolOrder,
requestOrder
);
dealId = IexecPocoBoost(voucherHub.getIexecPoco()).sponsorMatchOrdersBoost(
dealId = IexecPocoBoost(iexecPoco).sponsorMatchOrdersBoost(
appOrder,
datasetOrder,
workerpoolOrder,
Expand Down Expand Up @@ -246,8 +250,9 @@ contract Voucher is OwnableUpgradeable, IVoucher {
* @return sponsoredAmount The amount sponsored by the voucher.
*/
function _debitVoucherAndTransfer(
uint256 _type,
address _voucherHub,
uint256 voucherTypeId,
address voucherHub,
address iexecPoco,
IexecLibOrders_v5.AppOrder calldata appOrder,
IexecLibOrders_v5.DatasetOrder calldata datasetOrder,
IexecLibOrders_v5.WorkerpoolOrder calldata workerpoolOrder,
Expand All @@ -256,10 +261,9 @@ contract Voucher is OwnableUpgradeable, IVoucher {
uint256 appPrice = appOrder.appprice;
uint256 datasetPrice = datasetOrder.datasetprice;
uint256 workerpoolPrice = workerpoolOrder.workerpoolprice;
IVoucherHub voucherHub = IVoucherHub(_voucherHub);

sponsoredAmount = voucherHub.debitVoucher(
_type,
sponsoredAmount = IVoucherHub(voucherHub).debitVoucher(
voucherTypeId,
appOrder.app,
appPrice,
datasetOrder.dataset,
Expand All @@ -269,7 +273,6 @@ contract Voucher is OwnableUpgradeable, IVoucher {
);

uint256 dealPrice = appPrice + datasetPrice + workerpoolPrice;
address iexecPoco = voucherHub.getIexecPoco();

if (sponsoredAmount != dealPrice) {
// Transfer non-sponsored amount from the iExec account of the
Expand Down

0 comments on commit 7932b61

Please sign in to comment.