Merge pull request #270 from status-im/fix/infinite-loop

Fix infinite loop in the Sell page and add txHash to addOffer
This commit is contained in:
Jonathan Rainville 2019-05-24 15:02:02 -04:00 committed by GitHub
commit 9f1ee69cec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 11 deletions

View File

@ -142,7 +142,7 @@ module.exports = async (licensePrice, arbitrationLicensePrice, feeAmount, deps)
gas = await pay.estimateGas({from: buyerAddress});
receipt = await pay.send({from: buyerAddress, gas: gas + 1000});
const openCase = deps.contracts.Escrow.methods.openCase(escrowId);
const openCase = deps.contracts.Escrow.methods.openCase(escrowId, 'My Motive is...');
gas = await openCase.estimateGas({from: buyerAddress});
receipt = await openCase.send({from: buyerAddress, gas: gas + 1000});
}));

View File

@ -1,6 +1,6 @@
import {
LOAD_OFFERS_SUCCEEDED, LOAD_USER_SUCCEEDED,
ADD_OFFER, ADD_OFFER_SUCCEEDED, ADD_OFFER_FAILED, RESET_ADD_OFFER_STATUS,
ADD_OFFER, ADD_OFFER_SUCCEEDED, ADD_OFFER_FAILED, RESET_ADD_OFFER_STATUS, ADD_OFFER_PRE_SUCCESS,
UPDATE_USER, UPDATE_USER_SUCCEEDED, UPDATE_USER_FAILED, RESET_UPDATE_USER_STATUS,
LOAD_USER_LOCATION_SUCCEEDED, SET_CURRENT_USER, LOAD_USER_TRADE_NUMBER_SUCCEEDED
} from './constants';
@ -11,6 +11,7 @@ import {toChecksumAddress} from '../../utils/address';
const DEFAULT_STATE = {
addOfferStatus: States.none,
addOfferTx: '',
updateUserStatus: States.none,
users: {},
offers: {}
@ -30,11 +31,20 @@ function reducer(state = DEFAULT_STATE, action) {
switch (action.type) {
case RESET_ADD_OFFER_STATUS:
return {
...state, addOfferStatus: States.none
...state,
addOfferStatus: States.none,
addOfferTx: ''
};
case ADD_OFFER:
return {
...state, addOfferStatus: States.pending
...state,
addOfferStatus: States.pending,
addOfferTx: ''
};
case ADD_OFFER_PRE_SUCCESS:
return {
...state,
addOfferTx: action.txHash
};
case ADD_OFFER_SUCCEEDED: {
return {

View File

@ -62,3 +62,5 @@ export const getUsersWithOffers = (state) => {
};
export const getAllUsers = state => state.metadata.users;
export const getAddOfferTx = state => state.metadata.addOfferTx;

View File

@ -8,6 +8,7 @@ import {
SET_ARBITRATOR
} from './constants';
import {RESET_STATE, PURGE_STATE} from "../network/constants";
import {ADD_OFFER_SUCCEEDED} from '../metadata/constants';
const DEFAULT_STATE = {
asset: '',
@ -60,6 +61,7 @@ function reducer(state = DEFAULT_STATE, action) {
username: action.username,
statusContactCode: action.statusContactCode
};
case ADD_OFFER_SUCCEEDED:
case PURGE_STATE:
case RESET_STATE: {
return DEFAULT_STATE;

View File

@ -38,7 +38,7 @@ class Margin extends Component {
};
componentDidMount() {
if (!this.props.seller.currency) {
if (!this.props.seller.currency && this.props.addOfferStatus !== States.success) {
this.props.wizard.previous();
} else {
this.setState({ready: true});
@ -79,7 +79,7 @@ class Margin extends Component {
switch(this.props.addOfferStatus){
case States.pending:
return <Loading mining/>;
return <Loading mining txHash={this.props.txHash}/>;
case States.failed:
return <ErrorInformation transaction retry={this.postOffer} cancel={this.props.resetAddOfferStatus}/>;
case States.none:
@ -112,7 +112,8 @@ Margin.propTypes = {
wizard: PropTypes.object,
footer: PropTypes.object,
getFee: PropTypes.func,
fee: PropTypes.string
fee: PropTypes.string,
txHash: PropTypes.string
};
const mapStateToProps = state => ({
@ -120,7 +121,8 @@ const mapStateToProps = state => ({
addOfferStatus: metadata.selectors.getAddOfferStatus(state),
token: network.selectors.getTokenByAddress(state, newSeller.selectors.getNewSeller(state).asset),
prices: prices.selectors.getPrices(state),
fee: escrow.selectors.getFee(state)
fee: escrow.selectors.getFee(state),
txHash: metadata.selectors.getAddOfferTx(state)
});
export default connect(