diff --git a/README.md b/README.md index de86a57..c416497 100644 --- a/README.md +++ b/README.md @@ -209,3 +209,15 @@ These solutions were combined with ideas from [Hats Protocol](https://www.hatspr ```bash yarn contract bigbang --owner 0x51908F598A5e0d8F1A3bAbFa6DF76F9704daD072 --tophatdetails "tophatDetails" --tophatimageuri "tophatURI" --hatterhatdetails "hatterhatURI" --hatterhatimageuri "tophatDetails" --forwarder 0x51908F598A5e0d8F1A3bAbFa6DF76F9704daD072 --network sepolia ``` + + - #### **call getWoreTime task** + + ```bash + yarn contract getWoreTime --wearer 0x51908F598A5e0d8F1A3bAbFa6DF76F9704daD072 --network sepolia + ``` + + - #### **call mintHat task** + + ```bash + yarn contract mintHat --hatid 17011726346972053710434886519909386955065038130623101235576378067255296 --wearer 0x1295BDc0C102EB105dC0198fdC193588fe66A1e4 --network sepolia + ``` diff --git a/pkgs/contract/hardhat.config.ts b/pkgs/contract/hardhat.config.ts index 1799c71..a040f4e 100644 --- a/pkgs/contract/hardhat.config.ts +++ b/pkgs/contract/hardhat.config.ts @@ -21,7 +21,7 @@ const { // タスクファイルを読み込むための設定 const SKIP_LOAD = process.env.SKIP_LOAD === "true"; if (!SKIP_LOAD) { - const taskPaths = ["", "utils", "ens", "BigBang"]; + const taskPaths = ["", "utils", "ens", "BigBang", "HatsTimeFrameModule"]; taskPaths.forEach((folder) => { const tasksPath = path.join(__dirname, "tasks", folder); fs.readdirSync(tasksPath) diff --git a/pkgs/contract/package.json b/pkgs/contract/package.json index 1fe7508..bb5d860 100644 --- a/pkgs/contract/package.json +++ b/pkgs/contract/package.json @@ -19,7 +19,9 @@ "createSplit": "npx hardhat run scripts/createSplit.ts", "upgrade:FractionToken": "npx hardhat run scripts/upgrade/FractionToken.ts", "upgrade:BigBang": "npx hardhat run scripts/upgrade/BigBang.ts", - "bigbang": "npx hardhat bigbang" + "bigbang": "npx hardhat bigbang", + "getWoreTime": "npx hardhat getWoreTime", + "mintHat": "npx hardhat mintHat" }, "devDependencies": { "@nomicfoundation/hardhat-ethers": "^3.0.0", diff --git a/pkgs/contract/tasks/HatsTimeFrameModule/getWoreTime.ts b/pkgs/contract/tasks/HatsTimeFrameModule/getWoreTime.ts new file mode 100644 index 0000000..4e7a572 --- /dev/null +++ b/pkgs/contract/tasks/HatsTimeFrameModule/getWoreTime.ts @@ -0,0 +1,37 @@ +import { task } from "hardhat/config"; +import { HardhatRuntimeEnvironment } from "hardhat/types"; +import { loadDeployedContractAddresses } from "../../helpers/deploy/contractsJsonHelper"; + +/** + * 【Task】get getWoreTime of HatsTimeFrameModule + */ +task("getWoreTime", "getWoreTime") + .addParam("wearer", "address of wearer") + .setAction(async (taskArgs: any, hre: HardhatRuntimeEnvironment) => { + console.log( + "################################### [START] ###################################" + ); + + // BigBangコントラクトのアドレスをjsonファイルから取得してくる。 + const { + contracts: { HatsTimeFrameModule }, + } = loadDeployedContractAddresses(hre.network.name); + + // create HatsTimeFrameModule instance + const hatsTimeFrameModuleByBigBang = await hre.viem.getContractAt( + "HatsTimeFrameModule", + HatsTimeFrameModule + ); + + // call getWoreTime method + const woreTime = await hatsTimeFrameModuleByBigBang.read.getWoreTime([ + taskArgs.wearer, + 0n, + ]); + + console.log(`woreTime: ${woreTime}`); + + console.log( + "################################### [END] ###################################" + ); + }); diff --git a/pkgs/contract/tasks/HatsTimeFrameModule/mintHat.ts b/pkgs/contract/tasks/HatsTimeFrameModule/mintHat.ts new file mode 100644 index 0000000..fe2e95c --- /dev/null +++ b/pkgs/contract/tasks/HatsTimeFrameModule/mintHat.ts @@ -0,0 +1,38 @@ +import { task } from "hardhat/config"; +import { HardhatRuntimeEnvironment } from "hardhat/types"; +import { loadDeployedContractAddresses } from "../../helpers/deploy/contractsJsonHelper"; + +/** + * 【Task】call mintHat of HatsTimeFrameModule + */ +task("mintHat", "mintHat") + .addParam("hatid", "hatid") + .addParam("wearer", "address of wearer") + .setAction(async (taskArgs: any, hre: HardhatRuntimeEnvironment) => { + console.log( + "################################### [START] ###################################" + ); + + // BigBangコントラクトのアドレスをjsonファイルから取得してくる。 + const { + contracts: { HatsTimeFrameModule }, + } = loadDeployedContractAddresses(hre.network.name); + + // create HatsTimeFrameModule instance + const hatsTimeFrameModuleByBigBang = await hre.viem.getContractAt( + "HatsTimeFrameModule", + HatsTimeFrameModule + ); + + // call mintHat method + const tx = await hatsTimeFrameModuleByBigBang.write.mintHat([ + taskArgs.hatid, + taskArgs.wearer, + ]); + + console.log(`tx: ${tx}`); + + console.log( + "################################### [END] ###################################" + ); + });