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

feat(world): add system signatures to FunctionSignatures #2392

Merged
merged 5 commits into from
Mar 7, 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
5 changes: 5 additions & 0 deletions .changeset/poor-fishes-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/world": patch
---

Added system signatures to the `FunctionSignatures` table, so they can be used to generate system ABIs and decode system calls made via the world.
4 changes: 2 additions & 2 deletions packages/world-modules/gas-report.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@
"file": "test/UniqueEntityModule.t.sol",
"test": "testInstall",
"name": "install unique entity module",
"gasUsed": 710507
"gasUsed": 715495
},
{
"file": "test/UniqueEntityModule.t.sol",
Expand All @@ -315,7 +315,7 @@
"file": "test/UniqueEntityModule.t.sol",
"test": "testInstallRoot",
"name": "installRoot unique entity module",
"gasUsed": 680976
"gasUsed": 685964
},
{
"file": "test/UniqueEntityModule.t.sol",
Expand Down
2 changes: 1 addition & 1 deletion packages/world/gas-report.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"file": "test/World.t.sol",
"test": "testRegisterFunctionSelector",
"name": "Register a function selector",
"gasUsed": 111621
"gasUsed": 116605
},
{
"file": "test/World.t.sol",
Expand Down
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also set the world function selector in registerRootFunctionSelector. Do we need to do set the system one there or are they the same?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they're the same!

Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ contract WorldRegistrationSystem is System, IWorldErrors, LimitedCallContext {

// Compute global function selector
string memory namespaceString = WorldResourceIdLib.toTrimmedString(systemId.getNamespace());
bytes memory worldFunctionSignature = abi.encodePacked(namespaceString, "__", systemFunctionSignature);
worldFunctionSelector = bytes4(keccak256(worldFunctionSignature));
string memory worldFunctionSignature = string.concat(namespaceString, "__", systemFunctionSignature);
worldFunctionSelector = bytes4(keccak256(bytes(worldFunctionSignature)));

// Require the function selector to be globally unique
ResourceId existingSystemId = FunctionSelectors._getSystemId(worldFunctionSelector);
Expand All @@ -214,8 +214,9 @@ contract WorldRegistrationSystem is System, IWorldErrors, LimitedCallContext {
bytes4 systemFunctionSelector = bytes4(keccak256(bytes(systemFunctionSignature)));
FunctionSelectors._set(worldFunctionSelector, systemId, systemFunctionSelector);

// Register the function signature for offchain use
FunctionSignatures._set(worldFunctionSelector, string(worldFunctionSignature));
// Register the function signatures for offchain use
FunctionSignatures._set(systemFunctionSelector, systemFunctionSignature);
holic marked this conversation as resolved.
Show resolved Hide resolved
FunctionSignatures._set(worldFunctionSelector, worldFunctionSignature);
}

/**
Expand Down
Loading