Skip to content

Commit

Permalink
types
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Nov 8, 2024
1 parent e5f9b6f commit fb8e5a8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
10 changes: 5 additions & 5 deletions examples/token/tasks/connectedSetCounterparty.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { task } from "hardhat/config";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { ethers } from "ethers";
import { Connected } from "../typechain-types";

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

const contract = await hre.ethers.getContractAt(args.name, args.contract);
const contract: Connected = await hre.ethers.getContractAt(
"Connected",
args.contract
);

const tx = await contract.setCounterparty(args.counterparty);
const receipt = await tx.wait();

if (args.json) {
console.log(
Expand All @@ -26,13 +28,11 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
} else {
console.log(`🚀 Successfully set the universal contract.
📜 Contract address: ${args.contract}
🔗 Universal contract address: ${args.universalContract}
🔗 Transaction hash: ${tx.hash}`);
}
};

task("connected-set-counterparty", "Sets the universal contract address", main)
.addParam("contract", "The address of the deployed contract")
.addParam("counterparty", "The address of the universal contract to set")
.addOptionalParam("name", "The contract name to interact with", "Connected")
.addFlag("json", "Output the result in JSON format");
8 changes: 5 additions & 3 deletions examples/token/tasks/mint.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { task } from "hardhat/config";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { ethers } from "ethers";

const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
const [signer] = await hre.ethers.getSigners();
Expand All @@ -10,15 +9,18 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
);
}

const contract = await hre.ethers.getContractAt(args.name, args.contract);
const contract: any = await hre.ethers.getContractAt(
args.name,
args.contract
);

const recipient = args.to || signer.address;

const tx = await contract.mint(recipient, args.amount);
const receipt = await tx.wait();

const transferEvent = receipt.events?.find(
(event) => event.event === "Transfer"
(event: any) => event.event === "Transfer"
);
const tokenId = transferEvent?.args?.tokenId;

Expand Down
8 changes: 5 additions & 3 deletions examples/token/tasks/universalSetCounterparty.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { task } from "hardhat/config";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { Universal } from "../typechain-types";

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

const contract = await hre.ethers.getContractAt(args.name, args.contract);
const contract: Universal = await hre.ethers.getContractAt(
"Universal",
args.contract
);

const tx = await contract.setCounterparty(args.zrc20, args.counterparty);
const receipt = await tx.wait();

if (args.json) {
console.log(
Expand All @@ -36,5 +39,4 @@ task("universal-set-counterparty", "Sets the connected contract address", main)
.addParam("contract", "The address of the deployed contract")
.addParam("zrc20", "The ZRC20 address to link to the connected contract")
.addParam("counterparty", "The address of the connected contract to set")
.addOptionalParam("name", "The contract name to interact with", "Universal")
.addFlag("json", "Output the result in JSON format");

0 comments on commit fb8e5a8

Please sign in to comment.