aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test/asset_proxy_dispatcher
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-04-17 09:12:13 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-04-21 04:56:18 +0800
commit3b7068e8d0cb5c77af41f175571ea968d104187e (patch)
tree0fae2991402a27dcaaf50e0cf944807e0185b396 /packages/contracts/test/asset_proxy_dispatcher
parent2a8fc705c766f4c8a290d4e5836615b8566a1b82 (diff)
downloaddexon-0x-contracts-3b7068e8d0cb5c77af41f175571ea968d104187e.tar.gz
dexon-0x-contracts-3b7068e8d0cb5c77af41f175571ea968d104187e.tar.zst
dexon-0x-contracts-3b7068e8d0cb5c77af41f175571ea968d104187e.zip
renaming after tokenTransferProxy was removed
Diffstat (limited to 'packages/contracts/test/asset_proxy_dispatcher')
-rw-r--r--packages/contracts/test/asset_proxy_dispatcher/dispatcher.ts68
-rw-r--r--packages/contracts/test/asset_proxy_dispatcher/proxies.ts78
2 files changed, 73 insertions, 73 deletions
diff --git a/packages/contracts/test/asset_proxy_dispatcher/dispatcher.ts b/packages/contracts/test/asset_proxy_dispatcher/dispatcher.ts
index 103bce10d..8445483d8 100644
--- a/packages/contracts/test/asset_proxy_dispatcher/dispatcher.ts
+++ b/packages/contracts/test/asset_proxy_dispatcher/dispatcher.ts
@@ -33,8 +33,8 @@ describe('AssetProxyDispatcher', () => {
let zrx: DummyTokenContract;
let dmyBalances: Balances;
let assetProxyDispatcher: AssetProxyDispatcherContract;
- let erc20TransferProxy: ERC20ProxyContract;
- let erc721TransferProxy: ERC721ProxyContract;
+ let erc20Proxy: ERC20ProxyContract;
+ let erc721Proxy: ERC721ProxyContract;
const INITIAL_BALANCE = new BigNumber(10000);
before(async () => {
@@ -56,23 +56,23 @@ describe('AssetProxyDispatcher', () => {
from: owner,
});
// Deploy ERC20 Proxy
- const erc20TransferProxyInstance = await deployer.deployAsync(ContractName.ERC20Proxy);
- erc20TransferProxy = new ERC20ProxyContract(
- erc20TransferProxyInstance.abi,
- erc20TransferProxyInstance.address,
+ const erc20ProxyInstance = await deployer.deployAsync(ContractName.ERC20Proxy);
+ erc20Proxy = new ERC20ProxyContract(
+ erc20ProxyInstance.abi,
+ erc20ProxyInstance.address,
provider,
);
- await erc20TransferProxy.addAuthorizedAddress.sendTransactionAsync(assetProxyDispatcher.address, {
+ await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(assetProxyDispatcher.address, {
from: owner,
});
// Deploy ERC721 Proxy
- const erc721TransferProxyInstance = await deployer.deployAsync(ContractName.ERC721Proxy);
- erc721TransferProxy = new ERC721ProxyContract(
- erc721TransferProxyInstance.abi,
- erc721TransferProxyInstance.address,
+ const erc721ProxyInstance = await deployer.deployAsync(ContractName.ERC721Proxy);
+ erc721Proxy = new ERC721ProxyContract(
+ erc721ProxyInstance.abi,
+ erc721ProxyInstance.address,
provider,
);
- await erc721TransferProxy.addAuthorizedAddress.sendTransactionAsync(assetProxyDispatcher.address, {
+ await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(assetProxyDispatcher.address, {
from: owner,
});
// Deploy zrx and set initial balances
@@ -81,10 +81,10 @@ describe('AssetProxyDispatcher', () => {
await zrx.setBalance.sendTransactionAsync(makerAddress, INITIAL_BALANCE, { from: tokenOwner });
await zrx.setBalance.sendTransactionAsync(takerAddress, INITIAL_BALANCE, { from: tokenOwner });
dmyBalances = new Balances([zrx], [makerAddress, takerAddress]);
- await zrx.approve.sendTransactionAsync(erc20TransferProxy.address, INITIAL_BALANCE, {
+ await zrx.approve.sendTransactionAsync(erc20Proxy.address, INITIAL_BALANCE, {
from: takerAddress,
});
- await zrx.approve.sendTransactionAsync(erc20TransferProxy.address, INITIAL_BALANCE, {
+ await zrx.approve.sendTransactionAsync(erc20Proxy.address, INITIAL_BALANCE, {
from: makerAddress,
});
});
@@ -98,45 +98,45 @@ describe('AssetProxyDispatcher', () => {
it('should record proxy upon registration', async () => {
await assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
AssetProxyId.ERC20,
- erc20TransferProxy.address,
+ erc20Proxy.address,
ZeroEx.NULL_ADDRESS,
{ from: owner },
);
const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
- expect(proxyAddress).to.be.equal(erc20TransferProxy.address);
+ expect(proxyAddress).to.be.equal(erc20Proxy.address);
});
it('should be able to record multiple proxies', async () => {
// Record first proxy
await assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
AssetProxyId.ERC20,
- erc20TransferProxy.address,
+ erc20Proxy.address,
ZeroEx.NULL_ADDRESS,
{ from: owner },
);
let proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
- expect(proxyAddress).to.be.equal(erc20TransferProxy.address);
+ expect(proxyAddress).to.be.equal(erc20Proxy.address);
// Record another proxy
await assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
AssetProxyId.ERC721,
- erc721TransferProxy.address,
+ erc721Proxy.address,
ZeroEx.NULL_ADDRESS,
{ from: owner },
);
proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC721);
- expect(proxyAddress).to.be.equal(erc721TransferProxy.address);
+ expect(proxyAddress).to.be.equal(erc721Proxy.address);
});
it('should replace proxy address upon re-registration', async () => {
// Initial registration
await assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
AssetProxyId.ERC20,
- erc20TransferProxy.address,
+ erc20Proxy.address,
ZeroEx.NULL_ADDRESS,
{ from: owner },
);
let proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
- expect(proxyAddress).to.be.equal(erc20TransferProxy.address);
+ expect(proxyAddress).to.be.equal(erc20Proxy.address);
// Deploy a new version of the ERC20 Transfer Proxy contract
const newErc20TransferProxyInstance = await deployer.deployAsync(ContractName.ERC20Proxy);
const newErc20TransferProxy = new ERC20ProxyContract(
@@ -146,7 +146,7 @@ describe('AssetProxyDispatcher', () => {
);
// Register new ERC20 Transfer Proxy contract
const newAddress = newErc20TransferProxy.address;
- const currentAddress = erc20TransferProxy.address;
+ const currentAddress = erc20Proxy.address;
await assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
AssetProxyId.ERC20,
newAddress,
@@ -162,17 +162,17 @@ describe('AssetProxyDispatcher', () => {
// Initial registration
await assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
AssetProxyId.ERC20,
- erc20TransferProxy.address,
+ erc20Proxy.address,
ZeroEx.NULL_ADDRESS,
{ from: owner },
);
const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
- expect(proxyAddress).to.be.equal(erc20TransferProxy.address);
+ 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(
AssetProxyId.ERC20,
- erc20TransferProxy.address,
+ erc20Proxy.address,
ZeroEx.NULL_ADDRESS,
{ from: owner },
),
@@ -183,17 +183,17 @@ describe('AssetProxyDispatcher', () => {
// Initial registration
await assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
AssetProxyId.ERC20,
- erc20TransferProxy.address,
+ erc20Proxy.address,
ZeroEx.NULL_ADDRESS,
{ from: owner },
);
const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
- expect(proxyAddress).to.be.equal(erc20TransferProxy.address);
+ expect(proxyAddress).to.be.equal(erc20Proxy.address);
// The following transaction will reset the proxy address
await assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
AssetProxyId.ERC20,
ZeroEx.NULL_ADDRESS,
- erc20TransferProxy.address,
+ erc20Proxy.address,
{ from: owner },
);
const newProxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
@@ -204,7 +204,7 @@ describe('AssetProxyDispatcher', () => {
return expect(
assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
AssetProxyId.ERC20,
- erc20TransferProxy.address,
+ erc20Proxy.address,
ZeroEx.NULL_ADDRESS,
{ from: notOwner },
),
@@ -216,12 +216,12 @@ describe('AssetProxyDispatcher', () => {
it('should return correct address of registered proxy', async () => {
await assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
AssetProxyId.ERC20,
- erc20TransferProxy.address,
+ erc20Proxy.address,
ZeroEx.NULL_ADDRESS,
{ from: owner },
);
const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
- expect(proxyAddress).to.be.equal(erc20TransferProxy.address);
+ expect(proxyAddress).to.be.equal(erc20Proxy.address);
});
it('should return NULL address if requesting non-existent proxy', async () => {
@@ -235,7 +235,7 @@ describe('AssetProxyDispatcher', () => {
// Register ERC20 proxy
await assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
AssetProxyId.ERC20,
- erc20TransferProxy.address,
+ erc20Proxy.address,
ZeroEx.NULL_ADDRESS,
{ from: owner },
);
@@ -282,7 +282,7 @@ describe('AssetProxyDispatcher', () => {
// Register ERC20 proxy
await assetProxyDispatcher.addAssetProxy.sendTransactionAsync(
AssetProxyId.ERC20,
- erc20TransferProxy.address,
+ erc20Proxy.address,
ZeroEx.NULL_ADDRESS,
{ from: owner },
);
diff --git a/packages/contracts/test/asset_proxy_dispatcher/proxies.ts b/packages/contracts/test/asset_proxy_dispatcher/proxies.ts
index b7adf5a7e..b405cc37d 100644
--- a/packages/contracts/test/asset_proxy_dispatcher/proxies.ts
+++ b/packages/contracts/test/asset_proxy_dispatcher/proxies.ts
@@ -32,8 +32,8 @@ describe('Asset Transfer Proxies', () => {
let zrx: DummyTokenContract;
let erc721Token: DummyERC721TokenContract;
let dmyBalances: Balances;
- let erc20TransferProxy: ERC20ProxyContract;
- let erc721TransferProxy: ERC721ProxyContract;
+ let erc20Proxy: ERC20ProxyContract;
+ let erc721Proxy: ERC721ProxyContract;
const makerTokenId = new BigNumber('0x1010101010101010101010101010101010101010101010101010101010101010');
const testAddressPaddedWithZeros = '0x0000000000000000056000000000000000000010';
const INITIAL_BALANCE = new BigNumber(10000);
@@ -47,23 +47,23 @@ describe('Asset Transfer Proxies', () => {
makerAddress = accounts[3];
takerAddress = accounts[4];
// Deploy ERC20 Proxy
- const erc20TransferProxyInstance = await deployer.deployAsync(ContractName.ERC20Proxy);
- erc20TransferProxy = new ERC20ProxyContract(
- erc20TransferProxyInstance.abi,
- erc20TransferProxyInstance.address,
+ const erc20ProxyInstance = await deployer.deployAsync(ContractName.ERC20Proxy);
+ erc20Proxy = new ERC20ProxyContract(
+ erc20ProxyInstance.abi,
+ erc20ProxyInstance.address,
provider,
);
- await erc20TransferProxy.addAuthorizedAddress.sendTransactionAsync(assetProxyDispatcherAddress, {
+ await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(assetProxyDispatcherAddress, {
from: owner,
});
// Deploy ERC721 Proxy
- const erc721TransferProxyInstance = await deployer.deployAsync(ContractName.ERC721Proxy);
- erc721TransferProxy = new ERC721ProxyContract(
- erc721TransferProxyInstance.abi,
- erc721TransferProxyInstance.address,
+ const erc721ProxyInstance = await deployer.deployAsync(ContractName.ERC721Proxy);
+ erc721Proxy = new ERC721ProxyContract(
+ erc721ProxyInstance.abi,
+ erc721ProxyInstance.address,
provider,
);
- await erc721TransferProxy.addAuthorizedAddress.sendTransactionAsync(assetProxyDispatcherAddress, {
+ await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(assetProxyDispatcherAddress, {
from: owner,
});
// Deploy zrx and set initial balances
@@ -72,10 +72,10 @@ describe('Asset Transfer Proxies', () => {
await zrx.setBalance.sendTransactionAsync(makerAddress, INITIAL_BALANCE, { from: tokenOwner });
await zrx.setBalance.sendTransactionAsync(takerAddress, INITIAL_BALANCE, { from: tokenOwner });
dmyBalances = new Balances([zrx], [makerAddress, takerAddress]);
- await zrx.approve.sendTransactionAsync(erc20TransferProxy.address, INITIAL_BALANCE, {
+ await zrx.approve.sendTransactionAsync(erc20Proxy.address, INITIAL_BALANCE, {
from: takerAddress,
});
- await zrx.approve.sendTransactionAsync(erc20TransferProxy.address, INITIAL_BALANCE, {
+ await zrx.approve.sendTransactionAsync(erc20Proxy.address, INITIAL_BALANCE, {
from: makerAddress,
});
// Deploy erc721Token and set initial balances
@@ -84,10 +84,10 @@ describe('Asset Transfer Proxies', () => {
constants.DUMMY_ERC721TOKEN_ARGS,
);
erc721Token = new DummyERC721TokenContract(erc721TokenInstance.abi, erc721TokenInstance.address, provider);
- await erc721Token.setApprovalForAll.sendTransactionAsync(erc721TransferProxy.address, true, {
+ await erc721Token.setApprovalForAll.sendTransactionAsync(erc721Proxy.address, true, {
from: makerAddress,
});
- await erc721Token.setApprovalForAll.sendTransactionAsync(erc721TransferProxy.address, true, {
+ await erc721Token.setApprovalForAll.sendTransactionAsync(erc721Proxy.address, true, {
from: takerAddress,
});
await erc721Token.mint.sendTransactionAsync(makerAddress, makerTokenId, { from: tokenOwner });
@@ -100,29 +100,29 @@ describe('Asset Transfer Proxies', () => {
});
describe('Transfer Proxy - ERC20', () => {
it('should successfully encode/decode metadata', async () => {
- const metadata = await erc20TransferProxy.encodeMetadata.callAsync(AssetProxyId.ERC20, zrx.address);
- const address = await erc20TransferProxy.decodeMetadata.callAsync(metadata);
+ const metadata = await erc20Proxy.encodeMetadata.callAsync(AssetProxyId.ERC20, zrx.address);
+ const address = await erc20Proxy.decodeMetadata.callAsync(metadata);
expect(address).to.be.equal(zrx.address);
});
it('should successfully decode metadata encoded by typescript helpers', async () => {
const metadata = encodeERC20ProxyData(zrx.address);
- const address = await erc20TransferProxy.decodeMetadata.callAsync(metadata);
+ const address = await erc20Proxy.decodeMetadata.callAsync(metadata);
expect(address).to.be.equal(zrx.address);
});
it('should successfully encode/decode metadata padded with zeros', async () => {
- const metadata = await erc20TransferProxy.encodeMetadata.callAsync(
+ const metadata = await erc20Proxy.encodeMetadata.callAsync(
AssetProxyId.ERC20,
testAddressPaddedWithZeros,
);
- const address = await erc20TransferProxy.decodeMetadata.callAsync(metadata);
+ const address = await erc20Proxy.decodeMetadata.callAsync(metadata);
expect(address).to.be.equal(testAddressPaddedWithZeros);
});
it('should successfully decode metadata encoded padded with zeros by typescript helpers', async () => {
const metadata = encodeERC20ProxyData(testAddressPaddedWithZeros);
- const address = await erc20TransferProxy.decodeMetadata.callAsync(metadata);
+ const address = await erc20Proxy.decodeMetadata.callAsync(metadata);
expect(address).to.be.equal(testAddressPaddedWithZeros);
});
@@ -132,7 +132,7 @@ describe('Asset Transfer Proxies', () => {
// Perform a transfer from makerAddress to takerAddress
const balances = await dmyBalances.getAsync();
const amount = new BigNumber(10);
- await erc20TransferProxy.transferFrom.sendTransactionAsync(
+ await erc20Proxy.transferFrom.sendTransactionAsync(
encodedProxyMetadata,
makerAddress,
takerAddress,
@@ -155,7 +155,7 @@ describe('Asset Transfer Proxies', () => {
// Perform a transfer from makerAddress to takerAddress
const balances = await dmyBalances.getAsync();
const amount = new BigNumber(0);
- await erc20TransferProxy.transferFrom.sendTransactionAsync(
+ await erc20Proxy.transferFrom.sendTransactionAsync(
encodedProxyMetadata,
makerAddress,
takerAddress,
@@ -174,12 +174,12 @@ describe('Asset Transfer Proxies', () => {
// Create allowance less than transfer amount. Set allowance on proxy.
const allowance = new BigNumber(0);
const transferAmount = new BigNumber(10);
- await zrx.approve.sendTransactionAsync(erc20TransferProxy.address, allowance, {
+ await zrx.approve.sendTransactionAsync(erc20Proxy.address, allowance, {
from: makerAddress,
});
// Perform a transfer; expect this to fail.
return expect(
- erc20TransferProxy.transferFrom.sendTransactionAsync(
+ erc20Proxy.transferFrom.sendTransactionAsync(
encodedProxyMetadata,
makerAddress,
takerAddress,
@@ -195,7 +195,7 @@ describe('Asset Transfer Proxies', () => {
// Perform a transfer from makerAddress to takerAddress
const amount = new BigNumber(10);
return expect(
- erc20TransferProxy.transferFrom.sendTransactionAsync(
+ erc20Proxy.transferFrom.sendTransactionAsync(
encodedProxyMetadata,
makerAddress,
takerAddress,
@@ -208,37 +208,37 @@ describe('Asset Transfer Proxies', () => {
describe('Transfer Proxy - ERC721', () => {
it('should successfully encode/decode metadata', async () => {
- const metadata = await erc721TransferProxy.encodeMetadata.callAsync(
+ const metadata = await erc721Proxy.encodeMetadata.callAsync(
AssetProxyId.ERC721,
erc721Token.address,
makerTokenId,
);
- const [address, tokenId] = await erc721TransferProxy.decodeMetadata.callAsync(metadata);
+ const [address, tokenId] = await erc721Proxy.decodeMetadata.callAsync(metadata);
expect(address).to.be.equal(erc721Token.address);
expect(tokenId).to.be.bignumber.equal(makerTokenId);
});
it('should successfully decode metadata encoded by typescript helpers', async () => {
const metadata = encodeERC721ProxyData(erc721Token.address, makerTokenId);
- const [address, tokenId] = await erc721TransferProxy.decodeMetadata.callAsync(metadata);
+ const [address, tokenId] = await erc721Proxy.decodeMetadata.callAsync(metadata);
expect(address).to.be.equal(erc721Token.address);
expect(tokenId).to.be.bignumber.equal(makerTokenId);
});
it('should successfully encode/decode metadata padded with zeros', async () => {
- const metadata = await erc721TransferProxy.encodeMetadata.callAsync(
+ const metadata = await erc721Proxy.encodeMetadata.callAsync(
AssetProxyId.ERC721,
testAddressPaddedWithZeros,
makerTokenId,
);
- const [address, tokenId] = await erc721TransferProxy.decodeMetadata.callAsync(metadata);
+ const [address, tokenId] = await erc721Proxy.decodeMetadata.callAsync(metadata);
expect(address).to.be.equal(testAddressPaddedWithZeros);
expect(tokenId).to.be.bignumber.equal(makerTokenId);
});
it('should successfully decode metadata encoded padded with zeros by typescript helpers', async () => {
const metadata = encodeERC721ProxyData(testAddressPaddedWithZeros, makerTokenId);
- const [address, tokenId] = await erc721TransferProxy.decodeMetadata.callAsync(metadata);
+ const [address, tokenId] = await erc721Proxy.decodeMetadata.callAsync(metadata);
expect(address).to.be.equal(testAddressPaddedWithZeros);
expect(tokenId).to.be.bignumber.equal(makerTokenId);
});
@@ -252,7 +252,7 @@ describe('Asset Transfer Proxies', () => {
// Perform a transfer from makerAddress to takerAddress
const balances = await dmyBalances.getAsync();
const amount = new BigNumber(1);
- await erc721TransferProxy.transferFrom.sendTransactionAsync(
+ await erc721Proxy.transferFrom.sendTransactionAsync(
encodedProxyMetadata,
makerAddress,
takerAddress,
@@ -274,7 +274,7 @@ describe('Asset Transfer Proxies', () => {
const balances = await dmyBalances.getAsync();
const amount = new BigNumber(0);
return expect(
- erc721TransferProxy.transferFrom.sendTransactionAsync(
+ erc721Proxy.transferFrom.sendTransactionAsync(
encodedProxyMetadata,
makerAddress,
takerAddress,
@@ -294,7 +294,7 @@ describe('Asset Transfer Proxies', () => {
const balances = await dmyBalances.getAsync();
const amount = new BigNumber(500);
return expect(
- erc721TransferProxy.transferFrom.sendTransactionAsync(
+ erc721Proxy.transferFrom.sendTransactionAsync(
encodedProxyMetadata,
makerAddress,
takerAddress,
@@ -308,13 +308,13 @@ describe('Asset Transfer Proxies', () => {
// Construct metadata for ERC721 proxy
const encodedProxyMetadata = encodeERC721ProxyData(erc721Token.address, makerTokenId);
// Remove transfer approval for makerAddress.
- await erc721Token.setApprovalForAll.sendTransactionAsync(erc721TransferProxy.address, false, {
+ await erc721Token.setApprovalForAll.sendTransactionAsync(erc721Proxy.address, false, {
from: makerAddress,
});
// Perform a transfer; expect this to fail.
const amount = new BigNumber(1);
return expect(
- erc20TransferProxy.transferFrom.sendTransactionAsync(
+ erc20Proxy.transferFrom.sendTransactionAsync(
encodedProxyMetadata,
makerAddress,
takerAddress,
@@ -330,7 +330,7 @@ describe('Asset Transfer Proxies', () => {
// Perform a transfer from makerAddress to takerAddress
const amount = new BigNumber(1);
return expect(
- erc721TransferProxy.transferFrom.sendTransactionAsync(
+ erc721Proxy.transferFrom.sendTransactionAsync(
encodedProxyMetadata,
makerAddress,
takerAddress,