From 79703f628b8dbd8403efd8be51fd43be0c045b1b Mon Sep 17 00:00:00 2001 From: blockchaindevsh Date: Tue, 10 Dec 2024 16:32:51 +0800 Subject: [PATCH] SGT: add batchDepositForAll (#121) * SGT: add batchDepositForAll * follow op coding convention * address comment --- packages/contracts-bedrock/src/L2/SoulGasToken.sol | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/contracts-bedrock/src/L2/SoulGasToken.sol b/packages/contracts-bedrock/src/L2/SoulGasToken.sol index 6e071a5f7130..417f4a64da47 100644 --- a/packages/contracts-bedrock/src/L2/SoulGasToken.sol +++ b/packages/contracts-bedrock/src/L2/SoulGasToken.sol @@ -80,6 +80,16 @@ contract SoulGasToken is ERC20Upgradeable, OwnableUpgradeable { require(msg.value == totalValue, "SGT: unexpected msg.value"); } + /// @notice batchDepositForAll is similar to batchDepositFor, but the value is the same for all accounts. + function batchDepositForAll(address[] calldata _accounts, uint256 _value) external payable { + require(IS_BACKED_BY_NATIVE, "SGT: batchDepositForAll should only be called when IS_BACKED_BY_NATIVE"); + + for (uint256 i = 0; i < _accounts.length; i++) { + _mint(_accounts[i], _value); + } + require(msg.value == _value * _accounts.length, "SGT: unexpected msg.value"); + } + /// @notice withdrawFrom is called by the burner to burn SoulGasToken and return the native token when /// IS_BACKED_BY_NATIVE. function withdrawFrom(address _account, uint256 _value) external {