Skip to content

Commit

Permalink
Merge pull request #15 from lidofinance/feature/ackee_fixes_1_1
Browse files Browse the repository at this point in the history
Ackee fixes 1.1
  • Loading branch information
kovalgek authored Jun 6, 2024
2 parents a479315 + 6fba907 commit a31049a
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
4 changes: 4 additions & 0 deletions contracts/BridgingManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ contract BridgingManager is AccessControl {
/// @dev This method might be called only once
/// @param admin_ Address of the account to grant the DEFAULT_ADMIN_ROLE
function _initializeBridgingManager(address admin_) internal {
if (admin_ == address(0)) {
revert ErrorZeroAddressAdmin();
}
State storage s = _loadState();
if (s.isInitialized) {
revert ErrorAlreadyInitialized();
Expand Down Expand Up @@ -135,6 +138,7 @@ contract BridgingManager is AccessControl {
event WithdrawalsDisabled(address indexed disabler);
event Initialized(address indexed admin);

error ErrorZeroAddressAdmin();
error ErrorDepositsEnabled();
error ErrorDepositsDisabled();
error ErrorWithdrawalsEnabled();
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/ERC20RebasableBridged.sol
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ contract ERC20RebasableBridged is IERC20, IERC20Wrapper, IBridgeWrapper, ERC20Me
_setERC20MetadataSymbol(symbol_);
}

function _wrap(address from_, address to_, uint256 sharesAmount_) internal returns (uint256) {
function _wrap(address from_, address to_, uint256 sharesAmount_) internal returns (uint256) {
if (sharesAmount_ == 0) revert ErrorZeroSharesWrap();
TOKEN_TO_WRAP_FROM.safeTransferFrom(from_, address(this), sharesAmount_);
_mintShares(to_, sharesAmount_);
Expand Down
31 changes: 31 additions & 0 deletions test/optimism/L1LidoTokensBridge.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,37 @@ unit("Optimism :: L1LidoTokensBridge", ctxFactory)
);
})

.test("initialize() :: revert when admin is zero", async (ctx) => {
const { deployer, l2TokenBridgeEOA, zero } = ctx.accounts;
const {
totalPooledEther,
totalShares,
genesisTime,
secondsPerSlot,
lastProcessingRefSlot
} = ctx.constants;

const { l1TokenBridgeImpl } = await getL1LidoTokensBridgeImpl(
totalPooledEther,
totalShares,
genesisTime,
secondsPerSlot,
lastProcessingRefSlot,
deployer,
l2TokenBridgeEOA.address
);

await assert.revertsWith(new OssifiableProxy__factory(
deployer
).deploy(
l1TokenBridgeImpl.address,
deployer.address,
l1TokenBridgeImpl.interface.encodeFunctionData("initialize", [
zero.address
])
), "ErrorZeroAddressAdmin()");
})

.test("initialize() :: don't allow to initialize twice", async (ctx) => {
const { deployer, l2TokenBridgeEOA } = ctx.accounts;
const {
Expand Down
15 changes: 15 additions & 0 deletions test/optimism/L2ERC20ExtendedTokensBridge.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,21 @@ unit("Optimism:: L2ERC20ExtendedTokensBridge", ctxFactory)
);
})

.test("initialize() :: revert when admin is zero", async (ctx) => {
const { deployer, l1TokenBridgeEOA, zero } = ctx.accounts;
const l2TokenBridgeImpl = await getL2TokenBridgeImpl(deployer, l1TokenBridgeEOA.address);

await assert.revertsWith(new OssifiableProxy__factory(
deployer
).deploy(
l2TokenBridgeImpl.address,
deployer.address,
l2TokenBridgeImpl.interface.encodeFunctionData("initialize", [
zero.address
])
), "ErrorZeroAddressAdmin()");
})

.test("finalizeUpgrade_v2() :: bridging manager uninitialized", async (ctx) => {
const { deployer, l1TokenBridgeEOA } = ctx.accounts;

Expand Down

0 comments on commit a31049a

Please sign in to comment.