diff options
5 files changed, 26 insertions, 28 deletions
diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/AssetProxyDispatcher.sol b/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/AssetProxyDispatcher.sol index bf5001575..4552bec43 100644 --- a/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/AssetProxyDispatcher.sol +++ b/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/AssetProxyDispatcher.sol @@ -24,14 +24,14 @@ import "../../utils/Ownable/Ownable.sol"; import "../../utils/Authorizable/Authorizable.sol"; contract AssetProxyDispatcher is + IAssetProxyDispatcher, Ownable, - Authorizable, - IAssetProxyDispatcher + Authorizable { // Mapping from Asset Proxy Id's to their respective Asset Proxy mapping (uint8 => IAssetProxy) public assetProxies; - /// @dev Delegates transfer to the corresponding asset proxy. + /// @dev Transfers assets. Either succeeds or throws. /// @param assetMetadata Byte array encoded for the respective asset proxy. /// @param from Address to transfer token from. /// @param to Address to transfer token to. @@ -49,14 +49,13 @@ contract AssetProxyDispatcher is uint8 assetProxyId = uint8(assetMetadata[0]); IAssetProxy assetProxy = assetProxies[assetProxyId]; - // Dispatch transfer to asset proxy // transferFrom will either succeed or throw. assetProxy.transferFrom(assetMetadata, from, to, amount); } /// @dev Adds a new asset proxy. /// @param assetProxyId Id of the asset proxy. - /// @param newAssetProxyAddress Address of the asset proxy contract to register. + /// @param newAssetProxyAddress Address of the asset proxy contract to add. /// @param currentAssetProxyAddress Address of existing asset proxy to overwrite. function addAssetProxy( uint8 assetProxyId, @@ -65,10 +64,10 @@ contract AssetProxyDispatcher is external onlyOwner { - // Ensure any existing asset proxy is not unintentionally overwritten + // Ensure the existing asset proxy is not unintentionally overwritten require(currentAssetProxyAddress == address(assetProxies[assetProxyId])); - // Store asset proxy and log registration + // Add asset proxy and log registration assetProxies[assetProxyId] = IAssetProxy(newAssetProxyAddress); emit AssetProxyChanged(assetProxyId, newAssetProxyAddress, currentAssetProxyAddress); } diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/IAssetProxyDispatcher.sol b/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/IAssetProxyDispatcher.sol index 534be6114..c21b945de 100644 --- a/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/IAssetProxyDispatcher.sol +++ b/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/IAssetProxyDispatcher.sol @@ -20,9 +20,8 @@ pragma solidity ^0.4.21; import "./IAssetProxy.sol"; -contract IAssetProxyDispatcher is - IAssetProxy -{ +contract IAssetProxyDispatcher { + // Logs registration of new asset proxy event AssetProxyChanged( uint8 id, @@ -32,7 +31,7 @@ contract IAssetProxyDispatcher is /// @dev Adds a new asset proxy. /// @param assetProxyId Id of the asset proxy. - /// @param newAssetProxyAddress Address of the asset proxy contract to register. + /// @param newAssetProxyAddress Address of the asset proxy contract to add. /// @param currentAssetProxyAddress Address of existing asset proxy to overwrite. function addAssetProxy( uint8 assetProxyId, 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 53fc64b69..66d9d9b4b 100644 --- a/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/proxies/ERC20Proxy.sol +++ b/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/proxies/ERC20Proxy.sol @@ -30,7 +30,7 @@ contract ERC20Proxy is { /// @dev Transfers ERC20 tokens. - /// @param assetMetadata Byte array encoded for the respective asset proxy. + /// @param assetMetadata ERC20-encoded byte array. /// @param from Address to transfer token from. /// @param to Address to transfer token to. /// @param amount Amount of token to transfer. @@ -47,10 +47,10 @@ contract ERC20Proxy is require(success == true); } - /// @dev Encodes ERC20 byte array for the ERC20 asset proxy. + /// @dev Encodes ERC20 byte array. /// @param assetProxyId Id of the asset proxy. /// @param tokenAddress Address of the asset. - /// @return assetMetadata Byte array encoded for the ERC20 asset proxy. + /// @return assetMetadata ERC20-encoded byte. function encodeMetadata( uint8 assetProxyId, address tokenAddress) @@ -67,8 +67,8 @@ contract ERC20Proxy is return assetMetadata; } - /// @dev Decodes ERC20-encoded byte array for the ERC20 asset proxy. - /// @param assetMetadata Byte array encoded for the ERC20 asset proxy. + /// @dev Decodes ERC20-encoded byte array. + /// @param assetMetadata ERC20-encoded byte array. /// @return tokenAddress Address of ERC20 token. function decodeMetadata(bytes assetMetadata) public pure diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/proxies/ERC20Proxy_v1.sol b/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/proxies/ERC20Proxy_v1.sol index 051257eb5..ba84a439c 100644 --- a/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/proxies/ERC20Proxy_v1.sol +++ b/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/proxies/ERC20Proxy_v1.sol @@ -56,10 +56,10 @@ contract ERC20Proxy_v1 is require(success == true); } - /// @dev Encodes ERC20 byte array for the ERC20 asset proxy. + /// @dev Encodes ERC20 byte array. /// @param assetProxyId Id of the asset proxy. /// @param tokenAddress Address of the asset. - /// @return assetMetadata Byte array encoded for the ERC20 asset proxy. + /// @return assetMetadata ERC20-encoded byte. function encodeMetadata( uint8 assetProxyId, address tokenAddress) @@ -76,10 +76,10 @@ contract ERC20Proxy_v1 is return assetMetadata; } - /// @dev Decodes ERC20-encoded byte array for the ERC20 asset proxy. - /// @param assetMetadata Byte array encoded for the ERC20 asset proxy. + /// @dev Decodes ERC20-encoded byte array. + /// @param assetMetadata ERC20-encoded byte array. /// @return tokenAddress Address of ERC20 token. - function decodeMetadata(bytes memory assetMetadata) + function decodeMetadata(bytes assetMetadata) public pure returns (address tokenAddress) { 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 a2b0ba101..8d6cf3202 100644 --- a/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/proxies/ERC721Proxy.sol +++ b/packages/contracts/src/contracts/current/protocol/AssetProxyDispatcher/proxies/ERC721Proxy.sol @@ -30,7 +30,7 @@ contract ERC721Proxy is { /// @dev Transfers ERC20 tokens. - /// @param assetMetadata Byte array encoded for the respective asset proxy. + /// @param assetMetadata ERC721-encoded byte array /// @param from Address to transfer token from. /// @param to Address to transfer token to. /// @param amount Amount of token to transfer. @@ -42,7 +42,7 @@ contract ERC721Proxy is external onlyAuthorized { - // No work to do + // No work to do if amount is zero if (amount == 0) return; // Decode metadata @@ -53,15 +53,15 @@ contract ERC721Proxy is // There exists only 1 of each token. require(amount == 1); - // Call ERC721 contract. Either succeeds or throws. + // Either succeeds or throws. ERC721Token(token).transferFrom(from, to, tokenId); } - /// @dev Encodes ERC721 byte array for the ERC20 asset proxy. + /// @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 Byte array encoded for the ERC721 asset proxy. + /// @return assetMetadata ERC721-encoded byte array. function encodeMetadata( uint8 assetProxyId, address tokenAddress, @@ -80,8 +80,8 @@ contract ERC721Proxy is return assetMetadata; } - /// @dev Decodes ERC721-encoded byte array for the ERC721 asset proxy. - /// @param assetMetadata Byte array encoded for the ERC721 asset proxy. + /// @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) |