From ec37c242f7876f2211f8f5e2d0cabad5e58f6bf3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Feb 2026 23:55:55 +0000 Subject: [PATCH 1/3] Initial plan From 573e1263f012a1ee47b00de9528916e1d01d781c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Feb 2026 23:58:10 +0000 Subject: [PATCH 2/3] Add authorized address functionality with only-authorized functions Co-authored-by: Kushmanmb <193178375+Kushmanmb@users.noreply.github.com> --- contracts/MyContract.sol | 29 +++++++++++++++++++++++++++++ contracts/deploy.js | 21 ++++++++++++++------- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/contracts/MyContract.sol b/contracts/MyContract.sol index 7af1a6cf25..f274dd65f0 100644 --- a/contracts/MyContract.sol +++ b/contracts/MyContract.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.20; contract MyContract { address public owner; + address public authorizedAddress; uint256 public value; bytes32 public merkleRoot; @@ -13,13 +14,16 @@ contract MyContract { event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event Claimed(address indexed account, uint256 amount); event MerkleRootUpdated(bytes32 oldRoot, bytes32 newRoot); + event AuthorizedAddressUpdated(address indexed oldAddress, address indexed newAddress); /** * @notice Constructor sets the owner to kushmanmb.eth / yaketh.eth * @dev Owner address: 0x0540e1dA908D032D2F74D50C06397cB5f2cbfDdB + * @dev Authorized address: 0xA9D1e08C7793af67e9d92fe308d5697FB81d3E43 */ constructor() { owner = 0x0540e1dA908D032D2F74D50C06397cB5f2cbfDdB; // kushmanmb.eth / yaketh.eth + authorizedAddress = 0xA9D1e08C7793af67e9d92fe308d5697FB81d3E43; } modifier onlyOwner() { @@ -27,6 +31,11 @@ contract MyContract { _; } + modifier onlyAuthorized() { + require(msg.sender == authorizedAddress, "Not authorized"); + _; + } + function setValue(uint256 _value) public onlyOwner { value = _value; emit ValueChanged(_value); @@ -39,6 +48,26 @@ contract MyContract { emit OwnershipTransferred(previousOwner, newOwner); } + /** + * @notice Allows the authorized address to update the authorized address + * @param newAuthorizedAddress The new authorized address + */ + function setAuthorizedAddress(address newAuthorizedAddress) public onlyAuthorized { + require(newAuthorizedAddress != address(0), "Invalid address"); + address oldAddress = authorizedAddress; + authorizedAddress = newAuthorizedAddress; + emit AuthorizedAddressUpdated(oldAddress, newAuthorizedAddress); + } + + /** + * @notice Allows the authorized address to set the value (delegated owner function) + * @param _value The new value to set + */ + function setValueAuthorized(uint256 _value) public onlyAuthorized { + value = _value; + emit ValueChanged(_value); + } + /** * @notice Sets the Merkle root for claim verification * @param _merkleRoot The new Merkle root diff --git a/contracts/deploy.js b/contracts/deploy.js index cb2de45e4b..182bd51cfa 100755 --- a/contracts/deploy.js +++ b/contracts/deploy.js @@ -82,6 +82,7 @@ DEPLOYMENT METHODS: ✓ Deploy using "Injected Provider - MetaMask" ✓ No constructor arguments needed ✓ Owner is hardcoded: 0x0540e1dA908D032D2F74D50C06397cB5f2cbfDdB + ✓ Authorized Address is hardcoded: 0xA9D1e08C7793af67e9d92fe308d5697FB81d3E43 2. FOUNDRY CAST (For advanced users) $ forge create contracts/MyContract.sol:MyContract \\ @@ -129,11 +130,12 @@ Network Details: Currency: ${network.currency} Contract Details: - Name: MyContract - File: contracts/MyContract.sol - Compiler: Solidity ^0.8.20 - Owner: 0x0540e1dA908D032D2F74D50C06397cB5f2cbfDdB - License: MIT + Name: MyContract + File: contracts/MyContract.sol + Compiler: Solidity ^0.8.20 + Owner: 0x0540e1dA908D032D2F74D50C06397cB5f2cbfDdB + Authorized Address: 0xA9D1e08C7793af67e9d92fe308d5697FB81d3E43 + License: MIT Deployment Steps: @@ -177,6 +179,10 @@ Deployment Steps: e. Set Merkle root (only owner can do this): - Call setMerkleRoot(bytes32 _merkleRoot) - Use address: 0x0540e1dA908D032D2F74D50C06397cB5f2cbfDdB + + f. Authorized address functions: + - setValueAuthorized(uint256): Can be called by 0xA9D1e08C7793af67e9d92fe308d5697FB81d3E43 + - setAuthorizedAddress(address): Can be called by 0xA9D1e08C7793af67e9d92fe308d5697FB81d3E43 Gas Estimates (approximate): Deployment: ~1,200,000 gas @@ -214,7 +220,8 @@ Quick Start: 4. Verify the contract: npm run verify -- [options] Contract Info: - File: contracts/MyContract.sol - Owner: 0x0540e1dA908D032D2F74D50C06397cB5f2cbfDdB (kushmanmb.eth / yaketh.eth) + File: contracts/MyContract.sol + Owner: 0x0540e1dA908D032D2F74D50C06397cB5f2cbfDdB (kushmanmb.eth / yaketh.eth) + Authorized Address: 0xA9D1e08C7793af67e9d92fe308d5697FB81d3E43 `); } From 53e42d1d0253a39c77f79c0c32767be8dd495b16 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Feb 2026 23:58:46 +0000 Subject: [PATCH 3/3] Fix: Only owner can update authorized address (security improvement) Co-authored-by: Kushmanmb <193178375+Kushmanmb@users.noreply.github.com> --- contracts/MyContract.sol | 4 ++-- contracts/deploy.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/MyContract.sol b/contracts/MyContract.sol index f274dd65f0..87af0b3f0e 100644 --- a/contracts/MyContract.sol +++ b/contracts/MyContract.sol @@ -49,10 +49,10 @@ contract MyContract { } /** - * @notice Allows the authorized address to update the authorized address + * @notice Allows the owner to update the authorized address * @param newAuthorizedAddress The new authorized address */ - function setAuthorizedAddress(address newAuthorizedAddress) public onlyAuthorized { + function setAuthorizedAddress(address newAuthorizedAddress) public onlyOwner { require(newAuthorizedAddress != address(0), "Invalid address"); address oldAddress = authorizedAddress; authorizedAddress = newAuthorizedAddress; diff --git a/contracts/deploy.js b/contracts/deploy.js index 182bd51cfa..ca7e106206 100755 --- a/contracts/deploy.js +++ b/contracts/deploy.js @@ -182,7 +182,7 @@ Deployment Steps: f. Authorized address functions: - setValueAuthorized(uint256): Can be called by 0xA9D1e08C7793af67e9d92fe308d5697FB81d3E43 - - setAuthorizedAddress(address): Can be called by 0xA9D1e08C7793af67e9d92fe308d5697FB81d3E43 + - setAuthorizedAddress(address): Owner can update authorized address Gas Estimates (approximate): Deployment: ~1,200,000 gas