Skip to content

Commit

Permalink
fix naming, comments (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
YouStillAlive committed Apr 11, 2024
1 parent bc1db3a commit 6f6965b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion contracts/SimpleBuilder/SimpleBuilder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ contract SimpleBuilder is ERC721Holder, BuilderInternal, FirewallConsumer {
locals.provider = ISimpleProvider(addressParams[0]);
UserPool calldata firstUserData = userData.userPools[0];
locals.length = userData.userPools.length;
// one time transfer for deacrease number transactions
// one time transfer for decreasing the number of transactions
uint256[] memory simpleParams = _concatParams(firstUserData.amount, params);
locals.poolId = _createFirstNFT(locals.provider, locals.token, firstUserData.user, locals.totalAmount, simpleParams, signature);
locals.totalAmount -= firstUserData.amount;
Expand Down
12 changes: 6 additions & 6 deletions contracts/SimpleRefundBuilder/RefundBuilderInternal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ abstract contract RefundBuilderInternal is RefundBuilderState, FirewallConsumer
/// @notice Creates the collateral provider
/// @param data Rebuilder struct containing mainCoin data
/// @param collateralFinishTime Finish time for refund
/// @return poolId Collateral pool ID
/// @return collateralPoolId Collateral pool ID
function _createCollateralProvider(
Rebuilder memory data,
uint256 collateralFinishTime
) internal firewallProtectedSig(0x4516d406) returns (uint256 poolId) {
poolId = lockDealNFT.safeMintAndTransfer(
) internal firewallProtectedSig(0x4516d406) returns (uint256 collateralPoolId) {
collateralPoolId = lockDealNFT.safeMintAndTransfer(
msg.sender,
data.paramsData.mainCoin,
msg.sender,
Expand All @@ -56,8 +56,8 @@ abstract contract RefundBuilderInternal is RefundBuilderState, FirewallConsumer
collateralParams[0] = data.userData.totalAmount;
collateralParams[1] = data.paramsData.mainCoinAmount;
collateralParams[2] = collateralFinishTime;
collateralProvider.registerPool(poolId, collateralParams);
lockDealNFT.cloneVaultId(poolId + 2, data.tokenPoolId);
collateralProvider.registerPool(collateralPoolId, collateralParams);
lockDealNFT.cloneVaultId(collateralPoolId + 2, data.tokenPoolId);
}

/// @notice Updates collateral data
Expand Down Expand Up @@ -113,7 +113,7 @@ abstract contract RefundBuilderInternal is RefundBuilderState, FirewallConsumer

/// @notice Iterates over user data to create refund pools for each user
/// @param data Users data, paramsData, tokenPoolId, simple provider address
function _userDataIterator(
function _buildMassPools(
Rebuilder memory data
) internal firewallProtectedSig(0xbbc1f709) {
uint256 length = data.userData.userPools.length;
Expand Down
20 changes: 10 additions & 10 deletions contracts/SimpleRefundBuilder/SimpleRefundBuilder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ contract SimpleRefundBuilder is RefundBuilderInternal, IERC721Receiver {
/// @dev This function is called when an NFT is transferred to this contract
/// @param operator - the address that called the `safeTransferFrom` function
/// @param user - the address that owns the NFT
/// @param poolId - the ID of the Collateral NFT
/// @param collateralPoolId - the ID of the Collateral NFT
/// @param data - additional data with the NFT
function onERC721Received(address operator, address user, uint256 poolId, bytes calldata data) external virtual override firewallProtected returns (bytes4) {
function onERC721Received(address operator, address user, uint256 collateralPoolId, bytes calldata data) external virtual override firewallProtected returns (bytes4) {
require(msg.sender == address(lockDealNFT), "SimpleRefundBuilder: Only LockDealNFT contract allowed");
if (operator != address(this)) {
require(lockDealNFT.poolIdToProvider(poolId) == collateralProvider, "SimpleRefundBuilder: Invalid collateral provider");
require(lockDealNFT.poolIdToProvider(collateralPoolId) == collateralProvider, "SimpleRefundBuilder: Invalid collateral provider");
require(data.length > 0, "SimpleRefundBuilder: Invalid data length");
Rebuilder memory locals;
(
Expand All @@ -33,16 +33,16 @@ contract SimpleRefundBuilder is RefundBuilderInternal, IERC721Receiver {
locals.userData
) = abi.decode(data, (bytes, bytes, Builder));
require(locals.userData.userPools.length > 0, "SimpleRefundBuilder: invalid user length");
locals.paramsData = _getParamsData(poolId, locals.userData.totalAmount, locals.userData.userPools[0].amount);
// one time token transfer for deacrease number transactions
locals.paramsData = _getParamsData(collateralPoolId, locals.userData.totalAmount, locals.userData.userPools[0].amount);
// one time transfer for decreasing the number of transactions
locals.tokenPoolId = _createFirstNFT(locals, operator);
locals.paramsData.refundParams = _registerRefundProvider(locals.tokenPoolId - 1, poolId);
locals.paramsData.refundParams = _registerRefundProvider(locals.tokenPoolId - 1, collateralPoolId);
// update the collateral data and create another nft to transfer the mainСoin amount
_updateCollateralData(locals, operator, poolId + 3);
_updateCollateralData(locals, operator, collateralPoolId + 3);
// create mass refund pools
_userDataIterator(locals);
_buildMassPools(locals);
// // transfer back the NFT to the user
lockDealNFT.transferFrom(address(this), user, poolId);
lockDealNFT.transferFrom(address(this), user, collateralPoolId);
}
return this.onERC721Received.selector;
}
Expand Down Expand Up @@ -70,6 +70,6 @@ contract SimpleRefundBuilder is RefundBuilderInternal, IERC721Receiver {
locals.paramsData.simpleParams = _concatParams(userData.userPools[0].amount, params[1]);
locals.tokenPoolId = _createFirstNFT(locals);
locals.paramsData.refundParams = _finalizeFirstNFT(locals, params[0][1]);
_userDataIterator(locals);
_buildMassPools(locals);
}
}

0 comments on commit 6f6965b

Please sign in to comment.