Skip to content

Commit 2c35e66

Browse files
authored
Merge pull request #384 from hackdays-io/feature/p2ptokenv2
Feature/p2ptokenv2
2 parents 466dd57 + 4566d36 commit 2c35e66

File tree

10 files changed

+320
-860
lines changed

10 files changed

+320
-860
lines changed

pkgs/contract/contracts/bigbang/BigBang.sol

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,13 @@ contract BigBang is OwnableUpgradeable, UUPSUpgradeable {
9494
string calldata _hatterHatImageURI
9595
) external returns (uint256) {
9696
// 1. TopHatのMint
97-
9897
uint256 topHatId = Hats.mintTopHat(
9998
address(this), // target: Tophat's wearer address. topHatのみがHatterHatを作成できるためTophatを指定する
10099
_topHatDetails,
101100
_topHatImageURI
102101
);
103102

104103
// 2. HatterHatの作成
105-
106104
uint256 hatterHatId = Hats.createHat(
107105
topHatId, // _admin: The id of the Hat that will control who wears the newly created hat
108106
_hatterHatDetails,
@@ -165,7 +163,7 @@ contract BigBang is OwnableUpgradeable, UUPSUpgradeable {
165163
HatsFractionTokenModule_IMPL,
166164
topHatId,
167165
"",
168-
abi.encode(_owner, "", 10_000),
166+
abi.encode("", 10_000),
169167
0
170168
);
171169

pkgs/contract/contracts/hatsmodules/fractiontoken/HatsFractionTokenModule.sol

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
pragma solidity ^0.8.24;
33

44
import {HatsModule} from "../../hats/module/HatsModule.sol";
5-
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
65
import {ERC1155} from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
76
import {ERC1155Supply} from "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol";
87
import {IHatsFractionTokenModule} from "./IHatsFractionTokenModule.sol";
@@ -22,7 +21,6 @@ import {IHatsFractionTokenModule} from "./IHatsFractionTokenModule.sol";
2221
*/
2322
contract HatsFractionTokenModule is
2423
HatsModule,
25-
Ownable,
2624
ERC1155,
2725
ERC1155Supply,
2826
IHatsFractionTokenModule
@@ -45,19 +43,15 @@ contract HatsFractionTokenModule is
4543
/**
4644
* @notice Initialize the contract with required parameters
4745
* @param _version The version of the contract for upgrade compatibility
48-
* @param _tmpOwner The temporary owner of the contract (will be transferred during setup)
4946
*/
50-
constructor(
51-
string memory _version,
52-
address _tmpOwner
53-
) HatsModule(_version) Ownable(_tmpOwner) ERC1155("") {}
47+
constructor(string memory _version) HatsModule(_version) ERC1155("") {}
5448

5549
// ============ Initialization ============
5650

5751
/**
58-
* @notice Initializes the module with owner, URI, and token supply configuration
52+
* @notice Initializes the module with URI, and token supply configuration
5953
* @dev This function is called once during module deployment via the factory
60-
* @param _initData ABI-encoded data containing (address _owner, string _uri, uint256 _defaultTokenSupply)
54+
* @param _initData ABI-encoded data containing (string _uri, uint256 _defaultTokenSupply)
6155
*
6256
* Requirements:
6357
* - The hatId must be a top hat (ensures domain isolation)
@@ -67,11 +61,12 @@ contract HatsFractionTokenModule is
6761
* - Sets the base URI for token metadata
6862
* - Sets the token supply for initial minting
6963
* - Extracts and stores the domain from the top hat
70-
* - Transfers ownership to the specified address
7164
*/
7265
function _setUp(bytes calldata _initData) internal override {
73-
(address _owner, string memory _uri, uint256 _defaultTokenSupply) = abi
74-
.decode(_initData, (address, string, uint256));
66+
(string memory _uri, uint256 _defaultTokenSupply) = abi.decode(
67+
_initData,
68+
(string, uint256)
69+
);
7570

7671
_setURI(_uri);
7772

@@ -88,9 +83,6 @@ contract HatsFractionTokenModule is
8883

8984
// Extract domain from the top hat for validation in future operations
9085
DOMAIN = HATS().getTopHatDomain(hatId());
91-
92-
// Transfer ownership to the specified address
93-
_transferOwnership(_owner);
9486
}
9587

9688
// ============ Minting Functions ============

pkgs/contract/contracts/thankstoken/ThanksToken.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ contract ThanksToken is
3232
address _hatsAddress,
3333
address _fractionTokenAddress,
3434
address _hatsTimeFrameModuleAddress,
35-
uint256 defaultCoefficient
35+
uint256 _initialDefaultCoefficient
3636
) public initializer {
3737
__ERC20_init(_name, _symbol);
3838
__Ownable_init(_initialOwner);
3939
__UUPSUpgradeable_init();
4040
hatsContract = IHats(_hatsAddress);
4141
fractionToken = IHatsFractionTokenModule(_fractionTokenAddress);
4242
hatsTimeFrameModule = IHatsTimeFrameModule(_hatsTimeFrameModuleAddress);
43-
_defaultCoefficient = defaultCoefficient > 0
44-
? defaultCoefficient
43+
_defaultCoefficient = _initialDefaultCoefficient > 0
44+
? _initialDefaultCoefficient
4545
: 1e18;
4646
}
4747

pkgs/contract/helpers/deploy/FractionToken.ts

Lines changed: 0 additions & 57 deletions
This file was deleted.

pkgs/contract/helpers/deploy/Hats.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,14 @@ export const deployHatsHatCreatorModule = async (
9696
};
9797

9898
export const deployHatsFractionTokenModule = async (
99-
tmpOwner: Address,
10099
version = "0.0.0",
101100
create2DeployerAddress?: string,
102101
) => {
103102
const HatsFractionTokenModuleFactory = await ethers.getContractFactory(
104103
"HatsFractionTokenModule",
105104
);
106105
const HatsFractionTokenModuleTx =
107-
await HatsFractionTokenModuleFactory.getDeployTransaction(
108-
version,
109-
tmpOwner,
110-
);
106+
await HatsFractionTokenModuleFactory.getDeployTransaction(version);
111107
const HatsFractionTokenModuleAddress = await deployContract_Create2(
112108
baseSalt,
113109
HatsFractionTokenModuleTx.data || "0x",

pkgs/contract/test/BigBang.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,7 @@ describe("BigBang", () => {
8383
HatsHatCreatorModule_IMPL = _HatsHatCreatorModule;
8484

8585
const { HatsFractionTokenModule: _HatsFractionTokenModule_IMPL } =
86-
await deployHatsFractionTokenModule(
87-
await address1.getAddresses().then((addresses) => addresses[0]),
88-
"0.0.0",
89-
Create2Deployer.address,
90-
);
86+
await deployHatsFractionTokenModule("0.0.0", Create2Deployer.address);
9187
HatsFractionTokenModule_IMPL = _HatsFractionTokenModule_IMPL;
9288

9389
const {

pkgs/contract/test/HatsFractionTokenModule.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,7 @@ describe("HatsFractionTokenModule", () => {
7676
);
7777

7878
const { HatsFractionTokenModule: _HatsFractionTokenModule_IMPL } =
79-
await deployHatsFractionTokenModule(
80-
address1Validated,
81-
"0.0.0",
82-
Create2Deployer.address,
83-
);
79+
await deployHatsFractionTokenModule("0.0.0", Create2Deployer.address);
8480
HatsFractionTokenModule_IMPL = _HatsFractionTokenModule_IMPL;
8581

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

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

199195
it("should have valid owner, token URI, domain, and token supply", async () => {
200-
// オーナーアドレスはエンコードした初期データと一致
201-
expect(
202-
(await HatsFractionTokenModule.read.owner()).toLowerCase(),
203-
).to.equal(address1Validated.toLowerCase());
204-
205196
// トークンURIはエンコードした初期データと一致
206197
expect(await HatsFractionTokenModule.read.uri([0n])).to.equal(
207198
"https://example.com/fraction-token",

pkgs/contract/test/IntegrationTest.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,7 @@ describe("IntegrationTest", () => {
103103
HatsHatCreatorModule_IMPL = _HatsHatCreatorModule;
104104

105105
const { HatsFractionTokenModule: _HatsFractionTokenModule_IMPL } =
106-
await deployHatsFractionTokenModule(
107-
await deployer.getAddresses().then((addresses) => addresses[0]),
108-
"0.0.0",
109-
Create2Deployer.address,
110-
);
106+
await deployHatsFractionTokenModule("0.0.0", Create2Deployer.address);
111107
HatsFractionTokenModule_IMPL = _HatsFractionTokenModule_IMPL;
112108

113109
const {

pkgs/contract/test/SplitsCreator.ts

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,12 @@ describe("SplitsCreator Factory", () => {
155155
);
156156

157157
const { HatsFractionTokenModule: _HatsFractionTokenModule_IMPL } =
158-
await deployHatsFractionTokenModule(
159-
address1.account?.address!,
160-
"0.0.0",
161-
Create2Deployer.address,
162-
);
158+
await deployHatsFractionTokenModule("0.0.0", Create2Deployer.address);
163159
HatsFractionTokenModule_IMPL = _HatsFractionTokenModule_IMPL;
164160

165161
const timeFrameInitData = encodeAbiParameters(
166-
[{ type: "address" }],
167-
[address1.account?.address!],
162+
[{ type: "uint256" }],
163+
[timeFrameTobanId],
168164
);
169165

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

191187
// Deploy HatsFractionTokenModule
192188
const fractionTokenInitData = encodeAbiParameters(
193-
[{ type: "address" }, { type: "string" }, { type: "uint256" }],
194-
[
195-
address1.account?.address!,
196-
"https://example.com/fraction-token",
197-
10000n,
198-
],
189+
[{ type: "string" }, { type: "uint256" }],
190+
["https://example.com/fraction-token", 10000n],
199191
);
200192

201193
await HatsModuleFactory.write.createHatsModule([
@@ -428,11 +420,7 @@ describe("CreateSplit", () => {
428420
);
429421

430422
const { HatsFractionTokenModule: _HatsFractionTokenModule_IMPL } =
431-
await deployHatsFractionTokenModule(
432-
address1.account?.address!,
433-
"0.0.0",
434-
Create2Deployer.address,
435-
);
423+
await deployHatsFractionTokenModule("0.0.0", Create2Deployer.address);
436424
HatsFractionTokenModule_IMPL = _HatsFractionTokenModule_IMPL;
437425

438426
const timeFrameInitData = encodeAbiParameters(
@@ -463,12 +451,8 @@ describe("CreateSplit", () => {
463451

464452
// Deploy HatsFractionTokenModule
465453
const fractionTokenInitData = encodeAbiParameters(
466-
[{ type: "address" }, { type: "string" }, { type: "uint256" }],
467-
[
468-
address1.account?.address!,
469-
"https://example.com/fraction-token",
470-
10000n,
471-
],
454+
[{ type: "string" }, { type: "uint256" }],
455+
["https://example.com/fraction-token", 10000n],
472456
);
473457

474458
await HatsModuleFactory.write.createHatsModule([

0 commit comments

Comments
 (0)