Fix contract interact (#1233)

* reduce unintended side effects from empty units

* Fix contract interaction "to" address being empty

* Fix tsc errors
This commit is contained in:
HenryNguyen5 2018-03-02 16:57:17 -05:00 committed by Daniel Ternyak
parent 86992e8198
commit 4dd0fc9785
4 changed files with 16 additions and 6 deletions

View File

@ -10,7 +10,8 @@ import {
getNonceRequested,
TGetNonceRequested,
reset,
TReset
TReset,
ResetAction
} from 'actions/transaction';
import { fetchCCRatesRequested, TFetchCCRatesRequested } from 'actions/rates';
import { getNetworkConfig, getOffline } from 'selectors/config';
@ -44,6 +45,7 @@ interface DefaultProps {
}
interface OwnProps {
resetIncludeExcludeProperties?: ResetAction['payload'];
initialState?: SliderStates;
disableToggle?: boolean;
advancedGasOptions?: AdvancedOptions;
@ -69,7 +71,7 @@ class TXMetaDataPanel extends React.Component<Props, State> {
public componentDidMount() {
if (!this.props.offline) {
this.props.reset();
this.props.reset(this.props.resetIncludeExcludeProperties);
this.props.fetchCCRates([this.props.network.unit]);
this.props.getNonceRequested();
}

View File

@ -17,7 +17,7 @@ import {
resetWallet,
TResetWallet
} from 'actions/wallet';
import { reset, TReset } from 'actions/transaction';
import { reset, TReset, ResetAction } from 'actions/transaction';
import translate from 'translations';
import {
KeystoreDecrypt,
@ -55,6 +55,7 @@ interface OwnProps {
hidden?: boolean;
disabledWallets?: DisabledWallets;
showGenerateLink?: boolean;
resetIncludeExcludeProperties?: ResetAction['payload'];
}
interface DispatchProps {
@ -430,7 +431,7 @@ export class WalletDecrypt extends Component<Props, State> {
// the payload to contain the unlocked wallet info.
const unlockValue = value && !isEmpty(value) ? value : payload;
this.WALLETS[selectedWalletKey].unlock(unlockValue);
this.props.resetTransactionState();
this.props.resetTransactionState(this.props.resetIncludeExcludeProperties);
};
private isWalletDisabled = (walletKey: WalletName) => {

View File

@ -7,6 +7,7 @@ import { FullWalletOnly } from 'components/renderCbs';
interface OwnProps {
button: React.ReactElement<any>;
}
export class Fields extends Component<OwnProps> {
public render() {
const makeContent = () => (
@ -17,6 +18,7 @@ export class Fields extends Component<OwnProps> {
initialState="advanced"
disableToggle={true}
advancedGasOptions={{ dataField: false }}
resetIncludeExcludeProperties={{ exclude: { fields: ['to'] }, include: {} }}
/>
{this.props.button}
<SigningStatus />
@ -24,7 +26,12 @@ export class Fields extends Component<OwnProps> {
</React.Fragment>
);
const makeDecrypt = () => <WalletDecrypt disabledWallets={DISABLE_WALLETS.READ_ONLY} />;
const makeDecrypt = () => (
<WalletDecrypt
disabledWallets={DISABLE_WALLETS.READ_ONLY}
resetIncludeExcludeProperties={{ exclude: { fields: ['to'] }, include: {} }}
/>
);
return <FullWalletOnly withFullWallet={makeContent} withoutFullWallet={makeDecrypt} />;
}

View File

@ -32,7 +32,7 @@ export function* handleSetUnitMeta({ payload: currentUnit }: SetUnitMetaAction):
const tokenToToken = !currUnit && !prevUnit;
const decimal: number = yield select(getDecimalFromUnit, currentUnit);
if (etherToEther) {
if (etherToEther || previousUnit === '') {
return;
}