fix: reset available tokens when sra endpoint is changed

This commit is contained in:
fragosti 2018-12-04 12:23:25 -08:00
parent b7d804e949
commit 36f22ba069
2 changed files with 8 additions and 3 deletions

View File

@ -48,6 +48,11 @@ export class ConfigGenerator extends React.Component<ConfigGeneratorProps, Confi
public componentDidUpdate(prevProps: ConfigGeneratorProps): void { public componentDidUpdate(prevProps: ConfigGeneratorProps): void {
if (prevProps.value.orderSource !== this.props.value.orderSource) { if (prevProps.value.orderSource !== this.props.value.orderSource) {
this._setAvailableAssetsFromOrderProvider(); this._setAvailableAssetsFromOrderProvider();
const newConfig: ZeroExInstantBaseConfig = {
...this.props.value,
availableAssetDatas: undefined,
};
this.props.onConfigChange(newConfig);
} }
} }
public render(): React.ReactNode { public render(): React.ReactNode {
@ -117,7 +122,7 @@ export class ConfigGenerator extends React.Component<ConfigGeneratorProps, Confi
}; };
this.props.onConfigChange(newConfig); this.props.onConfigChange(newConfig);
}; };
private readonly _handleAffiliateAddressChange = (address: string) => { private readonly _handleAffiliateAddressChange = (address: string, isValid: boolean) => {
const oldConfig: ZeroExInstantBaseConfig = this.props.value; const oldConfig: ZeroExInstantBaseConfig = this.props.value;
const newConfig: ZeroExInstantBaseConfig = { const newConfig: ZeroExInstantBaseConfig = {
...oldConfig, ...oldConfig,

View File

@ -9,7 +9,7 @@ import { Text } from 'ts/components/ui/text';
export interface ConfigGeneratorAddressInputProps { export interface ConfigGeneratorAddressInputProps {
value?: string; value?: string;
onChange?: (address: string) => void; onChange?: (address: string, isValid: boolean) => void;
} }
export interface ConfigGeneratorAddressInputState { export interface ConfigGeneratorAddressInputState {
@ -54,6 +54,6 @@ export class ConfigGeneratorAddressInput extends React.Component<
this.setState({ this.setState({
errMsg, errMsg,
}); });
this.props.onChange(address); this.props.onChange(address, isValidAddress);
}; };
} }