From bc24e63085f4e6a3705da855a07f28e029410fc4 Mon Sep 17 00:00:00 2001 From: Gabriel Fournier Date: Mon, 10 Jun 2024 17:07:41 +0200 Subject: [PATCH] refactor transfer funds to voucher --- contracts/VoucherHub.sol | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/contracts/VoucherHub.sol b/contracts/VoucherHub.sol index 92a2d1d..448c726 100644 --- a/contracts/VoucherHub.sol +++ b/contracts/VoucherHub.sol @@ -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 } /** @@ -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);