From e4cafe672d07781c4cfcfa3b9d0e062ce367646c Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 13 Oct 2016 02:36:33 +0200 Subject: [PATCH] manual refresh triggering --- lib/wallet/wallet.ts | 6 +++++- lib/wallet/wxApi.ts | 4 ++++ lib/wallet/wxMessaging.ts | 6 ++++++ pages/tree.tsx | 7 +++++-- popup/popup.tsx | 7 +++++-- 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 { export async function getPreCoins(exchangeBaseUrl: string): Promise { return await callBackend("get-precoins", { exchangeBaseUrl }); +} + +export async function refresh(coinPub: string): Promise { + 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 { return (
Refresh amount: - +
); 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 { } 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) { +