Skip to content

Commit

Permalink
Merge branch 'main' into holic/function-selector-system-name
Browse files Browse the repository at this point in the history
  • Loading branch information
alvrs committed Jan 22, 2024
2 parents b179a1a + 52c37b5 commit b59e02f
Show file tree
Hide file tree
Showing 32 changed files with 508 additions and 187 deletions.
5 changes: 5 additions & 0 deletions .changeset/neat-tools-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/world": patch
---

Added a table to track the `CoreModule` address the world was initialised with.
1 change: 0 additions & 1 deletion packages/store-indexer/bin/postgres-decoded-indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ if (env.HEALTHCHECK_HOST != null || env.HEALTHCHECK_PORT != null) {
server.use(sentry(env.SENTRY_DSN));
}

server.use(cors());
server.use(cors());
server.use(
healthcheck({
Expand Down
28 changes: 14 additions & 14 deletions packages/world-modules/gas-report.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@
"file": "test/KeysInTableModule.t.sol",
"test": "testInstallComposite",
"name": "install keys in table module",
"gasUsed": 1438969
"gasUsed": 1438512
},
{
"file": "test/KeysInTableModule.t.sol",
"test": "testInstallGas",
"name": "install keys in table module",
"gasUsed": 1438969
"gasUsed": 1438512
},
{
"file": "test/KeysInTableModule.t.sol",
Expand All @@ -93,13 +93,13 @@
"file": "test/KeysInTableModule.t.sol",
"test": "testInstallSingleton",
"name": "install keys in table module",
"gasUsed": 1438969
"gasUsed": 1438512
},
{
"file": "test/KeysInTableModule.t.sol",
"test": "testSetAndDeleteRecordHookCompositeGas",
"name": "install keys in table module",
"gasUsed": 1438969
"gasUsed": 1438512
},
{
"file": "test/KeysInTableModule.t.sol",
Expand All @@ -117,7 +117,7 @@
"file": "test/KeysInTableModule.t.sol",
"test": "testSetAndDeleteRecordHookGas",
"name": "install keys in table module",
"gasUsed": 1438969
"gasUsed": 1438512
},
{
"file": "test/KeysInTableModule.t.sol",
Expand All @@ -135,7 +135,7 @@
"file": "test/KeysWithValueModule.t.sol",
"test": "testGetKeysWithValueGas",
"name": "install keys with value module",
"gasUsed": 684371
"gasUsed": 683899
},
{
"file": "test/KeysWithValueModule.t.sol",
Expand All @@ -153,7 +153,7 @@
"file": "test/KeysWithValueModule.t.sol",
"test": "testInstall",
"name": "install keys with value module",
"gasUsed": 684371
"gasUsed": 683899
},
{
"file": "test/KeysWithValueModule.t.sol",
Expand All @@ -165,7 +165,7 @@
"file": "test/KeysWithValueModule.t.sol",
"test": "testSetAndDeleteRecordHook",
"name": "install keys with value module",
"gasUsed": 684371
"gasUsed": 683899
},
{
"file": "test/KeysWithValueModule.t.sol",
Expand All @@ -183,7 +183,7 @@
"file": "test/KeysWithValueModule.t.sol",
"test": "testSetField",
"name": "install keys with value module",
"gasUsed": 684371
"gasUsed": 683899
},
{
"file": "test/KeysWithValueModule.t.sol",
Expand Down Expand Up @@ -267,7 +267,7 @@
"file": "test/StandardDelegationsModule.t.sol",
"test": "testCallFromCallboundDelegation",
"name": "register a callbound delegation",
"gasUsed": 118175
"gasUsed": 118198
},
{
"file": "test/StandardDelegationsModule.t.sol",
Expand All @@ -279,7 +279,7 @@
"file": "test/StandardDelegationsModule.t.sol",
"test": "testCallFromSystemDelegation",
"name": "register a systembound delegation",
"gasUsed": 115728
"gasUsed": 115751
},
{
"file": "test/StandardDelegationsModule.t.sol",
Expand All @@ -291,7 +291,7 @@
"file": "test/StandardDelegationsModule.t.sol",
"test": "testCallFromTimeboundDelegation",
"name": "register a timebound delegation",
"gasUsed": 112651
"gasUsed": 112674
},
{
"file": "test/StandardDelegationsModule.t.sol",
Expand All @@ -303,7 +303,7 @@
"file": "test/UniqueEntityModule.t.sol",
"test": "testInstall",
"name": "install unique entity module",
"gasUsed": 702338
"gasUsed": 701756
},
{
"file": "test/UniqueEntityModule.t.sol",
Expand All @@ -315,7 +315,7 @@
"file": "test/UniqueEntityModule.t.sol",
"test": "testInstallRoot",
"name": "installRoot unique entity module",
"gasUsed": 671242
"gasUsed": 670623
},
{
"file": "test/UniqueEntityModule.t.sol",
Expand Down
19 changes: 2 additions & 17 deletions packages/world-modules/src/modules/erc20-puppet/ERC20Module.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import { revertWithBytes } from "@latticexyz/world/src/revertWithBytes.sol";

import { Puppet } from "../puppet/Puppet.sol";
import { createPuppet } from "../puppet/createPuppet.sol";
import { MODULE_NAME as PUPPET_MODULE_NAME } from "../puppet/constants.sol";
import { Balances } from "../tokens/tables/Balances.sol";

import { MODULE_NAME, MODULE_NAMESPACE, MODULE_NAMESPACE_ID, ERC20_REGISTRY_TABLE_ID } from "./constants.sol";
import { MODULE_NAMESPACE, MODULE_NAMESPACE_ID, ERC20_REGISTRY_TABLE_ID } from "./constants.sol";
import { _allowancesTableId, _balancesTableId, _metadataTableId, _erc20SystemId } from "./utils.sol";
import { ERC20System } from "./ERC20System.sol";

Expand All @@ -26,20 +25,9 @@ contract ERC20Module is Module {

address immutable registrationLibrary = address(new ERC20ModuleRegistrationLibrary());

function getName() public pure override returns (bytes16) {
return MODULE_NAME;
}

function _requireDependencies() internal view {
// Require PuppetModule to be installed
if (!isInstalled(PUPPET_MODULE_NAME, new bytes(0))) {
revert Module_MissingDependency(string(bytes.concat(PUPPET_MODULE_NAME)));
}
}

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

// Extract args
(bytes14 namespace, ERC20MetadataData memory metadata) = abi.decode(args, (bytes14, ERC20MetadataData));
Expand All @@ -49,9 +37,6 @@ contract ERC20Module is Module {
revert ERC20Module_InvalidNamespace(namespace);
}

// Require dependencies
_requireDependencies();

// Register the ERC20 tables and system
IBaseWorld world = IBaseWorld(_world());
(bool success, bytes memory returnData) = registrationLibrary.delegatecall(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
import { RESOURCE_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol";
import { RESOURCE_SYSTEM, RESOURCE_NAMESPACE } from "@latticexyz/world/src/worldResourceTypes.sol";

bytes16 constant MODULE_NAME = "erc20-puppet";
bytes14 constant MODULE_NAMESPACE = "erc20-puppet";
ResourceId constant MODULE_NAMESPACE_ID = ResourceId.wrap(
bytes32(abi.encodePacked(RESOURCE_NAMESPACE, MODULE_NAMESPACE))
Expand Down
19 changes: 2 additions & 17 deletions packages/world-modules/src/modules/erc721-puppet/ERC721Module.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ import { revertWithBytes } from "@latticexyz/world/src/revertWithBytes.sol";

import { Puppet } from "../puppet/Puppet.sol";
import { createPuppet } from "../puppet/createPuppet.sol";
import { MODULE_NAME as PUPPET_MODULE_NAME } from "../puppet/constants.sol";
import { Balances } from "../tokens/tables/Balances.sol";

import { MODULE_NAME, MODULE_NAMESPACE, MODULE_NAMESPACE_ID, ERC721_REGISTRY_TABLE_ID } from "./constants.sol";
import { MODULE_NAMESPACE, MODULE_NAMESPACE_ID, ERC721_REGISTRY_TABLE_ID } from "./constants.sol";
import { _erc721SystemId, _balancesTableId, _metadataTableId, _tokenUriTableId, _operatorApprovalTableId, _ownersTableId, _tokenApprovalTableId } from "./utils.sol";
import { ERC721System } from "./ERC721System.sol";

Expand All @@ -30,20 +29,9 @@ contract ERC721Module is Module {

address immutable registrationLibrary = address(new ERC721ModuleRegistrationLibrary());

function getName() public pure override returns (bytes16) {
return MODULE_NAME;
}

function _requireDependencies() internal view {
// Require PuppetModule to be installed
if (!isInstalled(PUPPET_MODULE_NAME, new bytes(0))) {
revert Module_MissingDependency(string(bytes.concat(PUPPET_MODULE_NAME)));
}
}

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

// Extract args
(bytes14 namespace, ERC721MetadataData memory metadata) = abi.decode(args, (bytes14, ERC721MetadataData));
Expand All @@ -53,9 +41,6 @@ contract ERC721Module is Module {
revert ERC721Module_InvalidNamespace(namespace);
}

// Require dependencies
_requireDependencies();

// Register the ERC721 tables and system
IBaseWorld world = IBaseWorld(_world());
(bool success, bytes memory returnData) = registrationLibrary.delegatecall(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
import { RESOURCE_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol";
import { RESOURCE_SYSTEM, RESOURCE_NAMESPACE } from "@latticexyz/world/src/worldResourceTypes.sol";

bytes16 constant MODULE_NAME = "erc721-puppet";
bytes14 constant MODULE_NAMESPACE = "erc721-puppet";
ResourceId constant MODULE_NAMESPACE_ID = ResourceId.wrap(
bytes32(abi.encodePacked(RESOURCE_NAMESPACE, MODULE_NAMESPACE))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,10 @@ contract KeysInTableModule is Module {
// from the source table id (passed as argument to the hook methods)
KeysInTableHook private immutable hook = new KeysInTableHook();

function getName() public pure returns (bytes16) {
return bytes16("keysInTable");
}

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(getName(), 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 @@ -35,14 +35,10 @@ contract KeysWithValueModule is Module {
// from the source table id (passed as argument to the hook methods)
KeysWithValueHook private immutable hook = new KeysWithValueHook();

function getName() public pure returns (bytes16) {
return bytes16("index");
}

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(getName(), args);
requireNotInstalled(__self, args);

// Extract source table id from args
ResourceId sourceTableId = ResourceId.wrap(abi.decode(args, (bytes32)));
Expand Down
6 changes: 1 addition & 5 deletions packages/world-modules/src/modules/puppet/PuppetModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";

import { PuppetFactorySystem } from "./PuppetFactorySystem.sol";
import { PuppetDelegationControl } from "./PuppetDelegationControl.sol";
import { MODULE_NAME, PUPPET_DELEGATION, PUPPET_FACTORY, PUPPET_TABLE_ID, NAMESPACE_ID } from "./constants.sol";
import { PUPPET_DELEGATION, PUPPET_FACTORY, PUPPET_TABLE_ID, NAMESPACE_ID } from "./constants.sol";

import { PuppetRegistry } from "./tables/PuppetRegistry.sol";

Expand All @@ -23,10 +23,6 @@ contract PuppetModule is Module {
PuppetDelegationControl private immutable puppetDelegationControl = new PuppetDelegationControl();
PuppetFactorySystem private immutable puppetFactorySystem = new PuppetFactorySystem();

function getName() public pure returns (bytes16) {
return MODULE_NAME;
}

function installRoot(bytes memory) public {
IBaseWorld world = IBaseWorld(_world());

Expand Down
1 change: 0 additions & 1 deletion packages/world-modules/src/modules/puppet/constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { RESOURCE_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol";
import { RESOURCE_SYSTEM, RESOURCE_NAMESPACE } from "@latticexyz/world/src/worldResourceTypes.sol";
import { ROOT_NAMESPACE } from "@latticexyz/world/src/constants.sol";

bytes16 constant MODULE_NAME = bytes16("puppet");
bytes14 constant NAMESPACE = bytes14("puppet");

ResourceId constant NAMESPACE_ID = ResourceId.wrap(bytes32(abi.encodePacked(RESOURCE_NAMESPACE, NAMESPACE)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { revertWithBytes } from "@latticexyz/world/src/revertWithBytes.sol";
import { CallboundDelegationControl } from "./CallboundDelegationControl.sol";
import { SystemboundDelegationControl } from "./SystemboundDelegationControl.sol";
import { TimeboundDelegationControl } from "./TimeboundDelegationControl.sol";
import { MODULE_NAME, CALLBOUND_DELEGATION, SYSTEMBOUND_DELEGATION, TIMEBOUND_DELEGATION } from "./constants.sol";
import { CALLBOUND_DELEGATION, SYSTEMBOUND_DELEGATION, TIMEBOUND_DELEGATION } from "./constants.sol";

import { CallboundDelegations } from "./tables/CallboundDelegations.sol";
import { SystemboundDelegations } from "./tables/SystemboundDelegations.sol";
Expand All @@ -24,10 +24,6 @@ contract StandardDelegationsModule is Module {
SystemboundDelegationControl private immutable systemboundDelegationControl = new SystemboundDelegationControl();
TimeboundDelegationControl private immutable timeboundDelegationControl = new TimeboundDelegationControl();

function getName() public pure returns (bytes16) {
return MODULE_NAME;
}

function installRoot(bytes memory) public {
IBaseWorld world = IBaseWorld(_world());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
import { RESOURCE_SYSTEM } from "@latticexyz/world/src/worldResourceTypes.sol";
import { ROOT_NAMESPACE } from "@latticexyz/world/src/constants.sol";

bytes16 constant MODULE_NAME = bytes16("stddelegations.m");

// Callbound delegation
ResourceId constant CALLBOUND_DELEGATION = ResourceId.wrap(
bytes32(abi.encodePacked(RESOURCE_SYSTEM, ROOT_NAMESPACE, bytes16("callbound")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { revertWithBytes } from "@latticexyz/world/src/revertWithBytes.sol";
import { UniqueEntity } from "./tables/UniqueEntity.sol";
import { UniqueEntitySystem } from "./UniqueEntitySystem.sol";

import { MODULE_NAME, TABLE_ID, SYSTEM_ID, NAMESPACE_ID } from "./constants.sol";
import { TABLE_ID, SYSTEM_ID, NAMESPACE_ID } from "./constants.sol";

/**
* This module creates a table that stores a nonce, and
Expand All @@ -22,14 +22,10 @@ contract UniqueEntityModule is Module {
// known tables, we can deploy it once and register it in multiple Worlds.
UniqueEntitySystem private immutable uniqueEntitySystem = new UniqueEntitySystem();

function getName() public pure returns (bytes16) {
return MODULE_NAME;
}

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(getName(), args);
requireNotInstalled(__self, args);

IBaseWorld world = IBaseWorld(_world());

Expand Down Expand Up @@ -58,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(getName(), args);
requireNotInstalled(__self, args);

IBaseWorld world = IBaseWorld(_world());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { ResourceId } from "@latticexyz/world/src/WorldResourceId.sol";
import { RESOURCE_TABLE, RESOURCE_SYSTEM, RESOURCE_NAMESPACE } from "@latticexyz/world/src/worldResourceTypes.sol";

bytes14 constant NAMESPACE = bytes14("uniqueEntity");
bytes16 constant MODULE_NAME = bytes16("uniqueEntity");
bytes16 constant SYSTEM_NAME = bytes16("system");
bytes16 constant TABLE_NAME = bytes16("table");

Expand Down
Loading

0 comments on commit b59e02f

Please sign in to comment.