Check if the token doesn't exist before minting in fill scenarios

This commit is contained in:
Leonid Logvinov
2018-07-17 15:56:10 +02:00
parent c59cd36da6
commit 2aa729b212
2 changed files with 10 additions and 3 deletions

View File

@@ -238,9 +238,16 @@ export class FillScenarios {
this._web3Wrapper.getProvider(),
this._web3Wrapper.getContractDefaults(),
);
try {
const currentOwner = await erc721Token.ownerOf.callAsync(tokenId);
if (currentOwner !== address) {
throw new Error(`Token ${tokenAddress}:${tokenId} is already owner by ${currentOwner}`);
}
} catch (err) {
const txHash = await erc721Token.mint.sendTransactionAsync(address, tokenId, { from: this._coinbase });
await this._web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
}
}
private async _increaseERC20BalanceAndAllowanceAsync(
tokenAddress: string,
address: string,

View File

@@ -155,7 +155,7 @@ export class OrderWatcher {
const orderAssetDatas = [signedOrder.makerAssetData, signedOrder.takerAssetData];
_.each(orderAssetDatas, assetData => {
const decodedAssetData = assetProxyUtils.decodeAssetData(assetData);
const decodedAssetData = assetProxyUtils.decodeAssetDataOrThrow(assetData);
if (decodedAssetData.assetProxyId === AssetProxyId.ERC20) {
this._collisionResistantAbiDecoder.addERC20Token(decodedAssetData.tokenAddress);
} else if (decodedAssetData.assetProxyId === AssetProxyId.ERC721) {