Skip to content

Commit

Permalink
Update tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Sep 28, 2023
1 parent 6cdc802 commit a2b5480
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion templates/messaging/contracts/{{contractName}}.sol.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ contract {{contractName}} is ZetaInteractor, ZetaReceiver {
{{/if}}
}

function sendMessage(uint256 destinationChainId{{#unless arguments.feesNative}}, uint256 zetaValueAndGas{{/unless}}{{#if arguments.pairsWithDataLocation}}, {{#each arguments.pairsWithDataLocation}}{{#if @index}}, {{/if}}{{this.[1]}} {{this.[0]}}{{/each}}{{/if}}) external payable {
function sendMessage(uint256 destinationChainId{{#if arguments.pairsWithDataLocation}}, {{#each arguments.pairsWithDataLocation}}{{#if @index}}, {{/if}}{{this.[1]}} {{this.[0]}}{{/each}}{{/if}}{{#unless arguments.feesNative}}, uint256 zetaValueAndGas{{/unless}}) external payable {
if (!_isValidChainId(destinationChainId))
revert InvalidDestinationChainId();

Expand Down
8 changes: 3 additions & 5 deletions templates/messaging/tasks/deploy.ts.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const deployContract = async (

const connector = getAddress("connector", networkName as any);
const zetaToken = getAddress("zetaToken", networkName as any);
{{#if arguments.feesNative}}
const zetaTokenConsumerUniV2 = getAddress(
"zetaTokenConsumerUniV2",
networkName as any
Expand All @@ -49,14 +50,11 @@ const deployContract = async (
"zetaTokenConsumerUniV3",
networkName as any
);
{{/if}}

const { abi, bytecode } = await hre.artifacts.readArtifact(contractName);
const factory = new ethers.ContractFactory(abi, bytecode, wallet);
const contract = await factory.deploy(
connector,
zetaToken,
zetaTokenConsumerUniV2 || zetaTokenConsumerUniV3
);
const contract = await factory.deploy(connector, zetaToken{{#if arguments.feesNative}}, zetaTokenConsumerUniV2 || zetaTokenConsumerUniV3{{/if}});

await contract.deployed();
if (!json) {
Expand Down
6 changes: 3 additions & 3 deletions templates/messaging/tasks/interact.ts.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { task } from "hardhat/config";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { parseEther } from "@ethersproject/units";
import { trackCCTX } from "@zetachain/toolkit/helpers";

const contractName = "{{contractName}}";

Expand All @@ -20,15 +19,16 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
{{#each arguments.casts}}const param{{this.[0]}} = {{this.[1]}};
{{/each}}

const value = parseEther(args.amount);

const tx = await contract
.connect(signer)
.sendMessage(destination, {{#each arguments.casts}} param{{this.[0]}}, {{/each}} { value: parseEther(args.amount) });
.sendMessage(destination{{#each arguments.casts}}, param{{this.[0]}}{{/each}}{{#if arguments.feesNative}}, { value }{{else}}, value{{/if}});

const receipt = await tx.wait();
console.log(`✅ The transaction has been broadcasted to ${hre.network.name}
📝 Transaction hash: ${receipt.transactionHash}
`);
await trackCCTX(tx.hash);
};

task("interact", "Sends a message from one chain to another.", main)
Expand Down
3 changes: 1 addition & 2 deletions templates/omnichain/tasks/interact.ts.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { task } from "hardhat/config";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { parseEther } from "@ethersproject/units";
import { getAddress } from "@zetachain/protocol-contracts";
import { prepareData, trackCCTX } from "@zetachain/toolkit/helpers";
import { prepareData } from "@zetachain/toolkit/helpers";

const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
const [signer] = await hre.ethers.getSigners();
Expand All @@ -22,7 +22,6 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
🚀 Successfully broadcasted a token transfer transaction on ${hre.network.name} network.
📝 Transaction hash: ${tx.hash}
`);
await trackCCTX(tx.hash);
};

task("interact", "Interact with the contract", main)
Expand Down

0 comments on commit a2b5480

Please sign in to comment.