Re-enable affiliate fee

This commit is contained in:
Jacob Evans 2019-11-19 16:38:12 +10:00
parent c81455c760
commit ab7689d188
No known key found for this signature in database
GPG Key ID: 2036DA2ADDFB0842
6 changed files with 23 additions and 8 deletions

View File

@ -97,7 +97,7 @@ export class BuyButton extends React.PureComponent<BuyButtonProps> {
let txHash: string | undefined; let txHash: string | undefined;
const gasInfo = await gasPriceEstimator.getGasInfoAsync(); const gasInfo = await gasPriceEstimator.getGasInfoAsync();
const feeRecipient = oc(affiliateInfo).feeRecipient(); const feeRecipient = oc(affiliateInfo).feeRecipient();
const feePercentage = oc(affiliateInfo).feeRecipient(); const feePercentage = oc(affiliateInfo).feePercentage();
try { try {
analytics.trackBuyStarted(swapQuote); analytics.trackBuyStarted(swapQuote);
txHash = await swapQuoteConsumer.executeSwapQuoteOrThrowAsync(swapQuote, { txHash = await swapQuoteConsumer.executeSwapQuoteOrThrowAsync(swapQuote, {
@ -125,6 +125,13 @@ export class BuyButton extends React.PureComponent<BuyButtonProps> {
return; return;
} }
} }
// HACK(dekz): Wrappers no longer include decorators which map errors
// like transaction deny
if (e.message && e.message.includes('User denied transaction signature')) {
analytics.trackBuySignatureDenied(swapQuote);
this.props.onSignatureDenied(swapQuote);
return;
}
throw e; throw e;
} }
const startTimeUnix = new Date().getTime(); const startTimeUnix = new Date().getTime();

View File

@ -163,8 +163,9 @@ class TokenSelectorRowIcon extends React.PureComponent<TokenSelectorRowIconProps
const displaySymbol = assetUtils.bestNameForAsset(token); const displaySymbol = assetUtils.bestNameForAsset(token);
if (iconUrlIfExists !== undefined) { if (iconUrlIfExists !== undefined) {
return <img src={iconUrlIfExists} />; return <img src={iconUrlIfExists} />;
} else if (TokenIcon !== undefined) { // HACK(dekz): Disale Token icon as it is throwing an error in React renderer
return <TokenIcon />; // } else if (TokenIcon !== undefined) {
// return <TokenIcon />;
} else { } else {
return ( return (
<Text fontColor={ColorOption.white} fontSize="8px"> <Text fontColor={ColorOption.white} fontSize="8px">

View File

@ -85,6 +85,7 @@ export class ZeroExInstantProvider extends React.PureComponent<ZeroExInstantProv
), ),
assetMetaDataMap: completeAssetMetaDataMap, assetMetaDataMap: completeAssetMetaDataMap,
onSuccess: props.onSuccess, onSuccess: props.onSuccess,
affiliateInfo: props.affiliateInfo,
}; };
return storeStateFromProps; return storeStateFromProps;
} }
@ -139,7 +140,7 @@ export class ZeroExInstantProvider extends React.PureComponent<ZeroExInstantProv
state.providerState, state.providerState,
window, window,
state.selectedAsset, state.selectedAsset,
undefined, this.props.affiliateInfo,
state.baseCurrency, state.baseCurrency,
), ),
); );

View File

@ -48,10 +48,9 @@ const validateInstantRenderConfig = (config: ZeroExInstantConfig, selector: stri
if (config.zIndex !== undefined) { if (config.zIndex !== undefined) {
assert.isNumber('zIndex', config.zIndex); assert.isNumber('zIndex', config.zIndex);
} }
// TODO(dave4506) reenable affiliate fees once we figure out how to work with it if (config.affiliateInfo !== undefined) {
// if (config.affiliateInfo !== undefined) { assert.isValidAffiliateInfo('affiliateInfo', config.affiliateInfo);
// assert.isValidAffiliateInfo('affiliateInfo', config.affiliateInfo); }
// }
if (config.provider !== undefined) { if (config.provider !== undefined) {
providerUtils.standardizeOrThrow(config.provider); providerUtils.standardizeOrThrow(config.provider);
} }

View File

@ -291,6 +291,7 @@ const doesSwapQuoteMatchState = (swapQuote: MarketBuySwapQuote, state: State): b
selectedAssetMetaData.decimals, selectedAssetMetaData.decimals,
); );
const doesAssetAmountMatch = selectedAssetAmountBaseUnits.eq(swapQuote.makerAssetFillAmount); const doesAssetAmountMatch = selectedAssetAmountBaseUnits.eq(swapQuote.makerAssetFillAmount);
return doesAssetAmountMatch; return doesAssetAmountMatch;
} else { } else {
return true; return true;

View File

@ -192,6 +192,11 @@ export interface ZeroExInstantRequiredBaseConfig {
orderSource: OrderSource; orderSource: OrderSource;
} }
export interface AffiliateInfo {
feeRecipient: string;
feePercentage: number;
}
export interface ZeroExInstantOptionalBaseConfig { export interface ZeroExInstantOptionalBaseConfig {
provider: SupportedProvider; provider: SupportedProvider;
walletDisplayName: string; walletDisplayName: string;
@ -200,6 +205,7 @@ export interface ZeroExInstantOptionalBaseConfig {
defaultSelectedAssetData: string; defaultSelectedAssetData: string;
additionalAssetMetaDataMap: ObjectMap<AssetMetaData>; additionalAssetMetaDataMap: ObjectMap<AssetMetaData>;
networkId: Network; networkId: Network;
affiliateInfo: AffiliateInfo;
shouldDisableAnalyticsTracking: boolean; shouldDisableAnalyticsTracking: boolean;
onSuccess?: (txHash: string) => void; onSuccess?: (txHash: string) => void;
} }