aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-04-14 01:34:08 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-04-21 04:56:18 +0800
commit7ab54421630a95d5b646982d1bcc4a9d318f5c6c (patch)
tree6d681e15a4cb72f8c2622ae706eaeb3203669ae3 /packages
parent4d42f64fa333e897774bc6241db1bf8f8937acdd (diff)
downloaddexon-sol-tools-7ab54421630a95d5b646982d1bcc4a9d318f5c6c.tar
dexon-sol-tools-7ab54421630a95d5b646982d1bcc4a9d318f5c6c.tar.gz
dexon-sol-tools-7ab54421630a95d5b646982d1bcc4a9d318f5c6c.tar.bz2
dexon-sol-tools-7ab54421630a95d5b646982d1bcc4a9d318f5c6c.tar.lz
dexon-sol-tools-7ab54421630a95d5b646982d1bcc4a9d318f5c6c.tar.xz
dexon-sol-tools-7ab54421630a95d5b646982d1bcc4a9d318f5c6c.tar.zst
dexon-sol-tools-7ab54421630a95d5b646982d1bcc4a9d318f5c6c.zip
Reverted to calling read/write uint256
Diffstat (limited to 'packages')
-rw-r--r--packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/proxies/ERC721Proxy.sol4
-rw-r--r--packages/contracts/src/contracts/current/utils/LibBytes/LibBytes.sol26
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));
+ }
}