Skip to content

Commit

Permalink
fix(world-modules): rename token address fields (#1986)
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Dec 1, 2023
1 parent 6bae338 commit 747d8d1
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 52 deletions.
5 changes: 5 additions & 0 deletions .changeset/spotty-geese-yawn.md
@@ -0,0 +1,5 @@
---
"@latticexyz/world-modules": patch
---

Renamed token address fields in ERC20 and ERC721 modules to `tokenAddress`
4 changes: 2 additions & 2 deletions packages/world-modules/mud.config.ts
Expand Up @@ -171,7 +171,7 @@ export default mudConfig({
namespaceId: "ResourceId",
},
valueSchema: {
erc20Address: "address",
tokenAddress: "address",
},
tableIdArgument: true,
},
Expand Down Expand Up @@ -237,7 +237,7 @@ export default mudConfig({
namespaceId: "ResourceId",
},
valueSchema: {
erc20Address: "address",
tokenAddress: "address",
},
tableIdArgument: true,
},
Expand Down
Expand Up @@ -73,7 +73,7 @@ library ERC20Registry {
*/
function getFieldNames() internal pure returns (string[] memory fieldNames) {
fieldNames = new string[](1);
fieldNames[0] = "erc20Address";
fieldNames[0] = "tokenAddress";
}

/**
Expand All @@ -91,9 +91,9 @@ library ERC20Registry {
}

/**
* @notice Get erc20Address.
* @notice Get tokenAddress.
*/
function getErc20Address(ResourceId _tableId, ResourceId namespaceId) internal view returns (address erc20Address) {
function getTokenAddress(ResourceId _tableId, ResourceId namespaceId) internal view returns (address tokenAddress) {
bytes32[] memory _keyTuple = new bytes32[](1);
_keyTuple[0] = ResourceId.unwrap(namespaceId);

Expand All @@ -102,9 +102,9 @@ library ERC20Registry {
}

/**
* @notice Get erc20Address.
* @notice Get tokenAddress.
*/
function _getErc20Address(ResourceId _tableId, ResourceId namespaceId) internal view returns (address erc20Address) {
function _getTokenAddress(ResourceId _tableId, ResourceId namespaceId) internal view returns (address tokenAddress) {
bytes32[] memory _keyTuple = new bytes32[](1);
_keyTuple[0] = ResourceId.unwrap(namespaceId);

Expand All @@ -113,9 +113,9 @@ library ERC20Registry {
}

/**
* @notice Get erc20Address.
* @notice Get tokenAddress.
*/
function get(ResourceId _tableId, ResourceId namespaceId) internal view returns (address erc20Address) {
function get(ResourceId _tableId, ResourceId namespaceId) internal view returns (address tokenAddress) {
bytes32[] memory _keyTuple = new bytes32[](1);
_keyTuple[0] = ResourceId.unwrap(namespaceId);

Expand All @@ -124,9 +124,9 @@ library ERC20Registry {
}

/**
* @notice Get erc20Address.
* @notice Get tokenAddress.
*/
function _get(ResourceId _tableId, ResourceId namespaceId) internal view returns (address erc20Address) {
function _get(ResourceId _tableId, ResourceId namespaceId) internal view returns (address tokenAddress) {
bytes32[] memory _keyTuple = new bytes32[](1);
_keyTuple[0] = ResourceId.unwrap(namespaceId);

Expand All @@ -135,43 +135,43 @@ library ERC20Registry {
}

/**
* @notice Set erc20Address.
* @notice Set tokenAddress.
*/
function setErc20Address(ResourceId _tableId, ResourceId namespaceId, address erc20Address) internal {
function setTokenAddress(ResourceId _tableId, ResourceId namespaceId, address tokenAddress) internal {
bytes32[] memory _keyTuple = new bytes32[](1);
_keyTuple[0] = ResourceId.unwrap(namespaceId);

StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((erc20Address)), _fieldLayout);
StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((tokenAddress)), _fieldLayout);
}

/**
* @notice Set erc20Address.
* @notice Set tokenAddress.
*/
function _setErc20Address(ResourceId _tableId, ResourceId namespaceId, address erc20Address) internal {
function _setTokenAddress(ResourceId _tableId, ResourceId namespaceId, address tokenAddress) internal {
bytes32[] memory _keyTuple = new bytes32[](1);
_keyTuple[0] = ResourceId.unwrap(namespaceId);

StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((erc20Address)), _fieldLayout);
StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((tokenAddress)), _fieldLayout);
}

/**
* @notice Set erc20Address.
* @notice Set tokenAddress.
*/
function set(ResourceId _tableId, ResourceId namespaceId, address erc20Address) internal {
function set(ResourceId _tableId, ResourceId namespaceId, address tokenAddress) internal {
bytes32[] memory _keyTuple = new bytes32[](1);
_keyTuple[0] = ResourceId.unwrap(namespaceId);

StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((erc20Address)), _fieldLayout);
StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((tokenAddress)), _fieldLayout);
}

/**
* @notice Set erc20Address.
* @notice Set tokenAddress.
*/
function _set(ResourceId _tableId, ResourceId namespaceId, address erc20Address) internal {
function _set(ResourceId _tableId, ResourceId namespaceId, address tokenAddress) internal {
bytes32[] memory _keyTuple = new bytes32[](1);
_keyTuple[0] = ResourceId.unwrap(namespaceId);

StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((erc20Address)), _fieldLayout);
StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((tokenAddress)), _fieldLayout);
}

/**
Expand All @@ -198,8 +198,8 @@ library ERC20Registry {
* @notice Tightly pack static (fixed length) data using this table's schema.
* @return The static data, encoded into a sequence of bytes.
*/
function encodeStatic(address erc20Address) internal pure returns (bytes memory) {
return abi.encodePacked(erc20Address);
function encodeStatic(address tokenAddress) internal pure returns (bytes memory) {
return abi.encodePacked(tokenAddress);
}

/**
Expand All @@ -208,8 +208,8 @@ library ERC20Registry {
* @return The lengths of the dynamic fields (packed into a single bytes32 value).
* @return The dyanmic (variable length) data, encoded into a sequence of bytes.
*/
function encode(address erc20Address) internal pure returns (bytes memory, PackedCounter, bytes memory) {
bytes memory _staticData = encodeStatic(erc20Address);
function encode(address tokenAddress) internal pure returns (bytes memory, PackedCounter, bytes memory) {
bytes memory _staticData = encodeStatic(tokenAddress);

PackedCounter _encodedLengths;
bytes memory _dynamicData;
Expand Down
Expand Up @@ -73,7 +73,7 @@ library ERC721Registry {
*/
function getFieldNames() internal pure returns (string[] memory fieldNames) {
fieldNames = new string[](1);
fieldNames[0] = "erc20Address";
fieldNames[0] = "tokenAddress";
}

/**
Expand All @@ -91,9 +91,9 @@ library ERC721Registry {
}

/**
* @notice Get erc20Address.
* @notice Get tokenAddress.
*/
function getErc20Address(ResourceId _tableId, ResourceId namespaceId) internal view returns (address erc20Address) {
function getTokenAddress(ResourceId _tableId, ResourceId namespaceId) internal view returns (address tokenAddress) {
bytes32[] memory _keyTuple = new bytes32[](1);
_keyTuple[0] = ResourceId.unwrap(namespaceId);

Expand All @@ -102,9 +102,9 @@ library ERC721Registry {
}

/**
* @notice Get erc20Address.
* @notice Get tokenAddress.
*/
function _getErc20Address(ResourceId _tableId, ResourceId namespaceId) internal view returns (address erc20Address) {
function _getTokenAddress(ResourceId _tableId, ResourceId namespaceId) internal view returns (address tokenAddress) {
bytes32[] memory _keyTuple = new bytes32[](1);
_keyTuple[0] = ResourceId.unwrap(namespaceId);

Expand All @@ -113,9 +113,9 @@ library ERC721Registry {
}

/**
* @notice Get erc20Address.
* @notice Get tokenAddress.
*/
function get(ResourceId _tableId, ResourceId namespaceId) internal view returns (address erc20Address) {
function get(ResourceId _tableId, ResourceId namespaceId) internal view returns (address tokenAddress) {
bytes32[] memory _keyTuple = new bytes32[](1);
_keyTuple[0] = ResourceId.unwrap(namespaceId);

Expand All @@ -124,9 +124,9 @@ library ERC721Registry {
}

/**
* @notice Get erc20Address.
* @notice Get tokenAddress.
*/
function _get(ResourceId _tableId, ResourceId namespaceId) internal view returns (address erc20Address) {
function _get(ResourceId _tableId, ResourceId namespaceId) internal view returns (address tokenAddress) {
bytes32[] memory _keyTuple = new bytes32[](1);
_keyTuple[0] = ResourceId.unwrap(namespaceId);

Expand All @@ -135,43 +135,43 @@ library ERC721Registry {
}

/**
* @notice Set erc20Address.
* @notice Set tokenAddress.
*/
function setErc20Address(ResourceId _tableId, ResourceId namespaceId, address erc20Address) internal {
function setTokenAddress(ResourceId _tableId, ResourceId namespaceId, address tokenAddress) internal {
bytes32[] memory _keyTuple = new bytes32[](1);
_keyTuple[0] = ResourceId.unwrap(namespaceId);

StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((erc20Address)), _fieldLayout);
StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((tokenAddress)), _fieldLayout);
}

/**
* @notice Set erc20Address.
* @notice Set tokenAddress.
*/
function _setErc20Address(ResourceId _tableId, ResourceId namespaceId, address erc20Address) internal {
function _setTokenAddress(ResourceId _tableId, ResourceId namespaceId, address tokenAddress) internal {
bytes32[] memory _keyTuple = new bytes32[](1);
_keyTuple[0] = ResourceId.unwrap(namespaceId);

StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((erc20Address)), _fieldLayout);
StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((tokenAddress)), _fieldLayout);
}

/**
* @notice Set erc20Address.
* @notice Set tokenAddress.
*/
function set(ResourceId _tableId, ResourceId namespaceId, address erc20Address) internal {
function set(ResourceId _tableId, ResourceId namespaceId, address tokenAddress) internal {
bytes32[] memory _keyTuple = new bytes32[](1);
_keyTuple[0] = ResourceId.unwrap(namespaceId);

StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((erc20Address)), _fieldLayout);
StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((tokenAddress)), _fieldLayout);
}

/**
* @notice Set erc20Address.
* @notice Set tokenAddress.
*/
function _set(ResourceId _tableId, ResourceId namespaceId, address erc20Address) internal {
function _set(ResourceId _tableId, ResourceId namespaceId, address tokenAddress) internal {
bytes32[] memory _keyTuple = new bytes32[](1);
_keyTuple[0] = ResourceId.unwrap(namespaceId);

StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((erc20Address)), _fieldLayout);
StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((tokenAddress)), _fieldLayout);
}

/**
Expand All @@ -198,8 +198,8 @@ library ERC721Registry {
* @notice Tightly pack static (fixed length) data using this table's schema.
* @return The static data, encoded into a sequence of bytes.
*/
function encodeStatic(address erc20Address) internal pure returns (bytes memory) {
return abi.encodePacked(erc20Address);
function encodeStatic(address tokenAddress) internal pure returns (bytes memory) {
return abi.encodePacked(tokenAddress);
}

/**
Expand All @@ -208,8 +208,8 @@ library ERC721Registry {
* @return The lengths of the dynamic fields (packed into a single bytes32 value).
* @return The dyanmic (variable length) data, encoded into a sequence of bytes.
*/
function encode(address erc20Address) internal pure returns (bytes memory, PackedCounter, bytes memory) {
bytes memory _staticData = encodeStatic(erc20Address);
function encode(address tokenAddress) internal pure returns (bytes memory, PackedCounter, bytes memory) {
bytes memory _staticData = encodeStatic(tokenAddress);

PackedCounter _encodedLengths;
bytes memory _dynamicData;
Expand Down

0 comments on commit 747d8d1

Please sign in to comment.