Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: tasks to create new universal NFT and FT contracts #206

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/tasks/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export { evmDepositAndCall } from "./evmDepositAndCall";
export { faucetTask } from "./faucet";
export { feesTask } from "./fees";
export { messagingTask } from "./messaging";
export { newNFTTask } from "./newNFT";
export { newTokenTask } from "./newToken";
export { omnichainTask } from "./omnichain";
export { poolsTask } from "./pools";
export { sendBTCTask } from "./sendBTC";
Expand Down
20 changes: 20 additions & 0 deletions packages/tasks/src/newNFT.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as fs from "fs";
import { task } from "hardhat/config";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import * as path from "path";

import { processTemplates } from "./processTemplates";

const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
processTemplates("nft", args);
const configPath = path.resolve(process.cwd(), "hardhat.config.ts");
let hardhatConfigContents = fs.readFileSync(configPath, "utf8");

hardhatConfigContents =
`import "@zetachain/standard-contracts/contracts/nft/tasks"\n` +
hardhatConfigContents;

fs.writeFileSync(configPath, hardhatConfigContents);
};

export const newNFTTask = task("new:nft", "Create a new Universal NFT", main);
24 changes: 24 additions & 0 deletions packages/tasks/src/newToken.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import * as fs from "fs";
import { task } from "hardhat/config";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import * as path from "path";

import { processTemplates } from "./processTemplates";

const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
processTemplates("token", args);
const configPath = path.resolve(process.cwd(), "hardhat.config.ts");
let hardhatConfigContents = fs.readFileSync(configPath, "utf8");

hardhatConfigContents =
`import "@zetachain/standard-contracts/contracts/token/tasks"\n` +
hardhatConfigContents;

fs.writeFileSync(configPath, hardhatConfigContents);
};

export const newTokenTask = task(
"new:token",
"Create a new universal token",
main
);
2 changes: 1 addition & 1 deletion packages/tasks/src/processTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const prepareData = (args: any) => {
return pair;
}
});
const contractName = sanitizeSolidityFunctionName(args.name);
const contractName = sanitizeSolidityFunctionName(args.name || "Contract");
const casts = pairs.map((p: any) => {
const n = capitalizeFirstChar(p[0]);
const type = p[1];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

import "@zetachain/standard-contracts/contracts/nft/contracts/evm/UniversalNFT.sol";

contract EVMUniversalNFT is UniversalNFT {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

import "@zetachain/standard-contracts/contracts/nft/contracts/zetachain/UniversalNFT.sol";

contract ZetaChainUniversalNFT is UniversalNFT {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

import "@zetachain/standard-contracts/contracts/token/contracts/evm/UniversalToken.sol";

contract EVMUniversalToken is UniversalToken {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

import "@zetachain/standard-contracts/contracts/token/contracts/zetachain/UniversalToken.sol";

contract ZetaChainUniversalToken is UniversalToken {}

Large diffs are not rendered by default.

Loading