diff --git a/contracts/nft/hardhat.config.ts b/contracts/nft/hardhat.config.ts index 32b68ca..4a2d8a9 100644 --- a/contracts/nft/hardhat.config.ts +++ b/contracts/nft/hardhat.config.ts @@ -1,8 +1,8 @@ import "./tasks/deploy"; import "./tasks/mint"; import "./tasks/transfer"; -import "./tasks/universalSetConnected"; -import "./tasks/connectedSetUniversal"; +import "./tasks/setConnected"; +import "./tasks/setUniversal"; import "@zetachain/localnet/tasks"; import "@nomicfoundation/hardhat-toolbox"; import "@zetachain/toolkit/tasks"; diff --git a/contracts/nft/scripts/localnet.sh b/contracts/nft/scripts/localnet.sh index 274ec98..731b2c4 100755 --- a/contracts/nft/scripts/localnet.sh +++ b/contracts/nft/scripts/localnet.sh @@ -29,46 +29,46 @@ GATEWAY_BNB=$(jq -r '.addresses[] | select(.type=="gatewayEVM" and .chain=="bnb" UNISWAP_ROUTER=$(jq -r '.addresses[] | select(.type=="uniswapRouterInstance" and .chain=="zetachain") | .address' localnet.json) SENDER=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 -CONTRACT_ZETACHAIN=$(npx hardhat deploy --network localhost --name ZetaChainUniversalNFT --gateway "$GATEWAY_ZETACHAIN" --uniswap-router "$UNISWAP_ROUTER" --json | jq -r '.contractAddress') +CONTRACT_ZETACHAIN=$(npx hardhat nft:deploy --network localhost --name ZetaChainUniversalNFT --gateway "$GATEWAY_ZETACHAIN" --uniswap-router "$UNISWAP_ROUTER" --json | jq -r '.contractAddress') echo -e "\nšŸš€ Deployed NFT contract on ZetaChain: $CONTRACT_ZETACHAIN" -CONTRACT_ETHEREUM=$(npx hardhat deploy --name EVMUniversalNFT --json --network localhost --gateway "$GATEWAY_ETHEREUM" | jq -r '.contractAddress') +CONTRACT_ETHEREUM=$(npx hardhat nft:deploy --name EVMUniversalNFT --json --network localhost --gateway "$GATEWAY_ETHEREUM" | jq -r '.contractAddress') echo -e "šŸš€ Deployed NFT contract on Ethereum: $CONTRACT_ETHEREUM" -CONTRACT_BNB=$(npx hardhat deploy --name EVMUniversalNFT --json --network localhost --gas-limit 1000000 --gateway "$GATEWAY_BNB" | jq -r '.contractAddress') +CONTRACT_BNB=$(npx hardhat nft:deploy --name EVMUniversalNFT --json --network localhost --gas-limit 1000000 --gateway "$GATEWAY_BNB" | jq -r '.contractAddress') echo -e "šŸš€ Deployed NFT contract on BNB chain: $CONTRACT_BNB" echo -e "\nšŸ“® User Address: $SENDER" echo -e "\nšŸ”— Setting universal and connected contracts..." -npx hardhat connected-set-universal --network localhost --contract "$CONTRACT_ETHEREUM" --universal "$CONTRACT_ZETACHAIN" --json -npx hardhat connected-set-universal --network localhost --contract "$CONTRACT_BNB" --universal "$CONTRACT_ZETACHAIN" --json &>/dev/null -npx hardhat universal-set-connected --network localhost --contract "$CONTRACT_ZETACHAIN" --connected "$CONTRACT_ETHEREUM" --zrc20 "$ZRC20_ETHEREUM" --json &>/dev/null -npx hardhat universal-set-connected --network localhost --contract "$CONTRACT_ZETACHAIN" --connected "$CONTRACT_BNB" --zrc20 "$ZRC20_BNB" --json &>/dev/null +npx hardhat nft:set-universal --network localhost --contract "$CONTRACT_ETHEREUM" --universal "$CONTRACT_ZETACHAIN" --json +npx hardhat nft:set-universal --network localhost --contract "$CONTRACT_BNB" --universal "$CONTRACT_ZETACHAIN" --json &>/dev/null +npx hardhat nft:set-connected --network localhost --contract "$CONTRACT_ZETACHAIN" --connected "$CONTRACT_ETHEREUM" --zrc20 "$ZRC20_ETHEREUM" --json &>/dev/null +npx hardhat nft:set-connected --network localhost --contract "$CONTRACT_ZETACHAIN" --connected "$CONTRACT_BNB" --zrc20 "$ZRC20_BNB" --json &>/dev/null npx hardhat localnet-check balance -NFT_ID=$(npx hardhat mint --network localhost --json --contract "$CONTRACT_ZETACHAIN" --token-uri https://example.com/nft/metadata/1 | jq -r '.tokenId') +NFT_ID=$(npx hardhat nft:mint --network localhost --json --contract "$CONTRACT_ZETACHAIN" --token-uri https://example.com/nft/metadata/1 | jq -r '.tokenId') echo -e "\nMinted NFT with ID: $NFT_ID on ZetaChain." npx hardhat localnet-check balance echo -e "\nTransferring NFT: ZetaChain ā†’ Ethereum..." -npx hardhat transfer --network localhost --json --token-id "$NFT_ID" --from "$CONTRACT_ZETACHAIN" --to "$ZRC20_ETHEREUM" --gas-amount 1 +npx hardhat nft:transfer --network localhost --json --token-id "$NFT_ID" --from "$CONTRACT_ZETACHAIN" --to "$ZRC20_ETHEREUM" --gas-amount 1 npx hardhat localnet-check balance echo -e "\nTransferring NFT: Ethereum ā†’ BNB..." -npx hardhat transfer --network localhost --json --token-id "$NFT_ID" --from "$CONTRACT_ETHEREUM" --to "$ZRC20_BNB" --gas-amount 1 +npx hardhat nft:transfer --network localhost --json --token-id "$NFT_ID" --from "$CONTRACT_ETHEREUM" --to "$ZRC20_BNB" --gas-amount 1 npx hardhat localnet-check balance echo -e "\nTransferring NFT: BNB ā†’ ZetaChain..." -npx hardhat transfer --network localhost --json --token-id "$NFT_ID" --from "$CONTRACT_BNB" +npx hardhat nft:transfer --network localhost --json --token-id "$NFT_ID" --from "$CONTRACT_BNB" npx hardhat localnet-check balance diff --git a/contracts/nft/tasks/deploy.ts b/contracts/nft/tasks/deploy.ts index 786f5ce..a64109f 100644 --- a/contracts/nft/tasks/deploy.ts +++ b/contracts/nft/tasks/deploy.ts @@ -45,7 +45,7 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => { } }; -task("deploy", "Deploy the NFT contract", main) +export const nftDeploy = task("nft:deploy", "Deploy the NFT contract", main) .addFlag("json", "Output the result in JSON format") .addOptionalParam("tokenName", "NFT name", "Universal NFT") .addOptionalParam("tokenSymbol", "NFT symbol", "UNFT") diff --git a/contracts/nft/tasks/index.ts b/contracts/nft/tasks/index.ts new file mode 100644 index 0000000..c6de558 --- /dev/null +++ b/contracts/nft/tasks/index.ts @@ -0,0 +1,5 @@ +export { nftSetUniversal } from "./setUniversal"; +export { nftMint } from "./mint"; +export { nftTransfer } from "./transfer"; +export { nftSetConnected } from "./setConnected"; +export { nftDeploy } from "./deploy"; diff --git a/contracts/nft/tasks/mint.ts b/contracts/nft/tasks/mint.ts index f7f6b90..4e55d6d 100644 --- a/contracts/nft/tasks/mint.ts +++ b/contracts/nft/tasks/mint.ts @@ -80,7 +80,7 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => { } }; -task("mint", "Mint an NFT", main) +export const nftMint = task("nft:mint", "Mint an NFT", main) .addParam("contract", "The address of the deployed NFT contract") .addOptionalParam( "to", diff --git a/contracts/nft/tasks/universalSetConnected.ts b/contracts/nft/tasks/setConnected.ts similarity index 93% rename from contracts/nft/tasks/universalSetConnected.ts rename to contracts/nft/tasks/setConnected.ts index 2c89a03..3916695 100644 --- a/contracts/nft/tasks/universalSetConnected.ts +++ b/contracts/nft/tasks/setConnected.ts @@ -44,7 +44,11 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => { } }; -task("universal-set-connected", "Sets the connected contract address", main) +export const nftSetConnected = task( + "nft:set-connected", + "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("connected", "The address of the connected contract to set") diff --git a/contracts/nft/tasks/connectedSetUniversal.ts b/contracts/nft/tasks/setUniversal.ts similarity index 93% rename from contracts/nft/tasks/connectedSetUniversal.ts rename to contracts/nft/tasks/setUniversal.ts index 2bfd859..9a54073 100644 --- a/contracts/nft/tasks/connectedSetUniversal.ts +++ b/contracts/nft/tasks/setUniversal.ts @@ -41,7 +41,11 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => { } }; -task("connected-set-universal", "Sets the universal contract address", main) +export const nftSetUniversal = task( + "nft:set-universal", + "Sets the universal contract address", + main +) .addParam("contract", "The address of the deployed contract") .addParam("universal", "The address of the universal contract to set") .addFlag("json", "Output the result in JSON format"); diff --git a/contracts/nft/tasks/transfer.ts b/contracts/nft/tasks/transfer.ts index f68a18b..cf062da 100644 --- a/contracts/nft/tasks/transfer.ts +++ b/contracts/nft/tasks/transfer.ts @@ -57,7 +57,11 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => { } }; -task("transfer", "Transfer and lock an NFT", main) +export const nftTransfer = task( + "nft:transfer", + "Transfer and lock an NFT", + main +) .addOptionalParam("receiver", "The address to receive the NFT") .addParam("from", "The contract being transferred from") .addParam("tokenId", "The ID of the NFT to transfer")