aboutsummaryrefslogtreecommitdiff
path: root/extension
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-02-22 23:31:21 +0100
committerFlorian Dold <florian.dold@gmail.com>2016-02-22 23:31:21 +0100
commit33abcfd4dcb7b11745e6c6fa6da1858943005708 (patch)
tree057fef38c9d983b7c31719a954525addd117cfa8 /extension
parent0ad69f120fbdd6df8e7e6e10e37b768907d29f7a (diff)
downloadwallet-core-33abcfd4dcb7b11745e6c6fa6da1858943005708.tar.xz
remove excessive logging
Diffstat (limited to 'extension')
-rw-r--r--extension/lib/wallet/types.ts86
-rw-r--r--extension/lib/wallet/wallet.ts10
2 files changed, 36 insertions, 60 deletions
diff --git a/extension/lib/wallet/types.ts b/extension/lib/wallet/types.ts
index 8151bf41a..88b55f918 100644
--- a/extension/lib/wallet/types.ts
+++ b/extension/lib/wallet/types.ts
@@ -175,30 +175,24 @@ export namespace Amounts {
}
export function add(first: AmountJson, ...rest: AmountJson[]): Result {
- const doit = () => {
- let currency = first.currency;
- let value = first.value + Math.floor(first.fraction / 1e6);
+ let currency = first.currency;
+ let value = first.value + Math.floor(first.fraction / 1e6);
+ if (value > Number.MAX_SAFE_INTEGER) {
+ return {amount: getMaxAmount(currency), saturated: true};
+ }
+ let fraction = first.fraction % 1e6;
+ for (let x of rest) {
+ if (x.currency !== currency) {
+ throw Error(`Mismatched currency: ${x.currency} and ${currency}`);
+ }
+
+ value = value + x.value + Math.floor((fraction + x.fraction) / 1e6);
+ fraction = (fraction + x.fraction) % 1e6;
if (value > Number.MAX_SAFE_INTEGER) {
return {amount: getMaxAmount(currency), saturated: true};
}
- let fraction = first.fraction % 1e6;
- for (let x of rest) {
- if (x.currency !== currency) {
- throw Error(`Mismatched currency: ${x.currency} and ${currency}`);
- }
-
- value = value + x.value + Math.floor((fraction + x.fraction) / 1e6);
- fraction = (fraction + x.fraction) % 1e6;
- if (value > Number.MAX_SAFE_INTEGER) {
- return {amount: getMaxAmount(currency), saturated: true};
- }
- }
- return {amount: {currency, value, fraction}, saturated: false};
- };
- console.log("adding", first, "and", rest);
- let ret = doit();
- console.log("result is", ret);
- return ret;
+ }
+ return {amount: {currency, value, fraction}, saturated: false};
}
@@ -226,35 +220,27 @@ export namespace Amounts {
}
export function cmp(a: AmountJson, b: AmountJson): number {
- const doit = () => {
- if (a.currency !== b.currency) {
- throw Error(`Mismatched currency: ${a.currency} and ${b.currency}`);
- }
- let av = a.value + Math.floor(a.fraction / 1e6);
- let af = a.fraction % 1e6;
- let bv = b.value + Math.floor(b.fraction / 1e6);
- let bf = b.fraction % 1e6;
- switch (true) {
- case av < bv:
- return -1;
- case av > bv:
- return 1;
- case af < bf:
- return -1;
- case af > bf:
- return 1;
- case af == bf:
- return 0;
- default:
- throw Error("assertion failed");
- }
- };
-
- console.log("comparing", a, "and", b);
- let res = doit();
- console.log("result:", res);
- return res;
-
+ if (a.currency !== b.currency) {
+ throw Error(`Mismatched currency: ${a.currency} and ${b.currency}`);
+ }
+ let av = a.value + Math.floor(a.fraction / 1e6);
+ let af = a.fraction % 1e6;
+ let bv = b.value + Math.floor(b.fraction / 1e6);
+ let bf = b.fraction % 1e6;
+ switch (true) {
+ case av < bv:
+ return -1;
+ case av > bv:
+ return 1;
+ case af < bf:
+ return -1;
+ case af > bf:
+ return 1;
+ case af == bf:
+ return 0;
+ default:
+ throw Error("assertion failed");
+ }
}
export function copy(a: AmountJson): AmountJson {
diff --git a/extension/lib/wallet/wallet.ts b/extension/lib/wallet/wallet.ts
index 76339fe5d..67e35bd11 100644
--- a/extension/lib/wallet/wallet.ts
+++ b/extension/lib/wallet/wallet.ts
@@ -356,10 +356,6 @@ function getWithdrawDenomList(amountAvailable: AmountJson,
denoms = denoms.filter(isWithdrawableDenom);
denoms.sort((d1, d2) => Amounts.cmp(d2.value, d1.value));
- console.log("ranked denoms");
- console.dir(denoms);
-
-
// This is an arbitrary number of coins
// we can withdraw in one go. It's not clear if this limit
// is useful ...
@@ -376,7 +372,6 @@ function getWithdrawDenomList(amountAvailable: AmountJson,
break;
}
if (!found) {
- console.log("did not find coins for remaining ", remaining);
break;
}
}
@@ -561,7 +556,6 @@ export class Wallet {
error: "coins-insufficient",
};
}
- console.log("about to record ...");
let mintUrl = Object.keys(mcs)[0];
return this.cryptoApi.signDeposit(offer, mcs[mintUrl])
@@ -848,8 +842,6 @@ export class Wallet {
.map((d: Denomination) => Amounts.add(d.value,
d.fee_withdraw).amount)
.reduce((a, b) => Amounts.add(a, b).amount);
- console.log("actual coin cost", actualCoinCost);
- console.log("amount", amount);
let ret: ReserveCreationInfo = {
mintInfo,
selectedDenoms,
@@ -877,8 +869,6 @@ export class Wallet {
return Query(this.db).get("mints", baseUrl).then((r) => {
let mintInfo;
-
- console.log("got mints result");
console.dir(r);
if (!r) {