Skip to content

Commit

Permalink
refactor transfer funds to voucher
Browse files Browse the repository at this point in the history
  • Loading branch information
gfournieriExec committed Jun 10, 2024
1 parent c57e4ab commit bc24e63
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions contracts/VoucherHub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,10 @@ contract VoucherHub is
// The proxy contract does a delegatecall to its implementation.
// Re-Entrancy safe because the target contract is controlled.
Voucher(voucherAddress).initialize(owner, address(this), expiration, voucherType);
// SRLC
if (!IERC20($._iexecPoco).transfer(voucherAddress, value)) {
revert("VoucherHub: SRLC transfer to voucher failed");
}
_mint(voucherAddress, value); // VCHR
$._isVoucher[voucherAddress] = true;
emit VoucherCreated(voucherAddress, owner, voucherType, expiration, value);
_transfertFundsToVoucher($._iexecPoco, voucherAddress, value); // SRLC
}

/**
Expand All @@ -193,10 +190,7 @@ contract VoucherHub is
VoucherHubStorage storage $ = _getVoucherHubStorage();
require($._isVoucher[voucher], "VoucherHub: unknown voucher");
_mint(voucher, value); // VCHR
if (!IERC20($._iexecPoco).transfer(voucher, value)) {
// SRLC
revert("VoucherHub: SRLC transfer to voucher failed");
}
_transfertFundsToVoucher($._iexecPoco, voucher, value); // SRLC
uint256 expiration = block.timestamp + $.voucherTypes[Voucher(voucher).getType()].duration;
Voucher(voucher).setExpiration(expiration);
emit VoucherToppedUp(voucher, expiration, value);
Expand Down

0 comments on commit bc24e63

Please sign in to comment.