Skip to content

Commit

Permalink
Updated deposit sweep and redemption proposal validation
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszslabon committed Mar 7, 2024
1 parent 0e0d829 commit 6b63d2a
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions solidity/contracts/bridge/WalletProposalValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ contract WalletProposalValidator {
/// @param depositsExtraInfo Deposits extra info required to perform the validation.
/// @return True if the proposal is valid. Reverts otherwise.
/// @dev Requirements:
/// - The target wallet must be in the Live state,
/// - The target wallet must be in the Live or MovingFunds state,
/// - The number of deposits included in the sweep must be in
/// the range [1, `DEPOSIT_SWEEP_MAX_SIZE`],
/// - The length of `depositsExtraInfo` array must be equal to the
Expand All @@ -242,10 +242,14 @@ contract WalletProposalValidator {
DepositSweepProposal calldata proposal,
DepositExtraInfo[] calldata depositsExtraInfo
) external view returns (bool) {
Wallets.Wallet memory wallet = bridge.wallets(
proposal.walletPubKeyHash
);

require(
bridge.wallets(proposal.walletPubKeyHash).state ==
Wallets.WalletState.Live,
"Wallet is not in Live state"
wallet.state == Wallets.WalletState.Live ||
wallet.state == Wallets.WalletState.MovingFunds,
"Wallet is not in Live or MovingFunds state"
);

require(proposal.depositsKeys.length > 0, "Sweep below the min size");
Expand Down Expand Up @@ -517,7 +521,7 @@ contract WalletProposalValidator {
/// @param proposal The redemption proposal to validate.
/// @return True if the proposal is valid. Reverts otherwise.
/// @dev Requirements:
/// - The target wallet must be in the Live state,
/// - The target wallet must be in the Live or MovingFunds state,
/// - The number of redemption requests included in the redemption
/// proposal must be in the range [1, `redemptionMaxSize`],
/// - The proposed redemption tx fee must be grater than zero,
Expand All @@ -539,10 +543,14 @@ contract WalletProposalValidator {
view
returns (bool)
{
Wallets.Wallet memory wallet = bridge.wallets(
proposal.walletPubKeyHash
);

require(
bridge.wallets(proposal.walletPubKeyHash).state ==
Wallets.WalletState.Live,
"Wallet is not in Live state"
wallet.state == Wallets.WalletState.Live ||
wallet.state == Wallets.WalletState.MovingFunds,
"Wallet is not in Live or MovingFunds state"
);

uint256 requestsCount = proposal.redeemersOutputScripts.length;
Expand Down

0 comments on commit 6b63d2a

Please sign in to comment.