Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions src/IdGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,26 @@ contract IdGateway is IIdGateway, Guardians, Signatures, EIP712, Nonces {
//////////////////////////////////////////////////////////////*/

function _rentStorage(
uint256 fid,
uint256 extraUnits,
uint256 payment,
address payer
uint256 fid,
uint256 extraUnits,
uint256 payment,
address payer
) internal returns (uint256 overpayment) {
overpayment = storageRegistry.rent{value: payment}(fid, 1 + extraUnits);

if (overpayment > 0) {
payer.sendNative(overpayment);
}
// Calculate the overpayment before making any external calls
uint256 amountToRent = 1 + extraUnits;
overpayment = payment - storageRegistry.price(amountToRent);

// Make the external call to rent storage
storageRegistry.rent{value: payment}(fid, amountToRent);

// Return the overpayment after the external call
if (overpayment > 0) {
(bool success, ) = payer.call{value: overpayment}("");
require(success, "Transfer failed");
}
}


receive() external payable {
if (msg.sender != address(storageRegistry)) revert Unauthorized();
}
Expand Down