Skip to content

Commit

Permalink
fix(world-modules): token modules always register namespace (#2352)
Browse files Browse the repository at this point in the history
Co-authored-by: Kevin Ingersoll <kingersoll@gmail.com>
  • Loading branch information
yonadaaa and holic committed Mar 1, 2024
1 parent 5926765 commit 4be22ba
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/dull-otters-smash.md
@@ -0,0 +1,5 @@
---
"@latticexyz/world-modules": patch
---

ERC20 and ERC721 implementations now always register the token namespace, instead of checking if it has already been registered. This prevents issues with registering the namespace beforehand, namely that only the owner of a system can create a puppet for it.
Expand Up @@ -75,9 +75,7 @@ contract ERC20ModuleRegistrationLibrary {
function register(IBaseWorld world, bytes14 namespace) public {
// Register the namespace if it doesn't exist yet
ResourceId tokenNamespace = WorldResourceIdLib.encodeNamespace(namespace);
if (!ResourceIds.getExists(tokenNamespace)) {
world.registerNamespace(tokenNamespace);
}
world.registerNamespace(tokenNamespace);

// Register the tables
Allowances.register(_allowancesTableId(namespace));
Expand Down
Expand Up @@ -79,9 +79,7 @@ contract ERC721ModuleRegistrationLibrary {
function register(IBaseWorld world, bytes14 namespace) public {
// Register the namespace if it doesn't exist yet
ResourceId tokenNamespace = WorldResourceIdLib.encodeNamespace(namespace);
if (!ResourceIds.getExists(tokenNamespace)) {
world.registerNamespace(tokenNamespace);
}
world.registerNamespace(tokenNamespace);

// Register the tables
OperatorApproval.register(_operatorApprovalTableId(namespace));
Expand Down

0 comments on commit 4be22ba

Please sign in to comment.