Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/190: Split Creator #228

Merged
merged 3 commits into from
Dec 26, 2024
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
315 changes: 315 additions & 0 deletions pkgs/contract/.openzeppelin/sepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
"address": "0x08B4c53b98f46B14E2AD00189C2Aa3b9F3d0c8f3",
"txHash": "0x0b7d0cacd542bf718e6d99c13f12690b07a0f3228c31d013a2aa399cb67ae04e",
"kind": "transparent"
},
{
"address": "0x9e70310b99F946dB10394575c0B611A741e0A5db",
"txHash": "0xbbec6d941bc359657ce025f8122b6bfa1b7b57ae00ba261f7baea44e79830f95",
"kind": "transparent"
}
],
"impls": {
Expand Down Expand Up @@ -1253,6 +1258,316 @@
]
}
}
},
"bc6865de0e474b9423cb88c57d2cef5b0f4f1fc2f79c90bdca4b42b3bedc216a": {
"address": "0xe1a14D26a6cc879616fE569ed5708322D3Ed8Ff9",
"txHash": "0x1ea91babffeff4c0e5286768511fd6827e08b493fd382374d09293979cf73f6b",
"layout": {
"solcVersion": "0.8.24",
"storage": [
{
"label": "SPLITS_CREATOR_IMPLEMENTATION",
"offset": 0,
"slot": "0",
"type": "t_address",
"contract": "SplitsCreatorFactory",
"src": "contracts/splitscreator/SplitsCreatorFactory.sol:20"
},
{
"label": "BIG_BANG",
"offset": 0,
"slot": "1",
"type": "t_address",
"contract": "SplitsCreatorFactory",
"src": "contracts/splitscreator/SplitsCreatorFactory.sol:22"
}
],
"types": {
"t_address": {
"label": "address",
"numberOfBytes": "20"
},
"t_bool": {
"label": "bool",
"numberOfBytes": "1"
},
"t_struct(InitializableStorage)73_storage": {
"label": "struct Initializable.InitializableStorage",
"members": [
{
"label": "_initialized",
"type": "t_uint64",
"offset": 0,
"slot": "0"
},
{
"label": "_initializing",
"type": "t_bool",
"offset": 8,
"slot": "0"
}
],
"numberOfBytes": "32"
},
"t_struct(OwnableStorage)13_storage": {
"label": "struct OwnableUpgradeable.OwnableStorage",
"members": [
{
"label": "_owner",
"type": "t_address",
"offset": 0,
"slot": "0"
}
],
"numberOfBytes": "32"
},
"t_uint64": {
"label": "uint64",
"numberOfBytes": "8"
}
},
"namespaces": {
"erc7201:openzeppelin.storage.Ownable": [
{
"contract": "OwnableUpgradeable",
"label": "_owner",
"type": "t_address",
"src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:24",
"offset": 0,
"slot": "0"
}
],
"erc7201:openzeppelin.storage.Initializable": [
{
"contract": "Initializable",
"label": "_initialized",
"type": "t_uint64",
"src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:69",
"offset": 0,
"slot": "0"
},
{
"contract": "Initializable",
"label": "_initializing",
"type": "t_bool",
"src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:73",
"offset": 8,
"slot": "0"
}
]
}
}
},
"dd12bf6e75fb0acd68de953a2d3bb52bb98ef7fc45c7771ef4b96e40a51ea298": {
"address": "0x30Ee73482782dA4300C60B1DcD30b429a9C5f1eA",
"txHash": "0xb0055890b9abcbb62d1763d3fdf5d97615985dd3e6759714092a954c9840cd10",
"layout": {
"solcVersion": "0.8.24",
"storage": [
{
"label": "TOKEN_SUPPLY",
"offset": 0,
"slot": "0",
"type": "t_uint256",
"contract": "FractionToken",
"src": "contracts/fractiontoken/FractionToken.sol:15"
},
{
"label": "tokenRecipients",
"offset": 0,
"slot": "1",
"type": "t_mapping(t_uint256,t_array(t_address)dyn_storage)",
"contract": "FractionToken",
"src": "contracts/fractiontoken/FractionToken.sol:17"
},
{
"label": "hatsContract",
"offset": 0,
"slot": "2",
"type": "t_contract(IHats)17350",
"contract": "FractionToken",
"src": "contracts/fractiontoken/FractionToken.sol:19"
}
],
"types": {
"t_address": {
"label": "address",
"numberOfBytes": "20"
},
"t_bool": {
"label": "bool",
"numberOfBytes": "1"
},
"t_mapping(t_address,t_bool)": {
"label": "mapping(address => bool)",
"numberOfBytes": "32"
},
"t_mapping(t_address,t_mapping(t_address,t_bool))": {
"label": "mapping(address => mapping(address => bool))",
"numberOfBytes": "32"
},
"t_mapping(t_address,t_uint256)": {
"label": "mapping(address => uint256)",
"numberOfBytes": "32"
},
"t_mapping(t_uint256,t_mapping(t_address,t_uint256))": {
"label": "mapping(uint256 => mapping(address => uint256))",
"numberOfBytes": "32"
},
"t_mapping(t_uint256,t_uint256)": {
"label": "mapping(uint256 => uint256)",
"numberOfBytes": "32"
},
"t_string_storage": {
"label": "string",
"numberOfBytes": "32"
},
"t_struct(ERC1155Storage)166_storage": {
"label": "struct ERC1155Upgradeable.ERC1155Storage",
"members": [
{
"label": "_balances",
"type": "t_mapping(t_uint256,t_mapping(t_address,t_uint256))",
"offset": 0,
"slot": "0"
},
{
"label": "_operatorApprovals",
"type": "t_mapping(t_address,t_mapping(t_address,t_bool))",
"offset": 0,
"slot": "1"
},
{
"label": "_uri",
"type": "t_string_storage",
"offset": 0,
"slot": "2"
}
],
"numberOfBytes": "96"
},
"t_struct(ERC1155SupplyStorage)449_storage": {
"label": "struct ERC1155SupplyUpgradeable.ERC1155SupplyStorage",
"members": [
{
"label": "_totalSupply",
"type": "t_mapping(t_uint256,t_uint256)",
"offset": 0,
"slot": "0"
},
{
"label": "_totalSupplyAll",
"type": "t_uint256",
"offset": 0,
"slot": "1"
}
],
"numberOfBytes": "64"
},
"t_struct(InitializableStorage)73_storage": {
"label": "struct Initializable.InitializableStorage",
"members": [
{
"label": "_initialized",
"type": "t_uint64",
"offset": 0,
"slot": "0"
},
{
"label": "_initializing",
"type": "t_bool",
"offset": 8,
"slot": "0"
}
],
"numberOfBytes": "32"
},
"t_uint256": {
"label": "uint256",
"numberOfBytes": "32"
},
"t_uint64": {
"label": "uint64",
"numberOfBytes": "8"
},
"t_array(t_address)dyn_storage": {
"label": "address[]",
"numberOfBytes": "32"
},
"t_contract(IHats)17350": {
"label": "contract IHats",
"numberOfBytes": "20"
},
"t_mapping(t_uint256,t_array(t_address)dyn_storage)": {
"label": "mapping(uint256 => address[])",
"numberOfBytes": "32"
}
},
"namespaces": {
"erc7201:openzeppelin.storage.ERC1155Supply": [
{
"contract": "ERC1155SupplyUpgradeable",
"label": "_totalSupply",
"type": "t_mapping(t_uint256,t_uint256)",
"src": "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155SupplyUpgradeable.sol:25",
"offset": 0,
"slot": "0"
},
{
"contract": "ERC1155SupplyUpgradeable",
"label": "_totalSupplyAll",
"type": "t_uint256",
"src": "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155SupplyUpgradeable.sol:26",
"offset": 0,
"slot": "1"
}
],
"erc7201:openzeppelin.storage.ERC1155": [
{
"contract": "ERC1155Upgradeable",
"label": "_balances",
"type": "t_mapping(t_uint256,t_mapping(t_address,t_uint256))",
"src": "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol:27",
"offset": 0,
"slot": "0"
},
{
"contract": "ERC1155Upgradeable",
"label": "_operatorApprovals",
"type": "t_mapping(t_address,t_mapping(t_address,t_bool))",
"src": "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol:29",
"offset": 0,
"slot": "1"
},
{
"contract": "ERC1155Upgradeable",
"label": "_uri",
"type": "t_string_storage",
"src": "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol:32",
"offset": 0,
"slot": "2"
}
],
"erc7201:openzeppelin.storage.Initializable": [
{
"contract": "Initializable",
"label": "_initialized",
"type": "t_uint64",
"src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:69",
"offset": 0,
"slot": "0"
},
{
"contract": "Initializable",
"label": "_initializing",
"type": "t_bool",
"src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:73",
"offset": 8,
"slot": "0"
}
]
}
}
}
}
}
29 changes: 28 additions & 1 deletion pkgs/contract/contracts/fractiontoken/FractionToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@
pragma solidity ^0.8.24;

