Skip to content

Commit

Permalink
(Definitions): move definitions to separate contract for use in treasury
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminbollen committed Feb 27, 2024
1 parent 54d04bd commit c3da860
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
26 changes: 7 additions & 19 deletions src/hub/Hub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import "../migration/IToken.sol";
import "../circles/Circles.sol";
import "../groups/IMintPolicy.sol";
import "./IHub.sol";
import "./MetadataDefinitions.sol";

/**
* @title Hub v2 contract for Circles
Expand All @@ -35,16 +36,6 @@ contract Hub is Circles, IHubV2 {
uint96 expiry;
}

struct Metadata {
MetadataType metadataType;
bytes metadata;
bytes erc1155UserData;
}

struct GroupMintMetadata {
address group;
}

// Constants

/**
Expand All @@ -64,13 +55,6 @@ contract Hub is Circles, IHubV2 {
*/
address public constant SENTINEL = address(0x1);

// Enums

enum MetadataType {
NoMetadata,
GroupMint // safeTransferFrom initiated from group mint, appends GroupMintMetadata
}

// State variables

/**
Expand Down Expand Up @@ -365,9 +349,13 @@ contract Hub is Circles, IHubV2 {
);

// abi encode the group address into the data to send onwards to the treasury
bytes memory metadataGroup = abi.encode(GroupMintMetadata({group: _group}));
bytes memory metadataGroup = abi.encode(MetadataDefinitions.GroupMintMetadata({group: _group}));
bytes memory dataWithGroup = abi.encode(
Metadata({metadataType: MetadataType.GroupMint, metadata: metadataGroup, erc1155UserData: _data})
MetadataDefinitions.Metadata({
metadataType: MetadataDefinitions.MetadataType.GroupMint,
metadata: metadataGroup,
erc1155UserData: _data
})
);

// note: treasury.on1155Received must implement and unpack the GroupMintMetadata to know the group
Expand Down
23 changes: 23 additions & 0 deletions src/hub/MetadataDefinitions.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.13;

contract MetadataDefinitions {
// Type declarations

struct Metadata {
MetadataType metadataType;
bytes metadata;
bytes erc1155UserData;
}

struct GroupMintMetadata {
address group;
}

// Enums

enum MetadataType {
NoMetadata,
GroupMint // safeTransferFrom initiated from group mint, appends GroupMintMetadata
}
}

0 comments on commit c3da860

Please sign in to comment.