-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9702c43
commit c3af7fb
Showing
8 changed files
with
380 additions
and
32 deletions.
There are no files selected for viewing
137 changes: 137 additions & 0 deletions
137
pkgs/contract/contracts/bigbang/mock/BigBang_Mock_v2.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.24; | ||
|
||
import { IHats } from "../../hats/src/Interfaces/IHats.sol"; | ||
import { IHatsModuleFactory } from "./../IHatsModuleFactory.sol"; | ||
import { ISplitsCreatorFactory } from "../../splitscreator/ISplitsCreatorFactory.sol"; | ||
import { HatsTimeFrameModule } from "../../timeframe/HatsTimeFrameModule.sol"; | ||
import "./../../ERC2771ContextUpgradeable.sol"; | ||
|
||
/** | ||
* Upgradableになっている確認するための検証用BigBangコントラクト | ||
*/ | ||
contract BigBang_Mock_v2 is ERC2771ContextUpgradeable { | ||
IHats public Hats; | ||
|
||
IHatsModuleFactory public HatsModuleFactory; | ||
|
||
ISplitsCreatorFactory public SplitsCreatorFactory; | ||
|
||
address public HatsTimeFrameModule_IMPL; | ||
|
||
address public splitFactoryV2; | ||
|
||
address public fractionToken; | ||
|
||
event Executed( | ||
address indexed owner, | ||
uint256 indexed topHatId, | ||
uint256 indexed hatterHatId, | ||
address hatsTimeFrameModule, | ||
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. | ||
* @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. | ||
*/ | ||
function initialize ( | ||
address _trustedForwarder, | ||
address _hatsAddress, | ||
address _hatsModuleFactory, | ||
address _hatsTimeFrameModule_IMPL, | ||
address _splitsCreatorFactory, | ||
address _splitFactoryV2, | ||
address _fractionToken | ||
) initializer public { | ||
__ERC2771Context_init(address(_trustedForwarder)); | ||
Hats = IHats(_hatsAddress); | ||
HatsModuleFactory = IHatsModuleFactory(_hatsModuleFactory); | ||
HatsTimeFrameModule_IMPL = _hatsTimeFrameModule_IMPL; | ||
SplitsCreatorFactory = ISplitsCreatorFactory(_splitsCreatorFactory); | ||
splitFactoryV2 = _splitFactoryV2; | ||
fractionToken = _fractionToken; | ||
} | ||
|
||
/** | ||
* @dev | ||
* @param _owner The address of the user who will own the topHat. | ||
* @param _topHatDetails The details of the topHat. | ||
* @param _topHatImageURI The image URI of the topHat. | ||
* @param _hatterHatDetails The details of the hatterHat. | ||
* @param _hatterHatImageURI The image URI of the hatterHat. | ||
* @param _trustedForwarder The address of the trusted forwarder. | ||
* @return topHatId The ID used for navigating to the ProjectTop page after project creation. | ||
*/ | ||
function bigbang( | ||
address _owner, | ||
string calldata _topHatDetails, | ||
string calldata _topHatImageURI, | ||
string calldata _hatterHatDetails, | ||
string calldata _hatterHatImageURI, | ||
address _trustedForwarder | ||
) external returns (uint256) { | ||
// 1. TopHatのMint | ||
|
||
uint256 topHatId = Hats.mintTopHat( | ||
address(this), // target: Tophat's wearer address. topHatのみがHatterHatを作成できるためTophatを指定する | ||
_topHatDetails, | ||
_topHatImageURI | ||
); | ||
|
||
// 2. HatterHatの作成 | ||
|
||
uint256 hatterHatId = Hats.createHat( | ||
topHatId, // _admin: The id of the Hat that will control who wears the newly created hat | ||
_hatterHatDetails, | ||
1, | ||
0x0000000000000000000000000000000000004A75, | ||
0x0000000000000000000000000000000000004A75, | ||
true, | ||
_hatterHatImageURI | ||
); | ||
|
||
// 4. HatsTimeFrameModuleのデプロイ | ||
address hatsTimeFrameModule = HatsModuleFactory.createHatsModule( | ||
HatsTimeFrameModule_IMPL, | ||
topHatId, | ||
"", | ||
"", | ||
0 | ||
); | ||
|
||
// 5. HatsTimeFrameModuleにHatterHatをMint | ||
Hats.mintHat(hatterHatId, hatsTimeFrameModule); | ||
|
||
// 6. TopHatIdの権限を_ownerに譲渡 | ||
Hats.transferHat(topHatId, address(this), _owner); | ||
|
||
// 7. SplitCreatorをFactoryからデプロイ | ||
address splitCreator = SplitsCreatorFactory | ||
.createSplitCreatorDeterministic( | ||
topHatId, | ||
_trustedForwarder, | ||
splitFactoryV2, | ||
hatsTimeFrameModule, | ||
fractionToken, | ||
keccak256(abi.encodePacked(topHatId)) | ||
); | ||
|
||
emit Executed(_owner, topHatId, hatterHatId, hatsTimeFrameModule, splitCreator); | ||
|
||
return topHatId; | ||
} | ||
|
||
/** | ||
* 検証用に追加した関数 | ||
*/ | ||
function testUpgradeFunction() external pure returns (string memory) { | ||
return "testUpgradeFunction"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
pkgs/contract/contracts/fractiontoken/mock/FractionToken_Mock_v2.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.24; | ||
|
||
import "./../FractionToken.sol"; | ||
|
||
contract FractionToken_Mock_v2 is FractionToken { | ||
|
||
function initialize2( | ||
string memory _uri, | ||
uint256 _tokenSupply, | ||
address _hatsAddress, | ||
address _trustedForwarderAddress | ||
) initializer public { | ||
__ERC1155_init(_uri); | ||
__ERC2771Context_init(address(_trustedForwarderAddress)); | ||
hatsContract = IHats(_hatsAddress); | ||
TOKEN_SUPPLY = _tokenSupply; | ||
} | ||
|
||
/** | ||
* 検証用に追加した関数 | ||
*/ | ||
function testUpgradeFunction() external pure returns (string memory) { | ||
return "testUpgradeFunction"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,33 @@ | ||
·------------------------|----------------------------|-------------|-----------------------------· | ||
| 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 % · - │ | ||
·------------------------|--------------|-------------|-------------|---------------|-------------· | ||
·-------------------------|----------------------------|-------------|-----------------------------· | ||
| 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 · - · - · 2893315 · 9.6 % · - │ | ||
··························|··············|·············|·············|···············|·············· | ||
| FractionToken_Mock_v2 · - · - · 3037174 · 10.1 % · - │ | ||
··························|··············|·············|·············|···············|·············· | ||
| Hats · - · - · 7032431 · 23.4 % · - │ | ||
··························|··············|·············|·············|···············|·············· | ||
| HatsModule · - · - · 754132 · 2.5 % · - │ | ||
··························|··············|·············|·············|···············|·············· | ||
| HatsModuleFactory · 1101110 · 1101122 · 1101118 · 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 % · - │ | ||
·-------------------------|--------------|-------------|-------------|---------------|-------------· |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { ethers, upgrades, viem } from "hardhat"; | ||
import { Address } from "viem"; | ||
|
||
/** | ||
* BigBang Contractをアップグレードするメソッド | ||
* @param contractAddress アップグレード対象のコントラクトアドレス | ||
* @param contractName アップグレード後のコントラクト名 | ||
* @param params アップグレード時に必要なパラメータ | ||
* @returns | ||
*/ | ||
export const upgradeBigBang = async ( | ||
contractAddress: string, | ||
contractName: string, | ||
params?: any[] | ||
) => { | ||
// 新しいコントラクトのファクトリーを取得 | ||
const BigBang_Mock_v2 = await ethers.getContractFactory(contractName); | ||
// アップグレードを実行 | ||
const _BigBang = (await upgrades.upgradeProxy( | ||
contractAddress, | ||
BigBang_Mock_v2, | ||
params && { | ||
call: { | ||
fn: "initialize", | ||
args: params, | ||
}, | ||
} | ||
)) as any; | ||
|
||
await _BigBang.deployed(); | ||
const address = await _BigBang.getAddress(); | ||
|
||
console.log("upgraded address:", address); | ||
|
||
// create a new instance of the contract | ||
const newBigBang = await viem.getContractAt(contractName, address as Address); | ||
|
||
return newBigBang; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { ethers, upgrades, viem } from "hardhat"; | ||
import { Address } from "viem"; | ||
|
||
/** | ||
* FractionToken Contractをアップグレードするメソッド | ||
* @param contractAddress アップグレード対象のコントラクトアドレス | ||
* @param contractName アップグレード後のコントラクト名 | ||
* @param params アップグレード時に必要なパラメータ | ||
* @returns | ||
*/ | ||
export const upgradeFractionToken = async ( | ||
contractAddress: string, | ||
contractName: string, | ||
params?: any[] | ||
) => { | ||
// 新しいコントラクトのファクトリーを取得 | ||
const FractionToken_Mock_v2 = await ethers.getContractFactory(contractName); | ||
|
||
// アップグレードを実行 | ||
const _FractionToken = await upgrades.upgradeProxy( | ||
contractAddress, | ||
FractionToken_Mock_v2 | ||
); | ||
|
||
const address = _FractionToken.target; | ||
|
||
// create a new instance of the contract | ||
const newFractionToken = await viem.getContractAt( | ||
contractName, | ||
address as Address | ||
); | ||
|
||
return newFractionToken; | ||
}; |
Oops, something went wrong.