Skip to content

Commit

Permalink
use toTopic
Browse files Browse the repository at this point in the history
  • Loading branch information
alvrs committed Oct 31, 2023
1 parent 6e23f2a commit 26c6511
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { SystemRegistry } from "@latticexyz/world/src/codegen/tables/SystemRegis

import { AccessControlLib } from "../../utils/AccessControlLib.sol";
import { PuppetMaster } from "../puppet/PuppetMaster.sol";
import { toTopic } from "../puppet/utils.sol";
import { Balances } from "../tokens/tables/Balances.sol";

import { IERC721Mintable } from "./IERC721Mintable.sol";
Expand All @@ -19,7 +20,7 @@ import { Owners } from "./tables/Owners.sol";
import { TokenApproval } from "./tables/TokenApproval.sol";
import { TokenURI } from "./tables/TokenURI.sol";

import { _balancesTableId, _metadataTableId, _tokenUriTableId, _operatorApprovalTableId, _ownersTableId, _tokenApprovalTableId, _toBytes32 } from "./utils.sol";
import { _balancesTableId, _metadataTableId, _tokenUriTableId, _operatorApprovalTableId, _ownersTableId, _tokenApprovalTableId } from "./utils.sol";

contract ERC721System is IERC721Mintable, System, PuppetMaster {
using WorldResourceIdInstance for ResourceId;
Expand Down Expand Up @@ -297,7 +298,7 @@ contract ERC721System is IERC721Mintable, System, PuppetMaster {
Owners.set(_ownersTableId(_namespace()), tokenId, to);

// Emit Transfer event on puppet
puppet().log(Transfer.selector, _toBytes32(from), _toBytes32(to), _toBytes32(tokenId), new bytes(0));
puppet().log(Transfer.selector, toTopic(from), toTopic(to), toTopic(tokenId), new bytes(0));

return from;
}
Expand Down Expand Up @@ -450,7 +451,7 @@ contract ERC721System is IERC721Mintable, System, PuppetMaster {

if (emitEvent) {
// Emit Approval event on puppet
puppet().log(Approval.selector, _toBytes32(owner), _toBytes32(to), _toBytes32(tokenId), new bytes(0));
puppet().log(Approval.selector, toTopic(owner), toTopic(to), toTopic(tokenId), new bytes(0));
}
}

Expand All @@ -472,7 +473,7 @@ contract ERC721System is IERC721Mintable, System, PuppetMaster {
OperatorApproval.set(_operatorApprovalTableId(_namespace()), owner, operator, approved);

// Emit ApprovalForAll event on puppet
puppet().log(ApprovalForAll.selector, _toBytes32(owner), _toBytes32(operator), abi.encode(approved));
puppet().log(ApprovalForAll.selector, toTopic(owner), toTopic(operator), abi.encode(approved));
}

/**
Expand Down
8 changes: 0 additions & 8 deletions packages/world-modules/src/modules/erc721-puppet/utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ function _tokenUriTableId(bytes14 namespace) pure returns (ResourceId) {
return WorldResourceIdLib.encode({ typeId: RESOURCE_TABLE, namespace: namespace, name: TOKEN_URI_NAME });
}

function _toBytes32(address addr) pure returns (bytes32) {
return bytes32(uint256(uint160(addr)));
}

function _toBytes32(uint256 id) pure returns (bytes32) {
return bytes32(id);
}

function _erc721SystemId(bytes14 namespace) pure returns (ResourceId) {
return WorldResourceIdLib.encode({ typeId: RESOURCE_SYSTEM, namespace: namespace, name: ERC721_SYSTEM_NAME });
}

0 comments on commit 26c6511

Please sign in to comment.