-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!--- Please provide a general summary of your changes in the title above --> <!-- Give an estimate of the time you spent on this PR in terms of work days. Did you spend 0.5 days on this PR or rather 2 days? --> Time spent on this PR: ## Pull request type <!-- Please try to limit your pull request to one type, submit multiple pull requests if needed. --> Please check the type of change your PR introduces: - [ ] Bugfix - [x] Feature - [ ] Code style update (formatting, renaming) - [ ] Refactoring (no functional changes, no api changes) - [ ] Build related changes - [ ] Documentation content changes - [ ] Other (please describe): ## What is the current behavior? <!-- Please describe the current behavior that you are modifying, or link to a relevant issue. --> Resolves #1488 ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> Coinbase use Ownable2Step from OZ with version 5.0.2 <!-- Reviewable:start --> - - - This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/kkrt-labs/kakarot/1494) <!-- Reviewable:end -->
- Loading branch information
Showing
7 changed files
with
33 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@openzeppelin-contracts/=solidity_contracts/lib/openzeppelin-contracts/contracts/ | ||
openzeppelin/=solidity_contracts/lib/openzeppelin-uniswapV3/contracts/ |
Submodule openzeppelin-contracts
added at
dbb610
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,23 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.0 <0.9.0; | ||
pragma solidity 0.8.27; | ||
|
||
import {DualVmToken} from "../CairoPrecompiles/DualVmToken.sol"; | ||
import {Ownable2Step, Ownable} from "@openzeppelin-contracts/access/Ownable2Step.sol"; | ||
|
||
contract Coinbase { | ||
contract Coinbase is Ownable2Step { | ||
/// @dev The EVM address of the DualVmToken for Kakarot ETH. | ||
DualVmToken public immutable kakarotEth; | ||
|
||
/// @dev State variable to store the owner of the contract | ||
address public owner; | ||
|
||
/// Constructor sets the owner of the contract | ||
constructor(address _kakarotEth) { | ||
owner = msg.sender; | ||
constructor(address _kakarotEth) Ownable(msg.sender) { | ||
kakarotEth = DualVmToken(_kakarotEth); | ||
} | ||
|
||
/// Modifier to restrict access to owner only | ||
/// @dev Assert that msd.sender is the owner | ||
modifier onlyOwner() { | ||
require(msg.sender == owner, "Not the contract owner"); | ||
_; | ||
} | ||
|
||
/// @notice Withdraws ETH from the contract to a Starknet address | ||
/// @dev DualVmToken.balanceOf(this) is the same as address(this).balance | ||
/// @param toStarknetAddress The Starknet address to withdraw to | ||
function withdraw(uint256 toStarknetAddress) external onlyOwner { | ||
uint256 balance = address(this).balance; | ||
kakarotEth.transfer(toStarknetAddress, balance); | ||
} | ||
|
||
/// @notice Transfers ownership of the contract to a new address | ||
/// @param newOwner The address to transfer ownership to | ||
function transferOwnership(address newOwner) external onlyOwner { | ||
require(newOwner != address(0), "New owner cannot be the zero address"); | ||
owner = newOwner; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters