Skip to content

Commit

Permalink
fix(vault): adapt based on comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zgorizzo69 committed May 3, 2022
1 parent cde5a67 commit c40b080
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 26 deletions.
2 changes: 0 additions & 2 deletions contracts/facets/MeTokenRegistryFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ contract MeTokenRegistryFacet is
MeTokenInfo storage meTokenInfo = s.meTokens[meToken];
require(LibMeta.msgSender() == meTokenInfo.owner, "!owner");
require(meTokenInfo.targetHubId != 0, "!resubscribing");
// TODO: validiate !IMigration(meTokenInfo.migration).migrationStarted(meToken)
// and do this interface for sameAssetMigration
require(
IMigration(meTokenInfo.migration).canCancelResubscribe(meToken),
"cannot cancel resubscribe"
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,5 @@ interface IVault {
/// when a vault is registered to a new hub
/// @param encodedArgs Additional encoded arguments
/// @return True if encoded args are valid, else false
function isValid(bytes memory encodedArgs) external returns (bool);
function isValid(bytes memory encodedArgs) external pure returns (bool);
}
14 changes: 7 additions & 7 deletions contracts/migrations/SameAssetTransferMigration.sol
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,6 @@ contract SameAssetTransferMigration is ReentrancyGuard, Vault, IMigration {
usts = _sameAssetMigration[meToken];
}

/// @inheritdoc Vault
function isValid(
bytes memory /* encodedArgs */
) external view override returns (bool) {
return true;
}

/// @inheritdoc IMigration
function migrationStarted(address meToken)
external
Expand All @@ -140,4 +133,11 @@ contract SameAssetTransferMigration is ReentrancyGuard, Vault, IMigration {
{
return !_sameAssetMigration[meToken].started;
}

/// @inheritdoc Vault
function isValid(
bytes memory /* encodedArgs */
) external pure override returns (bool) {
return true;
}
}
30 changes: 15 additions & 15 deletions contracts/migrations/UniswapSingleTransferMigration.sol
Original file line number Diff line number Diff line change
Expand Up @@ -139,21 +139,6 @@ contract UniswapSingleTransferMigration is ReentrancyGuard, Vault, IMigration {
usts = _uniswapSingleTransfers[meToken];
}

/// @inheritdoc Vault
function isValid(bytes memory encodedArgs)
external
view
override
returns (bool)
{
// encodedArgs empty
if (encodedArgs.length == 0) return false;
uint24 fee = abi.decode(encodedArgs, (uint24));

// Must have valid fees
return (fee == MINFEE || fee == MIDFEE || fee == MAXFEE);
}

/// @inheritdoc IMigration
function migrationStarted(address meToken)
external
Expand All @@ -175,6 +160,21 @@ contract UniswapSingleTransferMigration is ReentrancyGuard, Vault, IMigration {
return (usts.fee != 0 && !usts.started);
}

/// @inheritdoc Vault
function isValid(bytes memory encodedArgs)
external
pure
override
returns (bool)
{
// encodedArgs empty
if (encodedArgs.length == 0) return false;
uint24 fee = abi.decode(encodedArgs, (uint24));

// Must have valid fees
return (fee == MINFEE || fee == MIDFEE || fee == MAXFEE);
}

/// @dev parent call must have reentrancy check
function _swap(address meToken) private returns (uint256 amountOut) {
UniswapSingleTransfer storage usts = _uniswapSingleTransfers[meToken];
Expand Down
2 changes: 1 addition & 1 deletion contracts/vaults/Vault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ contract Vault is IVault, ReentrancyGuard {
/// @inheritdoc IVault
function isValid(
bytes memory /* encodedArgs */
) external virtual override returns (bool) {
) external pure virtual override returns (bool) {
return true;
}
}

0 comments on commit c40b080

Please sign in to comment.