aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-12-01 08:13:35 +0800
committerAmir Bandeali <abandeali1@gmail.com>2019-01-08 02:31:11 +0800
commit19e93440b39161e8b1ecb79f29548faae1be4b1b (patch)
tree874621887722ea375963cabdf401f751b7ba10ea /packages
parent0cb5209266b979bcee094f3863efca0a1fa63697 (diff)
downloaddexon-sol-tools-19e93440b39161e8b1ecb79f29548faae1be4b1b.tar
dexon-sol-tools-19e93440b39161e8b1ecb79f29548faae1be4b1b.tar.gz
dexon-sol-tools-19e93440b39161e8b1ecb79f29548faae1be4b1b.tar.bz2
dexon-sol-tools-19e93440b39161e8b1ecb79f29548faae1be4b1b.tar.lz
dexon-sol-tools-19e93440b39161e8b1ecb79f29548faae1be4b1b.tar.xz
dexon-sol-tools-19e93440b39161e8b1ecb79f29548faae1be4b1b.tar.zst
dexon-sol-tools-19e93440b39161e8b1ecb79f29548faae1be4b1b.zip
fix: Add error message if assetProxyId is not ERC20 or ERC721
Diffstat (limited to 'packages')
-rw-r--r--packages/fill-scenarios/CHANGELOG.json9
-rw-r--r--packages/fill-scenarios/src/fill_scenarios.ts25
2 files changed, 27 insertions, 7 deletions
diff --git a/packages/fill-scenarios/CHANGELOG.json b/packages/fill-scenarios/CHANGELOG.json
index ca256399a..176267df9 100644
--- a/packages/fill-scenarios/CHANGELOG.json
+++ b/packages/fill-scenarios/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "version": "1.0.17",
+ "changes": [
+ {
+ "note": "Add error message if assetProxyId is not ERC20 or ERC721",
+ "pr": 1363
+ }
+ ]
+ },
+ {
"version": "1.0.16",
"changes": [
{
diff --git a/packages/fill-scenarios/src/fill_scenarios.ts b/packages/fill-scenarios/src/fill_scenarios.ts
index 0154bcd0a..e08c6ae5f 100644
--- a/packages/fill-scenarios/src/fill_scenarios.ts
+++ b/packages/fill-scenarios/src/fill_scenarios.ts
@@ -2,7 +2,14 @@ import { DummyERC20TokenContract, DummyERC721TokenContract, ExchangeContract } f
import * as artifacts from '@0x/contract-artifacts';
import { assetDataUtils } from '@0x/order-utils';
import { orderFactory } from '@0x/order-utils/lib/src/order_factory';
-import { AssetProxyId, ERC721AssetData, OrderWithoutExchangeAddress, SignedOrder } from '@0x/types';
+import {
+ AssetData,
+ AssetProxyId,
+ ERC20AssetData,
+ ERC721AssetData,
+ OrderWithoutExchangeAddress,
+ SignedOrder,
+} from '@0x/types';
import { BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
import { Provider } from 'ethereum-types';
@@ -153,35 +160,39 @@ export class FillScenarios {
const decodedMakerAssetData = assetDataUtils.decodeAssetDataOrThrow(makerAssetData);
if (decodedMakerAssetData.assetProxyId === AssetProxyId.ERC20) {
await this._increaseERC20BalanceAndAllowanceAsync(
- decodedMakerAssetData.tokenAddress,
+ (decodedMakerAssetData as ERC20AssetData).tokenAddress,
makerAddress,
makerFillableAmount,
);
- } else {
+ } else if (decodedMakerAssetData.assetProxyId === AssetProxyId.ERC721) {
if (!makerFillableAmount.equals(1)) {
throw new Error(`ERC721 makerFillableAmount should be equal 1. Found: ${makerFillableAmount}`);
}
await this._increaseERC721BalanceAndAllowanceAsync(
- decodedMakerAssetData.tokenAddress,
+ (decodedMakerAssetData as ERC721AssetData).tokenAddress,
makerAddress,
// tslint:disable-next-line:no-unnecessary-type-assertion
(decodedMakerAssetData as ERC721AssetData).tokenId,
);
+ } else {
+ throw new Error(`Proxy with id ${decodedMakerAssetData.assetProxyId} not supported`);
}
const decodedTakerAssetData = assetDataUtils.decodeAssetDataOrThrow(takerAssetData);
if (decodedTakerAssetData.assetProxyId === AssetProxyId.ERC20) {
- const takerTokenAddress = decodedTakerAssetData.tokenAddress;
+ const takerTokenAddress = (decodedTakerAssetData as ERC20AssetData).tokenAddress;
await this._increaseERC20BalanceAndAllowanceAsync(takerTokenAddress, takerAddress, takerFillableAmount);
- } else {
+ } else if (decodedTakerAssetData.assetProxyId === AssetProxyId.ERC721) {
if (!takerFillableAmount.equals(1)) {
throw new Error(`ERC721 takerFillableAmount should be equal 1. Found: ${takerFillableAmount}`);
}
await this._increaseERC721BalanceAndAllowanceAsync(
- decodedTakerAssetData.tokenAddress,
+ (decodedTakerAssetData as ERC721AssetData).tokenAddress,
takerAddress,
// tslint:disable-next-line:no-unnecessary-type-assertion
(decodedMakerAssetData as ERC721AssetData).tokenId,
);
+ } else {
+ throw new Error(`Proxy with id ${decodedTakerAssetData.assetProxyId} not supported`);
}
// Fees
await Promise.all([