-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: Incorporate upgrade deployment changes from PR #11 Coauthored by @doublo54 #15
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.23; | ||
|
||
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; | ||
|
||
// Import this file to use console.log | ||
// import "hardhat/console.sol"; | ||
|
||
/* solhint-disable not-rely-on-time */ | ||
contract LockUpgradeable is Initializable { | ||
/// ----------------------------------------------------------------------- | ||
/// Storage variables | ||
/// ----------------------------------------------------------------------- | ||
|
||
uint256 public unlockTime; | ||
address payable public owner; | ||
|
||
/// ----------------------------------------------------------------------- | ||
/// Events | ||
/// ----------------------------------------------------------------------- | ||
|
||
/// @notice Emitted when the contract is withdrawn | ||
/// @param amount The amount of wei withdrawn | ||
/// @param when The timestamp of the block when the withdraw happened | ||
event Withdrawal(uint256 amount, uint256 when); | ||
|
||
/// ----------------------------------------------------------------------- | ||
/// Constructor | ||
/// ----------------------------------------------------------------------- | ||
|
||
function initialize(uint256 _unlockTime, address payable _owner) public initializer { | ||
require(block.timestamp < _unlockTime, "Unlock time should be in the future"); | ||
Check notice Code scanning / Semgrep Semgrep Finding: rules.solidity.performance.use-custom-error-not-require
Consider using custom errors as they are more gas efficient while allowing developers
to describe the error in detail using NatSpec.
|
||
|
||
unlockTime = _unlockTime; | ||
owner = _owner; | ||
} | ||
|
||
receive() external payable {} | ||
|
||
/// ----------------------------------------------------------------------- | ||
/// Public functions | ||
/// ----------------------------------------------------------------------- | ||
|
||
/// @notice Withdraw all the funds | ||
function withdraw() public { | ||
// Uncomment this line to print a log in your terminal | ||
// console.log("Unlock time is %o and block timestamp is %o", unlockTime, block.timestamp); | ||
|
||
require(block.timestamp >= unlockTime, "You can't withdraw yet"); | ||
Check notice Code scanning / Semgrep Semgrep Finding: rules.solidity.performance.use-custom-error-not-require
Consider using custom errors as they are more gas efficient while allowing developers
to describe the error in detail using NatSpec.
|
||
require(msg.sender == owner, "You aren't the owner"); | ||
Check notice Code scanning / Semgrep Semgrep Finding: rules.solidity.performance.use-custom-error-not-require
Consider using custom errors as they are more gas efficient while allowing developers
to describe the error in detail using NatSpec.
|
||
|
||
emit Withdrawal(address(this).balance, block.timestamp); | ||
|
||
owner.transfer(address(this).balance); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// contracts/Dummy.sol | ||
|
||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; | ||
import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; | ||
|
||
/// @dev This contract enables hardhat to compile the builds for upgradeable deployments | ||
contract OpenZeppelinImports { | ||
// No implementation required | ||
} |
Check notice
Code scanning / Semgrep
Semgrep Finding: rules.solidity.performance.use-short-revert-string