From 6a517cd94f039e5efb64177c0f259c470f2a0e87 Mon Sep 17 00:00:00 2001 From: Fraser Scott Date: Mon, 22 Jan 2024 13:47:54 +0000 Subject: [PATCH] fix: world modules --- packages/world-modules/gas-report.json | 88 +++++++++---------- .../src/modules/erc20-puppet/ERC20Module.sol | 2 +- .../modules/erc721-puppet/ERC721Module.sol | 2 +- .../modules/keysintable/KeysInTableModule.sol | 2 +- .../keyswithvalue/KeysWithValueModule.sol | 2 +- .../uniqueentity/UniqueEntityModule.sol | 4 +- packages/world/src/Module.sol | 2 + 7 files changed, 52 insertions(+), 50 deletions(-) diff --git a/packages/world-modules/gas-report.json b/packages/world-modules/gas-report.json index 33c0de667b..afb2a6d2dc 100644 --- a/packages/world-modules/gas-report.json +++ b/packages/world-modules/gas-report.json @@ -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", @@ -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", @@ -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", @@ -261,7 +261,7 @@ "file": "test/query.t.sol", "test": "testNotValueQuery", "name": "NotValueQuery", - "gasUsed": 46806 + "gasUsed": 46812 }, { "file": "test/StandardDelegationsModule.t.sol", @@ -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 } ] diff --git a/packages/world-modules/src/modules/erc20-puppet/ERC20Module.sol b/packages/world-modules/src/modules/erc20-puppet/ERC20Module.sol index 2d0055e968..343d03d2b3 100644 --- a/packages/world-modules/src/modules/erc20-puppet/ERC20Module.sol +++ b/packages/world-modules/src/modules/erc20-puppet/ERC20Module.sol @@ -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)); diff --git a/packages/world-modules/src/modules/erc721-puppet/ERC721Module.sol b/packages/world-modules/src/modules/erc721-puppet/ERC721Module.sol index 7e1a0b14f2..6852a69e34 100644 --- a/packages/world-modules/src/modules/erc721-puppet/ERC721Module.sol +++ b/packages/world-modules/src/modules/erc721-puppet/ERC721Module.sol @@ -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)); diff --git a/packages/world-modules/src/modules/keysintable/KeysInTableModule.sol b/packages/world-modules/src/modules/keysintable/KeysInTableModule.sol index a5a25d322b..4e61c0162d 100644 --- a/packages/world-modules/src/modules/keysintable/KeysInTableModule.sol +++ b/packages/world-modules/src/modules/keysintable/KeysInTableModule.sol @@ -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))); diff --git a/packages/world-modules/src/modules/keyswithvalue/KeysWithValueModule.sol b/packages/world-modules/src/modules/keyswithvalue/KeysWithValueModule.sol index a357a206d9..d380eb8081 100644 --- a/packages/world-modules/src/modules/keyswithvalue/KeysWithValueModule.sol +++ b/packages/world-modules/src/modules/keyswithvalue/KeysWithValueModule.sol @@ -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))); diff --git a/packages/world-modules/src/modules/uniqueentity/UniqueEntityModule.sol b/packages/world-modules/src/modules/uniqueentity/UniqueEntityModule.sol index b8f8f93980..c104843bbf 100644 --- a/packages/world-modules/src/modules/uniqueentity/UniqueEntityModule.sol +++ b/packages/world-modules/src/modules/uniqueentity/UniqueEntityModule.sol @@ -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()); @@ -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()); diff --git a/packages/world/src/Module.sol b/packages/world/src/Module.sol index 0f753fa0b9..5a4e896576 100644 --- a/packages/world/src/Module.sol +++ b/packages/world/src/Module.sol @@ -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.