-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.26; | ||
|
||
import {RevertContext} from "@zetachain/protocol-contracts/contracts/Revert.sol"; | ||
|
||
contract Revert { | ||
event RevertEvent(string, RevertContext); | ||
event HelloEvent(string, string); | ||
|
||
function hello(string memory message) external { | ||
emit HelloEvent("Hello on EVM", message); | ||
} | ||
|
||
function onRevert(RevertContext calldata revertContext) external { | ||
emit RevertEvent("Revert on EVM", revertContext); | ||
} | ||
|
||
receive() external payable {} | ||
|
||
fallback() external payable {} | ||
} | ||
Check warning Code scanning / Slither Contracts that lock Ether Medium
Contract locking ether found:
Contract Revert has payable functions: - Revert.receive() - Revert.fallback() But does not have a function to withdraw the ether |
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,31 @@ | ||
import { task, types } from "hardhat/config"; | ||
import { HardhatRuntimeEnvironment } from "hardhat/types"; | ||
|
||
const main = async (args: any, hre: HardhatRuntimeEnvironment) => { | ||
const network = hre.network.name; | ||
|
||
const [signer] = await hre.ethers.getSigners(); | ||
if (signer === undefined) { | ||
throw new Error( | ||
`Wallet not found. Please, run "npx hardhat account --save" or set PRIVATE_KEY env variable (for example, in a .env file)` | ||
); | ||
} | ||
|
||
const factory = await hre.ethers.getContractFactory(args.name); | ||
const contract = await (factory as any).deploy(); | ||
await contract.deployed(); | ||
|
||
if (args.json) { | ||
console.log(JSON.stringify(contract)); | ||
} else { | ||
console.log(`🔑 Using account: ${signer.address} | ||
🚀 Successfully deployed "${args.name}" contract on ${network}. | ||
📜 Contract address: ${contract.address} | ||
`); | ||
} | ||
}; | ||
|
||
task("deploy-revert", "Deploy the contract", main) | ||
.addFlag("json", "Output in JSON") | ||
.addOptionalParam("name", "Contract to deploy", "Revert"); |