Skip to content

fix(oapp): Pass initialOwner to Ownable constructor in OAppCore #150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wenakita
Copy link
Contributor

@wenakita wenakita commented Jun 6, 2025

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:

TypeError: No arguments passed to the base constructor. Specify the arguments or mark "OAppCore" as abstract.
--> contracts/oapp/OAppCore.sol
|
16 | abstract contract OAppCore is IOAppCore, Ownable {
| ^
Note: Base constructor parameters:
--> @openzeppelin/contracts/access/Ownable.sol:38:16:
|
38 | constructor(address initialOwner) {
| ^^^^^^^^^^^^^^^^^^^^^^

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant