[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-wallet-webex] branch master updated: add currencies
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-wallet-webex] branch master updated: add currencies and currency defaults to DB |
Date: |
Fri, 24 Mar 2017 16:59:36 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-webex.
The following commit(s) were added to refs/heads/master by this push:
new df87dc0 add currencies and currency defaults to DB
df87dc0 is described below
commit df87dc0242caab05cb27623edf000625d1a7f039
Author: Florian Dold <address@hidden>
AuthorDate: Fri Mar 24 16:59:23 2017 +0100
add currencies and currency defaults to DB
---
src/wallet.ts | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 67 insertions(+), 1 deletion(-)
diff --git a/src/wallet.ts b/src/wallet.ts
index 030e603..a2d9e2a 100644
--- a/src/wallet.ts
+++ b/src/wallet.ts
@@ -202,6 +202,38 @@ export interface NonceRecord {
pub: string;
}
+export interface AuditorRecord {
+ baseUrl: string;
+ auditorPub: string;
+ expirationStamp: number;
+}
+
+export interface CurrencyRecord {
+ name: string;
+ fractionalDigits: number;
+ auditors: AuditorRecord[];
+}
+
+export interface ConfigRecord {
+ key: string;
+ value: any;
+}
+
+
+const builtinCurrencies: CurrencyRecord[] = [
+ {
+ name: "KUDOS",
+ fractionalDigits: 2,
+ auditors: [
+ {
+ baseUrl: "https://auditor.demo.taler.net",
+ expirationStamp: (new Date(2027, 1)).getTime(),
+ auditorPub: "XN9KMN5G2KGPCAN0E89MM5HE8FV4WBWA9KDTMTDR817MWBCYA7H0",
+ },
+ ]
+ },
+];
+
function setTimeout(f: any, t: number) {
return chrome.extension.getBackgroundPage().setTimeout(f, t);
@@ -354,7 +386,7 @@ export namespace Stores {
class DenominationsStore extends Store<DenominationRecord> {
constructor() {
- // case needed because of bug in type annotations
+ // cast needed because of bug in type annotations
super("denominations",
{keyPath: ["exchangeBaseUrl", "denomPub"] as any as IDBKeyPath});
}
@@ -363,6 +395,18 @@ export namespace Stores {
denomPubIndex = new Index<string, DenominationRecord>(this, "denomPub",
"denomPub");
}
+ class CurrenciesStore extends Store<CurrencyRecord> {
+ constructor() {
+ super("currencies", {keyPath: "name"});
+ }
+ }
+
+ class ConfigStore extends Store<ConfigRecord> {
+ constructor() {
+ super("config", {keyPath: "key"});
+ }
+ }
+
export const exchanges: ExchangeStore = new ExchangeStore();
export const nonces: NonceStore = new NonceStore();
export const transactions: TransactionsStore = new TransactionsStore();
@@ -373,6 +417,8 @@ export namespace Stores {
export const offers: OffersStore = new OffersStore();
export const precoins: Store<PreCoinRecord> = new
Store<PreCoinRecord>("precoins", {keyPath: "coinPub"});
export const denominations: DenominationsStore = new DenominationsStore();
+ export const currencies: CurrenciesStore = new CurrenciesStore();
+ export const config: ConfigStore = new ConfigStore();
}
@@ -405,9 +451,29 @@ export class Wallet {
this.notifier = notifier;
this.cryptoApi = new CryptoApi();
+ this.fillDefaults();
this.resumePendingFromDb();
}
+ private async fillDefaults() {
+ let onTrue = (r: QueryRoot) => {
+ console.log("defaults already applied");
+ };
+ let onFalse = (r: QueryRoot) => {
+ console.log("applying defaults");
+ r.put(Stores.config, {key: "currencyDefaultsApplied", value: true})
+ .putAll(Stores.currencies, builtinCurrencies)
+ .finish();
+ };
+ await (
+ this.q()
+ .iter(Stores.config)
+ .filter(x => x.key == "currencyDefaultsApplied")
+ .first()
+ .cond((x) => x && x.value, onTrue, onFalse)
+ );
+ }
+
private startOperation(operationId: string) {
this.runningOperations.add(operationId);
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-wallet-webex] branch master updated: add currencies and currency defaults to DB,
gnunet <=