Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Aug 20, 2024
1 parent 325de30 commit 04c14ab
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
5 changes: 5 additions & 0 deletions universal/hello/contracts/RevertContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "@zetachain/protocol-contracts/contracts/zevm/interfaces/UniversalContrac

contract RevertContract {
event RevertEvent(string message);
event HelloEvent(string name);

event ContextDataRevert(RevertContext revertContext);

Expand All @@ -16,6 +17,10 @@ contract RevertContract {
emit RevertEvent("Event from RevertContract!!!");
}

function hello(string memory name) external {
emit HelloEvent(name);
}

receive() external payable {}

fallback() external payable {}
Expand Down
21 changes: 11 additions & 10 deletions universal/hello/tasks/callFromZetaChain.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { task, types } from "hardhat/config";
import type { HardhatRuntimeEnvironment } from "hardhat/types";
import { utils } from "ethers";

const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
const [signer] = await hre.ethers.getSigners();
Expand All @@ -13,22 +12,24 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
);

const zrc20Artifact = await hre.artifacts.readArtifact("IZRC20");
const zrc20 = new hre.ethers.Contract(
args.zrc20,
zrc20Artifact.abi,
signer
);
const zrc20 = new hre.ethers.Contract(args.zrc20, zrc20Artifact.abi, signer);

const revertMessageBytes = hre.ethers.utils.toUtf8Bytes(args.revertMessage);

const message = hre.ethers.utils.defaultAbiCoder.encode(
const encodedFunctionCall = hre.ethers.utils.defaultAbiCoder.encode(
["string"],
[args.message]
);

const revertMessageBytes = hre.ethers.utils.toUtf8Bytes(args.revertMessage);
const message = hre.ethers.utils.hexlify(
hre.ethers.utils.concat([
hre.ethers.utils.toUtf8Bytes("hello(string)"),
encodedFunctionCall,
])
);

try {
const zrc20TransferTx = await zrc20.transfer(args.contract, 500_000_000,
{
const zrc20TransferTx = await zrc20.transfer(args.contract, 500_000_000, {
gasPrice: 10000000000,
gasLimit: 7000000,
});
Expand Down
7 changes: 3 additions & 4 deletions universal/hello/tasks/interact.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { task, types } from "hardhat/config";
import type { HardhatRuntimeEnvironment } from "hardhat/types";
import GatewayABI from "@zetachain/protocol-contracts/abi/GatewayEVM.sol/GatewayEVM.json";
import { utils } from "ethers";

const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
const [signer] = await hre.ethers.getSigners();
Expand All @@ -20,8 +19,8 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
);
try {
const callTx = await gateway[
// "depositAndCall(address,bytes,(address,bool,address,bytes))"
"call(address,bytes,(address,bool,address,bytes))"
"depositAndCall(address,bytes,(address,bool,address,bytes))"
// "call(address,bytes,(address,bool,address,bytes))"
](
args.contract,
message,
Expand All @@ -34,7 +33,7 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
{
gasPrice: 10000000000,
gasLimit: 7000000,
// value: hre.ethers.utils.parseEther(args.amount),
value: hre.ethers.utils.parseEther(args.amount),
}
);
await callTx.wait();
Expand Down

0 comments on commit 04c14ab

Please sign in to comment.