aboutsummaryrefslogtreecommitdiffstats
path: root/packages/asset-buyer/src/utils/assert.ts
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-09-15 18:59:23 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-09-15 20:14:48 +0800
commitf1a22e9bd7943bc9cb8d8308daca0c60af6e0039 (patch)
tree91f3e8f54103156500518ad521816e6df409d1d1 /packages/asset-buyer/src/utils/assert.ts
parent7b46cef83dca0a743bd598a70076004983cbf294 (diff)
downloaddexon-sol-tools-f1a22e9bd7943bc9cb8d8308daca0c60af6e0039.tar
dexon-sol-tools-f1a22e9bd7943bc9cb8d8308daca0c60af6e0039.tar.gz
dexon-sol-tools-f1a22e9bd7943bc9cb8d8308daca0c60af6e0039.tar.bz2
dexon-sol-tools-f1a22e9bd7943bc9cb8d8308daca0c60af6e0039.tar.lz
dexon-sol-tools-f1a22e9bd7943bc9cb8d8308daca0c60af6e0039.tar.xz
dexon-sol-tools-f1a22e9bd7943bc9cb8d8308daca0c60af6e0039.tar.zst
dexon-sol-tools-f1a22e9bd7943bc9cb8d8308daca0c60af6e0039.zip
Flesh out the AssetBuyer class
Diffstat (limited to 'packages/asset-buyer/src/utils/assert.ts')
-rw-r--r--packages/asset-buyer/src/utils/assert.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/packages/asset-buyer/src/utils/assert.ts b/packages/asset-buyer/src/utils/assert.ts
new file mode 100644
index 000000000..c4d611477
--- /dev/null
+++ b/packages/asset-buyer/src/utils/assert.ts
@@ -0,0 +1,23 @@
+import { assert as sharedAssert } from '@0xproject/assert';
+import { schemas } from '@0xproject/json-schemas';
+import * as _ from 'lodash';
+
+import { BuyQuote, OrderFetcher } from '../types';
+
+export const assert = {
+ ...sharedAssert,
+ isValidBuyQuote(variableName: string, buyQuote: BuyQuote): void {
+ sharedAssert.isHexString(`${variableName}.assetData`, buyQuote.assetData);
+ sharedAssert.doesConformToSchema(`${variableName}.orders`, buyQuote.orders, schemas.signedOrdersSchema);
+ sharedAssert.doesConformToSchema(`${variableName}.feeOrders`, buyQuote.feeOrders, schemas.signedOrdersSchema);
+ sharedAssert.isBigNumber(`${variableName}.minRate`, buyQuote.minRate);
+ sharedAssert.isBigNumber(`${variableName}.maxRate`, buyQuote.maxRate);
+ sharedAssert.isBigNumber(`${variableName}.assetBuyAmount`, buyQuote.assetBuyAmount);
+ if (!_.isUndefined(buyQuote.feePercentage)) {
+ sharedAssert.isNumber(`${variableName}.feePercentage`, buyQuote.feePercentage);
+ }
+ },
+ isValidOrderFetcher(variableName: string, orderFetcher: OrderFetcher): void {
+ sharedAssert.isFunction(`${variableName}.fetchOrdersAsync`, orderFetcher.fetchOrdersAsync);
+ },
+};