aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/util
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-11-02 09:24:32 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-11-03 01:57:24 +0800
commit5e66cc8a40759658a8763f85996163e5ae013fcd (patch)
treeea397e40f9c438c8598538f00d3ef0c8bb02e237 /packages/instant/src/util
parent4fda2a2d049843db7f87b930321c11c910e40ea3 (diff)
downloaddexon-sol-tools-5e66cc8a40759658a8763f85996163e5ae013fcd.tar.gz
dexon-sol-tools-5e66cc8a40759658a8763f85996163e5ae013fcd.tar.zst
dexon-sol-tools-5e66cc8a40759658a8763f85996163e5ae013fcd.zip
feat(instant): implement affiliateFeeInfo 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}`,
+ );
+ },
};