Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Sep 13, 2024
1 parent f74fa2e commit e1d09d7
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
21 changes: 21 additions & 0 deletions examples/hello/contracts/Revert.sol
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
31 changes: 31 additions & 0 deletions examples/hello/tasks/deployRevert.ts
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");

0 comments on commit e1d09d7

Please sign in to comment.