Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pkgs/cli/src/abi/bigbang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ export const BIGBANG_ABI = [
name: "_hatterHatImageURI",
type: "string",
},
{
internalType: "string",
name: "_memberHatDetails",
type: "string",
},
{
internalType: "string",
name: "_memberHatImageURI",
type: "string",
},
{
internalType: "address",
name: "_trustedForwarder",
Expand Down
4 changes: 4 additions & 0 deletions pkgs/cli/src/modules/bigbang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export const bigbang = async (params: {
topHatImageURI: string;
hatterHatDetails: string;
hatterHatImageURI: string;
memberHatDetails: string;
memberHatImageURI: string;
trustedForwarder: Address;
}) => {
const stop = startLoading();
Expand All @@ -32,6 +34,8 @@ export const bigbang = async (params: {
params.topHatImageURI,
params.hatterHatDetails,
params.hatterHatImageURI,
params.memberHatDetails,
params.memberHatImageURI,
params.trustedForwarder,
],
});
Expand Down
41 changes: 31 additions & 10 deletions pkgs/contract/contracts/bigbang/BigBang.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ contract BigBang is OwnableUpgradeable, UUPSUpgradeable {
address indexed owner,
uint256 indexed topHatId,
uint256 hatterHatId,
uint256 memberHatId,
uint256 operatorHatId,
uint256 creatorHatId,
uint256 minterHatId,
Expand Down Expand Up @@ -84,14 +85,18 @@ contract BigBang is OwnableUpgradeable, UUPSUpgradeable {
* @param _topHatImageURI The image URI of the topHat.
* @param _hatterHatDetails The details of the hatterHat.
* @param _hatterHatImageURI The image URI of the hatterHat.
* @param _memberHatDetails The details of the memberHat.
* @param _memberHatImageURI The image URI of the memberHat.
* @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
string calldata _hatterHatImageURI,
string calldata _memberHatDetails,
string calldata _memberHatImageURI
) external returns (uint256) {
// 1. TopHatのMint
uint256 topHatId = Hats.mintTopHat(
Expand All @@ -111,7 +116,20 @@ contract BigBang is OwnableUpgradeable, UUPSUpgradeable {
_hatterHatImageURI
);

// 3. Create Fixed Roles under TopHat
// 3. Create Member Hat ID
uint256 memberHatId = Hats.createHat(
hatterHatId,
_memberHatDetails,
99,
0x0000000000000000000000000000000000004A75,
0x0000000000000000000000000000000000004A75,
true,
_memberHatImageURI
);

Hats.mintHat(memberHatId, _owner);

// 4. Create Fixed Roles under TopHat
uint256 operatorHatId = Hats.createHat(
topHatId,
_hatterHatDetails,
Expand All @@ -121,6 +139,7 @@ contract BigBang is OwnableUpgradeable, UUPSUpgradeable {
true,
_hatterHatImageURI
);

uint256 creatorHatId = Hats.createHat(
operatorHatId,
_hatterHatDetails,
Expand All @@ -130,6 +149,7 @@ contract BigBang is OwnableUpgradeable, UUPSUpgradeable {
true,
_hatterHatImageURI
);

uint256 minterHatId = Hats.createHat(
operatorHatId,
_hatterHatDetails,
Expand All @@ -140,7 +160,7 @@ contract BigBang is OwnableUpgradeable, UUPSUpgradeable {
_hatterHatImageURI
);

// 4. HatsHatCreatorModuleのデプロイ
// 5. HatsHatCreatorModuleのデプロイ
address hatsHatCreatorModule = HatsModuleFactory.createHatsModule(
HatsHatCreatorModule_IMPL,
topHatId,
Expand All @@ -149,7 +169,7 @@ contract BigBang is OwnableUpgradeable, UUPSUpgradeable {
0
);

// 5. HatsTimeFrameModuleのデプロイ
// 6. HatsTimeFrameModuleのデプロイ
address hatsTimeFrameModule = HatsModuleFactory.createHatsModule(
HatsTimeFrameModule_IMPL,
topHatId,
Expand All @@ -158,7 +178,7 @@ contract BigBang is OwnableUpgradeable, UUPSUpgradeable {
0
);

// 6. HatsHatFractionTokenModuleのデプロイ
// 7. HatsHatFractionTokenModuleのデプロイ
address hatsFractionTokenModule = HatsModuleFactory.createHatsModule(
HatsFractionTokenModule_IMPL,
topHatId,
Expand All @@ -167,7 +187,7 @@ contract BigBang is OwnableUpgradeable, UUPSUpgradeable {
0
);

// 7. HatterHatにHatModuleをMint
// 8. HatterHatにHatModuleをMint
uint256[] memory hatIds = new uint256[](2);
hatIds[0] = hatterHatId;
hatIds[1] = hatterHatId;
Expand All @@ -178,10 +198,10 @@ contract BigBang is OwnableUpgradeable, UUPSUpgradeable {

Hats.batchMintHats(hatIds, modules);

// 8. TopHatIdの権限を_ownerに譲渡
// 9. TopHatIdの権限を_ownerに譲渡
Hats.transferHat(topHatId, address(this), _owner);

// 9. SplitCreatorをFactoryからデプロイ
// 10. SplitCreatorをFactoryからデプロイ
address splitCreator = SplitsCreatorFactory
.createSplitCreatorDeterministic(
topHatId,
Expand All @@ -192,21 +212,22 @@ contract BigBang is OwnableUpgradeable, UUPSUpgradeable {
keccak256(abi.encodePacked(topHatId))
);

// 10. ThanksTokenをFactoryからデプロイ
// 11. ThanksTokenをFactoryからデプロイ
address thanksToken = IThanksTokenFactory(ThanksTokenFactory)
.createThanksTokenDeterministic(
string(abi.encodePacked("ThanksToken ", _topHatDetails)),
string(abi.encodePacked("THX", topHatId)),
_owner,
1e18, // デフォルト係数(1.0)
keccak256(abi.encodePacked(topHatId, "ThanksToken"))
keccak256(abi.encodePacked(topHatId, "0"))
);

emit Executed(
msg.sender,
_owner,
topHatId,
hatterHatId,
memberHatId,
operatorHatId,
creatorHatId,
minterHatId,
Expand Down
31 changes: 24 additions & 7 deletions pkgs/contract/contracts/bigbang/mock/BigBang_Mock_v2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ contract BigBang_Mock_v2 is OwnableUpgradeable, UUPSUpgradeable {
address indexed owner,
uint256 indexed topHatId,
uint256 hatterHatId,
uint256 memberHatId,
uint256 operatorHatId,
uint256 creatorHatId,
uint256 minterHatId,
Expand Down Expand Up @@ -83,7 +84,9 @@ contract BigBang_Mock_v2 is OwnableUpgradeable, UUPSUpgradeable {
string calldata _topHatDetails,
string calldata _topHatImageURI,
string calldata _hatterHatDetails,
string calldata _hatterHatImageURI
string calldata _hatterHatImageURI,
string calldata _memberHatDetails,
string calldata _memberHatImageURI
) external returns (uint256) {
// 1. TopHatのMint

Expand All @@ -105,7 +108,20 @@ contract BigBang_Mock_v2 is OwnableUpgradeable, UUPSUpgradeable {
_hatterHatImageURI
);

// 3. Create Fixed Roles under TopHat
// 3. Create Member Hat ID
uint256 memberHatId = Hats.createHat(
hatterHatId,
_memberHatDetails,
99,
0x0000000000000000000000000000000000004A75,
0x0000000000000000000000000000000000004A75,
true,
_memberHatImageURI
);

Hats.mintHat(memberHatId, _owner);

// 4. Create Fixed Roles under TopHat
uint256 operatorHatId = Hats.createHat(
topHatId,
_hatterHatDetails,
Expand Down Expand Up @@ -134,7 +150,7 @@ contract BigBang_Mock_v2 is OwnableUpgradeable, UUPSUpgradeable {
_hatterHatImageURI
);

// 4. HatsHatCreatorModuleのデプロイ
// 5. HatsHatCreatorModuleのデプロイ
address hatsHatCreatorModule = HatsModuleFactory.createHatsModule(
HatsHatCreatorModule_IMPL,
topHatId,
Expand All @@ -143,7 +159,7 @@ contract BigBang_Mock_v2 is OwnableUpgradeable, UUPSUpgradeable {
0
);

// 5. HatsTimeFrameModuleのデプロイ
// 6. HatsTimeFrameModuleのデプロイ
address hatsTimeFrameModule = HatsModuleFactory.createHatsModule(
HatsTimeFrameModule_IMPL,
topHatId,
Expand All @@ -152,7 +168,7 @@ contract BigBang_Mock_v2 is OwnableUpgradeable, UUPSUpgradeable {
0
);

// 6. HatterHatにHatModuleをMint
// 7. HatterHatにHatModuleをMint
uint256[] memory hatIds = new uint256[](2);
hatIds[0] = hatterHatId;
hatIds[1] = hatterHatId;
Expand All @@ -163,10 +179,10 @@ contract BigBang_Mock_v2 is OwnableUpgradeable, UUPSUpgradeable {

Hats.batchMintHats(hatIds, modules);

// 7. TopHatIdの権限を_ownerに譲渡
// 8. TopHatIdの権限を_ownerに譲渡
Hats.transferHat(topHatId, address(this), _owner);

// 8. SplitCreatorをFactoryからデプロイ
// 9. SplitCreatorをFactoryからデプロイ
address splitCreator = SplitsCreatorFactory
.createSplitCreatorDeterministic(
topHatId,
Expand All @@ -182,6 +198,7 @@ contract BigBang_Mock_v2 is OwnableUpgradeable, UUPSUpgradeable {
_owner,
topHatId,
hatterHatId,
memberHatId,
operatorHatId,
creatorHatId,
minterHatId,
Expand Down
6 changes: 6 additions & 0 deletions pkgs/contract/tasks/BigBang/bigbang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ interface BigBangTaskArgs {
tophatimageuri: string;
hatterhatdetails: string;
hatterhatimageuri: string;
memberhatdetails: string;
memberhatimageuri: string;
}

/**
Expand All @@ -19,6 +21,8 @@ task("bigbang", "bigbang")
.addParam("tophatimageuri", "The image URI of the topHat.")
.addParam("hatterhatdetails", "The details of the hatterHat.")
.addParam("hatterhatimageuri", "The image URI of the hatterHat.")
.addParam("memberhatdetails", "The details of the memberHat.")
.addParam("memberhatimageuri", "The image URI of the memberHat.")
.setAction(
async (taskArgs: BigBangTaskArgs, hre: HardhatRuntimeEnvironment) => {
console.log(
Expand Down Expand Up @@ -46,6 +50,8 @@ task("bigbang", "bigbang")
taskArgs.tophatimageuri,
taskArgs.hatterhatdetails,
taskArgs.hatterhatimageuri,
taskArgs.memberhatdetails,
taskArgs.memberhatimageuri,
]);

console.log(`tx: ${tx}`);
Expand Down
9 changes: 9 additions & 0 deletions pkgs/contract/test/BigBang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ describe("BigBang", () => {
"tophatURI",
"hatterhatDetails",
"hatterhatURI",
"memberhatDetails",
"memberhatURI",
],
{ account: address1.account },
);
Expand All @@ -200,6 +202,11 @@ describe("BigBang", () => {
expect(decodedLog.args.owner.toLowerCase()).to.be.equal(
address1.account?.address!,
);
expect(decodedLog.args.memberHatId).to.be.not.equal(null);
Hats.read.isWearerOfHat([
decodedLog.args.memberHatId,
BigInt(address1.account?.address!),
]);
console.log(decodedLog.args);
}
} catch (error) {}
Expand Down Expand Up @@ -410,6 +417,8 @@ describe("BigBang", () => {
// "tophatURI",
// "hatterhatDetails",
// "hatterhatURI",
// "memberhatDetails",
// "memberhatURI",
// ],
// { account: address1.account },
// );
Expand Down
2 changes: 2 additions & 0 deletions pkgs/contract/test/IntegrationTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ describe("IntegrationTest", () => {
"tophatURI",
"hatterhatDetails",
"hatterhatURI",
"memberhatDetails",
"memberhatURI",
],
{ account: deployer.account },
);
Expand Down