fix(oapp): Pass initialOwner to Ownable constructor in OAppCore #150
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a constructor bug in OAppCore.sol that causes compilation to fail when using it with recent versions of @openzeppelin/contracts.
The Bug
The OAppCore contract inherits from OpenZeppelin's Ownable.sol. Newer versions of Ownable require an initialOwner address to be passed to their constructor. The OAppCore constructor was missing this call, leading to the following Solidity compiler error:
This issue occurs because of a version mismatch between the OAppCore implementation and its Ownable dependency, which is resolved to a newer, incompatible version during npm install.
The Fix
This PR resolves the issue by explicitly calling the Ownable constructor from the OAppCore constructor, passing the _delegate address as the initialOwner. This aligns with the contract's documentation, which states that the delegate should typically be the owner.
The change is a single line in packages/layerzero-v2/evm/oapp/contracts/oapp/OAppCore.sol:
Apply to OAppCore.sol
This small change makes the oapp module compatible with modern OpenZeppelin contract versions and resolves the compilation failure, allowing for a much smoother developer experience.