From 0856cee4ee66d95687bb8ff1e97d1e71b56389fb Mon Sep 17 00:00:00 2001 From: mashharuki Date: Mon, 21 Oct 2024 21:20:56 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=B3=E3=83=BC?= =?UTF-8?q?=E3=83=89=E4=BF=AE=E6=AD=A3=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkgs/contract/gas-report.txt | 70 ++++++-------- pkgs/contract/helpers/deploy/BigBang.ts | 12 +-- pkgs/contract/helpers/deploy/FractionToken.ts | 14 ++- pkgs/contract/scripts/deploy/all.ts | 6 +- pkgs/contract/test/BigBang.ts | 22 +++-- pkgs/contract/test/Burn.ts | 78 +++++++-------- pkgs/contract/test/FractionToken.ts | 96 +++++++++---------- pkgs/contract/test/IntegrationTest.ts | 90 ++++++++--------- pkgs/contract/test/SplitsCreator.ts | 64 ++++++++----- 9 files changed, 221 insertions(+), 231 deletions(-) diff --git a/pkgs/contract/gas-report.txt b/pkgs/contract/gas-report.txt index 4565993..be3d880 100644 --- a/pkgs/contract/gas-report.txt +++ b/pkgs/contract/gas-report.txt @@ -1,39 +1,31 @@ -·--------------------------------------|----------------------------|-------------|-----------------------------· -| Solc version: 0.8.24 · Optimizer enabled: false · Runs: 200 · Block limit: 30000000 gas │ -·······································|····························|·············|······························ -| Methods │ -··················|····················|··············|·············|·············|···············|·············· -| Contract · Method · Min · Max · Avg · # calls · usd (avg) │ -··················|····················|··············|·············|·············|···············|·············· -| BigBang · bigbang · - · - · 603669 · 2 · - │ -··················|····················|··············|·············|·············|···············|·············· -| FractionToken · burn · 41544 · 55511 · 47442 · 4 · - │ -··················|····················|··············|·············|·············|···············|·············· -| FractionToken · mint · 135046 · 137558 · 136717 · 9 · - │ -··················|····················|··············|·············|·············|···············|·············· -| FractionToken · safeTransferFrom · 106335 · 106347 · 106339 · 3 · - │ -··················|····················|··············|·············|·············|···············|·············· -| Deployments · · % of limit · │ -·······································|··············|·············|·············|···············|·············· -| BigBang · - · - · 1248128 · 4.2 % · - │ -·······································|··············|·············|·············|···············|·············· -| FractionToken · - · - · 2859199 · 9.5 % · - │ -·······································|··············|·············|·············|···············|·············· -| Hats · - · - · 7032431 · 23.4 % · - │ -·······································|··············|·············|·············|···············|·············· -| HatsModule · - · - · 754132 · 2.5 % · - │ -·······································|··············|·············|·············|···············|·············· -| HatsModuleFactory · - · - · 1101122 · 3.7 % · - │ -·······································|··············|·············|·············|···············|·············· -| HatsTimeFrameModule · - · - · 1287099 · 4.3 % · - │ -·······································|··············|·············|·············|···············|·············· -| PullSplitFactory · 4535815 · 4535827 · 4535825 · 15.1 % · - │ -·······································|··············|·············|·············|···············|·············· -| PushSplitFactory · 4483101 · 4483113 · 4483111 · 14.9 % · - │ -·······································|··············|·············|·············|···············|·············· -| SplitsCreator · - · - · 1487532 · 5 % · - │ -·······································|··············|·············|·············|···············|·············· -| SplitsCreatorFactory · 526824 · 526836 · 526833 · 1.8 % · - │ -·······································|··············|·············|·············|···············|·············· -| SplitsWarehouse · - · - · 3934655 · 13.1 % · - │ -·--------------------------------------|--------------|-------------|-------------|---------------|-------------· \ No newline at end of file +·------------------------|----------------------------|-------------|-----------------------------· +| Solc version: 0.8.24 · Optimizer enabled: false · Runs: 200 · Block limit: 30000000 gas │ +·························|····························|·············|······························ +| Methods │ +··············|··········|··············|·············|·············|···············|·············· +| Contract · Method · Min · Max · Avg · # calls · usd (avg) │ +··············|··········|··············|·············|·············|···············|·············· +| Deployments · · % of limit · │ +·························|··············|·············|·············|···············|·············· +| BigBang · - · - · 1248128 · 4.2 % · - │ +·························|··············|·············|·············|···············|·············· +| FractionToken · - · - · 2859199 · 9.5 % · - │ +·························|··············|·············|·············|···············|·············· +| Hats · - · - · 7032431 · 23.4 % · - │ +·························|··············|·············|·············|···············|·············· +| HatsModule · - · - · 754132 · 2.5 % · - │ +·························|··············|·············|·············|···············|·············· +| HatsModuleFactory · - · - · 1101122 · 3.7 % · - │ +·························|··············|·············|·············|···············|·············· +| HatsTimeFrameModule · - · - · 1287099 · 4.3 % · - │ +·························|··············|·············|·············|···············|·············· +| PullSplitFactory · - · - · 4535827 · 15.1 % · - │ +·························|··············|·············|·············|···············|·············· +| PushSplitFactory · - · - · 4483113 · 14.9 % · - │ +·························|··············|·············|·············|···············|·············· +| SplitsCreator · - · - · 1487532 · 5 % · - │ +·························|··············|·············|·············|···············|·············· +| SplitsCreatorFactory · - · - · 526836 · 1.8 % · - │ +·························|··············|·············|·············|···············|·············· +| SplitsWarehouse · - · - · 3934655 · 13.1 % · - │ +·------------------------|--------------|-------------|-------------|---------------|-------------· \ No newline at end of file diff --git a/pkgs/contract/helpers/deploy/BigBang.ts b/pkgs/contract/helpers/deploy/BigBang.ts index 341e249..30fcd9d 100644 --- a/pkgs/contract/helpers/deploy/BigBang.ts +++ b/pkgs/contract/helpers/deploy/BigBang.ts @@ -1,4 +1,4 @@ -import { ethers, upgrades } from "hardhat"; +import { ethers, upgrades, viem } from "hardhat"; import { Address } from "viem"; export type BigBang = Awaited>["BigBang"]; @@ -25,7 +25,7 @@ export const deployBigBang = async (params: { */ const bigBang = await ethers.getContractFactory("BigBang"); - const BigBang = await upgrades.deployProxy( + const _BigBang = await upgrades.deployProxy( bigBang, [ params.trustedForwarder, @@ -41,11 +41,11 @@ export const deployBigBang = async (params: { } ); - const tx = await BigBang.deploymentTransaction(); - await tx?.wait(); + await _BigBang.waitForDeployment(); + const address = await _BigBang.getAddress(); - // console.log("BigBang deployed at", tx); - // console.log("BigBang deployed at", BigBang.target); + // create a new instance of the contract + const BigBang = await viem.getContractAt("BigBang", address as Address); return { BigBang }; }; diff --git a/pkgs/contract/helpers/deploy/FractionToken.ts b/pkgs/contract/helpers/deploy/FractionToken.ts index 5188f66..35f55af 100644 --- a/pkgs/contract/helpers/deploy/FractionToken.ts +++ b/pkgs/contract/helpers/deploy/FractionToken.ts @@ -1,4 +1,4 @@ -import { ethers, upgrades } from "hardhat"; +import { ethers, upgrades, viem } from "hardhat"; import { Address } from "viem"; export type FractionToken = Awaited< @@ -12,7 +12,7 @@ export const deployFractionToken = async ( forwarderAddress: Address ) => { const fractionToken = await ethers.getContractFactory("FractionToken"); - const FractionToken = await upgrades.deployProxy( + const _FractionToken = await upgrades.deployProxy( fractionToken, [uri, tokenSupply, hatsContractAddress, forwarderAddress], { @@ -20,8 +20,14 @@ export const deployFractionToken = async ( } ); - const tx = await FractionToken.deploymentTransaction(); - await tx?.wait(); + await _FractionToken.waitForDeployment(); + const address = await _FractionToken.getAddress(); + + // create a new instance of the contract + const FractionToken = await viem.getContractAt( + "FractionToken", + address as Address + ); return { FractionToken }; }; diff --git a/pkgs/contract/scripts/deploy/all.ts b/pkgs/contract/scripts/deploy/all.ts index 6b7b699..0f3fc7b 100644 --- a/pkgs/contract/scripts/deploy/all.ts +++ b/pkgs/contract/scripts/deploy/all.ts @@ -51,7 +51,7 @@ const deployAll = async () => { hatsTimeFrameModule_impl: HatsTimeFrameModule.address, splitsCreatorFactoryAddress: SplitsCreatorFactory.address, splitsFactoryV2Address: PullSplitsFactory as Address, - fractionTokenAddress: FractionToken.target as `0x${string}`, + fractionTokenAddress: FractionToken.address, }); console.log("BigBang deployed at", BigBang.address); @@ -64,13 +64,13 @@ const deployAll = async () => { writeContractAddress({ group: "contracts", name: "BigBang", - value: BigBang.target as `0x${string}`, + value: BigBang.address, network: network.name, }); writeContractAddress({ group: "contracts", name: "FractionToken", - value: FractionToken.target as `0x${string}`, + value: FractionToken.address, network: network.name, }); writeContractAddress({ diff --git a/pkgs/contract/test/BigBang.ts b/pkgs/contract/test/BigBang.ts index 2891aed..1c87685 100644 --- a/pkgs/contract/test/BigBang.ts +++ b/pkgs/contract/test/BigBang.ts @@ -91,27 +91,29 @@ describe("BigBang", () => { hatsTimeFrameModule_impl: HatsTimeFrameModule_IMPL.address, splitsCreatorFactoryAddress: SplitsCreatorFactory.address, splitsFactoryV2Address: PullSplitsFactory.address, - fractionTokenAddress: FractionToken.target as `0x${string}`, + fractionTokenAddress: FractionToken.address, }); - expect(_BigBang.target).to.not.be.undefined; + expect(_BigBang.address).to.not.be.undefined; BigBang = _BigBang; }); it("should execute bigbang", async () => { - const tx = await BigBang.bigbang( - address1.account?.address!, - "tophatDetails", - "tophatURI", - "hatterhatDetails", - "hatterhatURI", - address1.account?.address!, + const txHash = await BigBang.write.bigbang( + [ + address1.account?.address!, + "tophatDetails", + "tophatURI", + "hatterhatDetails", + "hatterhatURI", + address1.account?.address!, + ], { account: address1.account } ); const receipt = await publicClient.waitForTransactionReceipt({ - hash: tx.hash, + hash: txHash, }); for (const log of receipt.logs) { diff --git a/pkgs/contract/test/Burn.ts b/pkgs/contract/test/Burn.ts index cd1bbd3..f6a76cc 100644 --- a/pkgs/contract/test/Burn.ts +++ b/pkgs/contract/test/Burn.ts @@ -1,6 +1,5 @@ import { expect } from "chai"; -import { Signer } from "ethers"; -import { ethers, viem } from "hardhat"; +import { viem } from "hardhat"; import { decodeEventLog, PublicClient, WalletClient, zeroAddress } from "viem"; import { deployFractionToken, @@ -16,10 +15,6 @@ describe("Burn", () => { let address2: WalletClient; let address3: WalletClient; - let signer1: Signer; - let signer2: Signer; - let signer3: Signer; - let hatId: bigint; let publicClient: PublicClient; @@ -38,8 +33,6 @@ describe("Burn", () => { [address1, address2, address3] = await viem.getWalletClients(); - [signer1, signer2, signer3] = await ethers.getSigners(); - publicClient = await viem.getPublicClient(); await Hats.write.mintTopHat([ @@ -80,55 +73,50 @@ describe("Burn", () => { await Hats.write.mintHat([hatId, address2.account?.address!]); // address1とaddress2にFractionTokenをmint - await FractionToken.mint(hatId, address1.account?.address!); - await FractionToken.mint(hatId, address2.account?.address!); + await FractionToken.write.mint([hatId, address1.account?.address!]); + await FractionToken.write.mint([hatId, address2.account?.address!]); - const tokenId = await FractionToken.getTokenId( + const tokenId = await FractionToken.read.getTokenId([ hatId, - address2.account?.address! - ); + address2.account?.address!, + ]); // address2のtokenの半分をaddress3に移動 - await (FractionToken as any) - .connect(signer2) - .safeTransferFrom( + await FractionToken.write.safeTransferFrom( + [ address2.account?.address!, address3.account?.address!, tokenId, 5000n, - "0x" - ); + "0x", + ], + { + account: address2.account!, + } + ); }); it("should burn tokens", async () => { // address1のtokenを自身で半分burnする - await FractionToken.burn( - address1.account?.address!, - address1.account?.address!, - hatId, - 5000n, + await FractionToken.write.burn( + [address1.account?.address!, address1.account?.address!, hatId, 5000n], { account: address1.account!, } ); // address3のtokenをaddress2によってすべてburnする - await (FractionToken as any) - .connect(signer3) - .burn( - address3.account?.address!, - address2.account?.address!, - hatId, - 5000n - ); + await FractionToken.write.burn( + [address3.account?.address!, address2.account?.address!, hatId, 5000n], + { + account: address2.account!, + } + ); // address3のtokenをaddress1によってすべてburnするとRevertする await expect( - FractionToken.burn( - address3.account?.address!, - address2.account?.address!, - hatId, - 5000n, + FractionToken.write.burn( + [address3.account?.address!, address2.account?.address!, hatId, 5000n], { account: address1.account!, } @@ -138,27 +126,27 @@ describe("Burn", () => { let balance: bigint; // address1のbalance - balance = await FractionToken["balanceOf(address,address,uint256)"]( + balance = await FractionToken.read.balanceOf([ address1.account?.address!, address1.account?.address!, - hatId - ); + hatId, + ]); expect(balance).to.equal(5000n); // address2のbalance - balance = await FractionToken["balanceOf(address,address,uint256)"]( + balance = await FractionToken.read.balanceOf([ address2.account?.address!, address2.account?.address!, - hatId - ); + hatId, + ]); expect(balance).to.equal(5000n); // address3のbalance - balance = await FractionToken["balanceOf(address,address,uint256)"]( + balance = await FractionToken.read.balanceOf([ address3.account?.address!, address2.account?.address!, - hatId - ); + hatId, + ]); expect(balance).to.equal(0n); }); }); diff --git a/pkgs/contract/test/FractionToken.ts b/pkgs/contract/test/FractionToken.ts index 99a70d5..9f4e036 100644 --- a/pkgs/contract/test/FractionToken.ts +++ b/pkgs/contract/test/FractionToken.ts @@ -1,6 +1,5 @@ import { expect } from "chai"; -import { Signer } from "ethers"; -import { ethers, viem } from "hardhat"; +import { viem } from "hardhat"; import { decodeEventLog, PublicClient, WalletClient, zeroAddress } from "viem"; import { deployFractionToken, @@ -17,10 +16,6 @@ describe("FractionToken", () => { let address3: WalletClient; let address4: WalletClient; - let signer1: Signer; - let signer2: Signer; - let signer3: Signer; - let hatId: bigint; let publicClient: PublicClient; @@ -39,8 +34,6 @@ describe("FractionToken", () => { [address1, address2, address3, address4] = await viem.getWalletClients(); - [signer1, signer2, signer3] = await ethers.getSigners(); - publicClient = await viem.getPublicClient(); await Hats.write.mintTopHat([ @@ -83,99 +76,96 @@ describe("FractionToken", () => { it("should mint, transfer and burn tokens", async () => { // address1,address2にtokenをmint - await FractionToken.mint(hatId, address1.account?.address!); - await FractionToken.mint(hatId, address2.account?.address!); + await FractionToken.write.mint([hatId, address1.account?.address!]); + await FractionToken.write.mint([hatId, address2.account?.address!]); - const tokenId = await FractionToken.getTokenId( + const tokenId = await FractionToken.read.getTokenId([ hatId, - address2.account?.address! - ); + address2.account?.address!, + ]); // address2のtokenの半分をaddress3に移動 - await (FractionToken as any) - .connect(signer2) - .safeTransferFrom( + await FractionToken.write.safeTransferFrom( + [ address2.account?.address!, address3.account?.address!, tokenId, 5000n, - "0x" - ); + "0x", + ], + { + account: address2.account!, + } + ); // address1のtokenを自ら半分burnする - await FractionToken.burn( - address1.account?.address!, - address1.account?.address!, - hatId, - 5000n, + await FractionToken.write.burn( + [address1.account?.address!, address1.account?.address!, hatId, 5000n], { account: address1.account!, } ); // address3のtokenをaddress2によって半分burnする - await (FractionToken as any) - .connect(signer2) - .burn( - address3.account?.address!, - address2.account?.address!, - hatId, - 2500n - ); + await FractionToken.write.burn( + [address3.account?.address!, address2.account?.address!, hatId, 2500n], + { + account: address2.account!, + } + ); let balance: bigint; // address1のbalance - balance = await FractionToken["balanceOf(address,address,uint256)"]( + balance = await FractionToken.read.balanceOf([ address1.account?.address!, address1.account?.address!, - hatId - ); + hatId, + ]); expect(balance).to.equal(5000n); // address2のbalance - balance = await FractionToken["balanceOf(address,address,uint256)"]( + balance = await FractionToken.read.balanceOf([ address2.account?.address!, address2.account?.address!, - hatId - ); + hatId, + ]); expect(balance).to.equal(5000n); // address3のbalance - balance = await FractionToken["balanceOf(address,address,uint256)"]( + balance = await FractionToken.read.balanceOf([ address3.account?.address!, address2.account?.address!, - hatId - ); + hatId, + ]); expect(balance).to.equal(2500n); }); it("should fail to mint a token", async () => { // roleのない人にtokenはmintできない - await FractionToken.mint(hatId, address3.account?.address!).catch( - (error: any) => { + await FractionToken.write + .mint([hatId, address3.account?.address!]) + .catch((error: any) => { expect(error.message).to.include("not authorized"); - } - ); + }); // tokenは二度mintできない - await FractionToken.mint(hatId, address1.account?.address!).catch( - (error: any) => { + await FractionToken.write + .mint([hatId, address1.account?.address!]) + .catch((error: any) => { expect(error.message).to.include("already received"); - } - ); + }); }); it("should fail to burn a token", async () => { // address1のtokenはaddress2によってburnできない - await (FractionToken as any) - .connect(signer2) - .burn( + await FractionToken.write + .burn([ address1.account?.address!, address1.account?.address!, hatId, - 5000n - ) + 5000n, + ]) .catch((error: any) => { expect(error.message).to.include("not authorized"); }); diff --git a/pkgs/contract/test/IntegrationTest.ts b/pkgs/contract/test/IntegrationTest.ts index 8b141b8..b758274 100644 --- a/pkgs/contract/test/IntegrationTest.ts +++ b/pkgs/contract/test/IntegrationTest.ts @@ -1,6 +1,5 @@ import { expect } from "chai"; -import { Signer } from "ethers"; -import { ethers, viem } from "hardhat"; +import { viem } from "hardhat"; import { Address, decodeEventLog, @@ -59,10 +58,6 @@ describe("IntegrationTest", () => { let address2: WalletClient; let address3: WalletClient; - let signer1: Signer; - let signer2: Signer; - let signer3: Signer; - let publicClient: PublicClient; const getPullSplitContract = async (address: Address) => { @@ -108,7 +103,7 @@ describe("IntegrationTest", () => { SplitsCreatorFactory = _SplitsCreatorFactory; [deployer, address1, address2, address3] = await viem.getWalletClients(); - [signer1, signer2, signer3] = await ethers.getSigners(); + publicClient = await viem.getPublicClient(); }); @@ -120,27 +115,29 @@ describe("IntegrationTest", () => { hatsTimeFrameModule_impl: HatsTimeFrameModule_IMPL.address, splitsCreatorFactoryAddress: SplitsCreatorFactory.address, splitsFactoryV2Address: PullSplitsFactory.address, - fractionTokenAddress: FractionToken.target as `0x${string}`, + fractionTokenAddress: FractionToken.address, }); - expect(_BigBang.target).to.not.be.undefined; + expect(_BigBang.address).to.not.be.undefined; BigBang = _BigBang; }); it("should execute bigbang", async () => { - const tx = await BigBang.bigbang( - deployer.account?.address!, - "tophatDetails", - "tophatURI", - "hatterhatDetails", - "hatterhatURI", - deployer.account?.address!, + const txHash = await BigBang.write.bigbang( + [ + deployer.account?.address!, + "tophatDetails", + "tophatURI", + "hatterhatDetails", + "hatterhatURI", + deployer.account?.address!, + ], { account: deployer.account } ); const receipt = await publicClient.waitForTransactionReceipt({ - hash: tx.hash, + hash: txHash, }); for (const log of receipt.logs) { @@ -238,75 +235,78 @@ describe("IntegrationTest", () => { it("should mint FractionToken", async () => { // address1,address2にtokenをmint - await FractionToken.mint(hat1_id, address1.account?.address!); - await FractionToken.mint(hat1_id, address2.account?.address!); + await FractionToken.write.mint([hat1_id, address1.account?.address!]); + await FractionToken.write.mint([hat1_id, address2.account?.address!]); // Check balance for address1 - let balance1 = await FractionToken["balanceOf(address,address,uint256)"]( + let balance1 = await FractionToken.read.balanceOf([ address1.account?.address!, address1.account?.address!, - hat1_id - ); + hat1_id, + ]); expect(balance1).to.equal(10000n); // Check balance for address2 - let balance2 = await FractionToken["balanceOf(address,address,uint256)"]( + let balance2 = await FractionToken.read.balanceOf([ address2.account?.address!, address2.account?.address!, - hat1_id - ); + hat1_id, + ]); expect(balance2).to.equal(10000n); // Check that address3 has no balance yet - let balance3 = await FractionToken["balanceOf(address,address,uint256)"]( + let balance3 = await FractionToken.read.balanceOf([ address3.account?.address!, address2.account?.address!, - hat1_id - ); + hat1_id, + ]); expect(balance3).to.equal(0n); }); it("should transfer and burn tokens", async () => { - const tokenId = await FractionToken.getTokenId( + const tokenId = await FractionToken.read.getTokenId([ hat1_id, - address1.account?.address! - ); + address1.account?.address!, + ]); // address2のtokenの半分をaddress3に移動 - await (FractionToken as any) - .connect(signer2) - .safeTransferFrom( + await FractionToken.write.safeTransferFrom( + [ address1.account?.address!, address3.account?.address!, tokenId, 1000n, - "0x" - ); + "0x", + ], + { + account: address1.account!, + } + ); let balance: bigint; // address1のbalance - balance = await FractionToken["balanceOf(address,address,uint256)"]( + balance = await FractionToken.read.balanceOf([ address1.account?.address!, address1.account?.address!, - hat1_id - ); + hat1_id, + ]); expect(balance).to.equal(9000n); // address2のbalance - balance = await FractionToken["balanceOf(address,address,uint256)"]( + balance = await FractionToken.read.balanceOf([ address2.account?.address!, address2.account?.address!, - hat1_id - ); + hat1_id, + ]); expect(balance).to.equal(10000n); // address3のbalance - balance = await FractionToken["balanceOf(address,address,uint256)"]( + balance = await FractionToken.read.balanceOf([ address3.account?.address!, address1.account?.address!, - hat1_id - ); + hat1_id, + ]); expect(balance).to.equal(1000n); }); diff --git a/pkgs/contract/test/SplitsCreator.ts b/pkgs/contract/test/SplitsCreator.ts index 587a678..99141ac 100644 --- a/pkgs/contract/test/SplitsCreator.ts +++ b/pkgs/contract/test/SplitsCreator.ts @@ -131,7 +131,7 @@ describe("SplitsCreator Factory", () => { zeroAddress, PullSplitsFactory.address, HatsTimeFrameModule.address, - FractionToken.target as `0x${string}`, + FractionToken.address, keccak256("0x1234"), ]) ).to.be.a("string"); @@ -144,7 +144,7 @@ describe("SplitsCreator Factory", () => { address1.account?.address!, PullSplitsFactory.address, HatsTimeFrameModule.address, - FractionToken.target as `0x${string}`, + FractionToken.address, keccak256("0x1234"), ]); @@ -153,7 +153,7 @@ describe("SplitsCreator Factory", () => { address1.account?.address!, PullSplitsFactory.address, HatsTimeFrameModule.address, - FractionToken.target as `0x${string}`, + FractionToken.address, keccak256("0x1234"), ]); @@ -163,7 +163,7 @@ describe("SplitsCreator Factory", () => { (await SplitsCreator.read.HATS_TIME_FRAME_MODULE()).toLowerCase() ).equal(HatsTimeFrameModule.address.toLowerCase()); expect((await SplitsCreator.read.FRACTION_TOKEN()).toLowerCase()).equal( - (FractionToken.target as `0x${string}`).toLowerCase() + FractionToken.address.toLowerCase() ); }); }); @@ -276,7 +276,7 @@ describe("CreateSplit", () => { address1.account?.address!, PullSplitsFactory.address, HatsTimeFrameModule.address, - FractionToken.target as `0x${string}`, + FractionToken.address, keccak256("0x1234"), ]); @@ -413,27 +413,33 @@ describe("CreateSplit", () => { }) .then((block) => block.timestamp); - await FractionToken.mint(hat1_id, address1.account?.address!); - await FractionToken.mint(hat1_id, address2.account?.address!); - await FractionToken.mint(hat2_id, address3.account?.address!); + await FractionToken.write.mint([hat1_id, address1.account?.address!]); + await FractionToken.write.mint([hat1_id, address2.account?.address!]); + await FractionToken.write.mint([hat2_id, address3.account?.address!]); // let balance: bigint; - const address1Balance = await FractionToken[ - "balanceOf(address,address,uint256)" - ](address1.account?.address!, address1.account?.address!, hat1_id); + const address1Balance = await FractionToken.read.balanceOf([ + address1.account?.address!, + address1.account?.address!, + hat1_id, + ]); expect(address1Balance).to.equal(10000n); // address2のbalance - const address2Balance = await FractionToken[ - "balanceOf(address,address,uint256)" - ](address2.account?.address!, address2.account?.address!, hat1_id); + const address2Balance = await FractionToken.read.balanceOf([ + address2.account?.address!, + address2.account?.address!, + hat1_id, + ]); expect(address2Balance).to.equal(10000n); // address3のbalance - const address3Balance = await FractionToken[ - "balanceOf(address,address,uint256)" - ](address3.account?.address!, address3.account?.address!, hat2_id); + const address3Balance = await FractionToken.read.balanceOf([ + address3.account?.address!, + address3.account?.address!, + hat2_id, + ]); expect(address3Balance).to.equal(10000n); }); @@ -499,21 +505,27 @@ describe("CreateSplit", () => { const sqrtAddress2Time = sqrt(address2Time); const sqrtAddress3Time = sqrt(address3Time); - const address1Balance = await FractionToken[ - "balanceOf(address,address,uint256)" - ](address1.account?.address!, address1.account?.address!, hat1_id); + const address1Balance = await FractionToken.read.balanceOf([ + address1.account?.address!, + address1.account?.address!, + hat1_id, + ]); expect(address1Balance).to.equal(10000n); // address2のbalance - const address2Balance = await FractionToken[ - "balanceOf(address,address,uint256)" - ](address2.account?.address!, address2.account?.address!, hat1_id); + const address2Balance = await FractionToken.read.balanceOf([ + address2.account?.address!, + address2.account?.address!, + hat1_id, + ]); expect(address2Balance).to.equal(10000n); // address3のbalance - const address3Balance = await FractionToken[ - "balanceOf(address,address,uint256)" - ](address3.account?.address!, address3.account?.address!, hat2_id); + const address3Balance = await FractionToken.read.balanceOf([ + address3.account?.address!, + address3.account?.address!, + hat2_id, + ]); expect(address3Balance).to.equal(10000n); expect(allocations.length).to.equal(3);