diff --git a/pkgs/contract/contracts/bigbang/BigBang.sol b/pkgs/contract/contracts/bigbang/BigBang.sol index 84c1caa..5387270 100644 --- a/pkgs/contract/contracts/bigbang/BigBang.sol +++ b/pkgs/contract/contracts/bigbang/BigBang.sol @@ -28,7 +28,7 @@ contract BigBang is ERC2771ContextUpgradeable { address splitCreator ); - /* + /** * @dev Constructor to initialize the trusted forwarder. * @param _trustedForwarder Address of the trusted forwarder contract. * @param _hatsAddress Address of the hats protocol V1 contract. diff --git a/pkgs/contract/contracts/splitscreator/SplitsCreatorFactory.sol b/pkgs/contract/contracts/splitscreator/SplitsCreatorFactory.sol index 8e26dc4..005c4d3 100644 --- a/pkgs/contract/contracts/splitscreator/SplitsCreatorFactory.sol +++ b/pkgs/contract/contracts/splitscreator/SplitsCreatorFactory.sol @@ -5,10 +5,11 @@ pragma solidity ^0.8.24; import { LibClone } from "solady/src/utils/LibClone.sol"; import { SplitsCreator } from "./SplitsCreator.sol"; import { ISplitsCreator } from "./ISplitsCreator.sol"; +import "./../ERC2771ContextUpgradeable.sol"; import "hardhat/console.sol"; -contract SplitsCreatorFactory { +contract SplitsCreatorFactory is ERC2771ContextUpgradeable { event SplitCreatorCreated( address indexed creator, address indexed splitCreator, @@ -19,9 +20,13 @@ contract SplitsCreatorFactory { address fractionToken ); - address public immutable SPLITS_CREATOR_IMPLEMENTATION; + address public SPLITS_CREATOR_IMPLEMENTATION; - constructor(address _splitsCreatorImplementation) { + function initialize ( + address _trustedForwarderAddress, + address _splitsCreatorImplementation + ) initializer public { + __ERC2771Context_init(_trustedForwarderAddress); SPLITS_CREATOR_IMPLEMENTATION = _splitsCreatorImplementation; } diff --git a/pkgs/contract/gas-report.txt b/pkgs/contract/gas-report.txt index be3d880..c86ee39 100644 --- a/pkgs/contract/gas-report.txt +++ b/pkgs/contract/gas-report.txt @@ -25,7 +25,7 @@ ·························|··············|·············|·············|···············|·············· | SplitsCreator · - · - · 1487532 · 5 % · - │ ·························|··············|·············|·············|···············|·············· -| SplitsCreatorFactory · - · - · 526836 · 1.8 % · - │ +| SplitsCreatorFactory · - · - · 820420 · 2.7 % · - │ ·························|··············|·············|·············|···············|·············· | SplitsWarehouse · - · - · 3934655 · 13.1 % · - │ ·------------------------|--------------|-------------|-------------|---------------|-------------· \ No newline at end of file diff --git a/pkgs/contract/helpers/deploy/Splits.ts b/pkgs/contract/helpers/deploy/Splits.ts index 586ddbc..43c564e 100644 --- a/pkgs/contract/helpers/deploy/Splits.ts +++ b/pkgs/contract/helpers/deploy/Splits.ts @@ -1,4 +1,4 @@ -import { viem } from "hardhat"; +import { ethers, upgrades, viem } from "hardhat"; import { Address } from "viem"; export type SplitsWarehouse = Awaited< @@ -43,11 +43,29 @@ export const deploySplitsProtocol = async () => { }; export const deploySplitsCreatorFactory = async ( + forwarderAddress: Address, splitsCreatorImpl: Address ) => { - const SplitsCreatorFactory = await viem.deployContract( + const splitsCreatorFactory = await ethers.getContractFactory("SplitsCreatorFactory"); + + const _SplitsCreatorFactory = await upgrades.deployProxy( + splitsCreatorFactory, + [ + forwarderAddress, + splitsCreatorImpl + ], + { + initializer: "initialize", + } + ); + + await _SplitsCreatorFactory.waitForDeployment(); + const address = await _SplitsCreatorFactory.getAddress(); + + // create a new instance of the contract + const SplitsCreatorFactory = await viem.getContractAt( "SplitsCreatorFactory", - [splitsCreatorImpl] + address as Address ); return { SplitsCreatorFactory }; diff --git a/pkgs/contract/test/BigBang.ts b/pkgs/contract/test/BigBang.ts index 1c87685..70bc677 100644 --- a/pkgs/contract/test/BigBang.ts +++ b/pkgs/contract/test/BigBang.ts @@ -75,7 +75,7 @@ describe("BigBang", () => { SplitsCreator_IMPL = _SplitsCreator; const { SplitsCreatorFactory: _SplitsCreatorFactory } = - await deploySplitsCreatorFactory(SplitsCreator_IMPL.address); + await deploySplitsCreatorFactory(zeroAddress, SplitsCreator_IMPL.address); SplitsCreatorFactory = _SplitsCreatorFactory; diff --git a/pkgs/contract/test/IntegrationTest.ts b/pkgs/contract/test/IntegrationTest.ts index b758274..8ac61bf 100644 --- a/pkgs/contract/test/IntegrationTest.ts +++ b/pkgs/contract/test/IntegrationTest.ts @@ -98,7 +98,7 @@ describe("IntegrationTest", () => { SplitsCreator_IMPL = _SplitsCreator; const { SplitsCreatorFactory: _SplitsCreatorFactory } = - await deploySplitsCreatorFactory(SplitsCreator_IMPL.address); + await deploySplitsCreatorFactory(zeroAddress, SplitsCreator_IMPL.address); SplitsCreatorFactory = _SplitsCreatorFactory; diff --git a/pkgs/contract/test/SplitsCreator.ts b/pkgs/contract/test/SplitsCreator.ts index 99141ac..a57b014 100644 --- a/pkgs/contract/test/SplitsCreator.ts +++ b/pkgs/contract/test/SplitsCreator.ts @@ -120,7 +120,7 @@ describe("SplitsCreator Factory", () => { it("Should deploy SplitsCreatorFactory", async () => { const { SplitsCreatorFactory: _SplitsCreatorFactory } = - await deploySplitsCreatorFactory(SplitsCreator_IMPL.address); + await deploySplitsCreatorFactory(zeroAddress, SplitsCreator_IMPL.address); SplitsCreatorFactory = _SplitsCreatorFactory; @@ -266,7 +266,7 @@ describe("CreateSplit", () => { ); const { SplitsCreatorFactory: _SplitsCreatorFactory } = - await deploySplitsCreatorFactory(SplitsCreator_IMPL.address); + await deploySplitsCreatorFactory(zeroAddress, SplitsCreator_IMPL.address); SplitsCreatorFactory = _SplitsCreatorFactory;