Skip to content

Commit

Permalink
Merge pull request #13 from fxhash/feat/add-events
Browse files Browse the repository at this point in the history
feat: add events
  • Loading branch information
stevennevins committed Nov 29, 2023
2 parents eb65e2b + 5a45821 commit 311ed7c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/FileSystem.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ contract FileSystem is IFileSystem {
if (inodeExists(directoryChecksum)) revert InodeAlreadyExists();
Directory memory newDirectory = Directory(_fileNames, _inodeChecksums);
inodes[directoryChecksum] = Inode(InodeType.Directory, File(bytes(""), new bytes32[](0)), newDirectory);
emit DirectoryCreated(directoryChecksum, _fileNames, _inodeChecksums);
}

/**
Expand All @@ -88,6 +89,7 @@ contract FileSystem is IFileSystem {
if (inodeExists(fileChecksum)) revert InodeAlreadyExists();
File memory newFile = File(_metadata, _chunkPointers);
inodes[fileChecksum] = Inode(InodeType.File, newFile, Directory(new string[](0), new bytes32[](0)));
emit FileCreated(fileChecksum, _metadata, _chunkPointers);
}

/**
Expand Down
14 changes: 14 additions & 0 deletions src/interfaces/IFileSystem.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ import {Directory, File, Inode, InodeType} from "src/lib/Structs.sol";
* @notice System for storing and retrieving files onchain
*/
interface IFileSystem {
/*//////////////////////////////////////////////////////////////////////////
Events
//////////////////////////////////////////////////////////////////////////*/

/**
* @notice Event emitted when creating a new file inode
*/
event FileCreated(bytes32 indexed _checksum, bytes metadata, bytes32[] _chunkPointers);

/**
* @notice Event emitted when creating a new directory inode
*/
event DirectoryCreated(bytes32 indexed _checksum, string[] _names, bytes32[] _inodeChecksums);

/*//////////////////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////////////////*/
Expand Down

0 comments on commit 311ed7c

Please sign in to comment.