Renamed addAssetProxy back to registerAssetProxy; this seemed to cause less confusion. Also updated the function description.
This commit is contained in:
committed by
Amir Bandeali
parent
ac0c35424b
commit
ab13ce96cc
@@ -24,9 +24,9 @@ import "../../utils/Ownable/Ownable.sol";
|
||||
import "../../utils/Authorizable/Authorizable.sol";
|
||||
|
||||
contract AssetProxyDispatcher is
|
||||
IAssetProxyDispatcher,
|
||||
Ownable,
|
||||
Authorizable
|
||||
Authorizable,
|
||||
IAssetProxyDispatcher
|
||||
{
|
||||
// Mapping from Asset Proxy Id's to their respective Asset Proxy
|
||||
mapping (uint8 => IAssetProxy) public assetProxies;
|
||||
@@ -53,11 +53,13 @@ contract AssetProxyDispatcher is
|
||||
assetProxy.transferFrom(assetMetadata, from, to, amount);
|
||||
}
|
||||
|
||||
/// @dev Adds a new asset proxy.
|
||||
/// @param assetProxyId Id of the asset proxy.
|
||||
/// @param newAssetProxy Asset proxy contract to add, or 0x0 to unset assetProxyId.
|
||||
/// @dev Registers an asset proxy to an asset proxy id.
|
||||
/// An id can only be assigned to a single proxy at a given time,
|
||||
/// however, an asset proxy may be registered to multiple ids.
|
||||
/// @param assetProxyId Id to register`newAssetProxy` under.
|
||||
/// @param newAssetProxy asset proxy to register, or 0x0 to unset assetProxyId.
|
||||
/// @param currentAssetProxy Existing asset proxy to overwrite, or 0x0 if assetProxyId is currently unused.
|
||||
function addAssetProxy(
|
||||
function registerAssetProxy(
|
||||
uint8 assetProxyId,
|
||||
IAssetProxy newAssetProxy,
|
||||
IAssetProxy currentAssetProxy)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
pragma solidity ^0.4.21;
|
||||
|
||||
import "../../../utils/Authorizable/IAuthorizable.sol";
|
||||
import "../../utils/Authorizable/IAuthorizable.sol";
|
||||
|
||||
contract IAssetProxy is IAuthorizable {
|
||||
|
||||
|
||||
@@ -35,11 +35,13 @@ contract IAssetProxyDispatcher is
|
||||
IAssetProxy oldAssetClassAddress
|
||||
);
|
||||
|
||||
/// @dev Adds a new asset proxy.
|
||||
/// @param assetProxyId Id of the asset proxy.
|
||||
/// @param newAssetProxy Asset proxy contract to add, or 0x0 to unset assetProxyId.
|
||||
/// @dev Registers an asset proxy to an asset proxy id.
|
||||
/// An id can only be assigned to a single proxy at a given time,
|
||||
/// however, an asset proxy may be registered to multiple ids.
|
||||
/// @param assetProxyId Id to register`newAssetProxy` under.
|
||||
/// @param newAssetProxy asset proxy to register, or 0x0 to unset assetProxyId.
|
||||
/// @param currentAssetProxy Existing asset proxy to overwrite, or 0x0 if assetProxyId is currently unused.
|
||||
function addAssetProxy(
|
||||
function registerAssetProxy(
|
||||
uint8 assetProxyId,
|
||||
IAssetProxy newAssetProxy,
|
||||
IAssetProxy currentAssetProxy)
|
||||
|
||||
@@ -86,10 +86,10 @@ describe('AssetProxyDispatcher', () => {
|
||||
afterEach(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
describe('addAssetProxy', () => {
|
||||
describe('registerAssetProxy', () => {
|
||||
it('should record proxy upon registration', async () => {
|
||||
const prevProxyAddress = ZeroEx.NULL_ADDRESS;
|
||||
await assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
|
||||
await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
|
||||
AssetProxyId.ERC20,
|
||||
erc20Proxy.address,
|
||||
prevProxyAddress,
|
||||
@@ -102,7 +102,7 @@ describe('AssetProxyDispatcher', () => {
|
||||
it('should be able to record multiple proxies', async () => {
|
||||
// Record first proxy
|
||||
const prevERC20ProxyAddress = ZeroEx.NULL_ADDRESS;
|
||||
await assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
|
||||
await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
|
||||
AssetProxyId.ERC20,
|
||||
erc20Proxy.address,
|
||||
prevERC20ProxyAddress,
|
||||
@@ -112,7 +112,7 @@ describe('AssetProxyDispatcher', () => {
|
||||
expect(proxyAddress).to.be.equal(erc20Proxy.address);
|
||||
// Record another proxy
|
||||
const prevERC721ProxyAddress = ZeroEx.NULL_ADDRESS;
|
||||
await assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
|
||||
await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
|
||||
AssetProxyId.ERC721,
|
||||
erc721Proxy.address,
|
||||
prevERC721ProxyAddress,
|
||||
@@ -125,7 +125,7 @@ describe('AssetProxyDispatcher', () => {
|
||||
it('should replace proxy address upon re-registration', async () => {
|
||||
// Initial registration
|
||||
const prevProxyAddress = ZeroEx.NULL_ADDRESS;
|
||||
await assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
|
||||
await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
|
||||
AssetProxyId.ERC20,
|
||||
erc20Proxy.address,
|
||||
prevProxyAddress,
|
||||
@@ -143,7 +143,7 @@ describe('AssetProxyDispatcher', () => {
|
||||
// Register new ERC20 Transfer Proxy contract
|
||||
const newAddress = newErc20TransferProxy.address;
|
||||
const currentAddress = erc20Proxy.address;
|
||||
await assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
|
||||
await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
|
||||
AssetProxyId.ERC20,
|
||||
newAddress,
|
||||
currentAddress,
|
||||
@@ -157,7 +157,7 @@ describe('AssetProxyDispatcher', () => {
|
||||
it('should throw if registering with incorrect "currentAssetProxyAddress" field', async () => {
|
||||
// Initial registration
|
||||
const prevProxyAddress = ZeroEx.NULL_ADDRESS;
|
||||
await assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
|
||||
await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
|
||||
AssetProxyId.ERC20,
|
||||
erc20Proxy.address,
|
||||
prevProxyAddress,
|
||||
@@ -167,7 +167,7 @@ describe('AssetProxyDispatcher', () => {
|
||||
expect(proxyAddress).to.be.equal(erc20Proxy.address);
|
||||
// The following transaction will throw because the currentAddress is no longer ZeroEx.NULL_ADDRESS
|
||||
return expect(
|
||||
assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
|
||||
assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
|
||||
AssetProxyId.ERC20,
|
||||
erc20Proxy.address,
|
||||
ZeroEx.NULL_ADDRESS,
|
||||
@@ -179,7 +179,7 @@ describe('AssetProxyDispatcher', () => {
|
||||
it('should be able to reset proxy address to NULL', async () => {
|
||||
// Initial registration
|
||||
const prevProxyAddress = ZeroEx.NULL_ADDRESS;
|
||||
await assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
|
||||
await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
|
||||
AssetProxyId.ERC20,
|
||||
erc20Proxy.address,
|
||||
prevProxyAddress,
|
||||
@@ -189,7 +189,7 @@ describe('AssetProxyDispatcher', () => {
|
||||
expect(proxyAddress).to.be.equal(erc20Proxy.address);
|
||||
// The following transaction will reset the proxy address
|
||||
const newProxyAddress = ZeroEx.NULL_ADDRESS;
|
||||
await assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
|
||||
await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
|
||||
AssetProxyId.ERC20,
|
||||
newProxyAddress,
|
||||
erc20Proxy.address,
|
||||
@@ -202,7 +202,7 @@ describe('AssetProxyDispatcher', () => {
|
||||
it('should throw if requesting address is not owner', async () => {
|
||||
const prevProxyAddress = ZeroEx.NULL_ADDRESS;
|
||||
return expect(
|
||||
assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
|
||||
assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
|
||||
AssetProxyId.ERC20,
|
||||
erc20Proxy.address,
|
||||
prevProxyAddress,
|
||||
@@ -215,7 +215,7 @@ describe('AssetProxyDispatcher', () => {
|
||||
describe('getAssetProxy', () => {
|
||||
it('should return correct address of registered proxy', async () => {
|
||||
const prevProxyAddress = ZeroEx.NULL_ADDRESS;
|
||||
await assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
|
||||
await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
|
||||
AssetProxyId.ERC20,
|
||||
erc20Proxy.address,
|
||||
prevProxyAddress,
|
||||
@@ -235,7 +235,7 @@ describe('AssetProxyDispatcher', () => {
|
||||
it('should dispatch transfer to registered proxy', async () => {
|
||||
// Register ERC20 proxy
|
||||
const prevProxyAddress = ZeroEx.NULL_ADDRESS;
|
||||
await assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
|
||||
await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
|
||||
AssetProxyId.ERC20,
|
||||
erc20Proxy.address,
|
||||
prevProxyAddress,
|
||||
@@ -283,7 +283,7 @@ describe('AssetProxyDispatcher', () => {
|
||||
it('should throw on transfer if requesting address is not authorized', async () => {
|
||||
// Register ERC20 proxy
|
||||
const prevProxyAddress = ZeroEx.NULL_ADDRESS;
|
||||
await assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
|
||||
await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
|
||||
AssetProxyId.ERC20,
|
||||
erc20Proxy.address,
|
||||
prevProxyAddress,
|
||||
|
||||
@@ -108,7 +108,7 @@ describe('Exchange', () => {
|
||||
from: owner,
|
||||
});
|
||||
const prevERC20ProxyAddress = ZeroEx.NULL_ADDRESS;
|
||||
await assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
|
||||
await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
|
||||
AssetProxyId.ERC20,
|
||||
erc20Proxy.address,
|
||||
prevERC20ProxyAddress,
|
||||
@@ -121,7 +121,7 @@ describe('Exchange', () => {
|
||||
from: owner,
|
||||
});
|
||||
const prevERC721ProxyAddress = ZeroEx.NULL_ADDRESS;
|
||||
await assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
|
||||
await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
|
||||
AssetProxyId.ERC721,
|
||||
erc721Proxy.address,
|
||||
prevERC721ProxyAddress,
|
||||
|
||||
@@ -89,7 +89,7 @@ describe('Exchange', () => {
|
||||
from: owner,
|
||||
});
|
||||
const prevERC20ProxyAddress = ZeroEx.NULL_ADDRESS;
|
||||
await assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
|
||||
await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
|
||||
AssetProxyId.ERC20,
|
||||
erc20Proxy.address,
|
||||
prevERC20ProxyAddress,
|
||||
@@ -102,7 +102,7 @@ describe('Exchange', () => {
|
||||
from: owner,
|
||||
});
|
||||
const prevERC721ProxyAddress = ZeroEx.NULL_ADDRESS;
|
||||
await assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
|
||||
await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
|
||||
AssetProxyId.ERC721,
|
||||
erc721Proxy.address,
|
||||
prevERC721ProxyAddress,
|
||||
|
||||
Reference in New Issue
Block a user