Skip to content

Commit

Permalink
fix: world modules
Browse files Browse the repository at this point in the history
  • Loading branch information
yonadaa committed Jan 22, 2024
1 parent 29a131c commit 6a517cd
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 50 deletions.
88 changes: 44 additions & 44 deletions packages/world-modules/gas-report.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,139 +3,139 @@
"file": "test/ERC20.t.sol",
"test": "testApprove",
"name": "approve",
"gasUsed": 114348
"gasUsed": 114354
},
{
"file": "test/ERC20.t.sol",
"test": "testBurn",
"name": "burn",
"gasUsed": 75910
"gasUsed": 75922
},
{
"file": "test/ERC20.t.sol",
"test": "testMint",
"name": "mint",
"gasUsed": 161749
"gasUsed": 161761
},
{
"file": "test/ERC20.t.sol",
"test": "testTransfer",
"name": "transfer",
"gasUsed": 92995
"gasUsed": 93007
},
{
"file": "test/ERC20.t.sol",
"test": "testTransferFrom",
"name": "transferFrom",
"gasUsed": 130331
"gasUsed": 130349
},
{
"file": "test/ERC721.t.sol",
"test": "testApproveAllGas",
"name": "setApprovalForAll",
"gasUsed": 113972
"gasUsed": 113978
},
{
"file": "test/ERC721.t.sol",
"test": "testApproveGas",
"name": "approve",
"gasUsed": 87981
"gasUsed": 87987
},
{
"file": "test/ERC721.t.sol",
"test": "testBurnGas",
"name": "burn",
"gasUsed": 101910
"gasUsed": 101928
},
{
"file": "test/ERC721.t.sol",
"test": "testMintGas",
"name": "mint",
"gasUsed": 169480
"gasUsed": 169492
},
{
"file": "test/ERC721.t.sol",
"test": "testSafeMintToEOAGas",
"name": "safeMint",
"gasUsed": 169751
"gasUsed": 169763
},
{
"file": "test/ERC721.t.sol",
"test": "testSafeTransferFromToEOAGas",
"name": "safeTransferFrom",
"gasUsed": 143744
"gasUsed": 143768
},
{
"file": "test/ERC721.t.sol",
"test": "testTransferFromGas",
"name": "transferFrom",
"gasUsed": 136901
"gasUsed": 136925
},
{
"file": "test/KeysInTableModule.t.sol",
"test": "testInstallComposite",
"name": "install keys in table module",
"gasUsed": 1439079
"gasUsed": 1438518
},
{
"file": "test/KeysInTableModule.t.sol",
"test": "testInstallGas",
"name": "install keys in table module",
"gasUsed": 1439079
"gasUsed": 1438518
},
{
"file": "test/KeysInTableModule.t.sol",
"test": "testInstallGas",
"name": "set a record on a table with keysInTableModule installed",
"gasUsed": 158830
"gasUsed": 158860
},
{
"file": "test/KeysInTableModule.t.sol",
"test": "testInstallSingleton",
"name": "install keys in table module",
"gasUsed": 1439079
"gasUsed": 1438518
},
{
"file": "test/KeysInTableModule.t.sol",
"test": "testSetAndDeleteRecordHookCompositeGas",
"name": "install keys in table module",
"gasUsed": 1439079
"gasUsed": 1438518
},
{
"file": "test/KeysInTableModule.t.sol",
"test": "testSetAndDeleteRecordHookCompositeGas",
"name": "change a composite record on a table with keysInTableModule installed",
"gasUsed": 22483
"gasUsed": 22489
},
{
"file": "test/KeysInTableModule.t.sol",
"test": "testSetAndDeleteRecordHookCompositeGas",
"name": "delete a composite record on a table with keysInTableModule installed",
"gasUsed": 155938
"gasUsed": 156040
},
{
"file": "test/KeysInTableModule.t.sol",
"test": "testSetAndDeleteRecordHookGas",
"name": "install keys in table module",
"gasUsed": 1439079
"gasUsed": 1438518
},
{
"file": "test/KeysInTableModule.t.sol",
"test": "testSetAndDeleteRecordHookGas",
"name": "change a record on a table with keysInTableModule installed",
"gasUsed": 21205
"gasUsed": 21211
},
{
"file": "test/KeysInTableModule.t.sol",
"test": "testSetAndDeleteRecordHookGas",
"name": "delete a record on a table with keysInTableModule installed",
"gasUsed": 85160
"gasUsed": 85214
},
{
"file": "test/KeysWithValueModule.t.sol",
"test": "testGetKeysWithValueGas",
"name": "install keys with value module",
"gasUsed": 684459
"gasUsed": 683905
},
{
"file": "test/KeysWithValueModule.t.sol",
Expand All @@ -153,79 +153,79 @@
"file": "test/KeysWithValueModule.t.sol",
"test": "testInstall",
"name": "install keys with value module",
"gasUsed": 684459
"gasUsed": 683905
},
{
"file": "test/KeysWithValueModule.t.sol",
"test": "testInstall",
"name": "set a record on a table with KeysWithValueModule installed",
"gasUsed": 135410
"gasUsed": 135440
},
{
"file": "test/KeysWithValueModule.t.sol",
"test": "testSetAndDeleteRecordHook",
"name": "install keys with value module",
"gasUsed": 684459
"gasUsed": 683905
},
{
"file": "test/KeysWithValueModule.t.sol",
"test": "testSetAndDeleteRecordHook",
"name": "change a record on a table with KeysWithValueModule installed",
"gasUsed": 103813
"gasUsed": 103843
},
{
"file": "test/KeysWithValueModule.t.sol",
"test": "testSetAndDeleteRecordHook",
"name": "delete a record on a table with KeysWithValueModule installed",
"gasUsed": 36468
"gasUsed": 36486
},
{
"file": "test/KeysWithValueModule.t.sol",
"test": "testSetField",
"name": "install keys with value module",
"gasUsed": 684459
"gasUsed": 683905
},
{
"file": "test/KeysWithValueModule.t.sol",
"test": "testSetField",
"name": "set a field on a table with KeysWithValueModule installed",
"gasUsed": 146645
"gasUsed": 146675
},
{
"file": "test/KeysWithValueModule.t.sol",
"test": "testSetField",
"name": "change a field on a table with KeysWithValueModule installed",
"gasUsed": 111404
"gasUsed": 111434
},
{
"file": "test/query.t.sol",
"test": "testCombinedHasHasValueNotQuery",
"name": "CombinedHasHasValueNotQuery",
"gasUsed": 104500
"gasUsed": 104518
},
{
"file": "test/query.t.sol",
"test": "testCombinedHasHasValueQuery",
"name": "CombinedHasHasValueQuery",
"gasUsed": 53210
"gasUsed": 53216
},
{
"file": "test/query.t.sol",
"test": "testCombinedHasNotQuery",
"name": "CombinedHasNotQuery",
"gasUsed": 130734
"gasUsed": 130764
},
{
"file": "test/query.t.sol",
"test": "testCombinedHasQuery",
"name": "CombinedHasQuery",
"gasUsed": 84137
"gasUsed": 84161
},
{
"file": "test/query.t.sol",
"test": "testCombinedHasValueNotQuery",
"name": "CombinedHasValueNotQuery",
"gasUsed": 84673
"gasUsed": 84691
},
{
"file": "test/query.t.sol",
Expand All @@ -237,19 +237,19 @@
"file": "test/query.t.sol",
"test": "testHasQuery",
"name": "HasQuery",
"gasUsed": 18802
"gasUsed": 18808
},
{
"file": "test/query.t.sol",
"test": "testHasQuery1000Keys",
"name": "HasQuery with 1000 keys",
"gasUsed": 5764585
"gasUsed": 5764591
},
{
"file": "test/query.t.sol",
"test": "testHasQuery100Keys",
"name": "HasQuery with 100 keys",
"gasUsed": 537538
"gasUsed": 537544
},
{
"file": "test/query.t.sol",
Expand All @@ -261,7 +261,7 @@
"file": "test/query.t.sol",
"test": "testNotValueQuery",
"name": "NotValueQuery",
"gasUsed": 46806
"gasUsed": 46812
},
{
"file": "test/StandardDelegationsModule.t.sol",
Expand Down Expand Up @@ -303,24 +303,24 @@
"file": "test/UniqueEntityModule.t.sol",
"test": "testInstall",
"name": "install unique entity module",
"gasUsed": 704219
"gasUsed": 703658
},
{
"file": "test/UniqueEntityModule.t.sol",
"test": "testInstall",
"name": "get a unique entity nonce (non-root module)",
"gasUsed": 50365
"gasUsed": 50371
},
{
"file": "test/UniqueEntityModule.t.sol",
"test": "testInstallRoot",
"name": "installRoot unique entity module",
"gasUsed": 673145
"gasUsed": 672531
},
{
"file": "test/UniqueEntityModule.t.sol",
"test": "testInstallRoot",
"name": "get a unique entity nonce (root module)",
"gasUsed": 50368
"gasUsed": 50374
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ contract ERC20Module is Module {

function install(bytes memory args) public {
// Require the module to not be installed with these args yet
requireNotInstalled(address(this), args);
requireNotInstalled(__self, args);

// Extract args
(bytes14 namespace, ERC20MetadataData memory metadata) = abi.decode(args, (bytes14, ERC20MetadataData));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ contract ERC721Module is Module {

function install(bytes memory args) public {
// Require the module to not be installed with these args yet
requireNotInstalled(address(this), args);
requireNotInstalled(__self, args);

// Extract args
(bytes14 namespace, ERC721MetadataData memory metadata) = abi.decode(args, (bytes14, ERC721MetadataData));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ contract KeysInTableModule is Module {
function installRoot(bytes memory args) public override {
// Naive check to ensure this is only installed once
// TODO: only revert if there's nothing to do
requireNotInstalled(address(this), args);
requireNotInstalled(__self, args);

// Extract source table id from args
ResourceId sourceTableId = ResourceId.wrap(abi.decode(args, (bytes32)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ contract KeysWithValueModule is Module {
function installRoot(bytes memory args) public {
// Naive check to ensure this is only installed once
// TODO: only revert if there's nothing to do
requireNotInstalled(address(this), args);
requireNotInstalled(__self, args);

// Extract source table id from args
ResourceId sourceTableId = ResourceId.wrap(abi.decode(args, (bytes32)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ contract UniqueEntityModule is Module {
function installRoot(bytes memory args) public {
// Naive check to ensure this is only installed once
// TODO: only revert if there's nothing to do
requireNotInstalled(address(this), args);
requireNotInstalled(__self, args);

IBaseWorld world = IBaseWorld(_world());

Expand Down Expand Up @@ -54,7 +54,7 @@ contract UniqueEntityModule is Module {
function install(bytes memory args) public {
// Naive check to ensure this is only installed once
// TODO: only revert if there's nothing to do
requireNotInstalled(address(this), args);
requireNotInstalled(__self, args);

IBaseWorld world = IBaseWorld(_world());

Expand Down
2 changes: 2 additions & 0 deletions packages/world/src/Module.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { InstalledModules } from "./codegen/tables/InstalledModules.sol";
* @dev Abstract contract that implements the ERC-165 supportsInterface function for IModule.
*/
abstract contract Module is IModule, WorldContextConsumer {
address internal immutable __self = address(this);

/**
* @notice Checks if the given interfaceId is supported by this contract.
* @dev Overrides the functionality from IERC165 and WorldContextConsumer to check for supported interfaces.
Expand Down

0 comments on commit 6a517cd

Please sign in to comment.