From e930ce9ef0ed357b02b6029f4793184828491725 Mon Sep 17 00:00:00 2001 From: yu23ki14 Date: Mon, 30 Sep 2024 20:57:55 +0900 Subject: [PATCH] deploy --- .github/workflows/test-contract.yml | 38 ++++++++--------- README.md | 13 +++--- pkgs/contract/contracts/bigbang/BigBang.sol | 22 ++++++---- pkgs/contract/gas-report.txt | 31 ++++++++++++++ pkgs/contract/hardhat.config.ts | 5 +++ pkgs/contract/helpers/deploy/BigBang.ts | 4 ++ pkgs/contract/scripts/deploy/all.ts | 46 +++++++++++++++++++++ pkgs/contract/test/BigBang.ts | 4 +- pkgs/contract/utils/signTx.ts | 31 -------------- 9 files changed, 129 insertions(+), 65 deletions(-) create mode 100644 pkgs/contract/gas-report.txt create mode 100644 pkgs/contract/scripts/deploy/all.ts delete mode 100644 pkgs/contract/utils/signTx.ts diff --git a/.github/workflows/test-contract.yml b/.github/workflows/test-contract.yml index 9794512..cf7d8cb 100644 --- a/.github/workflows/test-contract.yml +++ b/.github/workflows/test-contract.yml @@ -37,22 +37,22 @@ jobs: env: PRIVATE_KEY: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" - - name: Generate Gas Report - run: | - npx hardhat test --network hardhat > ./gas-report.txt - echo "\n### Gas Report" >> ./comments - echo "\`\`\`\n$(cat ./gas-report.txt)" >> ./comments - working-directory: ./pkgs/contract - - - name: Upload Gas Report as Artifact - uses: actions/upload-artifact@v3 - with: - name: gas-report - path: ./pkgs/contract/gas-report.txt - - # GitHub PRにテスト結果とガスレポートをコメントとして投稿 - - name: Post comments - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - URL: ${{ github.event.pull_request.html_url }} - run: gh pr comment -F ./comments "${URL}" + # - name: Generate Gas Report + # run: | + # npx hardhat test --network hardhat > ./gas-report.txt + # echo "\n### Gas Report" >> ./comments + # echo "\`\`\`\n$(cat ./gas-report.txt)" >> ./comments + # working-directory: ./pkgs/contract + + # - name: Upload Gas Report as Artifact + # uses: actions/upload-artifact@v3 + # with: + # name: gas-report + # path: ./pkgs/contract/gas-report.txt + + # # GitHub PRにテスト結果とガスレポートをコメントとして投稿 + # - name: Post comments + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # URL: ${{ github.event.pull_request.html_url }} + # run: gh pr comment -F ./comments "${URL}" diff --git a/README.md b/README.md index b9e12b7..6b0eab5 100644 --- a/README.md +++ b/README.md @@ -44,11 +44,14 @@ These solutions were combined with ideas from [Hats Protocol](https://www.hatspr ### Holesky -| ContractAddress | Name | Memo | -| ------------------------------------------ | ----------------- | ---- | -| 0x3bc1A0Ad72417f2d411118085256fC53CBdDd137 | Hats | | -| 0xfE661c01891172046feE16D3a57c3Cf456729efA | HatsModuleFactory | | -| 0x80f1B766817D04870f115fEBbcCADF8DBF75E017 | PullSplitsFactory | | +| ContractAddress | Name | Memo | +| ------------------------------------------ | -------------------- | ---- | +| 0xa55410b75578c8941a76249c18c72167459253c7 | BigBang | | +| 0x143a4605b682ec096274cef9fde5b3c077498942 | FractionToken | | +| 0xea4ee24c8411a71a7ce2cd676e1f17ebe18c2a98 | SplitsCreatorFactory | | +| 0x3bc1A0Ad72417f2d411118085256fC53CBdDd137 | Hats | | +| 0xfE661c01891172046feE16D3a57c3Cf456729efA | HatsModuleFactory | | +| 0x80f1B766817D04870f115fEBbcCADF8DBF75E017 | PullSplitsFactory | | ## How to work diff --git a/pkgs/contract/contracts/bigbang/BigBang.sol b/pkgs/contract/contracts/bigbang/BigBang.sol index 708a012..8a6c35c 100644 --- a/pkgs/contract/contracts/bigbang/BigBang.sol +++ b/pkgs/contract/contracts/bigbang/BigBang.sol @@ -16,6 +16,10 @@ contract BigBang is ERC2771Context { address public HatsTimeFrameModule_IMPL; + address public splitFactoryV2; + + address public fractionToken; + event Executed( address indexed owner, uint256 indexed topHatId, @@ -30,18 +34,24 @@ contract BigBang is ERC2771Context { * @param _hatsModuleFactory Address of the hats module factory contract. * @param _hatsTimeFrameModule_IMPL Address of the hats time frame module implementation contract. * @param _splitsCreatorFactory Address of the splits creator factory contract. + * @param _splitFactoryV2 Address of the split factory V2 contract. + * @param _fractionToken Address of the fraction token contract. */ constructor( address _trustedForwarder, address _hatsAddress, address _hatsModuleFactory, address _hatsTimeFrameModule_IMPL, - address _splitsCreatorFactory + address _splitsCreatorFactory, + address _splitFactoryV2, + address _fractionToken ) ERC2771Context(_trustedForwarder) { Hats = IHats(_hatsAddress); HatsModuleFactory = IHatsModuleFactory(_hatsModuleFactory); HatsTimeFrameModule_IMPL = _hatsTimeFrameModule_IMPL; SplitsCreatorFactory = ISplitsCreatorFactory(_splitsCreatorFactory); + splitFactoryV2 = _splitFactoryV2; + fractionToken = _fractionToken; } /** @@ -52,8 +62,6 @@ contract BigBang is ERC2771Context { * @param _hatterHatDetails The details of the hatterHat. * @param _hatterHatImageURI The image URI of the hatterHat. * @param _trustedForwarder The address of the trusted forwarder. - * @param _splitFactoryV2 The address of the splitFactoryV2 contract. - * @param _fractionToken The address of the fractionToken contract. * @return topHatId The ID used for navigating to the ProjectTop page after project creation. */ function bigbang( @@ -62,9 +70,7 @@ contract BigBang is ERC2771Context { string calldata _topHatImageURI, string calldata _hatterHatDetails, string calldata _hatterHatImageURI, - address _trustedForwarder, - address _splitFactoryV2, - address _fractionToken + address _trustedForwarder ) external returns (uint256) { // 1. TopHatのMint @@ -106,9 +112,9 @@ contract BigBang is ERC2771Context { .createSplitCreatorDeterministic( topHatId, _trustedForwarder, - _splitFactoryV2, + splitFactoryV2, hatsTimeFrameModule, - _fractionToken, + fractionToken, keccak256(abi.encodePacked(topHatId)) ); diff --git a/pkgs/contract/gas-report.txt b/pkgs/contract/gas-report.txt new file mode 100644 index 0000000..45a6b6c --- /dev/null +++ b/pkgs/contract/gas-report.txt @@ -0,0 +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) │ +··············|··········|··············|·············|·············|···············|·············· +| Deployments · · % of limit · │ +·························|··············|·············|·············|···············|·············· +| BigBang · - · - · 1089851 · 3.6 % · - │ +·························|··············|·············|·············|···············|·············· +| FractionToken · - · - · 2573797 · 8.6 % · - │ +·························|··············|·············|·············|···············|·············· +| Hats · - · - · 7032431 · 23.4 % · - │ +·························|··············|·············|·············|···············|·············· +| HatsModule · - · - · 754132 · 2.5 % · - │ +·························|··············|·············|·············|···············|·············· +| HatsModuleFactory · - · - · 1101122 · 3.7 % · - │ +·························|··············|·············|·············|···············|·············· +| HatsTimeFrameModule · - · - · 1115811 · 3.7 % · - │ +·························|··············|·············|·············|···············|·············· +| PullSplitFactory · 4535815 · 4535827 · 4535824 · 15.1 % · - │ +·························|··············|·············|·············|···············|·············· +| PushSplitFactory · 4483101 · 4483113 · 4483110 · 14.9 % · - │ +·························|··············|·············|·············|···············|·············· +| SplitsCreator · - · - · 1515444 · 5.1 % · - │ +·························|··············|·············|·············|···············|·············· +| SplitsCreatorFactory · - · - · 526836 · 1.8 % · - │ +·························|··············|·············|·············|···············|·············· +| SplitsWarehouse · - · - · 3934655 · 13.1 % · - │ +·------------------------|--------------|-------------|-------------|---------------|-------------· \ No newline at end of file diff --git a/pkgs/contract/hardhat.config.ts b/pkgs/contract/hardhat.config.ts index 81a0f71..52ec2b5 100644 --- a/pkgs/contract/hardhat.config.ts +++ b/pkgs/contract/hardhat.config.ts @@ -49,10 +49,15 @@ const config: HardhatUserConfig = { url: `https://eth-sepolia.g.alchemy.com/v2/${ALCHEMY_API_KEY}`, accounts: PRIVATE_KEY !== undefined ? [PRIVATE_KEY] : [], }, + holesky: { + url: `https://eth-holesky.g.alchemy.com/v2/${ALCHEMY_API_KEY}`, + accounts: PRIVATE_KEY !== undefined ? [PRIVATE_KEY] : [], + }, }, etherscan: { apiKey: { sepolia: ETHERSCAN_API_KEY!, + holesky: ETHERSCAN_API_KEY!, }, }, gasReporter: { diff --git a/pkgs/contract/helpers/deploy/BigBang.ts b/pkgs/contract/helpers/deploy/BigBang.ts index 1557e4b..10ec948 100644 --- a/pkgs/contract/helpers/deploy/BigBang.ts +++ b/pkgs/contract/helpers/deploy/BigBang.ts @@ -9,6 +9,8 @@ export const deployBigBang = async (params: { hatsModuleFacotryAddress: Address; hatsTimeFrameModule_impl: Address; splitsCreatorFactoryAddress: Address; + splitsFactoryV2Address: Address; + fractionTokenAddress: Address; }) => { const BigBang = await viem.deployContract("BigBang", [ params.trustedForwarder, @@ -16,6 +18,8 @@ export const deployBigBang = async (params: { params.hatsModuleFacotryAddress, params.hatsTimeFrameModule_impl, params.splitsCreatorFactoryAddress, + params.splitsFactoryV2Address, + params.fractionTokenAddress, ]); return { BigBang }; diff --git a/pkgs/contract/scripts/deploy/all.ts b/pkgs/contract/scripts/deploy/all.ts new file mode 100644 index 0000000..8dd0824 --- /dev/null +++ b/pkgs/contract/scripts/deploy/all.ts @@ -0,0 +1,46 @@ +import { Address, zeroAddress } from "viem"; +import { deployFractionToken } from "../../helpers/deploy/FractionToken"; +import { deployHatsTimeFrameModule } from "../../helpers/deploy/Hats"; +import { + deploySplitsCreator, + deploySplitsCreatorFactory, +} from "../../helpers/deploy/Splits"; +import { deployBigBang } from "../../helpers/deploy/BigBang"; + +const deployAll = async () => { + const { HatsTimeFrameModule } = await deployHatsTimeFrameModule(); + + const { FractionToken } = await deployFractionToken( + "", + 10000n, + process.env.HATS_ADDRESS as Address, + zeroAddress + ); + + const { SplitsCreator } = await deploySplitsCreator(); + + const { SplitsCreatorFactory } = await deploySplitsCreatorFactory( + SplitsCreator.address + ); + + const { BigBang } = await deployBigBang({ + trustedForwarder: zeroAddress, + hatsContractAddress: process.env.HATS_ADDRESS as Address, + hatsModuleFacotryAddress: process.env + .HATS_MODULE_FACTORY_ADDRESS as Address, + hatsTimeFrameModule_impl: HatsTimeFrameModule.address, + splitsCreatorFactoryAddress: SplitsCreatorFactory.address, + splitsFactoryV2Address: process.env.PULL_SPLITS_FACTORY_ADDRESS as Address, + fractionTokenAddress: FractionToken.address, + }); + + console.log("BigBang deployed at", BigBang.address); + console.log("FractionToken deployed at", FractionToken.address); + console.log("SplitsCreatorFactory deployed at", SplitsCreatorFactory.address); + console.log("SplitsCreator deployed at", SplitsCreator.address); + console.log("HatsTimeFrameModule deployed at", HatsTimeFrameModule.address); + + return; +}; + +deployAll(); diff --git a/pkgs/contract/test/BigBang.ts b/pkgs/contract/test/BigBang.ts index 25de389..f5311b5 100644 --- a/pkgs/contract/test/BigBang.ts +++ b/pkgs/contract/test/BigBang.ts @@ -90,6 +90,8 @@ describe("BigBang", () => { hatsModuleFacotryAddress: HatsModuleFactory.address, hatsTimeFrameModule_impl: HatsTimeFrameModule_IMPL.address, splitsCreatorFactoryAddress: SplitsCreatorFactory.address, + splitsFactoryV2Address: PullSplitsFactory.address, + fractionTokenAddress: FractionToken.address, }); expect(_BigBang.address).to.not.be.undefined; @@ -106,8 +108,6 @@ describe("BigBang", () => { "hatterhatDetails", "hatterhatURI", address1.account?.address!, - PullSplitsFactory.address, - FractionToken.address, ], { account: address1.account } ); diff --git a/pkgs/contract/utils/signTx.ts b/pkgs/contract/utils/signTx.ts deleted file mode 100644 index a1936f3..0000000 --- a/pkgs/contract/utils/signTx.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { - Address, - decodeEventLog, - formatEther, - parseEther, - PublicClient, - WalletClient, - zeroAddress, - createWalletClient, - http -} from "viem"; -import { privateKeyToAccount } from "viem/accounts"; -import { hardhat, mainnet } from "viem/chains"; - -export const signTx = async (secretKey: `0x${string}`, to: `0x${string}`) => { - const account = privateKeyToAccount(secretKey); - - const client = createWalletClient({ - account, - chain: hardhat, - transport: http() - }); - - const hash = await client.sendTransaction({ - account, - to: to, - value: parseEther('0.001') - }); - - return hash; -} \ No newline at end of file