Skip to content

Commit

Permalink
feat(world): add system signatures to FunctionSignatures (latticexyz#…
Browse files Browse the repository at this point in the history
…2392)

Co-authored-by: Kevin Ingersoll <kingersoll@gmail.com>
  • Loading branch information
yonadaaa and holic authored Mar 7, 2024
1 parent 95f64c8 commit 1a82c27
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
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
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);
FunctionSignatures._set(worldFunctionSelector, worldFunctionSignature);
}

/**
Expand Down

0 comments on commit 1a82c27

Please sign in to comment.