Skip to content

fix(Languages): add missing Ownable(msg.sender) initializer to 5 localized contracts - #957

Open
auyua9 wants to merge 1 commit into
AmazingAng:mainfrom
auyua9:fix/loc-ownable-constructor-initializers
Open

auyua9 wants to merge 1 commit into
AmazingAng:mainfrom
auyua9:fix/loc-ownable-constructor-initializers

Conversation

@auyua9

@auyua9 auyua9 commented Sep 20, 2026

Copy link
Copy Markdown

{
"title": "fix(Languages): add missing Ownable(msg.sender) initializer to 5 localized contracts",
"body": "## What this PR does\n\nAdds the missing Ownable(msg.sender) initializer to the constructors of the English and pt-br localized versions of the following tutorial contracts:\n\n- Languages/en/S03_Centralization_en/Centralization.sol\n- Languages/en/S04_AccessControlExploit_en/AccessControlExploit.sol\n- Languages/en/S10_Honeypot_en/Honeypot.sol\n- Languages/pt-br/S03_Centralization/Centralization.sol\n- Languages/pt-br/S04_AccessControlExploit/AccessControlExploit.sol\n\n## Why\n\nThe canonical Chinese versions (S03_Centralization/Centralization.sol, S04_AccessControlExploit/AccessControlExploit.sol, S10_Honeypot/Honeypot.sol) all declare:\n\nsolidity\nconstructor() ERC20(\"...\", \"...\") Ownable(msg.sender) { ... }\n\n\nThe English and pt-br localized versions, however, omit the Ownable(msg.sender) initializer, so they declare:\n\nsolidity\nconstructor() ERC20(\"...\", \"...\") { ... }\n\n\nThis is a divergence from the teaching material that creates a real bug: after deployment, owner() on these localized contracts is address(0), which means:\n\n- The deployer cannot call mint(...) (guarded by onlyOwner).\n- The deployer cannot call transferOwnership(...) to recover ownership because that function itself requires onlyOwner in newer OpenZeppelin versions.\n- The Centralization example explicitly demonstrates transferring ownership to a known address; without Ownable(msg.sender) in the constructor, that subsequent transferOwnership(exposedAccount) call reverts.\n\n## What was changed\n\nMechanical, one-token addition per file, matching the canonical Chinese pattern exactly:\n\ndiff\n- constructor() ERC20(\"Centralization\", \"Cent\") {\n+ constructor() ERC20(\"Centralization\", \"Cent\") Ownable(msg.sender) {\n\n\nSame pattern applied to the other four files (empty-body versions use {} instead of {).\n\n## Scope\n\n- 5 files, 5 insertions, 5 deletions.\n- No imports added; Ownable is already imported in every file.\n- No change to contract storage, logic, or behavior beyond setting owner() to the deployer at construction.\n- Pure code change; no readme/docs/test changes.\n- Does not touch the Chinese canonical versions (already correct).\n- Does not touch lib/openzeppelin-contracts/ (vendored library).\n\n## Verification\n\n- git diff --check passes (no whitespace errors).\n- All edits mirror the canonical Chinese pattern exactly.\n- OpenZeppelin Ownable(msg.sender) is the documented initializer in the version vendored at lib/openzeppelin-contracts.\n\n## Why this matters for the tutorial\n\nThe repo's mission is "works out of the box for beginners." Students running the English or pt-br Remix walkthrough will see onlyOwner guards silently fail (or transferOwnership revert) on first deployment because of this divergence. Aligning the localized contracts with the canonical Chinese version removes that friction for non-Chinese readers.",
"base": "main",
"head": "auyua9:fix/loc-ownable-constructor-initializers",
"draft": false,
"maintainer_can_modify": true
}

…lized contracts

The English and pt-br localized versions of S03_Centralization,
S04_AccessControlExploit, and S10_Honeypot were missing the
`Ownable(msg.sender)` initializer in their constructors, unlike the
Chinese canonical versions which include it. Without the initializer,
`owner()` would be `address(0)` after deployment, breaking any
`onlyOwner` modifier usage and the deployer cannot manage the
contract.

Files aligned:
- Languages/en/S03_Centralization_en/Centralization.sol
- Languages/en/S04_AccessControlExploit_en/AccessControlExploit.sol
- Languages/en/S10_Honeypot_en/Honeypot.sol
- Languages/pt-br/S03_Centralization/Centralization.sol
- Languages/pt-br/S04_AccessControlExploit/AccessControlExploit.sol

Atomic; matches the canonical Chinese version pattern.

This branch has not been deployed

No deployments
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