diff --git a/pkgs/contract/contracts/thankstoken/IThanksToken.sol b/pkgs/contract/contracts/thankstoken/IThanksToken.sol index 6c29b09c..499f23a1 100644 --- a/pkgs/contract/contracts/thankstoken/IThanksToken.sol +++ b/pkgs/contract/contracts/thankstoken/IThanksToken.sol @@ -20,7 +20,11 @@ interface IThanksToken is IERC20 { * @param relatedRoles Array of roles related to the sender * @return success Whether the operation was successful */ - function mint(address to, uint256 amount, RelatedRole[] memory relatedRoles) external returns (bool); + function mint( + address to, + uint256 amount, + RelatedRole[] memory relatedRoles + ) external returns (bool); /** * @notice Calculates the total amount that can be minted by an address @@ -28,7 +32,10 @@ interface IThanksToken is IERC20 { * @param relatedRoles Array of roles related to the owner * @return amount The mintable amount */ - function mintableAmount(address owner, RelatedRole[] memory relatedRoles) external view returns (uint256); + function mintableAmount( + address owner, + RelatedRole[] memory relatedRoles + ) external view returns (uint256); /** * @notice Returns the total amount an address has minted @@ -61,5 +68,5 @@ interface IThanksToken is IERC20 { * @param to The recipient of the minted tokens * @param amount The amount of tokens minted */ - event TokensMinted(address indexed to, uint256 amount); + event TokenMinted(address indexed from, address indexed to, uint256 amount); } diff --git a/pkgs/contract/contracts/thankstoken/ThanksToken.sol b/pkgs/contract/contracts/thankstoken/ThanksToken.sol index 616ca51d..1eb61427 100644 --- a/pkgs/contract/contracts/thankstoken/ThanksToken.sol +++ b/pkgs/contract/contracts/thankstoken/ThanksToken.sol @@ -43,7 +43,11 @@ contract ThanksToken is Clone, ERC20("", ""), IThanksToken { return IHatsFractionTokenModule(_getArgAddress(140)); // 12 + 128 } - function HATS_TIME_FRAME_MODULE() public pure returns (IHatsTimeFrameModule) { + function HATS_TIME_FRAME_MODULE() + public + pure + returns (IHatsTimeFrameModule) + { return IHatsTimeFrameModule(_getArgAddress(172)); // 12 + 160 } @@ -61,7 +65,9 @@ contract ThanksToken is Clone, ERC20("", ""), IThanksToken { } // Helper function to read dynamic strings from clone args - function _getArgString(uint256 argIndex) internal pure returns (string memory) { + function _getArgString( + uint256 argIndex + ) internal pure returns (string memory) { // Calculate offset to the string offset pointer // Name is at offset 32 (after workspaceOwner), Symbol at offset 64 uint256 stringPointerOffset = 32 + (argIndex * 32); @@ -93,7 +99,10 @@ contract ThanksToken is Clone, ERC20("", ""), IThanksToken { // Owner modifier modifier onlyOwner() { - require(msg.sender == WORKSPACE_OWNER(), "Ownable: caller is not the owner"); + require( + msg.sender == WORKSPACE_OWNER(), + "Ownable: caller is not the owner" + ); _; } @@ -124,7 +133,7 @@ contract ThanksToken is Clone, ERC20("", ""), IThanksToken { _isParticipant[to] = true; } - emit TokensMinted(to, amount); + emit TokenMinted(msg.sender, to, amount); return true; } diff --git a/pkgs/subgraph/abis/BigBang.json b/pkgs/subgraph/abis/BigBang.json index 6579f263..6e23046d 100644 --- a/pkgs/subgraph/abis/BigBang.json +++ b/pkgs/subgraph/abis/BigBang.json @@ -106,6 +106,30 @@ "name": "hatterHatId", "type": "uint256" }, + { + "indexed": false, + "internalType": "uint256", + "name": "memberHatId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "operatorHatId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "creatorHatId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "minterHatId", + "type": "uint256" + }, { "indexed": false, "internalType": "address", @@ -118,11 +142,23 @@ "name": "hatsHatCreatorModule", "type": "address" }, + { + "indexed": false, + "internalType": "address", + "name": "hatsFractionTokenModule", + "type": "address" + }, { "indexed": false, "internalType": "address", "name": "splitCreator", "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "thanksToken", + "type": "address" } ], "name": "Executed", @@ -175,10 +211,10 @@ }, { "inputs": [], - "name": "FractionToken", + "name": "Hats", "outputs": [ { - "internalType": "address", + "internalType": "contract IHats", "name": "", "type": "address" } @@ -188,10 +224,10 @@ }, { "inputs": [], - "name": "Hats", + "name": "HatsFractionTokenModule_IMPL", "outputs": [ { - "internalType": "contract IHats", + "internalType": "address", "name": "", "type": "address" } @@ -264,6 +300,19 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [], + "name": "ThanksTokenFactory", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [], "name": "UPGRADE_INTERFACE_VERSION", @@ -303,6 +352,16 @@ "internalType": "string", "name": "_hatterHatImageURI", "type": "string" + }, + { + "internalType": "string", + "name": "_memberHatDetails", + "type": "string" + }, + { + "internalType": "string", + "name": "_memberHatImageURI", + "type": "string" } ], "name": "bigbang", @@ -343,6 +402,11 @@ "name": "_hatsHatCreatorModule_IMPL", "type": "address" }, + { + "internalType": "address", + "name": "_hatsFractionTokenModule_IMPL", + "type": "address" + }, { "internalType": "address", "name": "_splitsCreatorFactory", @@ -355,7 +419,7 @@ }, { "internalType": "address", - "name": "_fractionToken", + "name": "_thanksTokenFactory", "type": "address" } ], @@ -401,11 +465,11 @@ "inputs": [ { "internalType": "address", - "name": "_fractionToken", + "name": "_hats", "type": "address" } ], - "name": "setFractionToken", + "name": "setHats", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -414,11 +478,11 @@ "inputs": [ { "internalType": "address", - "name": "_hats", + "name": "_hatsFractionTokenModuleImpl", "type": "address" } ], - "name": "setHats", + "name": "setHatsFractionTokenModuleImpl", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -488,6 +552,19 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "address", + "name": "_thanksTokenFactory", + "type": "address" + } + ], + "name": "setThanksTokenFactory", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { diff --git a/pkgs/subgraph/abis/FractionToken.json b/pkgs/subgraph/abis/HatsFractionTokenModule.json similarity index 81% rename from pkgs/subgraph/abis/FractionToken.json rename to pkgs/subgraph/abis/HatsFractionTokenModule.json index b88b19d2..36bc9f9a 100644 --- a/pkgs/subgraph/abis/FractionToken.json +++ b/pkgs/subgraph/abis/HatsFractionTokenModule.json @@ -2,12 +2,27 @@ { "inputs": [ { - "internalType": "address", - "name": "target", - "type": "address" + "internalType": "string", + "name": "_version", + "type": "string" } ], - "name": "AddressEmptyCode", + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "ArrayLengthMismatch", + "type": "error" + }, + { + "inputs": [], + "name": "CallerNotHatAdminOrWearer", + "type": "error" + }, + { + "inputs": [], + "name": "CannotTransferAllTokens", "type": "error" }, { @@ -113,24 +128,18 @@ "type": "error" }, { - "inputs": [ - { - "internalType": "address", - "name": "implementation", - "type": "address" - } - ], - "name": "ERC1967InvalidImplementation", + "inputs": [], + "name": "HatIdMustBeTopHat", "type": "error" }, { "inputs": [], - "name": "ERC1967NonPayable", + "name": "InitialSupplyNotMinted", "type": "error" }, { "inputs": [], - "name": "FailedCall", + "name": "InvalidHatIdForDomain", "type": "error" }, { @@ -144,42 +153,50 @@ "type": "error" }, { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "OwnableInvalidOwner", + "inputs": [], + "name": "TokenAlreadyMinted", "type": "error" }, { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "OwnableUnauthorizedAccount", + "inputs": [], + "name": "TokenSupplyExceedsMax", "type": "error" }, { "inputs": [], - "name": "UUPSUnauthorizedCallContext", + "name": "WearerDoesNotHaveHat", "type": "error" }, { + "anonymous": false, "inputs": [ { - "internalType": "bytes32", - "name": "slot", - "type": "bytes32" + "indexed": true, + "internalType": "uint256", + "name": "hatId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "wearer", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" } ], - "name": "UUPSUnsupportedProxiableUUID", - "type": "error" + "name": "AdditionalMint", + "type": "event" }, { "anonymous": false, @@ -209,6 +226,12 @@ { "anonymous": false, "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "hatId", + "type": "uint256" + }, { "indexed": true, "internalType": "address", @@ -218,13 +241,13 @@ { "indexed": true, "internalType": "uint256", - "name": "hatId", + "name": "tokenId", "type": "uint256" }, { - "indexed": true, + "indexed": false, "internalType": "uint256", - "name": "tokenId", + "name": "amount", "type": "uint256" } ], @@ -244,23 +267,54 @@ "name": "Initialized", "type": "event" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldSupply", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newSupply", + "type": "uint256" + } + ], + "name": "TokenSupplyUpdated", + "type": "event" + }, { "anonymous": false, "inputs": [ { "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" + "internalType": "uint256", + "name": "hatId", + "type": "uint256" }, { "indexed": true, "internalType": "address", - "name": "newOwner", + "name": "wearer", "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" } ], - "name": "OwnershipTransferred", + "name": "TokensBurned", "type": "event" }, { @@ -357,39 +411,52 @@ "type": "event" }, { - "anonymous": false, - "inputs": [ + "inputs": [], + "name": "DEFAULT_TOKEN_SUPPLY", + "outputs": [ { - "indexed": true, - "internalType": "address", - "name": "implementation", + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "HATS", + "outputs": [ + { + "internalType": "contract IHats", + "name": "", "type": "address" } ], - "name": "Upgraded", - "type": "event" + "stateMutability": "pure", + "type": "function" }, { "inputs": [], - "name": "TOKEN_SUPPLY", + "name": "IMPLEMENTATION", "outputs": [ { - "internalType": "uint256", + "internalType": "address", "name": "", - "type": "uint256" + "type": "address" } ], - "stateMutability": "view", + "stateMutability": "pure", "type": "function" }, { "inputs": [], - "name": "UPGRADE_INTERFACE_VERSION", + "name": "MAX_SUPPLY_PER_ROLE_USER", "outputs": [ { - "internalType": "string", + "internalType": "uint256", "name": "", - "type": "string" + "type": "uint256" } ], "stateMutability": "view", @@ -423,17 +490,17 @@ "inputs": [ { "internalType": "address", - "name": "account", + "name": "_account", "type": "address" }, { "internalType": "address", - "name": "wearer", + "name": "_wearer", "type": "address" }, { "internalType": "uint256", - "name": "hatId", + "name": "_hatId", "type": "uint256" } ], @@ -452,17 +519,17 @@ "inputs": [ { "internalType": "address[]", - "name": "accounts", + "name": "_accounts", "type": "address[]" }, { "internalType": "address[]", - "name": "wearers", + "name": "_wearers", "type": "address[]" }, { "internalType": "uint256[]", - "name": "hatIds", + "name": "_hatIds", "type": "uint256[]" } ], @@ -504,23 +571,46 @@ { "inputs": [ { - "internalType": "address", - "name": "from", - "type": "address" + "internalType": "uint256[]", + "name": "_hatIds", + "type": "uint256[]" }, { - "internalType": "address", - "name": "wearer", - "type": "address" + "internalType": "address[]", + "name": "_wearers", + "type": "address[]" }, + { + "internalType": "uint256[]", + "name": "_amounts", + "type": "uint256[]" + } + ], + "name": "batchMintInitialSupply", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ { "internalType": "uint256", - "name": "hatId", + "name": "_hatId", "type": "uint256" }, + { + "internalType": "address", + "name": "_wearer", + "type": "address" + }, + { + "internalType": "address", + "name": "_target", + "type": "address" + }, { "internalType": "uint256", - "name": "value", + "name": "_amount", "type": "uint256" } ], @@ -548,16 +638,29 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [], + "name": "getDomain", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { "internalType": "uint256", - "name": "hatId", + "name": "_hatId", "type": "uint256" }, { "internalType": "address", - "name": "account", + "name": "_wearer", "type": "address" } ], @@ -592,31 +695,16 @@ "type": "function" }, { - "inputs": [ - { - "internalType": "address", - "name": "_initialOwner", - "type": "address" - }, + "inputs": [], + "name": "hatId", + "outputs": [ { "internalType": "uint256", - "name": "_tokenSupply", + "name": "", "type": "uint256" - }, - { - "internalType": "address", - "name": "_hatsAddress", - "type": "address" - }, - { - "internalType": "string", - "name": "_uri", - "type": "string" } ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", + "stateMutability": "pure", "type": "function" }, { @@ -647,17 +735,17 @@ "inputs": [ { "internalType": "uint256", - "name": "hatId", + "name": "_hatId", "type": "uint256" }, { "internalType": "address", - "name": "account", + "name": "_wearer", "type": "address" }, { "internalType": "uint256", - "name": "amount", + "name": "_amount", "type": "uint256" } ], @@ -670,17 +758,17 @@ "inputs": [ { "internalType": "uint256", - "name": "hatId", + "name": "_hatId", "type": "uint256" }, { "internalType": "address", - "name": "account", + "name": "_wearer", "type": "address" }, { "internalType": "uint256", - "name": "amount", + "name": "_amount", "type": "uint256" } ], @@ -689,83 +777,31 @@ "stateMutability": "nonpayable", "type": "function" }, - { - "inputs": [ - { - "internalType": "bytes[]", - "name": "data", - "type": "bytes[]" - } - ], - "name": "multicall", - "outputs": [ - { - "internalType": "bytes[]", - "name": "results", - "type": "bytes[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "proxiableUUID", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, { "inputs": [ { "internalType": "address", - "name": "from", + "name": "_from", "type": "address" }, { "internalType": "address", - "name": "to", + "name": "_to", "type": "address" }, { "internalType": "uint256[]", - "name": "tokenIds", + "name": "_ids", "type": "uint256[]" }, { "internalType": "uint256[]", - "name": "amounts", + "name": "_amounts", "type": "uint256[]" }, { "internalType": "bytes", - "name": "data", + "name": "_data", "type": "bytes" } ], @@ -778,27 +814,27 @@ "inputs": [ { "internalType": "address", - "name": "from", + "name": "_from", "type": "address" }, { "internalType": "address", - "name": "to", + "name": "_to", "type": "address" }, { "internalType": "uint256", - "name": "tokenId", + "name": "_id", "type": "uint256" }, { "internalType": "uint256", - "name": "amount", + "name": "_amount", "type": "uint256" }, { "internalType": "bytes", - "name": "data", + "name": "_data", "type": "bytes" } ], @@ -825,6 +861,19 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "_initData", + "type": "bytes" + } + ], + "name": "setUp", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { @@ -861,12 +910,12 @@ "inputs": [ { "internalType": "address", - "name": "wearer", + "name": "_wearer", "type": "address" }, { "internalType": "uint256", - "name": "hatId", + "name": "_hatId", "type": "uint256" } ], @@ -903,43 +952,38 @@ { "inputs": [ { - "internalType": "address", - "name": "newOwner", - "type": "address" + "internalType": "uint256", + "name": "", + "type": "uint256" } ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - }, + "name": "uri", + "outputs": [ { - "internalType": "bytes", - "name": "data", - "type": "bytes" + "internalType": "string", + "name": "", + "type": "string" } ], - "name": "upgradeToAndCall", - "outputs": [], - "stateMutability": "payable", + "stateMutability": "view", "type": "function" }, { - "inputs": [ + "inputs": [], + "name": "version", + "outputs": [ { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" + "internalType": "string", + "name": "", + "type": "string" } ], - "name": "uri", + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "version_", "outputs": [ { "internalType": "string", diff --git a/pkgs/subgraph/abis/HatsHatCreatorModule.json b/pkgs/subgraph/abis/HatsHatCreatorModule.json deleted file mode 100644 index 89cb7017..00000000 --- a/pkgs/subgraph/abis/HatsHatCreatorModule.json +++ /dev/null @@ -1,332 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "string", - "name": "_version", - "type": "string" - }, - { - "internalType": "address", - "name": "_tmpOwner", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [], - "name": "InvalidInitialization", - "type": "error" - }, - { - "inputs": [], - "name": "NotInitializing", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "OwnableInvalidOwner", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "OwnableUnauthorizedAccount", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "authority", - "type": "address" - } - ], - "name": "CreateHatAuthorityGranted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "authority", - "type": "address" - } - ], - "name": "CreateHatAuthorityRevoked", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint64", - "name": "version", - "type": "uint64" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "inputs": [], - "name": "HATS", - "outputs": [ - { - "internalType": "contract IHats", - "name": "", - "type": "address" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [], - "name": "IMPLEMENTATION", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_admin", - "type": "uint256" - }, - { - "internalType": "string", - "name": "_details", - "type": "string" - }, - { - "internalType": "uint32", - "name": "_maxSupply", - "type": "uint32" - }, - { - "internalType": "address", - "name": "_eligibility", - "type": "address" - }, - { - "internalType": "address", - "name": "_toggle", - "type": "address" - }, - { - "internalType": "bool", - "name": "_mutable", - "type": "bool" - }, - { - "internalType": "string", - "name": "_imageURI", - "type": "string" - } - ], - "name": "createHat", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "createHatAuthorities", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "authority", - "type": "address" - } - ], - "name": "grantCreateHatAuthority", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "authority", - "type": "address" - } - ], - "name": "hasCreateHatAuthority", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "hatId", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "authority", - "type": "address" - } - ], - "name": "revokeCreateHatAuthority", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes", - "name": "_initData", - "type": "bytes" - } - ], - "name": "setUp", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "version", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "version_", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/pkgs/subgraph/abis/HatsTimeFrameModule.json b/pkgs/subgraph/abis/ThanksToken.json similarity index 66% rename from pkgs/subgraph/abis/HatsTimeFrameModule.json rename to pkgs/subgraph/abis/ThanksToken.json index 51e4075d..6f4c36a7 100644 --- a/pkgs/subgraph/abis/HatsTimeFrameModule.json +++ b/pkgs/subgraph/abis/ThanksToken.json @@ -1,94 +1,113 @@ [ { "inputs": [ - { - "internalType": "string", - "name": "_version", - "type": "string" - }, { "internalType": "address", - "name": "_tmpOwner", + "name": "spender", "type": "address" + }, + { + "internalType": "uint256", + "name": "allowance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "needed", + "type": "uint256" } ], - "stateMutability": "nonpayable", - "type": "constructor" + "name": "ERC20InsufficientAllowance", + "type": "error" }, { - "inputs": [], - "name": "InvalidInitialization", + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "needed", + "type": "uint256" + } + ], + "name": "ERC20InsufficientBalance", "type": "error" }, { - "inputs": [], - "name": "NotInitializing", + "inputs": [ + { + "internalType": "address", + "name": "approver", + "type": "address" + } + ], + "name": "ERC20InvalidApprover", "type": "error" }, { "inputs": [ { "internalType": "address", - "name": "owner", + "name": "receiver", "type": "address" } ], - "name": "OwnableInvalidOwner", + "name": "ERC20InvalidReceiver", "type": "error" }, { "inputs": [ { "internalType": "address", - "name": "account", + "name": "sender", "type": "address" } ], - "name": "OwnableUnauthorizedAccount", + "name": "ERC20InvalidSender", "type": "error" }, { - "anonymous": false, "inputs": [ { - "indexed": true, - "internalType": "uint256", - "name": "hatId", - "type": "uint256" - }, - { - "indexed": true, "internalType": "address", - "name": "wearer", + "name": "spender", "type": "address" } ], - "name": "HatDeactivated", - "type": "event" + "name": "ERC20InvalidSpender", + "type": "error" }, { "anonymous": false, "inputs": [ { "indexed": true, - "internalType": "uint256", - "name": "hatId", - "type": "uint256" + "internalType": "address", + "name": "owner", + "type": "address" }, { "indexed": true, "internalType": "address", - "name": "wearer", + "name": "spender", "type": "address" }, { "indexed": false, "internalType": "uint256", - "name": "timestamp", + "name": "value", "type": "uint256" } ], - "name": "HatMinted", + "name": "Approval", "type": "event" }, { @@ -96,18 +115,24 @@ "inputs": [ { "indexed": true, - "internalType": "uint256", - "name": "hatId", - "type": "uint256" + "internalType": "address", + "name": "from", + "type": "address" }, { "indexed": true, "internalType": "address", - "name": "wearer", + "name": "to", "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" } ], - "name": "HatReactivated", + "name": "TokenMinted", "type": "event" }, { @@ -115,86 +140,86 @@ "inputs": [ { "indexed": true, - "internalType": "uint256", - "name": "hatId", - "type": "uint256" + "internalType": "address", + "name": "from", + "type": "address" }, { "indexed": true, "internalType": "address", - "name": "wearer", + "name": "to", "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" } ], - "name": "HatRenounced", + "name": "Transfer", "type": "event" }, { - "anonymous": false, - "inputs": [ + "inputs": [], + "name": "DEFAULT_COEFFICIENT", + "outputs": [ { - "indexed": false, - "internalType": "uint64", - "name": "version", - "type": "uint64" + "internalType": "uint256", + "name": "", + "type": "uint256" } ], - "name": "Initialized", - "type": "event" + "stateMutability": "pure", + "type": "function" }, { - "anonymous": false, - "inputs": [ + "inputs": [], + "name": "FRACTION_TOKEN", + "outputs": [ { - "indexed": true, - "internalType": "address", - "name": "authority", + "internalType": "contract IHatsFractionTokenModule", + "name": "", "type": "address" } ], - "name": "OperationAuthorityGranted", - "type": "event" + "stateMutability": "pure", + "type": "function" }, { - "anonymous": false, - "inputs": [ + "inputs": [], + "name": "HATS", + "outputs": [ { - "indexed": true, - "internalType": "address", - "name": "authority", + "internalType": "contract IHats", + "name": "", "type": "address" } ], - "name": "OperationAuthorityRevoked", - "type": "event" + "stateMutability": "pure", + "type": "function" }, { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, + "inputs": [], + "name": "HATS_TIME_FRAME_MODULE", + "outputs": [ { - "indexed": true, - "internalType": "address", - "name": "newOwner", + "internalType": "contract IHatsTimeFrameModule", + "name": "", "type": "address" } ], - "name": "OwnershipTransferred", - "type": "event" + "stateMutability": "pure", + "type": "function" }, { "inputs": [], - "name": "HATS", + "name": "NAME", "outputs": [ { - "internalType": "contract IHats", + "internalType": "string", "name": "", - "type": "address" + "type": "string" } ], "stateMutability": "pure", @@ -202,49 +227,39 @@ }, { "inputs": [], - "name": "IMPLEMENTATION", + "name": "SYMBOL", "outputs": [ { - "internalType": "address", + "internalType": "string", "name": "", - "type": "address" + "type": "string" } ], "stateMutability": "pure", "type": "function" }, { - "inputs": [ - { - "internalType": "uint256", - "name": "hatId", - "type": "uint256" - }, + "inputs": [], + "name": "WORKSPACE_OWNER", + "outputs": [ { "internalType": "address", - "name": "wearer", + "name": "", "type": "address" } ], - "name": "deactivate", - "outputs": [], - "stateMutability": "nonpayable", + "stateMutability": "pure", "type": "function" }, { "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, { "internalType": "address", - "name": "", + "name": "owner", "type": "address" } ], - "name": "deactivatedTime", + "name": "addressCoefficient", "outputs": [ { "internalType": "uint256", @@ -259,16 +274,16 @@ "inputs": [ { "internalType": "address", - "name": "wearer", + "name": "owner", "type": "address" }, { - "internalType": "uint256", - "name": "hatId", - "type": "uint256" + "internalType": "address", + "name": "spender", + "type": "address" } ], - "name": "getWearingElapsedTime", + "name": "allowance", "outputs": [ { "internalType": "uint256", @@ -283,53 +298,53 @@ "inputs": [ { "internalType": "address", - "name": "wearer", + "name": "spender", "type": "address" }, { "internalType": "uint256", - "name": "hatId", + "name": "value", "type": "uint256" } ], - "name": "getWoreTime", + "name": "approve", "outputs": [ { - "internalType": "uint256", + "internalType": "bool", "name": "", - "type": "uint256" + "type": "bool" } ], - "stateMutability": "view", + "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "address", - "name": "authority", + "name": "account", "type": "address" } ], - "name": "grantOperationAuthority", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ + "name": "balanceOf", + "outputs": [ { - "internalType": "address", - "name": "authority", - "type": "address" + "internalType": "uint256", + "name": "", + "type": "uint256" } ], - "name": "hasOperationAuthority", + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", "outputs": [ { - "internalType": "bool", + "internalType": "uint8", "name": "", - "type": "bool" + "type": "uint8" } ], "stateMutability": "view", @@ -337,7 +352,7 @@ }, { "inputs": [], - "name": "hatId", + "name": "defaultCoefficient", "outputs": [ { "internalType": "uint256", @@ -348,20 +363,50 @@ "stateMutability": "pure", "type": "function" }, + { + "inputs": [], + "name": "getParticipants", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, { "internalType": "uint256", - "name": "", + "name": "amount", "type": "uint256" }, { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "isActive", + "components": [ + { + "internalType": "uint256", + "name": "hatId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "wearer", + "type": "address" + } + ], + "internalType": "struct IThanksToken.RelatedRole[]", + "name": "relatedRoles", + "type": "tuple[]" + } + ], + "name": "mint", "outputs": [ { "internalType": "bool", @@ -369,46 +414,59 @@ "type": "bool" } ], - "stateMutability": "view", + "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ - { - "internalType": "uint256", - "name": "hatId", - "type": "uint256" - }, { "internalType": "address", - "name": "wearer", + "name": "owner", "type": "address" }, + { + "components": [ + { + "internalType": "uint256", + "name": "hatId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "wearer", + "type": "address" + } + ], + "internalType": "struct IThanksToken.RelatedRole[]", + "name": "relatedRoles", + "type": "tuple[]" + } + ], + "name": "mintableAmount", + "outputs": [ { "internalType": "uint256", - "name": "time", + "name": "", "type": "uint256" } ], - "name": "mintHat", - "outputs": [], - "stateMutability": "nonpayable", + "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", - "name": "", + "name": "owner", "type": "address" } ], - "name": "operationAuthorities", + "name": "mintedAmount", "outputs": [ { - "internalType": "bool", + "internalType": "uint256", "name": "", - "type": "bool" + "type": "uint256" } ], "stateMutability": "view", @@ -416,56 +474,31 @@ }, { "inputs": [], - "name": "owner", + "name": "name", "outputs": [ { - "internalType": "address", + "internalType": "string", "name": "", - "type": "address" + "type": "string" } ], - "stateMutability": "view", + "stateMutability": "pure", "type": "function" }, { "inputs": [ - { - "internalType": "uint256", - "name": "hatId", - "type": "uint256" - }, { "internalType": "address", - "name": "wearer", + "name": "userAddress", "type": "address" - } - ], - "name": "reactivate", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ + }, { "internalType": "uint256", - "name": "hatId", + "name": "coefficient", "type": "uint256" - }, - { - "internalType": "address", - "name": "wearer", - "type": "address" } ], - "name": "renounce", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", + "name": "setAddressCoefficient", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -473,43 +506,37 @@ { "inputs": [ { - "internalType": "address", - "name": "authority", - "type": "address" + "internalType": "address[]", + "name": "userAddresses", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "coefficients", + "type": "uint256[]" } ], - "name": "revokeOperationAuthority", + "name": "setAddressCoefficients", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { - "inputs": [ + "inputs": [], + "name": "symbol", + "outputs": [ { - "internalType": "bytes", - "name": "_initData", - "type": "bytes" + "internalType": "string", + "name": "", + "type": "string" } ], - "name": "setUp", - "outputs": [], - "stateMutability": "nonpayable", + "stateMutability": "pure", "type": "function" }, { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "totalActiveTime", + "inputs": [], + "name": "totalSupply", "outputs": [ { "internalType": "uint256", @@ -524,63 +551,53 @@ "inputs": [ { "internalType": "address", - "name": "newOwner", + "name": "to", "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "version", - "outputs": [ + }, { - "internalType": "string", - "name": "", - "type": "string" + "internalType": "uint256", + "name": "value", + "type": "uint256" } ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "version_", + "name": "transfer", "outputs": [ { - "internalType": "string", + "internalType": "bool", "name": "", - "type": "string" + "type": "bool" } ], - "stateMutability": "view", + "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { - "internalType": "uint256", - "name": "", - "type": "uint256" + "internalType": "address", + "name": "from", + "type": "address" }, { "internalType": "address", - "name": "", + "name": "to", "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" } ], - "name": "woreTime", + "name": "transferFrom", "outputs": [ { - "internalType": "uint256", + "internalType": "bool", "name": "", - "type": "uint256" + "type": "bool" } ], - "stateMutability": "view", + "stateMutability": "nonpayable", "type": "function" } ] diff --git a/pkgs/subgraph/config/base.json b/pkgs/subgraph/config/base.json index a156a130..2302388b 100644 --- a/pkgs/subgraph/config/base.json +++ b/pkgs/subgraph/config/base.json @@ -9,60 +9,40 @@ "entities": [{ "name": "Executed" }], "handlers": [ { - "event": "Executed(indexed address,indexed address,indexed uint256,uint256,address,address,address)", + "event": "Executed(indexed address,indexed address,indexed uint256,uint256,uint256,uint256,uint256,address,address,address,address,address)", "handler": "handleExecuted" } ] }, { - "address": "0xBe3eC807B3062bfbADDa16c05C060d223F727fa3", - "file": "FractionToken", - "mappingFile": "fractionTokenMapping", - "entities": [{ "name": "InitialMint" }, { "name": "TransferSignle" }], + "address": "", + "file": "ThanksToken", + "mappingFile": "thanksTokenMapping", + "entities": [{ "name": "TokenMinted" }, { "name": "Transfer" }], "handlers": [ { - "event": "InitialMint(indexed address,indexed uint256,indexed uint256)", - "handler": "handleInitialMint" + "event": "TokenMinted(indexed address,uint256,uint256)", + "handler": "handleTokenMinted" }, { - "event": "TransferSingle(indexed address,indexed address,indexed address,uint256,uint256)", - "handler": "handleTransferSingle" + "event": "Transfer(indexed address,indexed address,uint256)", + "handler": "handleTransfer" } ] } ], "hatsModuleContracts": [ { - "file": "HatsHatCreatorModule", - "entities": [ - { "name": "CreateHatAuthorityGranted" }, - { "name": "CreateHatAuthorityRevoked" } - ], - "handlers": [ - { - "event": "CreateHatAuthorityGranted(indexed address)", - "handler": "handleCreateHatAuthorityGranted" - }, - { - "event": "CreateHatAuthorityRevoked(indexed address)", - "handler": "handleCreateHatAuthorityRevoked" - } - ] - }, - { - "file": "HatsTimeFrameModule", - "entities": [ - { "name": "OperationAuthorityGranted" }, - { "name": "OperationAuthorityRevoked" } - ], + "file": "HatsFractionTokenModule", + "entities": [{ "name": "InitialMint" }, { "name": "TransferSignle" }], "handlers": [ { - "event": "OperationAuthorityGranted(indexed address)", - "handler": "handleOperationAuthorityGranted" + "event": "InitialMint(indexed address,indexed uint256,indexed uint256)", + "handler": "handleInitialMint" }, { - "event": "OperationAuthorityRevoked(indexed address)", - "handler": "handleOperationAuthorityRevoked" + "event": "TransferSingle(indexed address,indexed address,indexed address,uint256,uint256)", + "handler": "handleTransferSingle" } ] } diff --git a/pkgs/subgraph/config/sepolia.json b/pkgs/subgraph/config/sepolia.json index 4cd82284..2d93e499 100644 --- a/pkgs/subgraph/config/sepolia.json +++ b/pkgs/subgraph/config/sepolia.json @@ -3,66 +3,46 @@ "startBlock": 7578217, "contracts": [ { - "address": "0x2662b0Dc151bbD9C0e5F1b5bD8674b4eD3E92D0b", + "address": "0xc498cCBc53FB6A31D947fF1631bF69b2F1224445", "file": "BigBang", "mappingFile": "bigbangMapping", "entities": [{ "name": "Executed" }], "handlers": [ { - "event": "Executed(indexed address,indexed address,indexed uint256,uint256,address,address,address)", + "event": "Executed(indexed address,indexed address,indexed uint256,uint256,uint256,uint256,uint256,uint256,address,address,address,address,address)", "handler": "handleExecuted" } ] - }, - { - "address": "0xd6031f9543bEB0963e32CA2AC474de69D0515059", - "file": "FractionToken", - "mappingFile": "fractionTokenMapping", - "entities": [{ "name": "InitialMint" }, { "name": "TransferSignle" }], - "handlers": [ - { - "event": "InitialMint(indexed address,indexed uint256,indexed uint256)", - "handler": "handleInitialMint" - }, - { - "event": "TransferSingle(indexed address,indexed address,indexed address,uint256,uint256)", - "handler": "handleTransferSingle" - } - ] } ], - "hatsModuleContracts": [ + "templatesContracts": [ { - "file": "HatsHatCreatorModule", - "entities": [ - { "name": "CreateHatAuthorityGranted" }, - { "name": "CreateHatAuthorityRevoked" } - ], + "file": "HatsFractionTokenModule", + "mappingFile": "hatsModuleMapping", + "entities": [{ "name": "InitialMint" }, { "name": "TransferSignle" }], "handlers": [ { - "event": "CreateHatAuthorityGranted(indexed address)", - "handler": "handleCreateHatAuthorityGranted" + "event": "InitialMint(indexed uint256,indexed address,indexed uint256,uint256)", + "handler": "handleRoleShareInitialMint" }, { - "event": "CreateHatAuthorityRevoked(indexed address)", - "handler": "handleCreateHatAuthorityRevoked" + "event": "TransferSingle(indexed address,indexed address,indexed address,uint256,uint256)", + "handler": "handleRoleShareTransferSingle" } ] }, { - "file": "HatsTimeFrameModule", - "entities": [ - { "name": "OperationAuthorityGranted" }, - { "name": "OperationAuthorityRevoked" } - ], + "file": "ThanksToken", + "mappingFile": "thanksTokenMapping", + "entities": [{ "name": "TokenMinted" }, { "name": "Transfer" }], "handlers": [ { - "event": "OperationAuthorityGranted(indexed address)", - "handler": "handleOperationAuthorityGranted" + "event": "TokenMinted(indexed address,indexed address,uint256)", + "handler": "handleTokenMinted" }, { - "event": "OperationAuthorityRevoked(indexed address)", - "handler": "handleOperationAuthorityRevoked" + "event": "Transfer(indexed address,indexed address,uint256)", + "handler": "handleTransfer" } ] } diff --git a/pkgs/subgraph/schema.graphql b/pkgs/subgraph/schema.graphql index ff8d44d4..178bc3ed 100644 --- a/pkgs/subgraph/schema.graphql +++ b/pkgs/subgraph/schema.graphql @@ -1,78 +1,112 @@ type Workspace @entity { id: ID! creator: String! + owner: String! topHatId: BigInt! hatterHatId: BigInt! - hatsTimeFrameModule: HatsTimeFrameModule - hatsHatCreatorModule: HatsHatCreatorModule + operatorHatId: BigInt! + creatorHatId: BigInt! + minterHatId: BigInt! + hatsTimeFrameModule: String! + hatsHatCreatorModule: String! + hatsFractionTokenModule: HatsFractionTokenModule + thanksToken: ThanksToken! splitCreator: String! blockTimestamp: BigInt! blockNumber: BigInt! } -type HatsTimeFrameModule @entity { +type HatsFractionTokenModule @entity { id: ID! workspaceId: ID! - authorities: [HatsTimeFrameModuleAuthority!]! - @derivedFrom(field: "hatsTimeFrameModule") + initializedTokens: [InitializedFractionToken!]! + @derivedFrom(field: "hatsFractionTokenModule") + transfers: [TransferFractionToken!]! + @derivedFrom(field: "hatsFractionTokenModule") + balances: [BalanceOfFractionToken!]! + @derivedFrom(field: "hatsFractionTokenModule") } -type HatsTimeFrameModuleAuthority @entity { +type InitializedFractionToken @entity { id: ID! + hatsFractionTokenModule: HatsFractionTokenModule! + tokenId: BigInt! + hatId: BigInt! + wearer: String! workspaceId: ID! - hatsTimeFrameModule: HatsTimeFrameModule! - address: String! - authorised: Boolean! blockTimestamp: BigInt! blockNumber: BigInt! } -type HatsHatCreatorModule @entity { +type TransferFractionToken @entity { id: ID! + hatsFractionTokenModule: HatsFractionTokenModule! + from: String! + to: String! + tokenId: BigInt! + amount: BigInt! workspaceId: ID! - authorities: [HatsHatCreatorModuleAuthority!]! - @derivedFrom(field: "hatsHatCreatorModule") + blockTimestamp: BigInt! + blockNumber: BigInt! } -type HatsHatCreatorModuleAuthority @entity { +type BalanceOfFractionToken @entity { id: ID! + hatsFractionTokenModule: HatsFractionTokenModule! + owner: String! + tokenId: BigInt! + balance: BigInt! workspaceId: ID! - hatsHatCreatorModule: HatsHatCreatorModule! - address: String! - authorised: Boolean! - blockTimestamp: BigInt! - blockNumber: BigInt! + hatId: BigInt! + wearer: String! + updatedAt: BigInt! } -type InitializedFractionToken @entity { +type ThanksToken @entity { id: ID! workspaceId: ID! - wearer: String! - hatId: BigInt! + mints: [MintThanksToken!]! @derivedFrom(field: "thanksToken") + transfers: [TransferThanksToken!]! @derivedFrom(field: "thanksToken") + mintAmounts: [AmountOfMintThanksToken!]! @derivedFrom(field: "thanksToken") + balances: [BalanceOfThanksToken!]! @derivedFrom(field: "thanksToken") +} + +type MintThanksToken @entity { + id: ID! + thanksToken: ThanksToken! + from: String! + to: String! + amount: BigInt! + workspaceId: ID! blockTimestamp: BigInt! blockNumber: BigInt! } -type TransferFractionToken @entity { +type TransferThanksToken @entity { id: ID! + thanksToken: ThanksToken! from: String! to: String! - tokenId: BigInt! amount: BigInt! - workspaceId: ID - hatId: BigInt - wearer: String + workspaceId: ID! blockTimestamp: BigInt! blockNumber: BigInt! } -type BalanceOfFractionToken @entity { +type AmountOfMintThanksToken @entity { + id: ID! + thanksToken: ThanksToken! + sender: String! + amount: BigInt! + workspaceId: ID! + updatedAt: BigInt! +} + +type BalanceOfThanksToken @entity { id: ID! + thanksToken: ThanksToken! owner: String! - tokenId: BigInt! balance: BigInt! - workspaceId: ID - hatId: BigInt - wearer: String + workspaceId: ID! updatedAt: BigInt! } diff --git a/pkgs/subgraph/src/bigbangMapping.ts b/pkgs/subgraph/src/bigbangMapping.ts index f39aa480..c284ba1a 100644 --- a/pkgs/subgraph/src/bigbangMapping.ts +++ b/pkgs/subgraph/src/bigbangMapping.ts @@ -1,13 +1,9 @@ import { Executed } from "../generated/BigBang/BigBang"; import { - HatsHatCreatorModule, - HatsTimeFrameModule, + HatsFractionTokenModule, + ThanksToken, Workspace, } from "../generated/schema"; -import { - HatsHatCreatorModule as HatsHatCreatorModuleTemplate, - HatsTimeFrameModule as HatsTimeFrameModuleTemplate, -} from "../generated/templates"; import { hatIdToTreeId } from "./helper/hat"; export function handleExecuted(ev: Executed): void { @@ -16,30 +12,29 @@ export function handleExecuted(ev: Executed): void { workspace.topHatId = ev.params.topHatId; workspace.creator = ev.params.creator.toHex(); + workspace.owner = ev.params.owner.toHex(); workspace.topHatId = ev.params.topHatId; workspace.hatterHatId = ev.params.hatterHatId; + workspace.operatorHatId = ev.params.operatorHatId; + workspace.creatorHatId = ev.params.creatorHatId; + workspace.minterHatId = ev.params.minterHatId; workspace.hatsTimeFrameModule = ev.params.hatsTimeFrameModule.toHex(); workspace.hatsHatCreatorModule = ev.params.hatsHatCreatorModule.toHex(); + workspace.hatsFractionTokenModule = ev.params.hatsFractionTokenModule.toHex(); + workspace.thanksToken = ev.params.thanksToken.toHex(); workspace.splitCreator = ev.params.splitCreator.toHex(); workspace.blockTimestamp = ev.block.timestamp; workspace.blockNumber = ev.block.number; workspace.save(); - // Create new index from template for HatsModules - const newHatsHatCreatorModule = new HatsHatCreatorModule( - ev.params.hatsHatCreatorModule.toHex(), - ); - newHatsHatCreatorModule.workspaceId = treeId; - newHatsHatCreatorModule.save(); - - HatsHatCreatorModuleTemplate.create(ev.params.hatsHatCreatorModule); - - const newHatsTimeFrameModule = new HatsTimeFrameModule( - ev.params.hatsTimeFrameModule.toHex(), + const newHatsFractionTokenModule = new HatsFractionTokenModule( + ev.params.hatsFractionTokenModule.toHex(), ); - newHatsTimeFrameModule.workspaceId = treeId; - newHatsTimeFrameModule.save(); + newHatsFractionTokenModule.workspaceId = treeId; + newHatsFractionTokenModule.save(); - HatsTimeFrameModuleTemplate.create(ev.params.hatsTimeFrameModule); + const newThanksToken = new ThanksToken(ev.params.thanksToken.toHex()); + newThanksToken.workspaceId = treeId; + newThanksToken.save(); } diff --git a/pkgs/subgraph/src/hatsModuleMapping.ts b/pkgs/subgraph/src/hatsModuleMapping.ts index e201ec2d..9cb714b1 100644 --- a/pkgs/subgraph/src/hatsModuleMapping.ts +++ b/pkgs/subgraph/src/hatsModuleMapping.ts @@ -1,126 +1,110 @@ +import { Address, BigInt as GraphBigInt } from "@graphprotocol/graph-ts"; import { - HatsHatCreatorModule, - HatsHatCreatorModuleAuthority, - HatsTimeFrameModule, - HatsTimeFrameModuleAuthority, + BalanceOfFractionToken, + HatsFractionTokenModule, + InitializedFractionToken, + TransferFractionToken, } from "../generated/schema"; import { - CreateHatAuthorityGranted, - CreateHatAuthorityRevoked, -} from "../generated/templates/HatsHatCreatorModule/HatsHatCreatorModule"; -import { - OperationAuthorityGranted, - OperationAuthorityRevoked, -} from "../generated/templates/HatsTimeFrameModule/HatsTimeFrameModule"; + InitialMint, + TransferSingle, +} from "../generated/templates/HatsFractionTokenModule/HatsFractionTokenModule"; -export function handleOperationAuthorityGranted( - ev: OperationAuthorityGranted, -): void { - const module = HatsTimeFrameModule.load(ev.address.toHex()); +export function handleRoleShareInitialMint(ev: InitialMint): void { + const module = HatsFractionTokenModule.load(ev.address.toHex()); + const id = `${ev.address.toHex()}-${ev.params.tokenId.toHexString()}`; if (module === null) { return; } - let authority = HatsTimeFrameModuleAuthority.load( - `${ev.address.toHex()}-${ev.params.authority.toHexString()}`, - ); - if (authority) { - authority.authorised = true; - } else { - authority = new HatsTimeFrameModuleAuthority( - `${ev.address.toHex()}-${ev.params.authority.toHexString()}`, - ); - authority.workspaceId = module.workspaceId; - authority.hatsTimeFrameModule = module.id; - authority.address = ev.params.authority.toHex(); - authority.authorised = true; - authority.blockNumber = ev.block.number; - authority.blockTimestamp = ev.block.timestamp; - } - authority.save(); + let initializedEvent = InitializedFractionToken.load(id); + if (initializedEvent) return; + + initializedEvent = new InitializedFractionToken(id); + initializedEvent.hatsFractionTokenModule = module.id; + initializedEvent.tokenId = ev.params.tokenId; + initializedEvent.hatId = ev.params.hatId; + initializedEvent.wearer = ev.params.wearer.toHex(); + initializedEvent.workspaceId = module.workspaceId; + initializedEvent.blockTimestamp = ev.block.timestamp; + initializedEvent.blockNumber = ev.block.number; + + initializedEvent.save(); } -export function handleOperationAuthorityRevoked( - ev: OperationAuthorityRevoked, -): void { - const module = HatsTimeFrameModule.load(ev.address.toHex()); +export function handleRoleShareTransferSingle(ev: TransferSingle): void { + const module = HatsFractionTokenModule.load(ev.address.toHex()); + const id = `${ev.address.toHex()}-${ev.params.id.toHexString()}`; + const initializedRoleShare = InitializedFractionToken.load(id); - if (module === null) { + if (initializedRoleShare === null || module === null) { return; } - let authority = HatsTimeFrameModuleAuthority.load( - `${ev.address.toHex()}-${ev.params.authority.toHexString()}`, + let transfer = TransferFractionToken.load( + `${ev.address.toHex()}-${ev.params.id.toHexString()}-${ev.params.to.toHexString()}-${ev.params.from.toHexString()}-${ev.block.number}`, ); - if (authority) { - authority.authorised = false; - } else { - authority = new HatsTimeFrameModuleAuthority( - `${ev.address.toHex()}-${ev.params.authority.toHexString()}`, - ); - authority.workspaceId = module.workspaceId; - authority.hatsTimeFrameModule = module.id; - authority.address = ev.params.authority.toHex(); - authority.authorised = false; - authority.blockNumber = ev.block.number; - authority.blockTimestamp = ev.block.timestamp; - } - authority.save(); -} - -export function handleCreateHatAuthorityGranted( - ev: CreateHatAuthorityGranted, -): void { - const module = HatsHatCreatorModule.load(ev.address.toHex()); + if (transfer) return; + transfer = new TransferFractionToken( + `${ev.address.toHex()}-${ev.params.id.toHexString()}-${ev.params.to.toHexString()}-${ev.params.from.toHexString()}-${ev.block.number}`, + ); + transfer.hatsFractionTokenModule = module.id; + transfer.from = ev.params.from.toHex(); + transfer.to = ev.params.to.toHex(); + transfer.tokenId = ev.params.id; + transfer.amount = ev.params.value; + transfer.workspaceId = module.workspaceId; + transfer.blockTimestamp = ev.block.timestamp; + transfer.blockNumber = ev.block.number; - if (module === null) { - return; - } + updateBalance( + ev.params.id, + ev.params.from, + ev.params.value.neg(), + initializedRoleShare, + ev.block.timestamp, + ); - let authority = HatsHatCreatorModuleAuthority.load( - `${ev.address.toHex()}-${ev.params.authority.toHexString()}`, + updateBalance( + ev.params.id, + ev.params.to, + ev.params.value, + initializedRoleShare, + ev.block.timestamp, ); - if (authority) { - authority.authorised = true; - } else { - authority = new HatsHatCreatorModuleAuthority( - `${ev.address.toHex()}-${ev.params.authority.toHexString()}`, - ); - authority.workspaceId = module.workspaceId; - authority.hatsHatCreatorModule = module.id; - authority.address = ev.params.authority.toHex(); - authority.authorised = true; - authority.blockNumber = ev.block.number; - authority.blockTimestamp = ev.block.timestamp; - } - authority.save(); + + transfer.save(); } -export function handleCreateHatAuthorityRevoked( - ev: CreateHatAuthorityRevoked, +function updateBalance( + tokenId: GraphBigInt, + account: Address, + amount: GraphBigInt, + initializedRoleShare: InitializedFractionToken, + timestamp: GraphBigInt, ): void { - const module = HatsHatCreatorModule.load(ev.address.toHex()); + let balance = BalanceOfFractionToken.load( + `${initializedRoleShare.id}-${tokenId.toHex()}-${account.toHex()}`, + ); + if (balance) { + balance.balance = balance.balance.plus(amount); + balance.updatedAt = timestamp; + } else if (account.toHex() !== "0x0000000000000000000000000000000000000000") { + balance = new BalanceOfFractionToken(`${tokenId}${account.toHex()}`); + balance.owner = account.toHex(); + balance.tokenId = tokenId; + balance.balance = amount; + balance.updatedAt = timestamp; + } - if (module === null) { - return; + if (balance && initializedRoleShare) { + balance.workspaceId = initializedRoleShare.workspaceId; + balance.hatId = initializedRoleShare.hatId; + balance.wearer = initializedRoleShare.wearer; } - let authority = HatsHatCreatorModuleAuthority.load( - `${ev.address.toHex()}-${ev.params.authority.toHexString()}`, - ); - if (authority) { - authority.authorised = false; - } else { - authority = new HatsHatCreatorModuleAuthority( - `${ev.address.toHex()}-${ev.params.authority.toHexString()}`, - ); - authority.workspaceId = module.workspaceId; - authority.hatsHatCreatorModule = module.id; - authority.address = ev.params.authority.toHex(); - authority.authorised = false; - authority.blockNumber = ev.block.number; - authority.blockTimestamp = ev.block.timestamp; + if (balance) { + balance.save(); } - authority.save(); } diff --git a/pkgs/subgraph/src/thanksTokenMapping.ts b/pkgs/subgraph/src/thanksTokenMapping.ts new file mode 100644 index 00000000..2e38ee75 --- /dev/null +++ b/pkgs/subgraph/src/thanksTokenMapping.ts @@ -0,0 +1,119 @@ +// MintThanksToken +// AmountOfMintThanksToken +// TransferThanksToken +// BalanceOfThanksToken + +import { Address, BigInt as GraphBigInt } from "@graphprotocol/graph-ts"; +import { + AmountOfMintThanksToken, + BalanceOfThanksToken, + MintThanksToken, + ThanksToken, + TransferThanksToken, +} from "../generated/schema"; +import { + TokenMinted, + Transfer, +} from "../generated/templates/ThanksToken/ThanksToken"; + +export function handleTokenMinted(ev: TokenMinted): void { + const thanksToken = ThanksToken.load(ev.address.toHex()); + + if (thanksToken === null) { + return; + } + + let tokenMinted = MintThanksToken.load( + `${ev.params.from.toHex()}-${ev.params.to.toHex()}-${ev.block.number}`, + ); + if (tokenMinted) return; + + tokenMinted = new MintThanksToken( + `${ev.params.from.toHex()}-${ev.params.to.toHex()}-${ev.block.number}`, + ); + tokenMinted.thanksToken = thanksToken.id; + tokenMinted.from = ev.params.from.toHex(); + tokenMinted.to = ev.params.to.toHex(); + tokenMinted.amount = ev.params.amount; + tokenMinted.workspaceId = thanksToken.workspaceId; + tokenMinted.blockTimestamp = ev.block.timestamp; + tokenMinted.blockNumber = ev.block.number; + + tokenMinted.save(); + + let amountOfMint = AmountOfMintThanksToken.load( + `${thanksToken.id}-${ev.params.from.toHex()}`, + ); + if (amountOfMint) { + amountOfMint.amount = amountOfMint.amount.plus(ev.params.amount); + amountOfMint.updatedAt = ev.block.timestamp; + } else { + amountOfMint = new AmountOfMintThanksToken( + `${thanksToken.id}-${ev.params.from.toHex()}`, + ); + amountOfMint.thanksToken = thanksToken.id; + amountOfMint.sender = ev.params.from.toHex(); + amountOfMint.amount = ev.params.amount; + amountOfMint.workspaceId = thanksToken.workspaceId; + amountOfMint.updatedAt = ev.block.timestamp; + } +} + +export function handleTransfer(ev: Transfer): void { + const thanksToken = ThanksToken.load(ev.address.toHex()); + + if (thanksToken === null) { + return; + } + + let transfer = TransferThanksToken.load( + `${ev.address.toHex()}-${ev.params.from.toHex()}-${ev.params.to.toHex()}-${ev.params.value.toString()}-${ev.block.number}`, + ); + if (transfer) return; + + transfer = new TransferThanksToken( + `${ev.address.toHex()}-${ev.params.from.toHex()}-${ev.params.to.toHex()}-${ev.params.value.toString()}-${ev.block.number}`, + ); + transfer.thanksToken = thanksToken.id; + transfer.from = ev.params.from.toHex(); + transfer.to = ev.params.to.toHex(); + transfer.amount = ev.params.value; + transfer.workspaceId = thanksToken.workspaceId; + transfer.blockTimestamp = ev.block.timestamp; + transfer.blockNumber = ev.block.number; + transfer.save(); + + updateBalance( + thanksToken, + ev.params.from, + ev.params.value.neg(), + ev.block.timestamp, + ); + updateBalance(thanksToken, ev.params.to, ev.params.value, ev.block.timestamp); +} + +function updateBalance( + thanksToken: ThanksToken, + account: Address, + amount: GraphBigInt, + timestamp: GraphBigInt, +): void { + let balance = BalanceOfThanksToken.load( + `${thanksToken.id}-${account.toHex()}`, + ); + if (balance) { + balance.balance = balance.balance.plus(amount); + balance.updatedAt = timestamp; + } else if (account.toHex() !== "0x0000000000000000000000000000000000000000") { + balance = new BalanceOfThanksToken(`${thanksToken.id}-${account.toHex()}`); + balance.thanksToken = thanksToken.id; + balance.owner = account.toHex(); + balance.balance = amount; + balance.workspaceId = thanksToken.workspaceId; + balance.updatedAt = timestamp; + } + + if (balance) { + balance.save(); + } +} diff --git a/pkgs/subgraph/subgraph.template.yaml b/pkgs/subgraph/subgraph.template.yaml index 92c3ff60..73d91ed6 100644 --- a/pkgs/subgraph/subgraph.template.yaml +++ b/pkgs/subgraph/subgraph.template.yaml @@ -31,7 +31,7 @@ dataSources: file: ./src/{{mappingFile}}.ts {{/contracts}} templates: - {{#hatsModuleContracts}} + {{#templatesContracts}} - kind: ethereum/contract name: {{ file }} network: {{ network }} @@ -53,5 +53,5 @@ templates: - event: {{event}} handler: {{handler}} {{/handlers}} - file: ./src/hatsModuleMapping.ts - {{/hatsModuleContracts}} + file: ./src/{{mappingFile}}.ts + {{/templatesContracts}}