aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-07-17 21:56:10 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-07-17 21:56:10 +0800
commit2aa729b21244a687b8403af351ed4c033ec42350 (patch)
tree9383b119d31b5d26b17cd46c04cfbab358cbe9b6
parentc59cd36da6d16ca89d99e9d44b0577e57a928b7f (diff)
downloaddexon-sol-tools-2aa729b21244a687b8403af351ed4c033ec42350.tar
dexon-sol-tools-2aa729b21244a687b8403af351ed4c033ec42350.tar.gz
dexon-sol-tools-2aa729b21244a687b8403af351ed4c033ec42350.tar.bz2
dexon-sol-tools-2aa729b21244a687b8403af351ed4c033ec42350.tar.lz
dexon-sol-tools-2aa729b21244a687b8403af351ed4c033ec42350.tar.xz
dexon-sol-tools-2aa729b21244a687b8403af351ed4c033ec42350.tar.zst
dexon-sol-tools-2aa729b21244a687b8403af351ed4c033ec42350.zip
Check if the token doesn't exist before minting in fill scenarios
-rw-r--r--packages/fill-scenarios/src/fill_scenarios.ts11
-rw-r--r--packages/order-watcher/src/order_watcher/order_watcher.ts2
2 files changed, 10 insertions, 3 deletions
diff --git a/packages/fill-scenarios/src/fill_scenarios.ts b/packages/fill-scenarios/src/fill_scenarios.ts
index 84c5fbc27..afe42fe32 100644
--- a/packages/fill-scenarios/src/fill_scenarios.ts
+++ b/packages/fill-scenarios/src/fill_scenarios.ts
@@ -238,8 +238,15 @@ export class FillScenarios {
this._web3Wrapper.getProvider(),
this._web3Wrapper.getContractDefaults(),
);
- const txHash = await erc721Token.mint.sendTransactionAsync(address, tokenId, { from: this._coinbase });
- await this._web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
+ 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,
diff --git a/packages/order-watcher/src/order_watcher/order_watcher.ts b/packages/order-watcher/src/order_watcher/order_watcher.ts
index 68ef9fab7..c43887b77 100644
--- a/packages/order-watcher/src/order_watcher/order_watcher.ts
+++ b/packages/order-watcher/src/order_watcher/order_watcher.ts
@@ -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) {