diff options
Diffstat (limited to 'lib/wallet/wallet.ts')
-rw-r--r-- | lib/wallet/wallet.ts | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/lib/wallet/wallet.ts b/lib/wallet/wallet.ts index 7cb30c358..209c7a253 100644 --- a/lib/wallet/wallet.ts +++ b/lib/wallet/wallet.ts @@ -154,12 +154,12 @@ interface Transaction { export interface Badge { setText(s: string): void; setColor(c: string): void; - startBusy(); - stopBusy(); + startBusy(): void; + stopBusy(): void; } -function deepEquals(x, y) { +function deepEquals(x: any, y: any): boolean { if (x === y) { return true; } @@ -179,7 +179,7 @@ function flatMap<T, U>(xs: T[], f: (x: T) => U[]): U[] { } -function getTalerStampSec(stamp: string): number { +function getTalerStampSec(stamp: string): number|null { const m = stamp.match(/\/?Date\(([0-9]*)\)\/?/); if (!m) { return null; @@ -188,7 +188,7 @@ function getTalerStampSec(stamp: string): number { } -function setTimeout(f, t) { +function setTimeout(f: any, t: number) { return chrome.extension.getBackgroundPage().setTimeout(f, t); } @@ -211,13 +211,13 @@ interface HttpRequestLibrary { get(url: string|uri.URI): Promise<HttpResponse>; - postJson(url: string|uri.URI, body): Promise<HttpResponse>; + postJson(url: string|uri.URI, body: any): Promise<HttpResponse>; - postForm(url: string|uri.URI, form): Promise<HttpResponse>; + postForm(url: string|uri.URI, form: any): Promise<HttpResponse>; } -function copy(o) { +function copy(o: any) { return JSON.parse(JSON.stringify(o)); } @@ -240,7 +240,7 @@ interface KeyUpdateInfo { function getWithdrawDenomList(amountAvailable: AmountJson, denoms: Denomination[]): Denomination[] { let remaining = Amounts.copy(amountAvailable); - let ds: Denomination[] = []; + const ds: Denomination[] = []; console.log("available denoms"); console.log(denoms); @@ -362,7 +362,7 @@ export class Wallet { let x: number; - function storeExchangeCoin(mc, url) { + function storeExchangeCoin(mc: any, url: string) { let exchange: IExchangeInfo = mc[0]; console.log("got coin for exchange", url); let coin: Coin = mc[1]; @@ -471,7 +471,7 @@ export class Wallet { private recordConfirmPay(offer: Offer, payCoinInfo: PayCoinInfo, chosenExchange: string): Promise<void> { - let payReq = {}; + let payReq: any = {}; payReq["amount"] = offer.contract.amount; payReq["coins"] = payCoinInfo.map((x) => x.sig); payReq["H_contract"] = offer.H_contract; @@ -588,7 +588,7 @@ export class Wallet { * Retrieve all necessary information for looking up the contract * with the given hash. */ - executePayment(H_contract): Promise<any> { + executePayment(H_contract: string): Promise<any> { return Promise.resolve().then(() => { return Query(this.db) .get("transactions", H_contract) @@ -614,7 +614,7 @@ export class Wallet { * First fetch information requred to withdraw from the reserve, * then deplete the reserve, withdrawing coins until it is empty. */ - private processReserve(reserveRecord): void { + private processReserve(reserveRecord: any): void { let retryDelayMs = 100; const opId = "reserve-" + reserveRecord.reserve_pub; this.startOperation(opId); @@ -644,7 +644,7 @@ export class Wallet { } - private processPreCoin(preCoin, retryDelayMs = 100): void { + private processPreCoin(preCoin: any, retryDelayMs = 100): void { this.withdrawExecute(preCoin) .then((c) => this.storeCoin(c)) .catch((e) => { @@ -810,7 +810,7 @@ export class Wallet { /** * Withdraw coins from a reserve until it is empty. */ - private depleteReserve(reserve, exchange: IExchangeInfo): Promise<void> { + private depleteReserve(reserve: any, exchange: IExchangeInfo): Promise<void> { let denomsAvailable: Denomination[] = copy(exchange.active_denoms); let denomsForWithdraw = getWithdrawDenomList(reserve.current_amount, denomsAvailable); @@ -919,7 +919,7 @@ export class Wallet { * Optionally link the reserve entry to the new or existing * exchange entry in then DB. */ - updateExchangeFromUrl(baseUrl): Promise<IExchangeInfo> { + updateExchangeFromUrl(baseUrl: string): Promise<IExchangeInfo> { baseUrl = canonicalizeBaseUrl(baseUrl); let reqUrl = URI("keys").absoluteTo(baseUrl); return this.http.get(reqUrl).then((resp) => { @@ -934,8 +934,8 @@ export class Wallet { private updateExchangeFromJson(baseUrl: string, exchangeKeysJson: KeysJson): Promise<IExchangeInfo> { - let updateTimeSec = getTalerStampSec(exchangeKeysJson.list_issue_date); - if (!updateTimeSec) { + const updateTimeSec = getTalerStampSec(exchangeKeysJson.list_issue_date); + if (updateTimeSec === null) { throw Error("invalid update time"); } @@ -973,9 +973,9 @@ export class Wallet { {indexName: "exchangeBaseUrl", only: baseUrl}) .reduce((coin: Coin, suspendedCoins: Coin[]) => { if (!updatedExchangeInfo.active_denoms.find((c) => c.denom_pub == coin.denomPub)) { - return [].concat(suspendedCoins, [coin]); + return Array.prototype.concat(suspendedCoins, [coin]); } - return [].concat(suspendedCoins); + return Array.prototype.concat(suspendedCoins); }, []) .then((suspendedCoins: Coin[]) => { let q = Query(this.db); @@ -1006,8 +1006,8 @@ export class Wallet { let found = false; for (let oldDenom of exchangeInfo.all_denoms) { if (oldDenom.denom_pub === newDenom.denom_pub) { - let a = Object.assign({}, oldDenom); - let b = Object.assign({}, newDenom); + let a: any = Object.assign({}, oldDenom); + let b: any = Object.assign({}, newDenom); // pub hash is only there for convenience in the wallet delete a["pub_hash"]; delete b["pub_hash"]; @@ -1055,7 +1055,7 @@ export class Wallet { * that is currenctly available for spending in the wallet. */ getBalances(): Promise<any> { - function collectBalances(c: Coin, byCurrency) { + function collectBalances(c: Coin, byCurrency: any) { if (c.suspended) { return byCurrency; } @@ -1081,7 +1081,7 @@ export class Wallet { * Retrive the full event history for this wallet. */ getHistory(): Promise<any> { - function collect(x, acc) { + function collect(x: any, acc: any) { acc.push(x); return acc; } @@ -1106,7 +1106,7 @@ export class Wallet { [contract.merchant_pub, contract.repurchase_correlation_id]) .then((result: Transaction) => { console.log("db result", result); - let isRepurchase; + let isRepurchase: boolean; if (result) { console.assert(result.contract.repurchase_correlation_id == contract.repurchase_correlation_id); return { |