Skip to content

Commit

Permalink
feat: added WithAdmin to OFTAdapterForSand
Browse files Browse the repository at this point in the history
  • Loading branch information
capedcrusader21 committed Jul 16, 2024
1 parent 0d304bd commit 70fbaaa
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
9 changes: 6 additions & 3 deletions packages/oft-sand/contracts/OFTAdapterForSand.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import {SendParam, OFTReceipt, MessagingReceipt, MessagingFee} from "@layerzerol
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {Context} from "@openzeppelin/contracts/utils/Context.sol";
import {OFTAdapter} from "./oft/OFTAdapter.sol";
import {WithAdmin} from "./sand/WithAdmin.sol";
import {ERC2771Handler} from "./sand/ERC2771Handler.sol";

/// @title OFTAdapterForSand
/// @author The Sandbox
/// @dev contract to be used with non-upgradable SAND contract
contract OFTAdapterForSand is OFTAdapter, ERC2771Handler {
contract OFTAdapterForSand is OFTAdapter, WithAdmin, ERC2771Handler {
bool public enabled;

/// @notice Emitted when the enabled state changes
Expand All @@ -28,9 +29,11 @@ contract OFTAdapterForSand is OFTAdapter, ERC2771Handler {
address sandToken,
address layerZeroEndpoint,
address owner,
address trustedForwarder
address trustedForwarder,
address admin
) OFTAdapter(sandToken, layerZeroEndpoint, owner) Ownable(owner) {
__ERC2771Handler_initialize(trustedForwarder);
_changeAdmin(admin);
_enable(true);
}

Expand All @@ -40,7 +43,7 @@ contract OFTAdapterForSand is OFTAdapter, ERC2771Handler {
_trustedForwarder = trustedForwarder;
}

function enable(bool _enabled) external onlyOwner {
function enable(bool _enabled) external onlyAdmin {
_enable(_enabled);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/oft-sand/contracts/OFTSand.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ contract OFTSand is SandBaseToken, ERC2771Handler, OFTCore {
_trustedForwarder = trustedForwarder;
}

function enable(bool _enabled) external onlyOwner {
function enable(bool _enabled) external onlyAdmin {
_enable(_enabled);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/oft-sand/contracts/sand/SandBaseToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ contract SandBaseToken is ERC20BaseToken, ERC20BasicApproveExtension {
address beneficiary,
uint256 amount
) ERC20BaseToken("SAND", "SAND", sandAdmin, executionAdmin) {
_admin = sandAdmin;
_changeAdmin(sandAdmin);
if (beneficiary != address(0)) {
uint256 initialSupply = amount * (1 ether);
_mint(beneficiary, initialSupply);
Expand Down
4 changes: 4 additions & 0 deletions packages/oft-sand/contracts/sand/WithAdmin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ contract WithAdmin is IErrors {
/// @dev Change the administrator to be `newAdmin`.
/// @param newAdmin The address of the new administrator.
function changeAdmin(address newAdmin) external onlyAdmin {
_changeAdmin(newAdmin);
}

function _changeAdmin(address newAdmin) internal {
emit AdminChanged(_admin, newAdmin);
_admin = newAdmin;
}
Expand Down

0 comments on commit 70fbaaa

Please sign in to comment.