Skip to content

Commit

Permalink
SplitsCreatorFactoryをUpgradeableにし、テストコードを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
aowheel committed Oct 25, 2024
1 parent 9702c43 commit 6110fc3
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pkgs/contract/contracts/bigbang/BigBang.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 8 additions & 3 deletions pkgs/contract/contracts/splitscreator/SplitsCreatorFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion pkgs/contract/gas-report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
·························|··············|·············|·············|···············|··············
| SplitsCreator · - · - · 1487532 · 5 % · - │
·························|··············|·············|·············|···············|··············
| SplitsCreatorFactory · - · - · 526836 · 1.8 % · - │
| SplitsCreatorFactory · - · - · 820420 · 2.7 % · - │
·························|··············|·············|·············|···············|··············
| SplitsWarehouse · - · - · 3934655 · 13.1 % · - │
·------------------------|--------------|-------------|-------------|---------------|-------------·
24 changes: 21 additions & 3 deletions pkgs/contract/helpers/deploy/Splits.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { viem } from "hardhat";
import { ethers, upgrades, viem } from "hardhat";
import { Address } from "viem";

export type SplitsWarehouse = Awaited<
Expand Down Expand Up @@ -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 };
Expand Down
2 changes: 1 addition & 1 deletion pkgs/contract/test/BigBang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion pkgs/contract/test/IntegrationTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions pkgs/contract/test/SplitsCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -266,7 +266,7 @@ describe("CreateSplit", () => {
);

const { SplitsCreatorFactory: _SplitsCreatorFactory } =
await deploySplitsCreatorFactory(SplitsCreator_IMPL.address);
await deploySplitsCreatorFactory(zeroAddress, SplitsCreator_IMPL.address);

SplitsCreatorFactory = _SplitsCreatorFactory;

Expand Down

0 comments on commit 6110fc3

Please sign in to comment.