From ded250e6a5886c469aaa57e35cc8b87b87cb929a Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 14 Nov 2016 03:54:51 +0100 Subject: [PATCH] fix insufficient funds message (#4768) We now distinguish the case where the wallet knows the exchange already and the case where we don't have anything in common. --- src/pages/confirm-contract.tsx | 39 +++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/src/pages/confirm-contract.tsx b/src/pages/confirm-contract.tsx index 7bae691b1..2beac08f6 100644 --- a/src/pages/confirm-contract.tsx +++ b/src/pages/confirm-contract.tsx @@ -32,12 +32,12 @@ import {getExchanges} from "src/wxApi"; interface DetailState { collapsed: boolean; - exchanges: null|IExchangeInfo[]; } interface DetailProps { contract: Contract collapsed: boolean + exchanges: null|IExchangeInfo[]; } @@ -47,17 +47,9 @@ class Details extends React.Component { console.log("new Details component created"); this.state = { collapsed: props.collapsed, - exchanges: null }; console.log("initial state:", this.state); - - this.update(); - } - - async update() { - let exchanges = await getExchanges(); - this.setState({exchanges} as any); } render() { @@ -85,7 +77,7 @@ class Details extends React.Component { Exchanges in the wallet:
    - {(this.state.exchanges || []).map( + {(this.props.exchanges || []).map( (e: IExchangeInfo) =>
  • {`${e.baseUrl}: ${e.masterPublicKey}`}
  • )}
@@ -100,18 +92,20 @@ interface ContractPromptProps { } interface ContractPromptState { - offer: any; + offer: Offer|null; error: string|null; payDisabled: boolean; + exchanges: null|IExchangeInfo[]; } class ContractPrompt extends React.Component { constructor() { super(); this.state = { - offer: undefined, + offer: null, error: null, payDisabled: true, + exchanges: null } } @@ -127,6 +121,8 @@ class ContractPrompt extends React.Component { @@ -155,7 +151,20 @@ class ContractPrompt extends React.Component e.master_pub); + let ex = this.state.exchanges.find((e) => acceptedExchangePubs.indexOf(e.masterPublicKey) >= 0); + if (ex) { + this.state.error = msgInsufficient; + } else { + this.state.error = msgNoMatch; + } + } else { + this.state.error = msgInsufficient; + } break; default: this.state.error = `Error: ${resp.error}`; @@ -188,7 +197,7 @@ class ContractPrompt extends React.Component {(this.state.error ?

{this.state.error}

:

)} -

+
); }