aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/util
diff options
context:
space:
mode:
authorBrandon Millman <brandon@0xproject.com>2018-11-03 03:43:53 +0800
committerGitHub <noreply@github.com>2018-11-03 03:43:53 +0800
commitec83a1d9e735573fe51df7a5854424c0ad4101fb (patch)
treef28def28bee9925daf8dd859b750c94c0cd83f98 /packages/instant/src/util
parente7e9c2a2ebf32ed96e859c9c50a5c9614e372bc7 (diff)
parentb895b855cbb555736be838e2630890ab6a69d884 (diff)
downloaddexon-sol-tools-ec83a1d9e735573fe51df7a5854424c0ad4101fb.tar
dexon-sol-tools-ec83a1d9e735573fe51df7a5854424c0ad4101fb.tar.gz
dexon-sol-tools-ec83a1d9e735573fe51df7a5854424c0ad4101fb.tar.bz2
dexon-sol-tools-ec83a1d9e735573fe51df7a5854424c0ad4101fb.tar.lz
dexon-sol-tools-ec83a1d9e735573fe51df7a5854424c0ad4101fb.tar.xz
dexon-sol-tools-ec83a1d9e735573fe51df7a5854424c0ad4101fb.tar.zst
dexon-sol-tools-ec83a1d9e735573fe51df7a5854424c0ad4101fb.zip
Merge pull request #1207 from 0xProject/feature/instant/affiliate-fee
[instant][asset-buyer] Implement affiliateInfo prop
Diffstat (limited to 'packages/instant/src/util')
-rw-r--r--packages/instant/src/util/assert.ts10
1 files changed, 9 insertions, 1 deletions
diff --git a/packages/instant/src/util/assert.ts b/packages/instant/src/util/assert.ts
index 584d3d4b1..20f8ddaee 100644
--- a/packages/instant/src/util/assert.ts
+++ b/packages/instant/src/util/assert.ts
@@ -4,7 +4,7 @@ import { assetDataUtils } from '@0x/order-utils';
import { AssetProxyId, ObjectMap, SignedOrder } from '@0x/types';
import * as _ from 'lodash';
-import { AssetMetaData } from '../types';
+import { AffiliateInfo, AssetMetaData } from '../types';
export const assert = {
...sharedAssert,
@@ -41,4 +41,12 @@ export const assert = {
assert.isUri(`${variableName}.imageUrl`, metaData.imageUrl);
}
},
+ isValidaffiliateInfo(variableName: string, affiliateInfo: AffiliateInfo): void {
+ assert.isETHAddressHex(`${variableName}.recipientAddress`, affiliateInfo.feeRecipient);
+ assert.isNumber(`${variableName}.percentage`, affiliateInfo.feePercentage);
+ assert.assert(
+ affiliateInfo.feePercentage >= 0 && affiliateInfo.feePercentage <= 0.05,
+ `Expected ${variableName}.percentage to be between 0 and 0.05, but is ${affiliateInfo.feePercentage}`,
+ );
+ },
};