Reverted to calling read/write uint256
This commit is contained in:
committed by
Amir Bandeali
parent
4d42f64fa3
commit
7ab5442163
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user