diff options
Diffstat (limited to 'packages/contracts/src')
2 files changed, 5 insertions, 72 deletions
diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/proxies/ERC20Proxy.sol b/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/proxies/ERC20Proxy.sol index b327eb7b6..e785bd26d 100644 --- a/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/proxies/ERC20Proxy.sol +++ b/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/proxies/ERC20Proxy.sol @@ -42,39 +42,9 @@ contract ERC20Proxy is external onlyAuthorized { - address token = decodeMetadata(assetMetadata); + require(assetMetadata.length == 21); + address token = readAddress(assetMetadata, 1); bool success = ERC20Token(token).transferFrom(from, to, amount); require(success == true); } - - /// @dev Decodes ERC20-encoded byte array. - /// @param assetMetadata ERC20-encoded byte array. - /// @return tokenAddress Address of ERC20 token. - function decodeMetadata(bytes memory assetMetadata) - public pure - returns (address tokenAddress) - { - require(assetMetadata.length == 21); - return readAddress(assetMetadata, 1); - } - - /// @dev Encodes ERC20 byte array. - /// @param assetProxyId Id of the asset proxy. - /// @param tokenAddress Address of the asset. - /// @return assetMetadata ERC20-encoded byte. - function encodeMetadata( - uint8 assetProxyId, - address tokenAddress) - public pure - returns (bytes memory assetMetadata) - { - // 0 is reserved as invalid proxy id - require(assetProxyId != 0); - - // Encode fields into a byte array - assetMetadata = new bytes(21); - assetMetadata[0] = byte(assetProxyId); - writeAddress(assetMetadata, 1, tokenAddress); - return assetMetadata; - } } 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 404d1ca6e..9021acd40 100644 --- a/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/proxies/ERC721Proxy.sol +++ b/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/proxies/ERC721Proxy.sol @@ -46,50 +46,13 @@ contract ERC721Proxy is require(amount == 1); // Decode metadata - address token; - uint256 tokenId; - (token, tokenId) = decodeMetadata(assetMetadata); + require(assetMetadata.length == 53); + address token = readAddress(assetMetadata, 1); + uint256 tokenId = readUint256(assetMetadata, 21); // Either succeeds or throws. // @TODO: Call safeTransferFrom if there is additional // data stored in `assetMetadata`. ERC721Token(token).transferFrom(from, to, tokenId); } - - /// @dev Decodes ERC721-encoded byte array. - /// @param assetMetadata ERC721-encoded byte array. - /// @return tokenAddress Address of ERC721 token. - /// @return tokenId Id of ERC721 token. - function decodeMetadata(bytes memory assetMetadata) - public pure - returns (address tokenAddress, uint256 tokenId) - { - require(assetMetadata.length == 53); - tokenAddress = readAddress(assetMetadata, 1); - tokenId = readUint256(assetMetadata, 21); - return (tokenAddress, tokenId); - } - - /// @dev Encodes ERC721 byte array. - /// @param assetProxyId Id of the asset proxy. - /// @param tokenAddress Address of the asset. - /// @param tokenId Id of ERC721 token. - /// @return assetMetadata ERC721-encoded byte array. - function encodeMetadata( - uint8 assetProxyId, - address tokenAddress, - uint256 tokenId) - public pure - returns (bytes memory assetMetadata) - { - // 0 is reserved as invalid proxy id - require(assetProxyId != 0); - - // Encode fields into a byte array - assetMetadata = new bytes(53); - assetMetadata[0] = byte(assetProxyId); - writeAddress(assetMetadata, 1, tokenAddress); - writeUint256(assetMetadata, 21, tokenId); - return assetMetadata; - } } |