implement currencies subcommand
This commit is contained in:
parent
4da4380480
commit
f4ec5b1a32
@ -22,7 +22,7 @@
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { TalerErrorDetails } from "./walletTypes";
|
||||
import { TalerErrorDetails } from "./walletTypes.js";
|
||||
|
||||
export enum NotificationType {
|
||||
CoinWithdrawn = "coin-withdrawn",
|
||||
|
@ -604,6 +604,19 @@ advancedCli
|
||||
});
|
||||
});
|
||||
|
||||
const currenciesCli = walletCli.subcommand("currencies", "currencies", {
|
||||
help: "Manage currencies.",
|
||||
});
|
||||
|
||||
currenciesCli
|
||||
.subcommand("show", "show", { help: "Show currencies."})
|
||||
.action(async (args) => {
|
||||
await withWallet(args, async (wallet) => {
|
||||
const currencies = await wallet.getCurrencies();
|
||||
console.log(JSON.stringify(currencies, undefined, 2));
|
||||
});
|
||||
})
|
||||
|
||||
const reservesCli = advancedCli.subcommand("reserves", "reserves", {
|
||||
help: "Manage reserves.",
|
||||
});
|
||||
|
@ -357,20 +357,41 @@ export interface AuditorRecord {
|
||||
expirationStamp: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exchange for currencies as stored in the wallet's currency
|
||||
* information database.
|
||||
*/
|
||||
export interface ExchangeForCurrencyRecord {
|
||||
|
||||
export interface AuditorTrustInfo {
|
||||
/**
|
||||
* FIXME: unused?
|
||||
* Base URL of the auditor.
|
||||
*/
|
||||
auditorBaseUrl: string;
|
||||
|
||||
/**
|
||||
* Public key of the auditor.
|
||||
*/
|
||||
auditorPub: string;
|
||||
|
||||
/**
|
||||
* UIDs for the operation of adding this auditor
|
||||
* as a trusted auditor.
|
||||
*/
|
||||
uids: string[];
|
||||
}
|
||||
|
||||
export interface ExchangeTrustInfo {
|
||||
/**
|
||||
* Canonicalized exchange base URL.
|
||||
*/
|
||||
exchangeBaseUrl: string;
|
||||
|
||||
/**
|
||||
* Master public key of the exchange.
|
||||
*/
|
||||
exchangeMasterPub: string;
|
||||
|
||||
/**
|
||||
* Base URL of the exchange.
|
||||
* UIDs for the operation of adding this exchange
|
||||
* as trusted.
|
||||
*/
|
||||
exchangeBaseUrl: string;
|
||||
uids: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -390,12 +411,12 @@ export interface CurrencyRecord {
|
||||
/**
|
||||
* Auditors that the wallet trusts for this currency.
|
||||
*/
|
||||
auditors: AuditorRecord[];
|
||||
auditors: AuditorTrustInfo[];
|
||||
|
||||
/**
|
||||
* Exchanges that the wallet trusts for this currency.
|
||||
*/
|
||||
exchanges: ExchangeForCurrencyRecord[];
|
||||
exchanges: ExchangeTrustInfo[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -175,6 +175,7 @@ export async function createReserve(
|
||||
currencyRecord.exchanges.push({
|
||||
exchangeBaseUrl: req.exchange,
|
||||
exchangeMasterPub: exchangeDetails.masterPublicKey,
|
||||
uids: [encodeCrock(getRandomBytes(32))],
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,11 @@
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import { BackupRecovery, codecForAny, TalerErrorCode } from "@gnu-taler/taler-util";
|
||||
import {
|
||||
BackupRecovery,
|
||||
codecForAny,
|
||||
TalerErrorCode,
|
||||
} from "@gnu-taler/taler-util";
|
||||
import { CryptoWorkerFactory } from "./crypto/workers/cryptoApi";
|
||||
import {
|
||||
addBackupProvider,
|
||||
@ -181,8 +185,8 @@ const builtinCurrencies: CurrencyRecord[] = [
|
||||
auditors: [
|
||||
{
|
||||
auditorPub: "BW9DC48PHQY4NH011SHHX36DZZ3Q22Y6X7FZ1VD1CMZ2PTFZ6PN0",
|
||||
baseUrl: "https://auditor.demo.taler.net/",
|
||||
expirationStamp: new Date(2027, 1).getTime(),
|
||||
auditorBaseUrl: "https://auditor.demo.taler.net/",
|
||||
uids: ["5P25XF8TVQP9AW6VYGY2KV47WT5Y3ZXFSJAA570GJPX5SVJXKBVG"],
|
||||
},
|
||||
],
|
||||
exchanges: [],
|
||||
@ -672,6 +676,7 @@ export class Wallet {
|
||||
return await this.db.iter(Stores.exchanges).toArray();
|
||||
}
|
||||
|
||||
|
||||
async getExchanges(): Promise<ExchangesListRespose> {
|
||||
const exchanges: (ExchangeListItem | undefined)[] = await this.db
|
||||
.iter(Stores.exchanges)
|
||||
|
Loading…
Reference in New Issue
Block a user