aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contracts/src')
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/MixinAssetProxyDispatcher.sol43
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IAssetProxyDispatcher.sol14
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/libs/LibExchangeErrors.sol3
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/mixins/MAssetProxyDispatcher.sol5
-rw-r--r--packages/contracts/src/utils/core_combinatorial_utils.ts4
-rw-r--r--packages/contracts/src/utils/exchange_wrapper.ts16
6 files changed, 25 insertions, 60 deletions
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinAssetProxyDispatcher.sol b/packages/contracts/src/contracts/current/protocol/Exchange/MixinAssetProxyDispatcher.sol
index 520569185..9e9d88ce7 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinAssetProxyDispatcher.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/MixinAssetProxyDispatcher.sol
@@ -32,43 +32,28 @@ contract MixinAssetProxyDispatcher is
// Mapping from Asset Proxy Id's to their respective Asset Proxy
mapping (bytes4 => IAssetProxy) public assetProxies;
- /// @dev Registers an asset proxy to an asset proxy id.
- /// An id can only be assigned to a single proxy at a given time.
- /// @param assetProxyId Id to register`newAssetProxy` under.
- /// @param newAssetProxy Address of new asset proxy to register, or 0x0 to unset assetProxyId.
- /// @param oldAssetProxy Existing asset proxy to overwrite, or 0x0 if assetProxyId is currently unused.
- function registerAssetProxy(
- bytes4 assetProxyId,
- address newAssetProxy,
- address oldAssetProxy
- )
+ /// @dev Registers an asset proxy to its asset proxy id.
+ /// Once an asset proxy is registered, it cannot be unregistered.
+ /// @param assetProxy Address of new asset proxy to register.
+ function registerAssetProxy(address assetProxy)
external
onlyOwner
{
- // Ensure the existing asset proxy is not unintentionally overwritten
+ IAssetProxy assetProxyContract = IAssetProxy(assetProxy);
+
+ // Ensure that no asset proxy exists with current id.
+ bytes4 assetProxyId = assetProxyContract.getProxyId();
address currentAssetProxy = assetProxies[assetProxyId];
require(
- oldAssetProxy == currentAssetProxy,
- "ASSET_PROXY_MISMATCH"
+ currentAssetProxy == address(0),
+ "ASSET_PROXY_ALREADY_EXISTS"
);
- IAssetProxy assetProxy = IAssetProxy(newAssetProxy);
-
- // Ensure that the id of newAssetProxy matches the passed in assetProxyId, unless it is being reset to 0.
- if (newAssetProxy != address(0)) {
- bytes4 newAssetProxyId = assetProxy.getProxyId();
- require(
- newAssetProxyId == assetProxyId,
- "ASSET_PROXY_ID_MISMATCH"
- );
- }
-
// Add asset proxy and log registration.
- assetProxies[assetProxyId] = assetProxy;
- emit AssetProxySet(
+ assetProxies[assetProxyId] = assetProxyContract;
+ emit AssetProxyRegistered(
assetProxyId,
- newAssetProxy,
- oldAssetProxy
+ assetProxy
);
}
@@ -112,7 +97,7 @@ contract MixinAssetProxyDispatcher is
0xFFFFFFFF00000000000000000000000000000000000000000000000000000000
)
}
- IAssetProxy assetProxy = assetProxies[assetProxyId];
+ address assetProxy = assetProxies[assetProxyId];
// Ensure that assetProxy exists
require(
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IAssetProxyDispatcher.sol b/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IAssetProxyDispatcher.sol
index fa55dff00..66f3b5796 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IAssetProxyDispatcher.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/interfaces/IAssetProxyDispatcher.sol
@@ -20,16 +20,10 @@ pragma solidity ^0.4.24;
contract IAssetProxyDispatcher {
- /// @dev Registers an asset proxy to an asset proxy id.
- /// An id can only be assigned to a single proxy at a given time.
- /// @param assetProxyId Id to register`newAssetProxy` under.
- /// @param newAssetProxy Address of new asset proxy to register, or 0x0 to unset assetProxyId.
- /// @param oldAssetProxy Existing asset proxy to overwrite, or 0x0 if assetProxyId is currently unused.
- function registerAssetProxy(
- bytes4 assetProxyId,
- address newAssetProxy,
- address oldAssetProxy
- )
+ /// @dev Registers an asset proxy to its asset proxy id.
+ /// Once an asset proxy is registered, it cannot be unregistered.
+ /// @param assetProxy Address of new asset proxy to register.
+ function registerAssetProxy(address assetProxy)
external;
/// @dev Gets an asset proxy.
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/libs/LibExchangeErrors.sol b/packages/contracts/src/contracts/current/protocol/Exchange/libs/LibExchangeErrors.sol
index e37f41ada..01aa78a1d 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/libs/LibExchangeErrors.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/libs/LibExchangeErrors.sol
@@ -54,8 +54,7 @@ contract LibExchangeErrors {
string constant FAILED_EXECUTION = "FAILED_EXECUTION"; // Transaction execution failed.
/// registerAssetProxy errors ///
- string constant ASSET_PROXY_MISMATCH = "ASSET_PROXY_MISMATCH"; // oldAssetProxy proxy does not match currentAssetProxy.
- string constant ASSET_PROXY_ID_MISMATCH = "ASSET_PROXY_ID_MISMATCH"; // newAssetProxyId does not match given assetProxyId.
+ string constant ASSET_PROXY_ALREADY_EXISTS = "ASSET_PROXY_ALREADY_EXISTS"; // AssetProxy with same id already exists.
/// dispatchTransferFrom errors ///
string constant ASSET_PROXY_DOES_NOT_EXIST = "ASSET_PROXY_DOES_NOT_EXIST"; // No assetProxy registered at given id.
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MAssetProxyDispatcher.sol b/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MAssetProxyDispatcher.sol
index c2b506dcf..5bf59c6ce 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MAssetProxyDispatcher.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MAssetProxyDispatcher.sol
@@ -26,10 +26,9 @@ contract MAssetProxyDispatcher is
{
// Logs registration of new asset proxy
- event AssetProxySet(
+ event AssetProxyRegistered(
bytes4 id, // Id of new registered AssetProxy.
- address newAssetProxy, // Address of new registered AssetProxy.
- address oldAssetProxy // Address of AssetProxy that was overwritten at given id (or null address).
+ address assetProxy // Address of new registered AssetProxy.
);
/// @dev Forwards arguments to assetProxy and calls `transferFrom`. Either succeeds or throws.
diff --git a/packages/contracts/src/utils/core_combinatorial_utils.ts b/packages/contracts/src/utils/core_combinatorial_utils.ts
index 5b725fbe3..93f4fc79d 100644
--- a/packages/contracts/src/utils/core_combinatorial_utils.ts
+++ b/packages/contracts/src/utils/core_combinatorial_utils.ts
@@ -96,8 +96,8 @@ export async function coreCombinatorialUtilsFactoryAsync(
zrxAssetData,
);
const exchangeWrapper = new ExchangeWrapper(exchangeContract, provider);
- await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC20, erc20Proxy.address, ownerAddress);
- await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC721, erc721Proxy.address, ownerAddress);
+ await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, ownerAddress);
+ await exchangeWrapper.registerAssetProxyAsync(erc721Proxy.address, ownerAddress);
await web3Wrapper.awaitTransactionSuccessAsync(
await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeContract.address, {
diff --git a/packages/contracts/src/utils/exchange_wrapper.ts b/packages/contracts/src/utils/exchange_wrapper.ts
index ad68c8ff4..baf967065 100644
--- a/packages/contracts/src/utils/exchange_wrapper.ts
+++ b/packages/contracts/src/utils/exchange_wrapper.ts
@@ -1,12 +1,10 @@
-import { AssetProxyId, SignedOrder } from '@0xproject/types';
+import { SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
-import * as _ from 'lodash';
import { ExchangeContract } from '../generated_contract_wrappers/exchange';
-import { constants } from './constants';
import { formatters } from './formatters';
import { LogDecoder } from './log_decoder';
import { orderUtils } from './order_utils';
@@ -192,20 +190,10 @@ export class ExchangeWrapper {
return tx;
}
public async registerAssetProxyAsync(
- assetProxyId: AssetProxyId,
assetProxyAddress: string,
from: string,
- opts: { oldAssetProxyAddressIfExists?: string } = {},
): Promise<TransactionReceiptWithDecodedLogs> {
- const oldAssetProxyAddress = _.isUndefined(opts.oldAssetProxyAddressIfExists)
- ? constants.NULL_ADDRESS
- : opts.oldAssetProxyAddressIfExists;
- const txHash = await this._exchange.registerAssetProxy.sendTransactionAsync(
- assetProxyId,
- assetProxyAddress,
- oldAssetProxyAddress,
- { from },
- );
+ const txHash = await this._exchange.registerAssetProxy.sendTransactionAsync(assetProxyAddress, { from });
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
return tx;
}