Skip to content

Commit bf9c477

Browse files
authored
Quick fix (#139)
* quick fix * coverage
1 parent 6b614ea commit bf9c477

File tree

5 files changed

+44
-4
lines changed

5 files changed

+44
-4
lines changed

contracts/access/AMultiOwnable.sol

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ abstract contract AMultiOwnable is IMultiOwnable, Initializable {
4343
_addOwners(msg.sender.asSingletonArray());
4444
}
4545

46+
/**
47+
* @dev Initializes the contract setting the array of initial owners.
48+
*/
49+
function __AMultiOwnable_init(address[] memory initialOwners_) internal onlyInitializing {
50+
if (initialOwners_.length == 0) revert InvalidOwner();
51+
52+
_addOwners(initialOwners_);
53+
}
54+
4655
/**
4756
* @notice The function to add equally rightful owners to the contract
4857
* @param newOwners_ the owners to be added

contracts/mock/access/MultiOwnableMock.sol

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,26 @@
22
// solhint-disable
33
pragma solidity ^0.8.21;
44

5-
import {AMultiOwnable} from "./../../access/AMultiOwnable.sol";
5+
import {AMultiOwnable} from "../../access/AMultiOwnable.sol";
6+
7+
import {TypeCaster} from "../../libs/utils/TypeCaster.sol";
68

79
contract MultiOwnableMock is AMultiOwnable {
10+
using TypeCaster for address;
11+
812
function __MultiOwnableMock_init() external initializer {
913
__AMultiOwnable_init();
1014
}
1115

16+
function __MultiOwnableMockMulti_init(address[] memory initialOwners_) external initializer {
17+
__AMultiOwnable_init(initialOwners_);
18+
}
19+
1220
function mockInit() external {
1321
__AMultiOwnable_init();
1422
}
23+
24+
function mockMultiInit() external {
25+
__AMultiOwnable_init(msg.sender.asSingletonArray());
26+
}
1527
}

contracts/mock/oracles/uniswap-v2/UniswapV2OracleMock.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ contract UniswapV2OracleMock is AUniswapV2Oracle {
1313
address uniswapV2Factory_,
1414
uint256 timeWindow_
1515
) external initializer {
16-
__OracleV2_init(uniswapV2Factory_, timeWindow_);
16+
__AUniswapV2Oracle_init(uniswapV2Factory_, timeWindow_);
1717
}
1818

1919
function mockInit(address uniswapV2Factory_, uint256 timeWindow_) external {
20-
__OracleV2_init(uniswapV2Factory_, timeWindow_);
20+
__AUniswapV2Oracle_init(uniswapV2Factory_, timeWindow_);
2121
}
2222

2323
function addPaths(address[][] calldata paths_) external {

contracts/oracles/AUniswapV2Oracle.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ abstract contract AUniswapV2Oracle is Initializable {
5454
* @param uniswapV2Factory_ the Uniswap V2 factory
5555
* @param timeWindow_ the time between oracle observations
5656
*/
57-
function __OracleV2_init(
57+
function __AUniswapV2Oracle_init(
5858
address uniswapV2Factory_,
5959
uint256 timeWindow_
6060
) internal onlyInitializing {

test/access/MultiOwnable.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,30 @@ describe("MultiOwnable", () => {
3030
afterEach(reverter.revert);
3131

3232
describe("access", () => {
33+
it("should initialize", async () => {
34+
const multiOwnableMock = await ethers.deployContract("MultiOwnableMock");
35+
36+
await expect(multiOwnableMock.__MultiOwnableMockMulti_init([]))
37+
.to.be.revertedWithCustomError(multiOwnable, "InvalidOwner")
38+
.withArgs();
39+
40+
await multiOwnableMock.__MultiOwnableMockMulti_init([FIRST.address]);
41+
42+
expect(await multiOwnableMock.isOwner(FIRST.address)).to.be.true;
43+
});
44+
3345
it("should not initialize twice", async () => {
3446
await expect(multiOwnable.mockInit()).to.be.revertedWithCustomError(multiOwnable, "NotInitializing").withArgs();
47+
await expect(multiOwnable.mockMultiInit())
48+
.to.be.revertedWithCustomError(multiOwnable, "NotInitializing")
49+
.withArgs();
50+
3551
await expect(multiOwnable.__MultiOwnableMock_init())
3652
.to.be.revertedWithCustomError(multiOwnable, "InvalidInitialization")
3753
.withArgs();
54+
await expect(multiOwnable.__MultiOwnableMockMulti_init([FIRST.address]))
55+
.to.be.revertedWithCustomError(multiOwnable, "InvalidInitialization")
56+
.withArgs();
3857
});
3958

4059
it("only owner should call these functions", async () => {

0 commit comments

Comments
 (0)