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
4 changes: 1 addition & 3 deletions pkgs/contract/contracts/bigbang/BigBang.sol
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,13 @@ contract BigBang is OwnableUpgradeable, UUPSUpgradeable {
string calldata _hatterHatImageURI
) 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,
Expand Down Expand Up @@ -165,7 +163,7 @@ contract BigBang is OwnableUpgradeable, UUPSUpgradeable {
HatsFractionTokenModule_IMPL,
topHatId,
"",
abi.encode(_owner, "", 10_000),
abi.encode("", 10_000),
0
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity ^0.8.24;

import {HatsModule} from "../../hats/module/HatsModule.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {ERC1155} from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import {ERC1155Supply} from "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol";
import {IHatsFractionTokenModule} from "./IHatsFractionTokenModule.sol";
Expand All @@ -22,7 +21,6 @@ import {IHatsFractionTokenModule} from "./IHatsFractionTokenModule.sol";
*/
contract HatsFractionTokenModule is
HatsModule,
Ownable,
ERC1155,
ERC1155Supply,
IHatsFractionTokenModule
Expand All @@ -45,19 +43,15 @@ contract HatsFractionTokenModule is
/**
* @notice Initialize the contract with required parameters
* @param _version The version of the contract for upgrade compatibility
* @param _tmpOwner The temporary owner of the contract (will be transferred during setup)
*/
constructor(
string memory _version,
address _tmpOwner
) HatsModule(_version) Ownable(_tmpOwner) ERC1155("") {}
constructor(string memory _version) HatsModule(_version) ERC1155("") {}

// ============ Initialization ============

/**
* @notice Initializes the module with owner, URI, and token supply configuration
* @notice Initializes the module with URI, and token supply configuration
* @dev This function is called once during module deployment via the factory
* @param _initData ABI-encoded data containing (address _owner, string _uri, uint256 _defaultTokenSupply)
* @param _initData ABI-encoded data containing (string _uri, uint256 _defaultTokenSupply)
*
* Requirements:
* - The hatId must be a top hat (ensures domain isolation)
Expand All @@ -67,11 +61,12 @@ contract HatsFractionTokenModule is
* - Sets the base URI for token metadata
* - Sets the token supply for initial minting
* - Extracts and stores the domain from the top hat
* - Transfers ownership to the specified address
*/
function _setUp(bytes calldata _initData) internal override {
(address _owner, string memory _uri, uint256 _defaultTokenSupply) = abi
.decode(_initData, (address, string, uint256));
(string memory _uri, uint256 _defaultTokenSupply) = abi.decode(
_initData,
(string, uint256)
);

_setURI(_uri);

Expand All @@ -88,9 +83,6 @@ contract HatsFractionTokenModule is

// Extract domain from the top hat for validation in future operations
DOMAIN = HATS().getTopHatDomain(hatId());

// Transfer ownership to the specified address
_transferOwnership(_owner);
}

// ============ Minting Functions ============
Expand Down
6 changes: 3 additions & 3 deletions pkgs/contract/contracts/thankstoken/ThanksToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ contract ThanksToken is
address _hatsAddress,
address _fractionTokenAddress,
address _hatsTimeFrameModuleAddress,
uint256 defaultCoefficient
uint256 _initialDefaultCoefficient
) public initializer {
__ERC20_init(_name, _symbol);
__Ownable_init(_initialOwner);
__UUPSUpgradeable_init();
hatsContract = IHats(_hatsAddress);
fractionToken = IHatsFractionTokenModule(_fractionTokenAddress);
hatsTimeFrameModule = IHatsTimeFrameModule(_hatsTimeFrameModuleAddress);
_defaultCoefficient = defaultCoefficient > 0
? defaultCoefficient
_defaultCoefficient = _initialDefaultCoefficient > 0
? _initialDefaultCoefficient
: 1e18;
}

Expand Down
57 changes: 0 additions & 57 deletions pkgs/contract/helpers/deploy/FractionToken.ts

This file was deleted.

6 changes: 1 addition & 5 deletions pkgs/contract/helpers/deploy/Hats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,14 @@ export const deployHatsHatCreatorModule = async (
};

