Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply check-effect-interaction pattern to contract. #653

Merged
merged 1 commit into from
May 11, 2022
Merged
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
10 changes: 5 additions & 5 deletions nightfall-deployer/contracts/Shield.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ contract Shield is Stateful, Structures, Config, Key_Registry, ReentrancyGuardUp
state.isBlockStakeWithdrawn(blockHash) == false,
'The block stake for this block is already claimed'
);
state.setBlockStakeWithdrawn(blockHash);
// add up how much the proposer is owed.
uint256 payment;
for (uint256 i = 0; i < ts.length; i++) {
Expand All @@ -68,7 +69,6 @@ contract Shield is Stateful, Structures, Config, Key_Registry, ReentrancyGuardUp
}
payment += BLOCK_STAKE;
state.addPendingWithdrawal(msg.sender, payment);
state.setBlockStakeWithdrawn(blockHash);
}

function onERC721Received(
Expand Down Expand Up @@ -193,16 +193,16 @@ contract Shield is Stateful, Structures, Config, Key_Registry, ReentrancyGuardUp
if (withdrawTransaction.tokenId != ZERO)
revert('ERC20 deposit should have tokenId equal to ZERO');
else {
// set new owner of transaction, settign fee to zero.
advancedFeeWithdrawals[withdrawTransactionHash] = 0;
advancedWithdrawals[withdrawTransactionHash] = msg.sender;
state.addPendingWithdrawal(msg.sender, advancedFee);
tokenContract.transferFrom(
address(msg.sender),
currentOwner,
uint256(withdrawTransaction.value)
);
}
// set new owner of transaction, settign fee to zero.
advancedFeeWithdrawals[withdrawTransactionHash] = 0;
advancedWithdrawals[withdrawTransactionHash] = msg.sender;
state.addPendingWithdrawal(msg.sender, advancedFee);
}

// TODO Is there a better way to set this fee, e.g. at the point of making a transaction.
Expand Down