aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-10-13 02:36:33 +0200
committerFlorian Dold <florian.dold@gmail.com>2016-10-13 02:36:33 +0200
commite4cafe672d07781c4cfcfa3b9d0e062ce367646c (patch)
tree7ad8b213a898236dee02a140207af301e8d400e4
parent250069d86097a966366d21e447f6c3fcc70659bd (diff)
manual refresh triggering
-rw-r--r--lib/wallet/wallet.ts6
-rw-r--r--lib/wallet/wxApi.ts4
-rw-r--r--lib/wallet/wxMessaging.ts6
-rw-r--r--pages/tree.tsx7
-rw-r--r--popup/popup.tsx7
5 files changed, 25 insertions, 5 deletions
diff --git a/lib/wallet/wallet.ts b/lib/wallet/wallet.ts
index 49e4e0a8d..b248d5315 100644
--- a/lib/wallet/wallet.ts
+++ b/lib/wallet/wallet.ts
@@ -1136,8 +1136,12 @@ export class Wallet {
coin.currentAmount,
oldDenom.fee_refresh));
- // FIXME: implement rest
+ let reqUrl = URI("reserve/withdraw").absoluteTo(exchange!.baseUrl);
+ let resp = await this.http.postJson(reqUrl, {});
+
+ console.log("melt response:", resp.responseText);
+ // FIXME: implement rest
}
diff --git a/lib/wallet/wxApi.ts b/lib/wallet/wxApi.ts
index 12d11a387..9ed7aabd3 100644
--- a/lib/wallet/wxApi.ts
+++ b/lib/wallet/wxApi.ts
@@ -68,4 +68,8 @@ export async function getCoins(exchangeBaseUrl: string): Promise<Coin[]> {
export async function getPreCoins(exchangeBaseUrl: string): Promise<PreCoin[]> {
return await callBackend("get-precoins", { exchangeBaseUrl });
+}
+
+export async function refresh(coinPub: string): Promise<void> {
+ return await callBackend("refresh-coin", { coinPub });
} \ No newline at end of file
diff --git a/lib/wallet/wxMessaging.ts b/lib/wallet/wxMessaging.ts
index b1916b4bc..2c69afc99 100644
--- a/lib/wallet/wxMessaging.ts
+++ b/lib/wallet/wxMessaging.ts
@@ -204,6 +204,12 @@ function makeHandlers(db: IDBDatabase,
}
return wallet.getPreCoins(detail.exchangeBaseUrl);
},
+ ["refresh-coin"]: function (detail, sender) {
+ if (typeof detail.coinPub !== "string") {
+ return Promise.reject(Error("coinPub missing"));
+ }
+ return wallet.refresh(detail.coinPub);
+ },
["payment-failed"]: function (detail, sender) {
// For now we just update exchanges (maybe the exchange did something
// wrong and the keys were messed up).
diff --git a/pages/tree.tsx b/pages/tree.tsx
index ba5f787b4..0d1046b34 100644
--- a/pages/tree.tsx
+++ b/pages/tree.tsx
@@ -25,7 +25,10 @@
import { IExchangeInfo } from "../lib/wallet/types";
import { ReserveRecord, Coin, PreCoin, Denomination } from "../lib/wallet/types";
import { ImplicitStateComponent, StateHolder } from "../lib/components";
-import { getReserves, getExchanges, getCoins, getPreCoins } from "../lib/wallet/wxApi";
+import {
+ getReserves, getExchanges, getCoins, getPreCoins,
+ refresh
+} from "../lib/wallet/wxApi";
import { prettyAmount, abbrev } from "../lib/wallet/renderHtml";
interface ReserveViewProps {
@@ -101,7 +104,7 @@ class RefreshDialog extends ImplicitStateComponent<RefreshDialogProps> {
return (
<div>
Refresh amount: <input type="text" size={10} />
- <button>ok</button>
+ <button onClick={() => refresh(this.props.coin.coinPub)}>ok</button>
<button onClick={() => this.refreshRequested(false)}>cancel</button>
</div>
);
diff --git a/popup/popup.tsx b/popup/popup.tsx
index 5364b4170..ec9aee7f7 100644
--- a/popup/popup.tsx
+++ b/popup/popup.tsx
@@ -52,9 +52,9 @@ class Router extends preact.Component<any,any> {
}
static onRoute(f: any): () => void {
- this.routeHandlers.push(f);
+ Router.routeHandlers.push(f);
return () => {
- let i = this.routeHandlers.indexOf(f);
+ let i = Router.routeHandlers.indexOf(f);
this.routeHandlers = this.routeHandlers.splice(i, 1);
}
}
@@ -391,6 +391,9 @@ function WalletDebug(props: any) {
<button onClick={openExtensionPage("pages/show-db.html")}>
show db
</button>
+ <button onClick={openExtensionPage("pages/tree.html")}>
+ show tree
+ </button>
<br />
<button onClick={confirmReset}>
reset