better error messages on redeem

This commit is contained in:
Andrea Franz 2020-05-13 15:52:58 +02:00
parent c09de707e6
commit 38eb174fe1
No known key found for this signature in database
GPG Key ID: 4F0D2F2D9DE7F29D
4 changed files with 8 additions and 9 deletions

1
.gitignore vendored
View File

@ -4,5 +4,6 @@ config/livenet/password
config/production/password config/production/password
coverage coverage
dist dist
build
embarkArtifacts embarkArtifacts
node_modules node_modules

View File

@ -1,5 +1,4 @@
import { RootState } from '../reducers'; import { RootState } from '../reducers';
import IERC20Detailed from '../embarkArtifacts/contracts/IERC20Detailed';
import { config } from "../config"; import { config } from "../config";
import { Dispatch } from 'redux'; import { Dispatch } from 'redux';
import { newBucketContract } from "./bucket"; import { newBucketContract } from "./bucket";
@ -126,7 +125,9 @@ export const redeem = (bucketAddress: string, recipientAddress: string, cleanCod
} }
//FIXME: remove! hack to wait for the request screen to slide down //FIXME: remove! hack to wait for the request screen to slide down
await sleep(3000); if (state.web3.type === Web3Type.Status) {
await sleep(3000);
}
const redeem = bucket.methods.redeem(message, sig); const redeem = bucket.methods.redeem(message, sig);
// const gas = await redeem.estimateGas(); // const gas = await redeem.estimateGas();
@ -136,14 +137,12 @@ export const redeem = (bucketAddress: string, recipientAddress: string, cleanCod
}).then((resp: any) => { }).then((resp: any) => {
dispatch(redeemDone(resp.transactionHash)); dispatch(redeemDone(resp.transactionHash));
}).catch((err: any) => { }).catch((err: any) => {
console.error("redeem error: ", err.reason); dispatch(redeemError(err.reason || err.message || err))
console.error("redeem error reason: ", err);
dispatch(redeemError(err.reason))
}); });
}).catch((err: any) => { }).catch((err: any) => {
console.error("sign redeem error reason:", err.reason); console.error("sign redeem error reason:", err.reason);
console.error("sign redeem error:", err); console.error("sign redeem error:", err);
dispatch(redeemError(err)) dispatch(redeemError(err.reason || err.message || err))
}); });
} }
} }

View File

@ -8,7 +8,6 @@ import {
} from 'react-redux'; } from 'react-redux';
import { redeemPath } from '../config'; import { redeemPath } from '../config';
import { import {
Token,
TokenERC20, TokenERC20,
TokenNFT, TokenNFT,
loadRedeemable, loadRedeemable,
@ -129,7 +128,7 @@ export default function(ownProps: any) {
{token.metadata !== undefined && <> {token.metadata !== undefined && <>
Name: {token.metadata.name}<br /> Name: {token.metadata.name}<br />
Description: {token.metadata.description}<br /> Description: {token.metadata.description}<br />
<img src={token.metadata.image} /> <img src={token.metadata.image} alt={token.metadata.name} />
</>} </>}
</>}<br /> </>}<br />
</> </>

View File

@ -1,4 +1,4 @@
import React, { useEffect } from 'react'; import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import thunkMiddleware from 'redux-thunk'; import thunkMiddleware from 'redux-thunk';
import { Provider } from 'react-redux'; import { Provider } from 'react-redux';