diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2018-04-14 01:34:08 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2018-04-21 04:56:18 +0800 |
commit | 7ab54421630a95d5b646982d1bcc4a9d318f5c6c (patch) | |
tree | 6d681e15a4cb72f8c2622ae706eaeb3203669ae3 /packages/contracts | |
parent | 4d42f64fa333e897774bc6241db1bf8f8937acdd (diff) | |
download | dexon-0x-contracts-7ab54421630a95d5b646982d1bcc4a9d318f5c6c.tar.gz dexon-0x-contracts-7ab54421630a95d5b646982d1bcc4a9d318f5c6c.tar.zst dexon-0x-contracts-7ab54421630a95d5b646982d1bcc4a9d318f5c6c.zip |
Reverted to calling read/write uint256
Diffstat (limited to 'packages/contracts')
-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)); + } } |