export const deployHatsFractionTokenModule = async (
tmpOwner: Address,
version = "0.0.0",
create2DeployerAddress?: string,
) => {
const HatsFractionTokenModuleFactory = await ethers.getContractFactory(
"HatsFractionTokenModule",
);
const HatsFractionTokenModuleTx =
await HatsFractionTokenModuleFactory.getDeployTransaction(
version,
tmpOwner,
);
await HatsFractionTokenModuleFactory.getDeployTransaction(version);
const HatsFractionTokenModuleAddress = await deployContract_Create2(
baseSalt,
HatsFractionTokenModuleTx.data || "0x",
Expand Down
6 changes: 1 addition & 5 deletions pkgs/contract/test/BigBang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,7 @@ describe("BigBang", () => {
HatsHatCreatorModule_IMPL = _HatsHatCreatorModule;

const { HatsFractionTokenModule: _HatsFractionTokenModule_IMPL } =
await deployHatsFractionTokenModule(
await address1.getAddresses().then((addresses) => addresses[0]),
"0.0.0",
Create2Deployer.address,
);
await deployHatsFractionTokenModule("0.0.0", Create2Deployer.address);
HatsFractionTokenModule_IMPL = _HatsFractionTokenModule_IMPL;

const {
Expand Down
15 changes: 3 additions & 12 deletions pkgs/contract/test/HatsFractionTokenModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,7 @@ describe("HatsFractionTokenModule", () => {
);

const { HatsFractionTokenModule: _HatsFractionTokenModule_IMPL } =
await deployHatsFractionTokenModule(
address1Validated,
"0.0.0",
Create2Deployer.address,
);
await deployHatsFractionTokenModule("0.0.0", Create2Deployer.address);
HatsFractionTokenModule_IMPL = _HatsFractionTokenModule_IMPL;

publicClient = await viem.getPublicClient();
Expand All @@ -90,8 +86,8 @@ describe("HatsFractionTokenModule", () => {
it("should deploy fraction token module", async () => {
// オーナーアドレス、トークンURI、トークン供給量をエンコード
const initData = encodeAbiParameters(
[{ type: "address" }, { type: "string" }, { type: "uint256" }],
[address1Validated, "https://example.com/fraction-token", 10000n],
[{ type: "string" }, { type: "uint256" }],
["https://example.com/fraction-token", 10000n],
);

// アシストクレジットのモジュールをデプロイ
Expand Down Expand Up @@ -197,11 +193,6 @@ describe("HatsFractionTokenModule", () => {
});

it("should have valid owner, token URI, domain, and token supply", async () => {
// オーナーアドレスはエンコードした初期データと一致
expect(
(await HatsFractionTokenModule.read.owner()).toLowerCase(),
).to.equal(address1Validated.toLowerCase());

// トークンURIはエンコードした初期データと一致
expect(await HatsFractionTokenModule.read.uri([0n])).to.equal(
"https://example.com/fraction-token",
Expand Down
6 changes: 1 addition & 5 deletions pkgs/contract/test/IntegrationTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,7 @@ describe("IntegrationTest", () => {
HatsHatCreatorModule_IMPL = _HatsHatCreatorModule;

const { HatsFractionTokenModule: _HatsFractionTokenModule_IMPL } =
await deployHatsFractionTokenModule(
await deployer.getAddresses().then((addresses) => addresses[0]),
"0.0.0",
Create2Deployer.address,
);
await deployHatsFractionTokenModule("0.0.0", Create2Deployer.address);
HatsFractionTokenModule_IMPL = _HatsFractionTokenModule_IMPL;

const {
Expand Down
32 changes: 8 additions & 24 deletions pkgs/contract/test/SplitsCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,12 @@ describe("SplitsCreator Factory", () => {
);

const { HatsFractionTokenModule: _HatsFractionTokenModule_IMPL } =
await deployHatsFractionTokenModule(
address1.account?.address!,
"0.0.0",
Create2Deployer.address,
);
await deployHatsFractionTokenModule("0.0.0", Create2Deployer.address);
HatsFractionTokenModule_IMPL = _HatsFractionTokenModule_IMPL;

const timeFrameInitData = encodeAbiParameters(
[{ type: "address" }],
[address1.account?.address!],
[{ type: "uint256" }],
[timeFrameTobanId],
);

await HatsModuleFactory.write.createHatsModule([
Expand All @@ -190,12 +186,8 @@ describe("SplitsCreator Factory", () => {

// Deploy HatsFractionTokenModule
const fractionTokenInitData = encodeAbiParameters(
[{ type: "address" }, { type: "string" }, { type: "uint256" }],
[
address1.account?.address!,
"https://example.com/fraction-token",
10000n,
],
[{ type: "string" }, { type: "uint256" }],
["https://example.com/fraction-token", 10000n],
);

await HatsModuleFactory.write.createHatsModule([
Expand Down Expand Up @@ -428,11 +420,7 @@ describe("CreateSplit", () => {
);

const { HatsFractionTokenModule: _HatsFractionTokenModule_IMPL } =
await deployHatsFractionTokenModule(
address1.account?.address!,
"0.0.0",
Create2Deployer.address,
);
await deployHatsFractionTokenModule("0.0.0", Create2Deployer.address);
HatsFractionTokenModule_IMPL = _HatsFractionTokenModule_IMPL;

const timeFrameInitData = encodeAbiParameters(
Expand Down Expand Up @@ -463,12 +451,8 @@ describe("CreateSplit", () => {

// Deploy HatsFractionTokenModule
const fractionTokenInitData = encodeAbiParameters(
[{ type: "address" }, { type: "string" }, { type: "uint256" }],
[
address1.account?.address!,
"https://example.com/fraction-token",
10000n,
],
[{ type: "string" }, { type: "uint256" }],
["https://example.com/fraction-token", 10000n],
);

await HatsModuleFactory.write.createHatsModule([
Expand Down
Loading
Loading