// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
contract A is Ownable {
constructor(address owner) Ownable(owner) {}
}
contract B is Ownable {
constructor(address owner) Ownable(owner) {}
}
contract C is A, B {
constructor(address owner) B(owner) A(owner) {}
}
Here is a simple file demonstrating a diamond linearization involving Openzeppelin 5.0 Ownable
contract, however this file won't compile and the error code is Base constructor arguments given twice.solidity(3364)
since try to construct both in A and B contract, one work-around is declare both A and B as abstract contracts.
pragma solidity ^0.8.13;
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
abstract contract A is Ownable {
constructor() {}
}
abstract contract B is Ownable {
constructor() {}
}
contract C is A, B {
constructor(address owner) Ownable(owner) {}
}
This file compiles, but it clearly has its own limitations in real life. So is there another way to handle the diamond linearization?