From f6fcb775b74a98a66b5c75e567bd7e184c432bc6 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 13 Jul 2018 17:22:35 +0200 Subject: Upgrade tslint to use prefer-readonly --- packages/contract-wrappers/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/contract-wrappers') diff --git a/packages/contract-wrappers/package.json b/packages/contract-wrappers/package.json index b8fd8bd50..cf4286e1b 100644 --- a/packages/contract-wrappers/package.json +++ b/packages/contract-wrappers/package.json @@ -69,7 +69,7 @@ "shx": "^0.2.2", "sinon": "^4.0.0", "source-map-support": "^0.5.0", - "tslint": "5.8.0", + "tslint": "5.10.0", "typescript": "2.7.1", "web3-provider-engine": "14.0.6" }, -- cgit v1.2.3 From 7b6cc14b71094b0b55353400ed3a383b135605a6 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 13 Jul 2018 17:37:33 +0200 Subject: Make getZRXAssetData not async --- .../contract-wrappers/src/contract_wrappers/exchange_wrapper.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'packages/contract-wrappers') diff --git a/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts index 8b7148aed..abe373dcf 100644 --- a/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts @@ -1,4 +1,5 @@ import { schemas } from '@0xproject/json-schemas'; +import { assetProxyUtils } from '@0xproject/order-utils'; import { AssetProxyId, Order, SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; @@ -1068,9 +1069,9 @@ export class ExchangeWrapper extends ContractWrapper { * Returns the ZRX asset data used by the exchange contract. * @return ZRX asset data */ - public async getZRXAssetDataAsync(): Promise { - const exchangeInstance = await this._getExchangeContractAsync(); - const zrxAssetData = exchangeInstance.ZRX_ASSET_DATA.callAsync(); + public getZRXAssetData(): string { + const zrxTokenAddress = this.getZRXTokenAddress(); + const zrxAssetData = assetProxyUtils.encodeERC20AssetData(zrxTokenAddress); return zrxAssetData; } // tslint:disable:no-unused-variable -- cgit v1.2.3 From 39de9c78798669bb38c389f4380f5ee748cdb6c3 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 13 Jul 2018 17:38:02 +0200 Subject: Export forgotten stuff from contract-wrappers --- packages/contract-wrappers/src/index.ts | 15 ++++++++++++--- packages/contract-wrappers/test/exchange_wrapper_test.ts | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'packages/contract-wrappers') diff --git a/packages/contract-wrappers/src/index.ts b/packages/contract-wrappers/src/index.ts index d8e597ed1..e5485d7a6 100644 --- a/packages/contract-wrappers/src/index.ts +++ b/packages/contract-wrappers/src/index.ts @@ -1,9 +1,9 @@ export { ContractWrappers } from './contract_wrappers'; export { ERC20TokenWrapper } from './contract_wrappers/erc20_token_wrapper'; +export { ERC721TokenWrapper } from './contract_wrappers/erc721_token_wrapper'; export { EtherTokenWrapper } from './contract_wrappers/ether_token_wrapper'; -export { ERC20ProxyWrapper } from './contract_wrappers/erc20_proxy_wrapper'; export { ExchangeWrapper } from './contract_wrappers/exchange_wrapper'; -export { ERC721TokenWrapper } from './contract_wrappers/erc721_token_wrapper'; +export { ERC20ProxyWrapper } from './contract_wrappers/erc20_proxy_wrapper'; export { ERC721ProxyWrapper } from './contract_wrappers/erc721_proxy_wrapper'; export { @@ -26,7 +26,15 @@ export { OrderInfo, } from './types'; -export { Order, SignedOrder, ECSignature, OrderStateValid, OrderStateInvalid, OrderState } from '@0xproject/types'; +export { + Order, + SignedOrder, + ECSignature, + OrderStateValid, + OrderStateInvalid, + OrderState, + AssetProxyId, +} from '@0xproject/types'; export { BlockParamLiteral, @@ -60,6 +68,7 @@ export { ERC721TokenApprovalForAllEventArgs, ERC721TokenTransferEventArgs, ERC721TokenEvents, + ERC721TokenEventArgs, } from './contract_wrappers/generated/erc721_token'; export { diff --git a/packages/contract-wrappers/test/exchange_wrapper_test.ts b/packages/contract-wrappers/test/exchange_wrapper_test.ts index b2c716008..33da19aee 100644 --- a/packages/contract-wrappers/test/exchange_wrapper_test.ts +++ b/packages/contract-wrappers/test/exchange_wrapper_test.ts @@ -264,8 +264,8 @@ describe('ExchangeWrapper', () => { }); }); describe('#getZRXAssetData', () => { - it('should get the asset data', async () => { - const ZRX_ASSET_DATA = await contractWrappers.exchange.getZRXAssetDataAsync(); + it('should get the asset data', () => { + const ZRX_ASSET_DATA = contractWrappers.exchange.getZRXAssetData(); const ASSET_DATA_HEX_LENGTH = 74; expect(ZRX_ASSET_DATA).to.have.length(ASSET_DATA_HEX_LENGTH); }); -- cgit v1.2.3 From c71781d9abf7f2654a51dbef95bd18200ea2bde1 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 18 Jul 2018 15:37:34 +0200 Subject: Merge --- .../src/contract_wrappers/erc721_token_wrapper.ts | 20 +++++++++++--------- .../contract-wrappers/test/exchange_wrapper_test.ts | 4 ++-- 2 files changed, 13 insertions(+), 11 deletions(-) (limited to 'packages/contract-wrappers') diff --git a/packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts index 3d24702b3..7c2b41c62 100644 --- a/packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts @@ -342,15 +342,17 @@ export class ERC721TokenWrapper extends ContractWrapper { const normalizedSenderAddress = senderAddress.toLowerCase(); const tokenContract = await this._getTokenContractAsync(normalizedTokenAddress); const ownerAddress = await this.getOwnerOfAsync(tokenAddress, tokenId); - const isApprovedForAll = await this.isApprovedForAllAsync( - normalizedTokenAddress, - ownerAddress, - normalizedSenderAddress, - ); - if (!isApprovedForAll) { - const approvedAddress = await this.getApprovedIfExistsAsync(normalizedTokenAddress, tokenId); - if (approvedAddress !== senderAddress) { - throw new Error(ContractWrappersError.ERC721NoApproval); + if (normalizedSenderAddress !== ownerAddress) { + const isApprovedForAll = await this.isApprovedForAllAsync( + normalizedTokenAddress, + ownerAddress, + normalizedSenderAddress, + ); + if (!isApprovedForAll) { + const approvedAddress = await this.getApprovedIfExistsAsync(normalizedTokenAddress, tokenId); + if (approvedAddress !== normalizedSenderAddress) { + throw new Error(ContractWrappersError.ERC721NoApproval); + } } } const txHash = await tokenContract.transferFrom.sendTransactionAsync( diff --git a/packages/contract-wrappers/test/exchange_wrapper_test.ts b/packages/contract-wrappers/test/exchange_wrapper_test.ts index 33da19aee..44f8a5680 100644 --- a/packages/contract-wrappers/test/exchange_wrapper_test.ts +++ b/packages/contract-wrappers/test/exchange_wrapper_test.ts @@ -53,7 +53,6 @@ describe('ExchangeWrapper', () => { await blockchainLifecycle.startAsync(); contractWrappers = new ContractWrappers(provider, config); exchangeContractAddress = contractWrappers.exchange.getContractAddress(); - const erc20ProxyAddress = contractWrappers.erc20Proxy.getContractAddress(); userAddresses = await web3Wrapper.getAvailableAddressesAsync(); zrxTokenAddress = tokenUtils.getProtocolTokenAddress(); fillScenarios = new FillScenarios( @@ -61,7 +60,8 @@ describe('ExchangeWrapper', () => { userAddresses, zrxTokenAddress, exchangeContractAddress, - erc20ProxyAddress, + contractWrappers.erc20Proxy.getContractAddress(), + contractWrappers.erc721Proxy.getContractAddress(), ); [coinbase, makerAddress, takerAddress, feeRecipient, anotherMakerAddress] = userAddresses; [makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses(); -- cgit v1.2.3 From a1acf19ff3c1948214dde05a91eb3fbeac728d2c Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Wed, 18 Jul 2018 15:48:23 +0200 Subject: Fix a bad merge --- packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'packages/contract-wrappers') diff --git a/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts index b5ea56789..3e7619228 100644 --- a/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/exchange_wrapper.ts @@ -1,5 +1,5 @@ import { schemas } from '@0xproject/json-schemas'; -import { assetProxyUtils } from '@0xproject/order-utils'; +import { assetDataUtils } from '@0xproject/order-utils'; import { AssetProxyId, Order, SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; @@ -1074,7 +1074,7 @@ export class ExchangeWrapper extends ContractWrapper { */ public getZRXAssetData(): string { const zrxTokenAddress = this.getZRXTokenAddress(); - const zrxAssetData = assetProxyUtils.encodeERC20AssetData(zrxTokenAddress); + const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxTokenAddress); return zrxAssetData; } // tslint:disable:no-unused-variable -- cgit v1.2.3