diff options
-rw-r--r-- | packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/proxies/ERC721Proxy.sol | 4 | ||||
-rw-r--r-- | packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol | 26 |
2 files changed, 28 insertions, 2 deletions
diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/proxies/ERC721Proxy.sol b/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/proxies/ERC721Proxy.sol index abb709bd7..e9b2b90ba 100644 --- a/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/proxies/ERC721Proxy.sol +++ b/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/proxies/ERC721Proxy.sol @@ -67,7 +67,7 @@ contract ERC721Proxy is { require(assetMetadata.length == 53); tokenAddress = readAddress(assetMetadata, 1); - tokenId = uint256(readBytes32(assetMetadata, 21)); + tokenId = readUint256(assetMetadata, 21); return (tokenAddress, tokenId); } @@ -90,7 +90,7 @@ contract ERC721Proxy is assetMetadata = new bytes(53); assetMetadata[0] = byte(assetProxyId); writeAddress(assetMetadata, 1, tokenAddress); - writeBytes32(assetMetadata, 21, bytes32(tokenId)); + writeUint256(assetMetadata, 21, tokenId); return assetMetadata; } } diff --git a/packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol b/packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol index e3df66b11..ed65463db 100644 --- a/packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol +++ b/packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol @@ -123,4 +123,30 @@ contract LibBytes { mstore(add(b, index), input) } } + + /// @dev Reads a uint256 value from a position in a byte array. + /// @param b Byte array containing a uint256 value. + /// @param index Index in byte array of uint256 value. + /// @return uint256 value from byte array. + function readUint256( + bytes memory b, + uint256 index) + public pure + returns (uint256 result) + { + return uint256(readBytes32(b, index)); + } + + /// @dev Writes a uint256 into a specific position in a byte array. + /// @param b Byte array to insert <input> into. + /// @param index Index in byte array of <input>. + /// @param input uint256 to put into byte array. + function writeUint256( + bytes memory b, + uint256 index, + uint256 input) + public pure + { + writeBytes32(b, index, bytes32(input)); + } } |