import { ERC1155Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol";
import { ERC1155SupplyUpgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155SupplyUpgradeable.sol";
import { IHats } from "../hats/src/Interfaces/IHats.sol";
import { IFractionToken } from "./IFractionToken.sol";
import { IERC1155 } from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";

contract FractionToken is ERC1155Upgradeable, IFractionToken {
contract FractionToken is
ERC1155Upgradeable,
ERC1155SupplyUpgradeable,
IFractionToken
{
uint256 public TOKEN_SUPPLY;

mapping(uint256 => address[]) private tokenRecipients;
Expand Down Expand Up @@ -192,9 +197,31 @@ contract FractionToken is ERC1155Upgradeable, IFractionToken {
return balances;
}

function totalSupply(
address wearer,
uint256 hatId
) public view returns (uint256) {
uint256 tokenId = getTokenId(hatId, wearer);

if (tokenRecipients[tokenId].length == 0) {
return TOKEN_SUPPLY;
}

return super.totalSupply(tokenId);
}

function uri(
uint256 tokenId
) public view override(ERC1155Upgradeable) returns (string memory) {
return super.uri(tokenId);
}

function _update(
address from,
address to,
uint256[] memory ids,
uint256[] memory values
) internal virtual override(ERC1155Upgradeable, ERC1155SupplyUpgradeable) {
super._update(from, to, ids, values);
}
}
5 changes: 5 additions & 0 deletions pkgs/contract/contracts/fractiontoken/IFractionToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@ interface IFractionToken is IERC1155 {
address[] memory warers,
uint256[] memory hatIds
) external view returns (uint256[] memory);

function totalSupply(
address wearer,
uint256 hatId
) external view returns (uint256);
}
Loading
Loading