From 9a3300c46854459e51e5e8d09e1a6ce200786bdf Mon Sep 17 00:00:00 2001 From: zhl Date: Sat, 8 Apr 2023 15:18:34 +0800 Subject: [PATCH] =?UTF-8?q?wallet=20=E5=A2=9E=E5=8A=A0=E6=89=B9=E9=87=8Fco?= =?UTF-8?q?nfirm=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contracts/core/BEMultiSigWallet.sol | 63 +++++++++++++++++------------ 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/contracts/core/BEMultiSigWallet.sol b/contracts/core/BEMultiSigWallet.sol index 40aece0..1832f96 100644 --- a/contracts/core/BEMultiSigWallet.sol +++ b/contracts/core/BEMultiSigWallet.sol @@ -126,12 +126,9 @@ contract BEMultiSigWallet is AccessControlEnumerable { /** * @dev Returns whether an operation is pending or not. */ - function isOperationPending(bytes32 id) - public - view - virtual - returns (bool pending) - { + function isOperationPending( + bytes32 id + ) public view virtual returns (bool pending) { return getTimestamp(id) > _DONE_TIMESTAMP; } @@ -147,12 +144,9 @@ contract BEMultiSigWallet is AccessControlEnumerable { /** * @dev Returns whether an operation is ready or not. */ - function isOperationReady(bytes32 id) - public - view - virtual - returns (bool ready) - { + function isOperationReady( + bytes32 id + ) public view virtual returns (bool ready) { uint256 timestamp = getTimestamp(id); return timestamp > _DONE_TIMESTAMP && timestamp <= block.timestamp; } @@ -168,12 +162,9 @@ contract BEMultiSigWallet is AccessControlEnumerable { * @dev Returns the timestamp at with an operation becomes ready (0 for * unset operations, 1 for done operations). */ - function getTimestamp(bytes32 id) - public - view - virtual - returns (uint256 timestamp) - { + function getTimestamp( + bytes32 id + ) public view virtual returns (uint256 timestamp) { return _timestamps[id]; } @@ -299,10 +290,9 @@ contract BEMultiSigWallet is AccessControlEnumerable { * Requirements * - the caller must have the 'executor' role. */ - function confirmTransaction(bytes32 id) - public - onlyRoleOrOpenRole(EXECUTOR_ROLE) - { + function confirmTransaction( + bytes32 id + ) public onlyRoleOrOpenRole(EXECUTOR_ROLE) { require( isOperationPending(id), "BEMultiSigWallet: operation not exist or finished" @@ -311,15 +301,25 @@ contract BEMultiSigWallet is AccessControlEnumerable { emit Confirmation(msg.sender, id); } + /** + * @dev Allows an executor to confirm multiple transactions. + */ + function confirmTransactionBatch( + bytes32[] calldata ids + ) public onlyRoleOrOpenRole(EXECUTOR_ROLE) { + for (uint256 i = 0; i < ids.length; ++i) { + confirmTransaction(ids[i]); + } + } + /** * @dev Allows an executor to revoke a confirmation for a transaction. * Requirements * - the caller must have the 'executor' role. */ - function revokeConfirmation(bytes32 id) - public - onlyRoleOrOpenRole(EXECUTOR_ROLE) - { + function revokeConfirmation( + bytes32 id + ) public onlyRoleOrOpenRole(EXECUTOR_ROLE) { require( isOperationPending(id), "BEMultiSigWallet: operation not exist or finished" @@ -328,6 +328,17 @@ contract BEMultiSigWallet is AccessControlEnumerable { emit Revocation(msg.sender, id); } + /** + * @dev Allows an executor to revoke multiple confirmations for a transaction. + */ + function revokeConfirmationBatch( + bytes32[] calldata ids + ) public onlyRoleOrOpenRole(EXECUTOR_ROLE) { + for (uint256 i = 0; i < ids.length; ++i) { + revokeConfirmation(ids[i]); + } + } + /** * @dev Execute an (ready) operation containing a single transaction. *